diff options
Diffstat (limited to 'fs/reiserfs/xattr.c')
-rw-r--r-- | fs/reiserfs/xattr.c | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c index 8c7033a8b67e..81f09fab8ae4 100644 --- a/fs/reiserfs/xattr.c +++ b/fs/reiserfs/xattr.c | |||
@@ -83,7 +83,8 @@ static int xattr_unlink(struct inode *dir, struct dentry *dentry) | |||
83 | BUG_ON(!mutex_is_locked(&dir->i_mutex)); | 83 | BUG_ON(!mutex_is_locked(&dir->i_mutex)); |
84 | vfs_dq_init(dir); | 84 | vfs_dq_init(dir); |
85 | 85 | ||
86 | mutex_lock_nested(&dentry->d_inode->i_mutex, I_MUTEX_CHILD); | 86 | reiserfs_mutex_lock_nested_safe(&dentry->d_inode->i_mutex, |
87 | I_MUTEX_CHILD, dir->i_sb); | ||
87 | error = dir->i_op->unlink(dir, dentry); | 88 | error = dir->i_op->unlink(dir, dentry); |
88 | mutex_unlock(&dentry->d_inode->i_mutex); | 89 | mutex_unlock(&dentry->d_inode->i_mutex); |
89 | 90 | ||
@@ -98,7 +99,8 @@ static int xattr_rmdir(struct inode *dir, struct dentry *dentry) | |||
98 | BUG_ON(!mutex_is_locked(&dir->i_mutex)); | 99 | BUG_ON(!mutex_is_locked(&dir->i_mutex)); |
99 | vfs_dq_init(dir); | 100 | vfs_dq_init(dir); |
100 | 101 | ||
101 | mutex_lock_nested(&dentry->d_inode->i_mutex, I_MUTEX_CHILD); | 102 | reiserfs_mutex_lock_nested_safe(&dentry->d_inode->i_mutex, |
103 | I_MUTEX_CHILD, dir->i_sb); | ||
102 | dentry_unhash(dentry); | 104 | dentry_unhash(dentry); |
103 | error = dir->i_op->rmdir(dir, dentry); | 105 | error = dir->i_op->rmdir(dir, dentry); |
104 | if (!error) | 106 | if (!error) |
@@ -235,16 +237,22 @@ static int reiserfs_for_each_xattr(struct inode *inode, | |||
235 | if (IS_PRIVATE(inode) || get_inode_sd_version(inode) == STAT_DATA_V1) | 237 | if (IS_PRIVATE(inode) || get_inode_sd_version(inode) == STAT_DATA_V1) |
236 | return 0; | 238 | return 0; |
237 | 239 | ||
240 | reiserfs_write_unlock(inode->i_sb); | ||
238 | dir = open_xa_dir(inode, XATTR_REPLACE); | 241 | dir = open_xa_dir(inode, XATTR_REPLACE); |
239 | if (IS_ERR(dir)) { | 242 | if (IS_ERR(dir)) { |
240 | err = PTR_ERR(dir); | 243 | err = PTR_ERR(dir); |
244 | reiserfs_write_lock(inode->i_sb); | ||
241 | goto out; | 245 | goto out; |
242 | } else if (!dir->d_inode) { | 246 | } else if (!dir->d_inode) { |
243 | err = 0; | 247 | err = 0; |
248 | reiserfs_write_lock(inode->i_sb); | ||
244 | goto out_dir; | 249 | goto out_dir; |
245 | } | 250 | } |
246 | 251 | ||
247 | mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_XATTR); | 252 | mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_XATTR); |
253 | |||
254 | reiserfs_write_lock(inode->i_sb); | ||
255 | |||
248 | buf.xadir = dir; | 256 | buf.xadir = dir; |
249 | err = reiserfs_readdir_dentry(dir, &buf, fill_with_dentries, &pos); | 257 | err = reiserfs_readdir_dentry(dir, &buf, fill_with_dentries, &pos); |
250 | while ((err == 0 || err == -ENOSPC) && buf.count) { | 258 | while ((err == 0 || err == -ENOSPC) && buf.count) { |
@@ -283,8 +291,9 @@ static int reiserfs_for_each_xattr(struct inode *inode, | |||
283 | err = journal_begin(&th, inode->i_sb, blocks); | 291 | err = journal_begin(&th, inode->i_sb, blocks); |
284 | if (!err) { | 292 | if (!err) { |
285 | int jerror; | 293 | int jerror; |
286 | mutex_lock_nested(&dir->d_parent->d_inode->i_mutex, | 294 | reiserfs_mutex_lock_nested_safe( |
287 | I_MUTEX_XATTR); | 295 | &dir->d_parent->d_inode->i_mutex, |
296 | I_MUTEX_XATTR, inode->i_sb); | ||
288 | err = action(dir, data); | 297 | err = action(dir, data); |
289 | jerror = journal_end(&th, inode->i_sb, blocks); | 298 | jerror = journal_end(&th, inode->i_sb, blocks); |
290 | mutex_unlock(&dir->d_parent->d_inode->i_mutex); | 299 | mutex_unlock(&dir->d_parent->d_inode->i_mutex); |
@@ -443,7 +452,9 @@ static int lookup_and_delete_xattr(struct inode *inode, const char *name) | |||
443 | } | 452 | } |
444 | 453 | ||
445 | if (dentry->d_inode) { | 454 | if (dentry->d_inode) { |
455 | reiserfs_write_lock(inode->i_sb); | ||
446 | err = xattr_unlink(xadir->d_inode, dentry); | 456 | err = xattr_unlink(xadir->d_inode, dentry); |
457 | reiserfs_write_unlock(inode->i_sb); | ||
447 | update_ctime(inode); | 458 | update_ctime(inode); |
448 | } | 459 | } |
449 | 460 | ||
@@ -477,15 +488,24 @@ reiserfs_xattr_set_handle(struct reiserfs_transaction_handle *th, | |||
477 | if (get_inode_sd_version(inode) == STAT_DATA_V1) | 488 | if (get_inode_sd_version(inode) == STAT_DATA_V1) |
478 | return -EOPNOTSUPP; | 489 | return -EOPNOTSUPP; |
479 | 490 | ||
480 | if (!buffer) | 491 | reiserfs_write_unlock(inode->i_sb); |
481 | return lookup_and_delete_xattr(inode, name); | 492 | |
493 | if (!buffer) { | ||
494 | err = lookup_and_delete_xattr(inode, name); | ||
495 | reiserfs_write_lock(inode->i_sb); | ||
496 | return err; | ||
497 | } | ||
482 | 498 | ||
483 | dentry = xattr_lookup(inode, name, flags); | 499 | dentry = xattr_lookup(inode, name, flags); |
484 | if (IS_ERR(dentry)) | 500 | if (IS_ERR(dentry)) { |
501 | reiserfs_write_lock(inode->i_sb); | ||
485 | return PTR_ERR(dentry); | 502 | return PTR_ERR(dentry); |
503 | } | ||
486 | 504 | ||
487 | down_write(&REISERFS_I(inode)->i_xattr_sem); | 505 | down_write(&REISERFS_I(inode)->i_xattr_sem); |
488 | 506 | ||
507 | reiserfs_write_lock(inode->i_sb); | ||
508 | |||
489 | xahash = xattr_hash(buffer, buffer_size); | 509 | xahash = xattr_hash(buffer, buffer_size); |
490 | while (buffer_pos < buffer_size || buffer_pos == 0) { | 510 | while (buffer_pos < buffer_size || buffer_pos == 0) { |
491 | size_t chunk; | 511 | size_t chunk; |
@@ -540,8 +560,12 @@ reiserfs_xattr_set_handle(struct reiserfs_transaction_handle *th, | |||
540 | .ia_size = buffer_size, | 560 | .ia_size = buffer_size, |
541 | .ia_valid = ATTR_SIZE | ATTR_CTIME, | 561 | .ia_valid = ATTR_SIZE | ATTR_CTIME, |
542 | }; | 562 | }; |
563 | |||
564 | reiserfs_write_unlock(inode->i_sb); | ||
543 | mutex_lock_nested(&dentry->d_inode->i_mutex, I_MUTEX_XATTR); | 565 | mutex_lock_nested(&dentry->d_inode->i_mutex, I_MUTEX_XATTR); |
544 | down_write(&dentry->d_inode->i_alloc_sem); | 566 | down_write(&dentry->d_inode->i_alloc_sem); |
567 | reiserfs_write_lock(inode->i_sb); | ||
568 | |||
545 | err = reiserfs_setattr(dentry, &newattrs); | 569 | err = reiserfs_setattr(dentry, &newattrs); |
546 | up_write(&dentry->d_inode->i_alloc_sem); | 570 | up_write(&dentry->d_inode->i_alloc_sem); |
547 | mutex_unlock(&dentry->d_inode->i_mutex); | 571 | mutex_unlock(&dentry->d_inode->i_mutex); |