aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/dir.c
diff options
context:
space:
mode:
authorDavid Quigley <dpquigl@davequigley.com>2013-05-22 12:50:43 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2013-06-08 16:20:15 -0400
commit14c43f767818c42f91ec7ffa586ee975845f68c8 (patch)
treee1f95f8344f144179d91c9531d83cd7de6684346 /fs/nfs/dir.c
parent1775fd3e805b6a852ef376256967de69284d7962 (diff)
NFS: Add label lifecycle management
This patch adds the lifecycle management for the security label structure introduced in an earlier patch. The label is not used yet but allocations and freeing of the structure is handled. Signed-off-by: Matthew N. Dodd <Matthew.Dodd@sparta.com> Signed-off-by: Miguel Rodel Felipe <Rodel_FM@dsi.a-star.edu.sg> Signed-off-by: Phua Eu Gene <PHUA_Eu_Gene@dsi.a-star.edu.sg> Signed-off-by: Khin Mi Mi Aung <Mi_Mi_AUNG@dsi.a-star.edu.sg> Signed-off-by: Steve Dickson <steved@redhat.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/dir.c')
-rw-r--r--fs/nfs/dir.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index e9ab2cd9dd3d..736b607ac8a8 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -585,10 +585,16 @@ int nfs_readdir_xdr_to_array(nfs_readdir_descriptor_t *desc, struct page *page,
585 if (entry.fh == NULL || entry.fattr == NULL) 585 if (entry.fh == NULL || entry.fattr == NULL)
586 goto out; 586 goto out;
587 587
588 entry.label = nfs4_label_alloc(NFS_SERVER(inode), GFP_NOWAIT);
589 if (IS_ERR(entry.label)) {
590 status = PTR_ERR(entry.label);
591 goto out;
592 }
593
588 array = nfs_readdir_get_array(page); 594 array = nfs_readdir_get_array(page);
589 if (IS_ERR(array)) { 595 if (IS_ERR(array)) {
590 status = PTR_ERR(array); 596 status = PTR_ERR(array);
591 goto out; 597 goto out_label_free;
592 } 598 }
593 memset(array, 0, sizeof(struct nfs_cache_array)); 599 memset(array, 0, sizeof(struct nfs_cache_array));
594 array->eof_index = -1; 600 array->eof_index = -1;
@@ -614,6 +620,8 @@ int nfs_readdir_xdr_to_array(nfs_readdir_descriptor_t *desc, struct page *page,
614 nfs_readdir_free_large_page(pages_ptr, pages, array_size); 620 nfs_readdir_free_large_page(pages_ptr, pages, array_size);
615out_release_array: 621out_release_array:
616 nfs_readdir_release_array(page); 622 nfs_readdir_release_array(page);
623out_label_free:
624 nfs4_label_free(entry.label);
617out: 625out:
618 nfs_free_fattr(entry.fattr); 626 nfs_free_fattr(entry.fattr);
619 nfs_free_fhandle(entry.fh); 627 nfs_free_fhandle(entry.fh);
@@ -1083,6 +1091,10 @@ static int nfs_lookup_revalidate(struct dentry *dentry, unsigned int flags)
1083 if (fhandle == NULL || fattr == NULL) 1091 if (fhandle == NULL || fattr == NULL)
1084 goto out_error; 1092 goto out_error;
1085 1093
1094 label = nfs4_label_alloc(NFS_SERVER(inode), GFP_NOWAIT);
1095 if (IS_ERR(label))
1096 goto out_error;
1097
1086 error = NFS_PROTO(dir)->lookup(dir, &dentry->d_name, fhandle, fattr, label); 1098 error = NFS_PROTO(dir)->lookup(dir, &dentry->d_name, fhandle, fattr, label);
1087 if (error) 1099 if (error)
1088 goto out_bad; 1100 goto out_bad;
@@ -1093,6 +1105,8 @@ static int nfs_lookup_revalidate(struct dentry *dentry, unsigned int flags)
1093 1105
1094 nfs_free_fattr(fattr); 1106 nfs_free_fattr(fattr);
1095 nfs_free_fhandle(fhandle); 1107 nfs_free_fhandle(fhandle);
1108 nfs4_label_free(label);
1109
1096out_set_verifier: 1110out_set_verifier:
1097 nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); 1111 nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
1098 out_valid: 1112 out_valid:
@@ -1109,6 +1123,7 @@ out_zap_parent:
1109 out_bad: 1123 out_bad:
1110 nfs_free_fattr(fattr); 1124 nfs_free_fattr(fattr);
1111 nfs_free_fhandle(fhandle); 1125 nfs_free_fhandle(fhandle);
1126 nfs4_label_free(label);
1112 nfs_mark_for_revalidate(dir); 1127 nfs_mark_for_revalidate(dir);
1113 if (inode && S_ISDIR(inode->i_mode)) { 1128 if (inode && S_ISDIR(inode->i_mode)) {
1114 /* Purge readdir caches. */ 1129 /* Purge readdir caches. */
@@ -1129,6 +1144,7 @@ out_zap_parent:
1129out_error: 1144out_error:
1130 nfs_free_fattr(fattr); 1145 nfs_free_fattr(fattr);
1131 nfs_free_fhandle(fhandle); 1146 nfs_free_fhandle(fhandle);
1147 nfs4_label_free(label);
1132 dput(parent); 1148 dput(parent);
1133 dfprintk(LOOKUPCACHE, "NFS: %s(%s/%s) lookup returned error %d\n", 1149 dfprintk(LOOKUPCACHE, "NFS: %s(%s/%s) lookup returned error %d\n",
1134 __func__, dentry->d_parent->d_name.name, 1150 __func__, dentry->d_parent->d_name.name,
@@ -1284,6 +1300,10 @@ struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, unsigned in
1284 if (fhandle == NULL || fattr == NULL) 1300 if (fhandle == NULL || fattr == NULL)
1285 goto out; 1301 goto out;
1286 1302
1303 label = nfs4_label_alloc(NFS_SERVER(dir), GFP_NOWAIT);
1304 if (IS_ERR(label))
1305 goto out;
1306
1287 parent = dentry->d_parent; 1307 parent = dentry->d_parent;
1288 /* Protect against concurrent sillydeletes */ 1308 /* Protect against concurrent sillydeletes */
1289 nfs_block_sillyrename(parent); 1309 nfs_block_sillyrename(parent);
@@ -1312,6 +1332,7 @@ no_entry:
1312 nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); 1332 nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
1313out_unblock_sillyrename: 1333out_unblock_sillyrename:
1314 nfs_unblock_sillyrename(parent); 1334 nfs_unblock_sillyrename(parent);
1335 nfs4_label_free(label);
1315out: 1336out:
1316 nfs_free_fattr(fattr); 1337 nfs_free_fattr(fattr);
1317 nfs_free_fhandle(fhandle); 1338 nfs_free_fhandle(fhandle);