From patchwork Sat Feb 5 17:46:34 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aneesh Kumar K.V" X-Patchwork-Id: 534001 X-Patchwork-Delegate: ericvh@gmail.com Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p15HlXeP021273 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sat, 5 Feb 2011 17:47:54 GMT Received: from localhost ([127.0.0.1] helo=sfs-ml-1.v29.ch3.sourceforge.com) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.74) (envelope-from ) id 1PlmE8-0004Tx-OR; Sat, 05 Feb 2011 17:47:16 +0000 Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.74) (envelope-from ) id 1PlmE6-0004Tm-PI for v9fs-developer@lists.sourceforge.net; Sat, 05 Feb 2011 17:47:14 +0000 X-ACL-Warn: Received: from e28smtp08.in.ibm.com ([122.248.162.8]) by sog-mx-3.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.74) id 1PlmE5-0008PW-4A for v9fs-developer@lists.sourceforge.net; Sat, 05 Feb 2011 17:47:14 +0000 Received: from d28relay01.in.ibm.com (d28relay01.in.ibm.com [9.184.220.58]) by e28smtp08.in.ibm.com (8.14.4/8.13.1) with ESMTP id p15GsXdD016232 for ; Sat, 5 Feb 2011 22:24:33 +0530 Received: from d28av03.in.ibm.com (d28av03.in.ibm.com [9.184.220.65]) by d28relay01.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p15Hl3JK3965116 for ; Sat, 5 Feb 2011 23:17:03 +0530 Received: from d28av03.in.ibm.com (loopback [127.0.0.1]) by d28av03.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p15Hl3qU014653 for ; Sun, 6 Feb 2011 04:47:03 +1100 Received: from skywalker.ibm.com ([9.124.88.193]) by d28av03.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p15HknSX014456; Sun, 6 Feb 2011 04:47:02 +1100 From: "Aneesh Kumar K.V" To: v9fs-developer@lists.sourceforge.net Date: Sat, 5 Feb 2011 23:16:34 +0530 Message-Id: <1296928005-9529-7-git-send-email-aneesh.kumar@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1296928005-9529-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> References: <1296928005-9529-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> X-Spam-Score: -0.0 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain X-Headers-End: 1PlmE5-0008PW-4A Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [V9fs-developer] [RFC PATCH -V2 06/17] fs/9p: Add fid to inode in cached mode X-BeenThere: v9fs-developer@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: v9fs-developer-bounces@lists.sourceforge.net X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Sat, 05 Feb 2011 17:47:54 +0000 (UTC) diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c index ecdd512..0f62b26 100644 --- a/fs/9p/vfs_file.c +++ b/fs/9p/vfs_file.c @@ -86,11 +86,42 @@ int v9fs_file_open(struct inode *inode, struct file *file) } file->private_data = fid; + /* + * In cached mode we need to attach a fid to inode. The fid + * attached to inode will only be used to write back the + * dirty pages. We always request for the open fid in read-write + * mode so that a partial page write which result in page + * read can work. + */ + if (v9ses->cache && !inode->i_private) { + /* + * clone a fid and add it to inode->i_private + * we do it during open time instead of + * page dirty time via write_begin/page_mkwrite + * because we want write after unlink usecase + * to work. + */ + fid = v9fs_fid_clone(file->f_path.dentry); + if (IS_ERR(fid)) { + err = PTR_ERR(fid); + goto out_error; + } + err = p9_client_open(fid, O_RDWR); + if (err < 0) { + p9_client_clunk(fid); + goto out_error; + } + inode->i_private = (void *) fid; + } #ifdef CONFIG_9P_FSCACHE if (v9ses->cache) v9fs_cache_inode_set_cookie(inode, file); #endif return 0; +out_error: + p9_client_clunk(file->private_data); + file->private_data = 0; + return err; } /** diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index ce56571..ecd2c6f 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c @@ -416,6 +416,11 @@ void v9fs_evict_inode(struct inode *inode) #ifdef CONFIG_9P_FSCACHE v9fs_cache_inode_put_cookie(inode); #endif + /* clunk the fid stashed in inode->i_private */ + if (inode->i_private) { + p9_client_clunk((struct p9_fid *)inode->i_private); + inode->i_private = 0; + } } struct inode * @@ -577,7 +582,7 @@ v9fs_vfs_create(struct inode *dir, struct dentry *dentry, int mode, u32 perm; int flags; struct v9fs_session_info *v9ses; - struct p9_fid *fid; + struct p9_fid *fid, *inode_fid; struct file *filp; err = 0; @@ -600,6 +605,33 @@ v9fs_vfs_create(struct inode *dir, struct dentry *dentry, int mode, /* if we are opening a file, assign the open fid to the file */ if (nd && nd->flags & LOOKUP_OPEN) { + /* + * In cached mode we need to attach a fid to inode. The fid + * attached to inode will only be used to write back the + * dirty pages. We always request for the open fid in read-write + * mode so that a partial page write which result in page + * read can work. + */ + if (v9ses->cache && !dentry->d_inode->i_private) { + /* + * clone a fid and add it to inode->i_private + * we do it during open time instead of + * page dirty time via write_begin/page_mkwrite + * because we want write after unlink usecase + * to work. + */ + inode_fid = v9fs_fid_clone(dentry); + if (IS_ERR(inode_fid)) { + err = PTR_ERR(inode_fid); + goto error; + } + err = p9_client_open(inode_fid, O_RDWR); + if (err < 0) { + p9_client_clunk(inode_fid); + goto error; + } + dentry->d_inode->i_private = (void *) inode_fid; + } filp = lookup_instantiate_filp(nd, dentry, generic_file_open); if (IS_ERR(filp)) { err = PTR_ERR(filp); diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c index 265f583..d5aa986 100644 --- a/fs/9p/vfs_inode_dotl.c +++ b/fs/9p/vfs_inode_dotl.c @@ -142,7 +142,7 @@ v9fs_vfs_create_dotl(struct inode *dir, struct dentry *dentry, int omode, mode_t mode; struct v9fs_session_info *v9ses; struct p9_fid *fid = NULL; - struct p9_fid *dfid, *ofid; + struct p9_fid *dfid, *ofid, *inode_fid; struct file *filp; struct p9_qid qid; struct inode *inode; @@ -218,7 +218,33 @@ v9fs_vfs_create_dotl(struct inode *dir, struct dentry *dentry, int omode, /* Now set the ACL based on the default value */ v9fs_set_create_acl(dentry, dacl, pacl); - + /* + * In cached mode we need to attach a fid to inode. The fid + * attached to inode will only be used to write back the + * dirty pages. We always request for the open fid in read-write + * mode so that a partial page write which result in page + * read can work. + */ + if (v9ses->cache && !inode->i_private) { + /* + * clone a fid and add it to inode->i_private + * we do it during open time instead of + * page dirty time via write_begin/page_mkwrite + * because we want write after unlink usecase + * to work. + */ + inode_fid = v9fs_fid_clone(dentry); + if (IS_ERR(inode_fid)) { + err = PTR_ERR(inode_fid); + goto error; + } + err = p9_client_open(inode_fid, O_RDWR); + if (err < 0) { + p9_client_clunk(inode_fid); + goto error; + } + inode->i_private = (void *) inode_fid; + } /* Since we are opening a file, assign the open fid to the file */ filp = lookup_instantiate_filp(nd, dentry, generic_file_open); if (IS_ERR(filp)) {