aboutsummaryrefslogtreecommitdiffstats
path: root/fs/reiserfs
diff options
context:
space:
mode:
Diffstat (limited to 'fs/reiserfs')
-rw-r--r--fs/reiserfs/Kconfig6
-rw-r--r--fs/reiserfs/Makefile4
-rw-r--r--fs/reiserfs/README2
-rw-r--r--fs/reiserfs/file.c3
-rw-r--r--fs/reiserfs/inode.c35
-rw-r--r--fs/reiserfs/ioctl.c18
-rw-r--r--fs/reiserfs/journal.c134
-rw-r--r--fs/reiserfs/lock.c2
-rw-r--r--fs/reiserfs/namei.c17
-rw-r--r--fs/reiserfs/prints.c4
-rw-r--r--fs/reiserfs/super.c42
-rw-r--r--fs/reiserfs/xattr.c25
-rw-r--r--fs/reiserfs/xattr_acl.c8
-rw-r--r--fs/reiserfs/xattr_security.c3
14 files changed, 112 insertions, 191 deletions
diff --git a/fs/reiserfs/Kconfig b/fs/reiserfs/Kconfig
index 513f431038f9..7cd46666ba2c 100644
--- a/fs/reiserfs/Kconfig
+++ b/fs/reiserfs/Kconfig
@@ -10,7 +10,8 @@ config REISERFS_FS
10 10
11 In general, ReiserFS is as fast as ext2, but is very efficient with 11 In general, ReiserFS is as fast as ext2, but is very efficient with
12 large directories and small files. Additional patches are needed 12 large directories and small files. Additional patches are needed
13 for NFS and quotas, please see <http://www.namesys.com/> for links. 13 for NFS and quotas, please see
14 <https://reiser4.wiki.kernel.org/index.php/Main_Page> for links.
14 15
15 It is more easily extended to have features currently found in 16 It is more easily extended to have features currently found in
16 database and keyword search systems than block allocation based file 17 database and keyword search systems than block allocation based file
@@ -18,7 +19,8 @@ config REISERFS_FS
18 plugins consistent with our motto ``It takes more than a license to 19 plugins consistent with our motto ``It takes more than a license to
19 make source code open.'' 20 make source code open.''
20 21
21 Read <http://www.namesys.com/> to learn more about reiserfs. 22 Read <https://reiser4.wiki.kernel.org/index.php/Main_Page>
23 to learn more about reiserfs.
22 24
23 Sponsored by Threshold Networks, Emusic.com, and Bigstorage.com. 25 Sponsored by Threshold Networks, Emusic.com, and Bigstorage.com.
24 26
diff --git a/fs/reiserfs/Makefile b/fs/reiserfs/Makefile
index 792b3cb2cd18..3c3b00165114 100644
--- a/fs/reiserfs/Makefile
+++ b/fs/reiserfs/Makefile
@@ -31,9 +31,7 @@ endif
31# and causing a panic. Since this behavior only affects ppc32, this ifeq 31# and causing a panic. Since this behavior only affects ppc32, this ifeq
32# will work around it. If any other architecture displays this behavior, 32# will work around it. If any other architecture displays this behavior,
33# add it here. 33# add it here.
34ifeq ($(CONFIG_PPC32),y) 34ccflags-$(CONFIG_PPC32) := $(call cc-ifversion, -lt, 0400, -O1)
35EXTRA_CFLAGS := $(call cc-ifversion, -lt, 0400, -O1)
36endif
37 35
38TAGS: 36TAGS:
39 etags *.c 37 etags *.c
diff --git a/fs/reiserfs/README b/fs/reiserfs/README
index 14e8c9d460e5..e2f7a264e3ff 100644
--- a/fs/reiserfs/README
+++ b/fs/reiserfs/README
@@ -43,7 +43,7 @@ to address the fair crediting issue in the next GPL version.)
43[END LICENSING] 43[END LICENSING]
44 44
45Reiserfs is a file system based on balanced tree algorithms, which is 45Reiserfs is a file system based on balanced tree algorithms, which is
46described at http://devlinux.com/namesys. 46described at https://reiser4.wiki.kernel.org/index.php/Main_Page
47 47
48Stop reading here. Go there, then return. 48Stop reading here. Go there, then return.
49 49
diff --git a/fs/reiserfs/file.c b/fs/reiserfs/file.c
index 6846371498b6..91f080cc76c8 100644
--- a/fs/reiserfs/file.c
+++ b/fs/reiserfs/file.c
@@ -152,8 +152,7 @@ static int reiserfs_sync_file(struct file *filp, int datasync)
152 barrier_done = reiserfs_commit_for_inode(inode); 152 barrier_done = reiserfs_commit_for_inode(inode);
153 reiserfs_write_unlock(inode->i_sb); 153 reiserfs_write_unlock(inode->i_sb);
154 if (barrier_done != 1 && reiserfs_barrier_flush(inode->i_sb)) 154 if (barrier_done != 1 && reiserfs_barrier_flush(inode->i_sb))
155 blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL, 155 blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL);
156 BLKDEV_IFL_WAIT);
157 if (barrier_done < 0) 156 if (barrier_done < 0)
158 return barrier_done; 157 return barrier_done;
159 return (err < 0) ? -EIO : 0; 158 return (err < 0) ? -EIO : 0;
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index caa758377d66..4fd5bb33dbb5 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -8,7 +8,6 @@
8#include <linux/reiserfs_acl.h> 8#include <linux/reiserfs_acl.h>
9#include <linux/reiserfs_xattr.h> 9#include <linux/reiserfs_xattr.h>
10#include <linux/exportfs.h> 10#include <linux/exportfs.h>
11#include <linux/smp_lock.h>
12#include <linux/pagemap.h> 11#include <linux/pagemap.h>
13#include <linux/highmem.h> 12#include <linux/highmem.h>
14#include <linux/slab.h> 13#include <linux/slab.h>
@@ -22,8 +21,6 @@
22 21
23int reiserfs_commit_write(struct file *f, struct page *page, 22int reiserfs_commit_write(struct file *f, struct page *page,
24 unsigned from, unsigned to); 23 unsigned from, unsigned to);
25int reiserfs_prepare_write(struct file *f, struct page *page,
26 unsigned from, unsigned to);
27 24
28void reiserfs_evict_inode(struct inode *inode) 25void reiserfs_evict_inode(struct inode *inode)
29{ 26{
@@ -165,7 +162,7 @@ inline void make_le_item_head(struct item_head *ih, const struct cpu_key *key,
165** but tail is still sitting in a direct item, and we can't write to 162** but tail is still sitting in a direct item, and we can't write to
166** it. So, look through this page, and check all the mapped buffers 163** it. So, look through this page, and check all the mapped buffers
167** to make sure they have valid block numbers. Any that don't need 164** to make sure they have valid block numbers. Any that don't need
168** to be unmapped, so that block_prepare_write will correctly call 165** to be unmapped, so that __block_write_begin will correctly call
169** reiserfs_get_block to convert the tail into an unformatted node 166** reiserfs_get_block to convert the tail into an unformatted node
170*/ 167*/
171static inline void fix_tail_page_for_writing(struct page *page) 168static inline void fix_tail_page_for_writing(struct page *page)
@@ -439,13 +436,13 @@ static int reiserfs_bmap(struct inode *inode, sector_t block,
439} 436}
440 437
441/* special version of get_block that is only used by grab_tail_page right 438/* special version of get_block that is only used by grab_tail_page right
442** now. It is sent to block_prepare_write, and when you try to get a 439** now. It is sent to __block_write_begin, and when you try to get a
443** block past the end of the file (or a block from a hole) it returns 440** block past the end of the file (or a block from a hole) it returns
444** -ENOENT instead of a valid buffer. block_prepare_write expects to 441** -ENOENT instead of a valid buffer. __block_write_begin expects to
445** be able to do i/o on the buffers returned, unless an error value 442** be able to do i/o on the buffers returned, unless an error value
446** is also returned. 443** is also returned.
447** 444**
448** So, this allows block_prepare_write to be used for reading a single block 445** So, this allows __block_write_begin to be used for reading a single block
449** in a page. Where it does not produce a valid page for holes, or past the 446** in a page. Where it does not produce a valid page for holes, or past the
450** end of the file. This turns out to be exactly what we need for reading 447** end of the file. This turns out to be exactly what we need for reading
451** tails for conversion. 448** tails for conversion.
@@ -558,11 +555,12 @@ static int convert_tail_for_hole(struct inode *inode,
558 ** 555 **
559 ** 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
560 ** 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
561 ** data that has been read directly into the page, and block_prepare_write 558 ** data that has been read directly into the page, and
562 ** won't trigger a get_block in this case. 559 ** __block_write_begin won't trigger a get_block in this case.
563 */ 560 */
564 fix_tail_page_for_writing(tail_page); 561 fix_tail_page_for_writing(tail_page);
565 retval = reiserfs_prepare_write(NULL, tail_page, tail_start, tail_end); 562 retval = __reiserfs_write_begin(tail_page, tail_start,
563 tail_end - tail_start);
566 if (retval) 564 if (retval)
567 goto unlock; 565 goto unlock;
568 566
@@ -1595,8 +1593,13 @@ int reiserfs_encode_fh(struct dentry *dentry, __u32 * data, int *lenp,
1595 struct inode *inode = dentry->d_inode; 1593 struct inode *inode = dentry->d_inode;
1596 int maxlen = *lenp; 1594 int maxlen = *lenp;
1597 1595
1598 if (maxlen < 3) 1596 if (need_parent && (maxlen < 5)) {
1597 *lenp = 5;
1599 return 255; 1598 return 255;
1599 } else if (maxlen < 3) {
1600 *lenp = 3;
1601 return 255;
1602 }
1600 1603
1601 data[0] = inode->i_ino; 1604 data[0] = inode->i_ino;
1602 data[1] = le32_to_cpu(INODE_PKEY(inode)->k_dir_id); 1605 data[1] = le32_to_cpu(INODE_PKEY(inode)->k_dir_id);
@@ -2033,7 +2036,7 @@ static int grab_tail_page(struct inode *inode,
2033 /* start within the page of the last block in the file */ 2036 /* start within the page of the last block in the file */
2034 start = (offset / blocksize) * blocksize; 2037 start = (offset / blocksize) * blocksize;
2035 2038
2036 error = block_prepare_write(page, start, offset, 2039 error = __block_write_begin(page, start, offset - start,
2037 reiserfs_get_block_create_0); 2040 reiserfs_get_block_create_0);
2038 if (error) 2041 if (error)
2039 goto unlock; 2042 goto unlock;
@@ -2438,7 +2441,7 @@ static int reiserfs_write_full_page(struct page *page,
2438 /* from this point on, we know the buffer is mapped to a 2441 /* from this point on, we know the buffer is mapped to a
2439 * real block and not a direct item 2442 * real block and not a direct item
2440 */ 2443 */
2441 if (wbc->sync_mode != WB_SYNC_NONE || !wbc->nonblocking) { 2444 if (wbc->sync_mode != WB_SYNC_NONE) {
2442 lock_buffer(bh); 2445 lock_buffer(bh);
2443 } else { 2446 } else {
2444 if (!trylock_buffer(bh)) { 2447 if (!trylock_buffer(bh)) {
@@ -2628,8 +2631,7 @@ static int reiserfs_write_begin(struct file *file,
2628 return ret; 2631 return ret;
2629} 2632}
2630 2633
2631int reiserfs_prepare_write(struct file *f, struct page *page, 2634int __reiserfs_write_begin(struct page *page, unsigned from, unsigned len)
2632 unsigned from, unsigned to)
2633{ 2635{
2634 struct inode *inode = page->mapping->host; 2636 struct inode *inode = page->mapping->host;
2635 int ret; 2637 int ret;
@@ -2650,7 +2652,7 @@ int reiserfs_prepare_write(struct file *f, struct page *page,
2650 th->t_refcount++; 2652 th->t_refcount++;
2651 } 2653 }
2652 2654
2653 ret = block_prepare_write(page, from, to, reiserfs_get_block); 2655 ret = __block_write_begin(page, from, len, reiserfs_get_block);
2654 if (ret && reiserfs_transaction_running(inode->i_sb)) { 2656 if (ret && reiserfs_transaction_running(inode->i_sb)) {
2655 struct reiserfs_transaction_handle *th = current->journal_info; 2657 struct reiserfs_transaction_handle *th = current->journal_info;
2656 /* this gets a little ugly. If reiserfs_get_block returned an 2658 /* this gets a little ugly. If reiserfs_get_block returned an
@@ -3215,7 +3217,6 @@ const struct address_space_operations reiserfs_address_space_operations = {
3215 .readpages = reiserfs_readpages, 3217 .readpages = reiserfs_readpages,
3216 .releasepage = reiserfs_releasepage, 3218 .releasepage = reiserfs_releasepage,
3217 .invalidatepage = reiserfs_invalidatepage, 3219 .invalidatepage = reiserfs_invalidatepage,
3218 .sync_page = block_sync_page,
3219 .write_begin = reiserfs_write_begin, 3220 .write_begin = reiserfs_write_begin,
3220 .write_end = reiserfs_write_end, 3221 .write_end = reiserfs_write_end,
3221 .bmap = reiserfs_aop_bmap, 3222 .bmap = reiserfs_aop_bmap,
diff --git a/fs/reiserfs/ioctl.c b/fs/reiserfs/ioctl.c
index 5cbb81e134ac..4e153051bc75 100644
--- a/fs/reiserfs/ioctl.c
+++ b/fs/reiserfs/ioctl.c
@@ -9,7 +9,6 @@
9#include <linux/time.h> 9#include <linux/time.h>
10#include <asm/uaccess.h> 10#include <asm/uaccess.h>
11#include <linux/pagemap.h> 11#include <linux/pagemap.h>
12#include <linux/smp_lock.h>
13#include <linux/compat.h> 12#include <linux/compat.h>
14 13
15/* 14/*
@@ -60,7 +59,7 @@ long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
60 if (err) 59 if (err)
61 break; 60 break;
62 61
63 if (!is_owner_or_cap(inode)) { 62 if (!inode_owner_or_capable(inode)) {
64 err = -EPERM; 63 err = -EPERM;
65 goto setflags_out; 64 goto setflags_out;
66 } 65 }
@@ -104,7 +103,7 @@ setflags_out:
104 err = put_user(inode->i_generation, (int __user *)arg); 103 err = put_user(inode->i_generation, (int __user *)arg);
105 break; 104 break;
106 case REISERFS_IOC_SETVERSION: 105 case REISERFS_IOC_SETVERSION:
107 if (!is_owner_or_cap(inode)) { 106 if (!inode_owner_or_capable(inode)) {
108 err = -EPERM; 107 err = -EPERM;
109 break; 108 break;
110 } 109 }
@@ -160,8 +159,6 @@ long reiserfs_compat_ioctl(struct file *file, unsigned int cmd,
160 159
161int reiserfs_commit_write(struct file *f, struct page *page, 160int reiserfs_commit_write(struct file *f, struct page *page,
162 unsigned from, unsigned to); 161 unsigned from, unsigned to);
163int reiserfs_prepare_write(struct file *f, struct page *page,
164 unsigned from, unsigned to);
165/* 162/*
166** reiserfs_unpack 163** reiserfs_unpack
167** Function try to convert tail from direct item into indirect. 164** Function try to convert tail from direct item into indirect.
@@ -186,12 +183,11 @@ int reiserfs_unpack(struct inode *inode, struct file *filp)
186 return 0; 183 return 0;
187 } 184 }
188 185
189 /* we need to make sure nobody is changing the file size beneath
190 ** us
191 */
192 reiserfs_mutex_lock_safe(&inode->i_mutex, inode->i_sb);
193 depth = reiserfs_write_lock_once(inode->i_sb); 186 depth = reiserfs_write_lock_once(inode->i_sb);
194 187
188 /* we need to make sure nobody is changing the file size beneath us */
189 reiserfs_mutex_lock_safe(&inode->i_mutex, inode->i_sb);
190
195 write_from = inode->i_size & (blocksize - 1); 191 write_from = inode->i_size & (blocksize - 1);
196 /* if we are on a block boundary, we are already unpacked. */ 192 /* if we are on a block boundary, we are already unpacked. */
197 if (write_from == 0) { 193 if (write_from == 0) {
@@ -200,7 +196,7 @@ int reiserfs_unpack(struct inode *inode, struct file *filp)
200 } 196 }
201 197
202 /* we unpack by finding the page with the tail, and calling 198 /* we unpack by finding the page with the tail, and calling
203 ** reiserfs_prepare_write on that page. This will force a 199 ** __reiserfs_write_begin on that page. This will force a
204 ** reiserfs_get_block to unpack the tail for us. 200 ** reiserfs_get_block to unpack the tail for us.
205 */ 201 */
206 index = inode->i_size >> PAGE_CACHE_SHIFT; 202 index = inode->i_size >> PAGE_CACHE_SHIFT;
@@ -210,7 +206,7 @@ int reiserfs_unpack(struct inode *inode, struct file *filp)
210 if (!page) { 206 if (!page) {
211 goto out; 207 goto out;
212 } 208 }
213 retval = reiserfs_prepare_write(NULL, page, write_from, write_from); 209 retval = __reiserfs_write_begin(page, write_from, 0);
214 if (retval) 210 if (retval)
215 goto out_unlock; 211 goto out_unlock;
216 212
diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c
index 812e2c05aa29..c5e82ece7c6c 100644
--- a/fs/reiserfs/journal.c
+++ b/fs/reiserfs/journal.c
@@ -1,7 +1,7 @@
1/* 1/*
2** Write ahead logging implementation copyright Chris Mason 2000 2** Write ahead logging implementation copyright Chris Mason 2000
3** 3**
4** The background commits make this code very interelated, and 4** The background commits make this code very interrelated, and
5** overly complex. I need to rethink things a bit....The major players: 5** overly complex. I need to rethink things a bit....The major players:
6** 6**
7** journal_begin -- call with the number of blocks you expect to log. 7** journal_begin -- call with the number of blocks you expect to log.
@@ -43,7 +43,6 @@
43#include <linux/fcntl.h> 43#include <linux/fcntl.h>
44#include <linux/stat.h> 44#include <linux/stat.h>
45#include <linux/string.h> 45#include <linux/string.h>
46#include <linux/smp_lock.h>
47#include <linux/buffer_head.h> 46#include <linux/buffer_head.h>
48#include <linux/workqueue.h> 47#include <linux/workqueue.h>
49#include <linux/writeback.h> 48#include <linux/writeback.h>
@@ -138,13 +137,6 @@ static int reiserfs_clean_and_file_buffer(struct buffer_head *bh)
138 return 0; 137 return 0;
139} 138}
140 139
141static void disable_barrier(struct super_block *s)
142{
143 REISERFS_SB(s)->s_mount_opt &= ~(1 << REISERFS_BARRIER_FLUSH);
144 printk("reiserfs: disabling flush barriers on %s\n",
145 reiserfs_bdevname(s));
146}
147
148static struct reiserfs_bitmap_node *allocate_bitmap_node(struct super_block 140static struct reiserfs_bitmap_node *allocate_bitmap_node(struct super_block
149 *sb) 141 *sb)
150{ 142{
@@ -677,30 +669,6 @@ static void submit_ordered_buffer(struct buffer_head *bh)
677 submit_bh(WRITE, bh); 669 submit_bh(WRITE, bh);
678} 670}
679 671
680static int submit_barrier_buffer(struct buffer_head *bh)
681{
682 get_bh(bh);
683 bh->b_end_io = reiserfs_end_ordered_io;
684 clear_buffer_dirty(bh);
685 if (!buffer_uptodate(bh))
686 BUG();
687 return submit_bh(WRITE_BARRIER, bh);
688}
689
690static void check_barrier_completion(struct super_block *s,
691 struct buffer_head *bh)
692{
693 if (buffer_eopnotsupp(bh)) {
694 clear_buffer_eopnotsupp(bh);
695 disable_barrier(s);
696 set_buffer_uptodate(bh);
697 set_buffer_dirty(bh);
698 reiserfs_write_unlock(s);
699 sync_dirty_buffer(bh);
700 reiserfs_write_lock(s);
701 }
702}
703
704#define CHUNK_SIZE 32 672#define CHUNK_SIZE 32
705struct buffer_chunk { 673struct buffer_chunk {
706 struct buffer_head *bh[CHUNK_SIZE]; 674 struct buffer_head *bh[CHUNK_SIZE];
@@ -1009,7 +977,6 @@ static int flush_commit_list(struct super_block *s,
1009 struct buffer_head *tbh = NULL; 977 struct buffer_head *tbh = NULL;
1010 unsigned int trans_id = jl->j_trans_id; 978 unsigned int trans_id = jl->j_trans_id;
1011 struct reiserfs_journal *journal = SB_JOURNAL(s); 979 struct reiserfs_journal *journal = SB_JOURNAL(s);
1012 int barrier = 0;
1013 int retval = 0; 980 int retval = 0;
1014 int write_len; 981 int write_len;
1015 982
@@ -1094,24 +1061,6 @@ static int flush_commit_list(struct super_block *s,
1094 } 1061 }
1095 atomic_dec(&journal->j_async_throttle); 1062 atomic_dec(&journal->j_async_throttle);
1096 1063
1097 /* We're skipping the commit if there's an error */
1098 if (retval || reiserfs_is_journal_aborted(journal))
1099 barrier = 0;
1100
1101 /* wait on everything written so far before writing the commit
1102 * if we are in barrier mode, send the commit down now
1103 */
1104 barrier = reiserfs_barrier_flush(s);
1105 if (barrier) {
1106 int ret;
1107 lock_buffer(jl->j_commit_bh);
1108 ret = submit_barrier_buffer(jl->j_commit_bh);
1109 if (ret == -EOPNOTSUPP) {
1110 set_buffer_uptodate(jl->j_commit_bh);
1111 disable_barrier(s);
1112 barrier = 0;
1113 }
1114 }
1115 for (i = 0; i < (jl->j_len + 1); i++) { 1064 for (i = 0; i < (jl->j_len + 1); i++) {
1116 bn = SB_ONDISK_JOURNAL_1st_BLOCK(s) + 1065 bn = SB_ONDISK_JOURNAL_1st_BLOCK(s) +
1117 (jl->j_start + i) % SB_ONDISK_JOURNAL_SIZE(s); 1066 (jl->j_start + i) % SB_ONDISK_JOURNAL_SIZE(s);
@@ -1143,27 +1092,22 @@ static int flush_commit_list(struct super_block *s,
1143 1092
1144 BUG_ON(atomic_read(&(jl->j_commit_left)) != 1); 1093 BUG_ON(atomic_read(&(jl->j_commit_left)) != 1);
1145 1094
1146 if (!barrier) { 1095 /* If there was a write error in the journal - we can't commit
1147 /* If there was a write error in the journal - we can't commit 1096 * this transaction - it will be invalid and, if successful,
1148 * this transaction - it will be invalid and, if successful, 1097 * will just end up propagating the write error out to
1149 * will just end up propagating the write error out to 1098 * the file system. */
1150 * the file system. */ 1099 if (likely(!retval && !reiserfs_is_journal_aborted (journal))) {
1151 if (likely(!retval && !reiserfs_is_journal_aborted (journal))) { 1100 if (buffer_dirty(jl->j_commit_bh))
1152 if (buffer_dirty(jl->j_commit_bh)) 1101 BUG();
1153 BUG(); 1102 mark_buffer_dirty(jl->j_commit_bh) ;
1154 mark_buffer_dirty(jl->j_commit_bh) ;
1155 reiserfs_write_unlock(s);
1156 sync_dirty_buffer(jl->j_commit_bh) ;
1157 reiserfs_write_lock(s);
1158 }
1159 } else {
1160 reiserfs_write_unlock(s); 1103 reiserfs_write_unlock(s);
1161 wait_on_buffer(jl->j_commit_bh); 1104 if (reiserfs_barrier_flush(s))
1105 __sync_dirty_buffer(jl->j_commit_bh, WRITE_FLUSH_FUA);
1106 else
1107 sync_dirty_buffer(jl->j_commit_bh);
1162 reiserfs_write_lock(s); 1108 reiserfs_write_lock(s);
1163 } 1109 }
1164 1110
1165 check_barrier_completion(s, jl->j_commit_bh);
1166
1167 /* If there was a write error in the journal - we can't commit this 1111 /* If there was a write error in the journal - we can't commit this
1168 * transaction - it will be invalid and, if successful, will just end 1112 * transaction - it will be invalid and, if successful, will just end
1169 * up propagating the write error out to the filesystem. */ 1113 * up propagating the write error out to the filesystem. */
@@ -1319,26 +1263,15 @@ static int _update_journal_header_block(struct super_block *sb,
1319 jh->j_first_unflushed_offset = cpu_to_le32(offset); 1263 jh->j_first_unflushed_offset = cpu_to_le32(offset);
1320 jh->j_mount_id = cpu_to_le32(journal->j_mount_id); 1264 jh->j_mount_id = cpu_to_le32(journal->j_mount_id);
1321 1265
1322 if (reiserfs_barrier_flush(sb)) { 1266 set_buffer_dirty(journal->j_header_bh);
1323 int ret; 1267 reiserfs_write_unlock(sb);
1324 lock_buffer(journal->j_header_bh); 1268
1325 ret = submit_barrier_buffer(journal->j_header_bh); 1269 if (reiserfs_barrier_flush(sb))
1326 if (ret == -EOPNOTSUPP) { 1270 __sync_dirty_buffer(journal->j_header_bh, WRITE_FLUSH_FUA);
1327 set_buffer_uptodate(journal->j_header_bh); 1271 else
1328 disable_barrier(sb);
1329 goto sync;
1330 }
1331 reiserfs_write_unlock(sb);
1332 wait_on_buffer(journal->j_header_bh);
1333 reiserfs_write_lock(sb);
1334 check_barrier_completion(sb, journal->j_header_bh);
1335 } else {
1336 sync:
1337 set_buffer_dirty(journal->j_header_bh);
1338 reiserfs_write_unlock(sb);
1339 sync_dirty_buffer(journal->j_header_bh); 1272 sync_dirty_buffer(journal->j_header_bh);
1340 reiserfs_write_lock(sb); 1273
1341 } 1274 reiserfs_write_lock(sb);
1342 if (!buffer_uptodate(journal->j_header_bh)) { 1275 if (!buffer_uptodate(journal->j_header_bh)) {
1343 reiserfs_warning(sb, "journal-837", 1276 reiserfs_warning(sb, "journal-837",
1344 "IO error during journal replay"); 1277 "IO error during journal replay");
@@ -2618,8 +2551,6 @@ static int release_journal_dev(struct super_block *super,
2618 result = 0; 2551 result = 0;
2619 2552
2620 if (journal->j_dev_bd != NULL) { 2553 if (journal->j_dev_bd != NULL) {
2621 if (journal->j_dev_bd->bd_dev != super->s_dev)
2622 bd_release(journal->j_dev_bd);
2623 result = blkdev_put(journal->j_dev_bd, journal->j_dev_mode); 2554 result = blkdev_put(journal->j_dev_bd, journal->j_dev_mode);
2624 journal->j_dev_bd = NULL; 2555 journal->j_dev_bd = NULL;
2625 } 2556 }
@@ -2637,7 +2568,7 @@ static int journal_init_dev(struct super_block *super,
2637{ 2568{
2638 int result; 2569 int result;
2639 dev_t jdev; 2570 dev_t jdev;
2640 fmode_t blkdev_mode = FMODE_READ | FMODE_WRITE; 2571 fmode_t blkdev_mode = FMODE_READ | FMODE_WRITE | FMODE_EXCL;
2641 char b[BDEVNAME_SIZE]; 2572 char b[BDEVNAME_SIZE];
2642 2573
2643 result = 0; 2574 result = 0;
@@ -2651,7 +2582,10 @@ static int journal_init_dev(struct super_block *super,
2651 2582
2652 /* there is no "jdev" option and journal is on separate device */ 2583 /* there is no "jdev" option and journal is on separate device */
2653 if ((!jdev_name || !jdev_name[0])) { 2584 if ((!jdev_name || !jdev_name[0])) {
2654 journal->j_dev_bd = open_by_devnum(jdev, blkdev_mode); 2585 if (jdev == super->s_dev)
2586 blkdev_mode &= ~FMODE_EXCL;
2587 journal->j_dev_bd = blkdev_get_by_dev(jdev, blkdev_mode,
2588 journal);
2655 journal->j_dev_mode = blkdev_mode; 2589 journal->j_dev_mode = blkdev_mode;
2656 if (IS_ERR(journal->j_dev_bd)) { 2590 if (IS_ERR(journal->j_dev_bd)) {
2657 result = PTR_ERR(journal->j_dev_bd); 2591 result = PTR_ERR(journal->j_dev_bd);
@@ -2660,22 +2594,14 @@ static int journal_init_dev(struct super_block *super,
2660 "cannot init journal device '%s': %i", 2594 "cannot init journal device '%s': %i",
2661 __bdevname(jdev, b), result); 2595 __bdevname(jdev, b), result);
2662 return result; 2596 return result;
2663 } else if (jdev != super->s_dev) { 2597 } else if (jdev != super->s_dev)
2664 result = bd_claim(journal->j_dev_bd, journal);
2665 if (result) {
2666 blkdev_put(journal->j_dev_bd, blkdev_mode);
2667 return result;
2668 }
2669
2670 set_blocksize(journal->j_dev_bd, super->s_blocksize); 2598 set_blocksize(journal->j_dev_bd, super->s_blocksize);
2671 }
2672 2599
2673 return 0; 2600 return 0;
2674 } 2601 }
2675 2602
2676 journal->j_dev_mode = blkdev_mode; 2603 journal->j_dev_mode = blkdev_mode;
2677 journal->j_dev_bd = open_bdev_exclusive(jdev_name, 2604 journal->j_dev_bd = blkdev_get_by_path(jdev_name, blkdev_mode, journal);
2678 blkdev_mode, journal);
2679 if (IS_ERR(journal->j_dev_bd)) { 2605 if (IS_ERR(journal->j_dev_bd)) {
2680 result = PTR_ERR(journal->j_dev_bd); 2606 result = PTR_ERR(journal->j_dev_bd);
2681 journal->j_dev_bd = NULL; 2607 journal->j_dev_bd = NULL;
@@ -2799,7 +2725,7 @@ int journal_init(struct super_block *sb, const char *j_dev_name,
2799 REISERFS_DISK_OFFSET_IN_BYTES / 2725 REISERFS_DISK_OFFSET_IN_BYTES /
2800 sb->s_blocksize + 2); 2726 sb->s_blocksize + 2);
2801 2727
2802 /* Sanity check to see is the standard journal fitting withing first bitmap 2728 /* Sanity check to see is the standard journal fitting within first bitmap
2803 (actual for small blocksizes) */ 2729 (actual for small blocksizes) */
2804 if (!SB_ONDISK_JOURNAL_DEVICE(sb) && 2730 if (!SB_ONDISK_JOURNAL_DEVICE(sb) &&
2805 (SB_JOURNAL_1st_RESERVED_BLOCK(sb) + 2731 (SB_JOURNAL_1st_RESERVED_BLOCK(sb) +
@@ -2950,7 +2876,7 @@ int journal_init(struct super_block *sb, const char *j_dev_name,
2950 reiserfs_mounted_fs_count++; 2876 reiserfs_mounted_fs_count++;
2951 if (reiserfs_mounted_fs_count <= 1) { 2877 if (reiserfs_mounted_fs_count <= 1) {
2952 reiserfs_write_unlock(sb); 2878 reiserfs_write_unlock(sb);
2953 commit_wq = create_workqueue("reiserfs"); 2879 commit_wq = alloc_workqueue("reiserfs", WQ_MEM_RECLAIM, 0);
2954 reiserfs_write_lock(sb); 2880 reiserfs_write_lock(sb);
2955 } 2881 }
2956 2882
diff --git a/fs/reiserfs/lock.c b/fs/reiserfs/lock.c
index b87aa2c1afc1..7df1ce48203a 100644
--- a/fs/reiserfs/lock.c
+++ b/fs/reiserfs/lock.c
@@ -15,7 +15,7 @@
15 * for this mutex, no need for a system wide mutex facility. 15 * for this mutex, no need for a system wide mutex facility.
16 * 16 *
17 * Also this lock is often released before a call that could block because 17 * Also this lock is often released before a call that could block because
18 * reiserfs performances were partialy based on the release while schedule() 18 * reiserfs performances were partially based on the release while schedule()
19 * property of the Bkl. 19 * property of the Bkl.
20 */ 20 */
21void reiserfs_write_lock(struct super_block *s) 21void reiserfs_write_lock(struct super_block *s)
diff --git a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c
index ee78d4a0086a..118662690cdf 100644
--- a/fs/reiserfs/namei.c
+++ b/fs/reiserfs/namei.c
@@ -593,7 +593,7 @@ static int reiserfs_create(struct inode *dir, struct dentry *dentry, int mode,
593 new_inode_init(inode, dir, mode); 593 new_inode_init(inode, dir, mode);
594 594
595 jbegin_count += reiserfs_cache_default_acl(dir); 595 jbegin_count += reiserfs_cache_default_acl(dir);
596 retval = reiserfs_security_init(dir, inode, &security); 596 retval = reiserfs_security_init(dir, inode, &dentry->d_name, &security);
597 if (retval < 0) { 597 if (retval < 0) {
598 drop_new_inode(inode); 598 drop_new_inode(inode);
599 return retval; 599 return retval;
@@ -667,7 +667,7 @@ static int reiserfs_mknod(struct inode *dir, struct dentry *dentry, int mode,
667 new_inode_init(inode, dir, mode); 667 new_inode_init(inode, dir, mode);
668 668
669 jbegin_count += reiserfs_cache_default_acl(dir); 669 jbegin_count += reiserfs_cache_default_acl(dir);
670 retval = reiserfs_security_init(dir, inode, &security); 670 retval = reiserfs_security_init(dir, inode, &dentry->d_name, &security);
671 if (retval < 0) { 671 if (retval < 0) {
672 drop_new_inode(inode); 672 drop_new_inode(inode);
673 return retval; 673 return retval;
@@ -747,7 +747,7 @@ static int reiserfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
747 new_inode_init(inode, dir, mode); 747 new_inode_init(inode, dir, mode);
748 748
749 jbegin_count += reiserfs_cache_default_acl(dir); 749 jbegin_count += reiserfs_cache_default_acl(dir);
750 retval = reiserfs_security_init(dir, inode, &security); 750 retval = reiserfs_security_init(dir, inode, &dentry->d_name, &security);
751 if (retval < 0) { 751 if (retval < 0) {
752 drop_new_inode(inode); 752 drop_new_inode(inode);
753 return retval; 753 return retval;
@@ -771,7 +771,7 @@ static int reiserfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
771 EMPTY_DIR_SIZE_V1 : EMPTY_DIR_SIZE, 771 EMPTY_DIR_SIZE_V1 : EMPTY_DIR_SIZE,
772 dentry, inode, &security); 772 dentry, inode, &security);
773 if (retval) { 773 if (retval) {
774 dir->i_nlink--; 774 DEC_DIR_INODE_NLINK(dir)
775 goto out_failed; 775 goto out_failed;
776 } 776 }
777 777
@@ -1032,7 +1032,8 @@ static int reiserfs_symlink(struct inode *parent_dir,
1032 } 1032 }
1033 new_inode_init(inode, parent_dir, mode); 1033 new_inode_init(inode, parent_dir, mode);
1034 1034
1035 retval = reiserfs_security_init(parent_dir, inode, &security); 1035 retval = reiserfs_security_init(parent_dir, inode, &dentry->d_name,
1036 &security);
1036 if (retval < 0) { 1037 if (retval < 0) {
1037 drop_new_inode(inode); 1038 drop_new_inode(inode);
1038 return retval; 1039 return retval;
@@ -1122,10 +1123,6 @@ static int reiserfs_link(struct dentry *old_dentry, struct inode *dir,
1122 reiserfs_write_unlock(dir->i_sb); 1123 reiserfs_write_unlock(dir->i_sb);
1123 return -EMLINK; 1124 return -EMLINK;
1124 } 1125 }
1125 if (inode->i_nlink == 0) {
1126 reiserfs_write_unlock(dir->i_sb);
1127 return -ENOENT;
1128 }
1129 1126
1130 /* inc before scheduling so reiserfs_unlink knows we are here */ 1127 /* inc before scheduling so reiserfs_unlink knows we are here */
1131 inc_nlink(inode); 1128 inc_nlink(inode);
@@ -1156,7 +1153,7 @@ static int reiserfs_link(struct dentry *old_dentry, struct inode *dir,
1156 inode->i_ctime = CURRENT_TIME_SEC; 1153 inode->i_ctime = CURRENT_TIME_SEC;
1157 reiserfs_update_sd(&th, inode); 1154 reiserfs_update_sd(&th, inode);
1158 1155
1159 atomic_inc(&inode->i_count); 1156 ihold(inode);
1160 d_instantiate(dentry, inode); 1157 d_instantiate(dentry, inode);
1161 retval = journal_end(&th, dir->i_sb, jbegin_count); 1158 retval = journal_end(&th, dir->i_sb, jbegin_count);
1162 reiserfs_write_unlock(dir->i_sb); 1159 reiserfs_write_unlock(dir->i_sb);
diff --git a/fs/reiserfs/prints.c b/fs/reiserfs/prints.c
index adbc6f538515..45de98b59466 100644
--- a/fs/reiserfs/prints.c
+++ b/fs/reiserfs/prints.c
@@ -586,13 +586,13 @@ void print_block(struct buffer_head *bh, ...) //int print_mode, int first, int l
586 va_list args; 586 va_list args;
587 int mode, first, last; 587 int mode, first, last;
588 588
589 va_start(args, bh);
590
591 if (!bh) { 589 if (!bh) {
592 printk("print_block: buffer is NULL\n"); 590 printk("print_block: buffer is NULL\n");
593 return; 591 return;
594 } 592 }
595 593
594 va_start(args, bh);
595
596 mode = va_arg(args, int); 596 mode = va_arg(args, int);
597 first = va_arg(args, int); 597 first = va_arg(args, int);
598 last = va_arg(args, int); 598 last = va_arg(args, int);
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index e15ff612002d..aa91089162cb 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -28,7 +28,6 @@
28#include <linux/mount.h> 28#include <linux/mount.h>
29#include <linux/namei.h> 29#include <linux/namei.h>
30#include <linux/crc32.h> 30#include <linux/crc32.h>
31#include <linux/smp_lock.h>
32 31
33struct file_system_type reiserfs_fs_type; 32struct file_system_type reiserfs_fs_type;
34 33
@@ -394,7 +393,7 @@ void add_save_link(struct reiserfs_transaction_handle *th,
394 /* body of "save" link */ 393 /* body of "save" link */
395 link = INODE_PKEY(inode)->k_dir_id; 394 link = INODE_PKEY(inode)->k_dir_id;
396 395
397 /* put "save" link inot tree, don't charge quota to anyone */ 396 /* put "save" link into tree, don't charge quota to anyone */
398 retval = 397 retval =
399 reiserfs_insert_item(th, &path, &key, &ih, NULL, (char *)&link); 398 reiserfs_insert_item(th, &path, &key, &ih, NULL, (char *)&link);
400 if (retval) { 399 if (retval) {
@@ -530,11 +529,18 @@ static struct inode *reiserfs_alloc_inode(struct super_block *sb)
530 return &ei->vfs_inode; 529 return &ei->vfs_inode;
531} 530}
532 531
533static void reiserfs_destroy_inode(struct inode *inode) 532static void reiserfs_i_callback(struct rcu_head *head)
534{ 533{
534 struct inode *inode = container_of(head, struct inode, i_rcu);
535 INIT_LIST_HEAD(&inode->i_dentry);
535 kmem_cache_free(reiserfs_inode_cachep, REISERFS_I(inode)); 536 kmem_cache_free(reiserfs_inode_cachep, REISERFS_I(inode));
536} 537}
537 538
539static void reiserfs_destroy_inode(struct inode *inode)
540{
541 call_rcu(&inode->i_rcu, reiserfs_i_callback);
542}
543
538static void init_once(void *foo) 544static void init_once(void *foo)
539{ 545{
540 struct reiserfs_inode_info *ei = (struct reiserfs_inode_info *)foo; 546 struct reiserfs_inode_info *ei = (struct reiserfs_inode_info *)foo;
@@ -562,7 +568,7 @@ static void destroy_inodecache(void)
562} 568}
563 569
564/* we don't mark inodes dirty, we just log them */ 570/* we don't mark inodes dirty, we just log them */
565static void reiserfs_dirty_inode(struct inode *inode) 571static void reiserfs_dirty_inode(struct inode *inode, int flags)
566{ 572{
567 struct reiserfs_transaction_handle th; 573 struct reiserfs_transaction_handle th;
568 574
@@ -626,7 +632,7 @@ static int reiserfs_acquire_dquot(struct dquot *);
626static int reiserfs_release_dquot(struct dquot *); 632static int reiserfs_release_dquot(struct dquot *);
627static int reiserfs_mark_dquot_dirty(struct dquot *); 633static int reiserfs_mark_dquot_dirty(struct dquot *);
628static int reiserfs_write_info(struct super_block *, int); 634static int reiserfs_write_info(struct super_block *, int);
629static int reiserfs_quota_on(struct super_block *, int, int, char *); 635static int reiserfs_quota_on(struct super_block *, int, int, struct path *);
630 636
631static const struct dquot_operations reiserfs_quota_operations = { 637static const struct dquot_operations reiserfs_quota_operations = {
632 .write_dquot = reiserfs_write_dquot, 638 .write_dquot = reiserfs_write_dquot,
@@ -2042,25 +2048,21 @@ static int reiserfs_quota_on_mount(struct super_block *sb, int type)
2042 * Standard function to be called on quota_on 2048 * Standard function to be called on quota_on
2043 */ 2049 */
2044static int reiserfs_quota_on(struct super_block *sb, int type, int format_id, 2050static int reiserfs_quota_on(struct super_block *sb, int type, int format_id,
2045 char *name) 2051 struct path *path)
2046{ 2052{
2047 int err; 2053 int err;
2048 struct path path;
2049 struct inode *inode; 2054 struct inode *inode;
2050 struct reiserfs_transaction_handle th; 2055 struct reiserfs_transaction_handle th;
2051 2056
2052 if (!(REISERFS_SB(sb)->s_mount_opt & (1 << REISERFS_QUOTA))) 2057 if (!(REISERFS_SB(sb)->s_mount_opt & (1 << REISERFS_QUOTA)))
2053 return -EINVAL; 2058 return -EINVAL;
2054 2059
2055 err = kern_path(name, LOOKUP_FOLLOW, &path);
2056 if (err)
2057 return err;
2058 /* Quotafile not on the same filesystem? */ 2060 /* Quotafile not on the same filesystem? */
2059 if (path.mnt->mnt_sb != sb) { 2061 if (path->mnt->mnt_sb != sb) {
2060 err = -EXDEV; 2062 err = -EXDEV;
2061 goto out; 2063 goto out;
2062 } 2064 }
2063 inode = path.dentry->d_inode; 2065 inode = path->dentry->d_inode;
2064 /* We must not pack tails for quota files on reiserfs for quota IO to work */ 2066 /* We must not pack tails for quota files on reiserfs for quota IO to work */
2065 if (!(REISERFS_I(inode)->i_flags & i_nopack_mask)) { 2067 if (!(REISERFS_I(inode)->i_flags & i_nopack_mask)) {
2066 err = reiserfs_unpack(inode, NULL); 2068 err = reiserfs_unpack(inode, NULL);
@@ -2076,7 +2078,7 @@ static int reiserfs_quota_on(struct super_block *sb, int type, int format_id,
2076 /* Journaling quota? */ 2078 /* Journaling quota? */
2077 if (REISERFS_SB(sb)->s_qf_names[type]) { 2079 if (REISERFS_SB(sb)->s_qf_names[type]) {
2078 /* Quotafile not of fs root? */ 2080 /* Quotafile not of fs root? */
2079 if (path.dentry->d_parent != sb->s_root) 2081 if (path->dentry->d_parent != sb->s_root)
2080 reiserfs_warning(sb, "super-6521", 2082 reiserfs_warning(sb, "super-6521",
2081 "Quota file not on filesystem root. " 2083 "Quota file not on filesystem root. "
2082 "Journalled quota will not work."); 2084 "Journalled quota will not work.");
@@ -2095,15 +2097,14 @@ static int reiserfs_quota_on(struct super_block *sb, int type, int format_id,
2095 if (err) 2097 if (err)
2096 goto out; 2098 goto out;
2097 } 2099 }
2098 err = dquot_quota_on_path(sb, type, format_id, &path); 2100 err = dquot_quota_on(sb, type, format_id, path);
2099out: 2101out:
2100 path_put(&path);
2101 return err; 2102 return err;
2102} 2103}
2103 2104
2104/* Read data from quotafile - avoid pagecache and such because we cannot afford 2105/* Read data from quotafile - avoid pagecache and such because we cannot afford
2105 * acquiring the locks... As quota files are never truncated and quota code 2106 * acquiring the locks... As quota files are never truncated and quota code
2106 * itself serializes the operations (and noone else should touch the files) 2107 * itself serializes the operations (and no one else should touch the files)
2107 * we don't have to be afraid of races */ 2108 * we don't have to be afraid of races */
2108static ssize_t reiserfs_quota_read(struct super_block *sb, int type, char *data, 2109static ssize_t reiserfs_quota_read(struct super_block *sb, int type, char *data,
2109 size_t len, loff_t off) 2110 size_t len, loff_t off)
@@ -2213,12 +2214,11 @@ out:
2213 2214
2214#endif 2215#endif
2215 2216
2216static int get_super_block(struct file_system_type *fs_type, 2217static struct dentry *get_super_block(struct file_system_type *fs_type,
2217 int flags, const char *dev_name, 2218 int flags, const char *dev_name,
2218 void *data, struct vfsmount *mnt) 2219 void *data)
2219{ 2220{
2220 return get_sb_bdev(fs_type, flags, dev_name, data, reiserfs_fill_super, 2221 return mount_bdev(fs_type, flags, dev_name, data, reiserfs_fill_super);
2221 mnt);
2222} 2222}
2223 2223
2224static int __init init_reiserfs_fs(void) 2224static int __init init_reiserfs_fs(void)
@@ -2253,7 +2253,7 @@ static void __exit exit_reiserfs_fs(void)
2253struct file_system_type reiserfs_fs_type = { 2253struct file_system_type reiserfs_fs_type = {
2254 .owner = THIS_MODULE, 2254 .owner = THIS_MODULE,
2255 .name = "reiserfs", 2255 .name = "reiserfs",
2256 .get_sb = get_super_block, 2256 .mount = get_super_block,
2257 .kill_sb = reiserfs_kill_sb, 2257 .kill_sb = reiserfs_kill_sb,
2258 .fs_flags = FS_REQUIRES_DEV, 2258 .fs_flags = FS_REQUIRES_DEV,
2259}; 2259};
diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c
index 8c4cf273c672..d78089690965 100644
--- a/fs/reiserfs/xattr.c
+++ b/fs/reiserfs/xattr.c
@@ -98,14 +98,12 @@ static int xattr_rmdir(struct inode *dir, struct dentry *dentry)
98 98
99 reiserfs_mutex_lock_nested_safe(&dentry->d_inode->i_mutex, 99 reiserfs_mutex_lock_nested_safe(&dentry->d_inode->i_mutex,
100 I_MUTEX_CHILD, dir->i_sb); 100 I_MUTEX_CHILD, dir->i_sb);
101 dentry_unhash(dentry);
102 error = dir->i_op->rmdir(dir, dentry); 101 error = dir->i_op->rmdir(dir, dentry);
103 if (!error) 102 if (!error)
104 dentry->d_inode->i_flags |= S_DEAD; 103 dentry->d_inode->i_flags |= S_DEAD;
105 mutex_unlock(&dentry->d_inode->i_mutex); 104 mutex_unlock(&dentry->d_inode->i_mutex);
106 if (!error) 105 if (!error)
107 d_delete(dentry); 106 d_delete(dentry);
108 dput(dentry);
109 107
110 return error; 108 return error;
111} 109}
@@ -396,7 +394,7 @@ static struct page *reiserfs_get_page(struct inode *dir, size_t n)
396 struct address_space *mapping = dir->i_mapping; 394 struct address_space *mapping = dir->i_mapping;
397 struct page *page; 395 struct page *page;
398 /* We can deadlock if we try to free dentries, 396 /* We can deadlock if we try to free dentries,
399 and an unlink/rmdir has just occured - GFP_NOFS avoids this */ 397 and an unlink/rmdir has just occurred - GFP_NOFS avoids this */
400 mapping_set_gfp_mask(mapping, GFP_NOFS); 398 mapping_set_gfp_mask(mapping, GFP_NOFS);
401 page = read_mapping_page(mapping, n >> PAGE_CACHE_SHIFT, NULL); 399 page = read_mapping_page(mapping, n >> PAGE_CACHE_SHIFT, NULL);
402 if (!IS_ERR(page)) { 400 if (!IS_ERR(page)) {
@@ -418,13 +416,11 @@ static inline __u32 xattr_hash(const char *msg, int len)
418 416
419int reiserfs_commit_write(struct file *f, struct page *page, 417int reiserfs_commit_write(struct file *f, struct page *page,
420 unsigned from, unsigned to); 418 unsigned from, unsigned to);
421int reiserfs_prepare_write(struct file *f, struct page *page,
422 unsigned from, unsigned to);
423 419
424static void update_ctime(struct inode *inode) 420static void update_ctime(struct inode *inode)
425{ 421{
426 struct timespec now = current_fs_time(inode->i_sb); 422 struct timespec now = current_fs_time(inode->i_sb);
427 if (hlist_unhashed(&inode->i_hash) || !inode->i_nlink || 423 if (inode_unhashed(inode) || !inode->i_nlink ||
428 timespec_equal(&inode->i_ctime, &now)) 424 timespec_equal(&inode->i_ctime, &now))
429 return; 425 return;
430 426
@@ -532,8 +528,7 @@ reiserfs_xattr_set_handle(struct reiserfs_transaction_handle *th,
532 rxh->h_hash = cpu_to_le32(xahash); 528 rxh->h_hash = cpu_to_le32(xahash);
533 } 529 }
534 530
535 err = reiserfs_prepare_write(NULL, page, page_offset, 531 err = __reiserfs_write_begin(page, page_offset, chunk + skip);
536 page_offset + chunk + skip);
537 if (!err) { 532 if (!err) {
538 if (buffer) 533 if (buffer)
539 memcpy(data + skip, buffer + buffer_pos, chunk); 534 memcpy(data + skip, buffer + buffer_pos, chunk);
@@ -873,11 +868,14 @@ out:
873 return err; 868 return err;
874} 869}
875 870
876static int reiserfs_check_acl(struct inode *inode, int mask) 871static int reiserfs_check_acl(struct inode *inode, int mask, unsigned int flags)
877{ 872{
878 struct posix_acl *acl; 873 struct posix_acl *acl;
879 int error = -EAGAIN; /* do regular unix permission checks by default */ 874 int error = -EAGAIN; /* do regular unix permission checks by default */
880 875
876 if (flags & IPERM_FLAG_RCU)
877 return -ECHILD;
878
881 acl = reiserfs_get_acl(inode, ACL_TYPE_ACCESS); 879 acl = reiserfs_get_acl(inode, ACL_TYPE_ACCESS);
882 880
883 if (acl) { 881 if (acl) {
@@ -954,7 +952,7 @@ static int xattr_mount_check(struct super_block *s)
954 return 0; 952 return 0;
955} 953}
956 954
957int reiserfs_permission(struct inode *inode, int mask) 955int reiserfs_permission(struct inode *inode, int mask, unsigned int flags)
958{ 956{
959 /* 957 /*
960 * We don't do permission checks on the internal objects. 958 * We don't do permission checks on the internal objects.
@@ -968,9 +966,10 @@ int reiserfs_permission(struct inode *inode, int mask)
968 * Stat data v1 doesn't support ACLs. 966 * Stat data v1 doesn't support ACLs.
969 */ 967 */
970 if (get_inode_sd_version(inode) != STAT_DATA_V1) 968 if (get_inode_sd_version(inode) != STAT_DATA_V1)
971 return generic_permission(inode, mask, reiserfs_check_acl); 969 return generic_permission(inode, mask, flags,
970 reiserfs_check_acl);
972#endif 971#endif
973 return generic_permission(inode, mask, NULL); 972 return generic_permission(inode, mask, flags, NULL);
974} 973}
975 974
976static int xattr_hide_revalidate(struct dentry *dentry, struct nameidata *nd) 975static int xattr_hide_revalidate(struct dentry *dentry, struct nameidata *nd)
@@ -993,7 +992,7 @@ int reiserfs_lookup_privroot(struct super_block *s)
993 strlen(PRIVROOT_NAME)); 992 strlen(PRIVROOT_NAME));
994 if (!IS_ERR(dentry)) { 993 if (!IS_ERR(dentry)) {
995 REISERFS_SB(s)->priv_root = dentry; 994 REISERFS_SB(s)->priv_root = dentry;
996 dentry->d_op = &xattr_lookup_poison_ops; 995 d_set_d_op(dentry, &xattr_lookup_poison_ops);
997 if (dentry->d_inode) 996 if (dentry->d_inode)
998 dentry->d_inode->i_flags |= S_PRIVATE; 997 dentry->d_inode->i_flags |= S_PRIVATE;
999 } else 998 } else
diff --git a/fs/reiserfs/xattr_acl.c b/fs/reiserfs/xattr_acl.c
index 536d697a8a28..3dc38f1206fc 100644
--- a/fs/reiserfs/xattr_acl.c
+++ b/fs/reiserfs/xattr_acl.c
@@ -26,7 +26,7 @@ posix_acl_set(struct dentry *dentry, const char *name, const void *value,
26 size_t jcreate_blocks; 26 size_t jcreate_blocks;
27 if (!reiserfs_posixacl(inode->i_sb)) 27 if (!reiserfs_posixacl(inode->i_sb))
28 return -EOPNOTSUPP; 28 return -EOPNOTSUPP;
29 if (!is_owner_or_cap(inode)) 29 if (!inode_owner_or_capable(inode))
30 return -EPERM; 30 return -EPERM;
31 31
32 if (value) { 32 if (value) {
@@ -472,7 +472,9 @@ int reiserfs_acl_chmod(struct inode *inode)
472 struct reiserfs_transaction_handle th; 472 struct reiserfs_transaction_handle th;
473 size_t size = reiserfs_xattr_nblocks(inode, 473 size_t size = reiserfs_xattr_nblocks(inode,
474 reiserfs_acl_size(clone->a_count)); 474 reiserfs_acl_size(clone->a_count));
475 reiserfs_write_lock(inode->i_sb); 475 int depth;
476
477 depth = reiserfs_write_lock_once(inode->i_sb);
476 error = journal_begin(&th, inode->i_sb, size * 2); 478 error = journal_begin(&th, inode->i_sb, size * 2);
477 if (!error) { 479 if (!error) {
478 int error2; 480 int error2;
@@ -482,7 +484,7 @@ int reiserfs_acl_chmod(struct inode *inode)
482 if (error2) 484 if (error2)
483 error = error2; 485 error = error2;
484 } 486 }
485 reiserfs_write_unlock(inode->i_sb); 487 reiserfs_write_unlock_once(inode->i_sb, depth);
486 } 488 }
487 posix_acl_release(clone); 489 posix_acl_release(clone);
488 return error; 490 return error;
diff --git a/fs/reiserfs/xattr_security.c b/fs/reiserfs/xattr_security.c
index 237c6928d3c6..ef66c18a9332 100644
--- a/fs/reiserfs/xattr_security.c
+++ b/fs/reiserfs/xattr_security.c
@@ -54,6 +54,7 @@ static size_t security_list(struct dentry *dentry, char *list, size_t list_len,
54 * of blocks needed for the transaction. If successful, reiserfs_security 54 * of blocks needed for the transaction. If successful, reiserfs_security
55 * must be released using reiserfs_security_free when the caller is done. */ 55 * must be released using reiserfs_security_free when the caller is done. */
56int reiserfs_security_init(struct inode *dir, struct inode *inode, 56int reiserfs_security_init(struct inode *dir, struct inode *inode,
57 const struct qstr *qstr,
57 struct reiserfs_security_handle *sec) 58 struct reiserfs_security_handle *sec)
58{ 59{
59 int blocks = 0; 60 int blocks = 0;
@@ -65,7 +66,7 @@ int reiserfs_security_init(struct inode *dir, struct inode *inode,
65 if (IS_PRIVATE(dir)) 66 if (IS_PRIVATE(dir))
66 return 0; 67 return 0;
67 68
68 error = security_inode_init_security(inode, dir, &sec->name, 69 error = security_inode_init_security(inode, dir, qstr, &sec->name,
69 &sec->value, &sec->length); 70 &sec->value, &sec->length);
70 if (error) { 71 if (error) {
71 if (error == -EOPNOTSUPP) 72 if (error == -EOPNOTSUPP)