Skip to content

Commit 8a1636c

Browse files
Benny HalevyBoaz Harrosh
authored andcommitted
pnfs: layoutret_on_setattr
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 <bhalevy@panasas.com>
1 parent cbe8260 commit 8a1636c

3 files changed

Lines changed: 26 additions & 0 deletions

File tree

‎fs/nfs/nfs4proc.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2361,6 +2361,9 @@ nfs4_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,
23612361
struct nfs4_state *state = NULL;
23622362
int status;
23632363

2364+
if (pnfs_ld_layoutret_on_setattr(inode))
2365+
pnfs_return_layout(inode);
2366+
23642367
nfs_fattr_init(fattr);
23652368

23662369
/* Search for an existing open(O_WRITE) file */

‎fs/nfs/objlayout/objio_osd.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,7 @@ objlayout_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev,
964964
static struct pnfs_layoutdriver_type objlayout_type = {
965965
.id = LAYOUT_OSD2_OBJECTS,
966966
.name = "LAYOUT_OSD2_OBJECTS",
967+
.flags = PNFS_LAYOUTRET_ON_SETATTR,
967968

968969
.alloc_layout_hdr = objlayout_alloc_layout_hdr,
969970
.free_layout_hdr = objlayout_free_layout_hdr,

‎fs/nfs/pnfs.h‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ enum {
6565
NFS_LAYOUT_DESTROYED, /* no new use of layout allowed */
6666
};
6767

68+
enum layoutdriver_policy_flags {
69+
/* Should the pNFS client commit and return the layout upon a setattr */
70+
PNFS_LAYOUTRET_ON_SETATTR = 1 << 0,
71+
};
72+
6873
struct nfs4_deviceid_node;
6974

7075
/* Per-layout driver specific registration structure */
@@ -73,6 +78,7 @@ struct pnfs_layoutdriver_type {
7378
const u32 id;
7479
const char *name;
7580
struct module *owner;
81+
unsigned flags;
7682

7783
struct pnfs_layout_hdr * (*alloc_layout_hdr) (struct inode *inode, gfp_t gfp_flags);
7884
void (*free_layout_hdr) (struct pnfs_layout_hdr *);
@@ -258,6 +264,16 @@ static inline void pnfs_clear_request_commit(struct nfs_page *req)
258264
put_lseg(req->wb_commit_lseg);
259265
}
260266

267+
/* Should the pNFS client commit and return the layout upon a setattr */
268+
static inline bool
269+
pnfs_ld_layoutret_on_setattr(struct inode *inode)
270+
{
271+
if (!pnfs_enabled_sb(NFS_SERVER(inode)))
272+
return false;
273+
return NFS_SERVER(inode)->pnfs_curr_ld->flags &
274+
PNFS_LAYOUTRET_ON_SETATTR;
275+
}
276+
261277
static inline int pnfs_return_layout(struct inode *ino)
262278
{
263279
struct nfs_inode *nfsi = NFS_I(ino);
@@ -316,6 +332,12 @@ static inline int pnfs_return_layout(struct inode *ino)
316332
return 0;
317333
}
318334

335+
static inline bool
336+
pnfs_ld_layoutret_on_setattr(struct inode *inode)
337+
{
338+
return false;
339+
}
340+
319341
static inline bool
320342
pnfs_roc(struct inode *ino)
321343
{

0 commit comments

Comments
 (0)