aboutsummaryrefslogtreecommitdiffstats
path: root/fs/reiserfs
diff options
context:
space:
mode:
authorSteve French <sfrench@us.ibm.com>2006-01-12 17:47:08 -0500
committerSteve French <sfrench@us.ibm.com>2006-01-12 17:47:08 -0500
commit94bc2be31a01a3055ec94176e595dfe208e92d3b (patch)
treeebfbe81c6718a6390bfa1b99c6d228237d818576 /fs/reiserfs
parentc32a0b689cb9cc160cfcd19735bbf50bb70c6ef4 (diff)
parent58cba4650a7a414eabd2b40cc9d8e45fcdf192d9 (diff)
Merge with /pub/scm/linux/kernel/git/torvalds/linux-2.6.git
Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/reiserfs')
-rw-r--r--fs/reiserfs/file.c12
-rw-r--r--fs/reiserfs/inode.c14
-rw-r--r--fs/reiserfs/ioctl.c5
-rw-r--r--fs/reiserfs/journal.c5
-rw-r--r--fs/reiserfs/super.c4
-rw-r--r--fs/reiserfs/tail_conversion.c2
-rw-r--r--fs/reiserfs/xattr.c60
-rw-r--r--fs/reiserfs/xattr_acl.c7
-rw-r--r--fs/reiserfs/xattr_trusted.c1
-rw-r--r--fs/reiserfs/xattr_user.c30
10 files changed, 48 insertions, 92 deletions
diff --git a/fs/reiserfs/file.c b/fs/reiserfs/file.c
index 7892a865b58a..ad6fa964b0e7 100644
--- a/fs/reiserfs/file.c
+++ b/fs/reiserfs/file.c
@@ -49,7 +49,7 @@ static int reiserfs_file_release(struct inode *inode, struct file *filp)
49 } 49 }
50 50
51 reiserfs_write_lock(inode->i_sb); 51 reiserfs_write_lock(inode->i_sb);
52 down(&inode->i_sem); 52 mutex_lock(&inode->i_mutex);
53 /* freeing preallocation only involves relogging blocks that 53 /* freeing preallocation only involves relogging blocks that
54 * are already in the current transaction. preallocation gets 54 * are already in the current transaction. preallocation gets
55 * freed at the end of each transaction, so it is impossible for 55 * freed at the end of each transaction, so it is impossible for
@@ -100,7 +100,7 @@ static int reiserfs_file_release(struct inode *inode, struct file *filp)
100 err = reiserfs_truncate_file(inode, 0); 100 err = reiserfs_truncate_file(inode, 0);
101 } 101 }
102 out: 102 out:
103 up(&inode->i_sem); 103 mutex_unlock(&inode->i_mutex);
104 reiserfs_write_unlock(inode->i_sb); 104 reiserfs_write_unlock(inode->i_sb);
105 return err; 105 return err;
106} 106}
@@ -1342,7 +1342,7 @@ static ssize_t reiserfs_file_write(struct file *file, /* the file we are going t
1342 if (unlikely(!access_ok(VERIFY_READ, buf, count))) 1342 if (unlikely(!access_ok(VERIFY_READ, buf, count)))
1343 return -EFAULT; 1343 return -EFAULT;
1344 1344
1345 down(&inode->i_sem); // locks the entire file for just us 1345 mutex_lock(&inode->i_mutex); // locks the entire file for just us
1346 1346
1347 pos = *ppos; 1347 pos = *ppos;
1348 1348
@@ -1360,7 +1360,7 @@ static ssize_t reiserfs_file_write(struct file *file, /* the file we are going t
1360 if (res) 1360 if (res)
1361 goto out; 1361 goto out;
1362 1362
1363 inode_update_time(inode, 1); /* Both mtime and ctime */ 1363 file_update_time(file);
1364 1364
1365 // Ok, we are done with all the checks. 1365 // Ok, we are done with all the checks.
1366 1366
@@ -1532,12 +1532,12 @@ static ssize_t reiserfs_file_write(struct file *file, /* the file we are going t
1532 generic_osync_inode(inode, file->f_mapping, 1532 generic_osync_inode(inode, file->f_mapping,
1533 OSYNC_METADATA | OSYNC_DATA); 1533 OSYNC_METADATA | OSYNC_DATA);
1534 1534
1535 up(&inode->i_sem); 1535 mutex_unlock(&inode->i_mutex);
1536 reiserfs_async_progress_wait(inode->i_sb); 1536 reiserfs_async_progress_wait(inode->i_sb);
1537 return (already_written != 0) ? already_written : res; 1537 return (already_written != 0) ? already_written : res;
1538 1538
1539 out: 1539 out:
1540 up(&inode->i_sem); // unlock the file on exit. 1540 mutex_unlock(&inode->i_mutex); // unlock the file on exit.
1541 return res; 1541 return res;
1542} 1542}
1543 1543
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index a5e3a0ddbe53..ffa34b861bdb 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -40,12 +40,12 @@ void reiserfs_delete_inode(struct inode *inode)
40 40
41 /* The = 0 happens when we abort creating a new inode for some reason like lack of space.. */ 41 /* The = 0 happens when we abort creating a new inode for some reason like lack of space.. */
42 if (!(inode->i_state & I_NEW) && INODE_PKEY(inode)->k_objectid != 0) { /* also handles bad_inode case */ 42 if (!(inode->i_state & I_NEW) && INODE_PKEY(inode)->k_objectid != 0) { /* also handles bad_inode case */
43 down(&inode->i_sem); 43 mutex_lock(&inode->i_mutex);
44 44
45 reiserfs_delete_xattrs(inode); 45 reiserfs_delete_xattrs(inode);
46 46
47 if (journal_begin(&th, inode->i_sb, jbegin_count)) { 47 if (journal_begin(&th, inode->i_sb, jbegin_count)) {
48 up(&inode->i_sem); 48 mutex_unlock(&inode->i_mutex);
49 goto out; 49 goto out;
50 } 50 }
51 reiserfs_update_inode_transaction(inode); 51 reiserfs_update_inode_transaction(inode);
@@ -59,11 +59,11 @@ void reiserfs_delete_inode(struct inode *inode)
59 DQUOT_FREE_INODE(inode); 59 DQUOT_FREE_INODE(inode);
60 60
61 if (journal_end(&th, inode->i_sb, jbegin_count)) { 61 if (journal_end(&th, inode->i_sb, jbegin_count)) {
62 up(&inode->i_sem); 62 mutex_unlock(&inode->i_mutex);
63 goto out; 63 goto out;
64 } 64 }
65 65
66 up(&inode->i_sem); 66 mutex_unlock(&inode->i_mutex);
67 67
68 /* check return value from reiserfs_delete_object after 68 /* check return value from reiserfs_delete_object after
69 * ending the transaction 69 * ending the transaction
@@ -551,7 +551,7 @@ static int convert_tail_for_hole(struct inode *inode,
551 551
552 /* we don't have to make sure the conversion did not happen while 552 /* we don't have to make sure the conversion did not happen while
553 ** we were locking the page because anyone that could convert 553 ** we were locking the page because anyone that could convert
554 ** must first take i_sem. 554 ** must first take i_mutex.
555 ** 555 **
556 ** We must fix the tail page for writing because it might have buffers 556 ** We must fix the tail page for writing because it might have buffers
557 ** that are mapped, but have a block number of 0. This indicates tail 557 ** that are mapped, but have a block number of 0. This indicates tail
@@ -586,7 +586,7 @@ static inline int _allocate_block(struct reiserfs_transaction_handle *th,
586 BUG_ON(!th->t_trans_id); 586 BUG_ON(!th->t_trans_id);
587 587
588#ifdef REISERFS_PREALLOCATE 588#ifdef REISERFS_PREALLOCATE
589 if (!(flags & GET_BLOCK_NO_ISEM)) { 589 if (!(flags & GET_BLOCK_NO_IMUX)) {
590 return reiserfs_new_unf_blocknrs2(th, inode, allocated_block_nr, 590 return reiserfs_new_unf_blocknrs2(th, inode, allocated_block_nr,
591 path, block); 591 path, block);
592 } 592 }
@@ -2318,7 +2318,7 @@ static int map_block_for_writepage(struct inode *inode,
2318 /* this is where we fill in holes in the file. */ 2318 /* this is where we fill in holes in the file. */
2319 if (use_get_block) { 2319 if (use_get_block) {
2320 retval = reiserfs_get_block(inode, block, bh_result, 2320 retval = reiserfs_get_block(inode, block, bh_result,
2321 GET_BLOCK_CREATE | GET_BLOCK_NO_ISEM 2321 GET_BLOCK_CREATE | GET_BLOCK_NO_IMUX
2322 | GET_BLOCK_NO_DANGLE); 2322 | GET_BLOCK_NO_DANGLE);
2323 if (!retval) { 2323 if (!retval) {
2324 if (!buffer_mapped(bh_result) 2324 if (!buffer_mapped(bh_result)
diff --git a/fs/reiserfs/ioctl.c b/fs/reiserfs/ioctl.c
index 81fc00285f60..745c88100895 100644
--- a/fs/reiserfs/ioctl.c
+++ b/fs/reiserfs/ioctl.c
@@ -2,6 +2,7 @@
2 * Copyright 2000 by Hans Reiser, licensing governed by reiserfs/README 2 * Copyright 2000 by Hans Reiser, licensing governed by reiserfs/README
3 */ 3 */
4 4
5#include <linux/capability.h>
5#include <linux/fs.h> 6#include <linux/fs.h>
6#include <linux/reiserfs_fs.h> 7#include <linux/reiserfs_fs.h>
7#include <linux/time.h> 8#include <linux/time.h>
@@ -120,7 +121,7 @@ static int reiserfs_unpack(struct inode *inode, struct file *filp)
120 /* we need to make sure nobody is changing the file size beneath 121 /* we need to make sure nobody is changing the file size beneath
121 ** us 122 ** us
122 */ 123 */
123 down(&inode->i_sem); 124 mutex_lock(&inode->i_mutex);
124 125
125 write_from = inode->i_size & (blocksize - 1); 126 write_from = inode->i_size & (blocksize - 1);
126 /* if we are on a block boundary, we are already unpacked. */ 127 /* if we are on a block boundary, we are already unpacked. */
@@ -156,7 +157,7 @@ static int reiserfs_unpack(struct inode *inode, struct file *filp)
156 page_cache_release(page); 157 page_cache_release(page);
157 158
158 out: 159 out:
159 up(&inode->i_sem); 160 mutex_unlock(&inode->i_mutex);
160 reiserfs_write_unlock(inode->i_sb); 161 reiserfs_write_unlock(inode->i_sb);
161 return retval; 162 return retval;
162} 163}
diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c
index 3f17ef844fb6..4491fcf2a0e6 100644
--- a/fs/reiserfs/journal.c
+++ b/fs/reiserfs/journal.c
@@ -3925,10 +3925,13 @@ static int do_journal_end(struct reiserfs_transaction_handle *th,
3925 flush = 1; 3925 flush = 1;
3926 } 3926 }
3927#ifdef REISERFS_PREALLOCATE 3927#ifdef REISERFS_PREALLOCATE
3928 /* quota ops might need to nest, setup the journal_info pointer for them */ 3928 /* quota ops might need to nest, setup the journal_info pointer for them
3929 * and raise the refcount so that it is > 0. */
3929 current->journal_info = th; 3930 current->journal_info = th;
3931 th->t_refcount++;
3930 reiserfs_discard_all_prealloc(th); /* it should not involve new blocks into 3932 reiserfs_discard_all_prealloc(th); /* it should not involve new blocks into
3931 * the transaction */ 3933 * the transaction */
3934 th->t_refcount--;
3932 current->journal_info = th->t_handle_save; 3935 current->journal_info = th->t_handle_save;
3933#endif 3936#endif
3934 3937
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index 42afb5bef111..397d9590c8f2 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -2211,7 +2211,7 @@ static ssize_t reiserfs_quota_write(struct super_block *sb, int type,
2211 size_t towrite = len; 2211 size_t towrite = len;
2212 struct buffer_head tmp_bh, *bh; 2212 struct buffer_head tmp_bh, *bh;
2213 2213
2214 down(&inode->i_sem); 2214 mutex_lock(&inode->i_mutex);
2215 while (towrite > 0) { 2215 while (towrite > 0) {
2216 tocopy = sb->s_blocksize - offset < towrite ? 2216 tocopy = sb->s_blocksize - offset < towrite ?
2217 sb->s_blocksize - offset : towrite; 2217 sb->s_blocksize - offset : towrite;
@@ -2250,7 +2250,7 @@ static ssize_t reiserfs_quota_write(struct super_block *sb, int type,
2250 inode->i_version++; 2250 inode->i_version++;
2251 inode->i_mtime = inode->i_ctime = CURRENT_TIME; 2251 inode->i_mtime = inode->i_ctime = CURRENT_TIME;
2252 mark_inode_dirty(inode); 2252 mark_inode_dirty(inode);
2253 up(&inode->i_sem); 2253 mutex_unlock(&inode->i_mutex);
2254 return len - towrite; 2254 return len - towrite;
2255} 2255}
2256 2256
diff --git a/fs/reiserfs/tail_conversion.c b/fs/reiserfs/tail_conversion.c
index c92e124f628e..196e971c03c9 100644
--- a/fs/reiserfs/tail_conversion.c
+++ b/fs/reiserfs/tail_conversion.c
@@ -205,7 +205,7 @@ int indirect2direct(struct reiserfs_transaction_handle *th, struct inode *p_s_in
205 1) * p_s_sb->s_blocksize; 205 1) * p_s_sb->s_blocksize;
206 pos1 = pos; 206 pos1 = pos;
207 207
208 // we are protected by i_sem. The tail can not disapper, not 208 // we are protected by i_mutex. The tail can not disapper, not
209 // append can be done either 209 // append can be done either
210 // we are in truncate or packing tail in file_release 210 // we are in truncate or packing tail in file_release
211 211
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 */
122static inline struct dentry *get_xa_root(struct super_block *s) 123static 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 */
274static int __xattr_readdir(struct file *filp, void *dirent, filldir_t filldir) 275static 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 */
485int 486int
486reiserfs_xattr_set(struct inode *inode, const char *name, const void *buffer, 487reiserfs_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 */
611int 606int
612reiserfs_xattr_get(const struct inode *inode, const char *name, void *buffer, 607reiserfs_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 */
797int reiserfs_delete_xattrs(struct inode *inode) 789int 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 */
951ssize_t 943ssize_t
952reiserfs_getxattr(struct dentry * dentry, const char *name, void *buffer, 944reiserfs_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 */
975int 967int
976reiserfs_setxattr(struct dentry *dentry, const char *name, const void *value, 968reiserfs_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 */
1013int reiserfs_removexattr(struct dentry *dentry, const char *name) 999int 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 */
1096ssize_t reiserfs_listxattr(struct dentry * dentry, char *buffer, size_t size) 1076ssize_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;
diff --git a/fs/reiserfs/xattr_acl.c b/fs/reiserfs/xattr_acl.c
index a47ac9aac8b2..43de3ba83332 100644
--- a/fs/reiserfs/xattr_acl.c
+++ b/fs/reiserfs/xattr_acl.c
@@ -1,3 +1,4 @@
1#include <linux/capability.h>
1#include <linux/fs.h> 2#include <linux/fs.h>
2#include <linux/posix_acl.h> 3#include <linux/posix_acl.h>
3#include <linux/reiserfs_fs.h> 4#include <linux/reiserfs_fs.h>
@@ -174,7 +175,7 @@ static void *posix_acl_to_disk(const struct posix_acl *acl, size_t * size)
174/* 175/*
175 * Inode operation get_posix_acl(). 176 * Inode operation get_posix_acl().
176 * 177 *
177 * inode->i_sem: down 178 * inode->i_mutex: down
178 * BKL held [before 2.5.x] 179 * BKL held [before 2.5.x]
179 */ 180 */
180struct posix_acl *reiserfs_get_acl(struct inode *inode, int type) 181struct posix_acl *reiserfs_get_acl(struct inode *inode, int type)
@@ -237,7 +238,7 @@ struct posix_acl *reiserfs_get_acl(struct inode *inode, int type)
237/* 238/*
238 * Inode operation set_posix_acl(). 239 * Inode operation set_posix_acl().
239 * 240 *
240 * inode->i_sem: down 241 * inode->i_mutex: down
241 * BKL held [before 2.5.x] 242 * BKL held [before 2.5.x]
242 */ 243 */
243static int 244static int
@@ -312,7 +313,7 @@ reiserfs_set_acl(struct inode *inode, int type, struct posix_acl *acl)
312 return error; 313 return error;
313} 314}
314 315
315/* dir->i_sem: down, 316/* dir->i_mutex: locked,
316 * inode is new and not released into the wild yet */ 317 * inode is new and not released into the wild yet */
317int 318int
318reiserfs_inherit_default_acl(struct inode *dir, struct dentry *dentry, 319reiserfs_inherit_default_acl(struct inode *dir, struct dentry *dentry,
diff --git a/fs/reiserfs/xattr_trusted.c b/fs/reiserfs/xattr_trusted.c
index 2501f7e66ab9..024a938ca60f 100644
--- a/fs/reiserfs/xattr_trusted.c
+++ b/fs/reiserfs/xattr_trusted.c
@@ -1,4 +1,5 @@
1#include <linux/reiserfs_fs.h> 1#include <linux/reiserfs_fs.h>
2#include <linux/capability.h>
2#include <linux/errno.h> 3#include <linux/errno.h>
3#include <linux/fs.h> 4#include <linux/fs.h>
4#include <linux/pagemap.h> 5#include <linux/pagemap.h>
diff --git a/fs/reiserfs/xattr_user.c b/fs/reiserfs/xattr_user.c
index 51458048ca66..073f39364b11 100644
--- a/fs/reiserfs/xattr_user.c
+++ b/fs/reiserfs/xattr_user.c
@@ -16,18 +16,10 @@ static int
16user_get(struct inode *inode, const char *name, void *buffer, size_t size) 16user_get(struct inode *inode, const char *name, void *buffer, size_t size)
17{ 17{
18 18
19 int error;
20
21 if (strlen(name) < sizeof(XATTR_USER_PREFIX)) 19 if (strlen(name) < sizeof(XATTR_USER_PREFIX))
22 return -EINVAL; 20 return -EINVAL;
23
24 if (!reiserfs_xattrs_user(inode->i_sb)) 21 if (!reiserfs_xattrs_user(inode->i_sb))
25 return -EOPNOTSUPP; 22 return -EOPNOTSUPP;
26
27 error = reiserfs_permission_locked(inode, MAY_READ, NULL);
28 if (error)
29 return error;
30
31 return reiserfs_xattr_get(inode, name, buffer, size); 23 return reiserfs_xattr_get(inode, name, buffer, size);
32} 24}
33 25
@@ -36,43 +28,21 @@ user_set(struct inode *inode, const char *name, const void *buffer,
36 size_t size, int flags) 28 size_t size, int flags)
37{ 29{
38 30
39 int error;
40
41 if (strlen(name) < sizeof(XATTR_USER_PREFIX)) 31 if (strlen(name) < sizeof(XATTR_USER_PREFIX))
42 return -EINVAL; 32 return -EINVAL;
43 33
44 if (!reiserfs_xattrs_user(inode->i_sb)) 34 if (!reiserfs_xattrs_user(inode->i_sb))
45 return -EOPNOTSUPP; 35 return -EOPNOTSUPP;
46
47 if (!S_ISREG(inode->i_mode) &&
48 (!S_ISDIR(inode->i_mode) || inode->i_mode & S_ISVTX))
49 return -EPERM;
50
51 error = reiserfs_permission_locked(inode, MAY_WRITE, NULL);
52 if (error)
53 return error;
54
55 return reiserfs_xattr_set(inode, name, buffer, size, flags); 36 return reiserfs_xattr_set(inode, name, buffer, size, flags);
56} 37}
57 38
58static int user_del(struct inode *inode, const char *name) 39static int user_del(struct inode *inode, const char *name)
59{ 40{
60 int error;
61
62 if (strlen(name) < sizeof(XATTR_USER_PREFIX)) 41 if (strlen(name) < sizeof(XATTR_USER_PREFIX))
63 return -EINVAL; 42 return -EINVAL;
64 43
65 if (!reiserfs_xattrs_user(inode->i_sb)) 44 if (!reiserfs_xattrs_user(inode->i_sb))
66 return -EOPNOTSUPP; 45 return -EOPNOTSUPP;
67
68 if (!S_ISREG(inode->i_mode) &&
69 (!S_ISDIR(inode->i_mode) || inode->i_mode & S_ISVTX))
70 return -EPERM;
71
72 error = reiserfs_permission_locked(inode, MAY_WRITE, NULL);
73 if (error)
74 return error;
75
76 return 0; 46 return 0;
77} 47}
78 48