aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2011-07-23 03:10:32 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2011-07-25 14:27:32 -0400
commit826cae2f2b4d726b925f43bc208a571639da4761 (patch)
treeb7f83eecf3bde8c4e455d89c7c535988b3e8bd59
parent95203befa8887997f14077d8557e67d78457ee02 (diff)
kill boilerplates around posix_acl_create_masq()
new helper: posix_acl_create(&acl, gfp, mode_p). Replaces acl with modified clone, on failure releases acl and replaces with NULL. Returns 0 or -ve on error. All callers of posix_acl_create_masq() switched. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--fs/9p/acl.c22
-rw-r--r--fs/btrfs/acl.c24
-rw-r--r--fs/ext2/acl.c25
-rw-r--r--fs/ext3/acl.c26
-rw-r--r--fs/ext4/acl.c26
-rw-r--r--fs/generic_acl.c20
-rw-r--r--fs/gfs2/acl.c14
-rw-r--r--fs/jffs2/acl.c15
-rw-r--r--fs/jfs/acl.c23
-rw-r--r--fs/nfs/nfs3acl.c10
-rw-r--r--fs/ocfs2/acl.c36
-rw-r--r--fs/posix_acl.c18
-rw-r--r--fs/reiserfs/xattr_acl.c30
-rw-r--r--fs/xfs/linux-2.6/xfs_acl.c28
-rw-r--r--fs/xfs/linux-2.6/xfs_iops.c2
-rw-r--r--include/linux/posix_acl.h1
16 files changed, 116 insertions, 204 deletions
diff --git a/fs/9p/acl.c b/fs/9p/acl.c
index d7211e28c0d1..075bc909da17 100644
--- a/fs/9p/acl.c
+++ b/fs/9p/acl.c
@@ -206,30 +206,18 @@ int v9fs_acl_mode(struct inode *dir, mode_t *modep,
206 mode &= ~current_umask(); 206 mode &= ~current_umask();
207 } 207 }
208 if (acl) { 208 if (acl) {
209 struct posix_acl *clone;
210
211 if (S_ISDIR(mode)) 209 if (S_ISDIR(mode))
212 *dpacl = posix_acl_dup(acl); 210 *dpacl = posix_acl_dup(acl);
213 clone = posix_acl_clone(acl, GFP_NOFS); 211 retval = posix_acl_create(&acl, GFP_NOFS, &mode);
214 posix_acl_release(acl); 212 if (retval < 0)
215 if (!clone) 213 return retval;
216 return -ENOMEM;
217
218 retval = posix_acl_create_masq(clone, &mode);
219 if (retval < 0) {
220 posix_acl_release(clone);
221 goto cleanup;
222 }
223 if (retval > 0) 214 if (retval > 0)
224 *pacl = clone; 215 *pacl = acl;
225 else 216 else
226 posix_acl_release(clone); 217 posix_acl_release(acl);
227 } 218 }
228 *modep = mode; 219 *modep = mode;
229 return 0; 220 return 0;
230cleanup:
231 return retval;
232
233} 221}
234 222
235static int v9fs_remote_get_acl(struct dentry *dentry, const char *name, 223static int v9fs_remote_get_acl(struct dentry *dentry, const char *name,
diff --git a/fs/btrfs/acl.c b/fs/btrfs/acl.c
index 88bca53b302a..9508ad14c924 100644
--- a/fs/btrfs/acl.c
+++ b/fs/btrfs/acl.c
@@ -238,8 +238,7 @@ int btrfs_init_acl(struct btrfs_trans_handle *trans,
238 } 238 }
239 239
240 if (IS_POSIXACL(dir) && acl) { 240 if (IS_POSIXACL(dir) && acl) {
241 struct posix_acl *clone; 241 mode_t mode = inode->i_mode;
242 mode_t mode;
243 242
244 if (S_ISDIR(inode->i_mode)) { 243 if (S_ISDIR(inode->i_mode)) {
245 ret = btrfs_set_acl(trans, inode, acl, 244 ret = btrfs_set_acl(trans, inode, acl,
@@ -247,22 +246,15 @@ int btrfs_init_acl(struct btrfs_trans_handle *trans,
247 if (ret) 246 if (ret)
248 goto failed; 247 goto failed;
249 } 248 }
250 clone = posix_acl_clone(acl, GFP_NOFS); 249 ret = posix_acl_create(&acl, GFP_NOFS, &mode);
251 ret = -ENOMEM; 250 if (ret < 0)
252 if (!clone) 251 return ret;
253 goto failed;
254 252
255 mode = inode->i_mode; 253 inode->i_mode = mode;
256 ret = posix_acl_create_masq(clone, &mode); 254 if (ret > 0) {
257 if (ret >= 0) { 255 /* we need an acl */
258 inode->i_mode = mode; 256 ret = btrfs_set_acl(trans, inode, acl, ACL_TYPE_ACCESS);
259 if (ret > 0) {
260 /* we need an acl */
261 ret = btrfs_set_acl(trans, inode, clone,
262 ACL_TYPE_ACCESS);
263 }
264 } 257 }
265 posix_acl_release(clone);
266 } 258 }
267failed: 259failed:
268 posix_acl_release(acl); 260 posix_acl_release(acl);
diff --git a/fs/ext2/acl.c b/fs/ext2/acl.c
index 1226dbcc66f5..ba99fa4b2f35 100644
--- a/fs/ext2/acl.c
+++ b/fs/ext2/acl.c
@@ -270,29 +270,20 @@ ext2_init_acl(struct inode *inode, struct inode *dir)
270 inode->i_mode &= ~current_umask(); 270 inode->i_mode &= ~current_umask();
271 } 271 }
272 if (test_opt(inode->i_sb, POSIX_ACL) && acl) { 272 if (test_opt(inode->i_sb, POSIX_ACL) && acl) {
273 struct posix_acl *clone; 273 mode_t mode = inode->i_mode;
274 mode_t mode;
275
276 if (S_ISDIR(inode->i_mode)) { 274 if (S_ISDIR(inode->i_mode)) {
277 error = ext2_set_acl(inode, ACL_TYPE_DEFAULT, acl); 275 error = ext2_set_acl(inode, ACL_TYPE_DEFAULT, acl);
278 if (error) 276 if (error)
279 goto cleanup; 277 goto cleanup;
280 } 278 }
281 clone = posix_acl_clone(acl, GFP_KERNEL); 279 error = posix_acl_create(&acl, GFP_KERNEL, &mode);
282 error = -ENOMEM; 280 if (error < 0)
283 if (!clone) 281 return error;
284 goto cleanup; 282 inode->i_mode = mode;
285 mode = inode->i_mode; 283 if (error > 0) {
286 error = posix_acl_create_masq(clone, &mode); 284 /* This is an extended ACL */
287 if (error >= 0) { 285 error = ext2_set_acl(inode, ACL_TYPE_ACCESS, acl);
288 inode->i_mode = mode;
289 if (error > 0) {
290 /* This is an extended ACL */
291 error = ext2_set_acl(inode,
292 ACL_TYPE_ACCESS, clone);
293 }
294 } 286 }
295 posix_acl_release(clone);
296 } 287 }
297cleanup: 288cleanup:
298 posix_acl_release(acl); 289 posix_acl_release(acl);
diff --git a/fs/ext3/acl.c b/fs/ext3/acl.c
index 7ea638acaecf..a9fdd77d4b58 100644
--- a/fs/ext3/acl.c
+++ b/fs/ext3/acl.c
@@ -278,8 +278,7 @@ ext3_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
278 inode->i_mode &= ~current_umask(); 278 inode->i_mode &= ~current_umask();
279 } 279 }
280 if (test_opt(inode->i_sb, POSIX_ACL) && acl) { 280 if (test_opt(inode->i_sb, POSIX_ACL) && acl) {
281 struct posix_acl *clone; 281 mode_t mode = inode->i_mode;
282 mode_t mode;
283 282
284 if (S_ISDIR(inode->i_mode)) { 283 if (S_ISDIR(inode->i_mode)) {
285 error = ext3_set_acl(handle, inode, 284 error = ext3_set_acl(handle, inode,
@@ -287,22 +286,15 @@ ext3_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
287 if (error) 286 if (error)
288 goto cleanup; 287 goto cleanup;
289 } 288 }
290 clone = posix_acl_clone(acl, GFP_NOFS); 289 error = posix_acl_create(&acl, GFP_NOFS, &mode);
291 error = -ENOMEM; 290 if (error < 0)
292 if (!clone) 291 return error;
293 goto cleanup; 292
294 293 inode->i_mode = mode;
295 mode = inode->i_mode; 294 if (error > 0) {
296 error = posix_acl_create_masq(clone, &mode); 295 /* This is an extended ACL */
297 if (error >= 0) { 296 error = ext3_set_acl(handle, inode, ACL_TYPE_ACCESS, acl);
298 inode->i_mode = mode;
299 if (error > 0) {
300 /* This is an extended ACL */
301 error = ext3_set_acl(handle, inode,
302 ACL_TYPE_ACCESS, clone);
303 }
304 } 297 }
305 posix_acl_release(clone);
306 } 298 }
307cleanup: 299cleanup:
308 posix_acl_release(acl); 300 posix_acl_release(acl);
diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c
index e38a2047d246..7b094d1a8d3e 100644
--- a/fs/ext4/acl.c
+++ b/fs/ext4/acl.c
@@ -276,8 +276,7 @@ ext4_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
276 inode->i_mode &= ~current_umask(); 276 inode->i_mode &= ~current_umask();
277 } 277 }
278 if (test_opt(inode->i_sb, POSIX_ACL) && acl) { 278 if (test_opt(inode->i_sb, POSIX_ACL) && acl) {
279 struct posix_acl *clone; 279 mode_t mode = inode->i_mode;
280 mode_t mode;
281 280
282 if (S_ISDIR(inode->i_mode)) { 281 if (S_ISDIR(inode->i_mode)) {
283 error = ext4_set_acl(handle, inode, 282 error = ext4_set_acl(handle, inode,
@@ -285,22 +284,15 @@ ext4_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
285 if (error) 284 if (error)
286 goto cleanup; 285 goto cleanup;
287 } 286 }
288 clone = posix_acl_clone(acl, GFP_NOFS); 287 error = posix_acl_create(&acl, GFP_NOFS, &mode);
289 error = -ENOMEM; 288 if (error < 0)
290 if (!clone) 289 return error;
291 goto cleanup; 290
292 291 inode->i_mode = mode;
293 mode = inode->i_mode; 292 if (error > 0) {
294 error = posix_acl_create_masq(clone, &mode); 293 /* This is an extended ACL */
295 if (error >= 0) { 294 error = ext4_set_acl(handle, inode, ACL_TYPE_ACCESS, acl);
296 inode->i_mode = mode;
297 if (error > 0) {
298 /* This is an extended ACL */
299 error = ext4_set_acl(handle, inode,
300 ACL_TYPE_ACCESS, clone);
301 }
302 } 295 }
303 posix_acl_release(clone);
304 } 296 }
305cleanup: 297cleanup:
306 posix_acl_release(acl); 298 posix_acl_release(acl);
diff --git a/fs/generic_acl.c b/fs/generic_acl.c
index 134782116a62..ea19ca47d452 100644
--- a/fs/generic_acl.c
+++ b/fs/generic_acl.c
@@ -132,25 +132,17 @@ generic_acl_init(struct inode *inode, struct inode *dir)
132 if (!S_ISLNK(inode->i_mode)) 132 if (!S_ISLNK(inode->i_mode))
133 acl = get_cached_acl(dir, ACL_TYPE_DEFAULT); 133 acl = get_cached_acl(dir, ACL_TYPE_DEFAULT);
134 if (acl) { 134 if (acl) {
135 struct posix_acl *clone;
136
137 if (S_ISDIR(inode->i_mode)) 135 if (S_ISDIR(inode->i_mode))
138 set_cached_acl(inode, ACL_TYPE_DEFAULT, acl); 136 set_cached_acl(inode, ACL_TYPE_DEFAULT, acl);
139 clone = posix_acl_clone(acl, GFP_KERNEL); 137 error = posix_acl_create(&acl, GFP_KERNEL, &mode);
140 error = -ENOMEM; 138 if (error < 0)
141 if (!clone) 139 return error;
142 goto cleanup; 140 inode->i_mode = mode;
143 error = posix_acl_create_masq(clone, &mode); 141 if (error > 0)
144 if (error >= 0) { 142 set_cached_acl(inode, ACL_TYPE_ACCESS, acl);
145 inode->i_mode = mode;
146 if (error > 0)
147 set_cached_acl(inode, ACL_TYPE_ACCESS, clone);
148 }
149 posix_acl_release(clone);
150 } 143 }
151 error = 0; 144 error = 0;
152 145
153cleanup:
154 posix_acl_release(acl); 146 posix_acl_release(acl);
155 return error; 147 return error;
156} 148}
diff --git a/fs/gfs2/acl.c b/fs/gfs2/acl.c
index 160d4e1575ce..a2dd63c0c11a 100644
--- a/fs/gfs2/acl.c
+++ b/fs/gfs2/acl.c
@@ -137,7 +137,7 @@ out:
137int gfs2_acl_create(struct gfs2_inode *dip, struct inode *inode) 137int gfs2_acl_create(struct gfs2_inode *dip, struct inode *inode)
138{ 138{
139 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); 139 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
140 struct posix_acl *acl, *clone; 140 struct posix_acl *acl;
141 mode_t mode = inode->i_mode; 141 mode_t mode = inode->i_mode;
142 int error = 0; 142 int error = 0;
143 143
@@ -162,16 +162,10 @@ int gfs2_acl_create(struct gfs2_inode *dip, struct inode *inode)
162 goto out; 162 goto out;
163 } 163 }
164 164
165 clone = posix_acl_clone(acl, GFP_NOFS); 165 error = posix_acl_create(&acl, GFP_NOFS, &mode);
166 error = -ENOMEM;
167 if (!clone)
168 goto out;
169 posix_acl_release(acl);
170 acl = clone;
171
172 error = posix_acl_create_masq(acl, &mode);
173 if (error < 0) 166 if (error < 0)
174 goto out; 167 return error;
168
175 if (error == 0) 169 if (error == 0)
176 goto munge; 170 goto munge;
177 171
diff --git a/fs/jffs2/acl.c b/fs/jffs2/acl.c
index 71d022d38508..5783ed81171b 100644
--- a/fs/jffs2/acl.c
+++ b/fs/jffs2/acl.c
@@ -277,7 +277,7 @@ int jffs2_check_acl(struct inode *inode, int mask)
277 277
278int jffs2_init_acl_pre(struct inode *dir_i, struct inode *inode, mode_t *i_mode) 278int jffs2_init_acl_pre(struct inode *dir_i, struct inode *inode, mode_t *i_mode)
279{ 279{
280 struct posix_acl *acl, *clone; 280 struct posix_acl *acl;
281 int rc; 281 int rc;
282 282
283 cache_no_acl(inode); 283 cache_no_acl(inode);
@@ -295,18 +295,13 @@ int jffs2_init_acl_pre(struct inode *dir_i, struct inode *inode, mode_t *i_mode)
295 if (S_ISDIR(*i_mode)) 295 if (S_ISDIR(*i_mode))
296 set_cached_acl(inode, ACL_TYPE_DEFAULT, acl); 296 set_cached_acl(inode, ACL_TYPE_DEFAULT, acl);
297 297
298 clone = posix_acl_clone(acl, GFP_KERNEL); 298 rc = posix_acl_create(&acl, GFP_KERNEL, i_mode);
299 if (!clone) 299 if (rc < 0)
300 return -ENOMEM;
301 rc = posix_acl_create_masq(clone, i_mode);
302 if (rc < 0) {
303 posix_acl_release(clone);
304 return rc; 300 return rc;
305 }
306 if (rc > 0) 301 if (rc > 0)
307 set_cached_acl(inode, ACL_TYPE_ACCESS, clone); 302 set_cached_acl(inode, ACL_TYPE_ACCESS, acl);
308 303
309 posix_acl_release(clone); 304 posix_acl_release(acl);
310 } 305 }
311 return 0; 306 return 0;
312} 307}
diff --git a/fs/jfs/acl.c b/fs/jfs/acl.c
index 89ced71e225a..687a1ae42e3f 100644
--- a/fs/jfs/acl.c
+++ b/fs/jfs/acl.c
@@ -133,8 +133,6 @@ int jfs_check_acl(struct inode *inode, int mask)
133int jfs_init_acl(tid_t tid, struct inode *inode, struct inode *dir) 133int jfs_init_acl(tid_t tid, struct inode *inode, struct inode *dir)
134{ 134{
135 struct posix_acl *acl = NULL; 135 struct posix_acl *acl = NULL;
136 struct posix_acl *clone;
137 mode_t mode;
138 int rc = 0; 136 int rc = 0;
139 137
140 if (S_ISLNK(inode->i_mode)) 138 if (S_ISLNK(inode->i_mode))
@@ -145,25 +143,18 @@ int jfs_init_acl(tid_t tid, struct inode *inode, struct inode *dir)
145 return PTR_ERR(acl); 143 return PTR_ERR(acl);
146 144
147 if (acl) { 145 if (acl) {
146 mode_t mode = inode->i_mode;
148 if (S_ISDIR(inode->i_mode)) { 147 if (S_ISDIR(inode->i_mode)) {
149 rc = jfs_set_acl(tid, inode, ACL_TYPE_DEFAULT, acl); 148 rc = jfs_set_acl(tid, inode, ACL_TYPE_DEFAULT, acl);
150 if (rc) 149 if (rc)
151 goto cleanup; 150 goto cleanup;
152 } 151 }
153 clone = posix_acl_clone(acl, GFP_KERNEL); 152 rc = posix_acl_create(&acl, GFP_KERNEL, &mode);
154 if (!clone) { 153 if (rc < 0)
155 rc = -ENOMEM; 154 goto cleanup; /* posix_acl_release(NULL) is no-op */
156 goto cleanup; 155 inode->i_mode = mode;
157 } 156 if (rc > 0)
158 mode = inode->i_mode; 157 rc = jfs_set_acl(tid, inode, ACL_TYPE_ACCESS, acl);
159 rc = posix_acl_create_masq(clone, &mode);
160 if (rc >= 0) {
161 inode->i_mode = mode;
162 if (rc > 0)
163 rc = jfs_set_acl(tid, inode, ACL_TYPE_ACCESS,
164 clone);
165 }
166 posix_acl_release(clone);
167cleanup: 158cleanup:
168 posix_acl_release(acl); 159 posix_acl_release(acl);
169 } else 160 } else
diff --git a/fs/nfs/nfs3acl.c b/fs/nfs/nfs3acl.c
index 274342771655..e49e73107e62 100644
--- a/fs/nfs/nfs3acl.c
+++ b/fs/nfs/nfs3acl.c
@@ -427,16 +427,12 @@ int nfs3_proc_set_default_acl(struct inode *dir, struct inode *inode,
427 } 427 }
428 if (!dfacl) 428 if (!dfacl)
429 return 0; 429 return 0;
430 acl = posix_acl_clone(dfacl, GFP_KERNEL); 430 acl = posix_acl_dup(dfacl);
431 error = -ENOMEM; 431 error = posix_acl_create(&acl, GFP_KERNEL, &mode);
432 if (!acl)
433 goto out_release_dfacl;
434 error = posix_acl_create_masq(acl, &mode);
435 if (error < 0) 432 if (error < 0)
436 goto out_release_acl; 433 goto out_release_dfacl;
437 error = nfs3_proc_setacls(inode, acl, S_ISDIR(inode->i_mode) ? 434 error = nfs3_proc_setacls(inode, acl, S_ISDIR(inode->i_mode) ?
438 dfacl : NULL); 435 dfacl : NULL);
439out_release_acl:
440 posix_acl_release(acl); 436 posix_acl_release(acl);
441out_release_dfacl: 437out_release_dfacl:
442 posix_acl_release(dfacl); 438 posix_acl_release(dfacl);
diff --git a/fs/ocfs2/acl.c b/fs/ocfs2/acl.c
index dd0296ade181..480200e94e83 100644
--- a/fs/ocfs2/acl.c
+++ b/fs/ocfs2/acl.c
@@ -382,8 +382,6 @@ int ocfs2_init_acl(handle_t *handle,
382 } 382 }
383 } 383 }
384 if ((osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL) && acl) { 384 if ((osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL) && acl) {
385 struct posix_acl *clone;
386
387 if (S_ISDIR(inode->i_mode)) { 385 if (S_ISDIR(inode->i_mode)) {
388 ret = ocfs2_set_acl(handle, inode, di_bh, 386 ret = ocfs2_set_acl(handle, inode, di_bh,
389 ACL_TYPE_DEFAULT, acl, 387 ACL_TYPE_DEFAULT, acl,
@@ -391,28 +389,22 @@ int ocfs2_init_acl(handle_t *handle,
391 if (ret) 389 if (ret)
392 goto cleanup; 390 goto cleanup;
393 } 391 }
394 clone = posix_acl_clone(acl, GFP_NOFS);
395 ret = -ENOMEM;
396 if (!clone)
397 goto cleanup;
398
399 mode = inode->i_mode; 392 mode = inode->i_mode;
400 ret = posix_acl_create_masq(clone, &mode); 393 ret = posix_acl_create(&acl, GFP_NOFS, &mode);
401 if (ret >= 0) { 394 if (ret < 0)
402 ret2 = ocfs2_acl_set_mode(inode, di_bh, handle, mode); 395 return ret;
403 if (ret2) { 396
404 mlog_errno(ret2); 397 ret2 = ocfs2_acl_set_mode(inode, di_bh, handle, mode);
405 ret = ret2; 398 if (ret2) {
406 posix_acl_release(clone); 399 mlog_errno(ret2);
407 goto cleanup; 400 ret = ret2;
408 } 401 goto cleanup;
409 if (ret > 0) { 402 }
410 ret = ocfs2_set_acl(handle, inode, 403 if (ret > 0) {
411 di_bh, ACL_TYPE_ACCESS, 404 ret = ocfs2_set_acl(handle, inode,
412 clone, meta_ac, data_ac); 405 di_bh, ACL_TYPE_ACCESS,
413 } 406 acl, meta_ac, data_ac);
414 } 407 }
415 posix_acl_release(clone);
416 } 408 }
417cleanup: 409cleanup:
418 posix_acl_release(acl); 410 posix_acl_release(acl);
diff --git a/fs/posix_acl.c b/fs/posix_acl.c
index 0aa9f1676726..365a0712da6a 100644
--- a/fs/posix_acl.c
+++ b/fs/posix_acl.c
@@ -388,6 +388,24 @@ posix_acl_chmod_masq(struct posix_acl *acl, mode_t mode)
388} 388}
389 389
390int 390int
391posix_acl_create(struct posix_acl **acl, gfp_t gfp, mode_t *mode_p)
392{
393 struct posix_acl *clone = posix_acl_clone(*acl, gfp);
394 int err = -ENOMEM;
395 if (clone) {
396 err = posix_acl_create_masq(clone, mode_p);
397 if (err < 0) {
398 posix_acl_release(clone);
399 clone = NULL;
400 }
401 }
402 posix_acl_release(*acl);
403 *acl = clone;
404 return err;
405}
406EXPORT_SYMBOL(posix_acl_create);
407
408int
391posix_acl_chmod(struct posix_acl **acl, gfp_t gfp, mode_t mode) 409posix_acl_chmod(struct posix_acl **acl, gfp_t gfp, mode_t mode)
392{ 410{
393 struct posix_acl *clone = posix_acl_clone(*acl, gfp); 411 struct posix_acl *clone = posix_acl_clone(*acl, gfp);
diff --git a/fs/reiserfs/xattr_acl.c b/fs/reiserfs/xattr_acl.c
index 26b08acf913f..7362cf4c946a 100644
--- a/fs/reiserfs/xattr_acl.c
+++ b/fs/reiserfs/xattr_acl.c
@@ -354,9 +354,7 @@ reiserfs_inherit_default_acl(struct reiserfs_transaction_handle *th,
354 return PTR_ERR(acl); 354 return PTR_ERR(acl);
355 355
356 if (acl) { 356 if (acl) {
357 struct posix_acl *acl_copy;
358 mode_t mode = inode->i_mode; 357 mode_t mode = inode->i_mode;
359 int need_acl;
360 358
361 /* Copy the default ACL to the default ACL of a new directory */ 359 /* Copy the default ACL to the default ACL of a new directory */
362 if (S_ISDIR(inode->i_mode)) { 360 if (S_ISDIR(inode->i_mode)) {
@@ -368,29 +366,15 @@ reiserfs_inherit_default_acl(struct reiserfs_transaction_handle *th,
368 366
369 /* Now we reconcile the new ACL and the mode, 367 /* Now we reconcile the new ACL and the mode,
370 potentially modifying both */ 368 potentially modifying both */
371 acl_copy = posix_acl_clone(acl, GFP_NOFS); 369 err = posix_acl_create(&acl, GFP_NOFS, &mode);
372 if (!acl_copy) { 370 if (err < 0)
373 err = -ENOMEM; 371 return err;
374 goto cleanup;
375 }
376 372
377 need_acl = posix_acl_create_masq(acl_copy, &mode); 373 inode->i_mode = mode;
378 if (need_acl >= 0) {
379 if (mode != inode->i_mode) {
380 inode->i_mode = mode;
381 }
382 374
383 /* If we need an ACL.. */ 375 /* If we need an ACL.. */
384 if (need_acl > 0) { 376 if (err > 0)
385 err = reiserfs_set_acl(th, inode, 377 err = reiserfs_set_acl(th, inode, ACL_TYPE_ACCESS, acl);
386 ACL_TYPE_ACCESS,
387 acl_copy);
388 if (err)
389 goto cleanup_copy;
390 }
391 }
392 cleanup_copy:
393 posix_acl_release(acl_copy);
394 cleanup: 378 cleanup:
395 posix_acl_release(acl); 379 posix_acl_release(acl);
396 } else { 380 } else {
diff --git a/fs/xfs/linux-2.6/xfs_acl.c b/fs/xfs/linux-2.6/xfs_acl.c
index 4c554122db02..2827bbd8366e 100644
--- a/fs/xfs/linux-2.6/xfs_acl.c
+++ b/fs/xfs/linux-2.6/xfs_acl.c
@@ -282,29 +282,23 @@ posix_acl_default_exists(struct inode *inode)
282 * No need for i_mutex because the inode is not yet exposed to the VFS. 282 * No need for i_mutex because the inode is not yet exposed to the VFS.
283 */ 283 */
284int 284int
285xfs_inherit_acl(struct inode *inode, struct posix_acl *default_acl) 285xfs_inherit_acl(struct inode *inode, struct posix_acl *acl)
286{ 286{
287 struct posix_acl *clone; 287 mode_t mode = inode->i_mode;
288 mode_t mode;
289 int error = 0, inherit = 0; 288 int error = 0, inherit = 0;
290 289
291 if (S_ISDIR(inode->i_mode)) { 290 if (S_ISDIR(inode->i_mode)) {
292 error = xfs_set_acl(inode, ACL_TYPE_DEFAULT, default_acl); 291 error = xfs_set_acl(inode, ACL_TYPE_DEFAULT, acl);
293 if (error) 292 if (error)
294 return error; 293 goto out;
295 } 294 }
296 295
297 clone = posix_acl_clone(default_acl, GFP_KERNEL); 296 error = posix_acl_create(&acl, GFP_KERNEL, &mode);
298 if (!clone)
299 return -ENOMEM;
300
301 mode = inode->i_mode;
302 error = posix_acl_create_masq(clone, &mode);
303 if (error < 0) 297 if (error < 0)
304 goto out_release_clone; 298 return error;
305 299
306 /* 300 /*
307 * If posix_acl_create_masq returns a positive value we need to 301 * If posix_acl_create returns a positive value we need to
308 * inherit a permission that can't be represented using the Unix 302 * inherit a permission that can't be represented using the Unix
309 * mode bits and we actually need to set an ACL. 303 * mode bits and we actually need to set an ACL.
310 */ 304 */
@@ -313,13 +307,13 @@ xfs_inherit_acl(struct inode *inode, struct posix_acl *default_acl)
313 307
314 error = xfs_set_mode(inode, mode); 308 error = xfs_set_mode(inode, mode);
315 if (error) 309 if (error)
316 goto out_release_clone; 310 goto out;
317 311
318 if (inherit) 312 if (inherit)
319 error = xfs_set_acl(inode, ACL_TYPE_ACCESS, clone); 313 error = xfs_set_acl(inode, ACL_TYPE_ACCESS, acl);
320 314
321 out_release_clone: 315out:
322 posix_acl_release(clone); 316 posix_acl_release(acl);
323 return error; 317 return error;
324} 318}
325 319
diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c
index de666917db06..77463dd55198 100644
--- a/fs/xfs/linux-2.6/xfs_iops.c
+++ b/fs/xfs/linux-2.6/xfs_iops.c
@@ -202,9 +202,9 @@ xfs_vn_mknod(
202 202
203 if (default_acl) { 203 if (default_acl) {
204 error = -xfs_inherit_acl(inode, default_acl); 204 error = -xfs_inherit_acl(inode, default_acl);
205 default_acl = NULL;
205 if (unlikely(error)) 206 if (unlikely(error))
206 goto out_cleanup_inode; 207 goto out_cleanup_inode;
207 posix_acl_release(default_acl);
208 } 208 }
209 209
210 210
diff --git a/include/linux/posix_acl.h b/include/linux/posix_acl.h
index 7a74d37482e8..0ae0e4a3e20c 100644
--- a/include/linux/posix_acl.h
+++ b/include/linux/posix_acl.h
@@ -80,6 +80,7 @@ extern struct posix_acl *posix_acl_from_mode(mode_t, gfp_t);
80extern int posix_acl_equiv_mode(const struct posix_acl *, mode_t *); 80extern int posix_acl_equiv_mode(const struct posix_acl *, mode_t *);
81extern int posix_acl_create_masq(struct posix_acl *, mode_t *); 81extern int posix_acl_create_masq(struct posix_acl *, mode_t *);
82extern int posix_acl_chmod_masq(struct posix_acl *, mode_t); 82extern int posix_acl_chmod_masq(struct posix_acl *, mode_t);
83extern int posix_acl_create(struct posix_acl **, gfp_t, mode_t *);
83extern int posix_acl_chmod(struct posix_acl **, gfp_t, mode_t); 84extern int posix_acl_chmod(struct posix_acl **, gfp_t, mode_t);
84 85
85extern struct posix_acl *get_posix_acl(struct inode *, int); 86extern struct posix_acl *get_posix_acl(struct inode *, int);