2 * linux/fs/9p/vfs_inode_dotl.c
4 * This file contains vfs inode ops for the 9P2000.L protocol.
6 * Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com>
7 * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2
11 * as published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to:
20 * Free Software Foundation
21 * 51 Franklin Street, Fifth Floor
22 * Boston, MA 02111-1301 USA
26 #include <linux/module.h>
27 #include <linux/errno.h>
29 #include <linux/file.h>
30 #include <linux/pagemap.h>
31 #include <linux/stat.h>
32 #include <linux/string.h>
33 #include <linux/inet.h>
34 #include <linux/namei.h>
35 #include <linux/idr.h>
36 #include <linux/sched.h>
37 #include <linux/slab.h>
38 #include <linux/xattr.h>
39 #include <linux/posix_acl.h>
40 #include <net/9p/9p.h>
41 #include <net/9p/client.h>
51 v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, int omode,
55 * v9fs_get_fsgid_for_create - Helper function to get the gid for creating a
56 * new file system object. This checks the S_ISGID to determine the owning
57 * group of the new file system object.
60 static gid_t v9fs_get_fsgid_for_create(struct inode *dir_inode)
62 BUG_ON(dir_inode == NULL);
64 if (dir_inode->i_mode & S_ISGID) {
65 /* set_gid bit is set.*/
66 return dir_inode->i_gid;
68 return current_fsgid();
72 * v9fs_dentry_from_dir_inode - helper function to get the dentry from
77 static struct dentry *v9fs_dentry_from_dir_inode(struct inode *inode)
79 struct dentry *dentry;
81 spin_lock(&inode->i_lock);
82 /* Directory should have only one entry. */
83 BUG_ON(S_ISDIR(inode->i_mode) && !list_is_singular(&inode->i_dentry));
84 dentry = list_entry(inode->i_dentry.next, struct dentry, d_u.d_alias);
85 spin_unlock(&inode->i_lock);
89 static int v9fs_test_inode_dotl(struct inode *inode, void *data)
91 struct v9fs_inode *v9inode = V9FS_I(inode);
92 struct p9_stat_dotl *st = (struct p9_stat_dotl *)data;
94 /* don't match inode of different type */
95 if ((inode->i_mode & S_IFMT) != (st->st_mode & S_IFMT))
98 if (inode->i_generation != st->st_gen)
101 /* compare qid details */
102 if (memcmp(&v9inode->qid.version,
103 &st->qid.version, sizeof(v9inode->qid.version)))
106 if (v9inode->qid.type != st->qid.type)
109 if (v9inode->qid.path != st->qid.path)
114 /* Always get a new inode */
115 static int v9fs_test_new_inode_dotl(struct inode *inode, void *data)
120 static int v9fs_set_inode_dotl(struct inode *inode, void *data)
122 struct v9fs_inode *v9inode = V9FS_I(inode);
123 struct p9_stat_dotl *st = (struct p9_stat_dotl *)data;
125 memcpy(&v9inode->qid, &st->qid, sizeof(st->qid));
126 inode->i_generation = st->st_gen;
130 static struct inode *v9fs_qid_iget_dotl(struct super_block *sb,
133 struct p9_stat_dotl *st,
139 struct v9fs_session_info *v9ses = sb->s_fs_info;
140 int (*test)(struct inode *, void *);
143 test = v9fs_test_new_inode_dotl;
145 test = v9fs_test_inode_dotl;
147 i_ino = v9fs_qid2ino(qid);
148 inode = iget5_locked(sb, i_ino, test, v9fs_set_inode_dotl, st);
150 return ERR_PTR(-ENOMEM);
151 if (!(inode->i_state & I_NEW))
154 * initialize the inode with the stat info
155 * FIXME!! we may need support for stale inodes
158 inode->i_ino = i_ino;
159 retval = v9fs_init_inode(v9ses, inode,
160 st->st_mode, new_decode_dev(st->st_rdev));
164 v9fs_stat2inode_dotl(st, inode);
165 #ifdef CONFIG_9P_FSCACHE
166 v9fs_cache_inode_get_cookie(inode);
168 retval = v9fs_get_acl(inode, fid);
172 unlock_new_inode(inode);
176 return ERR_PTR(retval);
181 v9fs_inode_from_fid_dotl(struct v9fs_session_info *v9ses, struct p9_fid *fid,
182 struct super_block *sb, int new)
184 struct p9_stat_dotl *st;
185 struct inode *inode = NULL;
187 st = p9_client_getattr_dotl(fid, P9_STATS_BASIC | P9_STATS_GEN);
191 inode = v9fs_qid_iget_dotl(sb, &st->qid, fid, st, new);
196 struct dotl_openflag_map {
201 static int v9fs_mapped_dotl_flags(int flags)
205 struct dotl_openflag_map dotl_oflag_map[] = {
206 { O_CREAT, P9_DOTL_CREATE },
207 { O_EXCL, P9_DOTL_EXCL },
208 { O_NOCTTY, P9_DOTL_NOCTTY },
209 { O_TRUNC, P9_DOTL_TRUNC },
210 { O_APPEND, P9_DOTL_APPEND },
211 { O_NONBLOCK, P9_DOTL_NONBLOCK },
212 { O_DSYNC, P9_DOTL_DSYNC },
213 { FASYNC, P9_DOTL_FASYNC },
214 { O_DIRECT, P9_DOTL_DIRECT },
215 { O_LARGEFILE, P9_DOTL_LARGEFILE },
216 { O_DIRECTORY, P9_DOTL_DIRECTORY },
217 { O_NOFOLLOW, P9_DOTL_NOFOLLOW },
218 { O_NOATIME, P9_DOTL_NOATIME },
219 { O_CLOEXEC, P9_DOTL_CLOEXEC },
220 { O_SYNC, P9_DOTL_SYNC},
222 for (i = 0; i < ARRAY_SIZE(dotl_oflag_map); i++) {
223 if (flags & dotl_oflag_map[i].open_flag)
224 rflags |= dotl_oflag_map[i].dotl_flag;
230 * v9fs_open_to_dotl_flags- convert Linux specific open flags to
232 * @flags: flags to convert
234 int v9fs_open_to_dotl_flags(int flags)
239 * We have same bits for P9_DOTL_READONLY, P9_DOTL_WRONLY
240 * and P9_DOTL_NOACCESS
242 rflags |= flags & O_ACCMODE;
243 rflags |= v9fs_mapped_dotl_flags(flags);
249 * v9fs_vfs_create_dotl - VFS hook to create files for 9P2000.L protocol.
250 * @dir: directory inode that is being created
251 * @dentry: dentry that is being deleted
252 * @mode: create permissions
253 * @nd: path information
258 v9fs_vfs_create_dotl(struct inode *dir, struct dentry *dentry, int omode,
259 struct nameidata *nd)
269 struct p9_fid *fid = NULL;
270 struct v9fs_inode *v9inode;
271 struct p9_fid *dfid, *ofid, *inode_fid;
272 struct v9fs_session_info *v9ses;
273 struct posix_acl *pacl = NULL, *dacl = NULL;
275 v9ses = v9fs_inode2v9ses(dir);
277 flags = nd->intent.open.flags;
280 * create call without LOOKUP_OPEN is due
281 * to mknod of regular files. So use mknod
284 return v9fs_vfs_mknod_dotl(dir, dentry, omode, 0);
287 name = (char *) dentry->d_name.name;
288 P9_DPRINTK(P9_DEBUG_VFS, "v9fs_vfs_create_dotl: name:%s flags:0x%x "
289 "mode:0x%x\n", name, flags, omode);
291 dfid = v9fs_fid_lookup(dentry->d_parent);
294 P9_DPRINTK(P9_DEBUG_VFS, "fid lookup failed %d\n", err);
298 /* clone a fid to use for creation */
299 ofid = p9_client_walk(dfid, 0, NULL, 1);
302 P9_DPRINTK(P9_DEBUG_VFS, "p9_client_walk failed %d\n", err);
306 gid = v9fs_get_fsgid_for_create(dir);
309 /* Update mode based on ACL value */
310 err = v9fs_acl_mode(dir, &mode, &dacl, &pacl);
312 P9_DPRINTK(P9_DEBUG_VFS,
313 "Failed to get acl values in creat %d\n", err);
316 err = p9_client_create_dotl(ofid, name, v9fs_open_to_dotl_flags(flags),
319 P9_DPRINTK(P9_DEBUG_VFS,
320 "p9_client_open_dotl failed in creat %d\n",
324 v9fs_invalidate_inode_attr(dir);
326 /* instantiate inode and assign the unopened fid to the dentry */
327 fid = p9_client_walk(dfid, 1, &name, 1);
330 P9_DPRINTK(P9_DEBUG_VFS, "p9_client_walk failed %d\n", err);
334 inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb);
336 err = PTR_ERR(inode);
337 P9_DPRINTK(P9_DEBUG_VFS, "inode creation failed %d\n", err);
340 err = v9fs_fid_add(dentry, fid);
343 d_instantiate(dentry, inode);
345 /* Now set the ACL based on the default value */
346 v9fs_set_create_acl(dentry, &dacl, &pacl);
348 v9inode = V9FS_I(inode);
349 mutex_lock(&v9inode->v_mutex);
350 if (v9ses->cache && !v9inode->writeback_fid &&
351 ((flags & O_ACCMODE) != O_RDONLY)) {
353 * clone a fid and add it to writeback_fid
354 * we do it during open time instead of
355 * page dirty time via write_begin/page_mkwrite
356 * because we want write after unlink usecase
359 inode_fid = v9fs_writeback_fid(dentry);
360 if (IS_ERR(inode_fid)) {
361 err = PTR_ERR(inode_fid);
362 mutex_unlock(&v9inode->v_mutex);
363 goto err_clunk_old_fid;
365 v9inode->writeback_fid = (void *) inode_fid;
367 mutex_unlock(&v9inode->v_mutex);
368 /* Since we are opening a file, assign the open fid to the file */
369 filp = lookup_instantiate_filp(nd, dentry, generic_file_open);
372 goto err_clunk_old_fid;
374 filp->private_data = ofid;
375 #ifdef CONFIG_9P_FSCACHE
377 v9fs_cache_inode_set_cookie(inode, filp);
383 p9_client_clunk(fid);
386 p9_client_clunk(ofid);
387 v9fs_set_create_acl(NULL, &dacl, &pacl);
392 * v9fs_vfs_mkdir_dotl - VFS mkdir hook to create a directory
393 * @dir: inode that is being unlinked
394 * @dentry: dentry that is being unlinked
395 * @mode: mode for new directory
399 static int v9fs_vfs_mkdir_dotl(struct inode *dir,
400 struct dentry *dentry, int omode)
403 struct v9fs_session_info *v9ses;
404 struct p9_fid *fid = NULL, *dfid = NULL;
410 struct dentry *dir_dentry;
411 struct posix_acl *dacl = NULL, *pacl = NULL;
413 P9_DPRINTK(P9_DEBUG_VFS, "name %s\n", dentry->d_name.name);
415 v9ses = v9fs_inode2v9ses(dir);
418 if (dir->i_mode & S_ISGID)
421 dir_dentry = v9fs_dentry_from_dir_inode(dir);
422 dfid = v9fs_fid_lookup(dir_dentry);
425 P9_DPRINTK(P9_DEBUG_VFS, "fid lookup failed %d\n", err);
430 gid = v9fs_get_fsgid_for_create(dir);
432 /* Update mode based on ACL value */
433 err = v9fs_acl_mode(dir, &mode, &dacl, &pacl);
435 P9_DPRINTK(P9_DEBUG_VFS,
436 "Failed to get acl values in mkdir %d\n", err);
439 name = (char *) dentry->d_name.name;
440 err = p9_client_mkdir_dotl(dfid, name, mode, gid, &qid);
444 /* instantiate inode and assign the unopened fid to the dentry */
445 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) {
446 fid = p9_client_walk(dfid, 1, &name, 1);
449 P9_DPRINTK(P9_DEBUG_VFS, "p9_client_walk failed %d\n",
455 inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb);
457 err = PTR_ERR(inode);
458 P9_DPRINTK(P9_DEBUG_VFS, "inode creation failed %d\n",
462 err = v9fs_fid_add(dentry, fid);
465 d_instantiate(dentry, inode);
469 * Not in cached mode. No need to populate
470 * inode with stat. We need to get an inode
471 * so that we can set the acl with dentry
473 inode = v9fs_get_inode(dir->i_sb, mode, 0);
475 err = PTR_ERR(inode);
478 d_instantiate(dentry, inode);
480 /* Now set the ACL based on the default value */
481 v9fs_set_create_acl(dentry, &dacl, &pacl);
483 v9fs_invalidate_inode_attr(dir);
486 p9_client_clunk(fid);
487 v9fs_set_create_acl(NULL, &dacl, &pacl);
492 v9fs_vfs_getattr_dotl(struct vfsmount *mnt, struct dentry *dentry,
496 struct v9fs_session_info *v9ses;
498 struct p9_stat_dotl *st;
500 P9_DPRINTK(P9_DEBUG_VFS, "dentry: %p\n", dentry);
502 v9ses = v9fs_dentry2v9ses(dentry);
503 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) {
504 generic_fillattr(dentry->d_inode, stat);
507 fid = v9fs_fid_lookup(dentry);
511 /* Ask for all the fields in stat structure. Server will return
512 * whatever it supports
515 st = p9_client_getattr_dotl(fid, P9_STATS_ALL);
519 v9fs_stat2inode_dotl(st, dentry->d_inode);
520 generic_fillattr(dentry->d_inode, stat);
521 /* Change block size to what the server returned */
522 stat->blksize = st->st_blksize;
529 * v9fs_vfs_setattr_dotl - set file metadata
530 * @dentry: file whose metadata to set
531 * @iattr: metadata assignment structure
535 int v9fs_vfs_setattr_dotl(struct dentry *dentry, struct iattr *iattr)
538 struct v9fs_session_info *v9ses;
540 struct p9_iattr_dotl p9attr;
542 P9_DPRINTK(P9_DEBUG_VFS, "\n");
544 retval = setattr_prepare(dentry, iattr);
548 p9attr.valid = iattr->ia_valid;
549 p9attr.mode = iattr->ia_mode;
550 p9attr.uid = iattr->ia_uid;
551 p9attr.gid = iattr->ia_gid;
552 p9attr.size = iattr->ia_size;
553 p9attr.atime_sec = iattr->ia_atime.tv_sec;
554 p9attr.atime_nsec = iattr->ia_atime.tv_nsec;
555 p9attr.mtime_sec = iattr->ia_mtime.tv_sec;
556 p9attr.mtime_nsec = iattr->ia_mtime.tv_nsec;
559 v9ses = v9fs_dentry2v9ses(dentry);
560 fid = v9fs_fid_lookup(dentry);
564 /* Write all dirty data */
565 if (S_ISREG(dentry->d_inode->i_mode))
566 filemap_write_and_wait(dentry->d_inode->i_mapping);
568 retval = p9_client_setattr(fid, &p9attr);
572 if ((iattr->ia_valid & ATTR_SIZE) &&
573 iattr->ia_size != i_size_read(dentry->d_inode))
574 truncate_setsize(dentry->d_inode, iattr->ia_size);
576 v9fs_invalidate_inode_attr(dentry->d_inode);
577 setattr_copy(dentry->d_inode, iattr);
578 mark_inode_dirty(dentry->d_inode);
579 if (iattr->ia_valid & ATTR_MODE) {
580 /* We also want to update ACL when we update mode bits */
581 retval = v9fs_acl_chmod(dentry);
589 * v9fs_stat2inode_dotl - populate an inode structure with stat info
590 * @stat: stat structure
591 * @inode: inode to populate
592 * @sb: superblock of filesystem
597 v9fs_stat2inode_dotl(struct p9_stat_dotl *stat, struct inode *inode)
600 struct v9fs_inode *v9inode = V9FS_I(inode);
602 if ((stat->st_result_mask & P9_STATS_BASIC) == P9_STATS_BASIC) {
603 inode->i_atime.tv_sec = stat->st_atime_sec;
604 inode->i_atime.tv_nsec = stat->st_atime_nsec;
605 inode->i_mtime.tv_sec = stat->st_mtime_sec;
606 inode->i_mtime.tv_nsec = stat->st_mtime_nsec;
607 inode->i_ctime.tv_sec = stat->st_ctime_sec;
608 inode->i_ctime.tv_nsec = stat->st_ctime_nsec;
609 inode->i_uid = stat->st_uid;
610 inode->i_gid = stat->st_gid;
611 set_nlink(inode, stat->st_nlink);
613 mode = stat->st_mode & S_IALLUGO;
614 mode |= inode->i_mode & ~S_IALLUGO;
615 inode->i_mode = mode;
617 i_size_write(inode, stat->st_size);
618 inode->i_blocks = stat->st_blocks;
620 if (stat->st_result_mask & P9_STATS_ATIME) {
621 inode->i_atime.tv_sec = stat->st_atime_sec;
622 inode->i_atime.tv_nsec = stat->st_atime_nsec;
624 if (stat->st_result_mask & P9_STATS_MTIME) {
625 inode->i_mtime.tv_sec = stat->st_mtime_sec;
626 inode->i_mtime.tv_nsec = stat->st_mtime_nsec;
628 if (stat->st_result_mask & P9_STATS_CTIME) {
629 inode->i_ctime.tv_sec = stat->st_ctime_sec;
630 inode->i_ctime.tv_nsec = stat->st_ctime_nsec;
632 if (stat->st_result_mask & P9_STATS_UID)
633 inode->i_uid = stat->st_uid;
634 if (stat->st_result_mask & P9_STATS_GID)
635 inode->i_gid = stat->st_gid;
636 if (stat->st_result_mask & P9_STATS_NLINK)
637 set_nlink(inode, stat->st_nlink);
638 if (stat->st_result_mask & P9_STATS_MODE) {
639 inode->i_mode = stat->st_mode;
640 if ((S_ISBLK(inode->i_mode)) ||
641 (S_ISCHR(inode->i_mode)))
642 init_special_inode(inode, inode->i_mode,
645 if (stat->st_result_mask & P9_STATS_RDEV)
646 inode->i_rdev = new_decode_dev(stat->st_rdev);
647 if (stat->st_result_mask & P9_STATS_SIZE)
648 i_size_write(inode, stat->st_size);
649 if (stat->st_result_mask & P9_STATS_BLOCKS)
650 inode->i_blocks = stat->st_blocks;
652 if (stat->st_result_mask & P9_STATS_GEN)
653 inode->i_generation = stat->st_gen;
655 /* Currently we don't support P9_STATS_BTIME and P9_STATS_DATA_VERSION
656 * because the inode structure does not have fields for them.
658 v9inode->cache_validity &= ~V9FS_INO_INVALID_ATTR;
662 v9fs_vfs_symlink_dotl(struct inode *dir, struct dentry *dentry,
671 struct p9_fid *fid = NULL;
672 struct v9fs_session_info *v9ses;
674 name = (char *) dentry->d_name.name;
675 P9_DPRINTK(P9_DEBUG_VFS, "v9fs_vfs_symlink_dotl : %lu,%s,%s\n",
676 dir->i_ino, name, symname);
677 v9ses = v9fs_inode2v9ses(dir);
679 dfid = v9fs_fid_lookup(dentry->d_parent);
682 P9_DPRINTK(P9_DEBUG_VFS, "fid lookup failed %d\n", err);
686 gid = v9fs_get_fsgid_for_create(dir);
688 /* Server doesn't alter fid on TSYMLINK. Hence no need to clone it. */
689 err = p9_client_symlink(dfid, name, (char *)symname, gid, &qid);
692 P9_DPRINTK(P9_DEBUG_VFS, "p9_client_symlink failed %d\n", err);
696 v9fs_invalidate_inode_attr(dir);
698 /* Now walk from the parent so we can get an unopened fid. */
699 fid = p9_client_walk(dfid, 1, &name, 1);
702 P9_DPRINTK(P9_DEBUG_VFS, "p9_client_walk failed %d\n",
708 /* instantiate inode and assign the unopened fid to dentry */
709 inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb);
711 err = PTR_ERR(inode);
712 P9_DPRINTK(P9_DEBUG_VFS, "inode creation failed %d\n",
716 err = v9fs_fid_add(dentry, fid);
719 d_instantiate(dentry, inode);
722 /* Not in cached mode. No need to populate inode with stat */
723 inode = v9fs_get_inode(dir->i_sb, S_IFLNK, 0);
725 err = PTR_ERR(inode);
728 d_instantiate(dentry, inode);
733 p9_client_clunk(fid);
739 * v9fs_vfs_link_dotl - create a hardlink for dotl
740 * @old_dentry: dentry for file to link to
741 * @dir: inode destination for new link
742 * @dentry: dentry for link
747 v9fs_vfs_link_dotl(struct dentry *old_dentry, struct inode *dir,
748 struct dentry *dentry)
752 struct dentry *dir_dentry;
753 struct p9_fid *dfid, *oldfid;
754 struct v9fs_session_info *v9ses;
756 P9_DPRINTK(P9_DEBUG_VFS, "dir ino: %lu, old_name: %s, new_name: %s\n",
757 dir->i_ino, old_dentry->d_name.name,
758 dentry->d_name.name);
760 v9ses = v9fs_inode2v9ses(dir);
761 dir_dentry = v9fs_dentry_from_dir_inode(dir);
762 dfid = v9fs_fid_lookup(dir_dentry);
764 return PTR_ERR(dfid);
766 oldfid = v9fs_fid_lookup(old_dentry);
768 return PTR_ERR(oldfid);
770 name = (char *) dentry->d_name.name;
772 err = p9_client_link(dfid, oldfid, (char *)dentry->d_name.name);
775 P9_DPRINTK(P9_DEBUG_VFS, "p9_client_link failed %d\n", err);
779 v9fs_invalidate_inode_attr(dir);
780 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) {
781 /* Get the latest stat info from server. */
783 fid = v9fs_fid_lookup(old_dentry);
787 v9fs_refresh_inode_dotl(fid, old_dentry->d_inode);
789 ihold(old_dentry->d_inode);
790 d_instantiate(dentry, old_dentry->d_inode);
796 * v9fs_vfs_mknod_dotl - create a special file
797 * @dir: inode destination for new link
798 * @dentry: dentry for file
799 * @mode: mode for creation
800 * @rdev: device associated with special file
804 v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, int omode,
811 struct v9fs_session_info *v9ses;
812 struct p9_fid *fid = NULL, *dfid = NULL;
815 struct dentry *dir_dentry;
816 struct posix_acl *dacl = NULL, *pacl = NULL;
818 P9_DPRINTK(P9_DEBUG_VFS,
819 " %lu,%s mode: %x MAJOR: %u MINOR: %u\n", dir->i_ino,
820 dentry->d_name.name, omode, MAJOR(rdev), MINOR(rdev));
822 if (!new_valid_dev(rdev))
825 v9ses = v9fs_inode2v9ses(dir);
826 dir_dentry = v9fs_dentry_from_dir_inode(dir);
827 dfid = v9fs_fid_lookup(dir_dentry);
830 P9_DPRINTK(P9_DEBUG_VFS, "fid lookup failed %d\n", err);
835 gid = v9fs_get_fsgid_for_create(dir);
837 /* Update mode based on ACL value */
838 err = v9fs_acl_mode(dir, &mode, &dacl, &pacl);
840 P9_DPRINTK(P9_DEBUG_VFS,
841 "Failed to get acl values in mknod %d\n", err);
844 name = (char *) dentry->d_name.name;
846 err = p9_client_mknod_dotl(dfid, name, mode, rdev, gid, &qid);
850 v9fs_invalidate_inode_attr(dir);
851 /* instantiate inode and assign the unopened fid to the dentry */
852 if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) {
853 fid = p9_client_walk(dfid, 1, &name, 1);
856 P9_DPRINTK(P9_DEBUG_VFS, "p9_client_walk failed %d\n",
862 inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb);
864 err = PTR_ERR(inode);
865 P9_DPRINTK(P9_DEBUG_VFS, "inode creation failed %d\n",
869 err = v9fs_fid_add(dentry, fid);
872 d_instantiate(dentry, inode);
876 * Not in cached mode. No need to populate inode with stat.
877 * socket syscall returns a fd, so we need instantiate
879 inode = v9fs_get_inode(dir->i_sb, mode, rdev);
881 err = PTR_ERR(inode);
884 d_instantiate(dentry, inode);
886 /* Now set the ACL based on the default value */
887 v9fs_set_create_acl(dentry, &dacl, &pacl);
890 p9_client_clunk(fid);
891 v9fs_set_create_acl(NULL, &dacl, &pacl);
896 * v9fs_vfs_follow_link_dotl - follow a symlink path
897 * @dentry: dentry for symlink
903 v9fs_vfs_follow_link_dotl(struct dentry *dentry, struct nameidata *nd)
907 char *link = __getname();
910 P9_DPRINTK(P9_DEBUG_VFS, "%s\n", dentry->d_name.name);
913 link = ERR_PTR(-ENOMEM);
916 fid = v9fs_fid_lookup(dentry);
919 link = ERR_CAST(fid);
922 retval = p9_client_readlink(fid, &target);
924 strcpy(link, target);
929 link = ERR_PTR(retval);
931 nd_set_link(nd, link);
935 int v9fs_refresh_inode_dotl(struct p9_fid *fid, struct inode *inode)
938 struct p9_stat_dotl *st;
939 struct v9fs_session_info *v9ses;
941 v9ses = v9fs_inode2v9ses(inode);
942 st = p9_client_getattr_dotl(fid, P9_STATS_ALL);
946 * Don't update inode if the file type is different
948 if ((inode->i_mode & S_IFMT) != (st->st_mode & S_IFMT))
951 spin_lock(&inode->i_lock);
953 * We don't want to refresh inode->i_size,
954 * because we may have cached data
956 i_size = inode->i_size;
957 v9fs_stat2inode_dotl(st, inode);
959 inode->i_size = i_size;
960 spin_unlock(&inode->i_lock);
966 const struct inode_operations v9fs_dir_inode_operations_dotl = {
967 .create = v9fs_vfs_create_dotl,
968 .lookup = v9fs_vfs_lookup,
969 .link = v9fs_vfs_link_dotl,
970 .symlink = v9fs_vfs_symlink_dotl,
971 .unlink = v9fs_vfs_unlink,
972 .mkdir = v9fs_vfs_mkdir_dotl,
973 .rmdir = v9fs_vfs_rmdir,
974 .mknod = v9fs_vfs_mknod_dotl,
975 .rename = v9fs_vfs_rename,
976 .getattr = v9fs_vfs_getattr_dotl,
977 .setattr = v9fs_vfs_setattr_dotl,
978 .setxattr = generic_setxattr,
979 .getxattr = generic_getxattr,
980 .removexattr = generic_removexattr,
981 .listxattr = v9fs_listxattr,
982 .get_acl = v9fs_iop_get_acl,
985 const struct inode_operations v9fs_file_inode_operations_dotl = {
986 .getattr = v9fs_vfs_getattr_dotl,
987 .setattr = v9fs_vfs_setattr_dotl,
988 .setxattr = generic_setxattr,
989 .getxattr = generic_getxattr,
990 .removexattr = generic_removexattr,
991 .listxattr = v9fs_listxattr,
992 .get_acl = v9fs_iop_get_acl,
995 const struct inode_operations v9fs_symlink_inode_operations_dotl = {
996 .readlink = generic_readlink,
997 .follow_link = v9fs_vfs_follow_link_dotl,
998 .put_link = v9fs_vfs_put_link,
999 .getattr = v9fs_vfs_getattr_dotl,
1000 .setattr = v9fs_vfs_setattr_dotl,
1001 .setxattr = generic_setxattr,
1002 .getxattr = generic_getxattr,
1003 .removexattr = generic_removexattr,
1004 .listxattr = v9fs_listxattr,