diff options
Diffstat (limited to 'fs/reiserfs/xattr.c')
-rw-r--r-- | fs/reiserfs/xattr.c | 70 |
1 files changed, 45 insertions, 25 deletions
diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c index 5cdfbd638b5c..ca416d099e7d 100644 --- a/fs/reiserfs/xattr.c +++ b/fs/reiserfs/xattr.c | |||
@@ -56,9 +56,11 @@ | |||
56 | #define XAROOT_NAME "xattrs" | 56 | #define XAROOT_NAME "xattrs" |
57 | 57 | ||
58 | 58 | ||
59 | /* Helpers for inode ops. We do this so that we don't have all the VFS | 59 | /* |
60 | * Helpers for inode ops. We do this so that we don't have all the VFS | ||
60 | * overhead and also for proper i_mutex annotation. | 61 | * overhead and also for proper i_mutex annotation. |
61 | * dir->i_mutex must be held for all of them. */ | 62 | * dir->i_mutex must be held for all of them. |
63 | */ | ||
62 | #ifdef CONFIG_REISERFS_FS_XATTR | 64 | #ifdef CONFIG_REISERFS_FS_XATTR |
63 | static int xattr_create(struct inode *dir, struct dentry *dentry, int mode) | 65 | static int xattr_create(struct inode *dir, struct dentry *dentry, int mode) |
64 | { | 66 | { |
@@ -73,10 +75,12 @@ static int xattr_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) | |||
73 | return dir->i_op->mkdir(dir, dentry, mode); | 75 | return dir->i_op->mkdir(dir, dentry, mode); |
74 | } | 76 | } |
75 | 77 | ||
76 | /* We use I_MUTEX_CHILD here to silence lockdep. It's safe because xattr | 78 | /* |
79 | * We use I_MUTEX_CHILD here to silence lockdep. It's safe because xattr | ||
77 | * mutation ops aren't called during rename or splace, which are the | 80 | * mutation ops aren't called during rename or splace, which are the |
78 | * only other users of I_MUTEX_CHILD. It violates the ordering, but that's | 81 | * only other users of I_MUTEX_CHILD. It violates the ordering, but that's |
79 | * better than allocating another subclass just for this code. */ | 82 | * better than allocating another subclass just for this code. |
83 | */ | ||
80 | static int xattr_unlink(struct inode *dir, struct dentry *dentry) | 84 | static int xattr_unlink(struct inode *dir, struct dentry *dentry) |
81 | { | 85 | { |
82 | int error; | 86 | int error; |
@@ -166,9 +170,11 @@ static struct dentry *open_xa_dir(const struct inode *inode, int flags) | |||
166 | return xadir; | 170 | return xadir; |
167 | } | 171 | } |
168 | 172 | ||
169 | /* The following are side effects of other operations that aren't explicitly | 173 | /* |
174 | * The following are side effects of other operations that aren't explicitly | ||
170 | * modifying extended attributes. This includes operations such as permissions | 175 | * modifying extended attributes. This includes operations such as permissions |
171 | * or ownership changes, object deletions, etc. */ | 176 | * or ownership changes, object deletions, etc. |
177 | */ | ||
172 | struct reiserfs_dentry_buf { | 178 | struct reiserfs_dentry_buf { |
173 | struct dir_context ctx; | 179 | struct dir_context ctx; |
174 | struct dentry *xadir; | 180 | struct dentry *xadir; |
@@ -267,11 +273,13 @@ static int reiserfs_for_each_xattr(struct inode *inode, | |||
267 | cleanup_dentry_buf(&buf); | 273 | cleanup_dentry_buf(&buf); |
268 | 274 | ||
269 | if (!err) { | 275 | if (!err) { |
270 | /* We start a transaction here to avoid a ABBA situation | 276 | /* |
277 | * We start a transaction here to avoid a ABBA situation | ||
271 | * between the xattr root's i_mutex and the journal lock. | 278 | * between the xattr root's i_mutex and the journal lock. |
272 | * This doesn't incur much additional overhead since the | 279 | * This doesn't incur much additional overhead since the |
273 | * new transaction will just nest inside the | 280 | * new transaction will just nest inside the |
274 | * outer transaction. */ | 281 | * outer transaction. |
282 | */ | ||
275 | int blocks = JOURNAL_PER_BALANCE_CNT * 2 + 2 + | 283 | int blocks = JOURNAL_PER_BALANCE_CNT * 2 + 2 + |
276 | 4 * REISERFS_QUOTA_TRANS_BLOCKS(inode->i_sb); | 284 | 4 * REISERFS_QUOTA_TRANS_BLOCKS(inode->i_sb); |
277 | struct reiserfs_transaction_handle th; | 285 | struct reiserfs_transaction_handle th; |
@@ -284,7 +292,7 @@ static int reiserfs_for_each_xattr(struct inode *inode, | |||
284 | I_MUTEX_XATTR); | 292 | I_MUTEX_XATTR); |
285 | err = action(dir, data); | 293 | err = action(dir, data); |
286 | reiserfs_write_lock(inode->i_sb); | 294 | reiserfs_write_lock(inode->i_sb); |
287 | jerror = journal_end(&th, inode->i_sb, blocks); | 295 | jerror = journal_end(&th); |
288 | reiserfs_write_unlock(inode->i_sb); | 296 | reiserfs_write_unlock(inode->i_sb); |
289 | mutex_unlock(&dir->d_parent->d_inode->i_mutex); | 297 | mutex_unlock(&dir->d_parent->d_inode->i_mutex); |
290 | err = jerror ?: err; | 298 | err = jerror ?: err; |
@@ -349,9 +357,11 @@ int reiserfs_chown_xattrs(struct inode *inode, struct iattr *attrs) | |||
349 | } | 357 | } |
350 | 358 | ||
351 | #ifdef CONFIG_REISERFS_FS_XATTR | 359 | #ifdef CONFIG_REISERFS_FS_XATTR |
352 | /* Returns a dentry corresponding to a specific extended attribute file | 360 | /* |
361 | * Returns a dentry corresponding to a specific extended attribute file | ||
353 | * for the inode. If flags allow, the file is created. Otherwise, a | 362 | * for the inode. If flags allow, the file is created. Otherwise, a |
354 | * valid or negative dentry, or an error is returned. */ | 363 | * valid or negative dentry, or an error is returned. |
364 | */ | ||
355 | static struct dentry *xattr_lookup(struct inode *inode, const char *name, | 365 | static struct dentry *xattr_lookup(struct inode *inode, const char *name, |
356 | int flags) | 366 | int flags) |
357 | { | 367 | { |
@@ -400,8 +410,10 @@ static struct page *reiserfs_get_page(struct inode *dir, size_t n) | |||
400 | { | 410 | { |
401 | struct address_space *mapping = dir->i_mapping; | 411 | struct address_space *mapping = dir->i_mapping; |
402 | struct page *page; | 412 | struct page *page; |
403 | /* We can deadlock if we try to free dentries, | 413 | /* |
404 | and an unlink/rmdir has just occurred - GFP_NOFS avoids this */ | 414 | * We can deadlock if we try to free dentries, |
415 | * and an unlink/rmdir has just occurred - GFP_NOFS avoids this | ||
416 | */ | ||
405 | mapping_set_gfp_mask(mapping, GFP_NOFS); | 417 | mapping_set_gfp_mask(mapping, GFP_NOFS); |
406 | page = read_mapping_page(mapping, n >> PAGE_CACHE_SHIFT, NULL); | 418 | page = read_mapping_page(mapping, n >> PAGE_CACHE_SHIFT, NULL); |
407 | if (!IS_ERR(page)) { | 419 | if (!IS_ERR(page)) { |
@@ -411,7 +423,7 @@ static struct page *reiserfs_get_page(struct inode *dir, size_t n) | |||
411 | } | 423 | } |
412 | return page; | 424 | return page; |
413 | 425 | ||
414 | fail: | 426 | fail: |
415 | reiserfs_put_page(page); | 427 | reiserfs_put_page(page); |
416 | return ERR_PTR(-EIO); | 428 | return ERR_PTR(-EIO); |
417 | } | 429 | } |
@@ -589,7 +601,7 @@ int reiserfs_xattr_set(struct inode *inode, const char *name, | |||
589 | buffer, buffer_size, flags); | 601 | buffer, buffer_size, flags); |
590 | 602 | ||
591 | reiserfs_write_lock(inode->i_sb); | 603 | reiserfs_write_lock(inode->i_sb); |
592 | error2 = journal_end(&th, inode->i_sb, jbegin_count); | 604 | error2 = journal_end(&th); |
593 | reiserfs_write_unlock(inode->i_sb); | 605 | reiserfs_write_unlock(inode->i_sb); |
594 | if (error == 0) | 606 | if (error == 0) |
595 | error = error2; | 607 | error = error2; |
@@ -615,8 +627,10 @@ reiserfs_xattr_get(struct inode *inode, const char *name, void *buffer, | |||
615 | if (name == NULL) | 627 | if (name == NULL) |
616 | return -EINVAL; | 628 | return -EINVAL; |
617 | 629 | ||
618 | /* We can't have xattrs attached to v1 items since they don't have | 630 | /* |
619 | * generation numbers */ | 631 | * We can't have xattrs attached to v1 items since they don't have |
632 | * generation numbers | ||
633 | */ | ||
620 | if (get_inode_sd_version(inode) == STAT_DATA_V1) | 634 | if (get_inode_sd_version(inode) == STAT_DATA_V1) |
621 | return -EOPNOTSUPP; | 635 | return -EOPNOTSUPP; |
622 | 636 | ||
@@ -913,12 +927,16 @@ static const struct xattr_handler *reiserfs_xattr_handlers[] = { | |||
913 | 927 | ||
914 | static int xattr_mount_check(struct super_block *s) | 928 | static int xattr_mount_check(struct super_block *s) |
915 | { | 929 | { |
916 | /* We need generation numbers to ensure that the oid mapping is correct | 930 | /* |
917 | * v3.5 filesystems don't have them. */ | 931 | * We need generation numbers to ensure that the oid mapping is correct |
932 | * v3.5 filesystems don't have them. | ||
933 | */ | ||
918 | if (old_format_only(s)) { | 934 | if (old_format_only(s)) { |
919 | if (reiserfs_xattrs_optional(s)) { | 935 | if (reiserfs_xattrs_optional(s)) { |
920 | /* Old format filesystem, but optional xattrs have | 936 | /* |
921 | * been enabled. Error out. */ | 937 | * Old format filesystem, but optional xattrs have |
938 | * been enabled. Error out. | ||
939 | */ | ||
922 | reiserfs_warning(s, "jdm-2005", | 940 | reiserfs_warning(s, "jdm-2005", |
923 | "xattrs/ACLs not supported " | 941 | "xattrs/ACLs not supported " |
924 | "on pre-v3.6 format filesystems. " | 942 | "on pre-v3.6 format filesystems. " |
@@ -972,9 +990,11 @@ int reiserfs_lookup_privroot(struct super_block *s) | |||
972 | return err; | 990 | return err; |
973 | } | 991 | } |
974 | 992 | ||
975 | /* We need to take a copy of the mount flags since things like | 993 | /* |
994 | * We need to take a copy of the mount flags since things like | ||
976 | * MS_RDONLY don't get set until *after* we're called. | 995 | * MS_RDONLY don't get set until *after* we're called. |
977 | * mount_flags != mount_options */ | 996 | * mount_flags != mount_options |
997 | */ | ||
978 | int reiserfs_xattr_init(struct super_block *s, int mount_flags) | 998 | int reiserfs_xattr_init(struct super_block *s, int mount_flags) |
979 | { | 999 | { |
980 | int err = 0; | 1000 | int err = 0; |
@@ -1007,8 +1027,8 @@ int reiserfs_xattr_init(struct super_block *s, int mount_flags) | |||
1007 | 1027 | ||
1008 | error: | 1028 | error: |
1009 | if (err) { | 1029 | if (err) { |
1010 | clear_bit(REISERFS_XATTRS_USER, &(REISERFS_SB(s)->s_mount_opt)); | 1030 | clear_bit(REISERFS_XATTRS_USER, &REISERFS_SB(s)->s_mount_opt); |
1011 | clear_bit(REISERFS_POSIXACL, &(REISERFS_SB(s)->s_mount_opt)); | 1031 | clear_bit(REISERFS_POSIXACL, &REISERFS_SB(s)->s_mount_opt); |
1012 | } | 1032 | } |
1013 | 1033 | ||
1014 | /* The super_block MS_POSIXACL must mirror the (no)acl mount option. */ | 1034 | /* The super_block MS_POSIXACL must mirror the (no)acl mount option. */ |