diff options
Diffstat (limited to 'fs/reiserfs/xattr.c')
-rw-r--r-- | fs/reiserfs/xattr.c | 60 |
1 files changed, 20 insertions, 40 deletions
diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c index 72e120798677..cc061bfd437b 100644 --- a/fs/reiserfs/xattr.c +++ b/fs/reiserfs/xattr.c | |||
@@ -30,6 +30,7 @@ | |||
30 | */ | 30 | */ |
31 | 31 | ||
32 | #include <linux/reiserfs_fs.h> | 32 | #include <linux/reiserfs_fs.h> |
33 | #include <linux/capability.h> | ||
33 | #include <linux/dcache.h> | 34 | #include <linux/dcache.h> |
34 | #include <linux/namei.h> | 35 | #include <linux/namei.h> |
35 | #include <linux/errno.h> | 36 | #include <linux/errno.h> |
@@ -67,11 +68,11 @@ static struct dentry *create_xa_root(struct super_block *sb) | |||
67 | goto out; | 68 | goto out; |
68 | } else if (!xaroot->d_inode) { | 69 | } else if (!xaroot->d_inode) { |
69 | int err; | 70 | int err; |
70 | down(&privroot->d_inode->i_sem); | 71 | mutex_lock(&privroot->d_inode->i_mutex); |
71 | err = | 72 | err = |
72 | privroot->d_inode->i_op->mkdir(privroot->d_inode, xaroot, | 73 | privroot->d_inode->i_op->mkdir(privroot->d_inode, xaroot, |
73 | 0700); | 74 | 0700); |
74 | up(&privroot->d_inode->i_sem); | 75 | mutex_unlock(&privroot->d_inode->i_mutex); |
75 | 76 | ||
76 | if (err) { | 77 | if (err) { |
77 | dput(xaroot); | 78 | dput(xaroot); |
@@ -115,8 +116,8 @@ static struct dentry *__get_xa_root(struct super_block *s) | |||
115 | } | 116 | } |
116 | 117 | ||
117 | /* Returns the dentry (or NULL) referring to the root of the extended | 118 | /* Returns the dentry (or NULL) referring to the root of the extended |
118 | * attribute directory tree. If it has already been retreived, it is used. | 119 | * attribute directory tree. If it has already been retrieved, it is used. |
119 | * Otherwise, we attempt to retreive it from disk. It may also return | 120 | * Otherwise, we attempt to retrieve it from disk. It may also return |
120 | * a pointer-encoded error. | 121 | * a pointer-encoded error. |
121 | */ | 122 | */ |
122 | static inline struct dentry *get_xa_root(struct super_block *s) | 123 | static inline struct dentry *get_xa_root(struct super_block *s) |
@@ -219,7 +220,7 @@ static struct dentry *get_xa_file_dentry(const struct inode *inode, | |||
219 | } else if (flags & XATTR_REPLACE || flags & FL_READONLY) { | 220 | } else if (flags & XATTR_REPLACE || flags & FL_READONLY) { |
220 | goto out; | 221 | goto out; |
221 | } else { | 222 | } else { |
222 | /* inode->i_sem is down, so nothing else can try to create | 223 | /* inode->i_mutex is down, so nothing else can try to create |
223 | * the same xattr */ | 224 | * the same xattr */ |
224 | err = xadir->d_inode->i_op->create(xadir->d_inode, xafile, | 225 | err = xadir->d_inode->i_op->create(xadir->d_inode, xafile, |
225 | 0700 | S_IFREG, NULL); | 226 | 0700 | S_IFREG, NULL); |
@@ -268,7 +269,7 @@ static struct file *open_xa_file(const struct inode *inode, const char *name, | |||
268 | * and don't mess with f->f_pos, but the idea is the same. Do some | 269 | * and don't mess with f->f_pos, but the idea is the same. Do some |
269 | * action on each and every entry in the directory. | 270 | * action on each and every entry in the directory. |
270 | * | 271 | * |
271 | * we're called with i_sem held, so there are no worries about the directory | 272 | * we're called with i_mutex held, so there are no worries about the directory |
272 | * changing underneath us. | 273 | * changing underneath us. |
273 | */ | 274 | */ |
274 | static int __xattr_readdir(struct file *filp, void *dirent, filldir_t filldir) | 275 | static int __xattr_readdir(struct file *filp, void *dirent, filldir_t filldir) |
@@ -426,7 +427,7 @@ int xattr_readdir(struct file *file, filldir_t filler, void *buf) | |||
426 | int res = -ENOTDIR; | 427 | int res = -ENOTDIR; |
427 | if (!file->f_op || !file->f_op->readdir) | 428 | if (!file->f_op || !file->f_op->readdir) |
428 | goto out; | 429 | goto out; |
429 | down(&inode->i_sem); | 430 | mutex_lock(&inode->i_mutex); |
430 | // down(&inode->i_zombie); | 431 | // down(&inode->i_zombie); |
431 | res = -ENOENT; | 432 | res = -ENOENT; |
432 | if (!IS_DEADDIR(inode)) { | 433 | if (!IS_DEADDIR(inode)) { |
@@ -435,7 +436,7 @@ int xattr_readdir(struct file *file, filldir_t filler, void *buf) | |||
435 | unlock_kernel(); | 436 | unlock_kernel(); |
436 | } | 437 | } |
437 | // up(&inode->i_zombie); | 438 | // up(&inode->i_zombie); |
438 | up(&inode->i_sem); | 439 | mutex_unlock(&inode->i_mutex); |
439 | out: | 440 | out: |
440 | return res; | 441 | return res; |
441 | } | 442 | } |
@@ -480,7 +481,7 @@ static inline __u32 xattr_hash(const char *msg, int len) | |||
480 | /* Generic extended attribute operations that can be used by xa plugins */ | 481 | /* Generic extended attribute operations that can be used by xa plugins */ |
481 | 482 | ||
482 | /* | 483 | /* |
483 | * inode->i_sem: down | 484 | * inode->i_mutex: down |
484 | */ | 485 | */ |
485 | int | 486 | int |
486 | reiserfs_xattr_set(struct inode *inode, const char *name, const void *buffer, | 487 | reiserfs_xattr_set(struct inode *inode, const char *name, const void *buffer, |
@@ -497,12 +498,6 @@ reiserfs_xattr_set(struct inode *inode, const char *name, const void *buffer, | |||
497 | struct iattr newattrs; | 498 | struct iattr newattrs; |
498 | __u32 xahash = 0; | 499 | __u32 xahash = 0; |
499 | 500 | ||
500 | if (IS_RDONLY(inode)) | ||
501 | return -EROFS; | ||
502 | |||
503 | if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) | ||
504 | return -EPERM; | ||
505 | |||
506 | if (get_inode_sd_version(inode) == STAT_DATA_V1) | 501 | if (get_inode_sd_version(inode) == STAT_DATA_V1) |
507 | return -EOPNOTSUPP; | 502 | return -EOPNOTSUPP; |
508 | 503 | ||
@@ -535,7 +530,7 @@ reiserfs_xattr_set(struct inode *inode, const char *name, const void *buffer, | |||
535 | /* Resize it so we're ok to write there */ | 530 | /* Resize it so we're ok to write there */ |
536 | newattrs.ia_size = buffer_size; | 531 | newattrs.ia_size = buffer_size; |
537 | newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME; | 532 | newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME; |
538 | down(&xinode->i_sem); | 533 | mutex_lock(&xinode->i_mutex); |
539 | err = notify_change(fp->f_dentry, &newattrs); | 534 | err = notify_change(fp->f_dentry, &newattrs); |
540 | if (err) | 535 | if (err) |
541 | goto out_filp; | 536 | goto out_filp; |
@@ -598,7 +593,7 @@ reiserfs_xattr_set(struct inode *inode, const char *name, const void *buffer, | |||
598 | } | 593 | } |
599 | 594 | ||
600 | out_filp: | 595 | out_filp: |
601 | up(&xinode->i_sem); | 596 | mutex_unlock(&xinode->i_mutex); |
602 | fput(fp); | 597 | fput(fp); |
603 | 598 | ||
604 | out: | 599 | out: |
@@ -606,7 +601,7 @@ reiserfs_xattr_set(struct inode *inode, const char *name, const void *buffer, | |||
606 | } | 601 | } |
607 | 602 | ||
608 | /* | 603 | /* |
609 | * inode->i_sem: down | 604 | * inode->i_mutex: down |
610 | */ | 605 | */ |
611 | int | 606 | int |
612 | reiserfs_xattr_get(const struct inode *inode, const char *name, void *buffer, | 607 | reiserfs_xattr_get(const struct inode *inode, const char *name, void *buffer, |
@@ -758,9 +753,6 @@ int reiserfs_xattr_del(struct inode *inode, const char *name) | |||
758 | struct dentry *dir; | 753 | struct dentry *dir; |
759 | int err; | 754 | int err; |
760 | 755 | ||
761 | if (IS_RDONLY(inode)) | ||
762 | return -EROFS; | ||
763 | |||
764 | dir = open_xa_dir(inode, FL_READONLY); | 756 | dir = open_xa_dir(inode, FL_READONLY); |
765 | if (IS_ERR(dir)) { | 757 | if (IS_ERR(dir)) { |
766 | err = PTR_ERR(dir); | 758 | err = PTR_ERR(dir); |
@@ -793,7 +785,7 @@ reiserfs_delete_xattrs_filler(void *buf, const char *name, int namelen, | |||
793 | 785 | ||
794 | } | 786 | } |
795 | 787 | ||
796 | /* This is called w/ inode->i_sem downed */ | 788 | /* This is called w/ inode->i_mutex downed */ |
797 | int reiserfs_delete_xattrs(struct inode *inode) | 789 | int reiserfs_delete_xattrs(struct inode *inode) |
798 | { | 790 | { |
799 | struct file *fp; | 791 | struct file *fp; |
@@ -946,7 +938,7 @@ int reiserfs_chown_xattrs(struct inode *inode, struct iattr *attrs) | |||
946 | 938 | ||
947 | /* | 939 | /* |
948 | * Inode operation getxattr() | 940 | * Inode operation getxattr() |
949 | * Preliminary locking: we down dentry->d_inode->i_sem | 941 | * Preliminary locking: we down dentry->d_inode->i_mutex |
950 | */ | 942 | */ |
951 | ssize_t | 943 | ssize_t |
952 | reiserfs_getxattr(struct dentry * dentry, const char *name, void *buffer, | 944 | reiserfs_getxattr(struct dentry * dentry, const char *name, void *buffer, |
@@ -970,7 +962,7 @@ reiserfs_getxattr(struct dentry * dentry, const char *name, void *buffer, | |||
970 | /* | 962 | /* |
971 | * Inode operation setxattr() | 963 | * Inode operation setxattr() |
972 | * | 964 | * |
973 | * dentry->d_inode->i_sem down | 965 | * dentry->d_inode->i_mutex down |
974 | */ | 966 | */ |
975 | int | 967 | int |
976 | reiserfs_setxattr(struct dentry *dentry, const char *name, const void *value, | 968 | reiserfs_setxattr(struct dentry *dentry, const char *name, const void *value, |
@@ -984,12 +976,6 @@ reiserfs_setxattr(struct dentry *dentry, const char *name, const void *value, | |||
984 | get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1) | 976 | get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1) |
985 | return -EOPNOTSUPP; | 977 | return -EOPNOTSUPP; |
986 | 978 | ||
987 | if (IS_RDONLY(dentry->d_inode)) | ||
988 | return -EROFS; | ||
989 | |||
990 | if (IS_IMMUTABLE(dentry->d_inode) || IS_APPEND(dentry->d_inode)) | ||
991 | return -EROFS; | ||
992 | |||
993 | reiserfs_write_lock_xattr_i(dentry->d_inode); | 979 | reiserfs_write_lock_xattr_i(dentry->d_inode); |
994 | lock = !has_xattr_dir(dentry->d_inode); | 980 | lock = !has_xattr_dir(dentry->d_inode); |
995 | if (lock) | 981 | if (lock) |
@@ -1008,7 +994,7 @@ reiserfs_setxattr(struct dentry *dentry, const char *name, const void *value, | |||
1008 | /* | 994 | /* |
1009 | * Inode operation removexattr() | 995 | * Inode operation removexattr() |
1010 | * | 996 | * |
1011 | * dentry->d_inode->i_sem down | 997 | * dentry->d_inode->i_mutex down |
1012 | */ | 998 | */ |
1013 | int reiserfs_removexattr(struct dentry *dentry, const char *name) | 999 | int reiserfs_removexattr(struct dentry *dentry, const char *name) |
1014 | { | 1000 | { |
@@ -1019,12 +1005,6 @@ int reiserfs_removexattr(struct dentry *dentry, const char *name) | |||
1019 | get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1) | 1005 | get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1) |
1020 | return -EOPNOTSUPP; | 1006 | return -EOPNOTSUPP; |
1021 | 1007 | ||
1022 | if (IS_RDONLY(dentry->d_inode)) | ||
1023 | return -EROFS; | ||
1024 | |||
1025 | if (IS_IMMUTABLE(dentry->d_inode) || IS_APPEND(dentry->d_inode)) | ||
1026 | return -EPERM; | ||
1027 | |||
1028 | reiserfs_write_lock_xattr_i(dentry->d_inode); | 1008 | reiserfs_write_lock_xattr_i(dentry->d_inode); |
1029 | reiserfs_read_lock_xattrs(dentry->d_sb); | 1009 | reiserfs_read_lock_xattrs(dentry->d_sb); |
1030 | 1010 | ||
@@ -1091,7 +1071,7 @@ reiserfs_listxattr_filler(void *buf, const char *name, int namelen, | |||
1091 | /* | 1071 | /* |
1092 | * Inode operation listxattr() | 1072 | * Inode operation listxattr() |
1093 | * | 1073 | * |
1094 | * Preliminary locking: we down dentry->d_inode->i_sem | 1074 | * Preliminary locking: we down dentry->d_inode->i_mutex |
1095 | */ | 1075 | */ |
1096 | ssize_t reiserfs_listxattr(struct dentry * dentry, char *buffer, size_t size) | 1076 | ssize_t reiserfs_listxattr(struct dentry * dentry, char *buffer, size_t size) |
1097 | { | 1077 | { |
@@ -1289,9 +1269,9 @@ int reiserfs_xattr_init(struct super_block *s, int mount_flags) | |||
1289 | if (!IS_ERR(dentry)) { | 1269 | if (!IS_ERR(dentry)) { |
1290 | if (!(mount_flags & MS_RDONLY) && !dentry->d_inode) { | 1270 | if (!(mount_flags & MS_RDONLY) && !dentry->d_inode) { |
1291 | struct inode *inode = dentry->d_parent->d_inode; | 1271 | struct inode *inode = dentry->d_parent->d_inode; |
1292 | down(&inode->i_sem); | 1272 | mutex_lock(&inode->i_mutex); |
1293 | err = inode->i_op->mkdir(inode, dentry, 0700); | 1273 | err = inode->i_op->mkdir(inode, dentry, 0700); |
1294 | up(&inode->i_sem); | 1274 | mutex_unlock(&inode->i_mutex); |
1295 | if (err) { | 1275 | if (err) { |
1296 | dput(dentry); | 1276 | dput(dentry); |
1297 | dentry = NULL; | 1277 | dentry = NULL; |