aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
diff options
context:
space:
mode:
authorPeng Tao <bergwolf@gmail.com>2011-07-30 20:52:32 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2011-07-31 12:18:14 -0400
commit9fa4075878a5faac872a63f4a97ce79c776264e9 (patch)
treebcc2009c237cf5b8217ddb335f46ceed38a6e24d /fs/nfs
parentacff5880539fe33897d016c0f3dcf062e67c61b6 (diff)
pnfs: save layoutcommit cred at layout header init
No need to save it for every lseg. No need to save it at every pnfs_set_layoutcommit. [Needed in v3.0] CC: Stable Tree <stable@kernel.org> Signed-off-by: Peng Tao <peng_tao@emc.com> Signed-off-by: Boaz Harrosh <bharrosh@panasas.com> Signed-off-by: Jim Rees <rees@umich.edu> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/pnfs.c21
-rw-r--r--fs/nfs/pnfs.h2
2 files changed, 12 insertions, 11 deletions
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index 7a948ab4e73d..ab2cb04f8a28 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -190,6 +190,7 @@ static void
190pnfs_free_layout_hdr(struct pnfs_layout_hdr *lo) 190pnfs_free_layout_hdr(struct pnfs_layout_hdr *lo)
191{ 191{
192 struct pnfs_layoutdriver_type *ld = NFS_SERVER(lo->plh_inode)->pnfs_curr_ld; 192 struct pnfs_layoutdriver_type *ld = NFS_SERVER(lo->plh_inode)->pnfs_curr_ld;
193 put_rpccred(lo->plh_lc_cred);
193 return ld->alloc_layout_hdr ? ld->free_layout_hdr(lo) : kfree(lo); 194 return ld->alloc_layout_hdr ? ld->free_layout_hdr(lo) : kfree(lo);
194} 195}
195 196
@@ -816,7 +817,9 @@ out:
816} 817}
817 818
818static struct pnfs_layout_hdr * 819static struct pnfs_layout_hdr *
819alloc_init_layout_hdr(struct inode *ino, gfp_t gfp_flags) 820alloc_init_layout_hdr(struct inode *ino,
821 struct nfs_open_context *ctx,
822 gfp_t gfp_flags)
820{ 823{
821 struct pnfs_layout_hdr *lo; 824 struct pnfs_layout_hdr *lo;
822 825
@@ -828,11 +831,14 @@ alloc_init_layout_hdr(struct inode *ino, gfp_t gfp_flags)
828 INIT_LIST_HEAD(&lo->plh_segs); 831 INIT_LIST_HEAD(&lo->plh_segs);
829 INIT_LIST_HEAD(&lo->plh_bulk_recall); 832 INIT_LIST_HEAD(&lo->plh_bulk_recall);
830 lo->plh_inode = ino; 833 lo->plh_inode = ino;
834 lo->plh_lc_cred = get_rpccred(ctx->state->owner->so_cred);
831 return lo; 835 return lo;
832} 836}
833 837
834static struct pnfs_layout_hdr * 838static struct pnfs_layout_hdr *
835pnfs_find_alloc_layout(struct inode *ino, gfp_t gfp_flags) 839pnfs_find_alloc_layout(struct inode *ino,
840 struct nfs_open_context *ctx,
841 gfp_t gfp_flags)
836{ 842{
837 struct nfs_inode *nfsi = NFS_I(ino); 843 struct nfs_inode *nfsi = NFS_I(ino);
838 struct pnfs_layout_hdr *new = NULL; 844 struct pnfs_layout_hdr *new = NULL;
@@ -847,7 +853,7 @@ pnfs_find_alloc_layout(struct inode *ino, gfp_t gfp_flags)
847 return nfsi->layout; 853 return nfsi->layout;
848 } 854 }
849 spin_unlock(&ino->i_lock); 855 spin_unlock(&ino->i_lock);
850 new = alloc_init_layout_hdr(ino, gfp_flags); 856 new = alloc_init_layout_hdr(ino, ctx, gfp_flags);
851 spin_lock(&ino->i_lock); 857 spin_lock(&ino->i_lock);
852 858
853 if (likely(nfsi->layout == NULL)) /* Won the race? */ 859 if (likely(nfsi->layout == NULL)) /* Won the race? */
@@ -940,7 +946,7 @@ pnfs_update_layout(struct inode *ino,
940 if (!pnfs_enabled_sb(NFS_SERVER(ino))) 946 if (!pnfs_enabled_sb(NFS_SERVER(ino)))
941 return NULL; 947 return NULL;
942 spin_lock(&ino->i_lock); 948 spin_lock(&ino->i_lock);
943 lo = pnfs_find_alloc_layout(ino, gfp_flags); 949 lo = pnfs_find_alloc_layout(ino, ctx, gfp_flags);
944 if (lo == NULL) { 950 if (lo == NULL) {
945 dprintk("%s ERROR: can't get pnfs_layout_hdr\n", __func__); 951 dprintk("%s ERROR: can't get pnfs_layout_hdr\n", __func__);
946 goto out_unlock; 952 goto out_unlock;
@@ -1373,8 +1379,6 @@ pnfs_set_layoutcommit(struct nfs_write_data *wdata)
1373 if (!test_and_set_bit(NFS_INO_LAYOUTCOMMIT, &nfsi->flags)) { 1379 if (!test_and_set_bit(NFS_INO_LAYOUTCOMMIT, &nfsi->flags)) {
1374 /* references matched in nfs4_layoutcommit_release */ 1380 /* references matched in nfs4_layoutcommit_release */
1375 get_lseg(wdata->lseg); 1381 get_lseg(wdata->lseg);
1376 wdata->lseg->pls_lc_cred =
1377 get_rpccred(wdata->args.context->state->owner->so_cred);
1378 mark_as_dirty = true; 1382 mark_as_dirty = true;
1379 dprintk("%s: Set layoutcommit for inode %lu ", 1383 dprintk("%s: Set layoutcommit for inode %lu ",
1380 __func__, wdata->inode->i_ino); 1384 __func__, wdata->inode->i_ino);
@@ -1406,7 +1410,6 @@ pnfs_layoutcommit_inode(struct inode *inode, bool sync)
1406 struct nfs4_layoutcommit_data *data; 1410 struct nfs4_layoutcommit_data *data;
1407 struct nfs_inode *nfsi = NFS_I(inode); 1411 struct nfs_inode *nfsi = NFS_I(inode);
1408 struct pnfs_layout_segment *lseg; 1412 struct pnfs_layout_segment *lseg;
1409 struct rpc_cred *cred;
1410 loff_t end_pos; 1413 loff_t end_pos;
1411 int status = 0; 1414 int status = 0;
1412 1415
@@ -1436,9 +1439,7 @@ pnfs_layoutcommit_inode(struct inode *inode, bool sync)
1436 lseg = pnfs_list_write_lseg(inode); 1439 lseg = pnfs_list_write_lseg(inode);
1437 1440
1438 end_pos = nfsi->layout->plh_lwb; 1441 end_pos = nfsi->layout->plh_lwb;
1439 cred = lseg->pls_lc_cred;
1440 nfsi->layout->plh_lwb = 0; 1442 nfsi->layout->plh_lwb = 0;
1441 lseg->pls_lc_cred = NULL;
1442 1443
1443 memcpy(&data->args.stateid.data, nfsi->layout->plh_stateid.data, 1444 memcpy(&data->args.stateid.data, nfsi->layout->plh_stateid.data,
1444 sizeof(nfsi->layout->plh_stateid.data)); 1445 sizeof(nfsi->layout->plh_stateid.data));
@@ -1446,7 +1447,7 @@ pnfs_layoutcommit_inode(struct inode *inode, bool sync)
1446 1447
1447 data->args.inode = inode; 1448 data->args.inode = inode;
1448 data->lseg = lseg; 1449 data->lseg = lseg;
1449 data->cred = cred; 1450 data->cred = get_rpccred(nfsi->layout->plh_lc_cred);
1450 nfs_fattr_init(&data->fattr); 1451 nfs_fattr_init(&data->fattr);
1451 data->args.bitmask = NFS_SERVER(inode)->cache_consistency_bitmask; 1452 data->args.bitmask = NFS_SERVER(inode)->cache_consistency_bitmask;
1452 data->res.fattr = &data->fattr; 1453 data->res.fattr = &data->fattr;
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h
index 1eb2c043d23a..1f5cb47e2a2c 100644
--- a/fs/nfs/pnfs.h
+++ b/fs/nfs/pnfs.h
@@ -44,7 +44,6 @@ struct pnfs_layout_segment {
44 atomic_t pls_refcount; 44 atomic_t pls_refcount;
45 unsigned long pls_flags; 45 unsigned long pls_flags;
46 struct pnfs_layout_hdr *pls_layout; 46 struct pnfs_layout_hdr *pls_layout;
47 struct rpc_cred *pls_lc_cred; /* LAYOUTCOMMIT credential */
48}; 47};
49 48
50enum pnfs_try_status { 49enum pnfs_try_status {
@@ -125,6 +124,7 @@ struct pnfs_layout_hdr {
125 u32 plh_barrier; /* ignore lower seqids */ 124 u32 plh_barrier; /* ignore lower seqids */
126 unsigned long plh_flags; 125 unsigned long plh_flags;
127 loff_t plh_lwb; /* last write byte for layoutcommit */ 126 loff_t plh_lwb; /* last write byte for layoutcommit */
127 struct rpc_cred *plh_lc_cred; /* layoutcommit cred */
128 struct inode *plh_inode; 128 struct inode *plh_inode;
129}; 129};
130 130