Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Mahoney <jeffm@suse.com>2013-09-12 16:53:40 -0400
committerJeff Mahoney <jeffm@suse.com>2013-09-12 16:53:40 -0400
commitfd0a17821467765e148d55578975e2e22e25d3a4 (patch)
treecb8383113f9a8e96eea1c7cd27548764f19f62b0
parentcddcbe7f991548be1d486bb353b242b990dcc4f3 (diff)
- Update
patches.fixes/reiserfs-locking-handle-nested-locks-properly. - Update patches.fixes/reiserfs-locking-push-write-lock-out-of-xattr-code. - Update patches.fixes/reiserfs-locking-release-lock-around-quota-operations.
-rw-r--r--patches.fixes/reiserfs-locking-handle-nested-locks-properly586
-rw-r--r--patches.fixes/reiserfs-locking-push-write-lock-out-of-xattr-code119
-rw-r--r--patches.fixes/reiserfs-locking-release-lock-around-quota-operations479
3 files changed, 448 insertions, 736 deletions
diff --git a/patches.fixes/reiserfs-locking-handle-nested-locks-properly b/patches.fixes/reiserfs-locking-handle-nested-locks-properly
index 2fbaeb7c80..b831425f1a 100644
--- a/patches.fixes/reiserfs-locking-handle-nested-locks-properly
+++ b/patches.fixes/reiserfs-locking-handle-nested-locks-properly
@@ -1,7 +1,9 @@
+From 278f6679f454bf185a07d9a4ca355b153482d17a Mon Sep 17 00:00:00 2001
From: Jeff Mahoney <jeffm@suse.com>
+Date: Thu, 8 Aug 2013 17:34:46 -0400
Subject: reiserfs: locking, handle nested locks properly
-References: bnc#815320
-Patch-mainline: Posted to reiserfs-devel, 5 Aug 2013
+Git-commit: 278f6679f454bf185a07d9a4ca355b153482d17a
+Patch-mainline: v3.12-rc1
The reiserfs write lock replaced the BKL and uses similar semantics.
@@ -18,25 +20,26 @@ should be dropped.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
+ fs/reiserfs/bitmap.c | 5 ++-
+ fs/reiserfs/dir.c | 7 ++--
+ fs/reiserfs/fix_node.c | 26 +++++++------
+ fs/reiserfs/inode.c | 77 +++++++++++++++++-------------------
+ fs/reiserfs/ioctl.c | 7 ++--
+ fs/reiserfs/journal.c | 104 ++++++++++++++++++++++++++-----------------------
+ fs/reiserfs/lock.c | 43 ++++++++++----------
+ fs/reiserfs/namei.c | 24 ++++--------
+ fs/reiserfs/prints.c | 5 ++-
+ fs/reiserfs/reiserfs.h | 36 +++++++++--------
+ fs/reiserfs/resize.c | 10 ++++-
+ fs/reiserfs/stree.c | 46 ++++++++++------------
+ fs/reiserfs/super.c | 5 +--
+ 13 files changed, 201 insertions(+), 194 deletions(-)
- fs/reiserfs/bitmap.c | 5 +-
- fs/reiserfs/dir.c | 7 +-
- fs/reiserfs/fix_node.c | 26 +++++------
- fs/reiserfs/inode.c | 79 +++++++++++++++------------------
- fs/reiserfs/ioctl.c | 7 +-
- fs/reiserfs/journal.c | 104 +++++++++++++++++++++++---------------------
- fs/reiserfs/lock.c | 66 +++++++++++++++++++--------
- fs/reiserfs/namei.c | 24 +++-------
- fs/reiserfs/prints.c | 5 +-
- fs/reiserfs/resize.c | 10 +++-
- fs/reiserfs/stree.c | 24 ++++++----
- fs/reiserfs/super.c | 5 --
- include/linux/reiserfs_fs.h | 82 +++++++++++++++++++++-------------
- 13 files changed, 249 insertions(+), 195 deletions(-)
-
+diff --git a/fs/reiserfs/bitmap.c b/fs/reiserfs/bitmap.c
+index a98b774..881f8ea 100644
--- a/fs/reiserfs/bitmap.c
+++ b/fs/reiserfs/bitmap.c
-@@ -1255,10 +1255,11 @@ struct buffer_head *reiserfs_read_bitmap
+@@ -1340,10 +1340,11 @@ struct buffer_head *reiserfs_read_bitmap_block(struct super_block *sb,
"reading failed", __func__, block);
else {
if (buffer_locked(bh)) {
@@ -50,9 +53,11 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
}
BUG_ON(!buffer_uptodate(bh));
BUG_ON(atomic_read(&bh->b_count) == 0);
+diff --git a/fs/reiserfs/dir.c b/fs/reiserfs/dir.c
+index 03e4ca5..1fd2051 100644
--- a/fs/reiserfs/dir.c
+++ b/fs/reiserfs/dir.c
-@@ -74,6 +74,7 @@ int reiserfs_readdir_dentry(struct dentr
+@@ -71,6 +71,7 @@ int reiserfs_readdir_inode(struct inode *inode, struct dir_context *ctx)
char small_buf[32]; /* avoid kmalloc if we can */
struct reiserfs_dir_entry de;
int ret = 0;
@@ -60,7 +65,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
reiserfs_write_lock(inode->i_sb);
-@@ -186,17 +187,17 @@ int reiserfs_readdir_dentry(struct dentr
+@@ -181,17 +182,17 @@ int reiserfs_readdir_inode(struct inode *inode, struct dir_context *ctx)
* Since filldir might sleep, we can release
* the write lock here for other waiters
*/
@@ -81,9 +86,11 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
if (local_buf != small_buf) {
kfree(local_buf);
}
+diff --git a/fs/reiserfs/fix_node.c b/fs/reiserfs/fix_node.c
+index 430e065..dc4d415 100644
--- a/fs/reiserfs/fix_node.c
+++ b/fs/reiserfs/fix_node.c
-@@ -1022,9 +1022,9 @@ static int get_far_parent(struct tree_ba
+@@ -1022,9 +1022,9 @@ static int get_far_parent(struct tree_balance *tb,
if (buffer_locked(*pcom_father)) {
/* Release the write lock while the buffer is busy */
@@ -95,7 +102,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
if (FILESYSTEM_CHANGED_TB(tb)) {
brelse(*pcom_father);
return REPEAT_SEARCH;
-@@ -1929,9 +1929,9 @@ static int get_direct_parent(struct tree
+@@ -1929,9 +1929,9 @@ static int get_direct_parent(struct tree_balance *tb, int h)
return REPEAT_SEARCH;
if (buffer_locked(bh)) {
@@ -107,7 +114,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
if (FILESYSTEM_CHANGED_TB(tb))
return REPEAT_SEARCH;
}
-@@ -1952,6 +1952,7 @@ static int get_neighbors(struct tree_bal
+@@ -1952,6 +1952,7 @@ static int get_neighbors(struct tree_balance *tb, int h)
unsigned long son_number;
struct super_block *sb = tb->tb_sb;
struct buffer_head *bh;
@@ -115,7 +122,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
PROC_INFO_INC(sb, get_neighbors[h]);
-@@ -1969,9 +1970,9 @@ static int get_neighbors(struct tree_bal
+@@ -1969,9 +1970,9 @@ static int get_neighbors(struct tree_balance *tb, int h)
tb->FL[h]) ? tb->lkey[h] : B_NR_ITEMS(tb->
FL[h]);
son_number = B_N_CHILD_NUM(tb->FL[h], child_position);
@@ -127,7 +134,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
if (!bh)
return IO_ERROR;
if (FILESYSTEM_CHANGED_TB(tb)) {
-@@ -2009,9 +2010,9 @@ static int get_neighbors(struct tree_bal
+@@ -2009,9 +2010,9 @@ static int get_neighbors(struct tree_balance *tb, int h)
child_position =
(bh == tb->FR[h]) ? tb->rkey[h] + 1 : 0;
son_number = B_N_CHILD_NUM(tb->FR[h], child_position);
@@ -139,7 +146,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
if (!bh)
return IO_ERROR;
if (FILESYSTEM_CHANGED_TB(tb)) {
-@@ -2272,6 +2273,7 @@ static int wait_tb_buffers_until_unlocke
+@@ -2272,6 +2273,7 @@ static int wait_tb_buffers_until_unlocked(struct tree_balance *tb)
}
if (locked) {
@@ -147,7 +154,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
#ifdef CONFIG_REISERFS_CHECK
repeat_counter++;
if ((repeat_counter % 10000) == 0) {
-@@ -2286,9 +2288,9 @@ static int wait_tb_buffers_until_unlocke
+@@ -2286,9 +2288,9 @@ static int wait_tb_buffers_until_unlocked(struct tree_balance *tb)
REPEAT_SEARCH : CARRY_ON;
}
#endif
@@ -159,7 +166,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
if (FILESYSTEM_CHANGED_TB(tb))
return REPEAT_SEARCH;
}
-@@ -2359,9 +2361,9 @@ int fix_nodes(int op_mode, struct tree_b
+@@ -2359,9 +2361,9 @@ int fix_nodes(int op_mode, struct tree_balance *tb,
/* if it possible in indirect_to_direct conversion */
if (buffer_locked(tbS0)) {
@@ -171,9 +178,11 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
if (FILESYSTEM_CHANGED_TB(tb))
return REPEAT_SEARCH;
}
+diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
+index bf1331a..4a3a57c 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
-@@ -40,11 +40,10 @@ void reiserfs_evict_inode(struct inode *
+@@ -41,11 +41,10 @@ void reiserfs_evict_inode(struct inode *inode)
/* The = 0 happens when we abort creating a new inode for some reason like lack of space.. */
if (!(inode->i_state & I_NEW) && INODE_PKEY(inode)->k_objectid != 0) { /* also handles bad_inode case */
@@ -186,7 +195,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
if (journal_begin(&th, inode->i_sb, jbegin_count))
goto out;
-@@ -73,7 +72,7 @@ void reiserfs_evict_inode(struct inode *
+@@ -74,7 +73,7 @@ void reiserfs_evict_inode(struct inode *inode)
remove_save_link(inode, 0 /* not truncate */ ); /* we can't do anything
* about an error here */
out:
@@ -195,7 +204,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
} else {
/* no object items are in the tree */
;
-@@ -610,7 +609,6 @@ int reiserfs_get_block(struct inode *ino
+@@ -611,7 +610,6 @@ int reiserfs_get_block(struct inode *inode, sector_t block,
__le32 *item;
int done;
int fs_gen;
@@ -203,7 +212,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
struct reiserfs_transaction_handle *th = NULL;
/* space reserved in transaction batch:
. 3 balancings in direct->indirect conversion
-@@ -626,11 +624,11 @@ int reiserfs_get_block(struct inode *ino
+@@ -627,11 +625,11 @@ int reiserfs_get_block(struct inode *inode, sector_t block,
loff_t new_offset =
(((loff_t) block) << inode->i_sb->s_blocksize_bits) + 1;
@@ -217,7 +226,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
return -EFBIG;
}
-@@ -642,7 +640,7 @@ int reiserfs_get_block(struct inode *ino
+@@ -643,7 +641,7 @@ int reiserfs_get_block(struct inode *inode, sector_t block,
/* find number of block-th logical block of the file */
ret = _get_block_create_0(inode, block, bh_result,
create | GET_BLOCK_READ_DIRECT);
@@ -226,7 +235,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
return ret;
}
/*
-@@ -760,7 +758,7 @@ int reiserfs_get_block(struct inode *ino
+@@ -761,7 +759,7 @@ int reiserfs_get_block(struct inode *inode, sector_t block,
if (!dangle && th)
retval = reiserfs_end_persistent_transaction(th);
@@ -235,7 +244,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
/* the item was found, so new blocks were not added to the file
** there is no need to make sure the inode is updated with this
-@@ -1011,11 +1009,7 @@ int reiserfs_get_block(struct inode *ino
+@@ -1012,11 +1010,7 @@ int reiserfs_get_block(struct inode *inode, sector_t block,
* long time. reschedule if needed and also release the write
* lock for others.
*/
@@ -248,7 +257,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
retval = search_for_position_by_key(inode->i_sb, &key, &path);
if (retval == IO_ERROR) {
-@@ -1050,7 +1044,7 @@ int reiserfs_get_block(struct inode *ino
+@@ -1051,7 +1045,7 @@ int reiserfs_get_block(struct inode *inode, sector_t block,
retval = err;
}
@@ -257,7 +266,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
reiserfs_check_path(&path);
return retval;
}
-@@ -1504,14 +1498,15 @@ struct inode *reiserfs_iget(struct super
+@@ -1510,14 +1504,15 @@ struct inode *reiserfs_iget(struct super_block *s, const struct cpu_key *key)
{
struct inode *inode;
struct reiserfs_iget_args args;
@@ -275,7 +284,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
if (!inode)
return ERR_PTR(-ENOMEM);
-@@ -1781,6 +1776,7 @@ int reiserfs_new_inode(struct reiserfs_t
+@@ -1781,6 +1776,7 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
struct stat_data sd;
int retval;
int err;
@@ -283,7 +292,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
BUG_ON(!th->t_trans_id);
-@@ -1813,10 +1809,10 @@ int reiserfs_new_inode(struct reiserfs_t
+@@ -1813,10 +1809,10 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
memcpy(INODE_PKEY(inode), &(ih.ih_key), KEY_SIZE);
args.dirid = le32_to_cpu(ih.ih_key.k_dir_id);
@@ -296,7 +305,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
if (err) {
err = -EINVAL;
goto out_bad_inode;
-@@ -2108,9 +2104,8 @@ int reiserfs_truncate_file(struct inode
+@@ -2108,9 +2104,8 @@ int reiserfs_truncate_file(struct inode *inode, int update_timestamps)
int error;
struct buffer_head *bh = NULL;
int err2;
@@ -307,7 +316,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
if (inode->i_size > 0) {
error = grab_tail_page(inode, &page, &bh);
-@@ -2179,7 +2174,7 @@ int reiserfs_truncate_file(struct inode
+@@ -2179,7 +2174,7 @@ int reiserfs_truncate_file(struct inode *inode, int update_timestamps)
page_cache_release(page);
}
@@ -316,7 +325,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
return 0;
out:
-@@ -2188,7 +2183,7 @@ int reiserfs_truncate_file(struct inode
+@@ -2188,7 +2183,7 @@ int reiserfs_truncate_file(struct inode *inode, int update_timestamps)
page_cache_release(page);
}
@@ -325,7 +334,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
return error;
}
-@@ -2646,10 +2641,11 @@ int __reiserfs_write_begin(struct page *
+@@ -2653,10 +2648,11 @@ int __reiserfs_write_begin(struct page *page, unsigned from, unsigned len)
struct inode *inode = page->mapping->host;
int ret;
int old_ref = 0;
@@ -339,7 +348,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
fix_tail_page_for_writing(page);
if (reiserfs_transaction_running(inode->i_sb)) {
-@@ -2706,7 +2702,6 @@ static int reiserfs_write_end(struct fil
+@@ -2713,7 +2709,6 @@ static int reiserfs_write_end(struct file *file, struct address_space *mapping,
int update_sd = 0;
struct reiserfs_transaction_handle *th;
unsigned start;
@@ -347,7 +356,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
bool locked = false;
if ((unsigned long)fsdata & AOP_FLAG_CONT_EXPAND)
-@@ -2735,7 +2730,7 @@ static int reiserfs_write_end(struct fil
+@@ -2742,7 +2737,7 @@ static int reiserfs_write_end(struct file *file, struct address_space *mapping,
*/
if (pos + copied > inode->i_size) {
struct reiserfs_transaction_handle myth;
@@ -356,7 +365,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
locked = true;
/* If the file have grown beyond the border where it
can have a tail, unmark it as needing a tail
-@@ -2766,7 +2761,7 @@ static int reiserfs_write_end(struct fil
+@@ -2773,7 +2768,7 @@ static int reiserfs_write_end(struct file *file, struct address_space *mapping,
}
if (th) {
if (!locked) {
@@ -365,7 +374,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
locked = true;
}
if (!update_sd)
-@@ -2778,7 +2773,7 @@ static int reiserfs_write_end(struct fil
+@@ -2785,7 +2780,7 @@ static int reiserfs_write_end(struct file *file, struct address_space *mapping,
out:
if (locked)
@@ -374,7 +383,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
unlock_page(page);
page_cache_release(page);
-@@ -2788,7 +2783,7 @@ static int reiserfs_write_end(struct fil
+@@ -2795,7 +2790,7 @@ static int reiserfs_write_end(struct file *file, struct address_space *mapping,
return ret == 0 ? copied : ret;
journal_error:
@@ -383,7 +392,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
locked = false;
if (th) {
if (!update_sd)
-@@ -2806,10 +2801,11 @@ int reiserfs_commit_write(struct file *f
+@@ -2813,10 +2808,11 @@ int reiserfs_commit_write(struct file *f, struct page *page,
int ret = 0;
int update_sd = 0;
struct reiserfs_transaction_handle *th = NULL;
@@ -397,7 +406,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
if (reiserfs_transaction_running(inode->i_sb)) {
th = current->journal_info;
-@@ -3101,7 +3097,6 @@ int reiserfs_setattr(struct dentry *dent
+@@ -3115,7 +3111,6 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
{
struct inode *inode = dentry->d_inode;
unsigned int ia_valid;
@@ -405,7 +414,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
int error;
error = inode_change_ok(inode, attr);
-@@ -3113,14 +3108,14 @@ int reiserfs_setattr(struct dentry *dent
+@@ -3127,14 +3122,14 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
if (is_quota_modification(inode, attr))
dquot_initialize(inode);
@@ -422,7 +431,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
error = -EFBIG;
goto out;
}
-@@ -3140,7 +3135,7 @@ int reiserfs_setattr(struct dentry *dent
+@@ -3157,7 +3152,7 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
error = err;
}
if (error) {
@@ -431,7 +440,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
goto out;
}
/*
-@@ -3150,12 +3145,12 @@ int reiserfs_setattr(struct dentry *dent
+@@ -3167,7 +3162,7 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
attr->ia_valid |= (ATTR_MTIME | ATTR_CTIME);
}
}
@@ -440,13 +449,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
if ((((attr->ia_valid & ATTR_UID) && (from_kuid(&init_user_ns, attr->ia_uid) & ~0xffff)) ||
((attr->ia_valid & ATTR_GID) && (from_kgid(&init_user_ns, attr->ia_gid) & ~0xffff))) &&
- (get_inode_sd_version(inode) == STAT_DATA_V1)) {
-- reiserfs_write_unlock_once(inode->i_sb, depth);
-+ reiserfs_write_unlock(inode->i_sb);
- /* stat data of format v3.5 has 16 bit uid and gid */
- error = -EINVAL;
- goto out;
-@@ -3176,16 +3171,16 @@ int reiserfs_setattr(struct dentry *dent
+@@ -3192,16 +3187,16 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
return error;
/* (user+group)*(old+new) structure - we count quota info and , inode write (sb, inode) */
@@ -467,7 +470,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
goto out;
}
-@@ -3197,7 +3192,7 @@ int reiserfs_setattr(struct dentry *dent
+@@ -3213,7 +3208,7 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
inode->i_gid = attr->ia_gid;
mark_inode_dirty(inode);
error = journal_end(&th, inode->i_sb, jbegin_count);
@@ -476,9 +479,11 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
if (error)
goto out;
}
+diff --git a/fs/reiserfs/ioctl.c b/fs/reiserfs/ioctl.c
+index 15cb5fe..946ccbf 100644
--- a/fs/reiserfs/ioctl.c
+++ b/fs/reiserfs/ioctl.c
-@@ -167,7 +167,6 @@ int reiserfs_commit_write(struct file *f
+@@ -167,7 +167,6 @@ int reiserfs_commit_write(struct file *f, struct page *page,
int reiserfs_unpack(struct inode *inode, struct file *filp)
{
int retval = 0;
@@ -486,7 +491,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
int index;
struct page *page;
struct address_space *mapping;
-@@ -183,11 +182,11 @@ int reiserfs_unpack(struct inode *inode,
+@@ -183,11 +182,11 @@ int reiserfs_unpack(struct inode *inode, struct file *filp)
return 0;
}
@@ -500,7 +505,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
write_from = inode->i_size & (blocksize - 1);
/* if we are on a block boundary, we are already unpacked. */
if (write_from == 0) {
-@@ -221,6 +220,6 @@ int reiserfs_unpack(struct inode *inode,
+@@ -221,6 +220,6 @@ int reiserfs_unpack(struct inode *inode, struct file *filp)
out:
mutex_unlock(&inode->i_mutex);
@@ -508,9 +513,11 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
+ reiserfs_write_unlock(inode->i_sb);
return retval;
}
+diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c
+index 742fdd4..73feacc4 100644
--- a/fs/reiserfs/journal.c
+++ b/fs/reiserfs/journal.c
-@@ -954,9 +954,11 @@ static int reiserfs_async_progress_wait(
+@@ -947,9 +947,11 @@ static int reiserfs_async_progress_wait(struct super_block *s)
struct reiserfs_journal *j = SB_JOURNAL(s);
if (atomic_read(&j->j_async_throttle)) {
@@ -524,7 +531,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
}
return 0;
-@@ -979,6 +981,7 @@ static int flush_commit_list(struct supe
+@@ -972,6 +974,7 @@ static int flush_commit_list(struct super_block *s,
struct reiserfs_journal *journal = SB_JOURNAL(s);
int retval = 0;
int write_len;
@@ -532,7 +539,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
reiserfs_check_lock_depth(s, "flush_commit_list");
-@@ -1027,12 +1030,12 @@ static int flush_commit_list(struct supe
+@@ -1018,12 +1021,12 @@ static int flush_commit_list(struct super_block *s,
* We might sleep in numerous places inside
* write_ordered_buffers. Relax the write lock.
*/
@@ -547,7 +554,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
}
BUG_ON(!list_empty(&jl->j_bh_list));
/*
-@@ -1052,9 +1055,9 @@ static int flush_commit_list(struct supe
+@@ -1043,9 +1046,9 @@ static int flush_commit_list(struct super_block *s,
tbh = journal_find_get_block(s, bn);
if (tbh) {
if (buffer_dirty(tbh)) {
@@ -559,7 +566,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
}
put_bh(tbh) ;
}
-@@ -1066,17 +1069,17 @@ static int flush_commit_list(struct supe
+@@ -1057,17 +1060,17 @@ static int flush_commit_list(struct super_block *s,
(jl->j_start + i) % SB_ONDISK_JOURNAL_SIZE(s);
tbh = journal_find_get_block(s, bn);
@@ -582,7 +589,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
}
if (unlikely(!buffer_uptodate(tbh))) {
#ifdef CONFIG_REISERFS_CHECK
-@@ -1100,12 +1103,12 @@ static int flush_commit_list(struct supe
+@@ -1091,12 +1094,12 @@ static int flush_commit_list(struct super_block *s,
if (buffer_dirty(jl->j_commit_bh))
BUG();
mark_buffer_dirty(jl->j_commit_bh) ;
@@ -597,7 +604,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
}
/* If there was a write error in the journal - we can't commit this
-@@ -1238,15 +1241,16 @@ static int _update_journal_header_block(
+@@ -1228,15 +1231,16 @@ static int _update_journal_header_block(struct super_block *sb,
{
struct reiserfs_journal_header *jh;
struct reiserfs_journal *journal = SB_JOURNAL(sb);
@@ -617,7 +624,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
if (unlikely(!buffer_uptodate(journal->j_header_bh))) {
#ifdef CONFIG_REISERFS_CHECK
reiserfs_warning(sb, "journal-699",
-@@ -1264,14 +1268,14 @@ static int _update_journal_header_block(
+@@ -1254,14 +1258,14 @@ static int _update_journal_header_block(struct super_block *sb,
jh->j_mount_id = cpu_to_le32(journal->j_mount_id);
set_buffer_dirty(journal->j_header_bh);
@@ -634,7 +641,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
if (!buffer_uptodate(journal->j_header_bh)) {
reiserfs_warning(sb, "journal-837",
"IO error during journal replay");
-@@ -1351,6 +1355,7 @@ static int flush_journal_list(struct sup
+@@ -1341,6 +1345,7 @@ static int flush_journal_list(struct super_block *s,
unsigned long j_len_saved = jl->j_len;
struct reiserfs_journal *journal = SB_JOURNAL(s);
int err = 0;
@@ -642,7 +649,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
BUG_ON(j_len_saved <= 0);
-@@ -1507,9 +1512,9 @@ static int flush_journal_list(struct sup
+@@ -1495,9 +1500,9 @@ static int flush_journal_list(struct super_block *s,
"cn->bh is NULL");
}
@@ -655,7 +662,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
if (!cn->bh) {
reiserfs_panic(s, "journal-1012",
-@@ -1985,6 +1990,7 @@ static int journal_compare_desc_commit(s
+@@ -1974,6 +1979,7 @@ static int journal_compare_desc_commit(struct super_block *sb,
/* returns 0 if it did not find a description block
** returns -1 if it found a corrupt commit block
** returns 1 if both desc and commit were valid
@@ -663,7 +670,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
*/
static int journal_transaction_is_valid(struct super_block *sb,
struct buffer_head *d_bh,
-@@ -2084,8 +2090,9 @@ static void brelse_array(struct buffer_h
+@@ -2073,8 +2079,9 @@ static void brelse_array(struct buffer_head **heads, int num)
/*
** given the start, and values for the oldest acceptable transactions,
@@ -675,7 +682,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
*/
static int journal_read_transaction(struct super_block *sb,
unsigned long cur_dblock,
-@@ -2219,10 +2226,7 @@ static int journal_read_transaction(stru
+@@ -2208,10 +2215,7 @@ static int journal_read_transaction(struct super_block *sb,
ll_rw_block(READ, get_desc_trans_len(desc), log_blocks);
for (i = 0; i < get_desc_trans_len(desc); i++) {
@@ -686,7 +693,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
if (!buffer_uptodate(log_blocks[i])) {
reiserfs_warning(sb, "journal-1212",
"REPLAY FAILURE fsck required! "
-@@ -2329,12 +2333,13 @@ static struct buffer_head *reiserfs_brea
+@@ -2318,12 +2322,13 @@ static struct buffer_head *reiserfs_breada(struct block_device *dev,
/*
** read and replay the log
@@ -705,7 +712,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
*/
static int journal_read(struct super_block *sb)
{
-@@ -2512,14 +2517,18 @@ static int journal_read(struct super_blo
+@@ -2501,14 +2506,18 @@ static int journal_read(struct super_block *sb)
"replayed %d transactions in %lu seconds\n",
replay_count, get_seconds() - start);
}
@@ -724,7 +731,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
return 0;
}
-@@ -2850,13 +2859,7 @@ int journal_init(struct super_block *sb,
+@@ -2828,13 +2837,7 @@ int journal_init(struct super_block *sb, const char *j_dev_name,
goto free_and_return;
}
@@ -738,7 +745,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
if (ret < 0) {
reiserfs_warning(sb, "reiserfs-2006",
"Replay Failure, unable to mount");
-@@ -2948,9 +2951,9 @@ static void queue_log_writer(struct supe
+@@ -2923,9 +2926,9 @@ static void queue_log_writer(struct super_block *s)
add_wait_queue(&journal->j_join_wait, &wait);
set_current_state(TASK_UNINTERRUPTIBLE);
if (test_bit(J_WRITERS_QUEUED, &journal->j_state)) {
@@ -750,7 +757,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
}
__set_current_state(TASK_RUNNING);
remove_wait_queue(&journal->j_join_wait, &wait);
-@@ -2968,9 +2971,12 @@ static void let_transaction_grow(struct
+@@ -2943,9 +2946,12 @@ static void let_transaction_grow(struct super_block *sb, unsigned int trans_id)
struct reiserfs_journal *journal = SB_JOURNAL(sb);
unsigned long bcount = journal->j_bcount;
while (1) {
@@ -765,7 +772,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
journal->j_current_jl->j_state |= LIST_COMMIT_PENDING;
while ((atomic_read(&journal->j_wcount) > 0 ||
atomic_read(&journal->j_jlock)) &&
-@@ -3001,6 +3007,7 @@ static int do_journal_begin_r(struct rei
+@@ -2976,6 +2982,7 @@ static int do_journal_begin_r(struct reiserfs_transaction_handle *th,
struct reiserfs_transaction_handle myth;
int sched_count = 0;
int retval;
@@ -773,7 +780,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
reiserfs_check_lock_depth(sb, "journal_begin");
BUG_ON(nblocks > journal->j_trans_max);
-@@ -3021,9 +3028,9 @@ static int do_journal_begin_r(struct rei
+@@ -2996,9 +3003,9 @@ static int do_journal_begin_r(struct reiserfs_transaction_handle *th,
if (test_bit(J_WRITERS_BLOCKED, &journal->j_state)) {
unlock_journal(sb);
@@ -785,7 +792,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
PROC_INFO_INC(sb, journal.journal_relock_writers);
goto relock;
}
-@@ -3850,6 +3857,7 @@ void reiserfs_restore_prepared_buffer(st
+@@ -3821,6 +3828,7 @@ void reiserfs_restore_prepared_buffer(struct super_block *sb,
if (test_clear_buffer_journal_restore_dirty(bh) &&
buffer_journal_dirty(bh)) {
struct reiserfs_journal_cnode *cn;
@@ -793,7 +800,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
cn = get_journal_hash_dev(sb,
journal->j_list_hash_table,
bh->b_blocknr);
-@@ -3857,6 +3865,7 @@ void reiserfs_restore_prepared_buffer(st
+@@ -3828,6 +3836,7 @@ void reiserfs_restore_prepared_buffer(struct super_block *sb,
set_buffer_journal_test(bh);
mark_buffer_dirty(bh);
}
@@ -801,7 +808,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
}
clear_buffer_journal_prepared(bh);
}
-@@ -3940,6 +3949,7 @@ static int do_journal_end(struct reiserf
+@@ -3911,6 +3920,7 @@ static int do_journal_end(struct reiserfs_transaction_handle *th,
unsigned long jindex;
unsigned int commit_trans_id;
int trans_half;
@@ -809,7 +816,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
BUG_ON(th->t_refcount > 1);
BUG_ON(!th->t_trans_id);
-@@ -4146,9 +4156,7 @@ static int do_journal_end(struct reiserf
+@@ -4116,9 +4126,7 @@ static int do_journal_end(struct reiserfs_transaction_handle *th,
next = cn->next;
free_cnode(sb, cn);
cn = next;
@@ -820,7 +827,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
}
/* we are done with both the c_bh and d_bh, but
-@@ -4195,10 +4203,10 @@ static int do_journal_end(struct reiserf
+@@ -4165,10 +4173,10 @@ static int do_journal_end(struct reiserfs_transaction_handle *th,
* is lost.
*/
if (!list_empty(&jl->j_tail_bh_list)) {
@@ -833,28 +840,11 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
}
BUG_ON(!list_empty(&jl->j_tail_bh_list));
mutex_unlock(&jl->j_commit_mutex);
+diff --git a/fs/reiserfs/lock.c b/fs/reiserfs/lock.c
+index d735bc8..045b83e 100644
--- a/fs/reiserfs/lock.c
+++ b/fs/reiserfs/lock.c
-@@ -29,6 +29,9 @@ void reiserfs_write_lock(struct super_bl
-
- /* No need to protect it, only the current task touches it */
- sb_i->lock_depth++;
-+#ifdef DEBUG
-+ inc_preempt_count();
-+#endif
- }
-
- void reiserfs_write_unlock(struct super_block *s)
-@@ -42,36 +45,59 @@ void reiserfs_write_unlock(struct super_
- */
- BUG_ON(sb_i->lock_owner != current);
-
-+#ifdef DEBUG
-+ dec_preempt_count();
-+#endif
- if (--sb_i->lock_depth == -1) {
- sb_i->lock_owner = NULL;
- mutex_unlock(&sb_i->lock);
+@@ -48,30 +48,35 @@ void reiserfs_write_unlock(struct super_block *s)
}
}
@@ -870,30 +860,22 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
{
struct reiserfs_sb_info *sb_i = REISERFS_SB(s);
+ int depth;
-+#ifdef DEBUG
-+ int i;
-+#endif
-+
+
+- if (sb_i->lock_owner != current) {
+- mutex_lock(&sb_i->lock);
+- sb_i->lock_owner = current;
+- return sb_i->lock_depth++;
+- }
+ /* this can happen when the lock isn't always held */
+ if (sb_i->lock_owner != current)
+ return -1;
+
+ depth = sb_i->lock_depth;
-+#ifdef DEBUG
-+ for (i = 0; i <= depth; i++)
-+ dec_preempt_count();
-+#endif
+
+ sb_i->lock_depth = -1;
+ sb_i->lock_owner = NULL;
+ mutex_unlock(&sb_i->lock);
-- if (sb_i->lock_owner != current) {
-- mutex_lock(&sb_i->lock);
-- sb_i->lock_owner = current;
-- return sb_i->lock_depth++;
-- }
--
- return sb_i->lock_depth;
+ return depth;
}
@@ -904,9 +886,6 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
- if (lock_depth == -1)
- reiserfs_write_unlock(s);
+ struct reiserfs_sb_info *sb_i = REISERFS_SB(s);
-+#ifdef DEBUG
-+ int i;
-+#endif
+
+ /* this can happen when the lock isn't always held */
+ if (depth == -1)
@@ -915,15 +894,10 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
+ mutex_lock(&sb_i->lock);
+ sb_i->lock_owner = current;
+ sb_i->lock_depth = depth;
-+
-+#ifdef DEBUG
-+ for (i = 0; i <= depth; i++)
-+ inc_preempt_count();
-+#endif
}
/*
-@@ -82,9 +108,7 @@ void reiserfs_check_lock_depth(struct su
+@@ -82,9 +87,7 @@ void reiserfs_check_lock_depth(struct super_block *sb, char *caller)
{
struct reiserfs_sb_info *sb_i = REISERFS_SB(sb);
@@ -934,9 +908,11 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
}
#ifdef CONFIG_REISERFS_CHECK
+diff --git a/fs/reiserfs/namei.c b/fs/reiserfs/namei.c
+index 8567fb8..dc5236f 100644
--- a/fs/reiserfs/namei.c
+++ b/fs/reiserfs/namei.c
-@@ -325,7 +325,6 @@ static struct dentry *reiserfs_lookup(st
+@@ -325,7 +325,6 @@ static struct dentry *reiserfs_lookup(struct inode *dir, struct dentry *dentry,
unsigned int flags)
{
int retval;
@@ -944,7 +920,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
struct inode *inode = NULL;
struct reiserfs_dir_entry de;
INITIALIZE_PATH(path_to_entry);
-@@ -333,12 +332,7 @@ static struct dentry *reiserfs_lookup(st
+@@ -333,12 +332,7 @@ static struct dentry *reiserfs_lookup(struct inode *dir, struct dentry *dentry,
if (REISERFS_MAX_NAME(dir->i_sb->s_blocksize) < dentry->d_name.len)
return ERR_PTR(-ENAMETOOLONG);
@@ -958,7 +934,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
de.de_gen_number_bit_string = NULL;
retval =
-@@ -349,7 +343,7 @@ static struct dentry *reiserfs_lookup(st
+@@ -349,7 +343,7 @@ static struct dentry *reiserfs_lookup(struct inode *dir, struct dentry *dentry,
inode = reiserfs_iget(dir->i_sb,
(struct cpu_key *)&(de.de_dir_id));
if (!inode || IS_ERR(inode)) {
@@ -967,7 +943,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
return ERR_PTR(-EACCES);
}
-@@ -358,7 +352,7 @@ static struct dentry *reiserfs_lookup(st
+@@ -358,7 +352,7 @@ static struct dentry *reiserfs_lookup(struct inode *dir, struct dentry *dentry,
if (IS_PRIVATE(dir))
inode->i_flags |= S_PRIVATE;
}
@@ -976,7 +952,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
if (retval == IO_ERROR) {
return ERR_PTR(-EIO);
}
-@@ -727,7 +721,6 @@ static int reiserfs_mkdir(struct inode *
+@@ -727,7 +721,6 @@ static int reiserfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode
struct inode *inode;
struct reiserfs_transaction_handle th;
struct reiserfs_security_handle security;
@@ -984,7 +960,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
/* We need blocks for transaction + (user+group)*(quotas for new inode + update of quota for directory owner) */
int jbegin_count =
JOURNAL_PER_BALANCE_CNT * 3 +
-@@ -753,7 +746,7 @@ static int reiserfs_mkdir(struct inode *
+@@ -753,7 +746,7 @@ static int reiserfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode
return retval;
}
jbegin_count += retval;
@@ -993,8 +969,8 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
retval = journal_begin(&th, dir->i_sb, jbegin_count);
if (retval) {
-@@ -804,7 +797,7 @@ static int reiserfs_mkdir(struct inode *
- d_instantiate(dentry, inode);
+@@ -804,7 +797,7 @@ static int reiserfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode
+ d_instantiate(dentry, inode);
retval = journal_end(&th, dir->i_sb, jbegin_count);
out_failed:
- reiserfs_write_unlock_once(dir->i_sb, lock_depth);
@@ -1002,7 +978,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
return retval;
}
-@@ -920,7 +913,6 @@ static int reiserfs_unlink(struct inode
+@@ -920,7 +913,6 @@ static int reiserfs_unlink(struct inode *dir, struct dentry *dentry)
struct reiserfs_transaction_handle th;
int jbegin_count;
unsigned long savelink;
@@ -1010,7 +986,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
dquot_initialize(dir);
-@@ -934,7 +926,7 @@ static int reiserfs_unlink(struct inode
+@@ -934,7 +926,7 @@ static int reiserfs_unlink(struct inode *dir, struct dentry *dentry)
JOURNAL_PER_BALANCE_CNT * 2 + 2 +
4 * REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb);
@@ -1019,7 +995,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
retval = journal_begin(&th, dir->i_sb, jbegin_count);
if (retval)
goto out_unlink;
-@@ -995,7 +987,7 @@ static int reiserfs_unlink(struct inode
+@@ -995,7 +987,7 @@ static int reiserfs_unlink(struct inode *dir, struct dentry *dentry)
retval = journal_end(&th, dir->i_sb, jbegin_count);
reiserfs_check_path(&path);
@@ -1028,7 +1004,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
return retval;
end_unlink:
-@@ -1005,7 +997,7 @@ static int reiserfs_unlink(struct inode
+@@ -1005,7 +997,7 @@ static int reiserfs_unlink(struct inode *dir, struct dentry *dentry)
if (err)
retval = err;
out_unlink:
@@ -1037,9 +1013,11 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
return retval;
}
+diff --git a/fs/reiserfs/prints.c b/fs/reiserfs/prints.c
+index c0b1112..54944d5 100644
--- a/fs/reiserfs/prints.c
+++ b/fs/reiserfs/prints.c
-@@ -358,12 +358,13 @@ void __reiserfs_panic(struct super_block
+@@ -358,12 +358,13 @@ void __reiserfs_panic(struct super_block *sb, const char *id,
dump_stack();
#endif
if (sb)
@@ -1055,9 +1033,86 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
}
void __reiserfs_error(struct super_block *sb, const char *id,
+diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
+index 3df5ce6..f8adaee 100644
+--- a/fs/reiserfs/reiserfs.h
++++ b/fs/reiserfs/reiserfs.h
+@@ -630,8 +630,8 @@ static inline int __reiserfs_is_journal_aborted(struct reiserfs_journal
+ */
+ void reiserfs_write_lock(struct super_block *s);
+ void reiserfs_write_unlock(struct super_block *s);
+-int reiserfs_write_lock_once(struct super_block *s);
+-void reiserfs_write_unlock_once(struct super_block *s, int lock_depth);
++int __must_check reiserfs_write_unlock_nested(struct super_block *s);
++void reiserfs_write_lock_nested(struct super_block *s, int depth);
+
+ #ifdef CONFIG_REISERFS_CHECK
+ void reiserfs_lock_check_recursive(struct super_block *s);
+@@ -667,31 +667,33 @@ static inline void reiserfs_lock_check_recursive(struct super_block *s) { }
+ * - The inode mutex
+ */
+ static inline void reiserfs_mutex_lock_safe(struct mutex *m,
+- struct super_block *s)
++ struct super_block *s)
+ {
+- reiserfs_lock_check_recursive(s);
+- reiserfs_write_unlock(s);
++ int depth;
++
++ depth = reiserfs_write_unlock_nested(s);
+ mutex_lock(m);
+- reiserfs_write_lock(s);
++ reiserfs_write_lock_nested(s, depth);
+ }
+
+ static inline void
+ reiserfs_mutex_lock_nested_safe(struct mutex *m, unsigned int subclass,
+- struct super_block *s)
++ struct super_block *s)
+ {
+- reiserfs_lock_check_recursive(s);
+- reiserfs_write_unlock(s);
++ int depth;
++
++ depth = reiserfs_write_unlock_nested(s);
+ mutex_lock_nested(m, subclass);
+- reiserfs_write_lock(s);
++ reiserfs_write_lock_nested(s, depth);
+ }
+
+ static inline void
+ reiserfs_down_read_safe(struct rw_semaphore *sem, struct super_block *s)
+ {
+- reiserfs_lock_check_recursive(s);
+- reiserfs_write_unlock(s);
+- down_read(sem);
+- reiserfs_write_lock(s);
++ int depth;
++ depth = reiserfs_write_unlock_nested(s);
++ down_read(sem);
++ reiserfs_write_lock_nested(s, depth);
+ }
+
+ /*
+@@ -701,9 +703,11 @@ reiserfs_down_read_safe(struct rw_semaphore *sem, struct super_block *s)
+ static inline void reiserfs_cond_resched(struct super_block *s)
+ {
+ if (need_resched()) {
+- reiserfs_write_unlock(s);
++ int depth;
++
++ depth = reiserfs_write_unlock_nested(s);
+ schedule();
+- reiserfs_write_lock(s);
++ reiserfs_write_lock_nested(s, depth);
+ }
+ }
+
+diff --git a/fs/reiserfs/resize.c b/fs/reiserfs/resize.c
+index 3ce02cf..a4ef5cd 100644
--- a/fs/reiserfs/resize.c
+++ b/fs/reiserfs/resize.c
-@@ -35,6 +35,7 @@ int reiserfs_resize(struct super_block *
+@@ -34,6 +34,7 @@ int reiserfs_resize(struct super_block *s, unsigned long block_count_new)
unsigned long int block_count, free_blocks;
int i;
int copy_size;
@@ -1065,7 +1120,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
sb = SB_DISK_SUPER_BLOCK(s);
-@@ -44,7 +45,9 @@ int reiserfs_resize(struct super_block *
+@@ -43,7 +44,9 @@ int reiserfs_resize(struct super_block *s, unsigned long block_count_new)
}
/* check the device size */
@@ -1075,7 +1130,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
if (!bh) {
printk("reiserfs_resize: can\'t read last block\n");
return -EINVAL;
-@@ -128,9 +131,12 @@ int reiserfs_resize(struct super_block *
+@@ -125,9 +128,12 @@ int reiserfs_resize(struct super_block *s, unsigned long block_count_new)
* transaction begins, and the new bitmaps don't matter if the
* transaction fails. */
for (i = bmap_nr; i < bmap_nr_new; i++) {
@@ -1088,7 +1143,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
if (!bh) {
vfree(bitmap);
return -EIO;
-@@ -141,9 +147,9 @@ int reiserfs_resize(struct super_block *
+@@ -138,9 +144,9 @@ int reiserfs_resize(struct super_block *s, unsigned long block_count_new)
set_buffer_uptodate(bh);
mark_buffer_dirty(bh);
@@ -1100,86 +1155,104 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
// update bitmap_info stuff
bitmap[i].free_count = sb_blocksize(sb) * 8 - 1;
brelse(bh);
+diff --git a/fs/reiserfs/stree.c b/fs/reiserfs/stree.c
+index 2f40a4c..4d7d476 100644
--- a/fs/reiserfs/stree.c
+++ b/fs/reiserfs/stree.c
-@@ -550,7 +550,8 @@ static bool search_by_key_reada(struct s
+@@ -524,14 +524,14 @@ static int is_tree_node(struct buffer_head *bh, int level)
+ * the caller (search_by_key) will perform other schedule-unsafe
+ * operations just after calling this function.
+ *
+- * @return true if we have unlocked
++ * @return depth of lock to be restored after read completes
+ */
+-static bool search_by_key_reada(struct super_block *s,
++static int search_by_key_reada(struct super_block *s,
+ struct buffer_head **bh,
+ b_blocknr_t *b, int num)
+ {
+ int i, j;
+- bool unlocked = false;
++ int depth = -1;
+
+ for (i = 0; i < num; i++) {
+ bh[i] = sb_getblk(s, b[i]);
+@@ -549,15 +549,13 @@ static bool search_by_key_reada(struct super_block *s,
+ * you have to make sure the prepared bit isn't set on this buffer
*/
if (!buffer_uptodate(bh[j])) {
- if (!unlocked) {
+- if (!unlocked) {
- reiserfs_write_unlock(s);
-+ int depth = -1; /* avoiding __must_check */
+- unlocked = true;
+- }
++ if (depth == -1)
+ depth = reiserfs_write_unlock_nested(s);
- unlocked = true;
- }
ll_rw_block(READA, 1, bh + j);
-@@ -625,7 +626,7 @@ int search_by_key(struct super_block *sb
- block_number = SB_ROOT_BLOCK(sb);
- expected_level = -1;
- while (1) {
--
-+ int depth;
- #ifdef CONFIG_REISERFS_CHECK
- if (!(++repeat_counter % 50000))
- reiserfs_warning(sb, "PAP-5100",
-@@ -646,25 +647,29 @@ int search_by_key(struct super_block *sb
+ }
+ brelse(bh[j]);
+ }
+- return unlocked;
++ return depth;
+ }
+
+ /**************************************************************************
+@@ -645,26 +643,26 @@ int search_by_key(struct super_block *sb, const struct cpu_key *key, /* Key to s
+ have a pointer to it. */
if ((bh = last_element->pe_buffer =
sb_getblk(sb, block_number))) {
- bool unlocked = false;
--
-+ depth = REISERFS_SB(sb)->lock_depth;
- if (!buffer_uptodate(bh) && reada_count > 1)
- /* may unlock the write lock */
- unlocked = search_by_key_reada(sb, reada_bh,
- reada_blocks, reada_count);
-+
+- bool unlocked = false;
+
+- if (!buffer_uptodate(bh) && reada_count > 1)
+- /* may unlock the write lock */
+- unlocked = search_by_key_reada(sb, reada_bh,
+- reada_blocks, reada_count);
/*
- * If we haven't already unlocked the write lock,
- * then we need to do that here before reading
- * the current block
+- * If we haven't already unlocked the write lock,
+- * then we need to do that here before reading
+- * the current block
++ * We'll need to drop the lock if we encounter any
++ * buffers that need to be read. If all of them are
++ * already up to date, we don't need to drop the lock.
*/
- if (!buffer_uptodate(bh) && !unlocked) {
+- if (!buffer_uptodate(bh) && !unlocked) {
- reiserfs_write_unlock(sb);
+- unlocked = true;
+- }
++ int depth = -1;
++
++ if (!buffer_uptodate(bh) && reada_count > 1)
++ depth = search_by_key_reada(sb, reada_bh,
++ reada_blocks, reada_count);
++
++ if (!buffer_uptodate(bh) && depth == -1)
+ depth = reiserfs_write_unlock_nested(sb);
-+ unlocked = true;
-+ } else if (!unlocked) { /* debug */
-+ depth = reiserfs_write_unlock_nested(sb);
- unlocked = true;
- }
++
ll_rw_block(READ, 1, &bh);
wait_on_buffer(bh);
- if (unlocked)
+- if (unlocked)
- reiserfs_write_lock(sb);
++ if (depth != -1)
+ reiserfs_write_lock_nested(sb, depth);
if (!buffer_uptodate(bh))
goto io_error;
} else {
-@@ -991,6 +996,7 @@ static char prepare_for_delete_or_cut(st
- struct super_block *sb = inode->i_sb;
- struct item_head *p_le_ih = PATH_PITEM_HEAD(path);
- struct buffer_head *bh = PATH_PLAST_BUFFER(path);
-+ int depth;
-
- BUG_ON(!th->t_trans_id);
-
-@@ -1059,9 +1065,11 @@ static char prepare_for_delete_or_cut(st
+@@ -1059,9 +1057,7 @@ static char prepare_for_delete_or_cut(struct reiserfs_transaction_handle *th, st
reiserfs_free_block(th, inode, block, 1);
}
- reiserfs_write_unlock(sb);
- cond_resched();
- reiserfs_write_lock(sb);
-+ if (need_resched()) {
-+ depth = reiserfs_write_unlock_nested(sb);
-+ cond_resched();
-+ reiserfs_write_lock_nested(sb, depth);
-+ }
++ reiserfs_cond_resched(sb);
if (item_moved (&s_ih, path)) {
need_re_search = 1;
+diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
+index 7e81d97..60d0932 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
-@@ -589,7 +589,6 @@ static void reiserfs_dirty_inode(struct
+@@ -624,7 +624,6 @@ static void reiserfs_dirty_inode(struct inode *inode, int flags)
struct reiserfs_transaction_handle th;
int err = 0;
@@ -1187,7 +1260,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
if (inode->i_sb->s_flags & MS_RDONLY) {
reiserfs_warning(inode->i_sb, "clm-6006",
-@@ -597,7 +596,7 @@ static void reiserfs_dirty_inode(struct
+@@ -632,7 +631,7 @@ static void reiserfs_dirty_inode(struct inode *inode, int flags)
inode->i_ino);
return;
}
@@ -1196,7 +1269,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
/* this is really only used for atime updates, so they don't have
** to be included in O_SYNC or fsync
-@@ -610,7 +609,7 @@ static void reiserfs_dirty_inode(struct
+@@ -645,7 +644,7 @@ static void reiserfs_dirty_inode(struct inode *inode, int flags)
journal_end(&th, inode->i_sb, 1);
out:
@@ -1205,117 +1278,4 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
}
static int reiserfs_show_options(struct seq_file *seq, struct dentry *root)
---- a/fs/reiserfs/reiserfs.h
-+++ b/fs/reiserfs/reiserfs.h
-@@ -58,8 +58,8 @@
- */
- void reiserfs_write_lock(struct super_block *s);
- void reiserfs_write_unlock(struct super_block *s);
--int reiserfs_write_lock_once(struct super_block *s);
--void reiserfs_write_unlock_once(struct super_block *s, int lock_depth);
-+int __must_check reiserfs_write_unlock_nested(struct super_block *s);
-+void reiserfs_write_lock_nested(struct super_block *s, int depth);
-
- #ifdef CONFIG_REISERFS_CHECK
- void reiserfs_lock_check_recursive(struct super_block *s);
-@@ -94,45 +94,54 @@ static inline void reiserfs_lock_check_r
- * - The journal lock
- * - The inode mutex
- */
--static inline void reiserfs_mutex_lock_safe(struct mutex *m,
-- struct super_block *s)
-+
-+#define reiserfs_safe(sb, action) \
-+do { \
-+ struct super_block *__sb = (sb); \
-+ int __depth; \
-+ __depth = reiserfs_write_unlock_nested(__sb); \
-+ (action); \
-+ reiserfs_write_lock_nested(__sb, __depth); \
-+} while(0)
-+
-+#define reiserfs_mutex_lock_safe(mtx, s) reiserfs_safe(s, mutex_lock(mtx))
-+#define reiserfs_mutex_lock_nested_safe(mtx, subclass, s) \
-+ reiserfs_safe(s, mutex_lock_nested(mtx, subclass))
-+#define reiserfs_down_read_safe(sem, s) reiserfs_safe(s, down_read(sem))
-+
-+/*
-+ * When we schedule, we usually want to also release the write lock,
-+ * according to the previous bkl based locking scheme of reiserfs.
-+ */
-+static inline void reiserfs_cond_resched(struct super_block *s)
- {
-- reiserfs_lock_check_recursive(s);
-- reiserfs_write_unlock(s);
-- mutex_lock(m);
-- reiserfs_write_lock(s);
-+ if (need_resched())
-+ reiserfs_safe(s, schedule());
- }
-
--static inline void
--reiserfs_mutex_lock_nested_safe(struct mutex *m, unsigned int subclass,
-- struct super_block *s)
-+static inline struct buffer_head *
-+reiserfs_safe_sb_bread(struct super_block *s, sector_t block)
- {
-- reiserfs_lock_check_recursive(s);
-- reiserfs_write_unlock(s);
-- mutex_lock_nested(m, subclass);
-- reiserfs_write_lock(s);
-+ int depth;
-+ struct buffer_head *bh;
-+
-+ depth = reiserfs_write_unlock_nested(s);
-+ bh = sb_bread(s, block);
-+ reiserfs_write_lock_nested(s, depth);
-+
-+ return bh;
- }
-
-+void reiserfs_safe_lock_buffer(struct buffer_head *bh);
-+
- static inline void
--reiserfs_down_read_safe(struct rw_semaphore *sem, struct super_block *s)
-+reiserfs_safe_wait_on_buffer(struct buffer_head *bh, struct super_block *s)
- {
-- reiserfs_lock_check_recursive(s);
-- reiserfs_write_unlock(s);
-- down_read(sem);
-- reiserfs_write_lock(s);
--}
-+ int depth;
-
--/*
-- * When we schedule, we usually want to also release the write lock,
-- * according to the previous bkl based locking scheme of reiserfs.
-- */
--static inline void reiserfs_cond_resched(struct super_block *s)
--{
-- if (need_resched()) {
-- reiserfs_write_unlock(s);
-- schedule();
-- reiserfs_write_lock(s);
-- }
-+ depth = reiserfs_write_unlock_nested(s);
-+ __wait_on_buffer(bh);
-+ reiserfs_write_lock_nested(s, depth);
- }
-
- struct fid;
-@@ -1889,6 +1898,15 @@ int reiserfs_commit_for_inode(struct ino
- int reiserfs_inode_needs_commit(struct inode *);
- void reiserfs_update_inode_transaction(struct inode *);
- void reiserfs_wait_on_write_block(struct super_block *s);
-+static inline void reiserfs_safe_wait_on_write_block(struct super_block *s)
-+{
-+ int depth;
-+
-+ depth = reiserfs_write_unlock_nested(s);
-+ reiserfs_wait_on_write_block(s);
-+ reiserfs_write_lock_nested(s, depth);
-+}
-+
- void reiserfs_block_writes(struct reiserfs_transaction_handle *th);
- void reiserfs_allow_writes(struct super_block *s);
- void reiserfs_check_lock_depth(struct super_block *s, char *caller);
+
diff --git a/patches.fixes/reiserfs-locking-push-write-lock-out-of-xattr-code b/patches.fixes/reiserfs-locking-push-write-lock-out-of-xattr-code
index b1e8990937..803db663f5 100644
--- a/patches.fixes/reiserfs-locking-push-write-lock-out-of-xattr-code
+++ b/patches.fixes/reiserfs-locking-push-write-lock-out-of-xattr-code
@@ -1,7 +1,9 @@
+From 4c05141df57f4ffc1a9a28f1925434924179bfe4 Mon Sep 17 00:00:00 2001
From: Jeff Mahoney <jeffm@suse.com>
+Date: Thu, 8 Aug 2013 17:27:19 -0400
Subject: reiserfs: locking, push write lock out of xattr code
-References: bnc#815320
-Patch-mainline: Posted to reiserfs-devel, 5 Aug 2013
+Git-commit: 4c05141df57f4ffc1a9a28f1925434924179bfe4
+Patch-mainline: v3.12-rc1
The reiserfs xattr code doesn't need the write lock and sleeps all over
the place. We can simplify the locking by releasing it and reacquiring
@@ -9,15 +11,17 @@ after the xattr call.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
- fs/reiserfs/inode.c | 37 ++++++++++++++++++++-----------------
- fs/reiserfs/super.c | 48 +++++++++++++++++++++++-------------------------
- fs/reiserfs/xattr.c | 46 +++++++++++++++++-----------------------------
- fs/reiserfs/xattr_acl.c | 16 ++++++++++------
- 4 files changed, 70 insertions(+), 77 deletions(-)
+ fs/reiserfs/inode.c | 38 ++++++++++++++++++++------------------
+ fs/reiserfs/super.c | 48 +++++++++++++++++++++++-------------------------
+ fs/reiserfs/xattr.c | 46 +++++++++++++++++-----------------------------
+ fs/reiserfs/xattr_acl.c | 16 ++++++++++------
+ 4 files changed, 70 insertions(+), 78 deletions(-)
---- a/fs/reiserfs/inode.c 2013-08-05 16:38:38.375484134 -0400
-+++ b/fs/reiserfs/inode.c 2013-08-05 16:39:43.523480861 -0400
-@@ -29,7 +29,6 @@ void reiserfs_evict_inode(struct inode *
+diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
+index 0048cc1..bf1331a 100644
+--- a/fs/reiserfs/inode.c
++++ b/fs/reiserfs/inode.c
+@@ -30,7 +30,6 @@ void reiserfs_evict_inode(struct inode *inode)
JOURNAL_PER_BALANCE_CNT * 2 +
2 * REISERFS_QUOTA_INIT_BLOCKS(inode->i_sb);
struct reiserfs_transaction_handle th;
@@ -25,7 +29,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
int err;
if (!inode->i_nlink && !is_bad_inode(inode))
-@@ -39,12 +38,14 @@ void reiserfs_evict_inode(struct inode *
+@@ -40,12 +39,14 @@ void reiserfs_evict_inode(struct inode *inode)
if (inode->i_nlink)
goto no_delete;
@@ -42,7 +46,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
if (journal_begin(&th, inode->i_sb, jbegin_count))
goto out;
reiserfs_update_inode_transaction(inode);
-@@ -71,12 +72,12 @@ void reiserfs_evict_inode(struct inode *
+@@ -72,12 +73,12 @@ void reiserfs_evict_inode(struct inode *inode)
/* all items of file are deleted, so we can remove "save" link */
remove_save_link(inode, 0 /* not truncate */ ); /* we can't do anything
* about an error here */
@@ -57,7 +61,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
clear_inode(inode); /* note this must go after the journal_end to prevent deadlock */
dquot_drop(inode);
inode->i_blocks = 0;
-@@ -1946,7 +1947,9 @@ int reiserfs_new_inode(struct reiserfs_t
+@@ -1941,7 +1942,9 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
}
if (reiserfs_posixacl(inode->i_sb)) {
@@ -67,7 +71,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
if (retval) {
err = retval;
reiserfs_check_path(&path_to_key);
-@@ -1961,7 +1964,9 @@ int reiserfs_new_inode(struct reiserfs_t
+@@ -1956,7 +1959,9 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
inode->i_flags |= S_PRIVATE;
if (security->name) {
@@ -77,7 +81,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
if (retval) {
err = retval;
reiserfs_check_path(&path_to_key);
-@@ -3126,6 +3131,7 @@ int reiserfs_setattr(struct dentry *dent
+@@ -3129,6 +3134,7 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
*/
if (get_inode_item_key_version(inode) == KEY_FORMAT_3_5 &&
attr->ia_size > MAX_NON_LFS) {
@@ -85,7 +89,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
error = -EFBIG;
goto out;
}
-@@ -3147,8 +3153,10 @@ int reiserfs_setattr(struct dentry *dent
+@@ -3150,8 +3156,10 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
if (err)
error = err;
}
@@ -97,7 +101,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
/*
* file size is changed, ctime and mtime are
* to be updated
-@@ -3156,10 +3164,12 @@ int reiserfs_setattr(struct dentry *dent
+@@ -3159,6 +3167,7 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
attr->ia_valid |= (ATTR_MTIME | ATTR_CTIME);
}
}
@@ -105,12 +109,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
if ((((attr->ia_valid & ATTR_UID) && (from_kuid(&init_user_ns, attr->ia_uid) & ~0xffff)) ||
((attr->ia_valid & ATTR_GID) && (from_kgid(&init_user_ns, attr->ia_gid) & ~0xffff))) &&
- (get_inode_sd_version(inode) == STAT_DATA_V1)) {
-+ reiserfs_write_unlock_once(inode->i_sb, depth);
- /* stat data of format v3.5 has 16 bit uid and gid */
- error = -EINVAL;
- goto out;
-@@ -3180,14 +3190,16 @@ int reiserfs_setattr(struct dentry *dent
+@@ -3183,14 +3192,16 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
return error;
/* (user+group)*(old+new) structure - we count quota info and , inode write (sb, inode) */
@@ -128,7 +127,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
goto out;
}
-@@ -3199,17 +3211,11 @@ int reiserfs_setattr(struct dentry *dent
+@@ -3202,17 +3213,11 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
inode->i_gid = attr->ia_gid;
mark_inode_dirty(inode);
error = journal_end(&th, inode->i_sb, jbegin_count);
@@ -147,7 +146,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
if ((attr->ia_valid & ATTR_SIZE) &&
attr->ia_size != i_size_read(inode)) {
error = inode_newsize_ok(inode, attr->ia_size);
-@@ -3218,7 +3224,6 @@ int reiserfs_setattr(struct dentry *dent
+@@ -3226,16 +3231,13 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
setattr_copy(inode, attr);
mark_inode_dirty(inode);
}
@@ -155,18 +154,21 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
if (!error && reiserfs_posixacl(inode->i_sb)) {
if (attr->ia_valid & ATTR_MODE)
-@@ -3226,8 +3231,6 @@ int reiserfs_setattr(struct dentry *dent
+ error = reiserfs_acl_chmod(inode);
}
- out:
+- out:
- reiserfs_write_unlock_once(inode->i_sb, depth);
-
++out:
return error;
}
---- a/fs/reiserfs/super.c 2013-08-05 16:38:36.103484249 -0400
-+++ b/fs/reiserfs/super.c 2013-08-05 16:39:43.527480860 -0400
-@@ -1294,7 +1294,7 @@ static int reiserfs_remount(struct super
+diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
+index f8a23c3..7e81d97 100644
+--- a/fs/reiserfs/super.c
++++ b/fs/reiserfs/super.c
+@@ -1335,7 +1335,7 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
kfree(qf_names[i]);
#endif
err = -EINVAL;
@@ -175,7 +177,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
}
#ifdef CONFIG_QUOTA
handle_quota_files(s, qf_names, &qfmt);
-@@ -1338,35 +1338,32 @@ static int reiserfs_remount(struct super
+@@ -1379,35 +1379,32 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
if (blocks) {
err = reiserfs_resize(s, blocks);
if (err != 0)
@@ -218,7 +220,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
/* Mounting a rw partition read-only. */
reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1);
-@@ -1375,13 +1372,14 @@ static int reiserfs_remount(struct super
+@@ -1416,13 +1413,14 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
} else {
/* remount read-write */
if (!(s->s_flags & MS_RDONLY)) {
@@ -235,7 +237,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
}
handle_data_mode(s, mount_options);
-@@ -1390,7 +1388,7 @@ static int reiserfs_remount(struct super
+@@ -1431,7 +1429,7 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
s->s_flags &= ~MS_RDONLY; /* now it is safe to call journal_begin */
err = journal_begin(&th, s, 10);
if (err)
@@ -244,7 +246,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
/* Mount a partition which is read-only, read-write */
reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1);
-@@ -1407,26 +1405,22 @@ static int reiserfs_remount(struct super
+@@ -1448,26 +1446,22 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
SB_JOURNAL(s)->j_must_wait = 1;
err = journal_end(&th, s, 10);
if (err)
@@ -276,7 +278,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
reiserfs_write_unlock(s);
out_err:
kfree(new_opts);
-@@ -1972,12 +1966,14 @@ static int reiserfs_fill_super(struct su
+@@ -2014,12 +2008,14 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
goto error;
}
@@ -292,7 +294,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
/* look for files which were to be removed in previous session */
finish_unfinished(s);
-@@ -1986,12 +1982,14 @@ static int reiserfs_fill_super(struct su
+@@ -2028,12 +2024,14 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
reiserfs_info(s, "using 3.5.x disk format\n");
}
@@ -308,9 +310,11 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
}
// mark hash in super block: it could be unset. overwrite should be ok
set_sb_hash_function_code(rs, function2code(sbi->s_hash_function));
---- a/fs/reiserfs/xattr.c 2013-08-05 16:38:38.375484134 -0400
-+++ b/fs/reiserfs/xattr.c 2013-08-05 16:39:43.531480860 -0400
-@@ -81,8 +81,7 @@ static int xattr_unlink(struct inode *di
+diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c
+index c69cdd7..8a9e2dc 100644
+--- a/fs/reiserfs/xattr.c
++++ b/fs/reiserfs/xattr.c
+@@ -81,8 +81,7 @@ static int xattr_unlink(struct inode *dir, struct dentry *dentry)
int error;
BUG_ON(!mutex_is_locked(&dir->i_mutex));
@@ -320,7 +324,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
error = dir->i_op->unlink(dir, dentry);
mutex_unlock(&dentry->d_inode->i_mutex);
-@@ -96,8 +95,7 @@ static int xattr_rmdir(struct inode *dir
+@@ -96,8 +95,7 @@ static int xattr_rmdir(struct inode *dir, struct dentry *dentry)
int error;
BUG_ON(!mutex_is_locked(&dir->i_mutex));
@@ -330,7 +334,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
error = dir->i_op->rmdir(dir, dentry);
if (!error)
dentry->d_inode->i_flags |= S_DEAD;
-@@ -232,22 +230,17 @@ static int reiserfs_for_each_xattr(struc
+@@ -232,22 +230,17 @@ static int reiserfs_for_each_xattr(struct inode *inode,
if (IS_PRIVATE(inode) || get_inode_sd_version(inode) == STAT_DATA_V1)
return 0;
@@ -353,7 +357,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
buf.xadir = dir;
while (1) {
err = reiserfs_readdir_inode(dir->d_inode, &buf.ctx);
-@@ -283,14 +276,17 @@ static int reiserfs_for_each_xattr(struc
+@@ -281,14 +274,17 @@ static int reiserfs_for_each_xattr(struct inode *inode,
int blocks = JOURNAL_PER_BALANCE_CNT * 2 + 2 +
4 * REISERFS_QUOTA_TRANS_BLOCKS(inode->i_sb);
struct reiserfs_transaction_handle th;
@@ -374,7 +378,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
mutex_unlock(&dir->d_parent->d_inode->i_mutex);
err = jerror ?: err;
}
-@@ -457,9 +453,7 @@ static int lookup_and_delete_xattr(struc
+@@ -455,9 +451,7 @@ static int lookup_and_delete_xattr(struct inode *inode, const char *name)
}
if (dentry->d_inode) {
@@ -384,7 +388,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
update_ctime(inode);
}
-@@ -493,24 +487,17 @@ reiserfs_xattr_set_handle(struct reiserf
+@@ -491,24 +485,17 @@ reiserfs_xattr_set_handle(struct reiserfs_transaction_handle *th,
if (get_inode_sd_version(inode) == STAT_DATA_V1)
return -EOPNOTSUPP;
@@ -410,7 +414,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
xahash = xattr_hash(buffer, buffer_size);
while (buffer_pos < buffer_size || buffer_pos == 0) {
size_t chunk;
-@@ -540,6 +527,7 @@ reiserfs_xattr_set_handle(struct reiserf
+@@ -538,6 +525,7 @@ reiserfs_xattr_set_handle(struct reiserfs_transaction_handle *th,
rxh->h_hash = cpu_to_le32(xahash);
}
@@ -418,7 +422,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
err = __reiserfs_write_begin(page, page_offset, chunk + skip);
if (!err) {
if (buffer)
-@@ -548,6 +536,7 @@ reiserfs_xattr_set_handle(struct reiserf
+@@ -546,6 +534,7 @@ reiserfs_xattr_set_handle(struct reiserfs_transaction_handle *th,
page_offset + chunk +
skip);
}
@@ -426,7 +430,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
unlock_page(page);
reiserfs_put_page(page);
buffer_pos += chunk;
-@@ -565,10 +554,8 @@ reiserfs_xattr_set_handle(struct reiserf
+@@ -563,10 +552,8 @@ reiserfs_xattr_set_handle(struct reiserfs_transaction_handle *th,
.ia_valid = ATTR_SIZE | ATTR_CTIME,
};
@@ -437,7 +441,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
err = reiserfs_setattr(dentry, &newattrs);
mutex_unlock(&dentry->d_inode->i_mutex);
-@@ -594,18 +581,19 @@ int reiserfs_xattr_set(struct inode *ino
+@@ -592,18 +579,19 @@ int reiserfs_xattr_set(struct inode *inode, const char *name,
reiserfs_write_lock(inode->i_sb);
error = journal_begin(&th, inode->i_sb, jbegin_count);
@@ -459,7 +463,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
return error;
}
-@@ -969,7 +957,7 @@ int reiserfs_lookup_privroot(struct supe
+@@ -968,7 +956,7 @@ int reiserfs_lookup_privroot(struct super_block *s)
int err = 0;
/* If we don't have the privroot located yet - go find it */
@@ -468,7 +472,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
dentry = lookup_one_len(PRIVROOT_NAME, s->s_root,
strlen(PRIVROOT_NAME));
if (!IS_ERR(dentry)) {
-@@ -997,14 +985,14 @@ int reiserfs_xattr_init(struct super_blo
+@@ -996,14 +984,14 @@ int reiserfs_xattr_init(struct super_block *s, int mount_flags)
goto error;
if (!privroot->d_inode && !(mount_flags & MS_RDONLY)) {
@@ -485,9 +489,11 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
if (!REISERFS_SB(s)->xattr_root) {
struct dentry *dentry;
dentry = lookup_one_len(XAROOT_NAME, privroot,
---- a/fs/reiserfs/xattr_acl.c 2013-08-05 16:38:38.375484134 -0400
-+++ b/fs/reiserfs/xattr_acl.c 2013-08-05 16:39:50.279480518 -0400
-@@ -49,13 +49,15 @@ posix_acl_set(struct dentry *dentry, con
+diff --git a/fs/reiserfs/xattr_acl.c b/fs/reiserfs/xattr_acl.c
+index 6c8767f..06c04f7 100644
+--- a/fs/reiserfs/xattr_acl.c
++++ b/fs/reiserfs/xattr_acl.c
+@@ -49,13 +49,15 @@ posix_acl_set(struct dentry *dentry, const char *name, const void *value,
reiserfs_write_lock(inode->i_sb);
error = journal_begin(&th, inode->i_sb, jcreate_blocks);
@@ -504,7 +510,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
release_and_out:
posix_acl_release(acl);
-@@ -421,12 +423,14 @@ int reiserfs_cache_default_acl(struct in
+@@ -435,12 +437,14 @@ int reiserfs_cache_default_acl(struct inode *inode)
return nblocks;
}
@@ -520,7 +526,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
int error;
if (IS_PRIVATE(inode))
-@@ -440,9 +444,7 @@ int reiserfs_acl_chmod(struct inode *ino
+@@ -454,9 +458,7 @@ int reiserfs_acl_chmod(struct inode *inode)
return 0;
}
@@ -530,7 +536,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
if (!acl)
return 0;
if (IS_ERR(acl))
-@@ -452,16 +454,18 @@ int reiserfs_acl_chmod(struct inode *ino
+@@ -466,16 +468,18 @@ int reiserfs_acl_chmod(struct inode *inode)
return error;
size = reiserfs_xattr_nblocks(inode, reiserfs_acl_size(acl->a_count));
@@ -551,3 +557,4 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
posix_acl_release(acl);
return error;
}
+
diff --git a/patches.fixes/reiserfs-locking-release-lock-around-quota-operations b/patches.fixes/reiserfs-locking-release-lock-around-quota-operations
index 8b97d35479..fc4f399b7a 100644
--- a/patches.fixes/reiserfs-locking-release-lock-around-quota-operations
+++ b/patches.fixes/reiserfs-locking-release-lock-around-quota-operations
@@ -1,7 +1,9 @@
+From d2d0395fd1778d4bf714adc5bfd23a5d748d7802 Mon Sep 17 00:00:00 2001
From: Jeff Mahoney <jeffm@suse.com>
+Date: Thu, 8 Aug 2013 17:34:47 -0400
Subject: reiserfs: locking, release lock around quota operations
-References: bnc#815320
-Patch-mainline: Posted to reiserfs-devel, 5 Aug 2013
+Git-commit: d2d0395fd1778d4bf714adc5bfd23a5d748d7802
+Patch-mainline: v3.12-rc1
Previous commits released the write lock across quota operations but
missed several places. In particular, the free operations can also
@@ -12,25 +14,19 @@ This patch introduces some more helpers and uses them for quota call
sites. Without this patch applied, reiserfs + quotas runs into deadlocks
under anything more than trivial load.
-With this patch applied, reiserfs survives a 50-thread stress test with
-quotas enabled and a default ACL set. Without it, it deadlocks fairly
-quickly under the same load.
-
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
+ fs/reiserfs/bitmap.c | 17 +++++++++++++++--
+ fs/reiserfs/inode.c | 19 +++++++++++--------
+ fs/reiserfs/stree.c | 28 +++++++++++++++++++++++-----
+ fs/reiserfs/super.c | 22 ++++++++++++++--------
+ 4 files changed, 63 insertions(+), 23 deletions(-)
- fs/reiserfs/bitmap.c | 26 +++++++++++++++++++-------
- fs/reiserfs/inode.c | 28 ++++++++++++++++++++--------
- fs/reiserfs/lock.c | 7 +++++++
- fs/reiserfs/namei.c | 24 ++++++++++++++----------
- fs/reiserfs/stree.c | 28 +++++++++++++++++++++++-----
- fs/reiserfs/super.c | 42 ++++++++++++++++++++++++++----------------
- include/linux/reiserfs_fs.h | 44 ++++++++++----------------------------------
- 7 files changed, 119 insertions(+), 80 deletions(-)
-
+diff --git a/fs/reiserfs/bitmap.c b/fs/reiserfs/bitmap.c
+index 881f8ea..dc9a682 100644
--- a/fs/reiserfs/bitmap.c
+++ b/fs/reiserfs/bitmap.c
-@@ -424,8 +424,11 @@ static void _reiserfs_free_block(struct
+@@ -423,8 +423,11 @@ static void _reiserfs_free_block(struct reiserfs_transaction_handle *th,
set_sb_free_blocks(rs, sb_free_blocks(rs) + 1);
journal_mark_dirty(th, s, sbh);
@@ -43,7 +39,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
}
void reiserfs_free_block(struct reiserfs_transaction_handle *th,
-@@ -1039,6 +1042,7 @@ static inline int blocknrs_and_prealloc_
+@@ -1128,6 +1131,7 @@ static inline int blocknrs_and_prealloc_arrays_from_search_start
b_blocknr_t finish = SB_BLOCK_COUNT(s) - 1;
int passno = 0;
int nr_allocated = 0;
@@ -51,7 +47,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
determine_prealloc_size(hint);
if (!hint->formatted_node) {
-@@ -1048,10 +1052,13 @@ static inline int blocknrs_and_prealloc_
+@@ -1137,10 +1141,13 @@ static inline int blocknrs_and_prealloc_arrays_from_search_start
"reiserquota: allocating %d blocks id=%u",
amount_needed, hint->inode->i_uid);
#endif
@@ -66,7 +62,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
if (hint->preallocate && hint->prealloc_size) {
#ifdef REISERQUOTA_DEBUG
reiserfs_debug(s, REISERFS_DEBUG_CODE,
-@@ -1064,6 +1071,7 @@ static inline int blocknrs_and_prealloc_
+@@ -1153,6 +1160,7 @@ static inline int blocknrs_and_prealloc_arrays_from_search_start
hint->preallocate = hint->prealloc_size = 0;
}
/* for unformatted nodes, force large allocations */
@@ -74,114 +70,80 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
}
do {
-@@ -1092,9 +1100,12 @@ static inline int blocknrs_and_prealloc_
+@@ -1181,9 +1189,11 @@ static inline int blocknrs_and_prealloc_arrays_from_search_start
hint->inode->i_uid);
#endif
/* Free not allocated blocks */
-- dquot_free_block_nodirty(hint->inode,
+ depth = reiserfs_write_unlock_nested(s);
-+ dquot_free_block_nodirty(
-+ hint->inode,
+ dquot_free_block_nodirty(hint->inode,
amount_needed + hint->prealloc_size -
nr_allocated);
+ reiserfs_write_lock_nested(s, depth);
}
while (nr_allocated--)
reiserfs_free_block(hint->th, hint->inode,
-@@ -1125,10 +1136,11 @@ static inline int blocknrs_and_prealloc_
+@@ -1214,10 +1224,13 @@ static inline int blocknrs_and_prealloc_arrays_from_search_start
REISERFS_I(hint->inode)->i_prealloc_count,
hint->inode->i_uid);
#endif
-- dquot_free_block_nodirty(hint->inode, amount_needed +
-- hint->prealloc_size - nr_allocated -
-- REISERFS_I(hint->inode)->
-- i_prealloc_count);
++
+ depth = reiserfs_write_unlock_nested(s);
-+ dquot_free_block_nodirty(hint->inode,
-+ amount_needed + hint->prealloc_size - nr_allocated -
-+ REISERFS_I(hint->inode)->i_prealloc_count);
+ dquot_free_block_nodirty(hint->inode, amount_needed +
+ hint->prealloc_size - nr_allocated -
+ REISERFS_I(hint->inode)->
+ i_prealloc_count);
+ reiserfs_write_lock_nested(s, depth);
}
return CARRY_ON;
+diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
+index 4a3a57c..ad62bdb 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
-@@ -24,6 +24,7 @@ int reiserfs_commit_write(struct file *f
-
- void reiserfs_evict_inode(struct inode *inode)
- {
-+ struct super_block *sb = inode->i_sb;
- /* We need blocks for transaction + (user+group) quota update (possibly delete) */
- int jbegin_count =
- JOURNAL_PER_BALANCE_CNT * 2 +
-@@ -56,8 +57,11 @@ void reiserfs_evict_inode(struct inode *
+@@ -57,8 +57,11 @@ void reiserfs_evict_inode(struct inode *inode)
/* Do quota update inside a transaction for journaled quotas. We must do that
* after delete_object so that quota updates go into the same transaction as
* stat data deletion */
- if (!err)
+ if (!err) {
-+ int depth = reiserfs_write_unlock_nested(sb);
++ int depth = reiserfs_write_unlock_nested(inode->i_sb);
dquot_free_inode(inode);
-+ reiserfs_write_lock_nested(sb, depth);
++ reiserfs_write_lock_nested(inode->i_sb, depth);
+ }
if (journal_end(&th, inode->i_sb, jbegin_count))
goto out;
-@@ -1517,7 +1521,10 @@ struct inode *reiserfs_iget(struct super
-
- if (comp_short_keys(INODE_PKEY(inode), key) || is_bad_inode(inode)) {
- /* either due to i/o error or a stale NFS handle */
-+ int depth;
-+ depth = reiserfs_write_unlock_nested(s);
- iput(inode);
-+ reiserfs_write_lock_nested(s, depth);
- inode = NULL;
- }
- return inode;
-@@ -1534,12 +1541,12 @@ static struct dentry *reiserfs_get_dentr
- key.on_disk_key.k_dir_id = dir_id;
- reiserfs_write_lock(sb);
- inode = reiserfs_iget(sb, &key);
-+ reiserfs_write_unlock(sb);
- if (inode && !IS_ERR(inode) && generation != 0 &&
- generation != inode->i_generation) {
- iput(inode);
- inode = NULL;
- }
-- reiserfs_write_unlock(sb);
-
- return d_obtain_alias(inode);
- }
-@@ -1778,11 +1785,13 @@ int reiserfs_new_inode(struct reiserfs_t
- int err;
- int depth;
+@@ -1768,7 +1771,7 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
+ struct inode *inode,
+ struct reiserfs_security_handle *security)
+ {
+- struct super_block *sb;
++ struct super_block *sb = dir->i_sb;
+ struct reiserfs_iget_args args;
+ INITIALIZE_PATH(path_to_key);
+ struct cpu_key key;
+@@ -1780,9 +1783,9 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
-+ reiserfs_check_lock_nested(dir->i_sb, __func__);
-+
BUG_ON(!th->t_trans_id);
- reiserfs_write_unlock(inode->i_sb);
-+ depth = reiserfs_write_unlock_nested(dir->i_sb);
++ depth = reiserfs_write_unlock_nested(sb);
err = dquot_alloc_inode(inode);
- reiserfs_write_lock(inode->i_sb);
-+ reiserfs_write_lock_nested(dir->i_sb, depth);
++ reiserfs_write_lock_nested(sb, depth);
if (err)
goto out_end_trans;
if (!dir->i_nlink) {
-@@ -1809,10 +1818,10 @@ int reiserfs_new_inode(struct reiserfs_t
- memcpy(INODE_PKEY(inode), &(ih.ih_key), KEY_SIZE);
- args.dirid = le32_to_cpu(ih.ih_key.k_dir_id);
-
-- depth = reiserfs_write_unlock_nested(inode->i_sb);
-+ reiserfs_write_unlock(inode->i_sb);
- err = insert_inode_locked4(inode, args.objectid,
- reiserfs_find_actor, &args);
-- reiserfs_write_lock_nested(inode->i_sb, depth);
-+ reiserfs_write_lock(inode->i_sb);
- if (err) {
- err = -EINVAL;
+@@ -1790,8 +1793,6 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
goto out_bad_inode;
-@@ -1983,14 +1992,16 @@ int reiserfs_new_inode(struct reiserfs_t
+ }
+
+- sb = dir->i_sb;
+-
+ /* item head of new item */
+ ih.ih_key.k_dir_id = reiserfs_choose_packing(dir);
+ ih.ih_key.k_objectid = cpu_to_le32(reiserfs_get_unused_objectid(th));
+@@ -1983,14 +1984,16 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
INODE_PKEY(inode)->k_objectid = 0;
/* Quota change must be inside a transaction for journaling */
@@ -200,106 +162,11 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
inode->i_flags |= S_NOQUOTA;
make_bad_inode(inode);
-@@ -1998,6 +2009,7 @@ int reiserfs_new_inode(struct reiserfs_t
- clear_nlink(inode);
- th->t_trans_id = 0; /* so the caller can't use this handle later */
- unlock_new_inode(inode); /* OK to do even if we hadn't locked it */
-+ reiserfs_write_unlock(inode->i_sb);
- iput(inode);
- return err;
- }
---- a/fs/reiserfs/lock.c
-+++ b/fs/reiserfs/lock.c
-@@ -111,6 +111,13 @@ void reiserfs_check_lock_depth(struct su
- WARN_ON(sb_i->lock_depth < 0);
- }
-
-+void reiserfs_check_lock_nested(struct super_block *sb, const char *caller)
-+{
-+ struct reiserfs_sb_info *sb_i = REISERFS_SB(sb);
-+
-+ WARN_ON(sb_i->lock_depth > 0);
-+}
-+
- #ifdef CONFIG_REISERFS_CHECK
- void reiserfs_lock_check_recursive(struct super_block *sb)
- {
---- a/fs/reiserfs/namei.c
-+++ b/fs/reiserfs/namei.c
-@@ -604,8 +604,9 @@ static int reiserfs_create(struct inode
- retval =
- reiserfs_new_inode(&th, dir, mode, NULL, 0 /*i_size */ , dentry,
- inode, &security);
-+ /* inode is dropped and write lock is released */
- if (retval)
-- goto out_failed;
-+ return retval;
-
- inode->i_op = &reiserfs_file_inode_operations;
- inode->i_fop = &reiserfs_file_operations;
-@@ -678,9 +679,9 @@ static int reiserfs_mknod(struct inode *
- retval =
- reiserfs_new_inode(&th, dir, mode, NULL, 0 /*i_size */ , dentry,
- inode, &security);
-- if (retval) {
-- goto out_failed;
-- }
-+ /* inode is dropped and write lock is released */
-+ if (retval)
-+ return retval;
-
- inode->i_op = &reiserfs_special_inode_operations;
- init_special_inode(inode, inode->i_mode, rdev);
-@@ -763,9 +764,10 @@ static int reiserfs_mkdir(struct inode *
- old_format_only(dir->i_sb) ?
- EMPTY_DIR_SIZE_V1 : EMPTY_DIR_SIZE,
- dentry, inode, &security);
-+ /* inode is dropped and write lock is released */
- if (retval) {
- DEC_DIR_INODE_NLINK(dir)
-- goto out_failed;
-+ return retval;
- }
-
- reiserfs_update_inode_transaction(inode);
-@@ -787,8 +789,9 @@ static int reiserfs_mkdir(struct inode *
- if (err)
- retval = err;
- unlock_new_inode(inode);
-+ reiserfs_write_unlock(dir->i_sb);
- iput(inode);
-- goto out_failed;
-+ return retval;
- }
- // the above add_entry did not update dir's stat data
- reiserfs_update_sd(&th, dir);
-@@ -1060,9 +1063,9 @@ static int reiserfs_symlink(struct inode
- reiserfs_new_inode(&th, parent_dir, mode, name, strlen(symname),
- dentry, inode, &security);
- kfree(name);
-- if (retval) { /* reiserfs_new_inode iputs for us */
-- goto out_failed;
-- }
-+ /* inode is dropped and write lock is released */
-+ if (retval)
-+ return retval;
-
- reiserfs_update_inode_transaction(inode);
- reiserfs_update_inode_transaction(parent_dir);
-@@ -1084,8 +1087,9 @@ static int reiserfs_symlink(struct inode
- if (err)
- retval = err;
- unlock_new_inode(inode);
-+ reiserfs_write_unlock(parent_dir->i_sb);
- iput(inode);
-- goto out_failed;
-+ return retval;
- }
-
- unlock_new_inode(inode);
+diff --git a/fs/reiserfs/stree.c b/fs/reiserfs/stree.c
+index 4d7d476..b14706a 100644
--- a/fs/reiserfs/stree.c
+++ b/fs/reiserfs/stree.c
-@@ -1198,6 +1198,7 @@ int reiserfs_delete_item(struct reiserfs
+@@ -1186,6 +1186,7 @@ int reiserfs_delete_item(struct reiserfs_transaction_handle *th,
struct item_head *q_ih;
int quota_cut_bytes;
int ret_value, del_size, removed;
@@ -307,25 +174,25 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
#ifdef CONFIG_REISERFS_CHECK
char mode;
-@@ -1307,7 +1308,9 @@ int reiserfs_delete_item(struct reiserfs
+@@ -1295,7 +1296,9 @@ int reiserfs_delete_item(struct reiserfs_transaction_handle *th,
"reiserquota delete_item(): freeing %u, id=%u type=%c",
quota_cut_bytes, inode->i_uid, head2type(&s_ih));
#endif
-+ depth = reiserfs_write_unlock_nested(sb);
++ depth = reiserfs_write_unlock_nested(inode->i_sb);
dquot_free_space_nodirty(inode, quota_cut_bytes);
-+ reiserfs_write_lock_nested(sb, depth);
++ reiserfs_write_lock_nested(inode->i_sb, depth);
/* Return deleted body length */
return ret_value;
-@@ -1340,6 +1343,7 @@ void reiserfs_delete_solid_item(struct r
- struct cpu_key cpu_key;
- int retval;
- int quota_cut_bytes = 0;
+@@ -1321,6 +1324,7 @@ int reiserfs_delete_item(struct reiserfs_transaction_handle *th,
+ void reiserfs_delete_solid_item(struct reiserfs_transaction_handle *th,
+ struct inode *inode, struct reiserfs_key *key)
+ {
+ struct super_block *sb = th->t_super;
-
- BUG_ON(!th->t_trans_id);
-
-@@ -1385,14 +1389,17 @@ void reiserfs_delete_solid_item(struct r
+ struct tree_balance tb;
+ INITIALIZE_PATH(path);
+ int item_len = 0;
+@@ -1373,14 +1377,17 @@ void reiserfs_delete_solid_item(struct reiserfs_transaction_handle *th,
if (retval == CARRY_ON) {
do_balance(&tb, NULL, NULL, M_DELETE);
if (inode) { /* Should we count quota for item? (we don't count quotas for save-links) */
@@ -343,7 +210,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
}
break;
}
-@@ -1569,6 +1576,7 @@ int reiserfs_cut_from_item(struct reiser
+@@ -1557,6 +1564,7 @@ int reiserfs_cut_from_item(struct reiserfs_transaction_handle *th,
int retval2 = -1;
int quota_cut_bytes;
loff_t tail_pos = 0;
@@ -351,7 +218,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
BUG_ON(!th->t_trans_id);
-@@ -1741,7 +1749,9 @@ int reiserfs_cut_from_item(struct reiser
+@@ -1729,7 +1737,9 @@ int reiserfs_cut_from_item(struct reiserfs_transaction_handle *th,
"reiserquota cut_from_item(): freeing %u id=%u type=%c",
quota_cut_bytes, inode->i_uid, '?');
#endif
@@ -361,7 +228,11 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
return ret_value;
}
-@@ -1964,6 +1974,7 @@ int reiserfs_paste_into_item(struct reis
+@@ -1949,9 +1959,11 @@ int reiserfs_paste_into_item(struct reiserfs_transaction_handle *th, struct tree
+ const char *body, /* Pointer to the bytes to paste. */
+ int pasted_size)
+ { /* Size of pasted bytes. */
++ struct super_block *sb = inode->i_sb;
struct tree_balance s_paste_balance;
int retval;
int fs_gen;
@@ -369,78 +240,75 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
BUG_ON(!th->t_trans_id);
-@@ -1976,9 +1987,9 @@ int reiserfs_paste_into_item(struct reis
+@@ -1964,9 +1976,9 @@ int reiserfs_paste_into_item(struct reiserfs_transaction_handle *th, struct tree
key2type(&(key->on_disk_key)));
#endif
- reiserfs_write_unlock(inode->i_sb);
-+ depth = reiserfs_write_unlock_nested(inode->i_sb);
++ depth = reiserfs_write_unlock_nested(sb);
retval = dquot_alloc_space_nodirty(inode, pasted_size);
- reiserfs_write_lock(inode->i_sb);
-+ reiserfs_write_lock_nested(inode->i_sb, depth);
++ reiserfs_write_lock_nested(sb, depth);
if (retval) {
pathrelse(search_path);
return retval;
-@@ -2035,7 +2046,9 @@ int reiserfs_paste_into_item(struct reis
+@@ -2023,7 +2035,9 @@ int reiserfs_paste_into_item(struct reiserfs_transaction_handle *th, struct tree
pasted_size, inode->i_uid,
key2type(&(key->on_disk_key)));
#endif
-+ depth = reiserfs_write_unlock_nested(inode->i_sb);
++ depth = reiserfs_write_unlock_nested(sb);
dquot_free_space_nodirty(inode, pasted_size);
-+ reiserfs_write_lock_nested(inode->i_sb, depth);
++ reiserfs_write_lock_nested(sb, depth);
return retval;
}
-@@ -2050,10 +2063,12 @@ int reiserfs_insert_item(struct reiserfs
- struct item_head *ih, struct inode *inode,
- const char *body)
- {
-+ struct super_block *sb = th->t_super;
- struct tree_balance s_ins_balance;
- int retval;
- int fs_gen = 0;
- int quota_bytes = 0;
-+ int depth;
-
+@@ -2046,6 +2060,7 @@ int reiserfs_insert_item(struct reiserfs_transaction_handle *th,
BUG_ON(!th->t_trans_id);
-@@ -2071,11 +2086,11 @@ int reiserfs_insert_item(struct reiserfs
+ if (inode) { /* Do we count quotas for item? */
++ int depth;
+ fs_gen = get_generation(inode->i_sb);
+ quota_bytes = ih_item_len(ih);
+
+@@ -2059,11 +2074,11 @@ int reiserfs_insert_item(struct reiserfs_transaction_handle *th,
"reiserquota insert_item(): allocating %u id=%u type=%c",
quota_bytes, inode->i_uid, head2type(ih));
#endif
- reiserfs_write_unlock(inode->i_sb);
/* We can't dirty inode here. It would be immediately written but
* appropriate stat item isn't inserted yet... */
-+ depth = reiserfs_write_unlock_nested(sb);
++ depth = reiserfs_write_unlock_nested(inode->i_sb);
retval = dquot_alloc_space_nodirty(inode, quota_bytes);
- reiserfs_write_lock(inode->i_sb);
-+ reiserfs_write_lock_nested(sb, depth);
++ reiserfs_write_lock_nested(inode->i_sb, depth);
if (retval) {
pathrelse(path);
return retval;
-@@ -2126,7 +2141,10 @@ int reiserfs_insert_item(struct reiserfs
+@@ -2114,7 +2129,10 @@ int reiserfs_insert_item(struct reiserfs_transaction_handle *th,
"reiserquota insert_item(): freeing %u id=%u type=%c",
quota_bytes, inode->i_uid, head2type(ih));
#endif
- if (inode)
+ if (inode) {
-+ depth = reiserfs_write_unlock_nested(sb);
++ int depth = reiserfs_write_unlock_nested(inode->i_sb);
dquot_free_space_nodirty(inode, quota_bytes);
-+ reiserfs_write_lock_nested(sb, depth);
++ reiserfs_write_lock_nested(inode->i_sb, depth);
+ }
return retval;
}
+diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
+index 60d0932..bb20d79 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
-@@ -162,6 +162,7 @@ static int finish_unfinished(struct supe
- int done;
- struct inode *inode;
- int truncate;
-+ int depth;
- #ifdef CONFIG_QUOTA
- int i;
- int ms_active_set;
-@@ -264,9 +265,9 @@ static int finish_unfinished(struct supe
+@@ -243,6 +243,7 @@ static int finish_unfinished(struct super_block *s)
+ done = 0;
+ REISERFS_SB(s)->s_is_unlinked_ok = 1;
+ while (!retval) {
++ int depth;
+ retval = search_item(s, &max_cpu_key, &path);
+ if (retval != ITEM_NOT_FOUND) {
+ reiserfs_error(s, "vs-2140",
+@@ -298,9 +299,9 @@ static int finish_unfinished(struct super_block *s)
retval = remove_save_link_only(s, &save_link_key, 0);
continue;
}
@@ -452,7 +320,7 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
if (truncate && S_ISDIR(inode->i_mode)) {
/* We got a truncate request for a dir which is impossible.
-@@ -322,10 +323,12 @@ static int finish_unfinished(struct supe
+@@ -356,10 +357,12 @@ static int finish_unfinished(struct super_block *s)
#ifdef CONFIG_QUOTA
/* Turn quotas off */
@@ -465,16 +333,15 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
if (ms_active_set)
/* Restore the flag back */
s->s_flags &= ~MS_ACTIVE;
-@@ -1975,7 +1978,7 @@ static int reiserfs_statfs(struct dentry
- static int reiserfs_write_dquot(struct dquot *dquot)
+@@ -2098,6 +2101,7 @@ static int reiserfs_write_dquot(struct dquot *dquot)
{
struct reiserfs_transaction_handle th;
-- int ret, err;
-+ int ret, err, depth;
+ int ret, err;
++ int depth;
reiserfs_write_lock(dquot->dq_sb);
ret =
-@@ -1983,9 +1986,9 @@ static int reiserfs_write_dquot(struct d
+@@ -2105,9 +2109,9 @@ static int reiserfs_write_dquot(struct dquot *dquot)
REISERFS_QUOTA_TRANS_BLOCKS(dquot->dq_sb));
if (ret)
goto out;
@@ -486,16 +353,15 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
err =
journal_end(&th, dquot->dq_sb,
REISERFS_QUOTA_TRANS_BLOCKS(dquot->dq_sb));
-@@ -1999,7 +2002,7 @@ out:
- static int reiserfs_acquire_dquot(struct dquot *dquot)
+@@ -2122,6 +2126,7 @@ static int reiserfs_acquire_dquot(struct dquot *dquot)
{
struct reiserfs_transaction_handle th;
-- int ret, err;
-+ int ret, err, depth;
+ int ret, err;
++ int depth;
reiserfs_write_lock(dquot->dq_sb);
ret =
-@@ -2007,9 +2010,9 @@ static int reiserfs_acquire_dquot(struct
+@@ -2129,9 +2134,9 @@ static int reiserfs_acquire_dquot(struct dquot *dquot)
REISERFS_QUOTA_INIT_BLOCKS(dquot->dq_sb));
if (ret)
goto out;
@@ -507,37 +373,11 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
err =
journal_end(&th, dquot->dq_sb,
REISERFS_QUOTA_INIT_BLOCKS(dquot->dq_sb));
-@@ -2023,20 +2026,21 @@ out:
- static int reiserfs_release_dquot(struct dquot *dquot)
+@@ -2184,15 +2189,16 @@ static int reiserfs_write_info(struct super_block *sb, int type)
{
struct reiserfs_transaction_handle th;
-- int ret, err;
-+ int ret, err, depth;
-
- reiserfs_write_lock(dquot->dq_sb);
- ret =
- journal_begin(&th, dquot->dq_sb,
- REISERFS_QUOTA_DEL_BLOCKS(dquot->dq_sb));
-- reiserfs_write_unlock(dquot->dq_sb);
-+ depth = reiserfs_write_unlock_nested(dquot->dq_sb);
- if (ret) {
- /* Release dquot anyway to avoid endless cycle in dqput() */
- dquot_release(dquot);
-+ reiserfs_write_lock_nested(dquot->dq_sb, depth);
- goto out;
- }
- ret = dquot_release(dquot);
-- reiserfs_write_lock(dquot->dq_sb);
-+ reiserfs_write_lock_nested(dquot->dq_sb, depth);
- err =
- journal_end(&th, dquot->dq_sb,
- REISERFS_QUOTA_DEL_BLOCKS(dquot->dq_sb));
-@@ -2061,16 +2065,16 @@ static int reiserfs_mark_dquot_dirty(str
- static int reiserfs_write_info(struct super_block *sb, int type)
- {
- struct reiserfs_transaction_handle th;
-- int ret, err;
-+ int ret, err, depth;
+ int ret, err;
++ int depth;
/* Data block + inode block */
reiserfs_write_lock(sb);
@@ -552,99 +392,4 @@ Signed-off-by: Jeff Mahoney <jeffm@suse.com>
err = journal_end(&th, sb, 2);
if (!ret && err)
ret = err;
-@@ -2084,8 +2088,14 @@ out:
- */
- static int reiserfs_quota_on_mount(struct super_block *sb, int type)
- {
-- return dquot_quota_on_mount(sb, REISERFS_SB(sb)->s_qf_names[type],
-- REISERFS_SB(sb)->s_jquota_fmt, type);
-+ int ret, depth;
-+
-+ depth = reiserfs_write_unlock_nested(sb);
-+ ret = dquot_quota_on_mount(sb, REISERFS_SB(sb)->s_qf_names[type],
-+ REISERFS_SB(sb)->s_jquota_fmt, type);
-+ reiserfs_write_lock_nested(sb, depth);
-+
-+ return ret;
- }
-
- /*
---- a/fs/reiserfs/reiserfs.h
-+++ b/fs/reiserfs/reiserfs.h
-@@ -23,6 +23,7 @@
- #include <linux/bitops.h>
- #include <linux/proc_fs.h>
- #include <linux/buffer_head.h>
-+#include <linux/quotaops.h>
-
- /* the 32 bit compat definitions with int argument */
- #define REISERFS_IOC32_UNPACK _IOW(0xCD, 1, int)
-@@ -60,6 +61,7 @@ void reiserfs_write_lock(struct super_bl
- void reiserfs_write_unlock(struct super_block *s);
- int __must_check reiserfs_write_unlock_nested(struct super_block *s);
- void reiserfs_write_lock_nested(struct super_block *s, int depth);
-+void reiserfs_check_lock_nested(struct super_block *s, const char *caller);
-
- #ifdef CONFIG_REISERFS_CHECK
- void reiserfs_lock_check_recursive(struct super_block *s);
-@@ -95,52 +97,26 @@ static inline void reiserfs_lock_check_r
- * - The inode mutex
- */
-
--#define reiserfs_safe(sb, action) \
--do { \
-- struct super_block *__sb = (sb); \
-- int __depth; \
-- __depth = reiserfs_write_unlock_nested(__sb); \
-- (action); \
-- reiserfs_write_lock_nested(__sb, __depth); \
--} while(0)
--
--#define reiserfs_mutex_lock_safe(mtx, s) reiserfs_safe(s, mutex_lock(mtx))
--#define reiserfs_mutex_lock_nested_safe(mtx, subclass, s) \
-- reiserfs_safe(s, mutex_lock_nested(mtx, subclass))
--#define reiserfs_down_read_safe(sem, s) reiserfs_safe(s, down_read(sem))
--
- /*
- * When we schedule, we usually want to also release the write lock,
- * according to the previous bkl based locking scheme of reiserfs.
- */
- static inline void reiserfs_cond_resched(struct super_block *s)
- {
-- if (need_resched())
-- reiserfs_safe(s, schedule());
--}
--
--static inline struct buffer_head *
--reiserfs_safe_sb_bread(struct super_block *s, sector_t block)
--{
-- int depth;
-- struct buffer_head *bh;
--
-- depth = reiserfs_write_unlock_nested(s);
-- bh = sb_bread(s, block);
-- reiserfs_write_lock_nested(s, depth);
--
-- return bh;
-+ if (need_resched()) {
-+ int depth = reiserfs_write_unlock_nested(s);
-+ schedule();
-+ reiserfs_write_lock_nested(s, depth);
-+ }
- }
-
--void reiserfs_safe_lock_buffer(struct buffer_head *bh);
--
--static inline void
--reiserfs_safe_wait_on_buffer(struct buffer_head *bh, struct super_block *s)
-+static inline void reiserfs_mutex_lock_safe(struct mutex *m,
-+ struct super_block *s)
- {
- int depth;
-
- depth = reiserfs_write_unlock_nested(s);
-- __wait_on_buffer(bh);
-+ mutex_lock(m);
- reiserfs_write_lock_nested(s, depth);
- }
-
+