Lines Matching full:ns
17 void nvmet_file_ns_revalidate(struct nvmet_ns *ns) in nvmet_file_ns_revalidate() argument
19 ns->size = i_size_read(ns->file->f_mapping->host); in nvmet_file_ns_revalidate()
22 void nvmet_file_ns_disable(struct nvmet_ns *ns) in nvmet_file_ns_disable() argument
24 if (ns->file) { in nvmet_file_ns_disable()
25 if (ns->buffered_io) in nvmet_file_ns_disable()
27 mempool_destroy(ns->bvec_pool); in nvmet_file_ns_disable()
28 ns->bvec_pool = NULL; in nvmet_file_ns_disable()
29 kmem_cache_destroy(ns->bvec_cache); in nvmet_file_ns_disable()
30 ns->bvec_cache = NULL; in nvmet_file_ns_disable()
31 fput(ns->file); in nvmet_file_ns_disable()
32 ns->file = NULL; in nvmet_file_ns_disable()
36 int nvmet_file_ns_enable(struct nvmet_ns *ns) in nvmet_file_ns_enable() argument
41 if (!ns->buffered_io) in nvmet_file_ns_enable()
44 ns->file = filp_open(ns->device_path, flags, 0); in nvmet_file_ns_enable()
45 if (IS_ERR(ns->file)) { in nvmet_file_ns_enable()
46 ret = PTR_ERR(ns->file); in nvmet_file_ns_enable()
48 ns->device_path, ret); in nvmet_file_ns_enable()
49 ns->file = NULL; in nvmet_file_ns_enable()
53 nvmet_file_ns_revalidate(ns); in nvmet_file_ns_enable()
59 ns->blksize_shift = min_t(u8, in nvmet_file_ns_enable()
60 file_inode(ns->file)->i_blkbits, 12); in nvmet_file_ns_enable()
62 ns->bvec_cache = kmem_cache_create("nvmet-bvec", in nvmet_file_ns_enable()
65 if (!ns->bvec_cache) { in nvmet_file_ns_enable()
70 ns->bvec_pool = mempool_create(NVMET_MIN_MPOOL_OBJ, mempool_alloc_slab, in nvmet_file_ns_enable()
71 mempool_free_slab, ns->bvec_cache); in nvmet_file_ns_enable()
73 if (!ns->bvec_pool) { in nvmet_file_ns_enable()
80 ns->size = 0; in nvmet_file_ns_enable()
81 ns->blksize_shift = 0; in nvmet_file_ns_enable()
82 nvmet_file_ns_disable(ns); in nvmet_file_ns_enable()
104 call_iter = req->ns->file->f_op->write_iter; in nvmet_file_submit_bvec()
107 call_iter = req->ns->file->f_op->read_iter; in nvmet_file_submit_bvec()
114 iocb->ki_filp = req->ns->file; in nvmet_file_submit_bvec()
129 mempool_free(req->f.bvec, req->ns->bvec_pool); in nvmet_file_io_done()
151 pos = le64_to_cpu(req->cmd->rw.slba) << req->ns->blksize_shift; in nvmet_file_execute_io()
152 if (unlikely(pos + req->transfer_len > req->ns->size)) { in nvmet_file_execute_io()
254 req->f.bvec = mempool_alloc(req->ns->bvec_pool, GFP_KERNEL); in nvmet_file_execute_rw()
259 if (req->ns->buffered_io) { in nvmet_file_execute_rw()
261 (req->ns->file->f_mode & FMODE_NOWAIT) && in nvmet_file_execute_rw()
271 return errno_to_nvme_status(req, vfs_fsync(req->ns->file, 1)); in nvmet_file_flush()
304 offset = le64_to_cpu(range.slba) << req->ns->blksize_shift; in nvmet_file_execute_discard()
306 len <<= req->ns->blksize_shift; in nvmet_file_execute_discard()
307 if (offset + len > req->ns->size) { in nvmet_file_execute_discard()
313 ret = vfs_fallocate(req->ns->file, mode, offset, len); in nvmet_file_execute_discard()
358 offset = le64_to_cpu(write_zeroes->slba) << req->ns->blksize_shift; in nvmet_file_write_zeroes_work()
360 req->ns->blksize_shift); in nvmet_file_write_zeroes_work()
362 if (unlikely(offset + len > req->ns->size)) { in nvmet_file_write_zeroes_work()
367 ret = vfs_fallocate(req->ns->file, mode, offset, len); in nvmet_file_write_zeroes_work()