Lines Matching full:fs

3  * virtio-fs: Virtio Filesystem
7 #include <linux/fs.h>
21 /* List of virtio-fs device instances and a lock for the list. Also provides
49 /* A virtio-fs device instance */
125 struct virtio_fs *fs = vq->vdev->priv; in vq_to_fsvq() local
127 return &fs->vqs[vq->index]; in vq_to_fsvq()
159 static void virtio_fs_put(struct virtio_fs *fs) in virtio_fs_put() argument
161 kref_put(&fs->refcount, release_virtio_fs_obj); in virtio_fs_put()
194 static void virtio_fs_drain_all_queues_locked(struct virtio_fs *fs) in virtio_fs_drain_all_queues_locked() argument
199 for (i = 0; i < fs->nvqs; i++) { in virtio_fs_drain_all_queues_locked()
200 fsvq = &fs->vqs[i]; in virtio_fs_drain_all_queues_locked()
205 static void virtio_fs_drain_all_queues(struct virtio_fs *fs) in virtio_fs_drain_all_queues() argument
214 virtio_fs_drain_all_queues_locked(fs); in virtio_fs_drain_all_queues()
218 static void virtio_fs_start_all_queues(struct virtio_fs *fs) in virtio_fs_start_all_queues() argument
223 for (i = 0; i < fs->nvqs; i++) { in virtio_fs_start_all_queues()
224 fsvq = &fs->vqs[i]; in virtio_fs_start_all_queues()
232 static int virtio_fs_add_instance(struct virtio_fs *fs) in virtio_fs_add_instance() argument
240 if (strcmp(fs->tag, fs2->tag) == 0) in virtio_fs_add_instance()
245 list_add_tail(&fs->list, &virtio_fs_instances); in virtio_fs_add_instance()
257 struct virtio_fs *fs; in virtio_fs_find_instance() local
261 list_for_each_entry(fs, &virtio_fs_instances, list) { in virtio_fs_find_instance()
262 if (strcmp(fs->tag, tag) == 0) { in virtio_fs_find_instance()
263 kref_get(&fs->refcount); in virtio_fs_find_instance()
268 fs = NULL; /* not found */ in virtio_fs_find_instance()
273 return fs; in virtio_fs_find_instance()
276 static void virtio_fs_free_devs(struct virtio_fs *fs) in virtio_fs_free_devs() argument
280 for (i = 0; i < fs->nvqs; i++) { in virtio_fs_free_devs()
281 struct virtio_fs_vq *fsvq = &fs->vqs[i]; in virtio_fs_free_devs()
291 /* Read filesystem name from virtio config into fs->tag (must kfree()). */
292 static int virtio_fs_read_tag(struct virtio_device *vdev, struct virtio_fs *fs) in virtio_fs_read_tag() argument
307 fs->tag = devm_kmalloc(&vdev->dev, len + 1, GFP_KERNEL); in virtio_fs_read_tag()
308 if (!fs->tag) in virtio_fs_read_tag()
310 memcpy(fs->tag, tag_buf, len); in virtio_fs_read_tag()
311 fs->tag[len] = '\0'; in virtio_fs_read_tag()
345 pr_debug("virtio-fs: worker %s called.\n", __func__); in virtio_fs_request_dispatch_work()
386 pr_err("virtio-fs: virtio_fs_enqueue_req() failed %d\n", in virtio_fs_request_dispatch_work()
422 pr_debug("virtio-fs: Could not queue FORGET: err=%d. Will try later\n", in send_forget_request()
432 pr_debug("virtio-fs: Could not queue FORGET: err=%d. Dropping it.\n", in send_forget_request()
459 pr_debug("virtio-fs: worker %s called.\n", __func__); in virtio_fs_hiprio_dispatch_work()
670 struct virtio_fs *fs) in virtio_fs_setup_vqs() argument
679 &fs->num_request_queues); in virtio_fs_setup_vqs()
680 if (fs->num_request_queues == 0) in virtio_fs_setup_vqs()
683 fs->nvqs = VQ_REQUEST + fs->num_request_queues; in virtio_fs_setup_vqs()
684 fs->vqs = kcalloc(fs->nvqs, sizeof(fs->vqs[VQ_HIPRIO]), GFP_KERNEL); in virtio_fs_setup_vqs()
685 if (!fs->vqs) in virtio_fs_setup_vqs()
688 vqs = kmalloc_array(fs->nvqs, sizeof(vqs[VQ_HIPRIO]), GFP_KERNEL); in virtio_fs_setup_vqs()
689 callbacks = kmalloc_array(fs->nvqs, sizeof(callbacks[VQ_HIPRIO]), in virtio_fs_setup_vqs()
691 names = kmalloc_array(fs->nvqs, sizeof(names[VQ_HIPRIO]), GFP_KERNEL); in virtio_fs_setup_vqs()
699 virtio_fs_init_vq(&fs->vqs[VQ_HIPRIO], "hiprio", VQ_HIPRIO); in virtio_fs_setup_vqs()
700 names[VQ_HIPRIO] = fs->vqs[VQ_HIPRIO].name; in virtio_fs_setup_vqs()
703 for (i = VQ_REQUEST; i < fs->nvqs; i++) { in virtio_fs_setup_vqs()
707 virtio_fs_init_vq(&fs->vqs[i], vq_name, VQ_REQUEST); in virtio_fs_setup_vqs()
709 names[i] = fs->vqs[i].name; in virtio_fs_setup_vqs()
712 ret = virtio_find_vqs(vdev, fs->nvqs, vqs, callbacks, names, NULL); in virtio_fs_setup_vqs()
716 for (i = 0; i < fs->nvqs; i++) in virtio_fs_setup_vqs()
717 fs->vqs[i].vq = vqs[i]; in virtio_fs_setup_vqs()
719 virtio_fs_start_all_queues(fs); in virtio_fs_setup_vqs()
725 kfree(fs->vqs); in virtio_fs_setup_vqs()
731 struct virtio_fs *fs) in virtio_fs_cleanup_vqs() argument
743 struct virtio_fs *fs = dax_get_private(dax_dev); in virtio_fs_direct_access() local
745 size_t max_nr_pages = fs->window_len/PAGE_SIZE - pgoff; in virtio_fs_direct_access()
748 *kaddr = fs->window_kaddr + offset; in virtio_fs_direct_access()
750 *pfn = phys_to_pfn_t(fs->window_phys_addr + offset, in virtio_fs_direct_access()
798 static int virtio_fs_setup_dax(struct virtio_device *vdev, struct virtio_fs *fs) in virtio_fs_setup_dax() argument
842 fs->window_kaddr = devm_memremap_pages(&vdev->dev, pgmap); in virtio_fs_setup_dax()
843 if (IS_ERR(fs->window_kaddr)) in virtio_fs_setup_dax()
844 return PTR_ERR(fs->window_kaddr); in virtio_fs_setup_dax()
846 fs->window_phys_addr = (phys_addr_t) cache_reg.addr; in virtio_fs_setup_dax()
847 fs->window_len = (phys_addr_t) cache_reg.len; in virtio_fs_setup_dax()
850 __func__, fs->window_kaddr, cache_reg.addr, cache_reg.len); in virtio_fs_setup_dax()
852 fs->dax_dev = alloc_dax(fs, NULL, &virtio_fs_dax_ops, 0); in virtio_fs_setup_dax()
853 if (IS_ERR(fs->dax_dev)) in virtio_fs_setup_dax()
854 return PTR_ERR(fs->dax_dev); in virtio_fs_setup_dax()
857 fs->dax_dev); in virtio_fs_setup_dax()
862 struct virtio_fs *fs; in virtio_fs_probe() local
865 fs = kzalloc(sizeof(*fs), GFP_KERNEL); in virtio_fs_probe()
866 if (!fs) in virtio_fs_probe()
868 kref_init(&fs->refcount); in virtio_fs_probe()
869 vdev->priv = fs; in virtio_fs_probe()
871 ret = virtio_fs_read_tag(vdev, fs); in virtio_fs_probe()
875 ret = virtio_fs_setup_vqs(vdev, fs); in virtio_fs_probe()
881 ret = virtio_fs_setup_dax(vdev, fs); in virtio_fs_probe()
890 ret = virtio_fs_add_instance(fs); in virtio_fs_probe()
898 virtio_fs_cleanup_vqs(vdev, fs); 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()
929 virtio_fs_cleanup_vqs(vdev, 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 ctx->dax_dev = fs->dax_dev; in virtio_fs_fill_super()
1333 for (i = 0; i < fs->nvqs; i++) { in virtio_fs_fill_super()
1334 struct virtio_fs_vq *fsvq = &fs->vqs[i]; in virtio_fs_fill_super()
1340 virtio_fs_start_all_queues(fs); in virtio_fs_fill_super()
1346 virtio_fs_free_devs(fs); in virtio_fs_fill_super()
1419 struct virtio_fs *fs; in virtio_fs_get_tree() local
1429 fs = virtio_fs_find_instance(fsc->source); in virtio_fs_get_tree()
1430 if (!fs) { in virtio_fs_get_tree()
1431 pr_info("virtio-fs: tag <%s> not found\n", fsc->source); in virtio_fs_get_tree()
1438 virtio_fs_put(fs); in virtio_fs_get_tree()
1446 virtio_fs_put(fs); in virtio_fs_get_tree()
1453 &virtio_fs_fiq_ops, fs); in virtio_fs_get_tree()