From patchwork Tue Jun 7 17:26:19 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Rees X-Patchwork-Id: 857972 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p57HQZtY007780 for ; Tue, 7 Jun 2011 17:26:35 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932070Ab1FGR0c (ORCPT ); Tue, 7 Jun 2011 13:26:32 -0400 Received: from int-mailstore01.merit.edu ([207.75.116.232]:52703 "EHLO int-mailstore01.merit.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755123Ab1FGR03 (ORCPT ); Tue, 7 Jun 2011 13:26:29 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by int-mailstore01.merit.edu (Postfix) with ESMTP id 255E53083A4A; Tue, 7 Jun 2011 13:26:29 -0400 (EDT) X-Virus-Scanned: amavisd-new at int-mailstore01.merit.edu Received: from int-mailstore01.merit.edu ([127.0.0.1]) by localhost (int-mailstore01.merit.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id w5GvmCwvNwrU; Tue, 7 Jun 2011 13:26:27 -0400 (EDT) Received: from merit.edu (host-17.subnet-17.med.umich.edu [141.214.17.17]) by int-mailstore01.merit.edu (Postfix) with ESMTPSA id C00F830852FB; Tue, 7 Jun 2011 13:26:20 -0400 (EDT) Date: Tue, 7 Jun 2011 13:26:19 -0400 From: Jim Rees To: Benny Halevy Cc: linux-nfs@vger.kernel.org, peter honeyman Subject: [PATCH 04/88] pnfs_post_submit: Restore the pnfs_write_end part of "pnfs: commit and pnfs_write_end" Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Tue, 07 Jun 2011 17:26:35 +0000 (UTC) From: Fred Isaman pnfs: commit and pnfs_write_end Add hooks in the nfs_write_end path, giving a driver the potential for post-copy manipulation of the page. [pnfs: pass lseg from write_begin to write_end] Signed-off-by: Fred Isaman Signed-off-by: Benny Halevy [pnfs: fix pnfs_commit update_layout range] Whole file semantics are different for COMMIT (0,0) and layouts (0,NFS4_MAX_UINT64). Reported-by: Alexandros Batsakis Signed-off-by: Andy Adamson Signed-off-by: Fred Isaman Signed-off-by: Benny Halevy --- fs/nfs/file.c | 4 ++++ fs/nfs/pnfs.h | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 0 deletions(-) diff --git a/fs/nfs/file.c b/fs/nfs/file.c index 8c54b32..3af1c00 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c @@ -466,8 +466,12 @@ static int nfs_write_end(struct file *file, struct address_space *mapping, } lseg = nfs4_pull_lseg_from_fsdata(file, fsdata); + status = pnfs_write_end(file, page, pos, len, copied, lseg); + if (status) + goto out; status = nfs_updatepage(file, page, offset, copied); +out: unlock_page(page); page_cache_release(page); pnfs_write_end_cleanup(file, fsdata); diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h index 5712053..cfa8ea6 100644 --- a/fs/nfs/pnfs.h +++ b/fs/nfs/pnfs.h @@ -113,6 +113,9 @@ struct pnfs_layoutdriver_type { int (*write_begin) (struct pnfs_layout_segment *lseg, struct page *page, loff_t pos, unsigned count, struct pnfs_fsdata *fsdata); + int (*write_end)(struct inode *inode, struct page *page, loff_t pos, + unsigned count, unsigned copied, + struct pnfs_layout_segment *lseg); void (*free_deviceid_node) (struct nfs4_deviceid_node *); @@ -333,6 +336,21 @@ static inline int pnfs_write_begin(struct file *filp, struct page *page, return status; } +/* CAREFUL - what happens if copied < len??? */ +static inline int pnfs_write_end(struct file *filp, struct page *page, + loff_t pos, unsigned len, unsigned copied, + struct pnfs_layout_segment *lseg) +{ + struct inode *inode = filp->f_dentry->d_inode; + struct nfs_server *nfss = NFS_SERVER(inode); + + if (nfss->pnfs_curr_ld && nfss->pnfs_curr_ld->write_end) + return nfss->pnfs_curr_ld->write_end(inode, page, pos, len, + copied, lseg); + else + return 0; +} + static inline void pnfs_write_end_cleanup(struct file *filp, void *fsdata) { struct nfs_server *nfss = NFS_SERVER(filp->f_dentry->d_inode); @@ -432,6 +450,13 @@ static inline int pnfs_write_begin(struct file *filp, struct page *page, return 0; } +static inline int pnfs_write_end(struct file *filp, struct page *page, + loff_t pos, unsigned len, unsigned copied, + struct pnfs_layout_segment *lseg) +{ + return 0; +} + static inline void pnfs_write_end_cleanup(struct file *filp, void *fsdata) { }