aboutsummaryrefslogtreecommitdiffstats
path: root/fs/aio.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2018-06-09 09:40:05 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2018-07-12 10:04:23 -0400
commitd93aa9d82aea80b80f225dbf9c7986df444d8106 (patch)
tree887b5626f375e6745e034e227eb0c583fbefad99 /fs/aio.c
parentdbae8f2ca2f0586f4b80201c78ff0aed2a012ab5 (diff)
new wrapper: alloc_file_pseudo()
takes inode, vfsmount, name, O_... flags and file_operations and either returns a new struct file (in which case inode reference we held is consumed) or returns ERR_PTR(), in which case no refcounts are altered. converted aio_private_file() and sock_alloc_file() to it Acked-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/aio.c')
-rw-r--r--fs/aio.c20
1 files changed, 4 insertions, 16 deletions
diff --git a/fs/aio.c b/fs/aio.c
index 9eea53887d6c..c3a8bac16374 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -215,9 +215,7 @@ static const struct address_space_operations aio_ctx_aops;
215 215
216static struct file *aio_private_file(struct kioctx *ctx, loff_t nr_pages) 216static struct file *aio_private_file(struct kioctx *ctx, loff_t nr_pages)
217{ 217{
218 struct qstr this = QSTR_INIT("[aio]", 5);
219 struct file *file; 218 struct file *file;
220 struct path path;
221 struct inode *inode = alloc_anon_inode(aio_mnt->mnt_sb); 219 struct inode *inode = alloc_anon_inode(aio_mnt->mnt_sb);
222 if (IS_ERR(inode)) 220 if (IS_ERR(inode))
223 return ERR_CAST(inode); 221 return ERR_CAST(inode);
@@ -226,27 +224,17 @@ static struct file *aio_private_file(struct kioctx *ctx, loff_t nr_pages)
226 inode->i_mapping->private_data = ctx; 224 inode->i_mapping->private_data = ctx;
227 inode->i_size = PAGE_SIZE * nr_pages; 225 inode->i_size = PAGE_SIZE * nr_pages;
228 226
229 path.dentry = d_alloc_pseudo(aio_mnt->mnt_sb, &this); 227 file = alloc_file_pseudo(inode, aio_mnt, "[aio]",
230 if (!path.dentry) { 228 O_RDWR, &aio_ring_fops);
231 iput(inode);
232 return ERR_PTR(-ENOMEM);
233 }
234 path.mnt = mntget(aio_mnt);
235
236 d_instantiate(path.dentry, inode);
237 file = alloc_file(&path, O_RDWR, &aio_ring_fops);
238 if (IS_ERR(file)) 229 if (IS_ERR(file))
239 path_put(&path); 230 iput(inode);
240 return file; 231 return file;
241} 232}
242 233
243static struct dentry *aio_mount(struct file_system_type *fs_type, 234static struct dentry *aio_mount(struct file_system_type *fs_type,
244 int flags, const char *dev_name, void *data) 235 int flags, const char *dev_name, void *data)
245{ 236{
246 static const struct dentry_operations ops = { 237 struct dentry *root = mount_pseudo(fs_type, "aio:", NULL, NULL,
247 .d_dname = simple_dname,
248 };
249 struct dentry *root = mount_pseudo(fs_type, "aio:", NULL, &ops,
250 AIO_RING_MAGIC); 238 AIO_RING_MAGIC);
251 239
252 if (!IS_ERR(root)) 240 if (!IS_ERR(root))