Lines Matching full:fs
3 * virtio-fs: Virtio Filesystem
7 #include <linux/fs.h>
28 /* List of virtio-fs device instances and a lock for the list. Also provides
56 /* A virtio-fs device instance */
144 struct virtio_fs *fs = vq->vdev->priv; in vq_to_fsvq() local
146 return &fs->vqs[vq->index]; in vq_to_fsvq()
173 static void virtio_fs_put(struct virtio_fs *fs) in virtio_fs_put() argument
175 kref_put(&fs->refcount, release_virtio_fs_obj); in virtio_fs_put()
208 static void virtio_fs_drain_all_queues_locked(struct virtio_fs *fs) in virtio_fs_drain_all_queues_locked() argument
213 for (i = 0; i < fs->nvqs; i++) { in virtio_fs_drain_all_queues_locked()
214 fsvq = &fs->vqs[i]; in virtio_fs_drain_all_queues_locked()
219 static void virtio_fs_drain_all_queues(struct virtio_fs *fs) in virtio_fs_drain_all_queues() argument
228 virtio_fs_drain_all_queues_locked(fs); in virtio_fs_drain_all_queues()
232 static void virtio_fs_start_all_queues(struct virtio_fs *fs) in virtio_fs_start_all_queues() argument
237 for (i = 0; i < fs->nvqs; i++) { in virtio_fs_start_all_queues()
238 fsvq = &fs->vqs[i]; in virtio_fs_start_all_queues()
246 static int virtio_fs_add_instance(struct virtio_fs *fs) in virtio_fs_add_instance() argument
254 if (strcmp(fs->tag, fs2->tag) == 0) in virtio_fs_add_instance()
259 list_add_tail(&fs->list, &virtio_fs_instances); in virtio_fs_add_instance()
271 struct virtio_fs *fs; in virtio_fs_find_instance() local
275 list_for_each_entry(fs, &virtio_fs_instances, list) { in virtio_fs_find_instance()
276 if (strcmp(fs->tag, tag) == 0) { in virtio_fs_find_instance()
277 kref_get(&fs->refcount); in virtio_fs_find_instance()
282 fs = NULL; /* not found */ in virtio_fs_find_instance()
287 return fs; in virtio_fs_find_instance()
290 static void virtio_fs_free_devs(struct virtio_fs *fs) in virtio_fs_free_devs() argument
294 for (i = 0; i < fs->nvqs; i++) { in virtio_fs_free_devs()
295 struct virtio_fs_vq *fsvq = &fs->vqs[i]; in virtio_fs_free_devs()
305 /* Read filesystem name from virtio config into fs->tag (must kfree()). */
306 static int virtio_fs_read_tag(struct virtio_device *vdev, struct virtio_fs *fs) in virtio_fs_read_tag() argument
321 fs->tag = devm_kmalloc(&vdev->dev, len + 1, GFP_KERNEL); in virtio_fs_read_tag()
322 if (!fs->tag) in virtio_fs_read_tag()
324 memcpy(fs->tag, tag_buf, len); in virtio_fs_read_tag()
325 fs->tag[len] = '\0'; in virtio_fs_read_tag()
359 pr_debug("virtio-fs: worker %s called.\n", __func__); in virtio_fs_request_dispatch_work()
400 pr_err("virtio-fs: virtio_fs_enqueue_req() failed %d\n", in virtio_fs_request_dispatch_work()
436 pr_debug("virtio-fs: Could not queue FORGET: err=%d. Will try later\n", in send_forget_request()
446 pr_debug("virtio-fs: Could not queue FORGET: err=%d. Dropping it.\n", in send_forget_request()
473 pr_debug("virtio-fs: worker %s called.\n", __func__); in virtio_fs_hiprio_dispatch_work()
684 struct virtio_fs *fs) in virtio_fs_setup_vqs() argument
693 &fs->num_request_queues); in virtio_fs_setup_vqs()
694 if (fs->num_request_queues == 0) in virtio_fs_setup_vqs()
697 fs->nvqs = VQ_REQUEST + fs->num_request_queues; in virtio_fs_setup_vqs()
698 fs->vqs = kcalloc(fs->nvqs, sizeof(fs->vqs[VQ_HIPRIO]), GFP_KERNEL); in virtio_fs_setup_vqs()
699 if (!fs->vqs) in virtio_fs_setup_vqs()
702 vqs = kmalloc_array(fs->nvqs, sizeof(vqs[VQ_HIPRIO]), GFP_KERNEL); in virtio_fs_setup_vqs()
703 callbacks = kmalloc_array(fs->nvqs, sizeof(callbacks[VQ_HIPRIO]), in virtio_fs_setup_vqs()
705 names = kmalloc_array(fs->nvqs, sizeof(names[VQ_HIPRIO]), GFP_KERNEL); in virtio_fs_setup_vqs()
713 virtio_fs_init_vq(&fs->vqs[VQ_HIPRIO], "hiprio", VQ_HIPRIO); in virtio_fs_setup_vqs()
714 names[VQ_HIPRIO] = fs->vqs[VQ_HIPRIO].name; in virtio_fs_setup_vqs()
717 for (i = VQ_REQUEST; i < fs->nvqs; i++) { in virtio_fs_setup_vqs()
721 virtio_fs_init_vq(&fs->vqs[i], vq_name, VQ_REQUEST); in virtio_fs_setup_vqs()
723 names[i] = fs->vqs[i].name; in virtio_fs_setup_vqs()
726 ret = virtio_find_vqs(vdev, fs->nvqs, vqs, callbacks, names, NULL); in virtio_fs_setup_vqs()
730 for (i = 0; i < fs->nvqs; i++) in virtio_fs_setup_vqs()
731 fs->vqs[i].vq = vqs[i]; in virtio_fs_setup_vqs()
733 virtio_fs_start_all_queues(fs); in virtio_fs_setup_vqs()
739 kfree(fs->vqs); in virtio_fs_setup_vqs()
757 struct virtio_fs *fs = dax_get_private(dax_dev); in virtio_fs_direct_access() local
759 size_t max_nr_pages = fs->window_len / PAGE_SIZE - pgoff; in virtio_fs_direct_access()
762 *kaddr = fs->window_kaddr + offset; in virtio_fs_direct_access()
764 *pfn = phys_to_pfn_t(fs->window_phys_addr + offset, in virtio_fs_direct_access()
797 static int virtio_fs_setup_dax(struct virtio_device *vdev, struct virtio_fs *fs) in virtio_fs_setup_dax() argument
841 fs->window_kaddr = devm_memremap_pages(&vdev->dev, pgmap); in virtio_fs_setup_dax()
842 if (IS_ERR(fs->window_kaddr)) in virtio_fs_setup_dax()
843 return PTR_ERR(fs->window_kaddr); in virtio_fs_setup_dax()
845 fs->window_phys_addr = (phys_addr_t) cache_reg.addr; in virtio_fs_setup_dax()
846 fs->window_len = (phys_addr_t) cache_reg.len; in virtio_fs_setup_dax()
849 __func__, fs->window_kaddr, cache_reg.addr, cache_reg.len); in virtio_fs_setup_dax()
851 fs->dax_dev = alloc_dax(fs, &virtio_fs_dax_ops); in virtio_fs_setup_dax()
852 if (IS_ERR(fs->dax_dev)) in virtio_fs_setup_dax()
853 return PTR_ERR(fs->dax_dev); in virtio_fs_setup_dax()
856 fs->dax_dev); in virtio_fs_setup_dax()
861 struct virtio_fs *fs; in virtio_fs_probe() local
864 fs = kzalloc(sizeof(*fs), GFP_KERNEL); in virtio_fs_probe()
865 if (!fs) in virtio_fs_probe()
867 kref_init(&fs->refcount); in virtio_fs_probe()
868 vdev->priv = fs; in virtio_fs_probe()
870 ret = virtio_fs_read_tag(vdev, fs); in virtio_fs_probe()
874 ret = virtio_fs_setup_vqs(vdev, fs); in virtio_fs_probe()
880 ret = virtio_fs_setup_dax(vdev, fs); in virtio_fs_probe()
889 ret = virtio_fs_add_instance(fs); in virtio_fs_probe()
898 kfree(fs->vqs); in virtio_fs_probe()
902 kfree(fs); in virtio_fs_probe()
906 static void virtio_fs_stop_all_queues(struct virtio_fs *fs) in virtio_fs_stop_all_queues() argument
911 for (i = 0; i < fs->nvqs; i++) { in virtio_fs_stop_all_queues()
912 fsvq = &fs->vqs[i]; in virtio_fs_stop_all_queues()
921 struct virtio_fs *fs = vdev->priv; in virtio_fs_remove() local
925 list_del_init(&fs->list); in virtio_fs_remove()
926 virtio_fs_stop_all_queues(fs); in virtio_fs_remove()
927 virtio_fs_drain_all_queues_locked(fs); in virtio_fs_remove()
933 virtio_fs_put(fs); in virtio_fs_remove()
941 pr_warn("virtio-fs: suspend/resume not yet supported\n"); in virtio_fs_freeze()
979 struct virtio_fs *fs; in virtio_fs_wake_forget_and_unlock() local
986 fs = fiq->priv; in virtio_fs_wake_forget_and_unlock()
987 fsvq = &fs->vqs[VQ_HIPRIO]; in virtio_fs_wake_forget_and_unlock()
1014 * Normal fs operations on a local filesystems aren't interruptible. in virtio_fs_wake_interrupt_and_unlock()
1227 struct virtio_fs *fs; in virtio_fs_wake_pending_and_unlock() local
1239 fs = fiq->priv; in virtio_fs_wake_pending_and_unlock()
1246 fsvq = &fs->vqs[queue_id]; in virtio_fs_wake_pending_and_unlock()
1263 pr_err("virtio-fs: virtio_fs_enqueue_req() failed %d\n", ret); in virtio_fs_wake_pending_and_unlock()
1297 struct virtio_fs *fs = fc->iq.priv; in virtio_fs_fill_super() local
1310 if (list_empty(&fs->list)) { in virtio_fs_fill_super()
1311 pr_info("virtio-fs: tag <%s> not found\n", fs->tag); in virtio_fs_fill_super()
1317 for (i = 0; i < fs->nvqs; i++) { in virtio_fs_fill_super()
1318 struct virtio_fs_vq *fsvq = &fs->vqs[i]; in virtio_fs_fill_super()
1328 if (ctx->dax_mode == FUSE_DAX_ALWAYS && !fs->dax_dev) { in virtio_fs_fill_super()
1330 pr_err("virtio-fs: dax can't be enabled as filesystem" in virtio_fs_fill_super()
1334 ctx->dax_dev = fs->dax_dev; in virtio_fs_fill_super()
1340 for (i = 0; i < fs->nvqs; i++) { in virtio_fs_fill_super()
1341 struct virtio_fs_vq *fsvq = &fs->vqs[i]; in virtio_fs_fill_super()
1347 virtio_fs_start_all_queues(fs); in virtio_fs_fill_super()
1353 virtio_fs_free_devs(fs); in virtio_fs_fill_super()
1415 struct virtio_fs *fs; in virtio_fs_get_tree() local
1426 fs = virtio_fs_find_instance(fsc->source); in virtio_fs_get_tree()
1427 if (!fs) { in virtio_fs_get_tree()
1428 pr_info("virtio-fs: tag <%s> not found\n", fsc->source); in virtio_fs_get_tree()
1432 virtqueue_size = virtqueue_get_vring_size(fs->vqs[VQ_REQUEST].vq); in virtio_fs_get_tree()
1445 fuse_conn_init(fc, fm, fsc->user_ns, &virtio_fs_fiq_ops, fs); in virtio_fs_get_tree()
1479 virtio_fs_put(fs); in virtio_fs_get_tree()