From patchwork Sun May 29 18:26:07 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boaz Harrosh X-Patchwork-Id: 828252 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p4TIPXAT030111 for ; Sun, 29 May 2011 18:26:19 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755462Ab1E2S0T (ORCPT ); Sun, 29 May 2011 14:26:19 -0400 Received: from daytona.panasas.com ([67.152.220.89]:50932 "EHLO daytona.panasas.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755219Ab1E2S0S (ORCPT ); Sun, 29 May 2011 14:26:18 -0400 Received: from fs2.bhalevy.com ([172.17.33.72]) by daytona.panasas.com with Microsoft SMTPSVC(6.0.3790.4675); Sun, 29 May 2011 14:26:17 -0400 From: Boaz Harrosh To: Trond Myklebust , Benny Halevy , NFS list , open-osd Cc: Benny Halevy Subject: [PATCH 23/32] pnfs: layoutret_on_setattr Date: Sun, 29 May 2011 21:26:07 +0300 Message-Id: <1306693567-8355-1-git-send-email-bharrosh@panasas.com> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <4DE28CFB.4060608@panasas.com> References: <4DE28CFB.4060608@panasas.com> X-OriginalArrivalTime: 29 May 2011 18:26:17.0777 (UTC) FILETIME=[E694BA10:01CC1E2D] 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 (demeter1.kernel.org [140.211.167.41]); Sun, 29 May 2011 18:26:19 +0000 (UTC) From: Benny Halevy With the objects layout security model, we have object capabilities that are associated with the layout and we anticipate that the server will issue a cb_layoutrecall for any setattr that changes security related attributes (user/group/mode/acl) or truncates the file. Therefore, the layout is returned before issuing the setattr to avoid the anticipated cb_layoutrecall. Signed-off-by: Benny Halevy --- fs/nfs/nfs4proc.c | 3 +++ fs/nfs/objlayout/objio_osd.c | 1 + fs/nfs/pnfs.h | 22 ++++++++++++++++++++++ 3 files changed, 26 insertions(+), 0 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 5b4124e..5734009 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -2361,6 +2361,9 @@ nfs4_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr, struct nfs4_state *state = NULL; int status; + if (pnfs_ld_layoutret_on_setattr(inode)) + pnfs_return_layout(inode); + nfs_fattr_init(fattr); /* Search for an existing open(O_WRITE) file */ diff --git a/fs/nfs/objlayout/objio_osd.c b/fs/nfs/objlayout/objio_osd.c index cc92d3b..4e8de3e 100644 --- a/fs/nfs/objlayout/objio_osd.c +++ b/fs/nfs/objlayout/objio_osd.c @@ -964,6 +964,7 @@ objlayout_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev, static struct pnfs_layoutdriver_type objlayout_type = { .id = LAYOUT_OSD2_OBJECTS, .name = "LAYOUT_OSD2_OBJECTS", + .flags = PNFS_LAYOUTRET_ON_SETATTR, .alloc_layout_hdr = objlayout_alloc_layout_hdr, .free_layout_hdr = objlayout_free_layout_hdr, diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h index c34f7a0..af3967a 100644 --- a/fs/nfs/pnfs.h +++ b/fs/nfs/pnfs.h @@ -65,6 +65,11 @@ enum { NFS_LAYOUT_DESTROYED, /* no new use of layout allowed */ }; +enum layoutdriver_policy_flags { + /* Should the pNFS client commit and return the layout upon a setattr */ + PNFS_LAYOUTRET_ON_SETATTR = 1 << 0, +}; + struct nfs4_deviceid_node; /* Per-layout driver specific registration structure */ @@ -73,6 +78,7 @@ struct pnfs_layoutdriver_type { const u32 id; const char *name; struct module *owner; + unsigned flags; struct pnfs_layout_hdr * (*alloc_layout_hdr) (struct inode *inode, gfp_t gfp_flags); void (*free_layout_hdr) (struct pnfs_layout_hdr *); @@ -258,6 +264,16 @@ static inline void pnfs_clear_request_commit(struct nfs_page *req) put_lseg(req->wb_commit_lseg); } +/* Should the pNFS client commit and return the layout upon a setattr */ +static inline bool +pnfs_ld_layoutret_on_setattr(struct inode *inode) +{ + if (!pnfs_enabled_sb(NFS_SERVER(inode))) + return false; + return NFS_SERVER(inode)->pnfs_curr_ld->flags & + PNFS_LAYOUTRET_ON_SETATTR; +} + static inline int pnfs_return_layout(struct inode *ino) { struct nfs_inode *nfsi = NFS_I(ino); @@ -317,6 +333,12 @@ static inline int pnfs_return_layout(struct inode *ino) } static inline bool +pnfs_ld_layoutret_on_setattr(struct inode *inode) +{ + return false; +} + +static inline bool pnfs_roc(struct inode *ino) { return false;