* [patch 00/40] reiserfs: patch queue (v2)
@ 2007-06-11 19:03 jeffm
2007-06-11 19:03 ` [patch 01/40] reiserfs: fix up lockdep warnings jeffm
` (40 more replies)
0 siblings, 41 replies; 43+ messages in thread
From: jeffm @ 2007-06-11 19:03 UTC (permalink / raw)
To: ReiserFS Mailing List
Hi all -
The following are a series of patches that have been kicking around for a
while. I thought I'd just put them out there to gauge interest and to get
some testing before submitting to -mm.
I've re-ordered a few of the patches. This is actually four distinct,
unrelated, though context-dependent, patch series. I've moved the trivial
changes to the front of the list to better reflect that.
There are a few groups:
* Little changes (01-04)
- Fixes lockdep warnings in xattr code.
- Changes reiserfs_panic() to panic() instead of BUG.
- Includes bitmap is_reusable unconditionally and uses to to catch
corruption. This is light-weight now that the stupid loop is gone.
- Make bitmap used cached first zero bit.
* Error handling (05-11)
- Reformat error/warning/panic/info/etc messages to be consistent with one
another.
- Makes some warnings informational. Rather than printing the
reiserfs_warning() full preamble to declare that a mount option was
invalid, we use reiserfs_info instead.
- Rework reiserfs_warning to take a unique ID, print the function name,
print the device name.
- Rework reiserfs_panic similarly.
- Add reiserfs_error() to handle metadata errors.
- Use reiserfs_error().
* Extended attributes (12-22)
- Simplify internal file lookups/opens.
- Eliminate per-super xattr lock.
- Make per-inode xattr lock more fine-grained.
- Remove i_has_xattr_dir flag.
- Remove shared xattr detection (unused).
- Use generic xattr handler infrastructure.
- Use O_NOATIME for internal file opens.
- Add per-file data=ordered mode and use it for xattrs.
- Journal xattrs.
- Kill xattr_readdir in favor of a for_each_xattr.
- Add atomic addition of selinux attributes during inode creation.
* Cleanups, code readability (23-30)
- Cleanup path functions to reduce redundancy.
- Strip trailing whitespace from all reiserfs code.
- Rename p_s_sb to sb.
- Rename p_s_bh to bh.
- Rename p_s_inode to inode.
- Rename p_s_tb to tb.
- Rename misc p_._ variables.
- Rename [cn]_* variables.
* Clean up do_balan.c (31-40)
- Factor out buffer_info initializations.
- Turn tb->s[12]num and tb[12]bytes into an array.
- Split balance_leaf from the 2500 line beast to more manageable chunks.
- Clean up balance_leaf_when_delete.
- Clean up comments.
I look forward to comments. The journaled xattr changes in particular need
testing as deadlocks may still lurk in there.
Changes:
- Reworked journal abort code to provide cleaner syslog output
- Always abort journal on error, unless panicking
- Always use bl_ prefix in do_balan.c
- Fixed unchecked deref in reiserfs_free_block
I've also posted the patch set here:
ftp://ftp.suse.com/pub/people/jeffm/reiserfs/kernel-v2.6/2.6.22-rc4-git3/
-Jeff
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 43+ messages in thread
* [patch 01/40] reiserfs: fix up lockdep warnings
2007-06-11 19:03 [patch 00/40] reiserfs: patch queue (v2) jeffm
@ 2007-06-11 19:03 ` jeffm
2007-06-11 19:03 ` [patch 02/40] reiserfs: dont use BUG when panicking jeffm
` (39 subsequent siblings)
40 siblings, 0 replies; 43+ messages in thread
From: jeffm @ 2007-06-11 19:03 UTC (permalink / raw)
To: ReiserFS Mailing List
[-- Attachment #1: reiserfs-fix-lockdep-warnings --]
[-- Type: text/plain, Size: 1153 bytes --]
This patch adds I_MUTEX_XATTR annotations to the inode locking in
the reiserfs xattr code.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
fs/reiserfs/xattr.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
--- a/fs/reiserfs/xattr.c 2007-06-11 14:49:05.000000000 -0400
+++ b/fs/reiserfs/xattr.c 2007-06-11 14:50:10.000000000 -0400
@@ -478,7 +478,7 @@ reiserfs_xattr_set(struct inode *inode,
/* Resize it so we're ok to write there */
newattrs.ia_size = buffer_size;
newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
- mutex_lock(&xinode->i_mutex);
+ mutex_lock_nested(&xinode->i_mutex, I_MUTEX_XATTR);
err = notify_change(fp->f_path.dentry, &newattrs);
if (err)
goto out_filp;
@@ -1217,7 +1217,8 @@ int reiserfs_xattr_init(struct super_blo
if (!IS_ERR(dentry)) {
if (!(mount_flags & MS_RDONLY) && !dentry->d_inode) {
struct inode *inode = dentry->d_parent->d_inode;
- mutex_lock(&inode->i_mutex);
+ mutex_lock_nested(&inode->i_mutex,
+ I_MUTEX_XATTR);
err = inode->i_op->mkdir(inode, dentry, 0700);
mutex_unlock(&inode->i_mutex);
if (err) {
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 43+ messages in thread
* [patch 02/40] reiserfs: dont use BUG when panicking
2007-06-11 19:03 [patch 00/40] reiserfs: patch queue (v2) jeffm
2007-06-11 19:03 ` [patch 01/40] reiserfs: fix up lockdep warnings jeffm
@ 2007-06-11 19:03 ` jeffm
2007-06-11 19:03 ` [patch 03/40] reiserfs: use is_reusable to catch corruption jeffm
` (38 subsequent siblings)
40 siblings, 0 replies; 43+ messages in thread
From: jeffm @ 2007-06-11 19:03 UTC (permalink / raw)
To: ReiserFS Mailing List
[-- Attachment #1: reiserfs-no-bug-on-panic.diff --]
[-- Type: text/plain, Size: 1115 bytes --]
This patch changes reiserfs_panic() to use panic() initially instead of
BUG(). Using BUG() ignores the configurable panic behavior, so systems
that should be failing and rebooting are left hanging. This causes problems
in active/standby HA scenarios.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
fs/reiserfs/prints.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
--- a/fs/reiserfs/prints.c 2007-06-11 14:49:05.000000000 -0400
+++ b/fs/reiserfs/prints.c 2007-06-11 14:50:11.000000000 -0400
@@ -356,13 +356,8 @@ extern struct tree_balance *cur_tb;
void reiserfs_panic(struct super_block *sb, const char *fmt, ...)
{
do_reiserfs_warning(fmt);
- printk(KERN_EMERG "REISERFS: panic (device %s): %s\n",
+ panic(KERN_EMERG "REISERFS: panic (device %s): %s\n",
reiserfs_bdevname(sb), error_buf);
- BUG();
-
- /* this is not actually called, but makes reiserfs_panic() "noreturn" */
- panic("REISERFS: panic (device %s): %s\n",
- reiserfs_bdevname(sb), error_buf);
}
void reiserfs_abort(struct super_block *sb, int errno, const char *fmt, ...)
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 43+ messages in thread
* [patch 03/40] reiserfs: use is_reusable to catch corruption
2007-06-11 19:03 [patch 00/40] reiserfs: patch queue (v2) jeffm
2007-06-11 19:03 ` [patch 01/40] reiserfs: fix up lockdep warnings jeffm
2007-06-11 19:03 ` [patch 02/40] reiserfs: dont use BUG when panicking jeffm
@ 2007-06-11 19:03 ` jeffm
2007-06-13 15:54 ` Jeff Mahoney
2007-06-11 19:03 ` [patch 04/40] reiserfs: make bitmap use cached first zero bit jeffm
` (37 subsequent siblings)
40 siblings, 1 reply; 43+ messages in thread
From: jeffm @ 2007-06-11 19:03 UTC (permalink / raw)
To: ReiserFS Mailing List
[-- Attachment #1: reiserfs-use-is_reusable.diff --]
[-- Type: text/plain, Size: 2246 bytes --]
This patch builds in is_reusable() unconditionally and uses it to catch
corruption before it reaches the block freeing paths.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
--
fs/reiserfs/bitmap.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
--- a/fs/reiserfs/bitmap.c 2007-06-11 14:49:05.000000000 -0400
+++ b/fs/reiserfs/bitmap.c 2007-06-11 14:50:11.000000000 -0400
@@ -56,7 +56,6 @@ static inline void get_bit_address(struc
*offset = block & ((s->s_blocksize << 3) - 1);
}
-#ifdef CONFIG_REISERFS_CHECK
int is_reusable(struct super_block *s, b_blocknr_t block, int bit_value)
{
int bmap, offset;
@@ -106,7 +105,6 @@ int is_reusable(struct super_block *s, b
return 1;
}
-#endif /* CONFIG_REISERFS_CHECK */
/* searches in journal structures for a given block number (bmap, off). If block
is found in reiserfs journal it suggests next free block candidate to test. */
@@ -434,12 +432,19 @@ void reiserfs_free_block(struct reiserfs
int for_unformatted)
{
struct super_block *s = th->t_super;
-
BUG_ON(!th->t_trans_id);
RFALSE(!s, "vs-4061: trying to free block on nonexistent device");
- RFALSE(is_reusable(s, block, 1) == 0,
- "vs-4071: can not free such block");
+ if (!is_reusable(s, block, 1))
+ return;
+
+ if (sb_block_count(REISERFS_SB(s)->s_rs) > blocks) {
+ reiserfs_error(th->t_super, "bitmap-4072",
+ "Trying to free block outside file system "
+ "boundaries (%lu > %lu)",
+ block, blocks);
+ return;
+ }
/* mark it before we clear it, just in case */
journal_mark_freed(th, s, block);
_reiserfs_free_block(th, inode, block, for_unformatted);
@@ -449,11 +454,11 @@ void reiserfs_free_block(struct reiserfs
static void reiserfs_free_prealloc_block(struct reiserfs_transaction_handle *th,
struct inode *inode, b_blocknr_t block)
{
+ BUG_ON(!th->t_trans_id);
RFALSE(!th->t_super,
"vs-4060: trying to free block on nonexistent device");
- RFALSE(is_reusable(th->t_super, block, 1) == 0,
- "vs-4070: can not free such block");
- BUG_ON(!th->t_trans_id);
+ if (!is_reusable(th->t_super, block, 1))
+ return;
_reiserfs_free_block(th, inode, block, 1);
}
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 43+ messages in thread
* [patch 04/40] reiserfs: make bitmap use cached first zero bit
2007-06-11 19:03 [patch 00/40] reiserfs: patch queue (v2) jeffm
` (2 preceding siblings ...)
2007-06-11 19:03 ` [patch 03/40] reiserfs: use is_reusable to catch corruption jeffm
@ 2007-06-11 19:03 ` jeffm
2007-06-11 19:03 ` [patch 05/40] reiserfs: use more consistent printk formatting jeffm
` (36 subsequent siblings)
40 siblings, 0 replies; 43+ messages in thread
From: jeffm @ 2007-06-11 19:03 UTC (permalink / raw)
To: ReiserFS Mailing List
[-- Attachment #1: reiserfs-bitmap-use-first-zero-hint.diff --]
[-- Type: text/plain, Size: 1105 bytes --]
Currently, the bitmap code uses half of the hinting data gathered and cached
and wastes the other half. We'll skip completely full bitmaps, but start
scanning in bitmaps at locations where if we consulted the zero bit hint,
we'd know there aren't any free bits available.
This patch uses the first zero hint to bump the beginning of the search
window to where we know there is at least one zero bit.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
fs/reiserfs/bitmap.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
--- a/fs/reiserfs/bitmap.c 2007-06-11 14:49:32.000000000 -0400
+++ b/fs/reiserfs/bitmap.c 2007-06-11 14:50:10.000000000 -0400
@@ -166,7 +166,10 @@ static int scan_bitmap_block(struct reis
return 0; // No free blocks in this bitmap
}
- /* search for a first zero bit -- beggining of a window */
+ if (*beg < bi->first_zero_hint)
+ *beg = bi->first_zero_hint;
+
+ /* search for a first zero bit -- beginning of a window */
*beg = reiserfs_find_next_zero_le_bit
((unsigned long *)(bh->b_data), boundary, *beg);
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 43+ messages in thread
* [patch 05/40] reiserfs: use more consistent printk formatting
2007-06-11 19:03 [patch 00/40] reiserfs: patch queue (v2) jeffm
` (3 preceding siblings ...)
2007-06-11 19:03 ` [patch 04/40] reiserfs: make bitmap use cached first zero bit jeffm
@ 2007-06-11 19:03 ` jeffm
2007-06-11 19:03 ` [patch 06/40] reiserfs: make some warnings informational jeffm
` (35 subsequent siblings)
40 siblings, 0 replies; 43+ messages in thread
From: jeffm @ 2007-06-11 19:03 UTC (permalink / raw)
To: ReiserFS Mailing List
[-- Attachment #1: reiserfs-consistent-messages.diff --]
[-- Type: text/plain, Size: 2585 bytes --]
The output format between a warning/error/panic/info/etc changes with
which one is used.
The following patch makes the messages more internally consistent, but also
more consistent with other Linux filesystems.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
--
fs/reiserfs/prints.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
--- a/fs/reiserfs/prints.c 2007-06-11 14:49:31.000000000 -0400
+++ b/fs/reiserfs/prints.c 2007-06-11 14:50:10.000000000 -0400
@@ -268,10 +268,10 @@ void reiserfs_warning(struct super_block
{
do_reiserfs_warning(fmt);
if (sb)
- printk(KERN_WARNING "ReiserFS: %s: warning: %s\n",
- reiserfs_bdevname(sb), error_buf);
+ printk(KERN_WARNING "REISERFS warning (device %s): %s\n",
+ sb->s_id, error_buf);
else
- printk(KERN_WARNING "ReiserFS: warning: %s\n", error_buf);
+ printk(KERN_WARNING "REISERFS warning: %s\n", error_buf);
}
/* No newline.. reiserfs_info calls can be followed by printk's */
@@ -279,10 +279,10 @@ void reiserfs_info(struct super_block *s
{
do_reiserfs_warning(fmt);
if (sb)
- printk(KERN_NOTICE "ReiserFS: %s: %s",
- reiserfs_bdevname(sb), error_buf);
+ printk(KERN_NOTICE "REISERFS (device %s): %s",
+ sb->s_id, error_buf);
else
- printk(KERN_NOTICE "ReiserFS: %s", error_buf);
+ printk(KERN_NOTICE "REISERFS %s:", error_buf);
}
/* No newline.. reiserfs_printk calls can be followed by printk's */
@@ -297,10 +297,10 @@ void reiserfs_debug(struct super_block *
#ifdef CONFIG_REISERFS_CHECK
do_reiserfs_warning(fmt);
if (s)
- printk(KERN_DEBUG "ReiserFS: %s: %s\n",
- reiserfs_bdevname(s), error_buf);
+ printk(KERN_DEBUG "REISERFS debug (device %s): %s\n",
+ s->s_id, error_buf);
else
- printk(KERN_DEBUG "ReiserFS: %s\n", error_buf);
+ printk(KERN_DEBUG "REISERFS debug: %s\n", error_buf);
#endif
}
@@ -365,15 +365,15 @@ void reiserfs_abort(struct super_block *
do_reiserfs_warning(fmt);
if (reiserfs_error_panic(sb)) {
- panic(KERN_CRIT "REISERFS: panic (device %s): %s\n",
- reiserfs_bdevname(sb), error_buf);
+ panic(KERN_CRIT "REISERFS panic (device %s): %s\n", sb->s_id,
+ error_buf);
}
- if (sb->s_flags & MS_RDONLY)
+ if (reiserfs_is_journal_aborted(SB_JOURNAL(sb)))
return;
- printk(KERN_CRIT "REISERFS: abort (device %s): %s\n",
- reiserfs_bdevname(sb), error_buf);
+ printk(KERN_CRIT "REISERFS abort (device %s): %s\n", sb->s_id,
+ error_buf);
sb->s_flags |= MS_RDONLY;
reiserfs_journal_abort(sb, errno);
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 43+ messages in thread
* [patch 06/40] reiserfs: make some warnings informational
2007-06-11 19:03 [patch 00/40] reiserfs: patch queue (v2) jeffm
` (4 preceding siblings ...)
2007-06-11 19:03 ` [patch 05/40] reiserfs: use more consistent printk formatting jeffm
@ 2007-06-11 19:03 ` jeffm
2007-06-11 19:03 ` [patch 07/40] reiserfs: rework reiserfs_warning jeffm
` (34 subsequent siblings)
40 siblings, 0 replies; 43+ messages in thread
From: jeffm @ 2007-06-11 19:03 UTC (permalink / raw)
To: ReiserFS Mailing List
[-- Attachment #1: reiserfs-reiserfs_info.diff --]
[-- Type: text/plain, Size: 3061 bytes --]
In several places, reiserfs_warning is used when there is no warning, just
a notice. This patch changes some of them to indicate that the message
is merely informational.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
--
fs/reiserfs/bitmap.c | 4 ++--
fs/reiserfs/super.c | 14 ++++++--------
fs/reiserfs/xattr.c | 10 ++++------
3 files changed, 12 insertions(+), 16 deletions(-)
--- a/fs/reiserfs/bitmap.c 2007-06-11 14:49:32.000000000 -0400
+++ b/fs/reiserfs/bitmap.c 2007-06-11 14:50:10.000000000 -0400
@@ -40,7 +40,7 @@
#define SET_OPTION(optname) \
do { \
- reiserfs_warning(s, "reiserfs: option \"%s\" is set", #optname); \
+ reiserfs_info(s, "block allocator option \"%s\" is set", #optname); \
set_bit(_ALLOC_ ## optname , &SB_ALLOC_OPTS(s)); \
} while(0)
#define TEST_OPTION(optname, s) \
@@ -633,7 +633,7 @@ int reiserfs_parse_alloc_options(struct
return 1;
}
- reiserfs_warning(s, "allocator options = [%08x]\n", SB_ALLOC_OPTS(s));
+ reiserfs_info(s, "allocator options = [%08x]\n", SB_ALLOC_OPTS(s));
return 0;
}
--- a/fs/reiserfs/super.c 2007-06-11 14:49:05.000000000 -0400
+++ b/fs/reiserfs/super.c 2007-06-11 14:50:10.000000000 -0400
@@ -1308,13 +1308,11 @@ static int read_super_block(struct super
/* magic is of non-standard journal filesystem, look at s_version to
find which format is in use */
if (sb_version(rs) == REISERFS_VERSION_2)
- reiserfs_warning(s,
- "read_super_block: found reiserfs format \"3.6\""
- " with non-standard journal");
+ reiserfs_info(s, "found reiserfs format \"3.6\""
+ " with non-standard journal\n");
else if (sb_version(rs) == REISERFS_VERSION_1)
- reiserfs_warning(s,
- "read_super_block: found reiserfs format \"3.5\""
- " with non-standard journal");
+ reiserfs_info(s, "found reiserfs format \"3.5\""
+ " with non-standard journal\n");
else {
reiserfs_warning(s,
"sh-2012: read_super_block: found unknown "
@@ -1393,8 +1391,8 @@ static __u32 find_hash_out(struct super_
if (reiserfs_rupasov_hash(s)) {
hash = YURA_HASH;
}
- reiserfs_warning(s, "FS seems to be empty, autodetect "
- "is using the default hash");
+ reiserfs_info(s, "FS seems to be empty, autodetect "
+ "is using the default hash\n");
break;
}
r5hash = GET_HASH_VALUE(r5_hash(de.de_name, de.de_namelen));
--- a/fs/reiserfs/xattr.c 2007-06-11 14:49:31.000000000 -0400
+++ b/fs/reiserfs/xattr.c 2007-06-11 14:50:10.000000000 -0400
@@ -1227,12 +1227,10 @@ int reiserfs_xattr_init(struct super_blo
}
if (dentry && dentry->d_inode)
- reiserfs_warning(s,
- "Created %s on %s - reserved for "
- "xattr storage.",
- PRIVROOT_NAME,
- reiserfs_bdevname
- (inode->i_sb));
+ reiserfs_info(s, "Created %s - "
+ "reserved for xattr "
+ "storage.\n",
+ PRIVROOT_NAME);
} else if (!dentry->d_inode) {
dput(dentry);
dentry = NULL;
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 43+ messages in thread
* [patch 07/40] reiserfs: rework reiserfs_warning
2007-06-11 19:03 [patch 00/40] reiserfs: patch queue (v2) jeffm
` (5 preceding siblings ...)
2007-06-11 19:03 ` [patch 06/40] reiserfs: make some warnings informational jeffm
@ 2007-06-11 19:03 ` jeffm
2007-06-11 19:03 ` [patch 08/40] reiserfs: rework reiserfs_panic jeffm
` (33 subsequent siblings)
40 siblings, 0 replies; 43+ messages in thread
From: jeffm @ 2007-06-11 19:03 UTC (permalink / raw)
To: ReiserFS Mailing List
[-- Attachment #1: reiserfs-reiserfs-warning.diff --]
[-- Type: text/plain, Size: 86526 bytes --]
ReiserFS warnings can be somewhat inconsistent.
In some cases:
* a unique identifier may be associated with it
* the function name may be included
* the device may be printed separately
This patch aims to make warnings more consistent. reiserfs_warning() prints
the device name, so printing it a second time is not required. The function
name for a warning is always helpful in debugging, so it is now automatically
inserted into the output. Hans has stated that every warning should have
a unique identifier. Some cases lack them, others really shouldn't have them.
reiserfs_warning() now expects an id associated with each message. In the
rare case where one isn't needed, "" will suffice.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
--
fs/reiserfs/bitmap.c | 50 ++++----
fs/reiserfs/do_balan.c | 39 +++---
fs/reiserfs/file.c | 11 +
fs/reiserfs/fix_node.c | 14 +-
fs/reiserfs/inode.c | 63 +++++------
fs/reiserfs/item_ops.c | 60 +++++-----
fs/reiserfs/journal.c | 168 +++++++++++++++--------------
fs/reiserfs/lbalance.c | 12 +-
fs/reiserfs/namei.c | 45 +++----
fs/reiserfs/objectid.c | 5
fs/reiserfs/prints.c | 11 +
fs/reiserfs/procfs.c | 5
fs/reiserfs/stree.c | 107 ++++++++----------
fs/reiserfs/super.c | 240 ++++++++++++++++++++++--------------------
fs/reiserfs/tail_conversion.c | 6 -
fs/reiserfs/xattr.c | 21 ++-
include/linux/reiserfs_fs.h | 9 +
17 files changed, 444 insertions(+), 422 deletions(-)
--- a/fs/reiserfs/bitmap.c 2007-06-11 14:49:33.000000000 -0400
+++ b/fs/reiserfs/bitmap.c 2007-06-11 14:50:08.000000000 -0400
@@ -61,8 +61,8 @@ int is_reusable(struct super_block *s, b
int bmap, offset;
if (block == 0 || block >= SB_BLOCK_COUNT(s)) {
- reiserfs_warning(s,
- "vs-4010: is_reusable: block number is out of range %lu (%u)",
+ reiserfs_warning(s, "vs-4010",
+ "block number is out of range %lu (%u)",
block, SB_BLOCK_COUNT(s));
return 0;
}
@@ -75,30 +75,29 @@ int is_reusable(struct super_block *s, b
&(REISERFS_SB(s)->s_properties)))) {
b_blocknr_t bmap1 = REISERFS_SB(s)->s_sbh->b_blocknr + 1;
if (block >= bmap1 && block <= bmap1 + SB_BMAP_NR(s)) {
- reiserfs_warning(s, "vs: 4019: is_reusable: "
- "bitmap block %lu(%u) can't be freed or reused",
+ reiserfs_warning(s, "vs-4019", "bitmap block "
+ "%lu(%u) can't be freed or reused",
block, SB_BMAP_NR(s));
return 0;
}
} else {
if (offset == 0) {
- reiserfs_warning(s, "vs: 4020: is_reusable: "
- "bitmap block %lu(%u) can't be freed or reused",
+ reiserfs_warning(s, "vs-4020", "bitmap block "
+ "%lu(%u) can't be freed or reused",
block, SB_BMAP_NR(s));
return 0;
}
}
if (bmap >= SB_BMAP_NR(s)) {
- reiserfs_warning(s,
- "vs-4030: is_reusable: there is no so many bitmap blocks: "
- "block=%lu, bitmap_nr=%d", block, bmap);
+ reiserfs_warning(s, "vs-4030", "there is no so many "
+ "bitmap blocks: block=%lu, bitmap_nr=%d",
+ block, bmap);
return 0;
}
if (bit_value == 0 && block == SB_ROOT_BLOCK(s)) {
- reiserfs_warning(s,
- "vs-4050: is_reusable: this is root block (%u), "
+ reiserfs_warning(s, "vs-4050", "this is root block (%u), "
"it must be busy", SB_ROOT_BLOCK(s));
return 0;
}
@@ -150,8 +149,8 @@ static int scan_bitmap_block(struct reis
/* - I mean `a window of zero bits' as in description of this function - Zam. */
if (!bi) {
- reiserfs_warning(s, "NULL bitmap info pointer for bitmap %d",
- bmap_n);
+ reiserfs_warning(s, "jdm-4055", "NULL bitmap info pointer "
+ "for bitmap %d", bmap_n);
return 0;
}
@@ -399,9 +398,8 @@ static void _reiserfs_free_block(struct
get_bit_address(s, block, &nr, &offset);
if (nr >= sb_bmap_nr(rs)) {
- reiserfs_warning(s, "vs-4075: reiserfs_free_block: "
- "block %lu is out of range on %s",
- block, reiserfs_bdevname(s));
+ reiserfs_warning(s, "vs-4075",
+ "block %lu is out of range", block);
return;
}
@@ -413,9 +411,8 @@ static void _reiserfs_free_block(struct
/* clear bit for the given block in bit map */
if (!reiserfs_test_and_clear_le_bit(offset, bmbh->b_data)) {
- reiserfs_warning(s, "vs-4080: reiserfs_free_block: "
- "free_block (%s:%lu)[dev:blocknr]: bit already cleared",
- reiserfs_bdevname(s), block);
+ reiserfs_warning(s, "vs-4080",
+ "block %lu: bit already cleared", block);
}
apbi[nr].free_count++;
journal_mark_dirty(th, s, bmbh);
@@ -474,9 +471,8 @@ static void __discard_prealloc(struct re
BUG_ON(!th->t_trans_id);
#ifdef CONFIG_REISERFS_CHECK
if (ei->i_prealloc_count < 0)
- reiserfs_warning(th->t_super,
- "zam-4001:%s: inode has negative prealloc blocks count.",
- __FUNCTION__);
+ reiserfs_warning(th->t_super, "zam-4001",
+ "inode has negative prealloc blocks count.");
#endif
while (ei->i_prealloc_count > 0) {
reiserfs_free_prealloc_block(th, inode, ei->i_prealloc_block);
@@ -512,9 +508,9 @@ void reiserfs_discard_all_prealloc(struc
i_prealloc_list);
#ifdef CONFIG_REISERFS_CHECK
if (!ei->i_prealloc_count) {
- reiserfs_warning(th->t_super,
- "zam-4001:%s: inode is in prealloc list but has no preallocated blocks.",
- __FUNCTION__);
+ reiserfs_warning(th->t_super, "zam-4001",
+ "inode is in prealloc list but has "
+ "no preallocated blocks.");
}
#endif
__discard_prealloc(th, ei);
@@ -628,8 +624,8 @@ int reiserfs_parse_alloc_options(struct
continue;
}
- reiserfs_warning(s, "zam-4001: %s : unknown option - %s",
- __FUNCTION__, this_char);
+ reiserfs_warning(s, "zam-4001", "unknown option - %s",
+ this_char);
return 1;
}
--- a/fs/reiserfs/do_balan.c 2007-06-11 14:49:05.000000000 -0400
+++ b/fs/reiserfs/do_balan.c 2007-06-11 14:50:09.000000000 -0400
@@ -1755,15 +1755,15 @@ static void store_thrown(struct tree_bal
int i;
if (buffer_dirty(bh))
- reiserfs_warning(tb->tb_sb,
- "store_thrown deals with dirty buffer");
+ reiserfs_warning(tb->tb_sb, "reiserfs-12320",
+ "called with dirty buffer");
for (i = 0; i < ARRAY_SIZE(tb->thrown); i++)
if (!tb->thrown[i]) {
tb->thrown[i] = bh;
get_bh(bh); /* free_thrown puts this */
return;
}
- reiserfs_warning(tb->tb_sb, "store_thrown: too many thrown buffers");
+ reiserfs_warning(tb->tb_sb, "reiserfs-12321", "too many thrown buffers");
}
static void free_thrown(struct tree_balance *tb)
@@ -1774,8 +1774,8 @@ static void free_thrown(struct tree_bala
if (tb->thrown[i]) {
blocknr = tb->thrown[i]->b_blocknr;
if (buffer_dirty(tb->thrown[i]))
- reiserfs_warning(tb->tb_sb,
- "free_thrown deals with dirty buffer %d",
+ reiserfs_warning(tb->tb_sb, "reiserfs-12322",
+ "called with dirty buffer %d",
blocknr);
brelse(tb->thrown[i]); /* incremented in store_thrown */
reiserfs_free_block(tb->transaction_handle, NULL,
@@ -1880,13 +1880,12 @@ static void check_internal_node(struct s
}
}
-static int locked_or_not_in_tree(struct buffer_head *bh, char *which)
+static int locked_or_not_in_tree(struct tree_balance *tb,
+ struct buffer_head *bh, char *which)
{
if ((!buffer_journal_prepared(bh) && buffer_locked(bh)) ||
!B_IS_IN_TREE(bh)) {
- reiserfs_warning(NULL,
- "vs-12339: locked_or_not_in_tree: %s (%b)",
- which, bh);
+ reiserfs_warning(tb->tb_sb, "vs-12339", "%s (%b)", which, bh);
return 1;
}
return 0;
@@ -1905,18 +1904,19 @@ static int check_before_balancing(struct
/* double check that buffers that we will modify are unlocked. (fix_nodes should already have
prepped all of these for us). */
if (tb->lnum[0]) {
- retval |= locked_or_not_in_tree(tb->L[0], "L[0]");
- retval |= locked_or_not_in_tree(tb->FL[0], "FL[0]");
- retval |= locked_or_not_in_tree(tb->CFL[0], "CFL[0]");
+ retval |= locked_or_not_in_tree(tb, tb->L[0], "L[0]");
+ retval |= locked_or_not_in_tree(tb, tb->FL[0], "FL[0]");
+ retval |= locked_or_not_in_tree(tb, tb->CFL[0], "CFL[0]");
check_leaf(tb->L[0]);
}
if (tb->rnum[0]) {
- retval |= locked_or_not_in_tree(tb->R[0], "R[0]");
- retval |= locked_or_not_in_tree(tb->FR[0], "FR[0]");
- retval |= locked_or_not_in_tree(tb->CFR[0], "CFR[0]");
+ retval |= locked_or_not_in_tree(tb, tb->R[0], "R[0]");
+ retval |= locked_or_not_in_tree(tb, tb->FR[0], "FR[0]");
+ retval |= locked_or_not_in_tree(tb, tb->CFR[0], "CFR[0]");
check_leaf(tb->R[0]);
}
- retval |= locked_or_not_in_tree(PATH_PLAST_BUFFER(tb->tb_path), "S[0]");
+ retval |= locked_or_not_in_tree(tb, PATH_PLAST_BUFFER(tb->tb_path),
+ "S[0]");
check_leaf(PATH_PLAST_BUFFER(tb->tb_path));
return retval;
@@ -1955,7 +1955,7 @@ static void check_after_balance_leaf(str
PATH_H_POSITION(tb->tb_path,
1))));
print_cur_tb("12223");
- reiserfs_warning(tb->tb_sb,
+ reiserfs_warning(tb->tb_sb, "reiserfs-12363",
"B_FREE_SPACE (PATH_H_PBUFFER(tb->tb_path,0)) = %d; "
"MAX_CHILD_SIZE (%d) - dc_size( %y, %d ) [%d] = %d",
left,
@@ -2107,9 +2107,8 @@ void do_balance(struct tree_balance *tb,
}
/* if we have no real work to do */
if (!tb->insert_size[0]) {
- reiserfs_warning(tb->tb_sb,
- "PAP-12350: do_balance: insert_size == 0, mode == %c",
- flag);
+ reiserfs_warning(tb->tb_sb, "PAP-12350",
+ "insert_size == 0, mode == %c", flag);
unfix_nodes(tb);
return;
}
--- a/fs/reiserfs/file.c 2007-06-11 14:49:05.000000000 -0400
+++ b/fs/reiserfs/file.c 2007-06-11 14:50:09.000000000 -0400
@@ -76,7 +76,7 @@ static int reiserfs_file_release(struct
* and let the admin know what is going on.
*/
igrab(inode);
- reiserfs_warning(inode->i_sb,
+ reiserfs_warning(inode->i_sb, "clm-9001",
"pinning inode %lu because the "
"preallocation can't be freed",
inode->i_ino);
@@ -397,7 +397,8 @@ static int reiserfs_allocate_blocks_for_
if (res != -ENOSPC) {
reiserfs_warning(inode->
i_sb,
- "green-9008: search_by_key (%K) returned %d",
+ "green-9008",
+ "search_by_key (%K) returned %d",
&key,
res);
}
@@ -599,7 +600,8 @@ static int reiserfs_allocate_blocks_for_
occured, we need to warn user and return error */
if (res != -ENOSPC) {
reiserfs_warning(inode->i_sb,
- "green-9009: search_by_key (%K) "
+ "green-9009",
+ "search_by_key (%K) "
"returned %d", &key,
res);
}
@@ -1015,8 +1017,7 @@ static int reiserfs_prepare_file_region_
int item_pos = -1; /* Position in indirect item */
if (num_pages < 1) {
- reiserfs_warning(inode->i_sb,
- "green-9001: reiserfs_prepare_file_region_for_write "
+ reiserfs_warning(inode->i_sb, "green-9001",
"called with zero number of pages to process");
return -EFAULT;
}
--- a/fs/reiserfs/fix_node.c 2007-06-11 14:49:05.000000000 -0400
+++ b/fs/reiserfs/fix_node.c 2007-06-11 14:50:09.000000000 -0400
@@ -496,8 +496,8 @@ static int get_num_ver(int mode, struct
snum012[needed_nodes - 1 + 3] = units;
if (needed_nodes > 2)
- reiserfs_warning(tb->tb_sb, "vs-8111: get_num_ver: "
- "split_item_position is out of boundary");
+ reiserfs_warning(tb->tb_sb, "vs-8111",
+ "split_item_position is out of range");
snum012[needed_nodes - 1]++;
split_item_positions[needed_nodes - 1] = i;
needed_nodes++;
@@ -533,8 +533,8 @@ static int get_num_ver(int mode, struct
if (vn->vn_vi[split_item_num].vi_index != TYPE_DIRENTRY &&
vn->vn_vi[split_item_num].vi_index != TYPE_INDIRECT)
- reiserfs_warning(tb->tb_sb, "vs-8115: get_num_ver: not "
- "directory or indirect item");
+ reiserfs_warning(tb->tb_sb, "vs-8115",
+ "not directory or indirect item");
}
/* now we know S2bytes, calculate S1bytes */
@@ -2266,9 +2266,9 @@ static int wait_tb_buffers_until_unlocke
#ifdef CONFIG_REISERFS_CHECK
repeat_counter++;
if ((repeat_counter % 10000) == 0) {
- reiserfs_warning(p_s_tb->tb_sb,
- "wait_tb_buffers_until_released(): too many "
- "iterations waiting for buffer to unlock "
+ reiserfs_warning(p_s_tb->tb_sb, "reiserfs-8200",
+ "too many iterations waiting "
+ "for buffer to unlock "
"(%b)", locked);
/* Don't loop forever. Try to recover from possible error. */
--- a/fs/reiserfs/inode.c 2007-06-11 14:49:05.000000000 -0400
+++ b/fs/reiserfs/inode.c 2007-06-11 14:50:09.000000000 -0400
@@ -838,7 +838,8 @@ int reiserfs_get_block(struct inode *ino
if (retval) {
if (retval != -ENOSPC)
reiserfs_warning(inode->i_sb,
- "clm-6004: convert tail failed inode %lu, error %d",
+ "clm-6004",
+ "convert tail failed inode %lu, error %d",
inode->i_ino,
retval);
if (allocated_block_nr) {
@@ -1002,8 +1003,7 @@ int reiserfs_get_block(struct inode *ino
goto failure;
}
if (retval == POSITION_FOUND) {
- reiserfs_warning(inode->i_sb,
- "vs-825: reiserfs_get_block: "
+ reiserfs_warning(inode->i_sb, "vs-825",
"%K should not be found", &key);
retval = -EEXIST;
if (allocated_block_nr)
@@ -1328,9 +1328,9 @@ void reiserfs_update_sd_size(struct reis
/* look for the object's stat data */
retval = search_item(inode->i_sb, &key, &path);
if (retval == IO_ERROR) {
- reiserfs_warning(inode->i_sb,
- "vs-13050: reiserfs_update_sd: "
- "i/o failure occurred trying to update %K stat data",
+ reiserfs_warning(inode->i_sb, "vs-13050",
+ "i/o failure occurred trying to "
+ "update %K stat data",
&key);
return;
}
@@ -1341,9 +1341,9 @@ void reiserfs_update_sd_size(struct reis
/*reiserfs_warning (inode->i_sb, "vs-13050: reiserfs_update_sd: i_nlink == 0, stat data not found"); */
return;
}
- reiserfs_warning(inode->i_sb,
- "vs-13060: reiserfs_update_sd: "
- "stat data of object %k (nlink == %d) not found (pos %d)",
+ reiserfs_warning(inode->i_sb, "vs-13060",
+ "stat data of object %k (nlink == %d) "
+ "not found (pos %d)",
INODE_PKEY(inode), inode->i_nlink,
pos);
reiserfs_check_path(&path);
@@ -1420,10 +1420,9 @@ void reiserfs_read_locked_inode(struct i
/* look for the object's stat data */
retval = search_item(inode->i_sb, &key, &path_to_sd);
if (retval == IO_ERROR) {
- reiserfs_warning(inode->i_sb,
- "vs-13070: reiserfs_read_locked_inode: "
- "i/o failure occurred trying to find stat data of %K",
- &key);
+ reiserfs_warning(inode->i_sb, "vs-13070",
+ "i/o failure occurred trying to find "
+ "stat data of %K", &key);
reiserfs_make_bad_inode(inode);
return;
}
@@ -1453,8 +1452,7 @@ void reiserfs_read_locked_inode(struct i
during mount (fs/reiserfs/super.c:finish_unfinished()). */
if ((inode->i_nlink == 0) &&
!REISERFS_SB(inode->i_sb)->s_is_unlinked_ok) {
- reiserfs_warning(inode->i_sb,
- "vs-13075: reiserfs_read_locked_inode: "
+ reiserfs_warning(inode->i_sb, "vs-13075",
"dead inode read from disk %K. "
"This is likely to be race with knfsd. Ignore",
&key);
@@ -1564,9 +1562,9 @@ struct dentry *reiserfs_decode_fh(struct
*/
if (fhtype > len) {
if (fhtype != 6 || len != 5)
- reiserfs_warning(sb,
- "nfsd/reiserfs, fhtype=%d, len=%d - odd",
- fhtype, len);
+ reiserfs_warning(sb, "reiserfs-13077",
+ "nfsd/reiserfs, fhtype=%d, "
+ "len=%d - odd", fhtype, len);
fhtype = 5;
}
@@ -1693,13 +1691,13 @@ static int reiserfs_new_directory(struct
/* look for place in the tree for new item */
retval = search_item(sb, &key, path);
if (retval == IO_ERROR) {
- reiserfs_warning(sb, "vs-13080: reiserfs_new_directory: "
+ reiserfs_warning(sb, "vs-13080",
"i/o failure occurred creating new directory");
return -EIO;
}
if (retval == ITEM_FOUND) {
pathrelse(path);
- reiserfs_warning(sb, "vs-13070: reiserfs_new_directory: "
+ reiserfs_warning(sb, "vs-13070",
"object with this key exists (%k)",
&(ih->ih_key));
return -EEXIST;
@@ -1733,13 +1731,13 @@ static int reiserfs_new_symlink(struct r
/* look for place in the tree for new item */
retval = search_item(sb, &key, path);
if (retval == IO_ERROR) {
- reiserfs_warning(sb, "vs-13080: reiserfs_new_symlinik: "
+ reiserfs_warning(sb, "vs-13080",
"i/o failure occurred creating new symlink");
return -EIO;
}
if (retval == ITEM_FOUND) {
pathrelse(path);
- reiserfs_warning(sb, "vs-13080: reiserfs_new_symlink: "
+ reiserfs_warning(sb, "vs-13080",
"object with this key exists (%k)",
&(ih->ih_key));
return -EEXIST;
@@ -1936,7 +1934,8 @@ int reiserfs_new_inode(struct reiserfs_t
goto out_inserted_sd;
}
} else if (inode->i_sb->s_flags & MS_POSIXACL) {
- reiserfs_warning(inode->i_sb, "ACLs aren't enabled in the fs, "
+ reiserfs_warning(inode->i_sb, "jdm-13090",
+ "ACLs aren't enabled in the fs, "
"but vfs thinks they are!");
} else if (is_reiserfs_priv_object(dir)) {
reiserfs_mark_inode_private(inode);
@@ -2053,8 +2052,8 @@ static int grab_tail_page(struct inode *
** I've screwed up the code to find the buffer, or the code to
** call prepare_write
*/
- reiserfs_warning(p_s_inode->i_sb,
- "clm-6000: error reading block %lu on dev %s",
+ reiserfs_warning(p_s_inode->i_sb, "clm-6000",
+ "error reading block %lu on dev %s",
bh->b_blocknr,
reiserfs_bdevname(p_s_inode->i_sb));
error = -EIO;
@@ -2098,8 +2097,8 @@ int reiserfs_truncate_file(struct inode
// and get_block_create_0 could not find a block to read in,
// which is ok.
if (error != -ENOENT)
- reiserfs_warning(p_s_inode->i_sb,
- "clm-6001: grab_tail_page failed %d",
+ reiserfs_warning(p_s_inode->i_sb, "clm-6001",
+ "grab_tail_page failed %d",
error);
page = NULL;
bh = NULL;
@@ -2217,9 +2216,8 @@ static int map_block_for_writepage(struc
/* we've found an unformatted node */
if (indirect_item_found(retval, ih)) {
if (bytes_copied > 0) {
- reiserfs_warning(inode->i_sb,
- "clm-6002: bytes_copied %d",
- bytes_copied);
+ reiserfs_warning(inode->i_sb, "clm-6002",
+ "bytes_copied %d", bytes_copied);
}
if (!get_block_num(item, pos_in_item)) {
/* crap, we are writing to a hole */
@@ -2276,9 +2274,8 @@ static int map_block_for_writepage(struc
goto research;
}
} else {
- reiserfs_warning(inode->i_sb,
- "clm-6003: bad item inode %lu, device %s",
- inode->i_ino, reiserfs_bdevname(inode->i_sb));
+ reiserfs_warning(inode->i_sb, "clm-6003",
+ "bad item inode %lu", inode->i_ino);
retval = -EIO;
goto out;
}
--- a/fs/reiserfs/item_ops.c 2007-06-11 14:49:05.000000000 -0400
+++ b/fs/reiserfs/item_ops.c 2007-06-11 14:50:09.000000000 -0400
@@ -97,7 +97,8 @@ static int sd_unit_num(struct virtual_it
static void sd_print_vi(struct virtual_item *vi)
{
- reiserfs_warning(NULL, "STATDATA, index %d, type 0x%x, %h",
+ reiserfs_warning(NULL, "reiserfs-16100",
+ "STATDATA, index %d, type 0x%x, %h",
vi->vi_index, vi->vi_type, vi->vi_ih);
}
@@ -190,7 +191,8 @@ static int direct_unit_num(struct virtua
static void direct_print_vi(struct virtual_item *vi)
{
- reiserfs_warning(NULL, "DIRECT, index %d, type 0x%x, %h",
+ reiserfs_warning(NULL, "reiserfs-16101",
+ "DIRECT, index %d, type 0x%x, %h",
vi->vi_index, vi->vi_type, vi->vi_ih);
}
@@ -278,7 +280,7 @@ static void indirect_print_item(struct i
unp = (__le32 *) item;
if (ih_item_len(ih) % UNFM_P_SIZE)
- reiserfs_warning(NULL, "indirect_print_item: invalid item len");
+ reiserfs_warning(NULL, "reiserfs-16102", "invalid item len");
printk("%d pointers\n[ ", (int)I_UNFM_NUM(ih));
for (j = 0; j < I_UNFM_NUM(ih); j++) {
@@ -334,7 +336,8 @@ static int indirect_unit_num(struct virt
static void indirect_print_vi(struct virtual_item *vi)
{
- reiserfs_warning(NULL, "INDIRECT, index %d, type 0x%x, %h",
+ reiserfs_warning(NULL, "reiserfs-16103",
+ "INDIRECT, index %d, type 0x%x, %h",
vi->vi_index, vi->vi_type, vi->vi_ih);
}
@@ -359,7 +362,7 @@ static struct item_operations indirect_o
static int direntry_bytes_number(struct item_head *ih, int block_size)
{
- reiserfs_warning(NULL, "vs-16090: direntry_bytes_number: "
+ reiserfs_warning(NULL, "vs-16090",
"bytes number is asked for direntry");
return 0;
}
@@ -614,7 +617,8 @@ static void direntry_print_vi(struct vir
int i;
struct direntry_uarea *dir_u = vi->vi_uarea;
- reiserfs_warning(NULL, "DIRENTRY, index %d, type 0x%x, %h, flags 0x%x",
+ reiserfs_warning(NULL, "reiserfs-16104",
+ "DIRENTRY, index %d, type 0x%x, %h, flags 0x%x",
vi->vi_index, vi->vi_type, vi->vi_ih, dir_u->flags);
printk("%d entries: ", dir_u->entry_count);
for (i = 0; i < dir_u->entry_count; i++)
@@ -642,43 +646,43 @@ static struct item_operations direntry_o
//
static int errcatch_bytes_number(struct item_head *ih, int block_size)
{
- reiserfs_warning(NULL,
- "green-16001: Invalid item type observed, run fsck ASAP");
+ reiserfs_warning(NULL, "green-16001",
+ "Invalid item type observed, run fsck ASAP");
return 0;
}
static void errcatch_decrement_key(struct cpu_key *key)
{
- reiserfs_warning(NULL,
- "green-16002: Invalid item type observed, run fsck ASAP");
+ reiserfs_warning(NULL, "green-16002",
+ "Invalid item type observed, run fsck ASAP");
}
static int errcatch_is_left_mergeable(struct reiserfs_key *key,
unsigned long bsize)
{
- reiserfs_warning(NULL,
- "green-16003: Invalid item type observed, run fsck ASAP");
+ reiserfs_warning(NULL, "green-16003",
+ "Invalid item type observed, run fsck ASAP");
return 0;
}
static void errcatch_print_item(struct item_head *ih, char *item)
{
- reiserfs_warning(NULL,
- "green-16004: Invalid item type observed, run fsck ASAP");
+ reiserfs_warning(NULL, "green-16004",
+ "Invalid item type observed, run fsck ASAP");
}
static void errcatch_check_item(struct item_head *ih, char *item)
{
- reiserfs_warning(NULL,
- "green-16005: Invalid item type observed, run fsck ASAP");
+ reiserfs_warning(NULL, "green-16005",
+ "Invalid item type observed, run fsck ASAP");
}
static int errcatch_create_vi(struct virtual_node *vn,
struct virtual_item *vi,
int is_affected, int insert_size)
{
- reiserfs_warning(NULL,
- "green-16006: Invalid item type observed, run fsck ASAP");
+ reiserfs_warning(NULL, "green-16006",
+ "Invalid item type observed, run fsck ASAP");
return 0; // We might return -1 here as well, but it won't help as create_virtual_node() from where
// this operation is called from is of return type void.
}
@@ -686,36 +690,36 @@ static int errcatch_create_vi(struct vir
static int errcatch_check_left(struct virtual_item *vi, int free,
int start_skip, int end_skip)
{
- reiserfs_warning(NULL,
- "green-16007: Invalid item type observed, run fsck ASAP");
+ reiserfs_warning(NULL, "green-16007",
+ "Invalid item type observed, run fsck ASAP");
return -1;
}
static int errcatch_check_right(struct virtual_item *vi, int free)
{
- reiserfs_warning(NULL,
- "green-16008: Invalid item type observed, run fsck ASAP");
+ reiserfs_warning(NULL, "green-16008",
+ "Invalid item type observed, run fsck ASAP");
return -1;
}
static int errcatch_part_size(struct virtual_item *vi, int first, int count)
{
- reiserfs_warning(NULL,
- "green-16009: Invalid item type observed, run fsck ASAP");
+ reiserfs_warning(NULL, "green-16009",
+ "Invalid item type observed, run fsck ASAP");
return 0;
}
static int errcatch_unit_num(struct virtual_item *vi)
{
- reiserfs_warning(NULL,
- "green-16010: Invalid item type observed, run fsck ASAP");
+ reiserfs_warning(NULL, "green-16010",
+ "Invalid item type observed, run fsck ASAP");
return 0;
}
static void errcatch_print_vi(struct virtual_item *vi)
{
- reiserfs_warning(NULL,
- "green-16011: Invalid item type observed, run fsck ASAP");
+ reiserfs_warning(NULL, "green-16011",
+ "Invalid item type observed, run fsck ASAP");
}
static struct item_operations errcatch_ops = {
--- a/fs/reiserfs/journal.c 2007-06-11 14:49:05.000000000 -0400
+++ b/fs/reiserfs/journal.c 2007-06-11 14:50:09.000000000 -0400
@@ -301,8 +301,8 @@ int reiserfs_allocate_list_bitmaps(struc
jb->journal_list = NULL;
jb->bitmaps = vmalloc(mem);
if (!jb->bitmaps) {
- reiserfs_warning(p_s_sb,
- "clm-2000, unable to allocate bitmaps for journal lists");
+ reiserfs_warning(p_s_sb, "clm-2000", "unable to "
+ "allocate bitmaps for journal lists");
failed = 1;
break;
}
@@ -620,8 +620,8 @@ static void reiserfs_end_buffer_io_sync(
char b[BDEVNAME_SIZE];
if (buffer_journaled(bh)) {
- reiserfs_warning(NULL,
- "clm-2084: pinned buffer %lu:%s sent to disk",
+ reiserfs_warning(NULL, "clm-2084",
+ "pinned buffer %lu:%s sent to disk",
bh->b_blocknr, bdevname(bh->b_bdev, b));
}
if (uptodate)
@@ -1096,7 +1096,8 @@ static int flush_commit_list(struct supe
sync_dirty_buffer(tbh);
if (unlikely(!buffer_uptodate(tbh))) {
#ifdef CONFIG_REISERFS_CHECK
- reiserfs_warning(s, "journal-601, buffer write failed");
+ reiserfs_warning(s, "journal-601",
+ "buffer write failed");
#endif
retval = -EIO;
}
@@ -1128,14 +1129,14 @@ static int flush_commit_list(struct supe
* up propagating the write error out to the filesystem. */
if (unlikely(!buffer_uptodate(jl->j_commit_bh))) {
#ifdef CONFIG_REISERFS_CHECK
- reiserfs_warning(s, "journal-615: buffer write failed");
+ reiserfs_warning(s, "journal-615", "buffer write failed");
#endif
retval = -EIO;
}
bforget(jl->j_commit_bh);
if (journal->j_last_commit_id != 0 &&
(jl->j_trans_id - journal->j_last_commit_id) != 1) {
- reiserfs_warning(s, "clm-2200: last commit %lu, current %lu",
+ reiserfs_warning(s, "clm-2200", "last commit %lu, current %lu",
journal->j_last_commit_id, jl->j_trans_id);
}
journal->j_last_commit_id = jl->j_trans_id;
@@ -1224,7 +1225,7 @@ static void remove_all_from_journal_list
while (cn) {
if (cn->blocknr != 0) {
if (debug) {
- reiserfs_warning(p_s_sb,
+ reiserfs_warning(p_s_sb, "reiserfs-2201",
"block %u, bh is %d, state %ld",
cn->blocknr, cn->bh ? 1 : 0,
cn->state);
@@ -1262,8 +1263,8 @@ static int _update_journal_header_block(
wait_on_buffer((journal->j_header_bh));
if (unlikely(!buffer_uptodate(journal->j_header_bh))) {
#ifdef CONFIG_REISERFS_CHECK
- reiserfs_warning(p_s_sb,
- "journal-699: buffer write failed");
+ reiserfs_warning(p_s_sb, "journal-699",
+ "buffer write failed");
#endif
return -EIO;
}
@@ -1293,8 +1294,8 @@ static int _update_journal_header_block(
sync_dirty_buffer(journal->j_header_bh);
}
if (!buffer_uptodate(journal->j_header_bh)) {
- reiserfs_warning(p_s_sb,
- "journal-837: IO error during journal replay");
+ reiserfs_warning(p_s_sb, "journal-837",
+ "IO error during journal replay");
return -EIO;
}
}
@@ -1375,8 +1376,7 @@ static int flush_journal_list(struct sup
BUG_ON(j_len_saved <= 0);
if (atomic_read(&journal->j_wcount) != 0) {
- reiserfs_warning(s,
- "clm-2048: flush_journal_list called with wcount %d",
+ reiserfs_warning(s, "clm-2048", "called with wcount %d",
atomic_read(&journal->j_wcount));
}
BUG_ON(jl->j_trans_id == 0);
@@ -1484,8 +1484,8 @@ static int flush_journal_list(struct sup
** is not marked JDirty_wait
*/
if ((!was_jwait) && !buffer_locked(saved_bh)) {
- reiserfs_warning(s,
- "journal-813: BAD! buffer %llu %cdirty %cjwait, "
+ reiserfs_warning(s, "journal-813",
+ "BAD! buffer %llu %cdirty %cjwait, "
"not in a newer tranasction",
(unsigned long long)saved_bh->
b_blocknr, was_dirty ? ' ' : '!',
@@ -1503,8 +1503,8 @@ static int flush_journal_list(struct sup
unlock_buffer(saved_bh);
count++;
} else {
- reiserfs_warning(s,
- "clm-2082: Unable to flush buffer %llu in %s",
+ reiserfs_warning(s, "clm-2082",
+ "Unable to flush buffer %llu in %s",
(unsigned long long)saved_bh->
b_blocknr, __FUNCTION__);
}
@@ -1515,8 +1515,8 @@ static int flush_journal_list(struct sup
/* we incremented this to keep others from taking the buffer head away */
put_bh(saved_bh);
if (atomic_read(&(saved_bh->b_count)) < 0) {
- reiserfs_warning(s,
- "journal-945: saved_bh->b_count < 0");
+ reiserfs_warning(s, "journal-945",
+ "saved_bh->b_count < 0");
}
}
}
@@ -1535,8 +1535,8 @@ static int flush_journal_list(struct sup
}
if (unlikely(!buffer_uptodate(cn->bh))) {
#ifdef CONFIG_REISERFS_CHECK
- reiserfs_warning(s,
- "journal-949: buffer write failed\n");
+ reiserfs_warning(s, "journal-949",
+ "buffer write failed");
#endif
err = -EIO;
}
@@ -1596,7 +1596,7 @@ static int flush_journal_list(struct sup
if (journal->j_last_flush_id != 0 &&
(jl->j_trans_id - journal->j_last_flush_id) != 1) {
- reiserfs_warning(s, "clm-2201: last flush %lu, current %lu",
+ reiserfs_warning(s, "clm-2201", "last flush %lu, current %lu",
journal->j_last_flush_id, jl->j_trans_id);
}
journal->j_last_flush_id = jl->j_trans_id;
@@ -2031,8 +2031,9 @@ static int journal_transaction_is_valid(
return -1;
}
if (get_desc_trans_len(desc) > SB_JOURNAL(p_s_sb)->j_trans_max) {
- reiserfs_warning(p_s_sb,
- "journal-2018: Bad transaction length %d encountered, ignoring transaction",
+ reiserfs_warning(p_s_sb, "journal-2018",
+ "Bad transaction length %d "
+ "encountered, ignoring transaction",
get_desc_trans_len(desc));
return -1;
}
@@ -2168,8 +2169,8 @@ static int journal_read_transaction(stru
brelse(d_bh);
kfree(log_blocks);
kfree(real_blocks);
- reiserfs_warning(p_s_sb,
- "journal-1169: kmalloc failed, unable to mount FS");
+ reiserfs_warning(p_s_sb, "journal-1169",
+ "kmalloc failed, unable to mount FS");
return -1;
}
/* get all the buffer heads */
@@ -2191,15 +2192,18 @@ static int journal_read_transaction(stru
j_realblock[i - trans_half]));
}
if (real_blocks[i]->b_blocknr > SB_BLOCK_COUNT(p_s_sb)) {
- reiserfs_warning(p_s_sb,
- "journal-1207: REPLAY FAILURE fsck required! Block to replay is outside of filesystem");
+ reiserfs_warning(p_s_sb, "journal-1207",
+ "REPLAY FAILURE fsck required! "
+ "Block to replay is outside of "
+ "filesystem");
goto abort_replay;
}
/* make sure we don't try to replay onto log or reserved area */
if (is_block_in_log_or_reserved_area
(p_s_sb, real_blocks[i]->b_blocknr)) {
- reiserfs_warning(p_s_sb,
- "journal-1204: REPLAY FAILURE fsck required! Trying to replay onto a log block");
+ reiserfs_warning(p_s_sb, "journal-1204",
+ "REPLAY FAILURE fsck required! "
+ "Trying to replay onto a log block");
abort_replay:
brelse_array(log_blocks, i);
brelse_array(real_blocks, i);
@@ -2215,8 +2219,9 @@ static int journal_read_transaction(stru
for (i = 0; i < get_desc_trans_len(desc); i++) {
wait_on_buffer(log_blocks[i]);
if (!buffer_uptodate(log_blocks[i])) {
- reiserfs_warning(p_s_sb,
- "journal-1212: REPLAY FAILURE fsck required! buffer write failed");
+ reiserfs_warning(p_s_sb, "journal-1212",
+ "REPLAY FAILURE fsck required! "
+ "buffer write failed");
brelse_array(log_blocks + i,
get_desc_trans_len(desc) - i);
brelse_array(real_blocks, get_desc_trans_len(desc));
@@ -2239,8 +2244,9 @@ static int journal_read_transaction(stru
for (i = 0; i < get_desc_trans_len(desc); i++) {
wait_on_buffer(real_blocks[i]);
if (!buffer_uptodate(real_blocks[i])) {
- reiserfs_warning(p_s_sb,
- "journal-1226: REPLAY FAILURE, fsck required! buffer write failed");
+ reiserfs_warning(p_s_sb, "journal-1226",
+ "REPLAY FAILURE, fsck required! "
+ "buffer write failed");
brelse_array(real_blocks + i,
get_desc_trans_len(desc) - i);
brelse(c_bh);
@@ -2390,8 +2396,8 @@ static int journal_read(struct super_blo
}
if (continue_replay && bdev_read_only(p_s_sb->s_bdev)) {
- reiserfs_warning(p_s_sb,
- "clm-2076: device is readonly, unable to replay log");
+ reiserfs_warning(p_s_sb, "clm-2076",
+ "device is readonly, unable to replay log");
return -1;
}
@@ -2554,9 +2560,8 @@ static int release_journal_dev(struct su
}
if (result != 0) {
- reiserfs_warning(super,
- "sh-457: release_journal_dev: Cannot release journal device: %i",
- result);
+ reiserfs_warning(super, "sh-457",
+ "Cannot release journal device: %i", result);
}
return result;
}
@@ -2586,7 +2591,7 @@ static int journal_init_dev(struct super
if (IS_ERR(journal->j_dev_bd)) {
result = PTR_ERR(journal->j_dev_bd);
journal->j_dev_bd = NULL;
- reiserfs_warning(super, "sh-458: journal_init_dev: "
+ reiserfs_warning(super, "sh-458",
"cannot init journal device '%s': %i",
__bdevname(jdev, b), result);
return result;
@@ -2599,7 +2604,7 @@ static int journal_init_dev(struct super
if (!IS_ERR(journal->j_dev_file)) {
struct inode *jdev_inode = journal->j_dev_file->f_mapping->host;
if (!S_ISBLK(jdev_inode->i_mode)) {
- reiserfs_warning(super, "journal_init_dev: '%s' is "
+ reiserfs_warning(super, "reiserfs-459", "'%s' is "
"not a block device", jdev_name);
result = -ENOTBLK;
release_journal_dev(super, journal);
@@ -2614,8 +2619,7 @@ static int journal_init_dev(struct super
} else {
result = PTR_ERR(journal->j_dev_file);
journal->j_dev_file = NULL;
- reiserfs_warning(super,
- "journal_init_dev: Cannot open '%s': %i",
+ reiserfs_warning(super, "reiserfs-460", "Cannot open '%s': %i",
jdev_name, result);
}
return result;
@@ -2637,8 +2641,8 @@ int journal_init(struct super_block *p_s
journal = SB_JOURNAL(p_s_sb) = vmalloc(sizeof(struct reiserfs_journal));
if (!journal) {
- reiserfs_warning(p_s_sb,
- "journal-1256: unable to get memory for journal structure");
+ reiserfs_warning(p_s_sb, "journal-1256",
+ "unable to get memory for journal structure");
return 1;
}
memset(journal, 0, sizeof(struct reiserfs_journal));
@@ -2667,9 +2671,9 @@ int journal_init(struct super_block *p_s
if (!SB_ONDISK_JOURNAL_DEVICE(p_s_sb) &&
(SB_JOURNAL_1st_RESERVED_BLOCK(p_s_sb) +
SB_ONDISK_JOURNAL_SIZE(p_s_sb) > p_s_sb->s_blocksize * 8)) {
- reiserfs_warning(p_s_sb,
- "journal-1393: journal does not fit for area "
- "addressed by first of bitmap blocks. It starts at "
+ reiserfs_warning(p_s_sb, "journal-1393",
+ "journal does not fit for area addressed "
+ "by first of bitmap blocks. It starts at "
"%u and its size is %u. Block size %ld",
SB_JOURNAL_1st_RESERVED_BLOCK(p_s_sb),
SB_ONDISK_JOURNAL_SIZE(p_s_sb),
@@ -2678,8 +2682,8 @@ int journal_init(struct super_block *p_s
}
if (journal_init_dev(p_s_sb, journal, j_dev_name) != 0) {
- reiserfs_warning(p_s_sb,
- "sh-462: unable to initialize jornal device");
+ reiserfs_warning(p_s_sb, "sh-462",
+ "unable to initialize jornal device");
goto free_and_return;
}
@@ -2690,8 +2694,8 @@ int journal_init(struct super_block *p_s
SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) +
SB_ONDISK_JOURNAL_SIZE(p_s_sb));
if (!bhjh) {
- reiserfs_warning(p_s_sb,
- "sh-459: unable to read journal header");
+ reiserfs_warning(p_s_sb, "sh-459",
+ "unable to read journal header");
goto free_and_return;
}
jh = (struct reiserfs_journal_header *)(bhjh->b_data);
@@ -2700,10 +2704,10 @@ int journal_init(struct super_block *p_s
if (is_reiserfs_jr(rs)
&& (le32_to_cpu(jh->jh_journal.jp_journal_magic) !=
sb_jp_journal_magic(rs))) {
- reiserfs_warning(p_s_sb,
- "sh-460: journal header magic %x "
- "(device %s) does not match to magic found in super "
- "block %x", jh->jh_journal.jp_journal_magic,
+ reiserfs_warning(p_s_sb, "sh-460",
+ "journal header magic %x (device %s) does "
+ "not match to magic found in super block %x",
+ jh->jh_journal.jp_journal_magic,
bdevname(journal->j_dev_bd, b),
sb_jp_journal_magic(rs));
brelse(bhjh);
@@ -2736,8 +2740,9 @@ int journal_init(struct super_block *p_s
JOURNAL_TRANS_MIN_DEFAULT / ratio;
if (journal->j_trans_max != initial)
- reiserfs_warning(p_s_sb,
- "sh-461: journal_init: wrong transaction max size (%u). Changed to %u",
+ reiserfs_warning(p_s_sb, "sh-461",
+ "wrong transaction max size (%u). "
+ "Changed to %u",
initial, journal->j_trans_max);
journal->j_max_batch = journal->j_trans_max *
@@ -2811,7 +2816,7 @@ int journal_init(struct super_block *p_s
journal->j_must_wait = 0;
if (journal->j_cnode_free == 0) {
- reiserfs_warning(p_s_sb, "journal-2004: Journal cnode memory "
+ reiserfs_warning(p_s_sb, "journal-2004", "Journal cnode memory "
"allocation failed (%ld bytes). Journal is "
"too large for available memory. Usually "
"this is due to a journal that is too large.",
@@ -2823,12 +2828,13 @@ int journal_init(struct super_block *p_s
jl = journal->j_current_jl;
jl->j_list_bitmap = get_list_bitmap(p_s_sb, jl);
if (!jl->j_list_bitmap) {
- reiserfs_warning(p_s_sb,
- "journal-2005, get_list_bitmap failed for journal list 0");
+ reiserfs_warning(p_s_sb, "journal-2005",
+ "get_list_bitmap failed for journal list 0");
goto free_and_return;
}
if (journal_read(p_s_sb) < 0) {
- reiserfs_warning(p_s_sb, "Replay Failure, unable to mount");
+ reiserfs_warning(p_s_sb, "reiserfs-2006",
+ "Replay Failure, unable to mount");
goto free_and_return;
}
@@ -3155,16 +3161,17 @@ int journal_begin(struct reiserfs_transa
cur_th->t_refcount++;
memcpy(th, cur_th, sizeof(*th));
if (th->t_refcount <= 1)
- reiserfs_warning(p_s_sb,
- "BAD: refcount <= 1, but journal_info != 0");
+ reiserfs_warning(p_s_sb, "reiserfs-2005",
+ "BAD: refcount <= 1, but "
+ "journal_info != 0");
return 0;
} else {
/* we've ended up with a handle from a different filesystem.
** save it and restore on journal_end. This should never
** really happen...
*/
- reiserfs_warning(p_s_sb,
- "clm-2100: nesting info a different FS");
+ reiserfs_warning(p_s_sb, "clm-2100",
+ "nesting info a different FS");
th->t_handle_save = current->journal_info;
current->journal_info = th;
}
@@ -3225,7 +3232,8 @@ int journal_mark_dirty(struct reiserfs_t
** could get to disk too early. NOT GOOD.
*/
if (!prepared || buffer_dirty(bh)) {
- reiserfs_warning(p_s_sb, "journal-1777: buffer %llu bad state "
+ reiserfs_warning(p_s_sb, "journal-1777",
+ "buffer %llu bad state "
"%cPREPARED %cLOCKED %cDIRTY %cJDIRTY_WAIT",
(unsigned long long)bh->b_blocknr,
prepared ? ' ' : '!',
@@ -3235,8 +3243,8 @@ int journal_mark_dirty(struct reiserfs_t
}
if (atomic_read(&(journal->j_wcount)) <= 0) {
- reiserfs_warning(p_s_sb,
- "journal-1409: journal_mark_dirty returning because j_wcount was %d",
+ reiserfs_warning(p_s_sb, "journal-1409",
+ "returning because j_wcount was %d",
atomic_read(&(journal->j_wcount)));
return 1;
}
@@ -3301,8 +3309,8 @@ int journal_end(struct reiserfs_transact
struct super_block *p_s_sb, unsigned long nblocks)
{
if (!current->journal_info && th->t_refcount > 1)
- reiserfs_warning(p_s_sb, "REISER-NESTING: th NULL, refcount %d",
- th->t_refcount);
+ reiserfs_warning(p_s_sb, "REISER-NESTING",
+ "th NULL, refcount %d", th->t_refcount);
if (!th->t_trans_id) {
WARN_ON(1);
@@ -3372,8 +3380,8 @@ static int remove_from_transaction(struc
clear_buffer_journal_test(bh);
put_bh(bh);
if (atomic_read(&(bh->b_count)) < 0) {
- reiserfs_warning(p_s_sb,
- "journal-1752: remove from trans, b_count < 0");
+ reiserfs_warning(p_s_sb, "journal-1752",
+ "b_count < 0");
}
ret = 1;
}
@@ -3693,7 +3701,8 @@ int journal_mark_freed(struct reiserfs_t
if (atomic_read
(&(cn->bh->b_count)) < 0) {
reiserfs_warning(p_s_sb,
- "journal-2138: cn->bh->b_count < 0");
+ "journal-2138",
+ "cn->bh->b_count < 0");
}
}
if (cn->jlist) { /* since we are clearing the bh, we MUST dec nonzerolen */
@@ -3711,8 +3720,8 @@ int journal_mark_freed(struct reiserfs_t
if (bh) {
put_bh(bh); /* get_hash grabs the buffer */
if (atomic_read(&(bh->b_count)) < 0) {
- reiserfs_warning(p_s_sb,
- "journal-2165: bh->b_count < 0");
+ reiserfs_warning(p_s_sb, "journal-2165",
+ "bh->b_count < 0");
}
}
return 0;
@@ -4101,8 +4110,9 @@ static int do_journal_end(struct reiserf
clear_buffer_journaled(cn->bh);
} else {
/* JDirty cleared sometime during transaction. don't log this one */
- reiserfs_warning(p_s_sb,
- "journal-2048: do_journal_end: BAD, buffer in journal hash, but not JDirty!");
+ reiserfs_warning(p_s_sb, "journal-2048",
+ "BAD, buffer in journal hash, "
+ "but not JDirty!");
brelse(cn->bh);
}
next = cn->next;
--- a/fs/reiserfs/lbalance.c 2007-06-11 14:49:05.000000000 -0400
+++ b/fs/reiserfs/lbalance.c 2007-06-11 14:50:09.000000000 -0400
@@ -1287,12 +1287,16 @@ void leaf_paste_entries(struct buffer_he
prev = (i != 0) ? deh_location(&(deh[i - 1])) : 0;
if (prev && prev <= deh_location(&(deh[i])))
- reiserfs_warning(NULL,
- "vs-10240: leaf_paste_entries: directory item (%h) corrupted (prev %a, cur(%d) %a)",
+ reiserfs_warning(NULL, "vs-10240",
+ "directory item (%h) "
+ "corrupted (prev %a, "
+ "cur(%d) %a)",
ih, deh + i - 1, i, deh + i);
if (next && next >= deh_location(&(deh[i])))
- reiserfs_warning(NULL,
- "vs-10250: leaf_paste_entries: directory item (%h) corrupted (cur(%d) %a, next %a)",
+ reiserfs_warning(NULL, "vs-10250",
+ "directory item (%h) "
+ "corrupted (cur(%d) %a, "
+ "next %a)",
ih, i, deh + i, deh + i + 1);
}
}
--- a/fs/reiserfs/namei.c 2007-06-11 14:49:05.000000000 -0400
+++ b/fs/reiserfs/namei.c 2007-06-11 14:50:09.000000000 -0400
@@ -120,8 +120,8 @@ int search_by_entry_key(struct super_blo
switch (retval) {
case ITEM_NOT_FOUND:
if (!PATH_LAST_POSITION(path)) {
- reiserfs_warning(sb,
- "vs-7000: search_by_entry_key: search_by_key returned item position == 0");
+ reiserfs_warning(sb, "vs-7000", "search_by_key "
+ "returned item position == 0");
pathrelse(path);
return IO_ERROR;
}
@@ -135,8 +135,7 @@ int search_by_entry_key(struct super_blo
default:
pathrelse(path);
- reiserfs_warning(sb,
- "vs-7002: search_by_entry_key: no path to here");
+ reiserfs_warning(sb, "vs-7002", "no path to here");
return IO_ERROR;
}
@@ -300,8 +299,7 @@ static int reiserfs_find_entry(struct in
search_by_entry_key(dir->i_sb, &key_to_search,
path_to_entry, de);
if (retval == IO_ERROR) {
- reiserfs_warning(dir->i_sb, "zam-7001: io error in %s",
- __FUNCTION__);
+ reiserfs_warning(dir->i_sb, "zam-7001", "io error");
return IO_ERROR;
}
@@ -493,10 +491,9 @@ static int reiserfs_add_entry(struct rei
}
if (retval != NAME_FOUND) {
- reiserfs_warning(dir->i_sb,
- "zam-7002:%s: \"reiserfs_find_entry\" "
- "has returned unexpected value (%d)",
- __FUNCTION__, retval);
+ reiserfs_warning(dir->i_sb, "zam-7002",
+ "reiserfs_find_entry() returned "
+ "unexpected value (%d)", retval);
}
return -EEXIST;
@@ -507,8 +504,9 @@ static int reiserfs_add_entry(struct rei
MAX_GENERATION_NUMBER + 1);
if (gen_number > MAX_GENERATION_NUMBER) {
/* there is no free generation number */
- reiserfs_warning(dir->i_sb,
- "reiserfs_add_entry: Congratulations! we have got hash function screwed up");
+ reiserfs_warning(dir->i_sb, "reiserfs-7010",
+ "Congratulations! we have got hash function "
+ "screwed up");
if (buffer != small_buf)
kfree(buffer);
pathrelse(&path);
@@ -524,10 +522,9 @@ static int reiserfs_add_entry(struct rei
if (gen_number != 0) { /* we need to re-search for the insertion point */
if (search_by_entry_key(dir->i_sb, &entry_key, &path, &de) !=
NAME_NOT_FOUND) {
- reiserfs_warning(dir->i_sb,
- "vs-7032: reiserfs_add_entry: "
- "entry with this key (%K) already exists",
- &entry_key);
+ reiserfs_warning(dir->i_sb, "vs-7032",
+ "entry with this key (%K) already "
+ "exists", &entry_key);
if (buffer != small_buf)
kfree(buffer);
@@ -906,8 +903,9 @@ static int reiserfs_rmdir(struct inode *
goto end_rmdir;
if (inode->i_nlink != 2 && inode->i_nlink != 1)
- reiserfs_warning(inode->i_sb, "%s: empty directory has nlink "
- "!= 2 (%d)", __FUNCTION__, inode->i_nlink);
+ reiserfs_warning(inode->i_sb, "reiserfs-7040",
+ "empty directory has nlink != 2 (%d)",
+ inode->i_nlink);
clear_nlink(inode);
inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC;
@@ -983,10 +981,9 @@ static int reiserfs_unlink(struct inode
}
if (!inode->i_nlink) {
- reiserfs_warning(inode->i_sb, "%s: deleting nonexistent file "
- "(%s:%lu), %d", __FUNCTION__,
- reiserfs_bdevname(inode->i_sb), inode->i_ino,
- inode->i_nlink);
+ reiserfs_warning(inode->i_sb, "reiserfs-7042",
+ "deleting nonexistent file (%lu), %d",
+ inode->i_ino, inode->i_nlink);
inode->i_nlink = 1;
}
@@ -1500,8 +1497,8 @@ static int reiserfs_rename(struct inode
if (reiserfs_cut_from_item
(&th, &old_entry_path, &(old_de.de_entry_key), old_dir, NULL,
0) < 0)
- reiserfs_warning(old_dir->i_sb,
- "vs-7060: reiserfs_rename: couldn't not cut old name. Fsck later?");
+ reiserfs_warning(old_dir->i_sb, "vs-7060",
+ "couldn't not cut old name. Fsck later?");
old_dir->i_size -= DEH_SIZE + old_de.de_entrylen;
--- a/fs/reiserfs/objectid.c 2007-06-11 14:49:05.000000000 -0400
+++ b/fs/reiserfs/objectid.c 2007-06-11 14:50:09.000000000 -0400
@@ -61,7 +61,7 @@ __u32 reiserfs_get_unused_objectid(struc
/* comment needed -Hans */
unused_objectid = le32_to_cpu(map[1]);
if (unused_objectid == U32_MAX) {
- reiserfs_warning(s, "%s: no more object ids", __FUNCTION__);
+ reiserfs_warning(s, "reiserfs-15100", "no more object ids");
reiserfs_restore_prepared_buffer(s, SB_BUFFER_WITH_SB(s));
return 0;
}
@@ -161,8 +161,7 @@ void reiserfs_release_objectid(struct re
i += 2;
}
- reiserfs_warning(s,
- "vs-15011: reiserfs_release_objectid: tried to free free object id (%lu)",
+ reiserfs_warning(s, "vs-15011", "tried to free free object id (%lu)",
(long unsigned)objectid_to_release);
}
--- a/fs/reiserfs/prints.c 2007-06-11 14:49:33.000000000 -0400
+++ b/fs/reiserfs/prints.c 2007-06-11 14:50:09.000000000 -0400
@@ -264,14 +264,17 @@ static void prepare_error_buf(const char
va_end( args );\
}
-void reiserfs_warning(struct super_block *sb, const char *fmt, ...)
+void __reiserfs_warning(struct super_block *sb, const char *id,
+ const char *function, const char *fmt, ...)
{
do_reiserfs_warning(fmt);
if (sb)
- printk(KERN_WARNING "REISERFS warning (device %s): %s\n",
- sb->s_id, error_buf);
+ printk(KERN_WARNING "REISERFS warning (device %s): %s%s%s: %s\n",
+ sb->s_id, id ? id : "", id ? " " : "",
+ function, error_buf);
else
- printk(KERN_WARNING "REISERFS warning: %s\n", error_buf);
+ printk(KERN_WARNING "REISERFS warning: %s%s%s: %s\n",
+ id ? id : "", id ? " " : "", function, error_buf);
}
/* No newline.. reiserfs_info calls can be followed by printk's */
--- a/fs/reiserfs/procfs.c 2007-06-11 14:49:05.000000000 -0400
+++ b/fs/reiserfs/procfs.c 2007-06-11 14:50:04.000000000 -0400
@@ -514,7 +514,7 @@ int reiserfs_proc_info_init(struct super
add_file(sb, "journal", show_journal);
return 0;
}
- reiserfs_warning(sb, "reiserfs: cannot create /proc/%s/%s",
+ reiserfs_warning(sb, "cannot create /proc/%s/%s",
proc_info_root_name, b);
return 1;
}
@@ -570,8 +570,7 @@ int reiserfs_proc_info_global_init(void)
if (proc_info_root) {
proc_info_root->owner = THIS_MODULE;
} else {
- reiserfs_warning(NULL,
- "reiserfs: cannot create /proc/%s",
+ reiserfs_warning(NULL, "cannot create /proc/%s",
proc_info_root_name);
return 1;
}
--- a/fs/reiserfs/stree.c 2007-06-11 14:49:05.000000000 -0400
+++ b/fs/reiserfs/stree.c 2007-06-11 14:50:09.000000000 -0400
@@ -444,23 +444,24 @@ static int is_leaf(char *buf, int blocks
blkh = (struct block_head *)buf;
if (blkh_level(blkh) != DISK_LEAF_NODE_LEVEL) {
- reiserfs_warning(NULL,
- "is_leaf: this should be caught earlier");
+ reiserfs_warning(NULL, "reiserfs-5080",
+ "this should be caught earlier");
return 0;
}
nr = blkh_nr_item(blkh);
if (nr < 1 || nr > ((blocksize - BLKH_SIZE) / (IH_SIZE + MIN_ITEM_LEN))) {
/* item number is too big or too small */
- reiserfs_warning(NULL, "is_leaf: nr_item seems wrong: %z", bh);
+ reiserfs_warning(NULL, "reiserfs-5081",
+ "nr_item seems wrong: %z", bh);
return 0;
}
ih = (struct item_head *)(buf + BLKH_SIZE) + nr - 1;
used_space = BLKH_SIZE + IH_SIZE * nr + (blocksize - ih_location(ih));
if (used_space != blocksize - blkh_free_space(blkh)) {
/* free space does not match to calculated amount of use space */
- reiserfs_warning(NULL, "is_leaf: free space seems wrong: %z",
- bh);
+ reiserfs_warning(NULL, "reiserfs-5082",
+ "free space seems wrong: %z", bh);
return 0;
}
// FIXME: it is_leaf will hit performance too much - we may have
@@ -471,29 +472,29 @@ static int is_leaf(char *buf, int blocks
prev_location = blocksize;
for (i = 0; i < nr; i++, ih++) {
if (le_ih_k_type(ih) == TYPE_ANY) {
- reiserfs_warning(NULL,
- "is_leaf: wrong item type for item %h",
+ reiserfs_warning(NULL, "reiserfs-5083",
+ "wrong item type for item %h",
ih);
return 0;
}
if (ih_location(ih) >= blocksize
|| ih_location(ih) < IH_SIZE * nr) {
- reiserfs_warning(NULL,
- "is_leaf: item location seems wrong: %h",
+ reiserfs_warning(NULL, "reiserfs-5084",
+ "item location seems wrong: %h",
ih);
return 0;
}
if (ih_item_len(ih) < 1
|| ih_item_len(ih) > MAX_ITEM_LEN(blocksize)) {
- reiserfs_warning(NULL,
- "is_leaf: item length seems wrong: %h",
+ reiserfs_warning(NULL, "reiserfs-5085",
+ "item length seems wrong: %h",
ih);
return 0;
}
if (prev_location - ih_location(ih) != ih_item_len(ih)) {
- reiserfs_warning(NULL,
- "is_leaf: item location seems wrong (second one): %h",
- ih);
+ reiserfs_warning(NULL, "reiserfs-5086",
+ "item location seems wrong "
+ "(second one): %h", ih);
return 0;
}
prev_location = ih_location(ih);
@@ -514,24 +515,23 @@ static int is_internal(char *buf, int bl
nr = blkh_level(blkh);
if (nr <= DISK_LEAF_NODE_LEVEL || nr > MAX_HEIGHT) {
/* this level is not possible for internal nodes */
- reiserfs_warning(NULL,
- "is_internal: this should be caught earlier");
+ reiserfs_warning(NULL, "reiserfs-5087",
+ "this should be caught earlier");
return 0;
}
nr = blkh_nr_item(blkh);
if (nr > (blocksize - BLKH_SIZE - DC_SIZE) / (KEY_SIZE + DC_SIZE)) {
/* for internal which is not root we might check min number of keys */
- reiserfs_warning(NULL,
- "is_internal: number of key seems wrong: %z",
- bh);
+ reiserfs_warning(NULL, "reiserfs-5088",
+ "number of key seems wrong: %z", bh);
return 0;
}
used_space = BLKH_SIZE + KEY_SIZE * nr + DC_SIZE * (nr + 1);
if (used_space != blocksize - blkh_free_space(blkh)) {
- reiserfs_warning(NULL,
- "is_internal: free space seems wrong: %z", bh);
+ reiserfs_warning(NULL, "reiserfs-5089",
+ "free space seems wrong: %z", bh);
return 0;
}
// one may imagine much more checks
@@ -543,8 +543,8 @@ static int is_internal(char *buf, int bl
static int is_tree_node(struct buffer_head *bh, int level)
{
if (B_LEVEL(bh) != level) {
- reiserfs_warning(NULL,
- "is_tree_node: node level %d does not match to the expected one %d",
+ reiserfs_warning(NULL, "reiserfs-5090", "node level %d does "
+ "not match to the expected one %d",
B_LEVEL(bh), level);
return 0;
}
@@ -645,9 +645,9 @@ int search_by_key(struct super_block *p_
#ifdef CONFIG_REISERFS_CHECK
if (!(++n_repeat_counter % 50000))
- reiserfs_warning(p_s_sb, "PAP-5100: search_by_key: %s:"
- "there were %d iterations of while loop "
- "looking for key %K",
+ reiserfs_warning(p_s_sb, "PAP-5100",
+ "%s: there were %d iterations of "
+ "while loop looking for key %K",
current->comm, n_repeat_counter,
p_s_key);
#endif
@@ -721,9 +721,9 @@ int search_by_key(struct super_block *p_
// make sure, that the node contents look like a node of
// certain level
if (!is_tree_node(p_s_bh, expected_level)) {
- reiserfs_warning(p_s_sb, "vs-5150: search_by_key: "
- "invalid format found in block %ld. Fsck?",
- p_s_bh->b_blocknr);
+ reiserfs_warning(p_s_sb, "vs-5150",
+ "invalid format found in block %ld. "
+ "Fsck?", p_s_bh->b_blocknr);
pathrelse(p_s_search_path);
return IO_ERROR;
}
@@ -1226,8 +1226,7 @@ int reiserfs_delete_item(struct reiserfs
if (n_ret_value == IO_ERROR)
break;
if (n_ret_value == FILE_NOT_FOUND) {
- reiserfs_warning(p_s_sb,
- "vs-5340: reiserfs_delete_item: "
+ reiserfs_warning(p_s_sb, "vs-5340",
"no items of the file %K found",
p_s_item_key);
break;
@@ -1337,10 +1336,9 @@ void reiserfs_delete_solid_item(struct r
while (1) {
retval = search_item(th->t_super, &cpu_key, &path);
if (retval == IO_ERROR) {
- reiserfs_warning(th->t_super,
- "vs-5350: reiserfs_delete_solid_item: "
- "i/o failure occurred trying to delete %K",
- &cpu_key);
+ reiserfs_warning(th->t_super, "vs-5350",
+ "i/o failure occurred trying "
+ "to delete %K", &cpu_key);
break;
}
if (retval != ITEM_FOUND) {
@@ -1354,9 +1352,8 @@ void reiserfs_delete_solid_item(struct r
GET_GENERATION_NUMBER(le_key_k_offset
(le_key_version(key),
key)) == 1))
- reiserfs_warning(th->t_super,
- "vs-5355: reiserfs_delete_solid_item: %k not found",
- key);
+ reiserfs_warning(th->t_super, "vs-5355",
+ "%k not found", key);
break;
}
if (!tb_init) {
@@ -1388,8 +1385,7 @@ void reiserfs_delete_solid_item(struct r
break;
}
// IO_ERROR, NO_DISK_SPACE, etc
- reiserfs_warning(th->t_super,
- "vs-5360: reiserfs_delete_solid_item: "
+ reiserfs_warning(th->t_super, "vs-5360",
"could not delete %K due to fix_nodes failure",
&cpu_key);
unfix_nodes(&tb);
@@ -1536,8 +1532,9 @@ static void indirect_to_direct_roll_back
set_cpu_key_k_offset(&tail_key,
cpu_key_k_offset(&tail_key) - removed);
}
- reiserfs_warning(inode->i_sb,
- "indirect_to_direct_roll_back: indirect_to_direct conversion has been rolled back due to lack of disk space");
+ reiserfs_warning(inode->i_sb, "reiserfs-5091", "indirect_to_direct "
+ "conversion has been rolled back due to "
+ "lack of disk space");
//mark_file_without_tail (inode);
mark_inode_dirty(inode);
}
@@ -1642,8 +1639,7 @@ int reiserfs_cut_from_item(struct reiser
if (n_ret_value == POSITION_FOUND)
continue;
- reiserfs_warning(p_s_sb,
- "PAP-5610: reiserfs_cut_from_item: item %K not found",
+ reiserfs_warning(p_s_sb, "PAP-5610", "item %K not found",
p_s_item_key);
unfix_nodes(&s_cut_balance);
return (n_ret_value == IO_ERROR) ? -EIO : -ENOENT;
@@ -1657,7 +1653,8 @@ int reiserfs_cut_from_item(struct reiser
indirect_to_direct_roll_back(th, p_s_inode, p_s_path);
}
if (n_ret_value == NO_DISK_SPACE)
- reiserfs_warning(p_s_sb, "NO_DISK_SPACE");
+ reiserfs_warning(p_s_sb, "reiserfs-5092",
+ "NO_DISK_SPACE");
unfix_nodes(&s_cut_balance);
return -EIO;
}
@@ -1746,8 +1743,7 @@ static void truncate_directory(struct re
{
BUG_ON(!th->t_trans_id);
if (inode->i_nlink)
- reiserfs_warning(inode->i_sb,
- "vs-5655: truncate_directory: link count != 0");
+ reiserfs_warning(inode->i_sb, "vs-5655", "link count != 0");
set_le_key_k_offset(KEY_FORMAT_3_5, INODE_PKEY(inode), DOT_OFFSET);
set_le_key_k_type(KEY_FORMAT_3_5, INODE_PKEY(inode), TYPE_DIRENTRY);
@@ -1800,16 +1796,14 @@ int reiserfs_do_truncate(struct reiserfs
search_for_position_by_key(p_s_inode->i_sb, &s_item_key,
&s_search_path);
if (retval == IO_ERROR) {
- reiserfs_warning(p_s_inode->i_sb,
- "vs-5657: reiserfs_do_truncate: "
+ reiserfs_warning(p_s_inode->i_sb, "vs-5657",
"i/o failure occurred trying to truncate %K",
&s_item_key);
err = -EIO;
goto out;
}
if (retval == POSITION_FOUND || retval == FILE_NOT_FOUND) {
- reiserfs_warning(p_s_inode->i_sb,
- "PAP-5660: reiserfs_do_truncate: "
+ reiserfs_warning(p_s_inode->i_sb, "PAP-5660",
"wrong result %d of search for %K", retval,
&s_item_key);
@@ -1853,8 +1847,8 @@ int reiserfs_do_truncate(struct reiserfs
reiserfs_cut_from_item(th, &s_search_path, &s_item_key,
p_s_inode, page, n_new_file_size);
if (n_deleted < 0) {
- reiserfs_warning(p_s_inode->i_sb,
- "vs-5665: reiserfs_do_truncate: reiserfs_cut_from_item failed");
+ reiserfs_warning(p_s_inode->i_sb, "vs-5665",
+ "reiserfs_cut_from_item failed");
reiserfs_check_path(&s_search_path);
return 0;
}
@@ -2003,8 +1997,8 @@ int reiserfs_paste_into_item(struct reis
goto error_out;
}
if (retval == POSITION_FOUND) {
- reiserfs_warning(inode->i_sb,
- "PAP-5710: reiserfs_paste_into_item: entry or pasted byte (%K) exists",
+ reiserfs_warning(inode->i_sb, "PAP-5710",
+ "entry or pasted byte (%K) exists",
p_s_key);
retval = -EEXIST;
goto error_out;
@@ -2090,8 +2084,7 @@ int reiserfs_insert_item(struct reiserfs
goto error_out;
}
if (retval == ITEM_FOUND) {
- reiserfs_warning(th->t_super,
- "PAP-5760: reiserfs_insert_item: "
+ reiserfs_warning(th->t_super, "PAP-5760",
"key %K already exists in the tree",
key);
retval = -EEXIST;
--- a/fs/reiserfs/super.c 2007-06-11 14:49:33.000000000 -0400
+++ b/fs/reiserfs/super.c 2007-06-11 14:50:08.000000000 -0400
@@ -178,9 +178,9 @@ static int finish_unfinished(struct supe
if (REISERFS_SB(s)->s_qf_names[i]) {
int ret = reiserfs_quota_on_mount(s, i);
if (ret < 0)
- reiserfs_warning(s,
- "reiserfs: cannot turn on journalled quota: error %d",
- ret);
+ reiserfs_warning(s, "reiserfs-2500",
+ "cannot turn on journalled "
+ "quota: error %d", ret);
}
}
#endif
@@ -190,8 +190,8 @@ static int finish_unfinished(struct supe
while (!retval) {
retval = search_item(s, &max_cpu_key, &path);
if (retval != ITEM_NOT_FOUND) {
- reiserfs_warning(s,
- "vs-2140: finish_unfinished: search_by_key returned %d",
+ reiserfs_warning(s, "vs-2140",
+ "search_by_key returned %d",
retval);
break;
}
@@ -199,8 +199,8 @@ static int finish_unfinished(struct supe
bh = get_last_bh(&path);
item_pos = get_item_pos(&path);
if (item_pos != B_NR_ITEMS(bh)) {
- reiserfs_warning(s,
- "vs-2060: finish_unfinished: wrong position found");
+ reiserfs_warning(s, "vs-2060",
+ "wrong position found");
break;
}
item_pos--;
@@ -230,8 +230,7 @@ static int finish_unfinished(struct supe
if (!inode) {
/* the unlink almost completed, it just did not manage to remove
"save" link and release objectid */
- reiserfs_warning(s,
- "vs-2180: finish_unfinished: iget failed for %K",
+ reiserfs_warning(s, "vs-2180", "iget failed for %K",
&obj_key);
retval = remove_save_link_only(s, &save_link_key, 1);
continue;
@@ -239,8 +238,8 @@ static int finish_unfinished(struct supe
if (!truncate && inode->i_nlink) {
/* file is not unlinked */
- reiserfs_warning(s,
- "vs-2185: finish_unfinished: file %K is not unlinked",
+ reiserfs_warning(s, "vs-2185",
+ "file %K is not unlinked",
&obj_key);
retval = remove_save_link_only(s, &save_link_key, 0);
continue;
@@ -252,8 +251,9 @@ static int finish_unfinished(struct supe
The only imaginable way is to execute unfinished truncate request
then boot into old kernel, remove the file and create dir with
the same key. */
- reiserfs_warning(s,
- "green-2101: impossible truncate on a directory %k. Please report",
+ reiserfs_warning(s, "green-2101",
+ "impossible truncate on a "
+ "directory %k. Please report",
INODE_PKEY(inode));
retval = remove_save_link_only(s, &save_link_key, 0);
truncate = 0;
@@ -345,8 +345,9 @@ void add_save_link(struct reiserfs_trans
} else {
/* truncate */
if (S_ISDIR(inode->i_mode))
- reiserfs_warning(inode->i_sb,
- "green-2102: Adding a truncate savelink for a directory %k! Please report",
+ reiserfs_warning(inode->i_sb, "green-2102",
+ "Adding a truncate savelink for "
+ "a directory %k! Please report",
INODE_PKEY(inode));
set_cpu_key_k_offset(&key, 1);
set_cpu_key_k_type(&key, TYPE_INDIRECT);
@@ -361,7 +362,7 @@ void add_save_link(struct reiserfs_trans
retval = search_item(inode->i_sb, &key, &path);
if (retval != ITEM_NOT_FOUND) {
if (retval != -ENOSPC)
- reiserfs_warning(inode->i_sb, "vs-2100: add_save_link:"
+ reiserfs_warning(inode->i_sb, "vs-2100",
"search_by_key (%K) returned %d", &key,
retval);
pathrelse(&path);
@@ -376,9 +377,8 @@ void add_save_link(struct reiserfs_trans
reiserfs_insert_item(th, &path, &key, &ih, NULL, (char *)&link);
if (retval) {
if (retval != -ENOSPC)
- reiserfs_warning(inode->i_sb,
- "vs-2120: add_save_link: insert_item returned %d",
- retval);
+ reiserfs_warning(inode->i_sb, "vs-2120",
+ "insert_item returned %d", retval);
} else {
if (truncate)
REISERFS_I(inode)->i_flags |=
@@ -477,8 +477,7 @@ static void reiserfs_put_super(struct su
print_statistics(s);
if (REISERFS_SB(s)->reserved_blocks != 0) {
- reiserfs_warning(s,
- "green-2005: reiserfs_put_super: reserved blocks left %d",
+ reiserfs_warning(s, "green-2005", "reserved blocks left %d",
REISERFS_SB(s)->reserved_blocks);
}
@@ -544,8 +543,8 @@ static void reiserfs_dirty_inode(struct
int err = 0;
if (inode->i_sb->s_flags & MS_RDONLY) {
- reiserfs_warning(inode->i_sb,
- "clm-6006: writing inode %lu on readonly FS",
+ reiserfs_warning(inode->i_sb, "clm-6006",
+ "writing inode %lu on readonly FS",
inode->i_ino);
return;
}
@@ -776,13 +775,15 @@ static int reiserfs_getopt(struct super_
if (bit_flags) {
if (opt->clrmask ==
(1 << REISERFS_UNSUPPORTED_OPT))
- reiserfs_warning(s, "%s not supported.",
+ reiserfs_warning(s, "super-6500",
+ "%s not supported.\n",
p);
else
*bit_flags &= ~opt->clrmask;
if (opt->setmask ==
(1 << REISERFS_UNSUPPORTED_OPT))
- reiserfs_warning(s, "%s not supported.",
+ reiserfs_warning(s, "super-6501",
+ "%s not supported.\n",
p);
else
*bit_flags |= opt->setmask;
@@ -791,7 +792,8 @@ static int reiserfs_getopt(struct super_
}
}
if (!opt->option_name) {
- reiserfs_warning(s, "unknown mount option \"%s\"", p);
+ reiserfs_warning(s, "super-6502",
+ "unknown mount option \"%s\"", p);
return -1;
}
@@ -799,8 +801,9 @@ static int reiserfs_getopt(struct super_
switch (*p) {
case '=':
if (!opt->arg_required) {
- reiserfs_warning(s,
- "the option \"%s\" does not require an argument",
+ reiserfs_warning(s, "super-6503",
+ "the option \"%s\" does not "
+ "require an argument\n",
opt->option_name);
return -1;
}
@@ -808,14 +811,15 @@ static int reiserfs_getopt(struct super_
case 0:
if (opt->arg_required) {
- reiserfs_warning(s,
- "the option \"%s\" requires an argument",
- opt->option_name);
+ reiserfs_warning(s, "super-6504",
+ "the option \"%s\" requires an "
+ "argument\n", opt->option_name);
return -1;
}
break;
default:
- reiserfs_warning(s, "head of option \"%s\" is only correct",
+ reiserfs_warning(s, "super-6505",
+ "head of option \"%s\" is only correct\n",
opt->option_name);
return -1;
}
@@ -827,7 +831,8 @@ static int reiserfs_getopt(struct super_
&& !(opt->arg_required & (1 << REISERFS_OPT_ALLOWEMPTY))
&& !strlen(p)) {
/* this catches "option=," if not allowed */
- reiserfs_warning(s, "empty argument for \"%s\"",
+ reiserfs_warning(s, "super-6506",
+ "empty argument for \"%s\"\n",
opt->option_name);
return -1;
}
@@ -849,7 +854,8 @@ static int reiserfs_getopt(struct super_
}
}
- reiserfs_warning(s, "bad value \"%s\" for option \"%s\"", p,
+ reiserfs_warning(s, "super-6506",
+ "bad value \"%s\" for option \"%s\"\n", p,
opt->option_name);
return -1;
}
@@ -937,9 +943,9 @@ static int reiserfs_parse_options(struct
*blocks = simple_strtoul(arg, &p, 0);
if (*p != '\0') {
/* NNN does not look like a number */
- reiserfs_warning(s,
- "reiserfs_parse_options: bad value %s",
- arg);
+ reiserfs_warning(s, "super-6507",
+ "bad value %s for "
+ "-oresize\n", arg);
return 0;
}
}
@@ -950,8 +956,8 @@ static int reiserfs_parse_options(struct
unsigned long val = simple_strtoul(arg, &p, 0);
/* commit=NNN (time in seconds) */
if (*p != '\0' || val >= (unsigned int)-1) {
- reiserfs_warning(s,
- "reiserfs_parse_options: bad value %s",
+ reiserfs_warning(s, "super-6508",
+ "bad value %s for -ocommit\n",
arg);
return 0;
}
@@ -959,16 +965,17 @@ static int reiserfs_parse_options(struct
}
if (c == 'w') {
- reiserfs_warning(s, "reiserfs: nolargeio option is no longer supported");
+ reiserfs_warning(s, "super-6509", "nolargeio option is no longer supported");
return 0;
}
if (c == 'j') {
if (arg && *arg && jdev_name) {
if (*jdev_name) { //Hm, already assigned?
- reiserfs_warning(s,
- "reiserfs_parse_options: journal device was already specified to be %s",
- *jdev_name);
+ reiserfs_warning(s, "super-6510",
+ "journal device was "
+ "already specified to "
+ "be %s", *jdev_name);
return 0;
}
*jdev_name = arg;
@@ -979,29 +986,34 @@ static int reiserfs_parse_options(struct
int qtype = c == 'u' ? USRQUOTA : GRPQUOTA;
if (sb_any_quota_enabled(s)) {
- reiserfs_warning(s,
- "reiserfs_parse_options: cannot change journalled quota options when quota turned on.");
+ reiserfs_warning(s, "super-6511",
+ "cannot change journalled "
+ "quota options when quota "
+ "turned on.");
return 0;
}
if (*arg) { /* Some filename specified? */
if (REISERFS_SB(s)->s_qf_names[qtype]
&& strcmp(REISERFS_SB(s)->s_qf_names[qtype],
arg)) {
- reiserfs_warning(s,
- "reiserfs_parse_options: %s quota file already specified.",
+ reiserfs_warning(s, "super-6512",
+ "%s quota file already specified.",
QTYPE2NAME(qtype));
return 0;
}
if (strchr(arg, '/')) {
- reiserfs_warning(s,
- "reiserfs_parse_options: quotafile must be on filesystem root.");
+ reiserfs_warning(s, "super-6513",
+ "quotafile must be "
+ "on filesystem root.");
return 0;
}
REISERFS_SB(s)->s_qf_names[qtype] =
kmalloc(strlen(arg) + 1, GFP_KERNEL);
if (!REISERFS_SB(s)->s_qf_names[qtype]) {
- reiserfs_warning(s,
- "reiserfs_parse_options: not enough memory for storing quotafile name.");
+ reiserfs_warning(s, "reiserfs-2502",
+ "not enough memory "
+ "for storing "
+ "quotafile name.");
return 0;
}
strcpy(REISERFS_SB(s)->s_qf_names[qtype], arg);
@@ -1017,15 +1029,16 @@ static int reiserfs_parse_options(struct
else if (!strcmp(arg, "vfsv0"))
REISERFS_SB(s)->s_jquota_fmt = QFMT_VFS_V0;
else {
- reiserfs_warning(s,
- "reiserfs_parse_options: unknown quota format specified.");
+ reiserfs_warning(s, "super-6514",
+ "unknown quota format "
+ "specified.");
return 0;
}
}
#else
if (c == 'u' || c == 'g' || c == 'f') {
- reiserfs_warning(s,
- "reiserfs_parse_options: journalled quota options not supported.");
+ reiserfs_warning(s, "reiserfs-2503", "journalled "
+ "quota options not supported.");
return 0;
}
#endif
@@ -1035,15 +1048,15 @@ static int reiserfs_parse_options(struct
if (!REISERFS_SB(s)->s_jquota_fmt
&& (REISERFS_SB(s)->s_qf_names[USRQUOTA]
|| REISERFS_SB(s)->s_qf_names[GRPQUOTA])) {
- reiserfs_warning(s,
- "reiserfs_parse_options: journalled quota format not specified.");
+ reiserfs_warning(s, "super-6515",
+ "journalled quota format not specified.");
return 0;
}
/* This checking is not precise wrt the quota type but for our purposes it is sufficient */
if (!(*mount_options & (1 << REISERFS_QUOTA))
&& sb_any_quota_enabled(s)) {
- reiserfs_warning(s,
- "reiserfs_parse_options: quota options must be present when quota is turned on.");
+ reiserfs_warning(s, "super-6516", "quota options must "
+ "be present when quota is turned on.");
return 0;
}
#endif
@@ -1103,14 +1116,15 @@ static void handle_attrs(struct super_bl
if (reiserfs_attrs(s)) {
if (old_format_only(s)) {
- reiserfs_warning(s,
- "reiserfs: cannot support attributes on 3.5.x disk format");
+ reiserfs_warning(s, "super-6517", "cannot support "
+ "attributes on 3.5.x disk format");
REISERFS_SB(s)->s_mount_opt &= ~(1 << REISERFS_ATTRS);
return;
}
if (!(le32_to_cpu(rs->s_flags) & reiserfs_attrs_cleared)) {
- reiserfs_warning(s,
- "reiserfs: cannot support attributes until flag is set in super-block");
+ reiserfs_warning(s, "super-6518", "cannot support "
+ "attributes until flag is set in "
+ "super-block");
REISERFS_SB(s)->s_mount_opt &= ~(1 << REISERFS_ATTRS);
}
}
@@ -1253,7 +1267,7 @@ static int read_super_block(struct super
bh = sb_bread(s, offset / s->s_blocksize);
if (!bh) {
- reiserfs_warning(s, "sh-2006: read_super_block: "
+ reiserfs_warning(s, "sh-2006",
"bread failed (dev %s, block %lu, size %lu)",
reiserfs_bdevname(s), offset / s->s_blocksize,
s->s_blocksize);
@@ -1274,8 +1288,8 @@ static int read_super_block(struct super
bh = sb_bread(s, offset / s->s_blocksize);
if (!bh) {
- reiserfs_warning(s, "sh-2007: read_super_block: "
- "bread failed (dev %s, block %lu, size %lu)\n",
+ reiserfs_warning(s, "sh-2007",
+ "bread failed (dev %s, block %lu, size %lu)",
reiserfs_bdevname(s), offset / s->s_blocksize,
s->s_blocksize);
return 1;
@@ -1283,8 +1297,8 @@ static int read_super_block(struct super
rs = (struct reiserfs_super_block *)bh->b_data;
if (sb_blocksize(rs) != s->s_blocksize) {
- reiserfs_warning(s, "sh-2011: read_super_block: "
- "can't find a reiserfs filesystem on (dev %s, block %Lu, size %lu)\n",
+ reiserfs_warning(s, "sh-2011", "can't find a reiserfs "
+ "filesystem on (dev %s, block %Lu, size %lu)",
reiserfs_bdevname(s),
(unsigned long long)bh->b_blocknr,
s->s_blocksize);
@@ -1294,9 +1308,10 @@ static int read_super_block(struct super
if (rs->s_v1.s_root_block == cpu_to_le32(-1)) {
brelse(bh);
- reiserfs_warning(s,
- "Unfinished reiserfsck --rebuild-tree run detected. Please run\n"
- "reiserfsck --rebuild-tree and wait for a completion. If that fails\n"
+ reiserfs_warning(s, "super-6519", "Unfinished reiserfsck "
+ "--rebuild-tree run detected. Please run\n"
+ "reiserfsck --rebuild-tree and wait for a "
+ "completion. If that fails\n"
"get newer reiserfsprogs package");
return 1;
}
@@ -1314,10 +1329,9 @@ static int read_super_block(struct super
reiserfs_info(s, "found reiserfs format \"3.5\""
" with non-standard journal\n");
else {
- reiserfs_warning(s,
- "sh-2012: read_super_block: found unknown "
- "format \"%u\" of reiserfs with non-standard magic",
- sb_version(rs));
+ reiserfs_warning(s, "sh-2012", "found unknown "
+ "format \"%u\" of reiserfs with "
+ "non-standard magic", sb_version(rs));
return 1;
}
} else
@@ -1347,8 +1361,7 @@ static int reread_meta_blocks(struct sup
ll_rw_block(READ, 1, &(SB_BUFFER_WITH_SB(s)));
wait_on_buffer(SB_BUFFER_WITH_SB(s));
if (!buffer_uptodate(SB_BUFFER_WITH_SB(s))) {
- reiserfs_warning(s,
- "reread_meta_blocks, error reading the super");
+ reiserfs_warning(s, "reiserfs-2504", "error reading the super");
return 1;
}
@@ -1412,10 +1425,10 @@ static __u32 find_hash_out(struct super_
&& (yurahash ==
GET_HASH_VALUE(deh_offset
(&(de.de_deh[de.de_entry_num])))))) {
- reiserfs_warning(s,
- "Unable to automatically detect hash function. "
- "Please mount with -o hash={tea,rupasov,r5}",
- reiserfs_bdevname(s));
+ reiserfs_warning(s, "reiserfs-2506", "Unable to "
+ "automatically detect hash function. "
+ "Please mount with -o "
+ "hash={tea,rupasov,r5}");
hash = UNSET_HASH;
break;
}
@@ -1429,7 +1442,8 @@ static __u32 find_hash_out(struct super_
(deh_offset(&(de.de_deh[de.de_entry_num]))) == r5hash)
hash = R5_HASH;
else {
- reiserfs_warning(s, "Unrecognised hash function");
+ reiserfs_warning(s, "reiserfs-2506",
+ "Unrecognised hash function");
hash = UNSET_HASH;
}
} while (0);
@@ -1457,17 +1471,20 @@ static int what_hash(struct super_block
** mount options
*/
if (reiserfs_rupasov_hash(s) && code != YURA_HASH) {
- reiserfs_warning(s, "Error, %s hash detected, "
+ reiserfs_warning(s, "reiserfs-2507",
+ "Error, %s hash detected, "
"unable to force rupasov hash",
reiserfs_hashname(code));
code = UNSET_HASH;
} else if (reiserfs_tea_hash(s) && code != TEA_HASH) {
- reiserfs_warning(s, "Error, %s hash detected, "
+ reiserfs_warning(s, "reiserfs-2508",
+ "Error, %s hash detected, "
"unable to force tea hash",
reiserfs_hashname(code));
code = UNSET_HASH;
} else if (reiserfs_r5_hash(s) && code != R5_HASH) {
- reiserfs_warning(s, "Error, %s hash detected, "
+ reiserfs_warning(s, "reiserfs-2509",
+ "Error, %s hash detected, "
"unable to force r5 hash",
reiserfs_hashname(code));
code = UNSET_HASH;
@@ -1526,9 +1543,9 @@ static int function2code(hashf_t func)
return 0;
}
-#define SWARN(silent, s, ...) \
+#define SWARN(silent, s, id, ...) \
if (!(silent)) \
- reiserfs_warning (s, __VA_ARGS__)
+ reiserfs_warning (s, id, __VA_ARGS__)
static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
{
@@ -1573,8 +1590,7 @@ static int reiserfs_fill_super(struct su
}
if (blocks) {
- SWARN(silent, s, "jmacd-7: reiserfs_fill_super: resize option "
- "for remount only");
+ SWARN(silent, s, "jmacd-7", "resize option for remount only");
goto error;
}
@@ -1583,8 +1599,7 @@ static int reiserfs_fill_super(struct su
old_format = 1;
/* try new format (64-th 1k block), which can contain reiserfs super block */
else if (read_super_block(s, REISERFS_DISK_OFFSET_IN_BYTES)) {
- SWARN(silent, s,
- "sh-2021: reiserfs_fill_super: can not find reiserfs on %s",
+ SWARN(silent, s, "sh-2021", "can not find reiserfs on %s",
reiserfs_bdevname(s));
goto error;
}
@@ -1596,13 +1611,12 @@ static int reiserfs_fill_super(struct su
if (s->s_bdev && s->s_bdev->bd_inode
&& i_size_read(s->s_bdev->bd_inode) <
sb_block_count(rs) * sb_blocksize(rs)) {
- SWARN(silent, s,
- "Filesystem on %s cannot be mounted because it is bigger than the device",
- reiserfs_bdevname(s));
- SWARN(silent, s,
- "You may need to run fsck or increase size of your LVM partition");
- SWARN(silent, s,
- "Or may be you forgot to reboot after fdisk when it told you to");
+ SWARN(silent, s, "", "Filesystem cannot be "
+ "mounted because it is bigger than the device");
+ SWARN(silent, s, "", "You may need to run fsck "
+ "or increase size of your LVM partition");
+ SWARN(silent, s, "", "Or may be you forgot to "
+ "reboot after fdisk when it told you to");
goto error;
}
@@ -1610,14 +1624,13 @@ static int reiserfs_fill_super(struct su
sbi->s_mount_state = REISERFS_VALID_FS;
if ((errval = reiserfs_init_bitmap_cache(s))) {
- SWARN(silent, s,
- "jmacd-8: reiserfs_fill_super: unable to read bitmap");
+ SWARN(silent, s, "jmacd-8", "unable to read bitmap");
goto error;
}
errval = -EINVAL;
#ifdef CONFIG_REISERFS_CHECK
- SWARN(silent, s, "CONFIG_REISERFS_CHECK is set ON");
- SWARN(silent, s, "- it is slow mode for debugging.");
+ SWARN(silent, s, "", "CONFIG_REISERFS_CHECK is set ON");
+ SWARN(silent, s, "", "- it is slow mode for debugging.");
#endif
/* make data=ordered the default */
@@ -1638,8 +1651,8 @@ static int reiserfs_fill_super(struct su
}
// set_device_ro(s->s_dev, 1) ;
if (journal_init(s, jdev_name, old_format, commit_max_age)) {
- SWARN(silent, s,
- "sh-2022: reiserfs_fill_super: unable to initialize journal space");
+ SWARN(silent, s, "sh-2022",
+ "unable to initialize journal space");
goto error;
} else {
jinit_done = 1; /* once this is set, journal_release must be called
@@ -1647,8 +1660,8 @@ static int reiserfs_fill_super(struct su
*/
}
if (reread_meta_blocks(s)) {
- SWARN(silent, s,
- "jmacd-9: reiserfs_fill_super: unable to reread meta blocks after journal init");
+ SWARN(silent, s, "jmacd-9",
+ "unable to reread meta blocks after journal init");
goto error;
}
@@ -1656,8 +1669,8 @@ static int reiserfs_fill_super(struct su
goto error;
if (bdev_read_only(s->s_bdev) && !(s->s_flags & MS_RDONLY)) {
- SWARN(silent, s,
- "clm-7000: Detected readonly device, marking FS readonly");
+ SWARN(silent, s, "clm-7000",
+ "Detected readonly device, marking FS readonly");
s->s_flags |= MS_RDONLY;
}
args.objectid = REISERFS_ROOT_OBJECTID;
@@ -1666,8 +1679,7 @@ static int reiserfs_fill_super(struct su
iget5_locked(s, REISERFS_ROOT_OBJECTID, reiserfs_find_actor,
reiserfs_init_locked_inode, (void *)(&args));
if (!root_inode) {
- SWARN(silent, s,
- "jmacd-10: reiserfs_fill_super: get root inode failed");
+ SWARN(silent, s, "jmacd-10", "get root inode failed");
goto error;
}
@@ -1985,8 +1997,8 @@ static int reiserfs_quota_on(struct supe
}
/* We must not pack tails for quota files on reiserfs for quota IO to work */
if (!REISERFS_I(nd.dentry->d_inode)->i_flags & i_nopack_mask) {
- reiserfs_warning(sb,
- "reiserfs: Quota file must have tail packing disabled.");
+ reiserfs_warning(sb, "super-6520",
+ "Quota file must have tail packing disabled.");
path_release(&nd);
return -EINVAL;
}
@@ -1998,8 +2010,8 @@ static int reiserfs_quota_on(struct supe
}
/* Quotafile not of fs root? */
if (nd.dentry->d_parent->d_inode != sb->s_root->d_inode)
- reiserfs_warning(sb,
- "reiserfs: Quota file not on filesystem root. "
+ reiserfs_warning(sb, "super-6521",
+ "Quota file not on filesystem root. "
"Journalled quota will not work.");
path_release(&nd);
return vfs_quota_on(sb, type, format_id, path);
--- a/fs/reiserfs/tail_conversion.c 2007-06-11 14:49:05.000000000 -0400
+++ b/fs/reiserfs/tail_conversion.c 2007-06-11 14:50:09.000000000 -0400
@@ -48,9 +48,9 @@ int direct2indirect(struct reiserfs_tran
// FIXME: we could avoid this
if (search_for_position_by_key(sb, &end_key, path) == POSITION_FOUND) {
- reiserfs_warning(sb, "PAP-14030: direct2indirect: "
- "pasted or inserted byte exists in the tree %K. "
- "Use fsck to repair.", &end_key);
+ reiserfs_warning(sb, "PAP-14030",
+ "pasted or inserted byte exists in "
+ "the tree %K. Use fsck to repair.", &end_key);
pathrelse(path);
return -EIO;
}
--- a/fs/reiserfs/xattr.c 2007-06-11 14:49:33.000000000 -0400
+++ b/fs/reiserfs/xattr.c 2007-06-11 14:50:08.000000000 -0400
@@ -278,7 +278,8 @@ static int __xattr_readdir(struct file *
ih = de.de_ih;
if (!is_direntry_le_ih(ih)) {
- reiserfs_warning(inode->i_sb, "not direntry %h", ih);
+ reiserfs_warning(inode->i_sb, "jdm-20000",
+ "not direntry %h", ih);
break;
}
copy_item_head(&tmp_ih, ih);
@@ -619,7 +620,7 @@ reiserfs_xattr_get(const struct inode *i
if (rxh->h_magic != cpu_to_le32(REISERFS_XATTR_MAGIC)) {
unlock_page(page);
reiserfs_put_page(page);
- reiserfs_warning(inode->i_sb,
+ reiserfs_warning(inode->i_sb, "jdm-20001",
"Invalid magic for xattr (%s) "
"associated with %k", name,
INODE_PKEY(inode));
@@ -639,7 +640,7 @@ reiserfs_xattr_get(const struct inode *i
if (xattr_hash(buffer, isize - sizeof(struct reiserfs_xattr_header)) !=
hash) {
- reiserfs_warning(inode->i_sb,
+ reiserfs_warning(inode->i_sb, "jdm-20002",
"Invalid hash for xattr (%s) associated "
"with %k", name, INODE_PKEY(inode));
err = -EIO;
@@ -673,7 +674,8 @@ __reiserfs_xattr_del(struct dentry *xadi
goto out_file;
if (!is_reiserfs_priv_object(dentry->d_inode)) {
- reiserfs_warning(dir->i_sb, "OID %08x [%.*s/%.*s] doesn't have "
+ reiserfs_warning(dir->i_sb, "jdm-20003",
+ "OID %08x [%.*s/%.*s] doesn't have "
"priv flag set [parent is %sset].",
le32_to_cpu(INODE_PKEY(dentry->d_inode)->
k_objectid), xadir->d_name.len,
@@ -779,7 +781,7 @@ int reiserfs_delete_xattrs(struct inode
reiserfs_write_unlock_xattrs(inode->i_sb);
dput(root);
} else {
- reiserfs_warning(inode->i_sb,
+ reiserfs_warning(inode->i_sb, "jdm-20004",
"Couldn't remove all entries in directory");
}
unlock_kernel();
@@ -1199,7 +1201,8 @@ int reiserfs_xattr_init(struct super_blo
} else if (reiserfs_xattrs_optional(s)) {
/* Old format filesystem, but optional xattrs have been enabled
* at mount time. Error out. */
- reiserfs_warning(s, "xattrs/ACLs not supported on pre v3.6 "
+ reiserfs_warning(s, "jdm-20005",
+ "xattrs/ACLs not supported on pre v3.6 "
"format filesystem. Failing mount.");
err = -EOPNOTSUPP;
goto error;
@@ -1246,8 +1249,10 @@ int reiserfs_xattr_init(struct super_blo
/* If we're read-only it just means that the dir hasn't been
* created. Not an error -- just no xattrs on the fs. We'll
* check again if we go read-write */
- reiserfs_warning(s, "xattrs/ACLs enabled and couldn't "
- "find/create .reiserfs_priv. Failing mount.");
+ reiserfs_warning(s, "jdm-20006",
+ "xattrs/ACLs enabled and couldn't "
+ "find/create .reiserfs_priv. "
+ "Failing mount.");
err = -EOPNOTSUPP;
}
}
--- a/include/linux/reiserfs_fs.h 2007-06-11 14:49:05.000000000 -0400
+++ b/include/linux/reiserfs_fs.h 2007-06-11 14:50:09.000000000 -0400
@@ -77,7 +77,10 @@
*/
#define REISERFS_DEBUG_CODE 5 /* extra messages to help find/debug errors */
-void reiserfs_warning(struct super_block *s, const char *fmt, ...);
+void __reiserfs_warning(struct super_block *s, const char *id,
+ const char *func, const char *fmt, ...);
+#define reiserfs_warning(s, id, fmt, args...) \
+ __reiserfs_warning(s, id, __FUNCTION__, fmt, ##args)
/* assertions handling */
/** always check a condition and panic if it's false. */
@@ -538,7 +541,7 @@ static inline int uniqueness2type(__u32
case V1_DIRENTRY_UNIQUENESS:
return TYPE_DIRENTRY;
default:
- reiserfs_warning(NULL, "vs-500: unknown uniqueness %d",
+ reiserfs_warning(NULL, "vs-500", "unknown uniqueness %d",
uniqueness);
case V1_ANY_UNIQUENESS:
return TYPE_ANY;
@@ -558,7 +561,7 @@ static inline __u32 type2uniqueness(int
case TYPE_DIRENTRY:
return V1_DIRENTRY_UNIQUENESS;
default:
- reiserfs_warning(NULL, "vs-501: unknown type %d", type);
+ reiserfs_warning(NULL, "vs-501", "unknown type %d", type);
case TYPE_ANY:
return V1_ANY_UNIQUENESS;
}
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 43+ messages in thread
* [patch 08/40] reiserfs: rework reiserfs_panic
2007-06-11 19:03 [patch 00/40] reiserfs: patch queue (v2) jeffm
` (6 preceding siblings ...)
2007-06-11 19:03 ` [patch 07/40] reiserfs: rework reiserfs_warning jeffm
@ 2007-06-11 19:03 ` jeffm
2007-06-11 19:03 ` [patch 09/40] reiserfs: rearrange journal abort jeffm
` (32 subsequent siblings)
40 siblings, 0 replies; 43+ messages in thread
From: jeffm @ 2007-06-11 19:03 UTC (permalink / raw)
To: ReiserFS Mailing List
[-- Attachment #1: reiserfs-reiserfs_panic.diff --]
[-- Type: text/plain, Size: 40601 bytes --]
ReiserFS panics can be somewhat inconsistent.
In some cases:
* a unique identifier may be associated with it
* the function name may be included
* the device may be printed separately
This patch aims to make warnings more consistent. reiserfs_warning() prints
the device name, so printing it a second time is not required. The function
name for a warning is always helpful in debugging, so it is now automatically
inserted into the output. Hans has stated that every warning should have
a unique identifier. Some cases lack them, others really shouldn't have them.
reiserfs_warning() now expects an id associated with each message. In the
rare case where one isn't needed, "" will suffice.
---
fs/reiserfs/do_balan.c | 60 ++++++++++++++++------------------
fs/reiserfs/file.c | 32 ++++++++++--------
fs/reiserfs/fix_node.c | 74 +++++++++++++++++++++---------------------
fs/reiserfs/ibalance.c | 12 +++---
fs/reiserfs/inode.c | 3 -
fs/reiserfs/item_ops.c | 8 ++--
fs/reiserfs/journal.c | 56 +++++++++++++++----------------
fs/reiserfs/lbalance.c | 27 ++++++++-------
fs/reiserfs/namei.c | 18 ++++------
fs/reiserfs/objectid.c | 3 -
fs/reiserfs/prints.c | 34 ++++++++++---------
fs/reiserfs/stree.c | 49 +++++++++++++--------------
fs/reiserfs/tail_conversion.c | 10 ++---
include/linux/reiserfs_fs.h | 23 ++++++++++---
14 files changed, 212 insertions(+), 197 deletions(-)
--- a/fs/reiserfs/do_balan.c 2007-06-11 14:49:34.000000000 -0400
+++ b/fs/reiserfs/do_balan.c 2007-06-11 14:50:04.000000000 -0400
@@ -153,8 +153,8 @@ static int balance_leaf_when_delete(stru
default:
print_cur_tb("12040");
- reiserfs_panic(tb->tb_sb,
- "PAP-12040: balance_leaf_when_delete: unexpectable mode: %s(%d)",
+ reiserfs_panic(tb->tb_sb, "PAP-12040",
+ "unexpected mode: %s(%d)",
(flag ==
M_PASTE) ? "PASTE" : ((flag ==
M_INSERT) ? "INSERT" :
@@ -722,8 +722,8 @@ static int balance_leaf(struct tree_bala
}
break;
default: /* cases d and t */
- reiserfs_panic(tb->tb_sb,
- "PAP-12130: balance_leaf: lnum > 0: unexpectable mode: %s(%d)",
+ reiserfs_panic(tb->tb_sb, "PAP-12130",
+ "lnum > 0: unexpected mode: %s(%d)",
(flag ==
M_DELETE) ? "DELETE" : ((flag ==
M_CUT)
@@ -1136,8 +1136,8 @@ static int balance_leaf(struct tree_bala
}
break;
default: /* cases d and t */
- reiserfs_panic(tb->tb_sb,
- "PAP-12175: balance_leaf: rnum > 0: unexpectable mode: %s(%d)",
+ reiserfs_panic(tb->tb_sb, "PAP-12175",
+ "rnum > 0: unexpected mode: %s(%d)",
(flag ==
M_DELETE) ? "DELETE" : ((flag ==
M_CUT) ? "CUT"
@@ -1167,8 +1167,8 @@ static int balance_leaf(struct tree_bala
not set correctly */
if (tb->CFL[0]) {
if (!tb->CFR[0])
- reiserfs_panic(tb->tb_sb,
- "vs-12195: balance_leaf: CFR not initialized");
+ reiserfs_panic(tb->tb_sb, "vs-12195",
+ "CFR not initialized");
copy_key(B_N_PDELIM_KEY(tb->CFL[0], tb->lkey[0]),
B_N_PDELIM_KEY(tb->CFR[0], tb->rkey[0]));
do_balance_mark_internal_dirty(tb, tb->CFL[0], 0);
@@ -1475,7 +1475,8 @@ static int balance_leaf(struct tree_bala
&& (pos_in_item != ih_item_len(ih)
|| tb->insert_size[0] <= 0))
reiserfs_panic(tb->tb_sb,
- "PAP-12235: balance_leaf: pos_in_item must be equal to ih_item_len");
+ "PAP-12235",
+ "pos_in_item must be equal to ih_item_len");
#endif /* CONFIG_REISERFS_CHECK */
ret_val =
@@ -1535,8 +1536,8 @@ static int balance_leaf(struct tree_bala
}
break;
default: /* cases d and t */
- reiserfs_panic(tb->tb_sb,
- "PAP-12245: balance_leaf: blknum > 2: unexpectable mode: %s(%d)",
+ reiserfs_panic(tb->tb_sb, "PAP-12245",
+ "blknum > 2: unexpected mode: %s(%d)",
(flag ==
M_DELETE) ? "DELETE" : ((flag ==
M_CUT) ? "CUT"
@@ -1681,7 +1682,7 @@ static int balance_leaf(struct tree_bala
print_cur_tb("12285");
reiserfs_panic(tb->
tb_sb,
- "PAP-12285: balance_leaf: insert_size must be 0 (%d)",
+ "PAP-12285", "insert_size must be 0 (%d)",
tb->
insert_size
[0]);
@@ -1697,11 +1698,10 @@ static int balance_leaf(struct tree_bala
if (flag == M_PASTE && tb->insert_size[0]) {
print_cur_tb("12290");
reiserfs_panic(tb->tb_sb,
- "PAP-12290: balance_leaf: insert_size is still not 0 (%d)",
- tb->insert_size[0]);
+ "PAP-12290", "insert_size is still not 0 (%d)",
+ tb->insert_size[0]);
}
#endif /* CONFIG_REISERFS_CHECK */
-
return 0;
} /* Leaf level of the tree is balanced (end of balance_leaf) */
@@ -1732,8 +1732,7 @@ struct buffer_head *get_FEB(struct tree_
break;
if (i == MAX_FEB_SIZE)
- reiserfs_panic(tb->tb_sb,
- "vs-12300: get_FEB: FEB list is empty");
+ reiserfs_panic(tb->tb_sb, "vs-12300", "FEB list is empty");
bi.tb = tb;
bi.bi_bh = first_b = tb->FEB[i];
@@ -1776,7 +1775,7 @@ static void free_thrown(struct tree_bala
if (buffer_dirty(tb->thrown[i]))
reiserfs_warning(tb->tb_sb, "reiserfs-12322",
"called with dirty buffer %d",
- blocknr);
+ blocknr);
brelse(tb->thrown[i]); /* incremented in store_thrown */
reiserfs_free_block(tb->transaction_handle, NULL,
blocknr, 0);
@@ -1873,8 +1872,8 @@ static void check_internal_node(struct s
for (i = 0; i <= B_NR_ITEMS(bh); i++, dc++) {
if (!is_reusable(s, dc_block_number(dc), 1)) {
print_cur_tb(mes);
- reiserfs_panic(s,
- "PAP-12338: check_internal_node: invalid child pointer %y in %b",
+ reiserfs_panic(s, "PAP-12338",
+ "invalid child pointer %y in %b",
dc, bh);
}
}
@@ -1896,9 +1895,10 @@ static int check_before_balancing(struct
int retval = 0;
if (cur_tb) {
- reiserfs_panic(tb->tb_sb, "vs-12335: check_before_balancing: "
- "suspect that schedule occurred based on cur_tb not being null at this point in code. "
- "do_balance cannot properly handle schedule occurring while it runs.");
+ reiserfs_panic(tb->tb_sb, "vs-12335", "suspect that schedule "
+ "occurred based on cur_tb not being null at "
+ "this point in code. do_balance cannot properly "
+ "handle schedule occurring while it runs.");
}
/* double check that buffers that we will modify are unlocked. (fix_nodes should already have
@@ -1930,8 +1930,8 @@ static void check_after_balance_leaf(str
dc_size(B_N_CHILD
(tb->FL[0], get_left_neighbor_position(tb, 0)))) {
print_cur_tb("12221");
- reiserfs_panic(tb->tb_sb,
- "PAP-12355: check_after_balance_leaf: shift to left was incorrect");
+ reiserfs_panic(tb->tb_sb, "PAP-12355",
+ "shift to left was incorrect");
}
}
if (tb->rnum[0]) {
@@ -1940,8 +1940,8 @@ static void check_after_balance_leaf(str
dc_size(B_N_CHILD
(tb->FR[0], get_right_neighbor_position(tb, 0)))) {
print_cur_tb("12222");
- reiserfs_panic(tb->tb_sb,
- "PAP-12360: check_after_balance_leaf: shift to right was incorrect");
+ reiserfs_panic(tb->tb_sb, "PAP-12360",
+ "shift to right was incorrect");
}
}
if (PATH_H_PBUFFER(tb->tb_path, 1) &&
@@ -1966,8 +1966,7 @@ static void check_after_balance_leaf(str
(PATH_H_PBUFFER(tb->tb_path, 1),
PATH_H_POSITION(tb->tb_path, 1))),
right);
- reiserfs_panic(tb->tb_sb,
- "PAP-12365: check_after_balance_leaf: S is incorrect");
+ reiserfs_panic(tb->tb_sb, "PAP-12365", "S is incorrect");
}
}
@@ -2102,8 +2101,7 @@ void do_balance(struct tree_balance *tb,
tb->need_balance_dirty = 0;
if (FILESYSTEM_CHANGED_TB(tb)) {
- reiserfs_panic(tb->tb_sb,
- "clm-6000: do_balance, fs generation has changed\n");
+ reiserfs_panic(tb->tb_sb, "clm-6000", "fs generation has changed");
}
/* if we have no real work to do */
if (!tb->insert_size[0]) {
--- a/fs/reiserfs/file.c 2007-06-11 14:49:34.000000000 -0400
+++ b/fs/reiserfs/file.c 2007-06-11 14:50:08.000000000 -0400
@@ -413,7 +413,8 @@ static int reiserfs_allocate_blocks_for_
(char *)zeros);
} else {
reiserfs_panic(inode->i_sb,
- "green-9011: Unexpected key type %K\n",
+ "green-9011",
+ "Unexpected key type %K",
&key);
}
if (res) {
@@ -615,9 +616,8 @@ static int reiserfs_allocate_blocks_for_
(char *)(allocated_blocks +
curr_block));
} else {
- reiserfs_panic(inode->i_sb,
- "green-9010: unexpected item type for key %K\n",
- &key);
+ reiserfs_panic(inode->i_sb, "green-9010",
+ "unexpected item type for key %K", &key);
}
}
// the caller is responsible for closing the transaction
@@ -642,15 +642,16 @@ static int reiserfs_allocate_blocks_for_
int block_start, block_end; // in-page offsets for buffers.
if (!page_buffers(page))
- reiserfs_panic(inode->i_sb,
- "green-9005: No buffers for prepared page???");
+ reiserfs_panic(inode->i_sb, "green-9005",
+ "No buffers for prepared page???");
/* For each buffer in page */
for (bh = head, block_start = 0; bh != head || !block_start;
block_start = block_end, bh = bh->b_this_page) {
if (!bh)
- reiserfs_panic(inode->i_sb,
- "green-9006: Allocated but absent buffer for a page?");
+ reiserfs_panic(inode->i_sb, "green-9006",
+ "Allocated but absent buffer "
+ "for a page?");
block_end = block_start + inode->i_sb->s_blocksize;
if (i == 0 && block_end <= from)
/* if this buffer is before requested data to map, skip it */
@@ -1091,8 +1092,9 @@ static int reiserfs_prepare_file_region_
for (bh = head, block_start = 0; bh != head || !block_start;
block_start = block_end, bh = bh->b_this_page) {
if (!bh)
- reiserfs_panic(inode->i_sb,
- "green-9002: Allocated but absent buffer for a page?");
+ reiserfs_panic(inode->i_sb, "green-9002",
+ "Allocated but absent "
+ "buffer for a page?");
/* Find where this buffer ends */
block_end = block_start + inode->i_sb->s_blocksize;
if (i == 0 && block_end <= from)
@@ -1178,8 +1180,9 @@ static int reiserfs_prepare_file_region_
block_start = block_end, bh = bh->b_this_page) {
if (!bh)
- reiserfs_panic(inode->i_sb,
- "green-9002: Allocated but absent buffer for a page?");
+ reiserfs_panic(inode->i_sb, "green-9002",
+ "Allocated but absent "
+ "buffer for a page?");
/* Find where this buffer ends */
block_end = block_start + inode->i_sb->s_blocksize;
if (block_end <= from)
@@ -1212,8 +1215,9 @@ static int reiserfs_prepare_file_region_
block_start = block_end, bh = bh->b_this_page) {
if (!bh)
- reiserfs_panic(inode->i_sb,
- "green-9002: Allocated but absent buffer for a page?");
+ reiserfs_panic(inode->i_sb, "green-9002",
+ "Allocated but absent "
+ "buffer for a page?");
/* Find where this buffer ends */
block_end = block_start + inode->i_sb->s_blocksize;
if (block_start >= to)
--- a/fs/reiserfs/fix_node.c 2007-06-11 14:49:34.000000000 -0400
+++ b/fs/reiserfs/fix_node.c 2007-06-11 14:50:04.000000000 -0400
@@ -135,8 +135,7 @@ static void create_virtual_node(struct t
vn->vn_free_ptr +=
op_create_vi(vn, vi, is_affected, tb->insert_size[0]);
if (tb->vn_buf + tb->vn_buf_size < vn->vn_free_ptr)
- reiserfs_panic(tb->tb_sb,
- "vs-8030: create_virtual_node: "
+ reiserfs_panic(tb->tb_sb, "vs-8030",
"virtual node space consumed");
if (!is_affected)
@@ -186,8 +185,9 @@ static void create_virtual_node(struct t
&& I_ENTRY_COUNT(B_N_PITEM_HEAD(Sh, 0)) == 1)) {
/* node contains more than 1 item, or item is not directory item, or this item contains more than 1 entry */
print_block(Sh, 0, -1, -1);
- reiserfs_panic(tb->tb_sb,
- "vs-8045: create_virtual_node: rdkey %k, affected item==%d (mode==%c) Must be %c",
+ reiserfs_panic(tb->tb_sb, "vs-8045",
+ "rdkey %k, affected item==%d "
+ "(mode==%c) Must be %c",
key, vn->vn_affected_item_num,
vn->vn_mode, M_DELETE);
}
@@ -1253,8 +1253,8 @@ static int ip_check_balance(struct tree_
/* Calculate balance parameters for creating new root. */
if (!Sh) {
if (!h)
- reiserfs_panic(tb->tb_sb,
- "vs-8210: ip_check_balance: S[0] can not be 0");
+ reiserfs_panic(tb->tb_sb, "vs-8210",
+ "S[0] can not be 0");
switch (n_ret_value = get_empty_nodes(tb, h)) {
case CARRY_ON:
set_parameters(tb, h, 0, 0, 1, NULL, -1, -1);
@@ -1264,8 +1264,8 @@ static int ip_check_balance(struct tree_
case REPEAT_SEARCH:
return n_ret_value;
default:
- reiserfs_panic(tb->tb_sb,
- "vs-8215: ip_check_balance: incorrect return value of get_empty_nodes");
+ reiserfs_panic(tb->tb_sb, "vs-8215", "incorrect "
+ "return value of get_empty_nodes");
}
}
@@ -2093,38 +2093,38 @@ static void tb_buffer_sanity_check(struc
if (p_s_bh) {
if (atomic_read(&(p_s_bh->b_count)) <= 0) {
- reiserfs_panic(p_s_sb,
- "jmacd-1: tb_buffer_sanity_check(): negative or zero reference counter for buffer %s[%d] (%b)\n",
- descr, level, p_s_bh);
+ reiserfs_panic(p_s_sb, "jmacd-1", "negative or zero "
+ "reference counter for buffer %s[%d] "
+ "(%b)", descr, level, p_s_bh);
}
if (!buffer_uptodate(p_s_bh)) {
- reiserfs_panic(p_s_sb,
- "jmacd-2: tb_buffer_sanity_check(): buffer is not up to date %s[%d] (%b)\n",
+ reiserfs_panic(p_s_sb, "jmacd-2", "buffer is not up "
+ "to date %s[%d] (%b)",
descr, level, p_s_bh);
}
if (!B_IS_IN_TREE(p_s_bh)) {
- reiserfs_panic(p_s_sb,
- "jmacd-3: tb_buffer_sanity_check(): buffer is not in tree %s[%d] (%b)\n",
+ reiserfs_panic(p_s_sb, "jmacd-3", "buffer is not "
+ "in tree %s[%d] (%b)",
descr, level, p_s_bh);
}
if (p_s_bh->b_bdev != p_s_sb->s_bdev) {
- reiserfs_panic(p_s_sb,
- "jmacd-4: tb_buffer_sanity_check(): buffer has wrong device %s[%d] (%b)\n",
+ reiserfs_panic(p_s_sb, "jmacd-4", "buffer has wrong "
+ "device %s[%d] (%b)",
descr, level, p_s_bh);
}
if (p_s_bh->b_size != p_s_sb->s_blocksize) {
- reiserfs_panic(p_s_sb,
- "jmacd-5: tb_buffer_sanity_check(): buffer has wrong blocksize %s[%d] (%b)\n",
+ reiserfs_panic(p_s_sb, "jmacd-5", "buffer has wrong "
+ "blocksize %s[%d] (%b)",
descr, level, p_s_bh);
}
if (p_s_bh->b_blocknr > SB_BLOCK_COUNT(p_s_sb)) {
- reiserfs_panic(p_s_sb,
- "jmacd-6: tb_buffer_sanity_check(): buffer block number too high %s[%d] (%b)\n",
+ reiserfs_panic(p_s_sb, "jmacd-6", "buffer block "
+ "number too high %s[%d] (%b)",
descr, level, p_s_bh);
}
}
@@ -2356,39 +2356,41 @@ int fix_nodes(int n_op_mode, struct tree
#ifdef CONFIG_REISERFS_CHECK
if (cur_tb) {
print_cur_tb("fix_nodes");
- reiserfs_panic(p_s_tb->tb_sb,
- "PAP-8305: fix_nodes: there is pending do_balance");
+ reiserfs_panic(p_s_tb->tb_sb, "PAP-8305",
+ "there is pending do_balance");
}
if (!buffer_uptodate(p_s_tbS0) || !B_IS_IN_TREE(p_s_tbS0)) {
- reiserfs_panic(p_s_tb->tb_sb,
- "PAP-8320: fix_nodes: S[0] (%b %z) is not uptodate "
- "at the beginning of fix_nodes or not in tree (mode %c)",
- p_s_tbS0, p_s_tbS0, n_op_mode);
+ reiserfs_panic(p_s_tb->tb_sb, "PAP-8320", "S[0] (%b %z) is "
+ "not uptodate at the beginning of fix_nodes "
+ "or not in tree (mode %c)",
+ p_s_tbS0, p_s_tbS0, n_op_mode);
}
/* Check parameters. */
switch (n_op_mode) {
case M_INSERT:
if (n_item_num <= 0 || n_item_num > B_NR_ITEMS(p_s_tbS0))
- reiserfs_panic(p_s_tb->tb_sb,
- "PAP-8330: fix_nodes: Incorrect item number %d (in S0 - %d) in case of insert",
- n_item_num, B_NR_ITEMS(p_s_tbS0));
+ reiserfs_panic(p_s_tb->tb_sb, "PAP-8330", "Incorrect "
+ "item number %d (in S0 - %d) in case "
+ "of insert", n_item_num,
+ B_NR_ITEMS(p_s_tbS0));
break;
case M_PASTE:
case M_DELETE:
case M_CUT:
if (n_item_num < 0 || n_item_num >= B_NR_ITEMS(p_s_tbS0)) {
print_block(p_s_tbS0, 0, -1, -1);
- reiserfs_panic(p_s_tb->tb_sb,
- "PAP-8335: fix_nodes: Incorrect item number(%d); mode = %c insert_size = %d\n",
- n_item_num, n_op_mode,
- p_s_tb->insert_size[0]);
+ reiserfs_panic(p_s_tb->tb_sb, "PAP-8335", "Incorrect "
+ "item number(%d); mode = %c "
+ "insert_size = %d",
+ n_item_num, n_op_mode,
+ p_s_tb->insert_size[0]);
}
break;
default:
- reiserfs_panic(p_s_tb->tb_sb,
- "PAP-8340: fix_nodes: Incorrect mode of operation");
+ reiserfs_panic(p_s_tb->tb_sb, "PAP-8340", "Incorrect mode "
+ "of operation");
}
#endif
--- a/fs/reiserfs/ibalance.c 2007-06-11 14:49:05.000000000 -0400
+++ b/fs/reiserfs/ibalance.c 2007-06-11 14:50:04.000000000 -0400
@@ -105,8 +105,8 @@ static void internal_define_dest_src_inf
break;
default:
- reiserfs_panic(tb->tb_sb,
- "internal_define_dest_src_infos: shift type is unknown (%d)",
+ reiserfs_panic(tb->tb_sb, "ibalance-1",
+ "shift type is unknown (%d)",
shift_mode);
}
}
@@ -702,8 +702,8 @@ static void balance_internal_when_delete
return;
}
- reiserfs_panic(tb->tb_sb,
- "balance_internal_when_delete: unexpected tb->lnum[%d]==%d or tb->rnum[%d]==%d",
+ reiserfs_panic(tb->tb_sb, "ibalance-2",
+ "unexpected tb->lnum[%d]==%d or tb->rnum[%d]==%d",
h, tb->lnum[h], h, tb->rnum[h]);
}
@@ -940,8 +940,8 @@ int balance_internal(struct tree_balance
struct block_head *blkh;
if (tb->blknum[h] != 1)
- reiserfs_panic(NULL,
- "balance_internal: One new node required for creating the new root");
+ reiserfs_panic(NULL, "ibalance-3", "One new node "
+ "required for creating the new root");
/* S[h] = empty buffer from the list FEB. */
tbSh = get_FEB(tb);
blkh = B_BLK_HEAD(tbSh);
--- a/fs/reiserfs/inode.c 2007-06-11 14:49:34.000000000 -0400
+++ b/fs/reiserfs/inode.c 2007-06-11 14:50:08.000000000 -0400
@@ -1295,8 +1295,7 @@ static void update_stat_data(struct tree
ih = PATH_PITEM_HEAD(path);
if (!is_statdata_le_ih(ih))
- reiserfs_panic(inode->i_sb,
- "vs-13065: update_stat_data: key %k, found item %h",
+ reiserfs_panic(inode->i_sb, "vs-13065", "key %k, found item %h",
INODE_PKEY(inode), ih);
if (stat_data_v1(ih)) {
--- a/fs/reiserfs/item_ops.c 2007-06-11 14:49:34.000000000 -0400
+++ b/fs/reiserfs/item_ops.c 2007-06-11 14:49:34.000000000 -0400
@@ -517,8 +517,9 @@ static int direntry_create_vi(struct vir
((is_affected
&& (vn->vn_mode == M_PASTE
|| vn->vn_mode == M_CUT)) ? insert_size : 0)) {
- reiserfs_panic(NULL,
- "vs-8025: set_entry_sizes: (mode==%c, insert_size==%d), invalid length of directory item",
+ reiserfs_panic(NULL, "vs-8025", "(mode==%c, "
+ "insert_size==%d), invalid length of "
+ "directory item",
vn->vn_mode, insert_size);
}
}
@@ -549,7 +550,8 @@ static int direntry_check_left(struct vi
}
if (entries == dir_u->entry_count) {
- reiserfs_panic(NULL, "free space %d, entry_count %d\n", free,
+ reiserfs_panic(NULL, "item_ops-1",
+ "free space %d, entry_count %d", free,
dir_u->entry_count);
}
--- a/fs/reiserfs/journal.c 2007-06-11 14:49:34.000000000 -0400
+++ b/fs/reiserfs/journal.c 2007-06-11 14:50:09.000000000 -0400
@@ -437,8 +437,8 @@ void reiserfs_check_lock_depth(struct su
{
#ifdef CONFIG_SMP
if (current->lock_depth < 0) {
- reiserfs_panic(sb, "%s called without kernel lock held",
- caller);
+ reiserfs_panic(sb, "journal-1", "%s called without kernel "
+ "lock held", caller);
}
#else
;
@@ -575,7 +575,7 @@ static inline void put_journal_list(stru
struct reiserfs_journal_list *jl)
{
if (jl->j_refcount < 1) {
- reiserfs_panic(s, "trans id %lu, refcount at %d",
+ reiserfs_panic(s, "journal-2", "trans id %lu, refcount at %d",
jl->j_trans_id, jl->j_refcount);
}
if (--jl->j_refcount == 0)
@@ -1390,8 +1390,7 @@ static int flush_journal_list(struct sup
count = 0;
if (j_len_saved > journal->j_trans_max) {
- reiserfs_panic(s,
- "journal-715: flush_journal_list, length is %lu, trans id %lu\n",
+ reiserfs_panic(s, "journal-715", "length is %lu, trans id %lu",
j_len_saved, jl->j_trans_id);
return 0;
}
@@ -1423,8 +1422,8 @@ static int flush_journal_list(struct sup
** or wait on a more recent transaction, or just ignore it
*/
if (atomic_read(&(journal->j_wcount)) != 0) {
- reiserfs_panic(s,
- "journal-844: panic journal list is flushing, wcount is not 0\n");
+ reiserfs_panic(s, "journal-844", "journal list is flushing, "
+ "wcount is not 0");
}
cn = jl->j_realblock;
while (cn) {
@@ -1525,13 +1524,13 @@ static int flush_journal_list(struct sup
while (cn) {
if (test_bit(BLOCK_NEEDS_FLUSH, &cn->state)) {
if (!cn->bh) {
- reiserfs_panic(s,
- "journal-1011: cn->bh is NULL\n");
+ reiserfs_panic(s, "journal-1011",
+ "cn->bh is NULL");
}
wait_on_buffer(cn->bh);
if (!cn->bh) {
- reiserfs_panic(s,
- "journal-1012: cn->bh is NULL\n");
+ reiserfs_panic(s, "journal-1012",
+ "cn->bh is NULL");
}
if (unlikely(!buffer_uptodate(cn->bh))) {
#ifdef CONFIG_REISERFS_CHECK
@@ -3212,8 +3211,8 @@ int journal_mark_dirty(struct reiserfs_t
PROC_INFO_INC(p_s_sb, journal.mark_dirty);
if (th->t_trans_id != journal->j_trans_id) {
- reiserfs_panic(th->t_super,
- "journal-1577: handle trans id %ld != current trans id %ld\n",
+ reiserfs_panic(th->t_super, "journal-1577",
+ "handle trans id %ld != current trans id %ld",
th->t_trans_id, journal->j_trans_id);
}
@@ -3252,8 +3251,8 @@ int journal_mark_dirty(struct reiserfs_t
** Nothing can be done here, except make the FS readonly or panic.
*/
if (journal->j_len >= journal->j_trans_max) {
- reiserfs_panic(th->t_super,
- "journal-1413: journal_mark_dirty: j_len (%lu) is too big\n",
+ reiserfs_panic(th->t_super, "journal-1413",
+ "j_len (%lu) is too big",
journal->j_len);
}
@@ -3273,7 +3272,7 @@ int journal_mark_dirty(struct reiserfs_t
if (!cn) {
cn = get_cnode(p_s_sb);
if (!cn) {
- reiserfs_panic(p_s_sb, "get_cnode failed!\n");
+ reiserfs_panic(p_s_sb, "journal-4", "get_cnode failed!");
}
if (th->t_blocks_logged == th->t_blocks_allocated) {
@@ -3541,8 +3540,8 @@ static int check_journal_end(struct reis
BUG_ON(!th->t_trans_id);
if (th->t_trans_id != journal->j_trans_id) {
- reiserfs_panic(th->t_super,
- "journal-1577: handle trans id %ld != current trans id %ld\n",
+ reiserfs_panic(th->t_super, "journal-1577",
+ "handle trans id %ld != current trans id %ld",
th->t_trans_id, journal->j_trans_id);
}
@@ -3621,8 +3620,8 @@ static int check_journal_end(struct reis
}
if (journal->j_start > SB_ONDISK_JOURNAL_SIZE(p_s_sb)) {
- reiserfs_panic(p_s_sb,
- "journal-003: journal_end: j_start (%ld) is too high\n",
+ reiserfs_panic(p_s_sb, "journal-003",
+ "j_start (%ld) is too high",
journal->j_start);
}
return 1;
@@ -3667,8 +3666,8 @@ int journal_mark_freed(struct reiserfs_t
/* set the bit for this block in the journal bitmap for this transaction */
jb = journal->j_current_jl->j_list_bitmap;
if (!jb) {
- reiserfs_panic(p_s_sb,
- "journal-1702: journal_mark_freed, journal_list_bitmap is NULL\n");
+ reiserfs_panic(p_s_sb, "journal-1702",
+ "journal_list_bitmap is NULL");
}
set_bit_in_list_bitmap(p_s_sb, blocknr, jb);
@@ -4028,8 +4027,8 @@ static int do_journal_end(struct reiserf
if (buffer_journaled(cn->bh)) {
jl_cn = get_cnode(p_s_sb);
if (!jl_cn) {
- reiserfs_panic(p_s_sb,
- "journal-1676, get_cnode returned NULL\n");
+ reiserfs_panic(p_s_sb, "journal-1676",
+ "get_cnode returned NULL");
}
if (i == 0) {
jl->j_realblock = jl_cn;
@@ -4045,8 +4044,9 @@ static int do_journal_end(struct reiserf
if (is_block_in_log_or_reserved_area
(p_s_sb, cn->bh->b_blocknr)) {
- reiserfs_panic(p_s_sb,
- "journal-2332: Trying to log block %lu, which is a log block\n",
+ reiserfs_panic(p_s_sb, "journal-2332",
+ "Trying to log block %lu, "
+ "which is a log block",
cn->bh->b_blocknr);
}
jl_cn->blocknr = cn->bh->b_blocknr;
@@ -4230,8 +4230,8 @@ static int do_journal_end(struct reiserf
get_list_bitmap(p_s_sb, journal->j_current_jl);
if (!(journal->j_current_jl->j_list_bitmap)) {
- reiserfs_panic(p_s_sb,
- "journal-1996: do_journal_end, could not get a list bitmap\n");
+ reiserfs_panic(p_s_sb, "journal-1996",
+ "could not get a list bitmap");
}
atomic_set(&(journal->j_jlock), 0);
--- a/fs/reiserfs/lbalance.c 2007-06-11 14:49:34.000000000 -0400
+++ b/fs/reiserfs/lbalance.c 2007-06-11 14:50:08.000000000 -0400
@@ -168,10 +168,11 @@ static int leaf_copy_boundary_item(struc
if (bytes_or_entries == ih_item_len(ih)
&& is_indirect_le_ih(ih))
if (get_ih_free_space(ih))
- reiserfs_panic(NULL,
- "vs-10020: leaf_copy_boundary_item: "
- "last unformatted node must be filled entirely (%h)",
- ih);
+ reiserfs_panic(sb_from_bi(dest_bi),
+ "vs-10020",
+ "last unformatted node "
+ "must be filled "
+ "entirely (%h)", ih);
}
#endif
@@ -622,9 +623,8 @@ static void leaf_define_dest_src_infos(i
break;
default:
- reiserfs_panic(NULL,
- "vs-10250: leaf_define_dest_src_infos: shift type is unknown (%d)",
- shift_mode);
+ reiserfs_panic(sb_from_bi(src_bi), "vs-10250",
+ "shift type is unknown (%d)", shift_mode);
}
RFALSE(src_bi->bi_bh == 0 || dest_bi->bi_bh == 0,
"vs-10260: mode==%d, source (%p) or dest (%p) buffer is initialized incorrectly",
@@ -674,9 +674,9 @@ int leaf_shift_left(struct tree_balance
#ifdef CONFIG_REISERFS_CHECK
if (tb->tb_mode == M_PASTE || tb->tb_mode == M_INSERT) {
print_cur_tb("vs-10275");
- reiserfs_panic(tb->tb_sb,
- "vs-10275: leaf_shift_left: balance condition corrupted (%c)",
- tb->tb_mode);
+ reiserfs_panic(tb->tb_sb, "vs-10275",
+ "balance condition corrupted "
+ "(%c)", tb->tb_mode);
}
#endif
@@ -889,9 +889,12 @@ void leaf_paste_in_buffer(struct buffer_
#ifdef CONFIG_REISERFS_CHECK
if (zeros_number > paste_size) {
+ struct super_block *sb = NULL;
+ if (bi && bi->tb)
+ sb = bi->tb->tb_sb;
print_cur_tb("10177");
- reiserfs_panic(NULL,
- "vs-10177: leaf_paste_in_buffer: ero number == %d, paste_size == %d",
+ reiserfs_panic(sb, "vs-10177",
+ "zeros_number == %d, paste_size == %d",
zeros_number, paste_size);
}
#endif /* CONFIG_REISERFS_CHECK */
--- a/fs/reiserfs/namei.c 2007-06-11 14:49:34.000000000 -0400
+++ b/fs/reiserfs/namei.c 2007-06-11 14:50:08.000000000 -0400
@@ -145,10 +145,9 @@ int search_by_entry_key(struct super_blo
if (!is_direntry_le_ih(de->de_ih) ||
COMP_SHORT_KEYS(&(de->de_ih->ih_key), key)) {
print_block(de->de_bh, 0, -1, -1);
- reiserfs_panic(sb,
- "vs-7005: search_by_entry_key: found item %h is not directory item or "
- "does not belong to the same directory as key %K",
- de->de_ih, key);
+ reiserfs_panic(sb, "vs-7005", "found item %h is not directory "
+ "item or does not belong to the same directory "
+ "as key %K", de->de_ih, key);
}
#endif /* CONFIG_REISERFS_CHECK */
@@ -1194,15 +1193,14 @@ static int entry_points_to_object(const
if (inode) {
if (!de_visible(de->de_deh + de->de_entry_num))
- reiserfs_panic(NULL,
- "vs-7042: entry_points_to_object: entry must be visible");
+ reiserfs_panic(inode->i_sb, "vs-7042",
+ "entry must be visible");
return (de->de_objectid == inode->i_ino) ? 1 : 0;
}
/* this must be added hidden entry */
if (de_visible(de->de_deh + de->de_entry_num))
- reiserfs_panic(NULL,
- "vs-7043: entry_points_to_object: entry must be visible");
+ reiserfs_panic(NULL, "vs-7043", "entry must be visible");
return 1;
}
@@ -1316,8 +1314,8 @@ static int reiserfs_rename(struct inode
new_dentry->d_name.len, old_inode, 0);
if (retval == -EEXIST) {
if (!new_dentry_inode) {
- reiserfs_panic(old_dir->i_sb,
- "vs-7050: new entry is found, new inode == 0\n");
+ reiserfs_panic(old_dir->i_sb, "vs-7050",
+ "new entry is found, new inode == 0");
}
} else if (retval) {
int err = journal_end(&th, old_dir->i_sb, jbegin_count);
--- a/fs/reiserfs/objectid.c 2007-06-11 14:49:34.000000000 -0400
+++ b/fs/reiserfs/objectid.c 2007-06-11 14:50:08.000000000 -0400
@@ -18,8 +18,7 @@
static void check_objectid_map(struct super_block *s, __le32 * map)
{
if (le32_to_cpu(map[0]) != 1)
- reiserfs_panic(s,
- "vs-15010: check_objectid_map: map corrupted: %lx",
+ reiserfs_panic(s, "vs-15010", "map corrupted: %lx",
(long unsigned int)le32_to_cpu(map[0]));
// FIXME: add something else here
--- a/fs/reiserfs/prints.c 2007-06-11 14:49:34.000000000 -0400
+++ b/fs/reiserfs/prints.c 2007-06-11 14:50:09.000000000 -0400
@@ -356,11 +356,21 @@ void reiserfs_debug(struct super_block *
extern struct tree_balance *cur_tb;
#endif
-void reiserfs_panic(struct super_block *sb, const char *fmt, ...)
+void __reiserfs_panic(struct super_block *sb, const char *id,
+ const char *function, const char *fmt, ...)
{
do_reiserfs_warning(fmt);
- panic(KERN_EMERG "REISERFS: panic (device %s): %s\n",
- reiserfs_bdevname(sb), error_buf);
+
+#ifdef CONFIG_REISERFS_CHECK
+ dump_stack();
+#endif
+ if (sb)
+ panic(KERN_WARNING "REISERFS panic (device %s): %s%s%s: %s\n",
+ sb->s_id, id ? id : "", id ? " " : "",
+ function, error_buf);
+ else
+ panic(KERN_WARNING "REISERFS panic: %s%s%s: %s\n",
+ id ? id : "", id ? " " : "", function, error_buf);
}
void reiserfs_abort(struct super_block *sb, int errno, const char *fmt, ...)
@@ -679,12 +689,10 @@ static void check_leaf_block_head(struct
blkh = B_BLK_HEAD(bh);
nr = blkh_nr_item(blkh);
if (nr > (bh->b_size - BLKH_SIZE) / IH_SIZE)
- reiserfs_panic(NULL,
- "vs-6010: check_leaf_block_head: invalid item number %z",
+ reiserfs_panic(NULL, "vs-6010", "invalid item number %z",
bh);
if (blkh_free_space(blkh) > bh->b_size - BLKH_SIZE - IH_SIZE * nr)
- reiserfs_panic(NULL,
- "vs-6020: check_leaf_block_head: invalid free space %z",
+ reiserfs_panic(NULL, "vs-6020", "invalid free space %z",
bh);
}
@@ -695,21 +703,15 @@ static void check_internal_block_head(st
blkh = B_BLK_HEAD(bh);
if (!(B_LEVEL(bh) > DISK_LEAF_NODE_LEVEL && B_LEVEL(bh) <= MAX_HEIGHT))
- reiserfs_panic(NULL,
- "vs-6025: check_internal_block_head: invalid level %z",
- bh);
+ reiserfs_panic(NULL, "vs-6025", "invalid level %z", bh);
if (B_NR_ITEMS(bh) > (bh->b_size - BLKH_SIZE) / IH_SIZE)
- reiserfs_panic(NULL,
- "vs-6030: check_internal_block_head: invalid item number %z",
- bh);
+ reiserfs_panic(NULL, "vs-6030", "invalid item number %z", bh);
if (B_FREE_SPACE(bh) !=
bh->b_size - BLKH_SIZE - KEY_SIZE * B_NR_ITEMS(bh) -
DC_SIZE * (B_NR_ITEMS(bh) + 1))
- reiserfs_panic(NULL,
- "vs-6040: check_internal_block_head: invalid free space %z",
- bh);
+ reiserfs_panic(NULL, "vs-6040", "invalid free space %z", bh);
}
--- a/fs/reiserfs/stree.c 2007-06-11 14:49:34.000000000 -0400
+++ b/fs/reiserfs/stree.c 2007-06-11 14:50:08.000000000 -0400
@@ -366,9 +366,8 @@ inline void decrement_bcount(struct buff
put_bh(p_s_bh);
return;
}
- reiserfs_panic(NULL,
- "PAP-5070: decrement_bcount: trying to free free buffer %b",
- p_s_bh);
+ reiserfs_panic(NULL, "PAP-5070",
+ "trying to free free buffer %b", p_s_bh);
}
}
@@ -713,8 +712,8 @@ int search_by_key(struct super_block *p_
#ifdef CONFIG_REISERFS_CHECK
if (cur_tb) {
print_cur_tb("5140");
- reiserfs_panic(p_s_sb,
- "PAP-5140: search_by_key: schedule occurred in do_balance!");
+ reiserfs_panic(p_s_sb, "PAP-5140",
+ "schedule occurred in do_balance!");
}
#endif
@@ -1514,8 +1513,8 @@ static void indirect_to_direct_roll_back
/* look for the last byte of the tail */
if (search_for_position_by_key(inode->i_sb, &tail_key, path) ==
POSITION_NOT_FOUND)
- reiserfs_panic(inode->i_sb,
- "vs-5615: indirect_to_direct_roll_back: found invalid item");
+ reiserfs_panic(inode->i_sb, "vs-5615",
+ "found invalid item");
RFALSE(path->pos_in_item !=
ih_item_len(PATH_PITEM_HEAD(path)) - 1,
"vs-5616: appended bytes found");
@@ -1615,8 +1614,8 @@ int reiserfs_cut_from_item(struct reiser
print_block(PATH_PLAST_BUFFER(p_s_path), 3,
PATH_LAST_POSITION(p_s_path) - 1,
PATH_LAST_POSITION(p_s_path) + 1);
- reiserfs_panic(p_s_sb,
- "PAP-5580: reiserfs_cut_from_item: item to convert does not exist (%K)",
+ reiserfs_panic(p_s_sb, "PAP-5580", "item to "
+ "convert does not exist (%K)",
p_s_item_key);
}
continue;
@@ -1696,22 +1695,20 @@ int reiserfs_cut_from_item(struct reiser
sure, that we exactly remove last unformatted node pointer
of the item */
if (!is_indirect_le_ih(le_ih))
- reiserfs_panic(p_s_sb,
- "vs-5652: reiserfs_cut_from_item: "
+ reiserfs_panic(p_s_sb, "vs-5652",
"item must be indirect %h", le_ih);
if (c_mode == M_DELETE && ih_item_len(le_ih) != UNFM_P_SIZE)
- reiserfs_panic(p_s_sb,
- "vs-5653: reiserfs_cut_from_item: "
- "completing indirect2direct conversion indirect item %h "
- "being deleted must be of 4 byte long",
- le_ih);
+ reiserfs_panic(p_s_sb, "vs-5653", "completing "
+ "indirect2direct conversion indirect "
+ "item %h being deleted must be of "
+ "4 byte long", le_ih);
if (c_mode == M_CUT
&& s_cut_balance.insert_size[0] != -UNFM_P_SIZE) {
- reiserfs_panic(p_s_sb,
- "vs-5654: reiserfs_cut_from_item: "
- "can not complete indirect2direct conversion of %h (CUT, insert_size==%d)",
+ reiserfs_panic(p_s_sb, "vs-5654", "can not complete "
+ "indirect2direct conversion of %h "
+ "(CUT, insert_size==%d)",
le_ih, s_cut_balance.insert_size[0]);
}
/* it would be useful to make sure, that right neighboring
@@ -1926,10 +1923,10 @@ static void check_research_for_paste(str
|| op_bytes_number(found_ih,
get_last_bh(path)->b_size) !=
pos_in_item(path))
- reiserfs_panic(NULL,
- "PAP-5720: check_research_for_paste: "
- "found direct item %h or position (%d) does not match to key %K",
- found_ih, pos_in_item(path), p_s_key);
+ reiserfs_panic(NULL, "PAP-5720", "found direct item "
+ "%h or position (%d) does not match "
+ "to key %K", found_ih,
+ pos_in_item(path), p_s_key);
}
if (is_indirect_le_ih(found_ih)) {
if (le_ih_k_offset(found_ih) +
@@ -1938,9 +1935,9 @@ static void check_research_for_paste(str
cpu_key_k_offset(p_s_key)
|| I_UNFM_NUM(found_ih) != pos_in_item(path)
|| get_ih_free_space(found_ih) != 0)
- reiserfs_panic(NULL,
- "PAP-5730: check_research_for_paste: "
- "found indirect item (%h) or position (%d) does not match to key (%K)",
+ reiserfs_panic(NULL, "PAP-5730", "found indirect "
+ "item (%h) or position (%d) does not "
+ "match to key (%K)",
found_ih, pos_in_item(path), p_s_key);
}
}
--- a/fs/reiserfs/tail_conversion.c 2007-06-11 14:49:34.000000000 -0400
+++ b/fs/reiserfs/tail_conversion.c 2007-06-11 14:50:08.000000000 -0400
@@ -92,8 +92,7 @@ int direct2indirect(struct reiserfs_tran
last item of the file */
if (search_for_position_by_key(sb, &end_key, path) ==
POSITION_FOUND)
- reiserfs_panic(sb,
- "PAP-14050: direct2indirect: "
+ reiserfs_panic(sb, "PAP-14050",
"direct item (%K) not found", &end_key);
p_le_ih = PATH_PITEM_HEAD(path);
RFALSE(!is_direct_le_ih(p_le_ih),
@@ -214,8 +213,7 @@ int indirect2direct(struct reiserfs_tran
/* re-search indirect item */
if (search_for_position_by_key(p_s_sb, p_s_item_key, p_s_path)
== POSITION_NOT_FOUND)
- reiserfs_panic(p_s_sb,
- "PAP-5520: indirect2direct: "
+ reiserfs_panic(p_s_sb, "PAP-5520",
"item to be converted %K does not exist",
p_s_item_key);
copy_item_head(&s_ih, PATH_PITEM_HEAD(p_s_path));
@@ -224,8 +222,8 @@ int indirect2direct(struct reiserfs_tran
(ih_item_len(&s_ih) / UNFM_P_SIZE -
1) * p_s_sb->s_blocksize;
if (pos != pos1)
- reiserfs_panic(p_s_sb, "vs-5530: indirect2direct: "
- "tail position changed while we were reading it");
+ reiserfs_panic(p_s_sb, "vs-5530", "tail position "
+ "changed while we were reading it");
#endif
}
--- a/include/linux/reiserfs_fs.h 2007-06-11 14:49:34.000000000 -0400
+++ b/include/linux/reiserfs_fs.h 2007-06-11 14:50:09.000000000 -0400
@@ -84,11 +84,11 @@ void __reiserfs_warning(struct super_blo
/* assertions handling */
/** always check a condition and panic if it's false. */
-#define RASSERT( cond, format, args... ) \
-if( !( cond ) ) \
- reiserfs_panic( NULL, "reiserfs[%i]: assertion " #cond " failed at " \
+#define RASSERT( cond, format, args... ) \
+if( !( cond ) ) \
+ reiserfs_panic( NULL, "assertion failure", "(" #cond ") at " \
__FILE__ ":%i:%s: " format "\n", \
- in_interrupt() ? -1 : current -> pid, __LINE__ , __FUNCTION__ , ##args )
+ __LINE__ , __FUNCTION__ , ##args )
#if defined( CONFIG_REISERFS_CHECK )
#define RFALSE( cond, format, args... ) RASSERT( !( cond ), format, ##args )
@@ -1431,6 +1431,16 @@ struct buffer_info {
int bi_position;
};
+static inline struct super_block *sb_from_tb(struct tree_balance *tb)
+{
+ return tb ? tb->tb_sb : NULL;
+}
+
+static inline struct super_block *sb_from_bi(struct buffer_info *bi)
+{
+ return bi ? sb_from_tb(bi->tb) : NULL;
+}
+
/* there are 4 types of items: stat data, directory item, indirect, direct.
+-------------------+------------+--------------+------------+
| | k_offset | k_uniqueness | mergeable? |
@@ -1977,8 +1987,11 @@ int fix_nodes(int n_op_mode, struct tree
void unfix_nodes(struct tree_balance *);
/* prints.c */
-void reiserfs_panic(struct super_block *s, const char *fmt, ...)
+void __reiserfs_panic(struct super_block *s, const char *id,
+ const char *function, const char *fmt, ...)
__attribute__ ((noreturn));
+#define reiserfs_panic(s, id, fmt, args...) \
+ __reiserfs_panic(s, id, __FUNCTION__, fmt, ##args)
void reiserfs_info(struct super_block *s, const char *fmt, ...);
void reiserfs_debug(struct super_block *s, int level, const char *fmt, ...);
void print_indirect_item(struct buffer_head *bh, int item_num);
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 43+ messages in thread
* [patch 09/40] reiserfs: rearrange journal abort
2007-06-11 19:03 [patch 00/40] reiserfs: patch queue (v2) jeffm
` (7 preceding siblings ...)
2007-06-11 19:03 ` [patch 08/40] reiserfs: rework reiserfs_panic jeffm
@ 2007-06-11 19:03 ` jeffm
2007-06-11 19:03 ` [patch 10/40] reiserfs: introduce reiserfs_error() jeffm
` (31 subsequent siblings)
40 siblings, 0 replies; 43+ messages in thread
From: jeffm @ 2007-06-11 19:03 UTC (permalink / raw)
To: ReiserFS Mailing List
[-- Attachment #1: reiserfs-rearrange-journal-abort.diff --]
[-- Type: text/plain, Size: 2904 bytes --]
This patch kills off reiserfs_journal_abort as it is never called, and
combines __reiserfs_journal_abort_{soft,hard} into one function called
reiserfs_abort_journal, which performs the same work. It is silent
as opposed to the old version, since the message was always issued
after a regular 'abort' message.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
fs/reiserfs/journal.c | 23 ++++-------------------
fs/reiserfs/prints.c | 2 +-
include/linux/reiserfs_fs.h | 2 +-
3 files changed, 6 insertions(+), 21 deletions(-)
--- a/fs/reiserfs/journal.c 2007-06-11 14:49:34.000000000 -0400
+++ b/fs/reiserfs/journal.c 2007-06-11 14:50:04.000000000 -0400
@@ -4256,14 +4256,15 @@ static int do_journal_end(struct reiserf
return journal->j_errno;
}
-static void __reiserfs_journal_abort_hard(struct super_block *sb)
+/* Send the file system read only and refuse new transactions */
+void reiserfs_abort_journal(struct super_block *sb, int errno)
{
struct reiserfs_journal *journal = SB_JOURNAL(sb);
if (test_bit(J_ABORTED, &journal->j_state))
return;
- printk(KERN_CRIT "REISERFS: Aborting journal for filesystem on %s\n",
- reiserfs_bdevname(sb));
+ if (!journal->j_errno)
+ journal->j_errno = errno;
sb->s_flags |= MS_RDONLY;
set_bit(J_ABORTED, &journal->j_state);
@@ -4273,19 +4274,3 @@ static void __reiserfs_journal_abort_har
#endif
}
-static void __reiserfs_journal_abort_soft(struct super_block *sb, int errno)
-{
- struct reiserfs_journal *journal = SB_JOURNAL(sb);
- if (test_bit(J_ABORTED, &journal->j_state))
- return;
-
- if (!journal->j_errno)
- journal->j_errno = errno;
-
- __reiserfs_journal_abort_hard(sb);
-}
-
-void reiserfs_journal_abort(struct super_block *sb, int errno)
-{
- return __reiserfs_journal_abort_soft(sb, errno);
-}
--- a/fs/reiserfs/prints.c 2007-06-11 14:49:34.000000000 -0400
+++ b/fs/reiserfs/prints.c 2007-06-11 14:50:09.000000000 -0400
@@ -389,7 +389,7 @@ void reiserfs_abort(struct super_block *
error_buf);
sb->s_flags |= MS_RDONLY;
- reiserfs_journal_abort(sb, errno);
+ reiserfs_abort_journal(sb, errno);
}
/* this prints internal nodes (4 keys/items in line) (dc_number,
--- a/include/linux/reiserfs_fs.h 2007-06-11 14:49:34.000000000 -0400
+++ b/include/linux/reiserfs_fs.h 2007-06-11 14:50:09.000000000 -0400
@@ -1753,7 +1753,7 @@ int journal_begin(struct reiserfs_transa
struct super_block *p_s_sb, unsigned long);
int journal_join_abort(struct reiserfs_transaction_handle *,
struct super_block *p_s_sb, unsigned long);
-void reiserfs_journal_abort(struct super_block *sb, int errno);
+void reiserfs_abort_journal(struct super_block *sb, int errno);
void reiserfs_abort(struct super_block *sb, int errno, const char *fmt, ...);
int reiserfs_allocate_list_bitmaps(struct super_block *s,
struct reiserfs_list_bitmap *, int);
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 43+ messages in thread
* [patch 10/40] reiserfs: introduce reiserfs_error()
2007-06-11 19:03 [patch 00/40] reiserfs: patch queue (v2) jeffm
` (8 preceding siblings ...)
2007-06-11 19:03 ` [patch 09/40] reiserfs: rearrange journal abort jeffm
@ 2007-06-11 19:03 ` jeffm
2007-06-11 19:03 ` [patch 11/40] reiserfs: use reiserfs_error() jeffm
` (30 subsequent siblings)
40 siblings, 0 replies; 43+ messages in thread
From: jeffm @ 2007-06-11 19:03 UTC (permalink / raw)
To: ReiserFS Mailing List
[-- Attachment #1: reiserfs-add-reiserfs_error.diff --]
[-- Type: text/plain, Size: 2336 bytes --]
Although reiserfs can currently handle severe errors such as journal failure,
it cannot handle less severe errors like metadata i/o failure. The following
patch adds a reiserfs_error() function akin to the one in ext3.
Subsequent patches will use this new error handler to handle errors more
gracefully in general.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
--
fs/reiserfs/prints.c | 23 +++++++++++++++++++++++
include/linux/reiserfs_fs.h | 3 +++
2 files changed, 26 insertions(+)
--- a/fs/reiserfs/prints.c 2007-06-11 14:49:34.000000000 -0400
+++ b/fs/reiserfs/prints.c 2007-06-11 14:50:04.000000000 -0400
@@ -373,6 +373,29 @@ void __reiserfs_panic(struct super_block
id ? id : "", id ? " " : "", function, error_buf);
}
+void __reiserfs_error(struct super_block *sb, const char *id,
+ const char *function, const char *fmt, ...)
+{
+ do_reiserfs_warning(fmt);
+
+ if (reiserfs_error_panic(sb))
+ __reiserfs_panic(sb, id, function, error_buf);
+
+ if (id && id[0])
+ printk(KERN_CRIT "REISERFS error (device %s): %s %s: %s\n",
+ sb->s_id, id, function, error_buf);
+ else
+ printk(KERN_CRIT "REISERFS error (device %s): %s: %s\n",
+ sb->s_id, function, error_buf);
+
+ if (sb->s_flags & MS_RDONLY)
+ return;
+
+ reiserfs_info(sb, "Remounting filesystem read-only\n");
+ sb->s_flags |= MS_RDONLY;
+ reiserfs_abort_journal(sb, -EIO);
+}
+
void reiserfs_abort(struct super_block *sb, int errno, const char *fmt, ...)
{
do_reiserfs_warning(fmt);
--- a/include/linux/reiserfs_fs.h 2007-06-11 14:49:35.000000000 -0400
+++ b/include/linux/reiserfs_fs.h 2007-06-11 14:50:08.000000000 -0400
@@ -1992,6 +1992,9 @@ void __reiserfs_panic(struct super_block
__attribute__ ((noreturn));
#define reiserfs_panic(s, id, fmt, args...) \
__reiserfs_panic(s, id, __FUNCTION__, fmt, ##args)
+void __reiserfs_error(struct super_block *s, const char *id, const char *function, const char *fmt, ...);
+#define reiserfs_error(s, id, fmt, args...) \
+ __reiserfs_error(s, id, __FUNCTION__, fmt, ##args)
void reiserfs_info(struct super_block *s, const char *fmt, ...);
void reiserfs_debug(struct super_block *s, int level, const char *fmt, ...);
void print_indirect_item(struct buffer_head *bh, int item_num);
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 43+ messages in thread
* [patch 11/40] reiserfs: use reiserfs_error()
2007-06-11 19:03 [patch 00/40] reiserfs: patch queue (v2) jeffm
` (9 preceding siblings ...)
2007-06-11 19:03 ` [patch 10/40] reiserfs: introduce reiserfs_error() jeffm
@ 2007-06-11 19:03 ` jeffm
2007-06-11 19:03 ` [patch 12/40] reiserfs: simplify xattr internal file lookups/opens jeffm
` (29 subsequent siblings)
40 siblings, 0 replies; 43+ messages in thread
From: jeffm @ 2007-06-11 19:03 UTC (permalink / raw)
To: ReiserFS Mailing List
[-- Attachment #1: reiserfs-use-reiserfs_error.diff --]
[-- Type: text/plain, Size: 23934 bytes --]
This patch makes many paths that are currently using warnings to handle
the error.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
--
fs/reiserfs/bitmap.c | 55 ++++++++++++++++-----------------
fs/reiserfs/file.c | 14 ++++----
fs/reiserfs/inode.c | 43 ++++++++++++-------------
fs/reiserfs/lbalance.c | 20 ++++++------
fs/reiserfs/namei.c | 24 +++++++-------
fs/reiserfs/objectid.c | 4 +-
fs/reiserfs/stree.c | 70 +++++++++++++++++++++---------------------
fs/reiserfs/super.c | 15 ++++-----
fs/reiserfs/tail_conversion.c | 6 +--
fs/reiserfs/xattr.c | 21 ++++++------
10 files changed, 134 insertions(+), 138 deletions(-)
--- a/fs/reiserfs/bitmap.c 2007-06-11 14:49:34.000000000 -0400
+++ b/fs/reiserfs/bitmap.c 2007-06-11 14:49:35.000000000 -0400
@@ -61,9 +61,9 @@ int is_reusable(struct super_block *s, b
int bmap, offset;
if (block == 0 || block >= SB_BLOCK_COUNT(s)) {
- reiserfs_warning(s, "vs-4010",
- "block number is out of range %lu (%u)",
- block, SB_BLOCK_COUNT(s));
+ reiserfs_error(s, "vs-4010",
+ "block number is out of range %lu (%u)",
+ block, SB_BLOCK_COUNT(s));
return 0;
}
@@ -75,30 +75,30 @@ int is_reusable(struct super_block *s, b
&(REISERFS_SB(s)->s_properties)))) {
b_blocknr_t bmap1 = REISERFS_SB(s)->s_sbh->b_blocknr + 1;
if (block >= bmap1 && block <= bmap1 + SB_BMAP_NR(s)) {
- reiserfs_warning(s, "vs-4019", "bitmap block "
- "%lu(%u) can't be freed or reused",
- block, SB_BMAP_NR(s));
+ reiserfs_error(s, "vs-4019", "bitmap block "
+ "%lu(%u) can't be freed or reused",
+ block, SB_BMAP_NR(s));
return 0;
}
} else {
if (offset == 0) {
- reiserfs_warning(s, "vs-4020", "bitmap block "
- "%lu(%u) can't be freed or reused",
- block, SB_BMAP_NR(s));
+ reiserfs_error(s, "vs-4020", "bitmap block "
+ "%lu(%u) can't be freed or reused",
+ block, SB_BMAP_NR(s));
return 0;
}
}
if (bmap >= SB_BMAP_NR(s)) {
- reiserfs_warning(s, "vs-4030", "there is no so many "
- "bitmap blocks: block=%lu, bitmap_nr=%d",
- block, bmap);
+ reiserfs_error(s, "vs-4030", "there is no so many "
+ "bitmap blocks: block=%lu, bitmap_nr=%d",
+ block, bmap);
return 0;
}
if (bit_value == 0 && block == SB_ROOT_BLOCK(s)) {
- reiserfs_warning(s, "vs-4050", "this is root block (%u), "
- "it must be busy", SB_ROOT_BLOCK(s));
+ reiserfs_error(s, "vs-4050", "this is root block (%u), "
+ "it must be busy", SB_ROOT_BLOCK(s));
return 0;
}
@@ -149,8 +149,8 @@ static int scan_bitmap_block(struct reis
/* - I mean `a window of zero bits' as in description of this function - Zam. */
if (!bi) {
- reiserfs_warning(s, "jdm-4055", "NULL bitmap info pointer "
- "for bitmap %d", bmap_n);
+ reiserfs_error(s, "jdm-4055", "NULL bitmap info pointer "
+ "for bitmap %d", bmap_n);
return 0;
}
@@ -398,8 +398,8 @@ static void _reiserfs_free_block(struct
get_bit_address(s, block, &nr, &offset);
if (nr >= sb_bmap_nr(rs)) {
- reiserfs_warning(s, "vs-4075",
- "block %lu is out of range", block);
+ reiserfs_error(s, "vs-4075",
+ "block %lu is out of range", block);
return;
}
@@ -411,8 +411,8 @@ static void _reiserfs_free_block(struct
/* clear bit for the given block in bit map */
if (!reiserfs_test_and_clear_le_bit(offset, bmbh->b_data)) {
- reiserfs_warning(s, "vs-4080",
- "block %lu: bit already cleared", block);
+ reiserfs_error(s, "vs-4080",
+ "block %lu: bit already cleared", block);
}
apbi[nr].free_count++;
journal_mark_dirty(th, s, bmbh);
@@ -471,8 +471,8 @@ static void __discard_prealloc(struct re
BUG_ON(!th->t_trans_id);
#ifdef CONFIG_REISERFS_CHECK
if (ei->i_prealloc_count < 0)
- reiserfs_warning(th->t_super, "zam-4001",
- "inode has negative prealloc blocks count.");
+ reiserfs_error(th->t_super, "zam-4001",
+ "inode has negative prealloc blocks count.");
#endif
while (ei->i_prealloc_count > 0) {
reiserfs_free_prealloc_block(th, inode, ei->i_prealloc_block);
@@ -508,9 +508,9 @@ void reiserfs_discard_all_prealloc(struc
i_prealloc_list);
#ifdef CONFIG_REISERFS_CHECK
if (!ei->i_prealloc_count) {
- reiserfs_warning(th->t_super, "zam-4001",
- "inode is in prealloc list but has "
- "no preallocated blocks.");
+ reiserfs_error(th->t_super, "zam-4001",
+ "inode is in prealloc list but has "
+ "no preallocated blocks.");
}
#endif
__discard_prealloc(th, ei);
@@ -1287,8 +1287,9 @@ void reiserfs_cache_bitmap_metadata(stru
}
}
}
- /* The first bit must ALWAYS be 1 */
- BUG_ON(info->first_zero_hint == 0);
+ if (info->first_zero_hint == 0)
+ reiserfs_error(sb, "reiserfs-2025", "bitmap block %lu is "
+ "corrupted: first bit must be 1", bh->b_blocknr);
}
struct buffer_head *reiserfs_read_bitmap_block(struct super_block *sb,
--- a/fs/reiserfs/file.c 2007-06-11 14:49:34.000000000 -0400
+++ b/fs/reiserfs/file.c 2007-06-11 14:50:06.000000000 -0400
@@ -395,7 +395,7 @@ static int reiserfs_allocate_blocks_for_
if (res != ITEM_NOT_FOUND) {
/* item should not exist, otherwise we have error */
if (res != -ENOSPC) {
- reiserfs_warning(inode->
+ reiserfs_error(inode->
i_sb,
"green-9008",
"search_by_key (%K) returned %d",
@@ -412,7 +412,7 @@ static int reiserfs_allocate_blocks_for_
inode,
(char *)zeros);
} else {
- reiserfs_panic(inode->i_sb,
+ reiserfs_error(inode->i_sb,
"green-9011",
"Unexpected key type %K",
&key);
@@ -600,11 +600,11 @@ static int reiserfs_allocate_blocks_for_
/* Well, if we have found such item already, or some error
occured, we need to warn user and return error */
if (res != -ENOSPC) {
- reiserfs_warning(inode->i_sb,
- "green-9009",
- "search_by_key (%K) "
- "returned %d", &key,
- res);
+ reiserfs_error(inode->i_sb,
+ "green-9009",
+ "search_by_key (%K) "
+ "returned %d", &key,
+ res);
}
res = -EIO;
goto error_exit_free_blocks;
--- a/fs/reiserfs/inode.c 2007-06-11 14:49:34.000000000 -0400
+++ b/fs/reiserfs/inode.c 2007-06-11 14:50:08.000000000 -0400
@@ -837,11 +837,11 @@ int reiserfs_get_block(struct inode *ino
tail_offset);
if (retval) {
if (retval != -ENOSPC)
- reiserfs_warning(inode->i_sb,
- "clm-6004",
- "convert tail failed inode %lu, error %d",
- inode->i_ino,
- retval);
+ reiserfs_error(inode->i_sb,
+ "clm-6004",
+ "convert tail failed inode %lu, error %d",
+ inode->i_ino,
+ retval);
if (allocated_block_nr) {
/* the bitmap, the super, and the stat data == 3 */
if (!th)
@@ -1327,10 +1327,9 @@ void reiserfs_update_sd_size(struct reis
/* look for the object's stat data */
retval = search_item(inode->i_sb, &key, &path);
if (retval == IO_ERROR) {
- reiserfs_warning(inode->i_sb, "vs-13050",
- "i/o failure occurred trying to "
- "update %K stat data",
- &key);
+ reiserfs_error(inode->i_sb, "vs-13050",
+ "i/o failure occurred trying to "
+ "update %K stat data", &key);
return;
}
if (retval == ITEM_NOT_FOUND) {
@@ -1419,9 +1418,9 @@ void reiserfs_read_locked_inode(struct i
/* look for the object's stat data */
retval = search_item(inode->i_sb, &key, &path_to_sd);
if (retval == IO_ERROR) {
- reiserfs_warning(inode->i_sb, "vs-13070",
- "i/o failure occurred trying to find "
- "stat data of %K", &key);
+ reiserfs_error(inode->i_sb, "vs-13070",
+ "i/o failure occurred trying to find "
+ "stat data of %K", &key);
reiserfs_make_bad_inode(inode);
return;
}
@@ -1690,8 +1689,8 @@ static int reiserfs_new_directory(struct
/* look for place in the tree for new item */
retval = search_item(sb, &key, path);
if (retval == IO_ERROR) {
- reiserfs_warning(sb, "vs-13080",
- "i/o failure occurred creating new directory");
+ reiserfs_error(sb, "vs-13080",
+ "i/o failure occurred creating new directory");
return -EIO;
}
if (retval == ITEM_FOUND) {
@@ -1730,8 +1729,8 @@ static int reiserfs_new_symlink(struct r
/* look for place in the tree for new item */
retval = search_item(sb, &key, path);
if (retval == IO_ERROR) {
- reiserfs_warning(sb, "vs-13080",
- "i/o failure occurred creating new symlink");
+ reiserfs_error(sb, "vs-13080",
+ "i/o failure occurred creating new symlink");
return -EIO;
}
if (retval == ITEM_FOUND) {
@@ -2051,10 +2050,8 @@ static int grab_tail_page(struct inode *
** I've screwed up the code to find the buffer, or the code to
** call prepare_write
*/
- reiserfs_warning(p_s_inode->i_sb, "clm-6000",
- "error reading block %lu on dev %s",
- bh->b_blocknr,
- reiserfs_bdevname(p_s_inode->i_sb));
+ reiserfs_error(p_s_inode->i_sb, "clm-6000",
+ "error reading block %lu", bh->b_blocknr);
error = -EIO;
goto unlock;
}
@@ -2096,9 +2093,9 @@ int reiserfs_truncate_file(struct inode
// and get_block_create_0 could not find a block to read in,
// which is ok.
if (error != -ENOENT)
- reiserfs_warning(p_s_inode->i_sb, "clm-6001",
- "grab_tail_page failed %d",
- error);
+ reiserfs_error(p_s_inode->i_sb, "clm-6001",
+ "grab_tail_page failed %d",
+ error);
page = NULL;
bh = NULL;
}
--- a/fs/reiserfs/lbalance.c 2007-06-11 14:49:34.000000000 -0400
+++ b/fs/reiserfs/lbalance.c 2007-06-11 14:50:04.000000000 -0400
@@ -1290,17 +1290,17 @@ void leaf_paste_entries(struct buffer_he
prev = (i != 0) ? deh_location(&(deh[i - 1])) : 0;
if (prev && prev <= deh_location(&(deh[i])))
- reiserfs_warning(NULL, "vs-10240",
- "directory item (%h) "
- "corrupted (prev %a, "
- "cur(%d) %a)",
- ih, deh + i - 1, i, deh + i);
+ reiserfs_error(NULL, "vs-10240",
+ "directory item (%h) "
+ "corrupted (prev %a, "
+ "cur(%d) %a)",
+ ih, deh + i - 1, i, deh + i);
if (next && next >= deh_location(&(deh[i])))
- reiserfs_warning(NULL, "vs-10250",
- "directory item (%h) "
- "corrupted (cur(%d) %a, "
- "next %a)",
- ih, i, deh + i, deh + i + 1);
+ reiserfs_error(NULL, "vs-10250",
+ "directory item (%h) "
+ "corrupted (cur(%d) %a, "
+ "next %a)",
+ ih, i, deh + i, deh + i + 1);
}
}
#endif
--- a/fs/reiserfs/namei.c 2007-06-11 14:49:34.000000000 -0400
+++ b/fs/reiserfs/namei.c 2007-06-11 14:50:08.000000000 -0400
@@ -120,8 +120,8 @@ int search_by_entry_key(struct super_blo
switch (retval) {
case ITEM_NOT_FOUND:
if (!PATH_LAST_POSITION(path)) {
- reiserfs_warning(sb, "vs-7000", "search_by_key "
- "returned item position == 0");
+ reiserfs_error(sb, "vs-7000", "search_by_key "
+ "returned item position == 0");
pathrelse(path);
return IO_ERROR;
}
@@ -135,7 +135,7 @@ int search_by_entry_key(struct super_blo
default:
pathrelse(path);
- reiserfs_warning(sb, "vs-7002", "no path to here");
+ reiserfs_error(sb, "vs-7002", "no path to here");
return IO_ERROR;
}
@@ -298,7 +298,7 @@ static int reiserfs_find_entry(struct in
search_by_entry_key(dir->i_sb, &key_to_search,
path_to_entry, de);
if (retval == IO_ERROR) {
- reiserfs_warning(dir->i_sb, "zam-7001", "io error");
+ reiserfs_error(dir->i_sb, "zam-7001", "io error");
return IO_ERROR;
}
@@ -490,9 +490,9 @@ static int reiserfs_add_entry(struct rei
}
if (retval != NAME_FOUND) {
- reiserfs_warning(dir->i_sb, "zam-7002",
- "reiserfs_find_entry() returned "
- "unexpected value (%d)", retval);
+ reiserfs_error(dir->i_sb, "zam-7002",
+ "reiserfs_find_entry() returned "
+ "unexpected value (%d)", retval);
}
return -EEXIST;
@@ -902,9 +902,9 @@ static int reiserfs_rmdir(struct inode *
goto end_rmdir;
if (inode->i_nlink != 2 && inode->i_nlink != 1)
- reiserfs_warning(inode->i_sb, "reiserfs-7040",
- "empty directory has nlink != 2 (%d)",
- inode->i_nlink);
+ reiserfs_error(inode->i_sb, "reiserfs-7040",
+ "empty directory has nlink != 2 (%d)",
+ inode->i_nlink);
clear_nlink(inode);
inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC;
@@ -1495,8 +1495,8 @@ static int reiserfs_rename(struct inode
if (reiserfs_cut_from_item
(&th, &old_entry_path, &(old_de.de_entry_key), old_dir, NULL,
0) < 0)
- reiserfs_warning(old_dir->i_sb, "vs-7060",
- "couldn't not cut old name. Fsck later?");
+ reiserfs_error(old_dir->i_sb, "vs-7060",
+ "couldn't not cut old name. Fsck later?");
old_dir->i_size -= DEH_SIZE + old_de.de_entrylen;
--- a/fs/reiserfs/objectid.c 2007-06-11 14:49:34.000000000 -0400
+++ b/fs/reiserfs/objectid.c 2007-06-11 14:50:04.000000000 -0400
@@ -160,8 +160,8 @@ void reiserfs_release_objectid(struct re
i += 2;
}
- reiserfs_warning(s, "vs-15011", "tried to free free object id (%lu)",
- (long unsigned)objectid_to_release);
+ reiserfs_error(s, "vs-15011", "tried to free free object id (%lu)",
+ (long unsigned)objectid_to_release);
}
int reiserfs_convert_objectid_map_v1(struct super_block *s)
--- a/fs/reiserfs/stree.c 2007-06-11 14:49:34.000000000 -0400
+++ b/fs/reiserfs/stree.c 2007-06-11 14:50:04.000000000 -0400
@@ -443,24 +443,24 @@ static int is_leaf(char *buf, int blocks
blkh = (struct block_head *)buf;
if (blkh_level(blkh) != DISK_LEAF_NODE_LEVEL) {
- reiserfs_warning(NULL, "reiserfs-5080",
- "this should be caught earlier");
+ reiserfs_error(NULL, "reiserfs-5080",
+ "this should be caught earlier");
return 0;
}
nr = blkh_nr_item(blkh);
if (nr < 1 || nr > ((blocksize - BLKH_SIZE) / (IH_SIZE + MIN_ITEM_LEN))) {
/* item number is too big or too small */
- reiserfs_warning(NULL, "reiserfs-5081",
- "nr_item seems wrong: %z", bh);
+ reiserfs_error(NULL, "reiserfs-5081",
+ "nr_item seems wrong: %z", bh);
return 0;
}
ih = (struct item_head *)(buf + BLKH_SIZE) + nr - 1;
used_space = BLKH_SIZE + IH_SIZE * nr + (blocksize - ih_location(ih));
if (used_space != blocksize - blkh_free_space(blkh)) {
/* free space does not match to calculated amount of use space */
- reiserfs_warning(NULL, "reiserfs-5082",
- "free space seems wrong: %z", bh);
+ reiserfs_error(NULL, "reiserfs-5082",
+ "free space seems wrong: %z", bh);
return 0;
}
// FIXME: it is_leaf will hit performance too much - we may have
@@ -471,28 +471,28 @@ static int is_leaf(char *buf, int blocks
prev_location = blocksize;
for (i = 0; i < nr; i++, ih++) {
if (le_ih_k_type(ih) == TYPE_ANY) {
- reiserfs_warning(NULL, "reiserfs-5083",
- "wrong item type for item %h",
+ reiserfs_error(NULL, "reiserfs-5083",
+ "wrong item type for item %h",
ih);
return 0;
}
if (ih_location(ih) >= blocksize
|| ih_location(ih) < IH_SIZE * nr) {
- reiserfs_warning(NULL, "reiserfs-5084",
- "item location seems wrong: %h",
+ reiserfs_error(NULL, "reiserfs-5084",
+ "item location seems wrong: %h",
ih);
return 0;
}
if (ih_item_len(ih) < 1
|| ih_item_len(ih) > MAX_ITEM_LEN(blocksize)) {
- reiserfs_warning(NULL, "reiserfs-5085",
- "item length seems wrong: %h",
+ reiserfs_error(NULL, "reiserfs-5085",
+ "item length seems wrong: %h",
ih);
return 0;
}
if (prev_location - ih_location(ih) != ih_item_len(ih)) {
- reiserfs_warning(NULL, "reiserfs-5086",
- "item location seems wrong "
+ reiserfs_error(NULL, "reiserfs-5086",
+ "item location seems wrong "
"(second one): %h", ih);
return 0;
}
@@ -514,23 +514,23 @@ static int is_internal(char *buf, int bl
nr = blkh_level(blkh);
if (nr <= DISK_LEAF_NODE_LEVEL || nr > MAX_HEIGHT) {
/* this level is not possible for internal nodes */
- reiserfs_warning(NULL, "reiserfs-5087",
- "this should be caught earlier");
+ reiserfs_error(NULL, "reiserfs-5087",
+ "this should be caught earlier");
return 0;
}
nr = blkh_nr_item(blkh);
if (nr > (blocksize - BLKH_SIZE - DC_SIZE) / (KEY_SIZE + DC_SIZE)) {
/* for internal which is not root we might check min number of keys */
- reiserfs_warning(NULL, "reiserfs-5088",
- "number of key seems wrong: %z", bh);
+ reiserfs_error(NULL, "reiserfs-5088",
+ "number of key seems wrong: %z", bh);
return 0;
}
used_space = BLKH_SIZE + KEY_SIZE * nr + DC_SIZE * (nr + 1);
if (used_space != blocksize - blkh_free_space(blkh)) {
- reiserfs_warning(NULL, "reiserfs-5089",
- "free space seems wrong: %z", bh);
+ reiserfs_error(NULL, "reiserfs-5089",
+ "free space seems wrong: %z", bh);
return 0;
}
// one may imagine much more checks
@@ -542,8 +542,8 @@ static int is_internal(char *buf, int bl
static int is_tree_node(struct buffer_head *bh, int level)
{
if (B_LEVEL(bh) != level) {
- reiserfs_warning(NULL, "reiserfs-5090", "node level %d does "
- "not match to the expected one %d",
+ reiserfs_error(NULL, "reiserfs-5090", "node level %d does "
+ "not match to the expected one %d",
B_LEVEL(bh), level);
return 0;
}
@@ -720,9 +720,9 @@ int search_by_key(struct super_block *p_
// make sure, that the node contents look like a node of
// certain level
if (!is_tree_node(p_s_bh, expected_level)) {
- reiserfs_warning(p_s_sb, "vs-5150",
- "invalid format found in block %ld. "
- "Fsck?", p_s_bh->b_blocknr);
+ reiserfs_error(p_s_sb, "vs-5150",
+ "invalid format found in block %ld. "
+ "Fsck?", p_s_bh->b_blocknr);
pathrelse(p_s_search_path);
return IO_ERROR;
}
@@ -1335,9 +1335,9 @@ void reiserfs_delete_solid_item(struct r
while (1) {
retval = search_item(th->t_super, &cpu_key, &path);
if (retval == IO_ERROR) {
- reiserfs_warning(th->t_super, "vs-5350",
- "i/o failure occurred trying "
- "to delete %K", &cpu_key);
+ reiserfs_error(th->t_super, "vs-5350",
+ "i/o failure occurred trying "
+ "to delete %K", &cpu_key);
break;
}
if (retval != ITEM_FOUND) {
@@ -1740,7 +1740,7 @@ static void truncate_directory(struct re
{
BUG_ON(!th->t_trans_id);
if (inode->i_nlink)
- reiserfs_warning(inode->i_sb, "vs-5655", "link count != 0");
+ reiserfs_error(inode->i_sb, "vs-5655", "link count != 0");
set_le_key_k_offset(KEY_FORMAT_3_5, INODE_PKEY(inode), DOT_OFFSET);
set_le_key_k_type(KEY_FORMAT_3_5, INODE_PKEY(inode), TYPE_DIRENTRY);
@@ -1793,16 +1793,16 @@ int reiserfs_do_truncate(struct reiserfs
search_for_position_by_key(p_s_inode->i_sb, &s_item_key,
&s_search_path);
if (retval == IO_ERROR) {
- reiserfs_warning(p_s_inode->i_sb, "vs-5657",
- "i/o failure occurred trying to truncate %K",
- &s_item_key);
+ reiserfs_error(p_s_inode->i_sb, "vs-5657",
+ "i/o failure occurred trying to truncate %K",
+ &s_item_key);
err = -EIO;
goto out;
}
if (retval == POSITION_FOUND || retval == FILE_NOT_FOUND) {
- reiserfs_warning(p_s_inode->i_sb, "PAP-5660",
- "wrong result %d of search for %K", retval,
- &s_item_key);
+ reiserfs_error(p_s_inode->i_sb, "PAP-5660",
+ "wrong result %d of search for %K", retval,
+ &s_item_key);
err = -EIO;
goto out;
--- a/fs/reiserfs/super.c 2007-06-11 14:49:34.000000000 -0400
+++ b/fs/reiserfs/super.c 2007-06-11 14:50:08.000000000 -0400
@@ -190,9 +190,8 @@ static int finish_unfinished(struct supe
while (!retval) {
retval = search_item(s, &max_cpu_key, &path);
if (retval != ITEM_NOT_FOUND) {
- reiserfs_warning(s, "vs-2140",
- "search_by_key returned %d",
- retval);
+ reiserfs_error(s, "vs-2140",
+ "search_by_key returned %d", retval);
break;
}
@@ -362,9 +361,9 @@ void add_save_link(struct reiserfs_trans
retval = search_item(inode->i_sb, &key, &path);
if (retval != ITEM_NOT_FOUND) {
if (retval != -ENOSPC)
- reiserfs_warning(inode->i_sb, "vs-2100",
- "search_by_key (%K) returned %d", &key,
- retval);
+ reiserfs_error(inode->i_sb, "vs-2100",
+ "search_by_key (%K) returned %d", &key,
+ retval);
pathrelse(&path);
return;
}
@@ -377,8 +376,8 @@ void add_save_link(struct reiserfs_trans
reiserfs_insert_item(th, &path, &key, &ih, NULL, (char *)&link);
if (retval) {
if (retval != -ENOSPC)
- reiserfs_warning(inode->i_sb, "vs-2120",
- "insert_item returned %d", retval);
+ reiserfs_error(inode->i_sb, "vs-2120",
+ "insert_item returned %d", retval);
} else {
if (truncate)
REISERFS_I(inode)->i_flags |=
--- a/fs/reiserfs/tail_conversion.c 2007-06-11 14:49:34.000000000 -0400
+++ b/fs/reiserfs/tail_conversion.c 2007-06-11 14:50:04.000000000 -0400
@@ -48,9 +48,9 @@ int direct2indirect(struct reiserfs_tran
// FIXME: we could avoid this
if (search_for_position_by_key(sb, &end_key, path) == POSITION_FOUND) {
- reiserfs_warning(sb, "PAP-14030",
- "pasted or inserted byte exists in "
- "the tree %K. Use fsck to repair.", &end_key);
+ reiserfs_error(sb, "PAP-14030",
+ "pasted or inserted byte exists in "
+ "the tree %K. Use fsck to repair.", &end_key);
pathrelse(path);
return -EIO;
}
--- a/fs/reiserfs/xattr.c 2007-06-11 14:49:34.000000000 -0400
+++ b/fs/reiserfs/xattr.c 2007-06-11 14:50:08.000000000 -0400
@@ -278,8 +278,8 @@ static int __xattr_readdir(struct file *
ih = de.de_ih;
if (!is_direntry_le_ih(ih)) {
- reiserfs_warning(inode->i_sb, "jdm-20000",
- "not direntry %h", ih);
+ reiserfs_error(inode->i_sb, "jdm-20000",
+ "not direntry %h", ih);
break;
}
copy_item_head(&tmp_ih, ih);
@@ -674,15 +674,14 @@ __reiserfs_xattr_del(struct dentry *xadi
goto out_file;
if (!is_reiserfs_priv_object(dentry->d_inode)) {
- reiserfs_warning(dir->i_sb, "jdm-20003",
- "OID %08x [%.*s/%.*s] doesn't have "
- "priv flag set [parent is %sset].",
- le32_to_cpu(INODE_PKEY(dentry->d_inode)->
- k_objectid), xadir->d_name.len,
- xadir->d_name.name, namelen, name,
- is_reiserfs_priv_object(xadir->
- d_inode) ? "" :
- "not ");
+ reiserfs_error(dir->i_sb, "jdm-20003",
+ "OID %08x [%.*s/%.*s] doesn't have "
+ "priv flag set [parent is %sset].",
+ le32_to_cpu(INODE_PKEY(dentry->d_inode)->
+ k_objectid), xadir->d_name.len,
+ xadir->d_name.name, namelen, name,
+ is_reiserfs_priv_object(xadir-> d_inode) ? "" :
+ "not ");
dput(dentry);
return -EIO;
}
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 43+ messages in thread
* [patch 12/40] reiserfs: simplify xattr internal file lookups/opens
2007-06-11 19:03 [patch 00/40] reiserfs: patch queue (v2) jeffm
` (10 preceding siblings ...)
2007-06-11 19:03 ` [patch 11/40] reiserfs: use reiserfs_error() jeffm
@ 2007-06-11 19:03 ` jeffm
2007-06-11 19:03 ` [patch 13/40] reiserfs: eliminate per-super xattr lock jeffm
` (28 subsequent siblings)
40 siblings, 0 replies; 43+ messages in thread
From: jeffm @ 2007-06-11 19:03 UTC (permalink / raw)
To: ReiserFS Mailing List
[-- Attachment #1: reiserfs-simplify-xattr-internal-file-lookups-opens.diff --]
[-- Type: text/plain, Size: 10370 bytes --]
The xattr file open/lookup code is needlessly complex. We can use vfs-level
operations to perform the same work, and also simplify the locking
constraints. The locking advantages will be exploited in future patches.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
fs/reiserfs/xattr.c | 200 +++++++++++++++++-----------------------------------
1 file changed, 66 insertions(+), 134 deletions(-)
--- a/fs/reiserfs/xattr.c 2007-06-11 14:49:35.000000000 -0400
+++ b/fs/reiserfs/xattr.c 2007-06-11 14:50:08.000000000 -0400
@@ -46,173 +46,104 @@
#include <linux/stat.h>
#include <asm/semaphore.h>
-#define FL_READONLY 128
-#define FL_DIR_SEM_HELD 256
#define PRIVROOT_NAME ".reiserfs_priv"
#define XAROOT_NAME "xattrs"
static struct reiserfs_xattr_handler *find_xattr_handler_prefix(const char
*prefix);
-/* Returns the dentry referring to the root of the extended attribute
- * directory tree. If it has already been retrieved, it is used. If it
- * hasn't been created and the flags indicate creation is allowed, we
- * attempt to create it. On error, we return a pointer-encoded error.
- */
-static struct dentry *get_xa_root(struct super_block *sb, int flags)
-{
- struct dentry *privroot = dget(REISERFS_SB(sb)->priv_root);
- struct dentry *xaroot;
+#define xattr_may_create(flags) (!flags || flags & XATTR_CREATE)
- /* This needs to be created at mount-time */
- if (!privroot)
- return ERR_PTR(-ENODATA);
+static struct dentry *lookup_or_create_dir(struct dentry *parent,
+ const char *name, int flags)
+{
+ struct dentry *dentry;
+ BUG_ON(!parent);
- mutex_lock_nested(&privroot->d_inode->i_mutex, I_MUTEX_XATTR);
- if (REISERFS_SB(sb)->xattr_root) {
- xaroot = dget(REISERFS_SB(sb)->xattr_root);
- goto out;
- }
+ mutex_lock_nested(&parent->d_inode->i_mutex, I_MUTEX_XATTR);
- xaroot = lookup_one_len(XAROOT_NAME, privroot, strlen(XAROOT_NAME));
- if (IS_ERR(xaroot)) {
- goto out;
- } else if (!xaroot->d_inode) {
+ dentry = lookup_one_len(name, parent, strlen(name));
+ if (IS_ERR(dentry)) {
+ mutex_unlock(&parent->d_inode->i_mutex);
+ return dentry;
+ } else if (!dentry->d_inode) {
int err = -ENODATA;
- if (flags == 0 || flags & XATTR_CREATE)
- err = privroot->d_inode->i_op->mkdir(privroot->d_inode,
- xaroot, 0700);
+
+ if (xattr_may_create(flags))
+ err = vfs_mkdir(parent->d_inode, dentry, 0700);
+
if (err) {
- dput(xaroot);
- xaroot = ERR_PTR(err);
- goto out;
+ dput(dentry);
+ dentry = ERR_PTR(err);
}
}
- REISERFS_SB(sb)->xattr_root = dget(xaroot);
- out:
- mutex_unlock(&privroot->d_inode->i_mutex);
- dput(privroot);
- return xaroot;
+ mutex_unlock(&parent->d_inode->i_mutex);
+ return dentry;
+}
+
+static struct dentry *open_xa_root(struct super_block *sb, int flags)
+{
+ struct dentry *privroot = REISERFS_SB(sb)->priv_root;
+ if (!privroot)
+ return ERR_PTR(-ENODATA);
+ return lookup_or_create_dir(privroot, XAROOT_NAME, flags);
}
-/* Opens the directory corresponding to the inode's extended attribute store.
- * If flags allow, the tree to the directory may be created. If creation is
- * prohibited, -ENODATA is returned. */
static struct dentry *open_xa_dir(const struct inode *inode, int flags)
{
struct dentry *xaroot, *xadir;
char namebuf[17];
- xaroot = get_xa_root(inode->i_sb, flags);
+ xaroot = open_xa_root(inode->i_sb, flags);
if (IS_ERR(xaroot))
return xaroot;
- /* ok, we have xaroot open */
snprintf(namebuf, sizeof(namebuf), "%X.%X",
le32_to_cpu(INODE_PKEY(inode)->k_objectid),
inode->i_generation);
- xadir = lookup_one_len(namebuf, xaroot, strlen(namebuf));
- if (IS_ERR(xadir)) {
- dput(xaroot);
- return xadir;
- }
-
- if (!xadir->d_inode) {
- int err;
- if (flags == 0 || flags & XATTR_CREATE) {
- /* Although there is nothing else trying to create this directory,
- * another directory with the same hash may be created, so we need
- * to protect against that */
- err =
- xaroot->d_inode->i_op->mkdir(xaroot->d_inode, xadir,
- 0700);
- if (err) {
- dput(xaroot);
- dput(xadir);
- return ERR_PTR(err);
- }
- }
- if (!xadir->d_inode) {
- dput(xaroot);
- dput(xadir);
- return ERR_PTR(-ENODATA);
- }
- }
+ xadir = lookup_or_create_dir(xaroot, namebuf, flags);
dput(xaroot);
return xadir;
+
}
-/* Returns a dentry corresponding to a specific extended attribute file
- * for the inode. If flags allow, the file is created. Otherwise, a
- * valid or negative dentry, or an error is returned. */
-static struct dentry *get_xa_file_dentry(const struct inode *inode,
- const char *name, int flags)
+static struct file *open_xattr_file(const struct inode *inode,
+ const char *name, int flags)
{
struct dentry *xadir, *xafile;
int err = 0;
xadir = open_xa_dir(inode, flags);
- if (IS_ERR(xadir)) {
+ if (IS_ERR(xadir))
return ERR_PTR(PTR_ERR(xadir));
- } else if (xadir && !xadir->d_inode) {
- dput(xadir);
- return ERR_PTR(-ENODATA);
- }
+ mutex_lock_nested(&xadir->d_inode->i_mutex, I_MUTEX_XATTR);
xafile = lookup_one_len(name, xadir, strlen(name));
if (IS_ERR(xafile)) {
- dput(xadir);
- return ERR_PTR(PTR_ERR(xafile));
+ err = PTR_ERR(xafile);
+ goto out;
}
- if (xafile->d_inode) { /* file exists */
- if (flags & XATTR_CREATE) {
- err = -EEXIST;
- dput(xafile);
- goto out;
- }
- } else if (flags & XATTR_REPLACE || flags & FL_READONLY) {
- goto out;
- } else {
- /* inode->i_mutex is down, so nothing else can try to create
- * the same xattr */
- err = xadir->d_inode->i_op->create(xadir->d_inode, xafile,
- 0700 | S_IFREG, NULL);
+ if (xafile->d_inode && (flags & XATTR_CREATE))
+ err = -EEXIST;
- if (err) {
- dput(xafile);
- goto out;
- }
+ if (!xafile->d_inode) {
+ err = -ENODATA;
+ if (xattr_may_create(flags))
+ err = vfs_create(xadir->d_inode, xafile,
+ 0700|S_IFREG, NULL);
}
- out:
- dput(xadir);
if (err)
- xafile = ERR_PTR(err);
- return xafile;
-}
-
-/* Opens a file pointer to the attribute associated with inode */
-static struct file *open_xa_file(const struct inode *inode, const char *name,
- int flags)
-{
- struct dentry *xafile;
- struct file *fp;
-
- xafile = get_xa_file_dentry(inode, name, flags);
- if (IS_ERR(xafile))
- return ERR_PTR(PTR_ERR(xafile));
- else if (!xafile->d_inode) {
dput(xafile);
- return ERR_PTR(-ENODATA);
- }
-
- fp = dentry_open(xafile, NULL, O_RDWR);
- /* dentry_open dputs the dentry if it fails */
-
- return fp;
+out:
+ mutex_unlock(&xadir->d_inode->i_mutex);
+ dput(xadir);
+ if (err)
+ return ERR_PTR(err);
+ return dentry_open(xafile, NULL, O_RDWR);
}
/*
@@ -455,7 +386,7 @@ reiserfs_xattr_set(struct inode *inode,
xahash = xattr_hash(buffer, buffer_size);
open_file:
- fp = open_xa_file(inode, name, flags);
+ fp = open_xattr_file(inode, name, flags);
if (IS_ERR(fp)) {
err = PTR_ERR(fp);
goto out;
@@ -573,7 +504,7 @@ reiserfs_xattr_get(const struct inode *i
if (get_inode_sd_version(inode) == STAT_DATA_V1)
return -EOPNOTSUPP;
- fp = open_xa_file(inode, name, FL_READONLY);
+ fp = open_xattr_file(inode, name, XATTR_REPLACE);
if (IS_ERR(fp)) {
err = PTR_ERR(fp);
goto out;
@@ -586,12 +517,12 @@ reiserfs_xattr_get(const struct inode *i
/* Just return the size needed */
if (buffer == NULL) {
err = isize - sizeof(struct reiserfs_xattr_header);
- goto out_dput;
+ goto out_fput;
}
if (buffer_size < isize - sizeof(struct reiserfs_xattr_header)) {
err = -ERANGE;
- goto out_dput;
+ goto out_fput;
}
while (file_pos < isize) {
@@ -606,7 +537,7 @@ reiserfs_xattr_get(const struct inode *i
page = reiserfs_get_page(xinode, file_pos >> PAGE_CACHE_SHIFT);
if (IS_ERR(page)) {
err = PTR_ERR(page);
- goto out_dput;
+ goto out_fput;
}
lock_page(page);
@@ -625,7 +556,7 @@ reiserfs_xattr_get(const struct inode *i
"associated with %k", name,
INODE_PKEY(inode));
err = -EIO;
- goto out_dput;
+ goto out_fput;
}
hash = le32_to_cpu(rxh->h_hash);
}
@@ -644,9 +575,10 @@ reiserfs_xattr_get(const struct inode *i
"Invalid hash for xattr (%s) associated "
"with %k", name, INODE_PKEY(inode));
err = -EIO;
+ goto out_fput;
}
- out_dput:
+ out_fput:
fput(fp);
out:
@@ -686,9 +618,7 @@ __reiserfs_xattr_del(struct dentry *xadi
return -EIO;
}
- err = dir->i_op->unlink(dir, dentry);
- if (!err)
- d_delete(dentry);
+ err = vfs_unlink(xadir->d_inode, dentry);
out_file:
dput(dentry);
@@ -702,7 +632,7 @@ int reiserfs_xattr_del(struct inode *ino
struct dentry *dir;
int err;
- dir = open_xa_dir(inode, FL_READONLY);
+ dir = open_xa_dir(inode, XATTR_REPLACE);
if (IS_ERR(dir)) {
err = PTR_ERR(dir);
goto out;
@@ -748,7 +678,7 @@ int reiserfs_delete_xattrs(struct inode
return 0;
}
reiserfs_read_lock_xattrs(inode->i_sb);
- dir = open_xa_dir(inode, FL_READONLY);
+ dir = open_xa_dir(inode, XATTR_REPLACE);
reiserfs_read_unlock_xattrs(inode->i_sb);
if (IS_ERR(dir)) {
err = PTR_ERR(dir);
@@ -774,9 +704,11 @@ int reiserfs_delete_xattrs(struct inode
/* Leftovers besides . and .. -- that's not good. */
if (dir->d_inode->i_nlink <= 2) {
- root = get_xa_root(inode->i_sb, XATTR_REPLACE);
+ root = open_xa_root(inode->i_sb, XATTR_REPLACE);
reiserfs_write_lock_xattrs(inode->i_sb);
+ mutex_lock_nested(&root->d_inode->i_mutex, I_MUTEX_XATTR);
err = vfs_rmdir(root->d_inode, dir);
+ mutex_unlock(&root->d_inode->i_mutex);
reiserfs_write_unlock_xattrs(inode->i_sb);
dput(root);
} else {
@@ -841,7 +773,7 @@ int reiserfs_chown_xattrs(struct inode *
return 0;
}
reiserfs_read_lock_xattrs(inode->i_sb);
- dir = open_xa_dir(inode, FL_READONLY);
+ dir = open_xa_dir(inode, XATTR_REPLACE);
reiserfs_read_unlock_xattrs(inode->i_sb);
if (IS_ERR(dir)) {
if (PTR_ERR(dir) != -ENODATA)
@@ -1038,7 +970,7 @@ ssize_t reiserfs_listxattr(struct dentry
reiserfs_read_lock_xattr_i(dentry->d_inode);
reiserfs_read_lock_xattrs(dentry->d_sb);
- dir = open_xa_dir(dentry->d_inode, FL_READONLY);
+ dir = open_xa_dir(dentry->d_inode, XATTR_REPLACE);
reiserfs_read_unlock_xattrs(dentry->d_sb);
if (IS_ERR(dir)) {
err = PTR_ERR(dir);
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 43+ messages in thread
* [patch 13/40] reiserfs: eliminate per-super xattr lock
2007-06-11 19:03 [patch 00/40] reiserfs: patch queue (v2) jeffm
` (11 preceding siblings ...)
2007-06-11 19:03 ` [patch 12/40] reiserfs: simplify xattr internal file lookups/opens jeffm
@ 2007-06-11 19:03 ` jeffm
2007-06-11 19:03 ` [patch 14/40] reiserfs: make per-inode xattr locking more fine grained jeffm
` (27 subsequent siblings)
40 siblings, 0 replies; 43+ messages in thread
From: jeffm @ 2007-06-11 19:03 UTC (permalink / raw)
To: ReiserFS Mailing List
[-- Attachment #1: reiserfs-eliminate-per-super-xattr-lock.diff --]
[-- Type: text/plain, Size: 15172 bytes --]
With the switch to using inode->i_mutex locking during lookups/creation in
the xattr root, the per-super xattr lock is no longer needed.
This patch removes it.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
--
fs/reiserfs/inode.c | 14 -------
fs/reiserfs/namei.c | 29 ----------------
fs/reiserfs/super.c | 4 --
fs/reiserfs/xattr.c | 34 +++---------------
fs/reiserfs/xattr_acl.c | 74 ++++++++++++++++++-----------------------
include/linux/reiserfs_fs.h | 3 -
include/linux/reiserfs_fs_sb.h | 1
include/linux/reiserfs_xattr.h | 18 ---------
8 files changed, 40 insertions(+), 137 deletions(-)
--- a/fs/reiserfs/inode.c 2007-06-11 14:49:35.000000000 -0400
+++ b/fs/reiserfs/inode.c 2007-06-11 14:50:07.000000000 -0400
@@ -1966,19 +1966,7 @@ int reiserfs_new_inode(struct reiserfs_t
out_inserted_sd:
inode->i_nlink = 0;
th->t_trans_id = 0; /* so the caller can't use this handle later */
-
- /* If we were inheriting an ACL, we need to release the lock so that
- * iput doesn't deadlock in reiserfs_delete_xattrs. The locking
- * code really needs to be reworked, but this will take care of it
- * for now. -jeffm */
-#ifdef CONFIG_REISERFS_FS_POSIX_ACL
- if (REISERFS_I(dir)->i_acl_default && !IS_ERR(REISERFS_I(dir)->i_acl_default)) {
- reiserfs_write_unlock_xattrs(dir->i_sb);
- iput(inode);
- reiserfs_write_lock_xattrs(dir->i_sb);
- } else
-#endif
- iput(inode);
+ iput(inode);
return err;
}
--- a/fs/reiserfs/namei.c 2007-06-11 14:49:35.000000000 -0400
+++ b/fs/reiserfs/namei.c 2007-06-11 14:50:06.000000000 -0400
@@ -617,9 +617,6 @@ static int reiserfs_create(struct inode
reiserfs_write_lock(dir->i_sb);
- if (locked)
- reiserfs_write_lock_xattrs(dir->i_sb);
-
retval = journal_begin(&th, dir->i_sb, jbegin_count);
if (retval) {
drop_new_inode(inode);
@@ -632,11 +629,6 @@ static int reiserfs_create(struct inode
if (retval)
goto out_failed;
- if (locked) {
- reiserfs_write_unlock_xattrs(dir->i_sb);
- locked = 0;
- }
-
inode->i_op = &reiserfs_file_inode_operations;
inode->i_fop = &reiserfs_file_operations;
inode->i_mapping->a_ops = &reiserfs_address_space_operations;
@@ -661,8 +653,6 @@ static int reiserfs_create(struct inode
retval = journal_end(&th, dir->i_sb, jbegin_count);
out_failed:
- if (locked)
- reiserfs_write_unlock_xattrs(dir->i_sb);
reiserfs_write_unlock(dir->i_sb);
return retval;
}
@@ -692,9 +682,6 @@ static int reiserfs_mknod(struct inode *
reiserfs_write_lock(dir->i_sb);
- if (locked)
- reiserfs_write_lock_xattrs(dir->i_sb);
-
retval = journal_begin(&th, dir->i_sb, jbegin_count);
if (retval) {
drop_new_inode(inode);
@@ -708,11 +695,6 @@ static int reiserfs_mknod(struct inode *
goto out_failed;
}
- if (locked) {
- reiserfs_write_unlock_xattrs(dir->i_sb);
- locked = 0;
- }
-
inode->i_op = &reiserfs_special_inode_operations;
init_special_inode(inode, inode->i_mode, rdev);
@@ -740,8 +722,6 @@ static int reiserfs_mknod(struct inode *
retval = journal_end(&th, dir->i_sb, jbegin_count);
out_failed:
- if (locked)
- reiserfs_write_unlock_xattrs(dir->i_sb);
reiserfs_write_unlock(dir->i_sb);
return retval;
}
@@ -771,8 +751,6 @@ static int reiserfs_mkdir(struct inode *
locked = reiserfs_cache_default_acl(dir);
reiserfs_write_lock(dir->i_sb);
- if (locked)
- reiserfs_write_lock_xattrs(dir->i_sb);
retval = journal_begin(&th, dir->i_sb, jbegin_count);
if (retval) {
@@ -794,11 +772,6 @@ static int reiserfs_mkdir(struct inode *
goto out_failed;
}
- if (locked) {
- reiserfs_write_unlock_xattrs(dir->i_sb);
- locked = 0;
- }
-
reiserfs_update_inode_transaction(inode);
reiserfs_update_inode_transaction(dir);
@@ -826,8 +799,6 @@ static int reiserfs_mkdir(struct inode *
d_instantiate(dentry, inode);
retval = journal_end(&th, dir->i_sb, jbegin_count);
out_failed:
- if (locked)
- reiserfs_write_unlock_xattrs(dir->i_sb);
reiserfs_write_unlock(dir->i_sb);
return retval;
}
--- a/fs/reiserfs/super.c 2007-06-11 14:49:35.000000000 -0400
+++ b/fs/reiserfs/super.c 2007-06-11 14:50:06.000000000 -0400
@@ -1574,10 +1574,6 @@ static int reiserfs_fill_super(struct su
REISERFS_SB(s)->s_alloc_options.preallocmin = 0;
/* Preallocate by 16 blocks (17-1) at once */
REISERFS_SB(s)->s_alloc_options.preallocsize = 17;
-#ifdef CONFIG_REISERFS_FS_XATTR
- /* Initialize the rwsem for xattr dir */
- init_rwsem(&REISERFS_SB(s)->xattr_dir_sem);
-#endif
/* setup default block allocator options */
reiserfs_init_alloc_options(s);
--- a/fs/reiserfs/xattr.c 2007-06-11 14:49:35.000000000 -0400
+++ b/fs/reiserfs/xattr.c 2007-06-11 14:50:07.000000000 -0400
@@ -27,6 +27,12 @@
* these are special cases for filesystem ACLs, they are interpreted by the
* kernel, in addition, they are negatively and positively cached and attached
* to the inode so that unnecessary lookups are avoided.
+ *
+ * Locking works like so:
+ * The xattr root (/.reiserfs_priv/xattrs) is protected by its i_mutex.
+ * The xattr dir (/.reiserfs_priv/xattrs/<oid>.<gen>) is protected by
+ * inode->xattr_sem.
+ * The xattrs themselves are likewise protected by the xattr_sem.
*/
#include <linux/reiserfs_fs.h>
@@ -677,9 +683,7 @@ int reiserfs_delete_xattrs(struct inode
!reiserfs_xattrs(inode->i_sb)) {
return 0;
}
- reiserfs_read_lock_xattrs(inode->i_sb);
dir = open_xa_dir(inode, XATTR_REPLACE);
- reiserfs_read_unlock_xattrs(inode->i_sb);
if (IS_ERR(dir)) {
err = PTR_ERR(dir);
goto out;
@@ -705,11 +709,9 @@ int reiserfs_delete_xattrs(struct inode
/* Leftovers besides . and .. -- that's not good. */
if (dir->d_inode->i_nlink <= 2) {
root = open_xa_root(inode->i_sb, XATTR_REPLACE);
- reiserfs_write_lock_xattrs(inode->i_sb);
mutex_lock_nested(&root->d_inode->i_mutex, I_MUTEX_XATTR);
err = vfs_rmdir(root->d_inode, dir);
mutex_unlock(&root->d_inode->i_mutex);
- reiserfs_write_unlock_xattrs(inode->i_sb);
dput(root);
} else {
reiserfs_warning(inode->i_sb, "jdm-20004",
@@ -772,9 +774,7 @@ int reiserfs_chown_xattrs(struct inode *
!reiserfs_xattrs(inode->i_sb)) {
return 0;
}
- reiserfs_read_lock_xattrs(inode->i_sb);
dir = open_xa_dir(inode, XATTR_REPLACE);
- reiserfs_read_unlock_xattrs(inode->i_sb);
if (IS_ERR(dir)) {
if (PTR_ERR(dir) != -ENODATA)
err = PTR_ERR(dir);
@@ -819,7 +819,6 @@ int reiserfs_chown_xattrs(struct inode *
/*
* Inode operation getxattr()
- * Preliminary locking: we down dentry->d_inode->i_mutex
*/
ssize_t
reiserfs_getxattr(struct dentry * dentry, const char *name, void *buffer,
@@ -833,9 +832,7 @@ reiserfs_getxattr(struct dentry * dentry
return -EOPNOTSUPP;
reiserfs_read_lock_xattr_i(dentry->d_inode);
- reiserfs_read_lock_xattrs(dentry->d_sb);
err = xah->get(dentry->d_inode, name, buffer, size);
- reiserfs_read_unlock_xattrs(dentry->d_sb);
reiserfs_read_unlock_xattr_i(dentry->d_inode);
return err;
}
@@ -851,23 +848,13 @@ reiserfs_setxattr(struct dentry *dentry,
{
struct reiserfs_xattr_handler *xah = find_xattr_handler_prefix(name);
int err;
- int lock;
if (!xah || !reiserfs_xattrs(dentry->d_sb) ||
get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1)
return -EOPNOTSUPP;
reiserfs_write_lock_xattr_i(dentry->d_inode);
- lock = !has_xattr_dir(dentry->d_inode);
- if (lock)
- reiserfs_write_lock_xattrs(dentry->d_sb);
- else
- reiserfs_read_lock_xattrs(dentry->d_sb);
err = xah->set(dentry->d_inode, name, value, size, flags);
- if (lock)
- reiserfs_write_unlock_xattrs(dentry->d_sb);
- else
- reiserfs_read_unlock_xattrs(dentry->d_sb);
reiserfs_write_unlock_xattr_i(dentry->d_inode);
return err;
}
@@ -887,8 +874,6 @@ int reiserfs_removexattr(struct dentry *
return -EOPNOTSUPP;
reiserfs_write_lock_xattr_i(dentry->d_inode);
- reiserfs_read_lock_xattrs(dentry->d_sb);
-
/* Deletion pre-operation */
if (xah->del) {
err = xah->del(dentry->d_inode, name);
@@ -902,7 +887,6 @@ int reiserfs_removexattr(struct dentry *
mark_inode_dirty(dentry->d_inode);
out:
- reiserfs_read_unlock_xattrs(dentry->d_sb);
reiserfs_write_unlock_xattr_i(dentry->d_inode);
return err;
}
@@ -951,8 +935,6 @@ reiserfs_listxattr_filler(void *buf, con
/*
* Inode operation listxattr()
- *
- * Preliminary locking: we down dentry->d_inode->i_mutex
*/
ssize_t reiserfs_listxattr(struct dentry * dentry, char *buffer, size_t size)
{
@@ -969,9 +951,7 @@ ssize_t reiserfs_listxattr(struct dentry
return -EOPNOTSUPP;
reiserfs_read_lock_xattr_i(dentry->d_inode);
- reiserfs_read_lock_xattrs(dentry->d_sb);
dir = open_xa_dir(dentry->d_inode, XATTR_REPLACE);
- reiserfs_read_unlock_xattrs(dentry->d_sb);
if (IS_ERR(dir)) {
err = PTR_ERR(dir);
if (err == -ENODATA)
@@ -1211,11 +1191,9 @@ static int reiserfs_check_acl(struct ino
int error = -EAGAIN; /* do regular unix permission checks by default */
reiserfs_read_lock_xattr_i(inode);
- reiserfs_read_lock_xattrs(inode->i_sb);
acl = reiserfs_get_acl(inode, ACL_TYPE_ACCESS);
- reiserfs_read_unlock_xattrs(inode->i_sb);
reiserfs_read_unlock_xattr_i(inode);
if (acl) {
--- a/fs/reiserfs/xattr_acl.c 2007-06-11 14:49:05.000000000 -0400
+++ b/fs/reiserfs/xattr_acl.c 2007-06-11 14:50:07.000000000 -0400
@@ -172,6 +172,29 @@ static void *posix_acl_to_disk(const str
return ERR_PTR(-EINVAL);
}
+static inline void iset_acl(struct inode *inode, struct posix_acl **i_acl,
+ struct posix_acl *acl)
+{
+ spin_lock(&inode->i_lock);
+ if (*i_acl != ERR_PTR(-ENODATA))
+ posix_acl_release(*i_acl);
+ *i_acl = posix_acl_dup(acl);
+ spin_unlock(&inode->i_lock);
+}
+
+static inline struct posix_acl *iget_acl(struct inode *inode,
+ struct posix_acl **i_acl)
+{
+ struct posix_acl *acl = ERR_PTR(-ENODATA);
+
+ spin_lock(&inode->i_lock);
+ if (*i_acl != ERR_PTR(-ENODATA))
+ acl = posix_acl_dup(*i_acl);
+ spin_unlock(&inode->i_lock);
+
+ return acl;
+}
+
/*
* Inode operation get_posix_acl().
*
@@ -199,11 +222,11 @@ struct posix_acl *reiserfs_get_acl(struc
return ERR_PTR(-EINVAL);
}
- if (IS_ERR(*p_acl)) {
- if (PTR_ERR(*p_acl) == -ENODATA)
- return NULL;
- } else if (*p_acl != NULL)
- return posix_acl_dup(*p_acl);
+ acl = iget_acl(inode, p_acl);
+ if (acl && !IS_ERR(acl))
+ return acl;
+ else if (PTR_ERR(acl) == -ENODATA)
+ return NULL;
size = reiserfs_xattr_get(inode, name, NULL, 0);
if (size < 0) {
@@ -229,7 +252,7 @@ struct posix_acl *reiserfs_get_acl(struc
} else {
acl = posix_acl_from_disk(value, retval);
if (!IS_ERR(acl))
- *p_acl = posix_acl_dup(acl);
+ iset_acl(inode, p_acl, acl);
}
kfree(value);
@@ -300,16 +323,8 @@ reiserfs_set_acl(struct inode *inode, in
kfree(value);
- if (!error) {
- /* Release the old one */
- if (!IS_ERR(*p_acl) && *p_acl)
- posix_acl_release(*p_acl);
-
- if (acl == NULL)
- *p_acl = ERR_PTR(-ENODATA);
- else
- *p_acl = posix_acl_dup(acl);
- }
+ if (!error)
+ iset_acl(inode, p_acl, acl);
return error;
}
@@ -404,9 +419,7 @@ int reiserfs_cache_default_acl(struct in
if (reiserfs_posixacl(inode->i_sb) && !is_reiserfs_priv_object(inode)) {
struct posix_acl *acl;
reiserfs_read_lock_xattr_i(inode);
- reiserfs_read_lock_xattrs(inode->i_sb);
acl = reiserfs_get_acl(inode, ACL_TYPE_DEFAULT);
- reiserfs_read_unlock_xattrs(inode->i_sb);
reiserfs_read_unlock_xattr_i(inode);
ret = (acl && !IS_ERR(acl));
if (ret)
@@ -429,9 +442,7 @@ int reiserfs_acl_chmod(struct inode *ino
return 0;
}
- reiserfs_read_lock_xattrs(inode->i_sb);
acl = reiserfs_get_acl(inode, ACL_TYPE_ACCESS);
- reiserfs_read_unlock_xattrs(inode->i_sb);
if (!acl)
return 0;
if (IS_ERR(acl))
@@ -442,17 +453,8 @@ int reiserfs_acl_chmod(struct inode *ino
return -ENOMEM;
error = posix_acl_chmod_masq(clone, inode->i_mode);
if (!error) {
- int lock = !has_xattr_dir(inode);
reiserfs_write_lock_xattr_i(inode);
- if (lock)
- reiserfs_write_lock_xattrs(inode->i_sb);
- else
- reiserfs_read_lock_xattrs(inode->i_sb);
error = reiserfs_set_acl(inode, ACL_TYPE_ACCESS, clone);
- if (lock)
- reiserfs_write_unlock_xattrs(inode->i_sb);
- else
- reiserfs_read_unlock_xattrs(inode->i_sb);
reiserfs_write_unlock_xattr_i(inode);
}
posix_acl_release(clone);
@@ -480,14 +482,9 @@ posix_acl_access_set(struct inode *inode
static int posix_acl_access_del(struct inode *inode, const char *name)
{
struct reiserfs_inode_info *reiserfs_i = REISERFS_I(inode);
- struct posix_acl **acl = &reiserfs_i->i_acl_access;
if (strlen(name) != sizeof(POSIX_ACL_XATTR_ACCESS) - 1)
return -EINVAL;
- if (!IS_ERR(*acl) && *acl) {
- posix_acl_release(*acl);
- *acl = ERR_PTR(-ENODATA);
- }
-
+ iset_acl(inode, &reiserfs_i->i_acl_access, ERR_PTR(-ENODATA));
return 0;
}
@@ -533,14 +530,9 @@ posix_acl_default_set(struct inode *inod
static int posix_acl_default_del(struct inode *inode, const char *name)
{
struct reiserfs_inode_info *reiserfs_i = REISERFS_I(inode);
- struct posix_acl **acl = &reiserfs_i->i_acl_default;
if (strlen(name) != sizeof(POSIX_ACL_XATTR_DEFAULT) - 1)
return -EINVAL;
- if (!IS_ERR(*acl) && *acl) {
- posix_acl_release(*acl);
- *acl = ERR_PTR(-ENODATA);
- }
-
+ iset_acl(inode, &reiserfs_i->i_acl_default, ERR_PTR(-ENODATA));
return 0;
}
--- a/include/linux/reiserfs_fs.h 2007-06-11 14:49:35.000000000 -0400
+++ b/include/linux/reiserfs_fs.h 2007-06-11 14:50:06.000000000 -0400
@@ -2209,7 +2209,4 @@ long reiserfs_compat_ioctl(struct file *
#define reiserfs_write_lock( sb ) lock_kernel()
#define reiserfs_write_unlock( sb ) unlock_kernel()
-/* xattr stuff */
-#define REISERFS_XATTR_DIR_SEM(s) (REISERFS_SB(s)->xattr_dir_sem)
-
#endif /* _LINUX_REISER_FS_H */
--- a/include/linux/reiserfs_fs_sb.h 2007-06-11 14:49:05.000000000 -0400
+++ b/include/linux/reiserfs_fs_sb.h 2007-06-11 14:50:06.000000000 -0400
@@ -403,7 +403,6 @@ struct reiserfs_sb_info {
struct dentry *priv_root; /* root of /.reiserfs_priv */
#ifdef CONFIG_REISERFS_FS_XATTR
struct dentry *xattr_root; /* root of /.reiserfs_priv/.xa */
- struct rw_semaphore xattr_dir_sem;
#endif
int j_errno;
#ifdef CONFIG_QUOTA
--- a/include/linux/reiserfs_xattr.h 2007-06-11 14:49:05.000000000 -0400
+++ b/include/linux/reiserfs_xattr.h 2007-06-11 14:50:07.000000000 -0400
@@ -68,24 +68,6 @@ extern struct reiserfs_xattr_handler sec
int reiserfs_xattr_register_handlers(void) __init;
void reiserfs_xattr_unregister_handlers(void);
-static inline void reiserfs_write_lock_xattrs(struct super_block *sb)
-{
- down_write(&REISERFS_XATTR_DIR_SEM(sb));
-}
-static inline void reiserfs_write_unlock_xattrs(struct super_block *sb)
-{
- up_write(&REISERFS_XATTR_DIR_SEM(sb));
-}
-static inline void reiserfs_read_lock_xattrs(struct super_block *sb)
-{
- down_read(&REISERFS_XATTR_DIR_SEM(sb));
-}
-
-static inline void reiserfs_read_unlock_xattrs(struct super_block *sb)
-{
- up_read(&REISERFS_XATTR_DIR_SEM(sb));
-}
-
static inline void reiserfs_write_lock_xattr_i(struct inode *inode)
{
down_write(&REISERFS_I(inode)->xattr_sem);
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 43+ messages in thread
* [patch 14/40] reiserfs: make per-inode xattr locking more fine grained
2007-06-11 19:03 [patch 00/40] reiserfs: patch queue (v2) jeffm
` (12 preceding siblings ...)
2007-06-11 19:03 ` [patch 13/40] reiserfs: eliminate per-super xattr lock jeffm
@ 2007-06-11 19:03 ` jeffm
2007-06-11 19:03 ` [patch 15/40] reiserfs: remove i_has_xattr_dir jeffm
` (26 subsequent siblings)
40 siblings, 0 replies; 43+ messages in thread
From: jeffm @ 2007-06-11 19:03 UTC (permalink / raw)
To: ReiserFS Mailing List
[-- Attachment #1: reiserfs-make-per-inode-xattr-locking-more-fine-grained.diff --]
[-- Type: text/plain, Size: 10185 bytes --]
The per-inode locking can be made more fine-grained to surround just the
interaction with the filesystem itself. This really only applies to protecting
reads during a write, since concurrent writes are barred with inode->i_mutex
at the vfs level.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
--
fs/reiserfs/inode.c | 2 -
fs/reiserfs/xattr.c | 62 +++++++++++++++++------------------------
fs/reiserfs/xattr_acl.c | 7 ----
include/linux/reiserfs_fs_i.h | 3 -
include/linux/reiserfs_xattr.h | 26 -----------------
5 files changed, 28 insertions(+), 72 deletions(-)
--- a/fs/reiserfs/inode.c 2007-06-11 14:49:36.000000000 -0400
+++ b/fs/reiserfs/inode.c 2007-06-11 14:50:06.000000000 -0400
@@ -1128,7 +1128,6 @@ static void init_inode(struct inode *ino
mutex_init(&(REISERFS_I(inode)->i_mmap));
reiserfs_init_acl_access(inode);
reiserfs_init_acl_default(inode);
- reiserfs_init_xattr_rwsem(inode);
if (stat_data_v1(ih)) {
struct stat_data_v1 *sd =
@@ -1832,7 +1831,6 @@ int reiserfs_new_inode(struct reiserfs_t
mutex_init(&(REISERFS_I(inode)->i_mmap));
reiserfs_init_acl_access(inode);
reiserfs_init_acl_default(inode);
- reiserfs_init_xattr_rwsem(inode);
if (old_format_only(sb))
make_le_item_head(&ih, NULL, KEY_FORMAT_3_5, SD_OFFSET,
--- a/fs/reiserfs/xattr.c 2007-06-11 14:49:36.000000000 -0400
+++ b/fs/reiserfs/xattr.c 2007-06-11 14:50:07.000000000 -0400
@@ -29,10 +29,8 @@
* to the inode so that unnecessary lookups are avoided.
*
* Locking works like so:
- * The xattr root (/.reiserfs_priv/xattrs) is protected by its i_mutex.
- * The xattr dir (/.reiserfs_priv/xattrs/<oid>.<gen>) is protected by
- * inode->xattr_sem.
- * The xattrs themselves are likewise protected by the xattr_sem.
+ * Every component (xattr root, xattr dir, and the xattrs themselves) are
+ * protected by their i_mutex.
*/
#include <linux/reiserfs_fs.h>
@@ -318,16 +316,12 @@ int xattr_readdir(struct file *file, fil
int res = -ENOTDIR;
if (!file->f_op || !file->f_op->readdir)
goto out;
- mutex_lock_nested(&inode->i_mutex, I_MUTEX_XATTR);
-// down(&inode->i_zombie);
res = -ENOENT;
if (!IS_DEADDIR(inode)) {
lock_kernel();
res = __xattr_readdir(file, buf, filler);
unlock_kernel();
}
-// up(&inode->i_zombie);
- mutex_unlock(&inode->i_mutex);
out:
return res;
}
@@ -387,9 +381,8 @@ reiserfs_xattr_set(struct inode *inode,
if (get_inode_sd_version(inode) == STAT_DATA_V1)
return -EOPNOTSUPP;
- /* Empty xattrs are ok, they're just empty files, no hash */
- if (buffer && buffer_size)
- xahash = xattr_hash(buffer, buffer_size);
+ if (!buffer)
+ return reiserfs_xattr_del(inode, name);
open_file:
fp = open_xattr_file(inode, name, flags);
@@ -398,6 +391,7 @@ reiserfs_xattr_set(struct inode *inode,
goto out;
}
+ xahash = xattr_hash(buffer, buffer_size);
xinode = fp->f_path.dentry->d_inode;
REISERFS_I(inode)->i_flags |= i_has_xattr_dir;
@@ -531,6 +525,8 @@ reiserfs_xattr_get(const struct inode *i
goto out_fput;
}
+ mutex_lock(&fp->f_path.dentry->d_inode->i_mutex);
+
while (file_pos < isize) {
size_t chunk;
char *data;
@@ -585,6 +581,7 @@ reiserfs_xattr_get(const struct inode *i
}
out_fput:
+ mutex_unlock(&fp->f_path.dentry->d_inode->i_mutex);
fput(fp);
out:
@@ -597,6 +594,7 @@ __reiserfs_xattr_del(struct dentry *xadi
struct dentry *dentry;
struct inode *dir = xadir->d_inode;
int err = 0;
+ struct reiserfs_xattr_handler *xah;
dentry = lookup_one_len(name, xadir, namelen);
if (IS_ERR(dentry)) {
@@ -624,6 +622,14 @@ __reiserfs_xattr_del(struct dentry *xadi
return -EIO;
}
+ /* Deletion pre-operation */
+ xah = find_xattr_handler_prefix(name);
+ if (xah && xah->del) {
+ err = xah->del(inode, name);
+ if (err)
+ goto out;
+ }
+
err = vfs_unlink(xadir->d_inode, dentry);
out_file:
@@ -644,7 +650,9 @@ int reiserfs_xattr_del(struct inode *ino
goto out;
}
+ mutex_lock(&dir->i_mutex);
err = __reiserfs_xattr_del(dir, name, strlen(name));
+ mutex_unlock(&dir->i_mutex);
dput(dir);
if (!err) {
@@ -689,7 +697,8 @@ int reiserfs_delete_xattrs(struct inode
goto out;
} else if (!dir->d_inode) {
dput(dir);
- return 0;
+ err = 0;
+ goto out;
}
fp = dentry_open(dir, NULL, O_RDWR);
@@ -699,12 +708,13 @@ int reiserfs_delete_xattrs(struct inode
goto out;
}
+ mutex_lock_nested(&fp->f_path.dentry->d_inode->i_mutex, I_MUTEX_XATTR);
lock_kernel();
err = xattr_readdir(fp, reiserfs_delete_xattrs_filler, dir);
- if (err) {
- unlock_kernel();
+ unlock_kernel();
+ mutex_unlock(&fp->f_path.dentry->d_inode->i_mutex);
+ if (err)
goto out_dir;
- }
/* Leftovers besides . and .. -- that's not good. */
if (dir->d_inode->i_nlink <= 2) {
@@ -717,7 +727,6 @@ int reiserfs_delete_xattrs(struct inode
reiserfs_warning(inode->i_sb, "jdm-20004",
"Couldn't remove all entries in directory");
}
- unlock_kernel();
out_dir:
fput(fp);
@@ -791,6 +800,7 @@ int reiserfs_chown_xattrs(struct inode *
goto out;
}
+ mutex_lock_nested(&fp->f_path.dentry->d_inode->i_mutex, I_MUTEX_XATTR);
lock_kernel();
attrs->ia_valid &= (ATTR_UID | ATTR_GID | ATTR_CTIME);
@@ -808,6 +818,7 @@ int reiserfs_chown_xattrs(struct inode *
unlock_kernel();
out_dir:
+ mutex_unlock(&fp->f_path.dentry->d_inode->i_mutex);
fput(fp);
out:
@@ -831,9 +842,7 @@ reiserfs_getxattr(struct dentry * dentry
get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1)
return -EOPNOTSUPP;
- reiserfs_read_lock_xattr_i(dentry->d_inode);
err = xah->get(dentry->d_inode, name, buffer, size);
- reiserfs_read_unlock_xattr_i(dentry->d_inode);
return err;
}
@@ -853,9 +862,7 @@ reiserfs_setxattr(struct dentry *dentry,
get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1)
return -EOPNOTSUPP;
- reiserfs_write_lock_xattr_i(dentry->d_inode);
err = xah->set(dentry->d_inode, name, value, size, flags);
- reiserfs_write_unlock_xattr_i(dentry->d_inode);
return err;
}
@@ -873,21 +880,12 @@ int reiserfs_removexattr(struct dentry *
get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1)
return -EOPNOTSUPP;
- reiserfs_write_lock_xattr_i(dentry->d_inode);
- /* Deletion pre-operation */
- if (xah->del) {
- err = xah->del(dentry->d_inode, name);
- if (err)
- goto out;
- }
-
err = reiserfs_xattr_del(dentry->d_inode, name);
dentry->d_inode->i_ctime = CURRENT_TIME_SEC;
mark_inode_dirty(dentry->d_inode);
out:
- reiserfs_write_unlock_xattr_i(dentry->d_inode);
return err;
}
@@ -950,7 +948,6 @@ ssize_t reiserfs_listxattr(struct dentry
get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1)
return -EOPNOTSUPP;
- reiserfs_read_lock_xattr_i(dentry->d_inode);
dir = open_xa_dir(dentry->d_inode, XATTR_REPLACE);
if (IS_ERR(dir)) {
err = PTR_ERR(dir);
@@ -986,7 +983,6 @@ ssize_t reiserfs_listxattr(struct dentry
fput(fp);
out:
- reiserfs_read_unlock_xattr_i(dentry->d_inode);
return err;
}
@@ -1190,12 +1186,8 @@ static int reiserfs_check_acl(struct ino
struct posix_acl *acl;
int error = -EAGAIN; /* do regular unix permission checks by default */
- reiserfs_read_lock_xattr_i(inode);
-
acl = reiserfs_get_acl(inode, ACL_TYPE_ACCESS);
- reiserfs_read_unlock_xattr_i(inode);
-
if (acl) {
if (!IS_ERR(acl)) {
error = posix_acl_permission(inode, acl, mask);
--- a/fs/reiserfs/xattr_acl.c 2007-06-11 14:49:36.000000000 -0400
+++ b/fs/reiserfs/xattr_acl.c 2007-06-11 14:50:06.000000000 -0400
@@ -418,9 +418,7 @@ int reiserfs_cache_default_acl(struct in
int ret = 0;
if (reiserfs_posixacl(inode->i_sb) && !is_reiserfs_priv_object(inode)) {
struct posix_acl *acl;
- reiserfs_read_lock_xattr_i(inode);
acl = reiserfs_get_acl(inode, ACL_TYPE_DEFAULT);
- reiserfs_read_unlock_xattr_i(inode);
ret = (acl && !IS_ERR(acl));
if (ret)
posix_acl_release(acl);
@@ -452,11 +450,8 @@ int reiserfs_acl_chmod(struct inode *ino
if (!clone)
return -ENOMEM;
error = posix_acl_chmod_masq(clone, inode->i_mode);
- if (!error) {
- reiserfs_write_lock_xattr_i(inode);
+ if (!error)
error = reiserfs_set_acl(inode, ACL_TYPE_ACCESS, clone);
- reiserfs_write_unlock_xattr_i(inode);
- }
posix_acl_release(clone);
return error;
}
--- a/include/linux/reiserfs_fs_i.h 2007-06-11 14:49:05.000000000 -0400
+++ b/include/linux/reiserfs_fs_i.h 2007-06-11 14:50:06.000000000 -0400
@@ -58,9 +58,6 @@ struct reiserfs_inode_info {
struct posix_acl *i_acl_access;
struct posix_acl *i_acl_default;
#endif
-#ifdef CONFIG_REISERFS_FS_XATTR
- struct rw_semaphore xattr_sem;
-#endif
struct inode vfs_inode;
};
--- a/include/linux/reiserfs_xattr.h 2007-06-11 14:49:36.000000000 -0400
+++ b/include/linux/reiserfs_xattr.h 2007-06-11 14:50:06.000000000 -0400
@@ -68,34 +68,12 @@ extern struct reiserfs_xattr_handler sec
int reiserfs_xattr_register_handlers(void) __init;
void reiserfs_xattr_unregister_handlers(void);
-static inline void reiserfs_write_lock_xattr_i(struct inode *inode)
-{
- down_write(&REISERFS_I(inode)->xattr_sem);
-}
-static inline void reiserfs_write_unlock_xattr_i(struct inode *inode)
-{
- up_write(&REISERFS_I(inode)->xattr_sem);
-}
-static inline void reiserfs_read_lock_xattr_i(struct inode *inode)
-{
- down_read(&REISERFS_I(inode)->xattr_sem);
-}
-
-static inline void reiserfs_read_unlock_xattr_i(struct inode *inode)
-{
- up_read(&REISERFS_I(inode)->xattr_sem);
-}
static inline void reiserfs_mark_inode_private(struct inode *inode)
{
inode->i_flags |= S_PRIVATE;
}
-static inline void reiserfs_init_xattr_rwsem(struct inode *inode)
-{
- init_rwsem(&REISERFS_I(inode)->xattr_sem);
-}
-
#else
#define is_reiserfs_priv_object(inode) 0
@@ -104,10 +82,6 @@ static inline void reiserfs_init_xattr_r
#define reiserfs_setxattr NULL
#define reiserfs_listxattr NULL
#define reiserfs_removexattr NULL
-#define reiserfs_write_lock_xattrs(sb) do {;} while(0)
-#define reiserfs_write_unlock_xattrs(sb) do {;} while(0)
-#define reiserfs_read_lock_xattrs(sb)
-#define reiserfs_read_unlock_xattrs(sb)
#define reiserfs_permission NULL
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 43+ messages in thread
* [patch 15/40] reiserfs: remove i_has_xattr_dir
2007-06-11 19:03 [patch 00/40] reiserfs: patch queue (v2) jeffm
` (13 preceding siblings ...)
2007-06-11 19:03 ` [patch 14/40] reiserfs: make per-inode xattr locking more fine grained jeffm
@ 2007-06-11 19:03 ` jeffm
2007-06-11 19:03 ` [patch 16/40] reiserfs: remove link detection code jeffm
` (25 subsequent siblings)
40 siblings, 0 replies; 43+ messages in thread
From: jeffm @ 2007-06-11 19:03 UTC (permalink / raw)
To: ReiserFS Mailing List
[-- Attachment #1: reiserfs-remove-i_has_xattr_dir.diff --]
[-- Type: text/plain, Size: 1348 bytes --]
With the changes to xattr root locking, the i_has_xattr_dir flag
is no longer needed. This patch removes it.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
fs/reiserfs/xattr.c | 7 -------
1 file changed, 7 deletions(-)
--- a/fs/reiserfs/xattr.c 2007-06-11 14:49:36.000000000 -0400
+++ b/fs/reiserfs/xattr.c 2007-06-11 14:50:07.000000000 -0400
@@ -393,7 +393,6 @@ reiserfs_xattr_set(struct inode *inode,
xahash = xattr_hash(buffer, buffer_size);
xinode = fp->f_path.dentry->d_inode;
- REISERFS_I(inode)->i_flags |= i_has_xattr_dir;
/* we need to copy it off.. */
if (xinode->i_nlink > 1) {
@@ -512,7 +511,6 @@ reiserfs_xattr_get(const struct inode *i
xinode = fp->f_path.dentry->d_inode;
isize = xinode->i_size;
- REISERFS_I(inode)->i_flags |= i_has_xattr_dir;
/* Just return the size needed */
if (buffer == NULL) {
@@ -732,9 +730,6 @@ int reiserfs_delete_xattrs(struct inode
fput(fp);
out:
- if (!err)
- REISERFS_I(inode)->i_flags =
- REISERFS_I(inode)->i_flags & ~i_has_xattr_dir;
return err;
}
@@ -968,8 +963,6 @@ ssize_t reiserfs_listxattr(struct dentry
buf.r_pos = 0;
buf.r_inode = dentry->d_inode;
- REISERFS_I(dentry->d_inode)->i_flags |= i_has_xattr_dir;
-
err = xattr_readdir(fp, reiserfs_listxattr_filler, &buf);
if (err)
goto out_dir;
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 43+ messages in thread
* [patch 16/40] reiserfs: remove link detection code
2007-06-11 19:03 [patch 00/40] reiserfs: patch queue (v2) jeffm
` (14 preceding siblings ...)
2007-06-11 19:03 ` [patch 15/40] reiserfs: remove i_has_xattr_dir jeffm
@ 2007-06-11 19:03 ` jeffm
2007-06-11 19:03 ` [patch 17/40] reiserfs: use generic xattr handlers jeffm
` (24 subsequent siblings)
40 siblings, 0 replies; 43+ messages in thread
From: jeffm @ 2007-06-11 19:03 UTC (permalink / raw)
To: ReiserFS Mailing List
[-- Attachment #1: reiserfs-remove-link-detection.diff --]
[-- Type: text/plain, Size: 1283 bytes --]
Early in the reiserfs xattr development, there was a plan to use hardlinks
to save disk space for identical xattrs. That code never materialized and
isn't going to, so this patch removes the detection code.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
fs/reiserfs/xattr.c | 13 -------------
1 file changed, 13 deletions(-)
--- a/fs/reiserfs/xattr.c 2007-06-11 14:49:36.000000000 -0400
+++ b/fs/reiserfs/xattr.c 2007-06-11 14:50:06.000000000 -0400
@@ -384,7 +384,6 @@ reiserfs_xattr_set(struct inode *inode,
if (!buffer)
return reiserfs_xattr_del(inode, name);
- open_file:
fp = open_xattr_file(inode, name, flags);
if (IS_ERR(fp)) {
err = PTR_ERR(fp);
@@ -394,18 +393,6 @@ reiserfs_xattr_set(struct inode *inode,
xahash = xattr_hash(buffer, buffer_size);
xinode = fp->f_path.dentry->d_inode;
- /* we need to copy it off.. */
- if (xinode->i_nlink > 1) {
- fput(fp);
- err = reiserfs_xattr_del(inode, name);
- if (err < 0)
- goto out;
- /* We just killed the old one, we're not replacing anymore */
- if (flags & XATTR_REPLACE)
- flags &= ~XATTR_REPLACE;
- goto open_file;
- }
-
/* Resize it so we're ok to write there */
newattrs.ia_size = buffer_size;
newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 43+ messages in thread
* [patch 17/40] reiserfs: use generic xattr handlers
2007-06-11 19:03 [patch 00/40] reiserfs: patch queue (v2) jeffm
` (15 preceding siblings ...)
2007-06-11 19:03 ` [patch 16/40] reiserfs: remove link detection code jeffm
@ 2007-06-11 19:03 ` jeffm
2007-06-11 19:03 ` [patch 18/40] reiserfs: use better open options for internal files jeffm
` (23 subsequent siblings)
40 siblings, 0 replies; 43+ messages in thread
From: jeffm @ 2007-06-11 19:03 UTC (permalink / raw)
To: ReiserFS Mailing List
[-- Attachment #1: reiserfs-use-generic-xattr-handlers.diff --]
[-- Type: text/plain, Size: 31530 bytes --]
Christoph Hellwig had asked me quite some time ago to port the reiserfs
xattrs to the generic xattr interface.
This patch replaces the reiserfs-specific xattr handling code with the
generic struct xattr_handler.
However, since reiserfs doesn't split the prefix and name when accessing
xattrs, it can't leverage generic_{set,get,list,remove}xattr without
needlessly reconstructing the name on the back end.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
fs/reiserfs/super.c | 7
fs/reiserfs/xattr.c | 399 +++++++++++++++--------------------------
fs/reiserfs/xattr_acl.c | 72 ++-----
fs/reiserfs/xattr_security.c | 26 --
fs/reiserfs/xattr_trusted.c | 45 +---
fs/reiserfs/xattr_user.c | 30 ---
include/linux/reiserfs_acl.h | 16 -
include/linux/reiserfs_fs_sb.h | 3
include/linux/reiserfs_xattr.h | 29 --
9 files changed, 206 insertions(+), 421 deletions(-)
--- a/fs/reiserfs/super.c 2007-06-11 14:49:36.000000000 -0400
+++ b/fs/reiserfs/super.c 2007-06-11 14:50:04.000000000 -0400
@@ -2132,9 +2132,6 @@ static int __init init_reiserfs_fs(void)
return ret;
}
- if ((ret = reiserfs_xattr_register_handlers()))
- goto failed_reiserfs_xattr_register_handlers;
-
reiserfs_proc_info_global_init();
reiserfs_proc_register_global("version",
reiserfs_global_version_in_proc);
@@ -2145,9 +2142,6 @@ static int __init init_reiserfs_fs(void)
return 0;
}
- reiserfs_xattr_unregister_handlers();
-
- failed_reiserfs_xattr_register_handlers:
reiserfs_proc_unregister_global("version");
reiserfs_proc_info_global_done();
destroy_inodecache();
@@ -2157,7 +2151,6 @@ static int __init init_reiserfs_fs(void)
static void __exit exit_reiserfs_fs(void)
{
- reiserfs_xattr_unregister_handlers();
reiserfs_proc_unregister_global("version");
reiserfs_proc_info_global_done();
unregister_filesystem(&reiserfs_fs_type);
--- a/fs/reiserfs/xattr.c 2007-06-11 14:49:37.000000000 -0400
+++ b/fs/reiserfs/xattr.c 2007-06-11 14:50:06.000000000 -0400
@@ -53,8 +53,49 @@
#define PRIVROOT_NAME ".reiserfs_priv"
#define XAROOT_NAME "xattrs"
-static struct reiserfs_xattr_handler *find_xattr_handler_prefix(const char
- *prefix);
+struct xattr_handler *reiserfs_xattr_handlers[] = {
+ &reiserfs_xattr_user_handler,
+ &reiserfs_xattr_trusted_handler,
+#ifdef CONFIG_REISERFS_FS_SECURITY
+ &reiserfs_xattr_security_handler,
+#endif
+#ifdef CONFIG_REISERFS_FS_POSIX_ACL
+ &reiserfs_posix_acl_access_handler,
+ &reiserfs_posix_acl_default_handler,
+#endif
+ NULL
+};
+
+/*
+ * In order to implement different sets of xattr operations for each xattr
+ * prefix with the generic xattr API, a filesystem should create a
+ * null-terminated array of struct xattr_handler (one for each prefix) and
+ * hang a pointer to it off of the s_xattr field of the superblock.
+ *
+ * The generic_fooxattr() functions will use this list to dispatch xattr
+ * operations to the correct xattr_handler.
+ */
+#define for_each_xattr_handler(handlers, handler) \
+ for ((handler) = *(handlers)++; \
+ (handler) != NULL; \
+ (handler) = *(handlers)++)
+
+/* This is the implementation for the xattr plugin infrastructure */
+static inline struct xattr_handler *find_xattr_handler_prefix(struct xattr_handler **handlers,
+ const char *name)
+{
+ struct xattr_handler *xah;
+
+ if (!handlers)
+ return NULL;
+
+ for_each_xattr_handler(handlers, xah) {
+ if (strncmp(xah->prefix, name, strlen(xah->prefix)) == 0)
+ break;
+ }
+
+ return xah;
+}
#define xattr_may_create(flags) (!flags || flags & XATTR_CREATE)
@@ -113,7 +154,7 @@ static struct dentry *open_xa_dir(const
}
-static struct file *open_xattr_file(const struct inode *inode,
+static struct file *open_xattr_file(struct inode *inode,
const char *name, int flags)
{
struct dentry *xadir, *xafile;
@@ -381,8 +422,27 @@ reiserfs_xattr_set(struct inode *inode,
if (get_inode_sd_version(inode) == STAT_DATA_V1)
return -EOPNOTSUPP;
- if (!buffer)
- return reiserfs_xattr_del(inode, name);
+ /* Clearing it out - delete it. */
+ if (!buffer) {
+ struct inode *dir;
+
+ fp = open_xattr_file(inode, name, XATTR_REPLACE);
+ if (IS_ERR(fp)) {
+ err = PTR_ERR(fp);
+ if (err == -ENODATA)
+ err = 0;
+ return err;
+ }
+
+ dir = fp->f_path.dentry->d_parent->d_inode;
+ err = vfs_unlink(dir, fp->f_dentry);
+ fput(fp);
+ if (!err) {
+ inode->i_ctime = CURRENT_TIME_SEC;
+ mark_inode_dirty(inode);
+ }
+ return err;
+ }
fp = open_xattr_file(inode, name, flags);
if (IS_ERR(fp)) {
@@ -449,6 +509,12 @@ reiserfs_xattr_set(struct inode *inode,
break;
}
+ out_filp:
+ mutex_unlock(&xinode->i_mutex);
+ fput(fp);
+
+ out:
+
/* We can't mark the inode dirty if it's not hashed. This is the case
* when we're inheriting the default ACL. If we dirty it, the inode
* gets marked dirty, but won't (ever) make it onto the dirty list until
@@ -458,11 +524,6 @@ reiserfs_xattr_set(struct inode *inode,
mark_inode_dirty(inode);
}
- out_filp:
- mutex_unlock(&xinode->i_mutex);
- fput(fp);
-
- out:
return err;
}
@@ -470,7 +531,7 @@ reiserfs_xattr_set(struct inode *inode,
* inode->i_mutex: down
*/
int
-reiserfs_xattr_get(const struct inode *inode, const char *name, void *buffer,
+reiserfs_xattr_get(struct inode *inode, const char *name, void *buffer,
size_t buffer_size)
{
ssize_t err = 0;
@@ -573,13 +634,17 @@ reiserfs_xattr_get(const struct inode *i
return err;
}
+/* The following are side effects of other operations that aren't explicitly
+ * modifying extended attributes. This includes operations such as permissions
+ * or ownership changes, object deletions, etc. */
+
static int
-__reiserfs_xattr_del(struct dentry *xadir, const char *name, int namelen)
+reiserfs_delete_xattrs_filler(void *buf, const char *name, int namelen,
+ loff_t offset, u64 ino, unsigned int d_type)
{
+ struct dentry *xadir = (struct dentry *)buf;
struct dentry *dentry;
- struct inode *dir = xadir->d_inode;
int err = 0;
- struct reiserfs_xattr_handler *xah;
dentry = lookup_one_len(name, xadir, namelen);
if (IS_ERR(dentry)) {
@@ -594,27 +659,6 @@ __reiserfs_xattr_del(struct dentry *xadi
if (S_ISDIR(dentry->d_inode->i_mode))
goto out_file;
- if (!is_reiserfs_priv_object(dentry->d_inode)) {
- reiserfs_error(dir->i_sb, "jdm-20003",
- "OID %08x [%.*s/%.*s] doesn't have "
- "priv flag set [parent is %sset].",
- le32_to_cpu(INODE_PKEY(dentry->d_inode)->
- k_objectid), xadir->d_name.len,
- xadir->d_name.name, namelen, name,
- is_reiserfs_priv_object(xadir-> d_inode) ? "" :
- "not ");
- dput(dentry);
- return -EIO;
- }
-
- /* Deletion pre-operation */
- xah = find_xattr_handler_prefix(name);
- if (xah && xah->del) {
- err = xah->del(inode, name);
- if (err)
- goto out;
- }
-
err = vfs_unlink(xadir->d_inode, dentry);
out_file:
@@ -624,45 +668,6 @@ __reiserfs_xattr_del(struct dentry *xadi
return err;
}
-int reiserfs_xattr_del(struct inode *inode, const char *name)
-{
- struct dentry *dir;
- int err;
-
- dir = open_xa_dir(inode, XATTR_REPLACE);
- if (IS_ERR(dir)) {
- err = PTR_ERR(dir);
- goto out;
- }
-
- mutex_lock(&dir->i_mutex);
- err = __reiserfs_xattr_del(dir, name, strlen(name));
- mutex_unlock(&dir->i_mutex);
- dput(dir);
-
- if (!err) {
- inode->i_ctime = CURRENT_TIME_SEC;
- mark_inode_dirty(inode);
- }
-
- out:
- return err;
-}
-
-/* The following are side effects of other operations that aren't explicitly
- * modifying extended attributes. This includes operations such as permissions
- * or ownership changes, object deletions, etc. */
-
-static int
-reiserfs_delete_xattrs_filler(void *buf, const char *name, int namelen,
- loff_t offset, u64 ino, unsigned int d_type)
-{
- struct dentry *xadir = (struct dentry *)buf;
-
- return __reiserfs_xattr_del(xadir, name, namelen);
-
-}
-
/* This is called w/ inode->i_mutex downed */
int reiserfs_delete_xattrs(struct inode *inode)
{
@@ -817,15 +822,15 @@ ssize_t
reiserfs_getxattr(struct dentry * dentry, const char *name, void *buffer,
size_t size)
{
- struct reiserfs_xattr_handler *xah = find_xattr_handler_prefix(name);
- int err;
+ struct inode *inode = dentry->d_inode;
+ struct xattr_handler *handler;
- if (!xah || !reiserfs_xattrs(dentry->d_sb) ||
- get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1)
+ handler = find_xattr_handler_prefix(inode->i_sb->s_xattr, name);
+
+ if (!handler || get_inode_sd_version(inode) == STAT_DATA_V1)
return -EOPNOTSUPP;
- err = xah->get(dentry->d_inode, name, buffer, size);
- return err;
+ return handler->get(inode, name, buffer, size);
}
/*
@@ -837,15 +842,15 @@ int
reiserfs_setxattr(struct dentry *dentry, const char *name, const void *value,
size_t size, int flags)
{
- struct reiserfs_xattr_handler *xah = find_xattr_handler_prefix(name);
- int err;
+ struct inode *inode = dentry->d_inode;
+ struct xattr_handler *handler;
- if (!xah || !reiserfs_xattrs(dentry->d_sb) ||
- get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1)
+ handler = find_xattr_handler_prefix(inode->i_sb->s_xattr, name);
+
+ if (!handler || get_inode_sd_version(inode) == STAT_DATA_V1)
return -EOPNOTSUPP;
- err = xah->set(dentry->d_inode, name, value, size, flags);
- return err;
+ return handler->set(inode, name, value, size, flags);
}
/*
@@ -855,73 +860,66 @@ reiserfs_setxattr(struct dentry *dentry,
*/
int reiserfs_removexattr(struct dentry *dentry, const char *name)
{
- int err;
- struct reiserfs_xattr_handler *xah = find_xattr_handler_prefix(name);
+ struct inode *inode = dentry->d_inode;
+ struct xattr_handler *handler;
+ handler = find_xattr_handler_prefix(inode->i_sb->s_xattr, name);
- if (!xah || !reiserfs_xattrs(dentry->d_sb) ||
- get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1)
+ if (!handler || get_inode_sd_version(inode) == STAT_DATA_V1)
return -EOPNOTSUPP;
- err = reiserfs_xattr_del(dentry->d_inode, name);
-
- dentry->d_inode->i_ctime = CURRENT_TIME_SEC;
- mark_inode_dirty(dentry->d_inode);
-
- out:
- return err;
+ return handler->set(inode, name, NULL, 0, XATTR_REPLACE);
}
-/* This is what filldir will use:
- * r_pos will always contain the amount of space required for the entire
- * list. If r_pos becomes larger than r_size, we need more space and we
- * return an error indicating this. If r_pos is less than r_size, then we've
- * filled the buffer successfully and we return success */
-struct reiserfs_listxattr_buf {
- int r_pos;
- int r_size;
- char *r_buf;
- struct inode *r_inode;
+struct listxattr_buf {
+ size_t size;
+ size_t pos;
+ char *buf;
+ struct inode *inode;
};
-static int
-reiserfs_listxattr_filler(void *buf, const char *name, int namelen,
- loff_t offset, u64 ino, unsigned int d_type)
+static int listxattr_filler(void *buf, const char *name, int namelen,
+ loff_t offset, u64 ino, unsigned int d_type)
{
- struct reiserfs_listxattr_buf *b = (struct reiserfs_listxattr_buf *)buf;
- int len = 0;
- if (name[0] != '.'
- || (namelen != 1 && (name[1] != '.' || namelen != 2))) {
- struct reiserfs_xattr_handler *xah =
- find_xattr_handler_prefix(name);
- if (!xah)
- return 0; /* Unsupported xattr name, skip it */
-
- /* We call ->list() twice because the operation isn't required to just
- * return the name back - we want to make sure we have enough space */
- len += xah->list(b->r_inode, name, namelen, NULL);
-
- if (len) {
- if (b->r_pos + len + 1 <= b->r_size) {
- char *p = b->r_buf + b->r_pos;
- p += xah->list(b->r_inode, name, namelen, p);
- *p++ = '\0';
- }
- b->r_pos += len + 1;
+ struct listxattr_buf *b = (struct listxattr_buf *)buf;
+ size_t size;
+ if (name[0] != '.' ||
+ (namelen != 1 && (name[1] != '.' || namelen != 2))) {
+ struct xattr_handler *handler;
+ handler = find_xattr_handler_prefix(b->inode->i_sb->s_xattr,
+ name);
+ if (!handler) /* Unsupported xattr name */
+ return 0;
+ if (b->buf) {
+ size = handler->list(b->inode, b->buf + b->pos,
+ b->size, name, namelen);
+ if (size > b->size)
+ return -ERANGE;
+ } else {
+ size = handler->list(b->inode, NULL, 0, name, namelen);
}
- }
+ b->pos += size;
+ }
return 0;
}
/*
* Inode operation listxattr()
+ *
+ * We totally ignore the generic listxattr here because it would be stupid
+ * not to. Since the xattrs are organized in a directory, we can just
+ * readdir to find them.
*/
ssize_t reiserfs_listxattr(struct dentry * dentry, char *buffer, size_t size)
{
struct file *fp;
struct dentry *dir;
int err = 0;
- struct reiserfs_listxattr_buf buf;
+ struct listxattr_buf buf = {
+ .inode = dentry->d_inode,
+ .buf = buffer,
+ .size = buffer ? size : 0,
+ };
if (!dentry->d_inode)
return -EINVAL;
@@ -934,30 +932,22 @@ ssize_t reiserfs_listxattr(struct dentry
if (IS_ERR(dir)) {
err = PTR_ERR(dir);
if (err == -ENODATA)
- err = 0; /* Not an error if there aren't any xattrs */
+ err = 0; /* Not an error if there aren't any xattrs */
goto out;
}
- fp = dentry_open(dir, NULL, O_RDWR);
+ fp = dentry_open(dir, NULL, O_RDWR|O_NOATIME|O_DIRECTORY);
if (IS_ERR(fp)) {
err = PTR_ERR(fp);
/* dentry_open dputs the dentry if it fails */
goto out;
}
- buf.r_buf = buffer;
- buf.r_size = buffer ? size : 0;
- buf.r_pos = 0;
- buf.r_inode = dentry->d_inode;
-
- err = xattr_readdir(fp, reiserfs_listxattr_filler, &buf);
+ err = xattr_readdir(fp, listxattr_filler, &buf);
if (err)
goto out_dir;
- if (buf.r_pos > buf.r_size && buffer != NULL)
- err = -ERANGE;
- else
- err = buf.r_pos;
+ err = buf.pos;
out_dir:
fput(fp);
@@ -966,95 +956,6 @@ ssize_t reiserfs_listxattr(struct dentry
return err;
}
-/* This is the implementation for the xattr plugin infrastructure */
-static struct list_head xattr_handlers = LIST_HEAD_INIT(xattr_handlers);
-static DEFINE_RWLOCK(handler_lock);
-
-static struct reiserfs_xattr_handler *find_xattr_handler_prefix(const char
- *prefix)
-{
- struct reiserfs_xattr_handler *xah = NULL;
- struct list_head *p;
-
- read_lock(&handler_lock);
- list_for_each(p, &xattr_handlers) {
- xah = list_entry(p, struct reiserfs_xattr_handler, handlers);
- if (strncmp(xah->prefix, prefix, strlen(xah->prefix)) == 0)
- break;
- xah = NULL;
- }
-
- read_unlock(&handler_lock);
- return xah;
-}
-
-static void __unregister_handlers(void)
-{
- struct reiserfs_xattr_handler *xah;
- struct list_head *p, *tmp;
-
- list_for_each_safe(p, tmp, &xattr_handlers) {
- xah = list_entry(p, struct reiserfs_xattr_handler, handlers);
- if (xah->exit)
- xah->exit();
-
- list_del_init(p);
- }
- INIT_LIST_HEAD(&xattr_handlers);
-}
-
-int __init reiserfs_xattr_register_handlers(void)
-{
- int err = 0;
- struct reiserfs_xattr_handler *xah;
- struct list_head *p;
-
- write_lock(&handler_lock);
-
- /* If we're already initialized, nothing to do */
- if (!list_empty(&xattr_handlers)) {
- write_unlock(&handler_lock);
- return 0;
- }
-
- /* Add the handlers */
- list_add_tail(&user_handler.handlers, &xattr_handlers);
- list_add_tail(&trusted_handler.handlers, &xattr_handlers);
-#ifdef CONFIG_REISERFS_FS_SECURITY
- list_add_tail(&security_handler.handlers, &xattr_handlers);
-#endif
-#ifdef CONFIG_REISERFS_FS_POSIX_ACL
- list_add_tail(&posix_acl_access_handler.handlers, &xattr_handlers);
- list_add_tail(&posix_acl_default_handler.handlers, &xattr_handlers);
-#endif
-
- /* Run initializers, if available */
- list_for_each(p, &xattr_handlers) {
- xah = list_entry(p, struct reiserfs_xattr_handler, handlers);
- if (xah->init) {
- err = xah->init();
- if (err) {
- list_del_init(p);
- break;
- }
- }
- }
-
- /* Clean up other handlers, if any failed */
- if (err)
- __unregister_handlers();
-
- write_unlock(&handler_lock);
- return err;
-}
-
-void reiserfs_xattr_unregister_handlers(void)
-{
- write_lock(&handler_lock);
- __unregister_handlers();
- write_unlock(&handler_lock);
-}
-
/* This will catch lookups from the fs root to .reiserfs_priv */
static int
xattr_lookup_poison(struct dentry *dentry, struct qstr *q1, struct qstr *name)
@@ -1083,24 +984,21 @@ int reiserfs_xattr_init(struct super_blo
/* We need generation numbers to ensure that the oid mapping is correct
* v3.5 filesystems don't have them. */
- if (!old_format_only(s)) {
- set_bit(REISERFS_XATTRS, &(REISERFS_SB(s)->s_mount_opt));
- } else if (reiserfs_xattrs_optional(s)) {
- /* Old format filesystem, but optional xattrs have been enabled
- * at mount time. Error out. */
- reiserfs_warning(s, "jdm-20005",
- "xattrs/ACLs not supported on pre v3.6 "
- "format filesystem. Failing mount.");
- err = -EOPNOTSUPP;
- goto error;
- } else {
- /* Old format filesystem, but no optional xattrs have been enabled. This
- * means we silently disable xattrs on the filesystem. */
- clear_bit(REISERFS_XATTRS, &(REISERFS_SB(s)->s_mount_opt));
+ if (old_format_only(s)) {
+ if (reiserfs_xattrs_optional(s)) {
+ /* Old format filesystem, but optional xattrs have
+ * been enabled. Error out. */
+ reiserfs_warning(s, "jdm-2005",
+ "xattrs/ACLs not supported "
+ "on pre-v3.6 format filesystems. "
+ "Failing mount.");
+ err = -EOPNOTSUPP;
+ }
+ return err;
}
/* If we don't have the privroot located yet - go find it */
- if (reiserfs_xattrs(s) && !REISERFS_SB(s)->priv_root) {
+ if (!REISERFS_SB(s)->priv_root) {
struct dentry *dentry;
dentry = lookup_one_len(PRIVROOT_NAME, s->s_root,
strlen(PRIVROOT_NAME));
@@ -1141,14 +1039,17 @@ int reiserfs_xattr_init(struct super_blo
"find/create .reiserfs_priv. "
"Failing mount.");
err = -EOPNOTSUPP;
+ goto error;
}
}
+ if (!err)
+ s->s_xattr = reiserfs_xattr_handlers;
+
error:
/* This is only nonzero if there was an error initializing the xattr
* directory or if there is a condition where we don't support them. */
if (err) {
- clear_bit(REISERFS_XATTRS, &(REISERFS_SB(s)->s_mount_opt));
clear_bit(REISERFS_XATTRS_USER, &(REISERFS_SB(s)->s_mount_opt));
clear_bit(REISERFS_POSIXACL, &(REISERFS_SB(s)->s_mount_opt));
}
--- a/fs/reiserfs/xattr_acl.c 2007-06-11 14:49:36.000000000 -0400
+++ b/fs/reiserfs/xattr_acl.c 2007-06-11 14:50:06.000000000 -0400
@@ -271,7 +271,7 @@ reiserfs_set_acl(struct inode *inode, in
char *name;
void *value = NULL;
struct posix_acl **p_acl;
- size_t size;
+ size_t size = 0;
int error;
struct reiserfs_inode_info *reiserfs_i = REISERFS_I(inode);
@@ -289,6 +289,9 @@ reiserfs_set_acl(struct inode *inode, in
return error;
else {
inode->i_mode = mode;
+ /* We don't dirty the inode, since
+ * reiserfs_xattr_set_handle will do it
+ * for us. */
if (error == 0)
acl = NULL;
}
@@ -308,19 +311,10 @@ reiserfs_set_acl(struct inode *inode, in
value = posix_acl_to_disk(acl, &size);
if (IS_ERR(value))
return (int)PTR_ERR(value);
- error = reiserfs_xattr_set(inode, name, value, size, 0);
- } else {
- error = reiserfs_xattr_del(inode, name);
- if (error == -ENODATA) {
- /* This may seem odd here, but it means that the ACL was set
- * with a value representable with mode bits. If there was
- * an ACL before, reiserfs_xattr_del already dirtied the inode.
- */
- mark_inode_dirty(inode);
- error = 0;
- }
}
+ error = reiserfs_xattr_set(inode, name, value, size, 0);
+
kfree(value);
if (!error)
@@ -474,33 +468,22 @@ posix_acl_access_set(struct inode *inode
return xattr_set_acl(inode, ACL_TYPE_ACCESS, value, size);
}
-static int posix_acl_access_del(struct inode *inode, const char *name)
-{
- struct reiserfs_inode_info *reiserfs_i = REISERFS_I(inode);
- if (strlen(name) != sizeof(POSIX_ACL_XATTR_ACCESS) - 1)
- return -EINVAL;
- iset_acl(inode, &reiserfs_i->i_acl_access, ERR_PTR(-ENODATA));
- return 0;
-}
-
-static int
-posix_acl_access_list(struct inode *inode, const char *name, int namelen,
- char *out)
+static size_t posix_acl_access_list(struct inode *inode, char *list,
+ size_t list_size, const char *name,
+ size_t name_len)
{
- int len = namelen;
+ const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS);
if (!reiserfs_posixacl(inode->i_sb))
return 0;
- if (out)
- memcpy(out, name, len);
-
- return len;
+ if (list && size <= list_size)
+ memcpy(list, POSIX_ACL_XATTR_ACCESS, size);
+ return size;
}
-struct reiserfs_xattr_handler posix_acl_access_handler = {
+struct xattr_handler reiserfs_posix_acl_access_handler = {
.prefix = POSIX_ACL_XATTR_ACCESS,
.get = posix_acl_access_get,
.set = posix_acl_access_set,
- .del = posix_acl_access_del,
.list = posix_acl_access_list,
};
@@ -522,32 +505,21 @@ posix_acl_default_set(struct inode *inod
return xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size);
}
-static int posix_acl_default_del(struct inode *inode, const char *name)
+static size_t posix_acl_default_list(struct inode *inode, char *list,
+ size_t list_size, const char *name,
+ size_t name_len)
{
- struct reiserfs_inode_info *reiserfs_i = REISERFS_I(inode);
- if (strlen(name) != sizeof(POSIX_ACL_XATTR_DEFAULT) - 1)
- return -EINVAL;
- iset_acl(inode, &reiserfs_i->i_acl_default, ERR_PTR(-ENODATA));
- return 0;
-}
-
-static int
-posix_acl_default_list(struct inode *inode, const char *name, int namelen,
- char *out)
-{
- int len = namelen;
+ const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT);
if (!reiserfs_posixacl(inode->i_sb))
return 0;
- if (out)
- memcpy(out, name, len);
-
- return len;
+ if (list && size <= list_size)
+ memcpy(list, POSIX_ACL_XATTR_DEFAULT, size);
+ return size;
}
-struct reiserfs_xattr_handler posix_acl_default_handler = {
+struct xattr_handler reiserfs_posix_acl_default_handler = {
.prefix = POSIX_ACL_XATTR_DEFAULT,
.get = posix_acl_default_get,
.set = posix_acl_default_set,
- .del = posix_acl_default_del,
.list = posix_acl_default_list,
};
--- a/fs/reiserfs/xattr_security.c 2007-06-11 14:49:05.000000000 -0400
+++ b/fs/reiserfs/xattr_security.c 2007-06-11 14:50:05.000000000 -0400
@@ -33,35 +33,25 @@ security_set(struct inode *inode, const
return reiserfs_xattr_set(inode, name, buffer, size, flags);
}
-static int security_del(struct inode *inode, const char *name)
+static size_t security_list(struct inode *inode, char *list, size_t list_len,
+ const char *name, size_t namelen)
{
- if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX))
- return -EINVAL;
-
- if (is_reiserfs_priv_object(inode))
- return -EPERM;
-
- return 0;
-}
-
-static int
-security_list(struct inode *inode, const char *name, int namelen, char *out)
-{
- int len = namelen;
+ const size_t len = namelen + 1;
if (is_reiserfs_priv_object(inode))
return 0;
- if (out)
- memcpy(out, name, len);
+ if (list && len <= list_len) {
+ memcpy(list, name, namelen);
+ list[namelen] = '\0';
+ }
return len;
}
-struct reiserfs_xattr_handler security_handler = {
+struct xattr_handler reiserfs_xattr_security_handler = {
.prefix = XATTR_SECURITY_PREFIX,
.get = security_get,
.set = security_set,
- .del = security_del,
.list = security_list,
};
--- a/fs/reiserfs/xattr_trusted.c 2007-06-11 14:49:05.000000000 -0400
+++ b/fs/reiserfs/xattr_trusted.c 2007-06-11 14:49:37.000000000 -0400
@@ -15,10 +15,7 @@ trusted_get(struct inode *inode, const c
if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX))
return -EINVAL;
- if (!reiserfs_xattrs(inode->i_sb))
- return -EOPNOTSUPP;
-
- if (!(capable(CAP_SYS_ADMIN) || is_reiserfs_priv_object(inode)))
+ if (!capable(CAP_SYS_ADMIN) || is_reiserfs_priv_object(inode))
return -EPERM;
return reiserfs_xattr_get(inode, name, buffer, size);
@@ -31,50 +28,30 @@ trusted_set(struct inode *inode, const c
if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX))
return -EINVAL;
- if (!reiserfs_xattrs(inode->i_sb))
- return -EOPNOTSUPP;
-
- if (!(capable(CAP_SYS_ADMIN) || is_reiserfs_priv_object(inode)))
+ if (!capable(CAP_SYS_ADMIN) || is_reiserfs_priv_object(inode))
return -EPERM;
return reiserfs_xattr_set(inode, name, buffer, size, flags);
}
-static int trusted_del(struct inode *inode, const char *name)
+static size_t trusted_list(struct inode *inode, char *list, size_t list_size,
+ const char *name, size_t name_len)
{
- if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX))
- return -EINVAL;
+ const size_t len = name_len + 1;
- if (!reiserfs_xattrs(inode->i_sb))
- return -EOPNOTSUPP;
-
- if (!(capable(CAP_SYS_ADMIN) || is_reiserfs_priv_object(inode)))
- return -EPERM;
-
- return 0;
-}
-
-static int
-trusted_list(struct inode *inode, const char *name, int namelen, char *out)
-{
- int len = namelen;
-
- if (!reiserfs_xattrs(inode->i_sb))
+ if (!capable(CAP_SYS_ADMIN) || is_reiserfs_priv_object(inode))
return 0;
- if (!(capable(CAP_SYS_ADMIN) || is_reiserfs_priv_object(inode)))
- return 0;
-
- if (out)
- memcpy(out, name, len);
-
+ if (list && len <= list_size) {
+ memcpy(list, name, name_len);
+ list[name_len] = '\0';
+ }
return len;
}
-struct reiserfs_xattr_handler trusted_handler = {
+struct xattr_handler reiserfs_xattr_trusted_handler = {
.prefix = XATTR_TRUSTED_PREFIX,
.get = trusted_get,
.set = trusted_set,
- .del = trusted_del,
.list = trusted_list,
};
--- a/fs/reiserfs/xattr_user.c 2007-06-11 14:49:05.000000000 -0400
+++ b/fs/reiserfs/xattr_user.c 2007-06-11 14:49:37.000000000 -0400
@@ -6,10 +6,6 @@
#include <linux/reiserfs_xattr.h>
#include <asm/uaccess.h>
-#ifdef CONFIG_REISERFS_FS_POSIX_ACL
-# include <linux/reiserfs_acl.h>
-#endif
-
#define XATTR_USER_PREFIX "user."
static int
@@ -36,33 +32,23 @@ user_set(struct inode *inode, const char
return reiserfs_xattr_set(inode, name, buffer, size, flags);
}
-static int user_del(struct inode *inode, const char *name)
+static size_t user_list(struct inode *inode, char *list, size_t list_size,
+ const char *name, size_t name_len)
{
- if (strlen(name) < sizeof(XATTR_USER_PREFIX))
- return -EINVAL;
+ const size_t len = name_len + 1;
if (!reiserfs_xattrs_user(inode->i_sb))
- return -EOPNOTSUPP;
- return 0;
-}
-
-static int
-user_list(struct inode *inode, const char *name, int namelen, char *out)
-{
- int len = namelen;
- if (!reiserfs_xattrs_user(inode->i_sb))
return 0;
-
- if (out)
- memcpy(out, name, len);
-
+ if (list && len <= list_size) {
+ memcpy(list, name, name_len);
+ list[name_len] = '\0';
+ }
return len;
}
-struct reiserfs_xattr_handler user_handler = {
+struct xattr_handler reiserfs_xattr_user_handler = {
.prefix = XATTR_USER_PREFIX,
.get = user_get,
.set = user_set,
- .del = user_del,
.list = user_list,
};
--- a/include/linux/reiserfs_acl.h 2007-06-11 14:49:05.000000000 -0400
+++ b/include/linux/reiserfs_acl.h 2007-06-11 14:50:06.000000000 -0400
@@ -52,10 +52,8 @@ int reiserfs_acl_chmod(struct inode *ino
int reiserfs_inherit_default_acl(struct inode *dir, struct dentry *dentry,
struct inode *inode);
int reiserfs_cache_default_acl(struct inode *dir);
-extern int reiserfs_xattr_posix_acl_init(void) __init;
-extern int reiserfs_xattr_posix_acl_exit(void);
-extern struct reiserfs_xattr_handler posix_acl_default_handler;
-extern struct reiserfs_xattr_handler posix_acl_access_handler;
+extern struct xattr_handler reiserfs_posix_acl_default_handler;
+extern struct xattr_handler reiserfs_posix_acl_access_handler;
static inline void reiserfs_init_acl_access(struct inode *inode)
{
@@ -75,16 +73,6 @@ static inline struct posix_acl *reiserfs
return NULL;
}
-static inline int reiserfs_xattr_posix_acl_init(void)
-{
- return 0;
-}
-
-static inline int reiserfs_xattr_posix_acl_exit(void)
-{
- return 0;
-}
-
static inline int reiserfs_acl_chmod(struct inode *inode)
{
return 0;
--- a/include/linux/reiserfs_fs_sb.h 2007-06-11 14:49:36.000000000 -0400
+++ b/include/linux/reiserfs_fs_sb.h 2007-06-11 14:50:04.000000000 -0400
@@ -452,7 +452,6 @@ enum reiserfs_mount_options {
REISERFS_NO_UNHASHED_RELOCATION,
REISERFS_HASHED_RELOCATION,
REISERFS_ATTRS,
- REISERFS_XATTRS,
REISERFS_XATTRS_USER,
REISERFS_POSIXACL,
REISERFS_BARRIER_NONE,
@@ -490,7 +489,7 @@ enum reiserfs_mount_options {
#define reiserfs_data_log(s) (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_DATA_LOG))
#define reiserfs_data_ordered(s) (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_DATA_ORDERED))
#define reiserfs_data_writeback(s) (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_DATA_WRITEBACK))
-#define reiserfs_xattrs(s) (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_XATTRS))
+#define reiserfs_xattrs(s) ((s)->s_xattr != NULL)
#define reiserfs_xattrs_user(s) (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_XATTRS_USER))
#define reiserfs_posixacl(s) (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_POSIXACL))
#define reiserfs_xattrs_optional(s) (reiserfs_xattrs_user(s) || reiserfs_posixacl(s))
--- a/include/linux/reiserfs_xattr.h 2007-06-11 14:49:36.000000000 -0400
+++ b/include/linux/reiserfs_xattr.h 2007-06-11 14:50:06.000000000 -0400
@@ -29,20 +29,6 @@ struct iattr;
struct super_block;
struct nameidata;
-struct reiserfs_xattr_handler {
- char *prefix;
- int (*init) (void);
- void (*exit) (void);
- int (*get) (struct inode * inode, const char *name, void *buffer,
- size_t size);
- int (*set) (struct inode * inode, const char *name, const void *buffer,
- size_t size, int flags);
- int (*del) (struct inode * inode, const char *name);
- int (*list) (struct inode * inode, const char *name, int namelen,
- char *out);
- struct list_head handlers;
-};
-
#ifdef CONFIG_REISERFS_FS_XATTR
#define is_reiserfs_priv_object(inode) IS_PRIVATE(inode)
#define has_xattr_dir(inode) (REISERFS_I(inode)->i_flags & i_has_xattr_dir)
@@ -57,16 +43,12 @@ int reiserfs_chown_xattrs(struct inode *
int reiserfs_xattr_init(struct super_block *sb, int mount_flags);
int reiserfs_permission(struct inode *inode, int mask, struct nameidata *nd);
-int reiserfs_xattr_del(struct inode *, const char *);
-int reiserfs_xattr_get(const struct inode *, const char *, void *, size_t);
+int reiserfs_xattr_get(struct inode *, const char *, void *, size_t);
int reiserfs_xattr_set(struct inode *, const char *, const void *, size_t, int);
-extern struct reiserfs_xattr_handler user_handler;
-extern struct reiserfs_xattr_handler trusted_handler;
-extern struct reiserfs_xattr_handler security_handler;
-
-int reiserfs_xattr_register_handlers(void) __init;
-void reiserfs_xattr_unregister_handlers(void);
+extern struct xattr_handler reiserfs_xattr_user_handler;
+extern struct xattr_handler reiserfs_xattr_trusted_handler;
+extern struct xattr_handler reiserfs_xattr_security_handler;
static inline void reiserfs_mark_inode_private(struct inode *inode)
@@ -85,9 +67,6 @@ static inline void reiserfs_mark_inode_p
#define reiserfs_permission NULL
-#define reiserfs_xattr_register_handlers() 0
-#define reiserfs_xattr_unregister_handlers()
-
static inline int reiserfs_delete_xattrs(struct inode *inode)
{
return 0;
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 43+ messages in thread
* [patch 18/40] reiserfs: use better open options for internal files
2007-06-11 19:03 [patch 00/40] reiserfs: patch queue (v2) jeffm
` (16 preceding siblings ...)
2007-06-11 19:03 ` [patch 17/40] reiserfs: use generic xattr handlers jeffm
@ 2007-06-11 19:03 ` jeffm
2007-06-11 19:03 ` [patch 19/40] reiserfs: add per-file data=ordered mode and use it for xattrs jeffm
` (22 subsequent siblings)
40 siblings, 0 replies; 43+ messages in thread
From: jeffm @ 2007-06-11 19:03 UTC (permalink / raw)
To: ReiserFS Mailing List
[-- Attachment #1: reiserfs-xattrs-noatime.diff --]
[-- Type: text/plain, Size: 1288 bytes --]
The generic read path will mark the file's atime during the course of the
read. For xattr backing files, this behavior is undesirable, so we open
the xattr files and directories with O_NOATIME. We also add the O_DIRECTORY
flag where the xattr dir is opened for readdir.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
--
fs/reiserfs/xattr.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
--- a/fs/reiserfs/xattr.c 2007-06-11 14:49:37.000000000 -0400
+++ b/fs/reiserfs/xattr.c 2007-06-11 14:50:06.000000000 -0400
@@ -188,7 +188,7 @@ out:
dput(xadir);
if (err)
return ERR_PTR(err);
- return dentry_open(xafile, NULL, O_RDWR);
+ return dentry_open(xafile, NULL, O_RDWR|O_NOATIME);
}
/*
@@ -691,7 +691,7 @@ int reiserfs_delete_xattrs(struct inode
goto out;
}
- fp = dentry_open(dir, NULL, O_RDWR);
+ fp = dentry_open(dir, NULL, O_RDWR|O_NOATIME|O_DIRECTORY);
if (IS_ERR(fp)) {
err = PTR_ERR(fp);
/* dentry_open dputs the dentry if it fails */
@@ -780,7 +780,7 @@ int reiserfs_chown_xattrs(struct inode *
goto out;
}
- fp = dentry_open(dir, NULL, O_RDWR);
+ fp = dentry_open(dir, NULL, O_RDWR|O_NOATIME|O_DIRECTORY);
if (IS_ERR(fp)) {
err = PTR_ERR(fp);
/* dentry_open dputs the dentry if it fails */
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 43+ messages in thread
* [patch 19/40] reiserfs: add per-file data=ordered mode and use it for xattrs
2007-06-11 19:03 [patch 00/40] reiserfs: patch queue (v2) jeffm
` (17 preceding siblings ...)
2007-06-11 19:03 ` [patch 18/40] reiserfs: use better open options for internal files jeffm
@ 2007-06-11 19:03 ` jeffm
2007-06-11 19:03 ` [patch 20/40] reiserfs: journaled xattrs jeffm
` (21 subsequent siblings)
40 siblings, 0 replies; 43+ messages in thread
From: jeffm @ 2007-06-11 19:03 UTC (permalink / raw)
To: ReiserFS Mailing List
[-- Attachment #1: reiserfs-add-per-file-data-ordered-mode.diff --]
[-- Type: text/plain, Size: 3049 bytes --]
This patch allows a per-file data=ordered mode similar to the per-file
data=journal mode implemented now. This functionality isn't yet exported,
but the main use of this code is to allow xattrs to be ordered even if the
the file system is mounted with data=writeback.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
--
fs/reiserfs/file.c | 2 +-
fs/reiserfs/inode.c | 2 +-
fs/reiserfs/xattr.c | 5 +++++
include/linux/reiserfs_fs.h | 8 ++++++++
include/linux/reiserfs_fs_i.h | 3 ++-
5 files changed, 17 insertions(+), 3 deletions(-)
--- a/fs/reiserfs/file.c 2007-06-11 14:49:35.000000000 -0400
+++ b/fs/reiserfs/file.c 2007-06-11 14:50:04.000000000 -0400
@@ -804,7 +804,7 @@ int reiserfs_commit_page(struct inode *i
/* do data=ordered on any page past the end
* of file and any buffer marked BH_New.
*/
- if (reiserfs_data_ordered(inode->i_sb) &&
+ if (reiserfs_file_data_ordered(inode) &&
(new || page->index >= i_size_index)) {
reiserfs_add_ordered_list(inode, bh);
}
--- a/fs/reiserfs/inode.c 2007-06-11 14:49:36.000000000 -0400
+++ b/fs/reiserfs/inode.c 2007-06-11 14:50:06.000000000 -0400
@@ -734,7 +734,7 @@ int reiserfs_get_block(struct inode *ino
}
set_buffer_new(bh_result);
if (buffer_dirty(bh_result)
- && reiserfs_data_ordered(inode->i_sb))
+ && reiserfs_file_data_ordered(inode))
reiserfs_add_ordered_list(inode, bh_result);
put_block_num(item, pos_in_item, allocated_block_nr);
unfm_ptr = allocated_block_nr;
--- a/fs/reiserfs/xattr.c 2007-06-11 14:49:37.000000000 -0400
+++ b/fs/reiserfs/xattr.c 2007-06-11 14:50:06.000000000 -0400
@@ -462,6 +462,11 @@ reiserfs_xattr_set(struct inode *inode,
goto out_filp;
mapping = xinode->i_mapping;
+
+ /* If we're in writeback mode, we still need to order xattr writes */
+ if (reiserfs_data_writeback(xinode->i_sb))
+ REISERFS_I(xinode)->i_flags |= i_data_ordered;
+
while (buffer_pos < buffer_size || buffer_pos == 0) {
size_t chunk;
size_t skip = 0;
--- a/include/linux/reiserfs_fs.h 2007-06-11 14:49:36.000000000 -0400
+++ b/include/linux/reiserfs_fs.h 2007-06-11 14:50:06.000000000 -0400
@@ -1699,6 +1699,14 @@ static inline int reiserfs_file_data_log
return 0;
}
+static inline int reiserfs_file_data_ordered(struct inode *inode)
+{
+ if (reiserfs_data_ordered(inode->i_sb) ||
+ (REISERFS_I(inode)->i_flags & i_data_ordered))
+ return 1;
+ return 0;
+}
+
static inline int reiserfs_transaction_running(struct super_block *s)
{
struct reiserfs_transaction_handle *th = current->journal_info;
--- a/include/linux/reiserfs_fs_i.h 2007-06-11 14:49:36.000000000 -0400
+++ b/include/linux/reiserfs_fs_i.h 2007-06-11 14:49:38.000000000 -0400
@@ -25,7 +25,8 @@ typedef enum {
i_link_saved_truncate_mask = 0x0020,
i_has_xattr_dir = 0x0040,
i_data_log = 0x0080,
- i_ever_mapped = 0x0100
+ i_ever_mapped = 0x0100,
+ i_data_ordered = 0x0200,
} reiserfs_inode_flags;
struct reiserfs_inode_info {
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 43+ messages in thread
* [patch 20/40] reiserfs: journaled xattrs
2007-06-11 19:03 [patch 00/40] reiserfs: patch queue (v2) jeffm
` (18 preceding siblings ...)
2007-06-11 19:03 ` [patch 19/40] reiserfs: add per-file data=ordered mode and use it for xattrs jeffm
@ 2007-06-11 19:03 ` jeffm
2007-06-11 19:03 ` [patch 21/40] reiserfs: use generic readdir for operations across all xattrs jeffm
` (20 subsequent siblings)
40 siblings, 0 replies; 43+ messages in thread
From: jeffm @ 2007-06-11 19:03 UTC (permalink / raw)
To: ReiserFS Mailing List
[-- Attachment #1: reiserfs-journaled-xattrs.diff --]
[-- Type: text/plain, Size: 15845 bytes --]
Deadlocks are possible in the xattr code between the journal lock and the
xattr sems.
This patch implements journalling for xattr operations. The benefit is
twofold:
* It gets rid of the deadlock possibility by always ensuring that xattr
write operations are initiated inside a transaction.
* It corrects the problem where xattr backing files aren't considered any
differently than normal files, despite the fact they are metadata.
I discussed the added journal load with Chris Mason, and we decided that
since xattrs (versus other journal activity) is fairly rare, the introduction
of larger transactions to support journaled xattrs wouldn't be too big a deal.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
--
fs/reiserfs/inode.c | 3 -
fs/reiserfs/namei.c | 14 +----
fs/reiserfs/xattr.c | 52 +++++++++++++++++++-
fs/reiserfs/xattr_acl.c | 104 +++++++++++++++++++++++++++++++----------
include/linux/reiserfs_acl.h | 3 -
include/linux/reiserfs_fs.h | 4 +
include/linux/reiserfs_xattr.h | 28 +++++++++++
7 files changed, 168 insertions(+), 40 deletions(-)
--- a/fs/reiserfs/inode.c 2007-06-11 14:49:38.000000000 -0400
+++ b/fs/reiserfs/inode.c 2007-06-11 14:50:05.000000000 -0400
@@ -1920,9 +1920,8 @@ int reiserfs_new_inode(struct reiserfs_t
goto out_inserted_sd;
}
- /* XXX CHECK THIS */
if (reiserfs_posixacl(inode->i_sb)) {
- retval = reiserfs_inherit_default_acl(dir, dentry, inode);
+ retval = reiserfs_inherit_default_acl(th, dir, dentry, inode);
if (retval) {
err = retval;
reiserfs_check_path(&path_to_key);
--- a/fs/reiserfs/namei.c 2007-06-11 14:49:36.000000000 -0400
+++ b/fs/reiserfs/namei.c 2007-06-11 14:50:05.000000000 -0400
@@ -606,15 +606,13 @@ static int reiserfs_create(struct inode
2 * (REISERFS_QUOTA_INIT_BLOCKS(dir->i_sb) +
REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb));
struct reiserfs_transaction_handle th;
- int locked;
if (!(inode = new_inode(dir->i_sb))) {
return -ENOMEM;
}
new_inode_init(inode, dir, mode);
- locked = reiserfs_cache_default_acl(dir);
-
+ jbegin_count += reiserfs_cache_default_acl(dir);
reiserfs_write_lock(dir->i_sb);
retval = journal_begin(&th, dir->i_sb, jbegin_count);
@@ -668,7 +666,6 @@ static int reiserfs_mknod(struct inode *
JOURNAL_PER_BALANCE_CNT * 3 +
2 * (REISERFS_QUOTA_INIT_BLOCKS(dir->i_sb) +
REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb));
- int locked;
if (!new_valid_dev(rdev))
return -EINVAL;
@@ -678,8 +675,7 @@ static int reiserfs_mknod(struct inode *
}
new_inode_init(inode, dir, mode);
- locked = reiserfs_cache_default_acl(dir);
-
+ jbegin_count += reiserfs_cache_default_acl(dir);
reiserfs_write_lock(dir->i_sb);
retval = journal_begin(&th, dir->i_sb, jbegin_count);
@@ -736,7 +732,6 @@ static int reiserfs_mkdir(struct inode *
JOURNAL_PER_BALANCE_CNT * 3 +
2 * (REISERFS_QUOTA_INIT_BLOCKS(dir->i_sb) +
REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb));
- int locked;
#ifdef DISPLACE_NEW_PACKING_LOCALITIES
/* set flag that new packing locality created and new blocks for the content * of that directory are not displaced yet */
@@ -748,8 +743,7 @@ static int reiserfs_mkdir(struct inode *
}
new_inode_init(inode, dir, mode);
- locked = reiserfs_cache_default_acl(dir);
-
+ jbegin_count += reiserfs_cache_default_acl(dir);
reiserfs_write_lock(dir->i_sb);
retval = journal_begin(&th, dir->i_sb, jbegin_count);
@@ -1036,8 +1030,6 @@ static int reiserfs_symlink(struct inode
memcpy(name, symname, strlen(symname));
padd_item(name, item_len, strlen(symname));
- /* We would inherit the default ACL here, but symlinks don't get ACLs */
-
retval = journal_begin(&th, parent_dir->i_sb, jbegin_count);
if (retval) {
drop_new_inode(inode);
--- a/fs/reiserfs/xattr.c 2007-06-11 14:49:38.000000000 -0400
+++ b/fs/reiserfs/xattr.c 2007-06-11 14:50:05.000000000 -0400
@@ -405,8 +405,9 @@ static inline __u32 xattr_hash(const cha
* inode->i_mutex: down
*/
int
-reiserfs_xattr_set(struct inode *inode, const char *name, const void *buffer,
- size_t buffer_size, int flags)
+reiserfs_xattr_set_handle(struct reiserfs_transaction_handle *th,
+ struct inode *inode, const char *name,
+ const void *buffer, size_t buffer_size, int flags)
{
int err = 0;
struct file *fp;
@@ -532,6 +533,36 @@ reiserfs_xattr_set(struct inode *inode,
return err;
}
+/* We need to start a transaction to maintain lock ordering */
+int reiserfs_xattr_set(struct inode *inode, const char *name,
+ const void *buffer, size_t buffer_size, int flags)
+{
+
+ struct reiserfs_transaction_handle th;
+ int error, error2;
+ size_t jbegin_count = reiserfs_xattr_nblocks(inode, buffer_size);
+
+ if (!(flags & XATTR_REPLACE))
+ jbegin_count += reiserfs_xattr_jcreate_nblocks(inode);
+
+ reiserfs_write_lock(inode->i_sb);
+ error = journal_begin(&th, inode->i_sb, jbegin_count);
+ if (error) {
+ reiserfs_write_unlock(inode->i_sb);
+ return error;
+ }
+
+ error = reiserfs_xattr_set_handle(&th, inode, name,
+ buffer, buffer_size, flags);
+
+ error2 = journal_end(&th, inode->i_sb, jbegin_count);
+ if (error == 0)
+ error = error2;
+ reiserfs_write_unlock(inode->i_sb);
+
+ return error;
+}
+
/*
* inode->i_mutex: down
*/
@@ -713,11 +744,28 @@ int reiserfs_delete_xattrs(struct inode
/* Leftovers besides . and .. -- that's not good. */
if (dir->d_inode->i_nlink <= 2) {
+ struct reiserfs_transaction_handle th;
+ int jbegin_count;
+ int jerr;
+
+ jbegin_count = JOURNAL_PER_BALANCE_CNT * 2 + 2 + 4 *
+ REISERFS_QUOTA_TRANS_BLOCKS(inode->i_sb);
+ reiserfs_write_lock(inode->i_sb);
+ err = journal_begin (&th, inode->i_sb, jbegin_count);
+ if (err) {
+ reiserfs_write_unlock(inode->i_sb);
+ unlock_kernel();
+ goto out_dir;
+ }
root = open_xa_root(inode->i_sb, XATTR_REPLACE);
mutex_lock_nested(&root->d_inode->i_mutex, I_MUTEX_XATTR);
err = vfs_rmdir(root->d_inode, dir);
mutex_unlock(&root->d_inode->i_mutex);
+ jerr = journal_end (&th, inode->i_sb, jbegin_count);
+ reiserfs_write_unlock(inode->i_sb);
dput(root);
+ if (!err && jerr)
+ err = jerr;
} else {
reiserfs_warning(inode->i_sb, "jdm-20004",
"Couldn't remove all entries in directory");
--- a/fs/reiserfs/xattr_acl.c 2007-06-11 14:49:37.000000000 -0400
+++ b/fs/reiserfs/xattr_acl.c 2007-06-11 14:49:38.000000000 -0400
@@ -10,15 +10,17 @@
#include <linux/reiserfs_acl.h>
#include <asm/uaccess.h>
-static int reiserfs_set_acl(struct inode *inode, int type,
+static int reiserfs_set_acl(struct reiserfs_transaction_handle *th,
+ struct inode *inode, int type,
struct posix_acl *acl);
static int
xattr_set_acl(struct inode *inode, int type, const void *value, size_t size)
{
struct posix_acl *acl;
- int error;
-
+ int error, error2;
+ struct reiserfs_transaction_handle th;
+ size_t jcreate_blocks;
if (!reiserfs_posixacl(inode->i_sb))
return -EOPNOTSUPP;
if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
@@ -36,7 +38,21 @@ xattr_set_acl(struct inode *inode, int t
} else
acl = NULL;
- error = reiserfs_set_acl(inode, type, acl);
+ /* Pessimism: We can't assume that anything from the xattr root up
+ * has been created. */
+
+ jcreate_blocks = reiserfs_xattr_jcreate_nblocks(inode) +
+ reiserfs_xattr_nblocks(inode, size) * 2;
+
+ reiserfs_write_lock(inode->i_sb);
+ error = journal_begin(&th, inode->i_sb, jcreate_blocks);
+ if (error == 0) {
+ error = reiserfs_set_acl(&th, inode, type, acl);
+ error2 = journal_end(&th, inode->i_sb, jcreate_blocks);
+ if (error2)
+ error = error2;
+ }
+ reiserfs_write_unlock(inode->i_sb);
release_and_out:
posix_acl_release(acl);
@@ -266,7 +282,8 @@ struct posix_acl *reiserfs_get_acl(struc
* BKL held [before 2.5.x]
*/
static int
-reiserfs_set_acl(struct inode *inode, int type, struct posix_acl *acl)
+reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode,
+ int type, struct posix_acl *acl)
{
char *name;
void *value = NULL;
@@ -313,7 +330,7 @@ reiserfs_set_acl(struct inode *inode, in
return (int)PTR_ERR(value);
}
- error = reiserfs_xattr_set(inode, name, value, size, 0);
+ error = reiserfs_xattr_set_handle(th, inode, name, value, size, 0);
kfree(value);
@@ -326,7 +343,8 @@ reiserfs_set_acl(struct inode *inode, in
/* dir->i_mutex: locked,
* inode is new and not released into the wild yet */
int
-reiserfs_inherit_default_acl(struct inode *dir, struct dentry *dentry,
+reiserfs_inherit_default_acl(struct reiserfs_transaction_handle *th,
+ struct inode *dir, struct dentry *dentry,
struct inode *inode)
{
struct posix_acl *acl;
@@ -363,7 +381,8 @@ reiserfs_inherit_default_acl(struct inod
/* Copy the default ACL to the default ACL of a new directory */
if (S_ISDIR(inode->i_mode)) {
- err = reiserfs_set_acl(inode, ACL_TYPE_DEFAULT, acl);
+ err = reiserfs_set_acl(th, inode, ACL_TYPE_DEFAULT,
+ acl);
if (err)
goto cleanup;
}
@@ -384,9 +403,9 @@ reiserfs_inherit_default_acl(struct inod
/* If we need an ACL.. */
if (need_acl > 0) {
- err =
- reiserfs_set_acl(inode, ACL_TYPE_ACCESS,
- acl_copy);
+ err = reiserfs_set_acl(th, inode,
+ ACL_TYPE_ACCESS,
+ acl_copy);
if (err)
goto cleanup_copy;
}
@@ -404,21 +423,45 @@ reiserfs_inherit_default_acl(struct inod
return err;
}
-/* Looks up and caches the result of the default ACL.
- * We do this so that we don't need to carry the xattr_sem into
- * reiserfs_new_inode if we don't need to */
+/* This is used to cache the default acl before a new object is created.
+ * The biggest reason for this is to get an idea of how many blocks will
+ * actually be required for the create operation if we must inherit an ACL.
+ * An ACL write can add up to 3 object creations and an additional file write
+ * so we'd prefer not to reserve that many blocks in the journal if we can.
+ * It also has the advantage of not loading the ACL with a transaction open,
+ * this may seem silly, but if the owner of the directory is doing the
+ * creation, the ACL may not be loaded since the permissions wouldn't require
+ * it.
+ * We return the number of blocks required for the transaction.
+ */
int reiserfs_cache_default_acl(struct inode *inode)
{
- int ret = 0;
- if (reiserfs_posixacl(inode->i_sb) && !is_reiserfs_priv_object(inode)) {
- struct posix_acl *acl;
- acl = reiserfs_get_acl(inode, ACL_TYPE_DEFAULT);
- ret = (acl && !IS_ERR(acl));
- if (ret)
- posix_acl_release(acl);
+ struct posix_acl *acl;
+ int nblocks = 0;
+
+ if (is_reiserfs_priv_object(inode))
+ return 0;
+
+ acl = reiserfs_get_acl(inode, ACL_TYPE_DEFAULT);
+
+ if (acl && !IS_ERR(acl)) {
+ int size = reiserfs_acl_size(acl->a_count);
+
+ /* Other xattrs can be created during inode creation. We don't
+ * want to claim too many blocks, so we check to see if we
+ * we need to create the tree to the xattrs, and then we
+ * just want two files. */
+ nblocks = reiserfs_xattr_jcreate_nblocks(inode);
+ nblocks += JOURNAL_BLOCKS_PER_OBJECT(inode->i_sb);
+
+ REISERFS_I(inode)->i_flags |= i_has_xattr_dir;
+
+ /* We need to account for writes + bitmaps for two files */
+ nblocks += reiserfs_xattr_nblocks(inode, size) * 4;
+ posix_acl_release(acl);
}
- return ret;
+ return nblocks;
}
int reiserfs_acl_chmod(struct inode *inode)
@@ -444,8 +487,21 @@ int reiserfs_acl_chmod(struct inode *ino
if (!clone)
return -ENOMEM;
error = posix_acl_chmod_masq(clone, inode->i_mode);
- if (!error)
- error = reiserfs_set_acl(inode, ACL_TYPE_ACCESS, clone);
+ if (!error) {
+ struct reiserfs_transaction_handle th;
+ size_t size = reiserfs_xattr_nblocks(inode,
+ reiserfs_acl_size(clone->a_count));
+ reiserfs_write_lock(inode->i_sb);
+ error = journal_begin (&th, inode->i_sb, size * 2);
+ if (!error) {
+ int error2;
+ error = reiserfs_set_acl(&th, inode, ACL_TYPE_ACCESS, clone);
+ error2 = journal_end(&th, inode->i_sb, size * 2);
+ if (error2)
+ error = error2;
+ }
+ reiserfs_write_unlock(inode->i_sb);
+ }
posix_acl_release(clone);
return error;
}
--- a/include/linux/reiserfs_acl.h 2007-06-11 14:49:37.000000000 -0400
+++ b/include/linux/reiserfs_acl.h 2007-06-11 14:49:38.000000000 -0400
@@ -49,7 +49,8 @@ static inline int reiserfs_acl_count(siz
#ifdef CONFIG_REISERFS_FS_POSIX_ACL
struct posix_acl *reiserfs_get_acl(struct inode *inode, int type);
int reiserfs_acl_chmod(struct inode *inode);
-int reiserfs_inherit_default_acl(struct inode *dir, struct dentry *dentry,
+int reiserfs_inherit_default_acl(struct reiserfs_transaction_handle *th,
+ struct inode *dir, struct dentry *dentry,
struct inode *inode);
int reiserfs_cache_default_acl(struct inode *dir);
extern struct xattr_handler reiserfs_posix_acl_default_handler;
--- a/include/linux/reiserfs_fs.h 2007-06-11 14:49:38.000000000 -0400
+++ b/include/linux/reiserfs_fs.h 2007-06-11 14:50:05.000000000 -0400
@@ -1595,6 +1595,10 @@ struct reiserfs_journal_header {
#define JOURNAL_MAX_COMMIT_AGE 30
#define JOURNAL_MAX_TRANS_AGE 30
#define JOURNAL_PER_BALANCE_CNT (3 * (MAX_HEIGHT-2) + 9)
+#define JOURNAL_BLOCKS_PER_OBJECT(sb) (JOURNAL_PER_BALANCE_CNT * 3 + \
+ 2 * (REISERFS_QUOTA_INIT_BLOCKS(sb) + \
+ REISERFS_QUOTA_TRANS_BLOCKS(sb)))
+
#ifdef CONFIG_QUOTA
/* We need to update data and inode (atime) */
#define REISERFS_QUOTA_TRANS_BLOCKS(s) (REISERFS_SB(s)->s_mount_opt & (1<<REISERFS_QUOTA) ? 2 : 0)
--- a/include/linux/reiserfs_xattr.h 2007-06-11 14:49:37.000000000 -0400
+++ b/include/linux/reiserfs_xattr.h 2007-06-11 14:50:05.000000000 -0400
@@ -45,6 +45,7 @@ int reiserfs_permission(struct inode *in
int reiserfs_xattr_get(struct inode *, const char *, void *, size_t);
int reiserfs_xattr_set(struct inode *, const char *, const void *, size_t, int);
+int reiserfs_xattr_set_handle(struct reiserfs_transaction_handle *,struct inode *, const char *, const void *, size_t, int);
extern struct xattr_handler reiserfs_xattr_user_handler;
extern struct xattr_handler reiserfs_xattr_trusted_handler;
@@ -56,6 +57,33 @@ static inline void reiserfs_mark_inode_p
inode->i_flags |= S_PRIVATE;
}
+#define xattr_size(size) ((size) + sizeof (struct reiserfs_xattr_header))
+#define reiserfs_xattr_nblocks(inode, size) (reiserfs_file_data_log(inode) && _ROUND_UP(xattr_size(size), (inode)->i_sb->s_blocksize) >> (inode)->i_sb->s_blocksize_bits)
+
+/* We may have to create up to 3 objects: xattr root, xattr dir, xattr file.
+ * Let's try to be smart about it.
+ * xattr root: We cache it. If it's not cached, we may need to create it.
+ * xattr dir: If anything has been loaded for this inode, we can set a flag
+ * saying so.
+ * xattr file: Since we don't cache xattrs, we can't tell. We always include
+ * blocks for it.
+ *
+ * However, since root and dir can be created between calls - YOU MUST SAVE
+ * THIS VALUE.
+ */
+static inline size_t reiserfs_xattr_jcreate_nblocks(struct inode *inode)
+{
+ size_t nblocks = JOURNAL_BLOCKS_PER_OBJECT(inode->i_sb);
+
+ if ((REISERFS_I(inode)->i_flags & i_has_xattr_dir) == 0) {
+ nblocks += JOURNAL_BLOCKS_PER_OBJECT(inode->i_sb);
+ if (REISERFS_SB(inode->i_sb)->xattr_root == NULL)
+ nblocks += JOURNAL_BLOCKS_PER_OBJECT(inode->i_sb);
+ }
+
+ return nblocks;
+}
+
#else
#define is_reiserfs_priv_object(inode) 0
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 43+ messages in thread
* [patch 21/40] reiserfs: use generic readdir for operations across all xattrs
2007-06-11 19:03 [patch 00/40] reiserfs: patch queue (v2) jeffm
` (19 preceding siblings ...)
2007-06-11 19:03 ` [patch 20/40] reiserfs: journaled xattrs jeffm
@ 2007-06-11 19:03 ` jeffm
2007-06-11 19:03 ` [patch 22/40] reiserfs: add atomic addition of selinux attributes during inode creation jeffm
` (19 subsequent siblings)
40 siblings, 0 replies; 43+ messages in thread
From: jeffm @ 2007-06-11 19:03 UTC (permalink / raw)
To: ReiserFS Mailing List
[-- Attachment #1: reiserfs-kill-xattr-readdir.diff --]
[-- Type: text/plain, Size: 14989 bytes --]
The current reiserfs xattr implementation open codes reiserfs_readdir and
frees the path before calling the filldir function. Typically, the filldir
function is something that modifies the file system, such as a chown or
an inode deletion that also require reading of an inode associated with each
direntry. Since the file system is modified, the path retained becomes
invalid for the next run. In addition, it runs backwards in attempt to
minimize activity.
This is clearly suboptimal from a code cleanliness perspective as well as
performance-wise.
This patch implements a generic reiserfs_for_each_xattr that uses the generic
readdir and a specific filldir routine that simply populates an array of
dentries and then performs a specific operation on them. When all files have
been operated on, it then calls the operation on the directory itself.
The result is a noticable code reduction and better performance.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
--
fs/reiserfs/xattr.c | 439 +++++++++++++++-------------------------------------
1 file changed, 129 insertions(+), 310 deletions(-)
--- a/fs/reiserfs/xattr.c 2007-06-11 14:49:38.000000000 -0400
+++ b/fs/reiserfs/xattr.c 2007-06-11 14:49:38.000000000 -0400
@@ -191,182 +191,6 @@ out:
return dentry_open(xafile, NULL, O_RDWR|O_NOATIME);
}
-/*
- * this is very similar to fs/reiserfs/dir.c:reiserfs_readdir, but
- * we need to drop the path before calling the filldir struct. That
- * would be a big performance hit to the non-xattr case, so I've copied
- * the whole thing for now. --clm
- *
- * the big difference is that I go backwards through the directory,
- * and don't mess with f->f_pos, but the idea is the same. Do some
- * action on each and every entry in the directory.
- *
- * we're called with i_mutex held, so there are no worries about the directory
- * changing underneath us.
- */
-static int __xattr_readdir(struct file *filp, void *dirent, filldir_t filldir)
-{
- struct inode *inode = filp->f_path.dentry->d_inode;
- struct cpu_key pos_key; /* key of current position in the directory (key of directory entry) */
- INITIALIZE_PATH(path_to_entry);
- struct buffer_head *bh;
- int entry_num;
- struct item_head *ih, tmp_ih;
- int search_res;
- char *local_buf;
- loff_t next_pos;
- char small_buf[32]; /* avoid kmalloc if we can */
- struct reiserfs_de_head *deh;
- int d_reclen;
- char *d_name;
- off_t d_off;
- ino_t d_ino;
- struct reiserfs_dir_entry de;
-
- /* form key for search the next directory entry using f_pos field of
- file structure */
- next_pos = max_reiserfs_offset(inode);
-
- while (1) {
- research:
- if (next_pos <= DOT_DOT_OFFSET)
- break;
- make_cpu_key(&pos_key, inode, next_pos, TYPE_DIRENTRY, 3);
-
- search_res =
- search_by_entry_key(inode->i_sb, &pos_key, &path_to_entry,
- &de);
- if (search_res == IO_ERROR) {
- // FIXME: we could just skip part of directory which could
- // not be read
- pathrelse(&path_to_entry);
- return -EIO;
- }
-
- if (search_res == NAME_NOT_FOUND)
- de.de_entry_num--;
-
- set_de_name_and_namelen(&de);
- entry_num = de.de_entry_num;
- deh = &(de.de_deh[entry_num]);
-
- bh = de.de_bh;
- ih = de.de_ih;
-
- if (!is_direntry_le_ih(ih)) {
- reiserfs_error(inode->i_sb, "jdm-20000",
- "not direntry %h", ih);
- break;
- }
- copy_item_head(&tmp_ih, ih);
-
- /* we must have found item, that is item of this directory, */
- RFALSE(COMP_SHORT_KEYS(&(ih->ih_key), &pos_key),
- "vs-9000: found item %h does not match to dir we readdir %K",
- ih, &pos_key);
-
- if (deh_offset(deh) <= DOT_DOT_OFFSET) {
- break;
- }
-
- /* look for the previous entry in the directory */
- next_pos = deh_offset(deh) - 1;
-
- if (!de_visible(deh))
- /* it is hidden entry */
- continue;
-
- d_reclen = entry_length(bh, ih, entry_num);
- d_name = B_I_DEH_ENTRY_FILE_NAME(bh, ih, deh);
- d_off = deh_offset(deh);
- d_ino = deh_objectid(deh);
-
- if (!d_name[d_reclen - 1])
- d_reclen = strlen(d_name);
-
- if (d_reclen > REISERFS_MAX_NAME(inode->i_sb->s_blocksize)) {
- /* too big to send back to VFS */
- continue;
- }
-
- /* Ignore the .reiserfs_priv entry */
- if (reiserfs_xattrs(inode->i_sb) &&
- !old_format_only(inode->i_sb) &&
- deh_objectid(deh) ==
- le32_to_cpu(INODE_PKEY
- (REISERFS_SB(inode->i_sb)->priv_root->d_inode)->
- k_objectid))
- continue;
-
- if (d_reclen <= 32) {
- local_buf = small_buf;
- } else {
- local_buf = kmalloc(d_reclen, GFP_NOFS);
- if (!local_buf) {
- pathrelse(&path_to_entry);
- return -ENOMEM;
- }
- if (item_moved(&tmp_ih, &path_to_entry)) {
- kfree(local_buf);
-
- /* sigh, must retry. Do this same offset again */
- next_pos = d_off;
- goto research;
- }
- }
-
- // Note, that we copy name to user space via temporary
- // buffer (local_buf) because filldir will block if
- // user space buffer is swapped out. At that time
- // entry can move to somewhere else
- memcpy(local_buf, d_name, d_reclen);
-
- /* the filldir function might need to start transactions,
- * or do who knows what. Release the path now that we've
- * copied all the important stuff out of the deh
- */
- pathrelse(&path_to_entry);
-
- if (filldir(dirent, local_buf, d_reclen, d_off, d_ino,
- DT_UNKNOWN) < 0) {
- if (local_buf != small_buf) {
- kfree(local_buf);
- }
- goto end;
- }
- if (local_buf != small_buf) {
- kfree(local_buf);
- }
- } /* while */
-
- end:
- pathrelse(&path_to_entry);
- return 0;
-}
-
-/*
- * this could be done with dedicated readdir ops for the xattr files,
- * but I want to get something working asap
- * this is stolen from vfs_readdir
- *
- */
-static
-int xattr_readdir(struct file *file, filldir_t filler, void *buf)
-{
- struct inode *inode = file->f_path.dentry->d_inode;
- int res = -ENOTDIR;
- if (!file->f_op || !file->f_op->readdir)
- goto out;
- res = -ENOENT;
- if (!IS_DEADDIR(inode)) {
- lock_kernel();
- res = __xattr_readdir(file, buf, filler);
- unlock_kernel();
- }
- out:
- return res;
-}
-
/* Internal operations on file data */
static inline void reiserfs_put_page(struct page *page)
{
@@ -670,152 +494,83 @@ reiserfs_xattr_get(struct inode *inode,
return err;
}
-/* The following are side effects of other operations that aren't explicitly
- * modifying extended attributes. This includes operations such as permissions
- * or ownership changes, object deletions, etc. */
-
-static int
-reiserfs_delete_xattrs_filler(void *buf, const char *name, int namelen,
- loff_t offset, u64 ino, unsigned int d_type)
+#if 0
+static int __restart_transaction_if_needed(struct inode *inode, int chunk)
{
- struct dentry *xadir = (struct dentry *)buf;
- struct dentry *dentry;
- int err = 0;
+ struct reiserfs_transaction_handle *th = current->journal_info;
+ struct super_block *s = th->t_super;
+ int len = th->t_blocks_allocated;
+ int err;
- dentry = lookup_one_len(name, xadir, namelen);
- if (IS_ERR(dentry)) {
- err = PTR_ERR(dentry);
- goto out;
- } else if (!dentry->d_inode) {
- err = -ENODATA;
- goto out_file;
- }
+ BUG_ON(!th->t_trans_id);
+ BUG_ON(!th->t_refcount);
- /* Skip directories.. */
- if (S_ISDIR(dentry->d_inode->i_mode))
- goto out_file;
-
- err = vfs_unlink(xadir->d_inode, dentry);
-
- out_file:
- dput(dentry);
-
- out:
- return err;
-}
-
-/* This is called w/ inode->i_mutex downed */
-int reiserfs_delete_xattrs(struct inode *inode)
-{
- struct file *fp;
- struct dentry *dir, *root;
- int err = 0;
-
- /* Skip out, an xattr has no xattrs associated with it */
- if (is_reiserfs_priv_object(inode) ||
- get_inode_sd_version(inode) == STAT_DATA_V1 ||
- !reiserfs_xattrs(inode->i_sb)) {
+ if (!journal_transaction_should_end(th, len))
return 0;
- }
- dir = open_xa_dir(inode, XATTR_REPLACE);
- if (IS_ERR(dir)) {
- err = PTR_ERR(dir);
- goto out;
- } else if (!dir->d_inode) {
- dput(dir);
- err = 0;
- goto out;
- }
- fp = dentry_open(dir, NULL, O_RDWR|O_NOATIME|O_DIRECTORY);
- if (IS_ERR(fp)) {
- err = PTR_ERR(fp);
- /* dentry_open dputs the dentry if it fails */
- goto out;
+ /* we cannot restart while nested */
+ if (th->t_refcount > 1) {
+ reiserfs_warning(th->t_super, "jdm-20003", "can't restart nested transaction in %s\n", __FUNCTION__);
+ return 0;
}
- mutex_lock_nested(&fp->f_path.dentry->d_inode->i_mutex, I_MUTEX_XATTR);
- lock_kernel();
- err = xattr_readdir(fp, reiserfs_delete_xattrs_filler, dir);
- unlock_kernel();
- mutex_unlock(&fp->f_path.dentry->d_inode->i_mutex);
- if (err)
- goto out_dir;
-
- /* Leftovers besides . and .. -- that's not good. */
- if (dir->d_inode->i_nlink <= 2) {
- struct reiserfs_transaction_handle th;
- int jbegin_count;
- int jerr;
-
- jbegin_count = JOURNAL_PER_BALANCE_CNT * 2 + 2 + 4 *
- REISERFS_QUOTA_TRANS_BLOCKS(inode->i_sb);
- reiserfs_write_lock(inode->i_sb);
- err = journal_begin (&th, inode->i_sb, jbegin_count);
- if (err) {
- reiserfs_write_unlock(inode->i_sb);
- unlock_kernel();
- goto out_dir;
- }
- root = open_xa_root(inode->i_sb, XATTR_REPLACE);
- mutex_lock_nested(&root->d_inode->i_mutex, I_MUTEX_XATTR);
- err = vfs_rmdir(root->d_inode, dir);
- mutex_unlock(&root->d_inode->i_mutex);
- jerr = journal_end (&th, inode->i_sb, jbegin_count);
- reiserfs_write_unlock(inode->i_sb);
- dput(root);
- if (!err && jerr)
- err = jerr;
- } else {
- reiserfs_warning(inode->i_sb, "jdm-20004",
- "Couldn't remove all entries in directory");
+ err = journal_end(th, s, len);
+ if (!err) {
+ err = journal_begin(th, s, chunk);
+ if (!err)
+ reiserfs_update_inode_transaction(inode);
}
- out_dir:
- fput(fp);
-
- out:
return err;
}
+#endif
-struct reiserfs_chown_buf {
- struct inode *inode;
+/* The following are side effects of other operations that aren't explicitly
+ * modifying extended attributes. This includes operations such as permissions
+ * or ownership changes, object deletions, etc. */
+struct reiserfs_dentry_buf {
struct dentry *xadir;
- struct iattr *attrs;
+ int count;
+ struct dentry *dentries[8];
};
-/* XXX: If there is a better way to do this, I'd love to hear about it */
static int
-reiserfs_chown_xattrs_filler(void *buf, const char *name, int namelen,
- loff_t offset, u64 ino, unsigned int d_type)
+fill_with_dentries(void *buf, const char *name, int namelen, loff_t offset,
+ u64 ino, unsigned int d_type)
{
- struct reiserfs_chown_buf *chown_buf = (struct reiserfs_chown_buf *)buf;
- struct dentry *xafile, *xadir = chown_buf->xadir;
- struct iattr *attrs = chown_buf->attrs;
- int err = 0;
+ struct reiserfs_dentry_buf *dbuf = buf;
+ struct dentry *dentry;
+
+ if (dbuf->count == ARRAY_SIZE(dbuf->dentries))
+ return -ENOSPC;
+
+ if (name[0] == '.' && (name[1] == '\0' || (name[1] == '.' && name[2] == '\0')))
+ return 0;
- xafile = lookup_one_len(name, xadir, namelen);
- if (IS_ERR(xafile))
- return PTR_ERR(xafile);
- else if (!xafile->d_inode) {
- dput(xafile);
+ dentry = lookup_one_len(name, dbuf->xadir, namelen);
+ if (IS_ERR(dentry)) {
+ return PTR_ERR(dentry);
+ } else if (!dentry->d_inode) {
+ /* This should never happen */
+ dput(dentry);
return -ENODATA;
}
- if (!S_ISDIR(xafile->d_inode->i_mode))
- err = notify_change(xafile, attrs);
- dput(xafile);
-
- return err;
+ dbuf->dentries[dbuf->count++] = dentry;
+ return 0;
}
-int reiserfs_chown_xattrs(struct inode *inode, struct iattr *attrs)
+typedef int(*xattr_action)(struct dentry *dentry, void *data);
+
+static int reiserfs_for_each_xattr(struct inode *inode, xattr_action action,
+ void *data)
{
struct file *fp;
struct dentry *dir;
int err = 0;
- struct reiserfs_chown_buf buf;
- unsigned int ia_valid = attrs->ia_valid;
+ struct reiserfs_dentry_buf buf = {
+ .count = 0,
+ };
/* Skip out, an xattr has no xattrs associated with it */
if (is_reiserfs_priv_object(inode) ||
@@ -841,31 +596,95 @@ int reiserfs_chown_xattrs(struct inode *
}
mutex_lock_nested(&fp->f_path.dentry->d_inode->i_mutex, I_MUTEX_XATTR);
- lock_kernel();
-
- attrs->ia_valid &= (ATTR_UID | ATTR_GID | ATTR_CTIME);
buf.xadir = dir;
- buf.attrs = attrs;
- buf.inode = inode;
- err = xattr_readdir(fp, reiserfs_chown_xattrs_filler, &buf);
- if (err) {
- unlock_kernel();
- goto out_dir;
- }
+ err = fp->f_op->readdir(fp, &buf, fill_with_dentries);
+ while ((err == 0 || err == -ENOSPC) && buf.count) {
+ int i;
+ err = 0;
- err = notify_change(dir, attrs);
- unlock_kernel();
+ for (i = 0; i < buf.count && buf.dentries[i]; i++) {
+ int lerr = 0;
+ struct dentry *dentry = buf.dentries[i];
+
+ if (err == 0 && !S_ISDIR(dentry->d_inode->i_mode))
+ lerr = action(dentry, data);
+
+ dput(dentry);
+ buf.dentries[i] = NULL;
+
+ if (lerr)
+ err = lerr;
+ }
+ buf.count = 0;
+ if (err == 0)
+ err = fp->f_op->readdir(fp, &buf, fill_with_dentries);
+ }
- out_dir:
mutex_unlock(&fp->f_path.dentry->d_inode->i_mutex);
+
+ if (err == 0)
+ err = action(dir, data);
+
fput(fp);
out:
- attrs->ia_valid = ia_valid;
return err;
}
+static int delete_one_xattr(struct dentry *dentry, void *data)
+{
+ struct inode *dir = dentry->d_parent->d_inode;
+
+ /* This is the xattr dir, handle specially. */
+ if (S_ISDIR(dentry->d_inode->i_mode)) {
+ int err;
+ struct reiserfs_transaction_handle th;
+ int nblocks = JOURNAL_PER_BALANCE_CNT * 2 + 2 +
+ 4 * REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb);
+
+ BUG_ON(dentry == dentry->d_parent);
+ if (dir == dentry->d_inode) {
+ printk ("dir = %s\n", dentry->d_parent->d_name.name);
+ printk ("dentry = %s\n", dentry->d_name.name);
+ return -EBUSY;
+ }
+
+ /* reiserfs_rmdir is going to start a transaction itself,
+ * but we need to start it outside of locking the xattr
+ * root to preserve lock ordering. */
+ err = journal_begin(&th, dir->i_sb, nblocks);
+ if (err == 0) {
+ int err2;
+ mutex_lock_nested(&dir->i_mutex, I_MUTEX_XATTR);
+ err = vfs_rmdir(dir, dentry);
+ err2 = journal_end(&th, dir->i_sb, nblocks);
+ mutex_unlock(&dir->i_mutex);
+ if (err2)
+ err = err2;
+ }
+ return err;
+ }
+
+ return vfs_unlink(dir, dentry);
+}
+
+static int chown_one_xattr(struct dentry *dentry, void *data)
+{
+ struct iattr *attrs = data;
+ return notify_change(dentry, attrs);
+}
+
+int reiserfs_delete_xattrs(struct inode *inode)
+{
+ return reiserfs_for_each_xattr(inode, delete_one_xattr, NULL);
+}
+
+int reiserfs_chown_xattrs(struct inode *inode, struct iattr *attrs)
+{
+ return reiserfs_for_each_xattr(inode, chown_one_xattr, attrs);
+}
+
/* Actual operations that are exported to VFS-land */
/*
@@ -996,7 +815,7 @@ ssize_t reiserfs_listxattr(struct dentry
goto out;
}
- err = xattr_readdir(fp, listxattr_filler, &buf);
+ err = fp->f_op->readdir(fp, &buf, listxattr_filler);
if (err)
goto out_dir;
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 43+ messages in thread
* [patch 22/40] reiserfs: add atomic addition of selinux attributes during inode creation
2007-06-11 19:03 [patch 00/40] reiserfs: patch queue (v2) jeffm
` (20 preceding siblings ...)
2007-06-11 19:03 ` [patch 21/40] reiserfs: use generic readdir for operations across all xattrs jeffm
@ 2007-06-11 19:03 ` jeffm
2007-06-11 19:03 ` [patch 23/40] reiserfs: cleanup path functions jeffm
` (18 subsequent siblings)
40 siblings, 0 replies; 43+ messages in thread
From: jeffm @ 2007-06-11 19:03 UTC (permalink / raw)
To: ReiserFS Mailing List
[-- Attachment #1: reiserfs-selinux.diff --]
[-- Type: text/plain, Size: 10907 bytes --]
Some time ago, some changes were made to make security inode attributes
be atomically written during inode creation. ReiserFS fell behind in this
area, but with the reworking of the xattr code, it's now fairly easy to add.
The following patch adds the ability for security attributes to be added
automatically during inode creation.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
--
fs/reiserfs/inode.c | 16 +++++++++++
fs/reiserfs/namei.c | 37 ++++++++++++++++++++++++---
fs/reiserfs/xattr_security.c | 55 +++++++++++++++++++++++++++++++++++++++--
include/linux/reiserfs_fs.h | 4 ++
include/linux/reiserfs_xattr.h | 31 +++++++++++++++++++++++
5 files changed, 135 insertions(+), 8 deletions(-)
--- a/fs/reiserfs/inode.c 2007-06-11 14:49:38.000000000 -0400
+++ b/fs/reiserfs/inode.c 2007-06-11 14:50:04.000000000 -0400
@@ -1758,7 +1758,8 @@ int reiserfs_new_inode(struct reiserfs_t
/* 0 for regular, EMTRY_DIR_SIZE for dirs,
strlen (symname) for symlinks) */
loff_t i_size, struct dentry *dentry,
- struct inode *inode)
+ struct inode *inode,
+ struct reiserfs_security_handle *security)
{
struct super_block *sb;
INITIALIZE_PATH(path_to_key);
@@ -1936,6 +1937,19 @@ int reiserfs_new_inode(struct reiserfs_t
reiserfs_mark_inode_private(inode);
}
+ if (security->name) {
+ retval = reiserfs_security_write(th, inode, security);
+ if (retval) {
+ err = retval;
+ reiserfs_check_path(&path_to_key);
+ retval = journal_end(th, th->t_super,
+ th->t_blocks_allocated);
+ if (retval)
+ err = retval;
+ goto out_inserted_sd;
+ }
+ }
+
insert_inode_hash(inode);
reiserfs_update_sd(th, inode);
reiserfs_check_path(&path_to_key);
--- a/fs/reiserfs/namei.c 2007-06-11 14:49:38.000000000 -0400
+++ b/fs/reiserfs/namei.c 2007-06-11 14:50:04.000000000 -0400
@@ -606,6 +606,7 @@ static int reiserfs_create(struct inode
2 * (REISERFS_QUOTA_INIT_BLOCKS(dir->i_sb) +
REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb));
struct reiserfs_transaction_handle th;
+ struct reiserfs_security_handle security;
if (!(inode = new_inode(dir->i_sb))) {
return -ENOMEM;
@@ -613,6 +614,12 @@ static int reiserfs_create(struct inode
new_inode_init(inode, dir, mode);
jbegin_count += reiserfs_cache_default_acl(dir);
+ retval = reiserfs_security_init(dir, inode, &security);
+ if (retval < 0) {
+ drop_new_inode(inode);
+ return retval;
+ }
+ jbegin_count += retval;
reiserfs_write_lock(dir->i_sb);
retval = journal_begin(&th, dir->i_sb, jbegin_count);
@@ -623,7 +630,7 @@ static int reiserfs_create(struct inode
retval =
reiserfs_new_inode(&th, dir, mode, NULL, 0 /*i_size */ , dentry,
- inode);
+ inode, &security);
if (retval)
goto out_failed;
@@ -661,6 +668,7 @@ static int reiserfs_mknod(struct inode *
int retval;
struct inode *inode;
struct reiserfs_transaction_handle th;
+ struct reiserfs_security_handle security;
/* 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 +
@@ -676,6 +684,12 @@ static int reiserfs_mknod(struct inode *
new_inode_init(inode, dir, mode);
jbegin_count += reiserfs_cache_default_acl(dir);
+ retval = reiserfs_security_init(dir, inode, &security);
+ if (retval < 0) {
+ drop_new_inode(inode);
+ return retval;
+ }
+ jbegin_count += retval;
reiserfs_write_lock(dir->i_sb);
retval = journal_begin(&th, dir->i_sb, jbegin_count);
@@ -686,7 +700,7 @@ static int reiserfs_mknod(struct inode *
retval =
reiserfs_new_inode(&th, dir, mode, NULL, 0 /*i_size */ , dentry,
- inode);
+ inode, &security);
if (retval) {
goto out_failed;
}
@@ -727,6 +741,7 @@ static int reiserfs_mkdir(struct inode *
int retval;
struct inode *inode;
struct reiserfs_transaction_handle th;
+ struct reiserfs_security_handle security;
/* 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 +
@@ -744,6 +759,12 @@ static int reiserfs_mkdir(struct inode *
new_inode_init(inode, dir, mode);
jbegin_count += reiserfs_cache_default_acl(dir);
+ retval = reiserfs_security_init(dir, inode, &security);
+ if (retval < 0) {
+ drop_new_inode(inode);
+ return retval;
+ }
+ jbegin_count += retval;
reiserfs_write_lock(dir->i_sb);
retval = journal_begin(&th, dir->i_sb, jbegin_count);
@@ -760,7 +781,7 @@ static int reiserfs_mkdir(struct inode *
retval = reiserfs_new_inode(&th, dir, mode, NULL /*symlink */ ,
old_format_only(dir->i_sb) ?
EMPTY_DIR_SIZE_V1 : EMPTY_DIR_SIZE,
- dentry, inode);
+ dentry, inode, &security);
if (retval) {
dir->i_nlink--;
goto out_failed;
@@ -1001,6 +1022,7 @@ static int reiserfs_symlink(struct inode
char *name;
int item_len;
struct reiserfs_transaction_handle th;
+ struct reiserfs_security_handle security;
int mode = S_IFLNK | S_IRWXUGO;
/* We need blocks for transaction + (user+group)*(quotas for new inode + update of quota for directory owner) */
int jbegin_count =
@@ -1013,6 +1035,13 @@ static int reiserfs_symlink(struct inode
}
new_inode_init(inode, parent_dir, mode);
+ retval = reiserfs_security_init(parent_dir, inode, &security);
+ if (retval < 0) {
+ drop_new_inode(inode);
+ return retval;
+ }
+ jbegin_count += retval;
+
reiserfs_write_lock(parent_dir->i_sb);
item_len = ROUND_UP(strlen(symname));
if (item_len > MAX_DIRECT_ITEM_LEN(parent_dir->i_sb->s_blocksize)) {
@@ -1039,7 +1068,7 @@ static int reiserfs_symlink(struct inode
retval =
reiserfs_new_inode(&th, parent_dir, mode, name, strlen(symname),
- dentry, inode);
+ dentry, inode, &security);
kfree(name);
if (retval) { /* reiserfs_new_inode iputs for us */
goto out_failed;
--- a/fs/reiserfs/xattr_security.c 2007-06-11 14:49:37.000000000 -0400
+++ b/fs/reiserfs/xattr_security.c 2007-06-11 14:49:38.000000000 -0400
@@ -4,10 +4,9 @@
#include <linux/pagemap.h>
#include <linux/xattr.h>
#include <linux/reiserfs_xattr.h>
+#include <linux/security.h>
#include <asm/uaccess.h>
-#define XATTR_SECURITY_PREFIX "security."
-
static int
security_get(struct inode *inode, const char *name, void *buffer, size_t size)
{
@@ -49,6 +48,58 @@ static size_t security_list(struct inode
return len;
}
+/* Initializes the security context for a new inode and returns the number
+ * of blocks needed for the transaction. If successful, reiserfs_security
+ * must be released using reiserfs_security_free when the caller is done. */
+int reiserfs_security_init(struct inode *dir, struct inode *inode,
+ struct reiserfs_security_handle *sec)
+{
+ int blocks = 0;
+ int error = security_inode_init_security(inode, dir, &sec->name,
+ &sec->value, &sec->length);
+ if (error) {
+ if (error == -EOPNOTSUPP)
+ error = 0;
+
+ sec->name = NULL;
+ sec->value = NULL;
+ sec->length = 0;
+ return error;
+ }
+
+ if (sec->length) {
+ blocks = reiserfs_xattr_jcreate_nblocks(inode) +
+ reiserfs_xattr_nblocks(inode, sec->length);
+ /* We don't want to count the directories twice if we have
+ * a default ACL. */
+ REISERFS_I(inode)->i_flags |= i_has_xattr_dir;
+ }
+ return blocks;
+}
+
+int reiserfs_security_write(struct reiserfs_transaction_handle *th,
+ struct inode *inode,
+ struct reiserfs_security_handle *sec)
+{
+ int error;
+ if (strlen(sec->name) < sizeof(XATTR_SECURITY_PREFIX))
+ return -EINVAL;
+
+ error = reiserfs_xattr_set_handle(th, inode, sec->name, sec->value,
+ sec->length, XATTR_CREATE);
+ if (error == -ENODATA || error == -EOPNOTSUPP)
+ error = 0;
+
+ return error;
+}
+
+void reiserfs_security_free(struct reiserfs_security_handle *sec)
+{
+ kfree(sec->name);
+ kfree(sec->value);
+ sec->name = sec->value = NULL;
+}
+
struct xattr_handler reiserfs_xattr_security_handler = {
.prefix = XATTR_SECURITY_PREFIX,
.get = security_get,
--- a/include/linux/reiserfs_fs.h 2007-06-11 14:49:38.000000000 -0400
+++ b/include/linux/reiserfs_fs.h 2007-06-11 14:50:04.000000000 -0400
@@ -1909,10 +1909,12 @@ void make_le_item_head(struct item_head
loff_t offset, int type, int length, int entry_count);
struct inode *reiserfs_iget(struct super_block *s, const struct cpu_key *key);
+struct reiserfs_security_handle;
int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
struct inode *dir, int mode,
const char *symname, loff_t i_size,
- struct dentry *dentry, struct inode *inode);
+ struct dentry *dentry, struct inode *inode,
+ struct reiserfs_security_handle *security);
void reiserfs_update_sd_size(struct reiserfs_transaction_handle *th,
struct inode *inode, loff_t size);
--- a/include/linux/reiserfs_xattr.h 2007-06-11 14:49:38.000000000 -0400
+++ b/include/linux/reiserfs_xattr.h 2007-06-11 14:49:38.000000000 -0400
@@ -15,6 +15,12 @@ struct reiserfs_xattr_header {
__le32 h_hash; /* hash of the value */
};
+struct reiserfs_security_handle {
+ char *name;
+ void *value;
+ size_t length;
+};
+
#ifdef __KERNEL__
#include <linux/init.h>
@@ -50,6 +56,14 @@ int reiserfs_xattr_set_handle(struct rei
extern struct xattr_handler reiserfs_xattr_user_handler;
extern struct xattr_handler reiserfs_xattr_trusted_handler;
extern struct xattr_handler reiserfs_xattr_security_handler;
+#ifdef CONFIG_REISERFS_FS_SECURITY
+int reiserfs_security_init(struct inode *dir, struct inode *inode,
+ struct reiserfs_security_handle *sec);
+int reiserfs_security_write(struct reiserfs_transaction_handle *th,
+ struct inode *inode,
+ struct reiserfs_security_handle *sec);
+void reiserfs_security_free(struct reiserfs_security_handle *sec);
+#endif
static inline void reiserfs_mark_inode_private(struct inode *inode)
@@ -114,6 +128,23 @@ static inline void reiserfs_init_xattr_r
}
#endif /* CONFIG_REISERFS_FS_XATTR */
+#ifndef CONFIG_REISERFS_FS_SECURITY
+static inline int reiserfs_security_init(struct inode *dir,
+ struct inode *inode,
+ struct reiserfs_security_handle *sec)
+{
+ return 0;
+}
+static inline int reiserfs_security_write(struct reiserfs_transaction_handle *th,
+ struct inode *inode,
+ struct reiserfs_security_handle *sec)
+{
+ return 0;
+}
+static inline void reiserfs_security_free(struct reiserfs_security_handle *sec)
+{}
+#endif
+
#endif /* __KERNEL__ */
#endif /* _LINUX_REISERFS_XATTR_H */
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 43+ messages in thread
* [patch 23/40] reiserfs: cleanup path functions
2007-06-11 19:03 [patch 00/40] reiserfs: patch queue (v2) jeffm
` (21 preceding siblings ...)
2007-06-11 19:03 ` [patch 22/40] reiserfs: add atomic addition of selinux attributes during inode creation jeffm
@ 2007-06-11 19:03 ` jeffm
2007-06-11 19:03 ` [patch 24/40] reiserfs: strip trailing whitespace jeffm
` (17 subsequent siblings)
40 siblings, 0 replies; 43+ messages in thread
From: jeffm @ 2007-06-11 19:03 UTC (permalink / raw)
To: ReiserFS Mailing List
[-- Attachment #1: reiserfs-cleanup-path-funcs.diff --]
[-- Type: text/plain, Size: 9426 bytes --]
This patch cleans up some redundancies in the reiserfs tree path code.
decrement_bcount() is essentially the same function as brelse(), so we use
that instead.
decrement_counters_in_path() is exactly the same function as pathrelse(), so
we kill that and use pathrelse() instead.
There's also a bit of cleanup that makes the code a bit more readable.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
fs/reiserfs/fix_node.c | 58 ++++++++++++++++++++++++------------------------
fs/reiserfs/stree.c | 59 ++++++++++---------------------------------------
2 files changed, 43 insertions(+), 74 deletions(-)
--- a/fs/reiserfs/fix_node.c 2007-06-11 14:49:34.000000000 -0400
+++ b/fs/reiserfs/fix_node.c 2007-06-11 14:50:04.000000000 -0400
@@ -753,20 +753,21 @@ static void free_buffers_in_tb(struct tr
{
int n_counter;
- decrement_counters_in_path(p_s_tb->tb_path);
+ pathrelse(p_s_tb->tb_path);
for (n_counter = 0; n_counter < MAX_HEIGHT; n_counter++) {
- decrement_bcount(p_s_tb->L[n_counter]);
+ brelse(p_s_tb->L[n_counter]);
+ brelse(p_s_tb->R[n_counter]);
+ brelse(p_s_tb->FL[n_counter]);
+ brelse(p_s_tb->FR[n_counter]);
+ brelse(p_s_tb->CFL[n_counter]);
+ brelse(p_s_tb->CFR[n_counter]);
+
p_s_tb->L[n_counter] = NULL;
- decrement_bcount(p_s_tb->R[n_counter]);
p_s_tb->R[n_counter] = NULL;
- decrement_bcount(p_s_tb->FL[n_counter]);
p_s_tb->FL[n_counter] = NULL;
- decrement_bcount(p_s_tb->FR[n_counter]);
p_s_tb->FR[n_counter] = NULL;
- decrement_bcount(p_s_tb->CFL[n_counter]);
p_s_tb->CFL[n_counter] = NULL;
- decrement_bcount(p_s_tb->CFR[n_counter]);
p_s_tb->CFR[n_counter] = NULL;
}
}
@@ -1020,7 +1021,7 @@ static int get_far_parent(struct tree_ba
if (buffer_locked(*pp_s_com_father)) {
__wait_on_buffer(*pp_s_com_father);
if (FILESYSTEM_CHANGED_TB(p_s_tb)) {
- decrement_bcount(*pp_s_com_father);
+ brelse(*pp_s_com_father);
return REPEAT_SEARCH;
}
}
@@ -1048,8 +1049,8 @@ static int get_far_parent(struct tree_ba
return IO_ERROR;
if (FILESYSTEM_CHANGED_TB(p_s_tb)) {
- decrement_counters_in_path(&s_path_to_neighbor_father);
- decrement_bcount(*pp_s_com_father);
+ pathrelse(&s_path_to_neighbor_father);
+ brelse(*pp_s_com_father);
return REPEAT_SEARCH;
}
@@ -1061,7 +1062,7 @@ static int get_far_parent(struct tree_ba
FIRST_PATH_ELEMENT_OFFSET, "PAP-8192: path length is too small");
s_path_to_neighbor_father.path_length--;
- decrement_counters_in_path(&s_path_to_neighbor_father);
+ pathrelse(&s_path_to_neighbor_father);
return CARRY_ON;
}
@@ -1084,10 +1085,10 @@ static int get_parents(struct tree_balan
if (n_path_offset <= FIRST_PATH_ELEMENT_OFFSET) {
/* The root can not have parents.
Release nodes which previously were obtained as parents of the current node neighbors. */
- decrement_bcount(p_s_tb->FL[n_h]);
- decrement_bcount(p_s_tb->CFL[n_h]);
- decrement_bcount(p_s_tb->FR[n_h]);
- decrement_bcount(p_s_tb->CFR[n_h]);
+ brelse(p_s_tb->FL[n_h]);
+ brelse(p_s_tb->CFL[n_h]);
+ brelse(p_s_tb->FR[n_h]);
+ brelse(p_s_tb->CFR[n_h]);
p_s_tb->FL[n_h] = p_s_tb->CFL[n_h] = p_s_tb->FR[n_h] =
p_s_tb->CFR[n_h] = NULL;
return CARRY_ON;
@@ -1113,9 +1114,9 @@ static int get_parents(struct tree_balan
return n_ret_value;
}
- decrement_bcount(p_s_tb->FL[n_h]);
+ brelse(p_s_tb->FL[n_h]);
p_s_tb->FL[n_h] = p_s_curf; /* New initialization of FL[n_h]. */
- decrement_bcount(p_s_tb->CFL[n_h]);
+ brelse(p_s_tb->CFL[n_h]);
p_s_tb->CFL[n_h] = p_s_curcf; /* New initialization of CFL[n_h]. */
RFALSE((p_s_curf && !B_IS_IN_TREE(p_s_curf)) ||
@@ -1143,10 +1144,10 @@ static int get_parents(struct tree_balan
p_s_tb->rkey[n_h] = n_position;
}
- decrement_bcount(p_s_tb->FR[n_h]);
+ brelse(p_s_tb->FR[n_h]);
p_s_tb->FR[n_h] = p_s_curf; /* New initialization of FR[n_path_offset]. */
- decrement_bcount(p_s_tb->CFR[n_h]);
+ brelse(p_s_tb->CFR[n_h]);
p_s_tb->CFR[n_h] = p_s_curcf; /* New initialization of CFR[n_path_offset]. */
RFALSE((p_s_curf && !B_IS_IN_TREE(p_s_curf)) ||
@@ -1962,7 +1963,7 @@ static int get_neighbors(struct tree_bal
if (!p_s_bh)
return IO_ERROR;
if (FILESYSTEM_CHANGED_TB(p_s_tb)) {
- decrement_bcount(p_s_bh);
+ brelse(p_s_bh);
PROC_INFO_INC(p_s_sb, get_neighbors_restart[n_h]);
return REPEAT_SEARCH;
}
@@ -1978,7 +1979,7 @@ static int get_neighbors(struct tree_bal
dc_size(B_N_CHILD(p_s_tb->FL[0], n_child_position)),
"PAP-8290: invalid child size of left neighbor");
- decrement_bcount(p_s_tb->L[n_h]);
+ brelse(p_s_tb->L[n_h]);
p_s_tb->L[n_h] = p_s_bh;
}
@@ -1999,11 +2000,11 @@ static int get_neighbors(struct tree_bal
if (!p_s_bh)
return IO_ERROR;
if (FILESYSTEM_CHANGED_TB(p_s_tb)) {
- decrement_bcount(p_s_bh);
+ brelse(p_s_bh);
PROC_INFO_INC(p_s_sb, get_neighbors_restart[n_h]);
return REPEAT_SEARCH;
}
- decrement_bcount(p_s_tb->R[n_h]);
+ brelse(p_s_tb->R[n_h]);
p_s_tb->R[n_h] = p_s_bh;
RFALSE(!n_h
@@ -2509,16 +2510,17 @@ int fix_nodes(int n_op_mode, struct tree
}
brelse(p_s_tb->L[i]);
- p_s_tb->L[i] = NULL;
brelse(p_s_tb->R[i]);
- p_s_tb->R[i] = NULL;
brelse(p_s_tb->FL[i]);
- p_s_tb->FL[i] = NULL;
brelse(p_s_tb->FR[i]);
- p_s_tb->FR[i] = NULL;
brelse(p_s_tb->CFL[i]);
- p_s_tb->CFL[i] = NULL;
brelse(p_s_tb->CFR[i]);
+
+ p_s_tb->L[i] = NULL;
+ p_s_tb->R[i] = NULL;
+ p_s_tb->FL[i] = NULL;
+ p_s_tb->FR[i] = NULL;
+ p_s_tb->CFL[i] = NULL;
p_s_tb->CFR[i] = NULL;
}
--- a/fs/reiserfs/stree.c 2007-06-11 14:49:35.000000000 -0400
+++ b/fs/reiserfs/stree.c 2007-06-11 14:50:04.000000000 -0400
@@ -23,7 +23,6 @@
* get_rkey
* key_in_buffer
* decrement_bcount
- * decrement_counters_in_path
* reiserfs_check_path
* pathrelse_and_restore
* pathrelse
@@ -359,36 +358,6 @@ static inline int key_in_buffer(struct t
return 1;
}
-inline void decrement_bcount(struct buffer_head *p_s_bh)
-{
- if (p_s_bh) {
- if (atomic_read(&(p_s_bh->b_count))) {
- put_bh(p_s_bh);
- return;
- }
- reiserfs_panic(NULL, "PAP-5070",
- "trying to free free buffer %b", p_s_bh);
- }
-}
-
-/* Decrement b_count field of the all buffers in the path. */
-void decrement_counters_in_path(struct treepath *p_s_search_path)
-{
- int n_path_offset = p_s_search_path->path_length;
-
- RFALSE(n_path_offset < ILLEGAL_PATH_ELEMENT_OFFSET ||
- n_path_offset > EXTENDED_MAX_HEIGHT - 1,
- "PAP-5080: invalid path offset of %d", n_path_offset);
-
- while (n_path_offset > ILLEGAL_PATH_ELEMENT_OFFSET) {
- struct buffer_head *bh;
-
- bh = PATH_OFFSET_PBUFFER(p_s_search_path, n_path_offset--);
- decrement_bcount(bh);
- }
- p_s_search_path->path_length = ILLEGAL_PATH_ELEMENT_OFFSET;
-}
-
int reiserfs_check_path(struct treepath *p)
{
RFALSE(p->path_length != ILLEGAL_PATH_ELEMENT_OFFSET,
@@ -396,12 +365,11 @@ int reiserfs_check_path(struct treepath
return 0;
}
-/* Release all buffers in the path. Restore dirty bits clean
-** when preparing the buffer for the log
-**
-** only called from fix_nodes()
-*/
-void pathrelse_and_restore(struct super_block *s, struct treepath *p_s_search_path)
+/* Drop the reference to each buffer in a path and restore
+ * dirty bits clean when preparing the buffer for the log.
+ * This version should only be called from fix_nodes() */
+void pathrelse_and_restore(struct super_block *sb,
+ struct treepath *p_s_search_path)
{
int n_path_offset = p_s_search_path->path_length;
@@ -409,16 +377,15 @@ void pathrelse_and_restore(struct super_
"clm-4000: invalid path offset");
while (n_path_offset > ILLEGAL_PATH_ELEMENT_OFFSET) {
- reiserfs_restore_prepared_buffer(s,
- PATH_OFFSET_PBUFFER
- (p_s_search_path,
- n_path_offset));
- brelse(PATH_OFFSET_PBUFFER(p_s_search_path, n_path_offset--));
+ struct buffer_head *bh;
+ bh = PATH_OFFSET_PBUFFER(p_s_search_path, n_path_offset--);
+ reiserfs_restore_prepared_buffer(sb, bh);
+ brelse(bh);
}
p_s_search_path->path_length = ILLEGAL_PATH_ELEMENT_OFFSET;
}
-/* Release all buffers in the path. */
+/* Drop the reference to each buffer in a path */
void pathrelse(struct treepath *p_s_search_path)
{
int n_path_offset = p_s_search_path->path_length;
@@ -631,7 +598,7 @@ int search_by_key(struct super_block *p_
we must be careful to release all nodes in a path before we either
discard the path struct or re-use the path struct, as we do here. */
- decrement_counters_in_path(p_s_search_path);
+ pathrelse(p_s_search_path);
right_neighbor_of_leaf_node = 0;
@@ -691,7 +658,7 @@ int search_by_key(struct super_block *p_
PROC_INFO_INC(p_s_sb, search_by_key_restarted);
PROC_INFO_INC(p_s_sb,
sbk_restarted[expected_level - 1]);
- decrement_counters_in_path(p_s_search_path);
+ pathrelse(p_s_search_path);
/* Get the root block number so that we can repeat the search
starting from the root. */
@@ -1871,7 +1838,7 @@ int reiserfs_do_truncate(struct reiserfs
if (journal_transaction_should_end(th, 0) ||
reiserfs_transaction_free_space(th) <= JOURNAL_FOR_FREE_BLOCK_AND_UPDATE_SD) {
int orig_len_alloc = th->t_blocks_allocated;
- decrement_counters_in_path(&s_search_path);
+ pathrelse(&s_search_path);
if (update_timestamps) {
p_s_inode->i_mtime = p_s_inode->i_ctime =
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 43+ messages in thread
* [patch 24/40] reiserfs: strip trailing whitespace
2007-06-11 19:03 [patch 00/40] reiserfs: patch queue (v2) jeffm
` (22 preceding siblings ...)
2007-06-11 19:03 ` [patch 23/40] reiserfs: cleanup path functions jeffm
@ 2007-06-11 19:03 ` jeffm
2007-06-11 19:03 ` [patch 26/40] reiserfs: rename p_s_bh to bh jeffm
` (16 subsequent siblings)
40 siblings, 0 replies; 43+ messages in thread
From: jeffm @ 2007-06-11 19:03 UTC (permalink / raw)
To: ReiserFS Mailing List
[-- Attachment #1: reiserfs-strip-whitespace.diff --]
[-- Type: text/plain, Size: 59360 bytes --]
This patch strips trailing whitespace from the reiserfs code.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
fs/reiserfs/README | 4 -
fs/reiserfs/do_balan.c | 14 ++--
fs/reiserfs/file.c | 14 ++--
fs/reiserfs/fix_node.c | 38 ++++++------
fs/reiserfs/hashes.c | 2
fs/reiserfs/ibalance.c | 10 +--
fs/reiserfs/inode.c | 52 ++++++++---------
fs/reiserfs/ioctl.c | 2
fs/reiserfs/journal.c | 124 ++++++++++++++++++++---------------------
fs/reiserfs/lbalance.c | 18 ++---
fs/reiserfs/namei.c | 30 ++++-----
fs/reiserfs/objectid.c | 2
fs/reiserfs/prints.c | 26 ++++----
fs/reiserfs/procfs.c | 2
fs/reiserfs/resize.c | 6 -
fs/reiserfs/stree.c | 8 +-
fs/reiserfs/super.c | 10 +--
fs/reiserfs/tail_conversion.c | 2
include/linux/reiserfs_fs_sb.h | 14 ++--
19 files changed, 189 insertions(+), 189 deletions(-)
--- a/fs/reiserfs/README 2007-06-11 14:49:03.000000000 -0400
+++ b/fs/reiserfs/README 2007-06-11 14:49:39.000000000 -0400
@@ -1,4 +1,4 @@
-[LICENSING]
+[LICENSING]
ReiserFS is hereby licensed under the GNU General
Public License version 2.
@@ -31,7 +31,7 @@ the GPL as not allowing those additional
it wrongly, and Richard Stallman agrees with me, when carefully read
you can see that those restrictions on additional terms do not apply
to the owner of the copyright, and my interpretation of this shall
-govern for this license.
+govern for this license.
Finally, nothing in this license shall be interpreted to allow you to
fail to fairly credit me, or to remove my credits, without my
--- a/fs/reiserfs/do_balan.c 2007-06-11 14:49:34.000000000 -0400
+++ b/fs/reiserfs/do_balan.c 2007-06-11 14:50:01.000000000 -0400
@@ -39,21 +39,21 @@ inline void do_balance_mark_leaf_dirty(s
#define do_balance_mark_internal_dirty do_balance_mark_leaf_dirty
#define do_balance_mark_sb_dirty do_balance_mark_leaf_dirty
-/* summary:
+/* summary:
if deleting something ( tb->insert_size[0] < 0 )
return(balance_leaf_when_delete()); (flag d handled here)
else
if lnum is larger than 0 we put items into the left node
if rnum is larger than 0 we put items into the right node
if snum1 is larger than 0 we put items into the new node s1
- if snum2 is larger than 0 we put items into the new node s2
+ if snum2 is larger than 0 we put items into the new node s2
Note that all *num* count new items being created.
It would be easier to read balance_leaf() if each of these summary
lines was a separate procedure rather than being inlined. I think
that there are many passages here and in balance_leaf_when_delete() in
which two calls to one procedure can replace two passages, and it
-might save cache space and improve software maintenance costs to do so.
+might save cache space and improve software maintenance costs to do so.
Vladimir made the perceptive comment that we should offload most of
the decision making in this function into fix_nodes/check_balance, and
@@ -258,15 +258,15 @@ static int balance_leaf(struct tree_bala
)
{
struct buffer_head *tbS0 = PATH_PLAST_BUFFER(tb->tb_path);
- int item_pos = PATH_LAST_POSITION(tb->tb_path); /* index into the array of item headers in S[0]
+ int item_pos = PATH_LAST_POSITION(tb->tb_path); /* index into the array of item headers in S[0]
of the affected item */
struct buffer_info bi;
struct buffer_head *S_new[2]; /* new nodes allocated to hold what could not fit into S */
int snum[2]; /* number of items that will be placed
into S_new (includes partially shifted
items) */
- int sbytes[2]; /* if an item is partially shifted into S_new then
- if it is a directory item
+ int sbytes[2]; /* if an item is partially shifted into S_new then
+ if it is a directory item
it is the number of entries from the item that are shifted into S_new
else
it is the number of bytes from the item that are shifted into S_new
@@ -2036,7 +2036,7 @@ static inline void do_balance_starts(str
/* store_print_tb (tb); */
/* do not delete, just comment it out */
-/* print_tb(flag, PATH_LAST_POSITION(tb->tb_path), tb->tb_path->pos_in_item, tb,
+/* print_tb(flag, PATH_LAST_POSITION(tb->tb_path), tb->tb_path->pos_in_item, tb,
"check");*/
RFALSE(check_before_balancing(tb), "PAP-12340: locked buffers in TB");
#ifdef CONFIG_REISERFS_CHECK
--- a/fs/reiserfs/file.c 2007-06-11 14:49:38.000000000 -0400
+++ b/fs/reiserfs/file.c 2007-06-11 14:50:03.000000000 -0400
@@ -20,14 +20,14 @@
** insertion/balancing, for files that are written in one write.
** It avoids unnecessary tail packings (balances) for files that are written in
** multiple writes and are small enough to have tails.
-**
+**
** file_release is called by the VFS layer when the file is closed. If
** this is the last open file descriptor, and the file
** small enough to have a tail, and the tail is currently in an
** unformatted node, the tail is converted back into a direct item.
-**
+**
** We use reiserfs_truncate_file to pack the tail, since it already has
-** all the conditions coded.
+** all the conditions coded.
*/
static int reiserfs_file_release(struct inode *inode, struct file *filp)
{
@@ -723,7 +723,7 @@ static void reiserfs_unprepare_pages(str
static int reiserfs_copy_from_user_to_file_region(loff_t pos, /* In-file position */
int num_pages, /* Number of pages affected */
int write_bytes, /* Amount of bytes to write */
- struct page **prepared_pages, /* pointer to
+ struct page **prepared_pages, /* pointer to
array to
prepared pages
*/
@@ -900,7 +900,7 @@ static int reiserfs_submit_file_region_f
}
th->t_trans_id = 0;
- /*
+ /*
* we have to unlock the pages after updating i_size, otherwise
* we race with writepage
*/
@@ -971,7 +971,7 @@ static int reiserfs_check_for_tail_and_c
@prepared_pages array. Also buffers are allocated for these pages.
First and last page of the region is read if it is overwritten only
partially. If last page did not exist before write (file hole or file
- append), it is zeroed, then.
+ append), it is zeroed, then.
Returns number of unallocated blocks that should be allocated to cover
new file data.*/
static int reiserfs_prepare_file_region_for_write(struct inode *inode
@@ -1256,7 +1256,7 @@ static int reiserfs_prepare_file_region_
}
/* Write @count bytes at position @ppos in a file indicated by @file
- from the buffer @buf.
+ from the buffer @buf.
generic_file_write() is only appropriate for filesystems that are not seeking to optimize performance and want
something simple that works. It is not for serious use by general purpose filesystems, excepting the one that it was
--- a/fs/reiserfs/fix_node.c 2007-06-11 14:49:39.000000000 -0400
+++ b/fs/reiserfs/fix_node.c 2007-06-11 14:50:04.000000000 -0400
@@ -30,8 +30,8 @@
** get_direct_parent
** get_neighbors
** fix_nodes
- **
- **
+ **
+ **
**/
#include <linux/time.h>
@@ -377,9 +377,9 @@ static int get_num_ver(int mode, struct
int needed_nodes;
int start_item, /* position of item we start filling node from */
end_item, /* position of item we finish filling node by */
- start_bytes, /* number of first bytes (entries for directory) of start_item-th item
+ start_bytes, /* number of first bytes (entries for directory) of start_item-th item
we do not include into node that is being filled */
- end_bytes; /* number of last bytes (entries for directory) of end_item-th item
+ end_bytes; /* number of last bytes (entries for directory) of end_item-th item
we do node include into node that is being filled */
int split_item_positions[2]; /* these are positions in virtual item of
items, that are split between S[0] and
@@ -569,7 +569,7 @@ extern struct tree_balance *cur_tb;
/* Set parameters for balancing.
* Performs write of results of analysis of balancing into structure tb,
- * where it will later be used by the functions that actually do the balancing.
+ * where it will later be used by the functions that actually do the balancing.
* Parameters:
* tb tree_balance structure;
* h current level of the node;
@@ -1202,7 +1202,7 @@ static inline int can_node_be_removed(in
* h current level of the node;
* inum item number in S[h];
* mode i - insert, p - paste;
- * Returns: 1 - schedule occurred;
+ * Returns: 1 - schedule occurred;
* 0 - balancing for higher levels needed;
* -1 - no balancing for higher levels needed;
* -2 - no disk space.
@@ -1237,7 +1237,7 @@ static int ip_check_balance(struct tree_
/* we perform 8 calls to get_num_ver(). For each call we calculate five parameters.
where 4th parameter is s1bytes and 5th - s2bytes
*/
- short snum012[40] = { 0, }; /* s0num, s1num, s2num for 8 cases
+ short snum012[40] = { 0, }; /* s0num, s1num, s2num for 8 cases
0,1 - do not shift and do not shift but bottle
2 - shift only whole item to left
3 - shift to left and bottle as much as possible
@@ -1286,7 +1286,7 @@ static int ip_check_balance(struct tree_
create_virtual_node(tb, h);
- /*
+ /*
determine maximal number of items we can shift to the left neighbor (in tb structure)
and the maximal number of bytes that can flow to the left neighbor
from the left most liquid item that cannot be shifted from S[0] entirely (returned value)
@@ -1347,13 +1347,13 @@ static int ip_check_balance(struct tree_
{
int lpar, rpar, nset, lset, rset, lrset;
- /*
+ /*
* regular overflowing of the node
*/
- /* get_num_ver works in 2 modes (FLOW & NO_FLOW)
+ /* get_num_ver works in 2 modes (FLOW & NO_FLOW)
lpar, rpar - number of items we can shift to left/right neighbor (including splitting item)
- nset, lset, rset, lrset - shows, whether flowing items give better packing
+ nset, lset, rset, lrset - shows, whether flowing items give better packing
*/
#define FLOW 1
#define NO_FLOW 0 /* do not any splitting */
@@ -1543,7 +1543,7 @@ static int ip_check_balance(struct tree_
* h current level of the node;
* inum item number in S[h];
* mode i - insert, p - paste;
- * Returns: 1 - schedule occurred;
+ * Returns: 1 - schedule occurred;
* 0 - balancing for higher levels needed;
* -1 - no balancing for higher levels needed;
* -2 - no disk space.
@@ -1726,7 +1726,7 @@ static int dc_check_balance_internal(str
* h current level of the node;
* inum item number in S[h];
* mode i - insert, p - paste;
- * Returns: 1 - schedule occurred;
+ * Returns: 1 - schedule occurred;
* 0 - balancing for higher levels needed;
* -1 - no balancing for higher levels needed;
* -2 - no disk space.
@@ -1820,7 +1820,7 @@ static int dc_check_balance_leaf(struct
* h current level of the node;
* inum item number in S[h];
* mode d - delete, c - cut.
- * Returns: 1 - schedule occurred;
+ * Returns: 1 - schedule occurred;
* 0 - balancing for higher levels needed;
* -1 - no balancing for higher levels needed;
* -2 - no disk space.
@@ -1849,7 +1849,7 @@ static int dc_check_balance(struct tree_
* h current level of the node;
* inum item number in S[h];
* mode i - insert, p - paste, d - delete, c - cut.
- * Returns: 1 - schedule occurred;
+ * Returns: 1 - schedule occurred;
* 0 - balancing for higher levels needed;
* -1 - no balancing for higher levels needed;
* -2 - no disk space.
@@ -2294,15 +2294,15 @@ static int wait_tb_buffers_until_unlocke
* analyze what and where should be moved;
* get sufficient number of new nodes;
* Balancing will start only after all resources will be collected at a time.
- *
+ *
* When ported to SMP kernels, only at the last moment after all needed nodes
* are collected in cache, will the resources be locked using the usual
* textbook ordered lock acquisition algorithms. Note that ensuring that
* this code neither write locks what it does not need to write lock nor locks out of order
* will be a pain in the butt that could have been avoided. Grumble grumble. -Hans
- *
+ *
* fix is meant in the sense of render unchanging
- *
+ *
* Latency might be improved by first gathering a list of what buffers are needed
* and then getting as many of them in parallel as possible? -Hans
*
@@ -2314,7 +2314,7 @@ static int wait_tb_buffers_until_unlocke
* ins_ih & ins_sd are used when inserting
* Returns: 1 - schedule occurred while the function worked;
* 0 - schedule didn't occur while the function worked;
- * -1 - if no_disk_space
+ * -1 - if no_disk_space
*/
int fix_nodes(int n_op_mode, struct tree_balance *p_s_tb, struct item_head *p_s_ins_ih, // item head of item being inserted
--- a/fs/reiserfs/hashes.c 2007-06-11 14:49:05.000000000 -0400
+++ b/fs/reiserfs/hashes.c 2007-06-11 14:49:39.000000000 -0400
@@ -7,7 +7,7 @@
* (see Applied Cryptography, 2nd edition, p448).
*
* Jeremy Fitzhardinge <jeremy@zip.com.au> 1998
- *
+ *
* Jeremy has agreed to the contents of reiserfs/README. -Hans
* Yura's function is added (04/07/2000)
*/
--- a/fs/reiserfs/ibalance.c 2007-06-11 14:49:34.000000000 -0400
+++ b/fs/reiserfs/ibalance.c 2007-06-11 14:49:39.000000000 -0400
@@ -278,7 +278,7 @@ static void internal_delete_childs(struc
/* copy cpy_num node pointers and cpy_num - 1 items from buffer src to buffer dest
* last_first == FIRST_TO_LAST means, that we copy first items from src to tail of dest
- * last_first == LAST_TO_FIRST means, that we copy last items from src to head of dest
+ * last_first == LAST_TO_FIRST means, that we copy last items from src to head of dest
*/
static void internal_copy_pointers_items(struct buffer_info *dest_bi,
struct buffer_head *src,
@@ -385,7 +385,7 @@ static void internal_move_pointers_items
if (last_first == FIRST_TO_LAST) { /* shift_left occurs */
first_pointer = 0;
first_item = 0;
- /* delete cpy_num - del_par pointers and keys starting for pointers with first_pointer,
+ /* delete cpy_num - del_par pointers and keys starting for pointers with first_pointer,
for key - with first_item */
internal_delete_pointers_items(src_bi, first_pointer,
first_item, cpy_num - del_par);
@@ -453,7 +453,7 @@ static void internal_insert_key(struct b
}
}
-/* Insert d_key'th (delimiting) key from buffer cfl to tail of dest.
+/* Insert d_key'th (delimiting) key from buffer cfl to tail of dest.
* Copy pointer_amount node pointers and pointer_amount - 1 items from buffer src to buffer dest.
* Replace d_key'th key in buffer cfl.
* Delete pointer_amount items and node pointers from buffer src.
@@ -518,7 +518,7 @@ static void internal_shift1_left(struct
/* internal_move_pointers_items (tb->L[h], tb->S[h], FIRST_TO_LAST, pointer_amount, 1); */
}
-/* Insert d_key'th (delimiting) key from buffer cfr to head of dest.
+/* Insert d_key'th (delimiting) key from buffer cfr to head of dest.
* Copy n node pointers and n - 1 items from buffer src to buffer dest.
* Replace d_key'th key in buffer cfr.
* Delete n items and node pointers from buffer src.
@@ -749,7 +749,7 @@ int balance_internal(struct tree_balance
this means that new pointers and items must be inserted AFTER *
child_pos
}
- else
+ else
{
it is the position of the leftmost pointer that must be deleted (together with
its corresponding key to the left of the pointer)
--- a/fs/reiserfs/inode.c 2007-06-11 14:49:38.000000000 -0400
+++ b/fs/reiserfs/inode.c 2007-06-11 14:50:03.000000000 -0400
@@ -48,7 +48,7 @@ void reiserfs_delete_inode(struct 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)
DQUOT_FREE_INODE(inode);
if (journal_end(&th, inode->i_sb, jbegin_count))
@@ -359,7 +359,7 @@ static int _get_block_create_0(struct in
}
/* make sure we don't read more bytes than actually exist in
** the file. This can happen in odd cases where i_size isn't
- ** correct, and when direct item padding results in a few
+ ** correct, and when direct item padding results in a few
** extra bytes at the end of the direct item
*/
if ((le_ih_k_offset(ih) + path.pos_in_item) > inode->i_size)
@@ -434,15 +434,15 @@ static int reiserfs_bmap(struct inode *i
** -ENOENT instead of a valid buffer. block_prepare_write expects to
** be able to do i/o on the buffers returned, unless an error value
** is also returned.
-**
+**
** So, this allows block_prepare_write to be used for reading a single block
** in a page. Where it does not produce a valid page for holes, or past the
** end of the file. This turns out to be exactly what we need for reading
** tails for conversion.
**
** The point of the wrapper is forcing a certain value for create, even
-** though the VFS layer is calling this function with create==1. If you
-** don't want to send create == GET_BLOCK_NO_HOLE to reiserfs_get_block,
+** though the VFS layer is calling this function with create==1. If you
+** don't want to send create == GET_BLOCK_NO_HOLE to reiserfs_get_block,
** don't use this function.
*/
static int reiserfs_get_block_create_0(struct inode *inode, sector_t block,
@@ -598,7 +598,7 @@ int reiserfs_get_block(struct inode *ino
int done;
int fs_gen;
struct reiserfs_transaction_handle *th = NULL;
- /* space reserved in transaction batch:
+ /* space reserved in transaction batch:
. 3 balancings in direct->indirect conversion
. 1 block involved into reiserfs_update_sd()
XXX in practically impossible worst case direct2indirect()
@@ -750,7 +750,7 @@ int reiserfs_get_block(struct inode *ino
reiserfs_write_unlock(inode->i_sb);
/* 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
+ ** there is no need to make sure the inode is updated with this
** transaction
*/
return retval;
@@ -981,7 +981,7 @@ int reiserfs_get_block(struct inode *ino
/* this loop could log more blocks than we had originally asked
** for. So, we have to allow the transaction to end if it is
- ** too big or too full. Update the inode so things are
+ ** too big or too full. Update the inode so things are
** consistent if we crash before the function returns
**
** release the path so that anybody waiting on the path before
@@ -992,7 +992,7 @@ int reiserfs_get_block(struct inode *ino
if (retval)
goto failure;
}
- /* inserting indirect pointers for a hole can take a
+ /* inserting indirect pointers for a hole can take a
** long time. reschedule if needed
*/
cond_resched();
@@ -1438,7 +1438,7 @@ void reiserfs_read_locked_inode(struct i
update sd on unlink all that is required is to check for nlink
here. This bug was first found by Sizif when debugging
SquidNG/Butterfly, forgotten, and found again after Philippe
- Gramoulle <philippe.gramoulle@mmania.com> reproduced it.
+ Gramoulle <philippe.gramoulle@mmania.com> reproduced it.
More logical fix would require changes in fs/inode.c:iput() to
remove inode from hash-table _after_ fs cleaned disk stuff up and
@@ -1630,7 +1630,7 @@ int reiserfs_write_inode(struct inode *i
if (inode->i_sb->s_flags & MS_RDONLY)
return -EROFS;
/* memory pressure can sometimes initiate write_inode calls with sync == 1,
- ** these cases are just when the system needs ram, not when the
+ ** these cases are just when the system needs ram, not when the
** inode needs to reach disk for safety, and they can safely be
** ignored because the altered inode has already been logged.
*/
@@ -1747,7 +1747,7 @@ static int reiserfs_new_symlink(struct r
/* inserts the stat data into the tree, and then calls
reiserfs_new_directory (to insert ".", ".." item if new object is
directory) or reiserfs_new_symlink (to insert symlink body if new
- object is symlink) or nothing (if new object is regular file)
+ object is symlink) or nothing (if new object is regular file)
NOTE! uid and gid must already be set in the inode. If we return
non-zero due to an error, we have to drop the quota previously allocated
@@ -1755,7 +1755,7 @@ static int reiserfs_new_symlink(struct r
if we return non-zero, we also end the transaction. */
int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
struct inode *dir, int mode, const char *symname,
- /* 0 for regular, EMTRY_DIR_SIZE for dirs,
+ /* 0 for regular, EMTRY_DIR_SIZE for dirs,
strlen (symname) for symlinks) */
loff_t i_size, struct dentry *dentry,
struct inode *inode,
@@ -1790,7 +1790,7 @@ int reiserfs_new_inode(struct reiserfs_t
goto out_bad_inode;
}
if (old_format_only(sb))
- /* not a perfect generation count, as object ids can be reused, but
+ /* not a perfect generation count, as object ids can be reused, but
** this is as good as reiserfs can do right now.
** note that the private part of inode isn't filled in yet, we have
** to use the directory.
@@ -2088,7 +2088,7 @@ int reiserfs_truncate_file(struct inode
if (p_s_inode->i_size > 0) {
if ((error = grab_tail_page(p_s_inode, &page, &bh))) {
- // -ENOENT means we truncated past the end of the file,
+ // -ENOENT means we truncated past the end of the file,
// and get_block_create_0 could not find a block to read in,
// which is ok.
if (error != -ENOENT)
@@ -2100,11 +2100,11 @@ int reiserfs_truncate_file(struct inode
}
}
- /* so, if page != NULL, we have a buffer head for the offset at
- ** the end of the file. if the bh is mapped, and bh->b_blocknr != 0,
- ** then we have an unformatted node. Otherwise, we have a direct item,
- ** and no zeroing is required on disk. We zero after the truncate,
- ** because the truncate might pack the item anyway
+ /* so, if page != NULL, we have a buffer head for the offset at
+ ** the end of the file. if the bh is mapped, and bh->b_blocknr != 0,
+ ** then we have an unformatted node. Otherwise, we have a direct item,
+ ** and no zeroing is required on disk. We zero after the truncate,
+ ** because the truncate might pack the item anyway
** (it will unmap bh if it packs).
*/
/* it is enough to reserve space in transaction for 2 balancings:
@@ -2313,8 +2313,8 @@ static int map_block_for_writepage(struc
return retval;
}
-/*
- * mason@suse.com: updated in 2.5.54 to follow the same general io
+/*
+ * mason@suse.com: updated in 2.5.54 to follow the same general io
* start/recovery path as __block_write_full_page, along with special
* code to handle reiserfs tails.
*/
@@ -2454,7 +2454,7 @@ static int reiserfs_write_full_page(stru
unlock_page(page);
/*
- * since any buffer might be the only dirty buffer on the page,
+ * since any buffer might be the only dirty buffer on the page,
* the first submit_bh can bring the page out of writeback.
* be careful with the buffers.
*/
@@ -2473,8 +2473,8 @@ static int reiserfs_write_full_page(stru
if (nr == 0) {
/*
* if this page only had a direct item, it is very possible for
- * no io to be required without there being an error. Or,
- * someone else could have locked them and sent them down the
+ * no io to be required without there being an error. Or,
+ * someone else could have locked them and sent them down the
* pipe without locking the page
*/
bh = head;
@@ -2493,7 +2493,7 @@ static int reiserfs_write_full_page(stru
fail:
/* catches various errors, we need to make sure any valid dirty blocks
- * get to the media. The page is currently locked and not marked for
+ * get to the media. The page is currently locked and not marked for
* writeback
*/
ClearPageUptodate(page);
--- a/fs/reiserfs/ioctl.c 2007-06-11 14:49:05.000000000 -0400
+++ b/fs/reiserfs/ioctl.c 2007-06-11 14:49:39.000000000 -0400
@@ -166,7 +166,7 @@ static int reiserfs_unpack(struct inode
}
/* we unpack by finding the page with the tail, and calling
- ** reiserfs_prepare_write on that page. This will force a
+ ** reiserfs_prepare_write on that page. This will force a
** reiserfs_get_block to unpack the tail for us.
*/
index = inode->i_size >> PAGE_CACHE_SHIFT;
--- a/fs/reiserfs/journal.c 2007-06-11 14:49:34.000000000 -0400
+++ b/fs/reiserfs/journal.c 2007-06-11 14:50:04.000000000 -0400
@@ -1,36 +1,36 @@
/*
** Write ahead logging implementation copyright Chris Mason 2000
**
-** The background commits make this code very interelated, and
+** The background commits make this code very interelated, and
** overly complex. I need to rethink things a bit....The major players:
**
-** journal_begin -- call with the number of blocks you expect to log.
+** journal_begin -- call with the number of blocks you expect to log.
** If the current transaction is too
-** old, it will block until the current transaction is
+** old, it will block until the current transaction is
** finished, and then start a new one.
-** Usually, your transaction will get joined in with
+** Usually, your transaction will get joined in with
** previous ones for speed.
**
-** journal_join -- same as journal_begin, but won't block on the current
+** journal_join -- same as journal_begin, but won't block on the current
** transaction regardless of age. Don't ever call
-** this. Ever. There are only two places it should be
+** this. Ever. There are only two places it should be
** called from, and they are both inside this file.
**
-** journal_mark_dirty -- adds blocks into this transaction. clears any flags
+** journal_mark_dirty -- adds blocks into this transaction. clears any flags
** that might make them get sent to disk
-** and then marks them BH_JDirty. Puts the buffer head
-** into the current transaction hash.
+** and then marks them BH_JDirty. Puts the buffer head
+** into the current transaction hash.
**
** journal_end -- if the current transaction is batchable, it does nothing
** otherwise, it could do an async/synchronous commit, or
-** a full flush of all log and real blocks in the
+** a full flush of all log and real blocks in the
** transaction.
**
-** flush_old_commits -- if the current transaction is too old, it is ended and
-** commit blocks are sent to disk. Forces commit blocks
-** to disk for all backgrounded commits that have been
+** flush_old_commits -- if the current transaction is too old, it is ended and
+** commit blocks are sent to disk. Forces commit blocks
+** to disk for all backgrounded commits that have been
** around too long.
-** -- Note, if you call this as an immediate flush from
+** -- Note, if you call this as an immediate flush from
** from within kupdate, it will ignore the immediate flag
*/
@@ -214,7 +214,7 @@ static void allocate_bitmap_nodes(struct
list_add(&bn->list, &journal->j_bitmap_nodes);
journal->j_free_bitmap_nodes++;
} else {
- break; // this is ok, we'll try again when more are needed
+ break; // this is ok, we'll try again when more are needed
}
}
}
@@ -284,7 +284,7 @@ static int free_bitmap_nodes(struct supe
}
/*
-** get memory for JOURNAL_NUM_BITMAPS worth of bitmaps.
+** get memory for JOURNAL_NUM_BITMAPS worth of bitmaps.
** jb_array is the array to be filled in.
*/
int reiserfs_allocate_list_bitmaps(struct super_block *p_s_sb,
@@ -316,7 +316,7 @@ int reiserfs_allocate_list_bitmaps(struc
}
/*
-** find an available list bitmap. If you can't find one, flush a commit list
+** find an available list bitmap. If you can't find one, flush a commit list
** and try again
*/
static struct reiserfs_list_bitmap *get_list_bitmap(struct super_block *p_s_sb,
@@ -349,7 +349,7 @@ static struct reiserfs_list_bitmap *get_
return jb;
}
-/*
+/*
** allocates a new chunk of X nodes, and links them all together as a list.
** Uses the cnode->next and cnode->prev pointers
** returns NULL on failure
@@ -377,7 +377,7 @@ static struct reiserfs_journal_cnode *al
}
/*
-** pulls a cnode off the free list, or returns NULL on failure
+** pulls a cnode off the free list, or returns NULL on failure
*/
static struct reiserfs_journal_cnode *get_cnode(struct super_block *p_s_sb)
{
@@ -404,7 +404,7 @@ static struct reiserfs_journal_cnode *ge
}
/*
-** returns a cnode to the free list
+** returns a cnode to the free list
*/
static void free_cnode(struct super_block *p_s_sb,
struct reiserfs_journal_cnode *cn)
@@ -1166,8 +1166,8 @@ static int flush_commit_list(struct supe
}
/*
-** flush_journal_list frequently needs to find a newer transaction for a given block. This does that, or
-** returns NULL if it can't find anything
+** flush_journal_list frequently needs to find a newer transaction for a given block. This does that, or
+** returns NULL if it can't find anything
*/
static struct reiserfs_journal_list *find_newer_jl_for_cn(struct
reiserfs_journal_cnode
@@ -1309,8 +1309,8 @@ static int update_journal_header_block(s
return _update_journal_header_block(p_s_sb, offset, trans_id);
}
-/*
-** flush any and all journal lists older than you are
+/*
+** flush any and all journal lists older than you are
** can only be called from flush_journal_list
*/
static int flush_older_journal_lists(struct super_block *p_s_sb,
@@ -1356,8 +1356,8 @@ static void del_from_work_list(struct su
** always set flushall to 1, unless you are calling from inside
** flush_journal_list
**
-** IMPORTANT. This can only be called while there are no journal writers,
-** and the journal is locked. That means it can only be called from
+** IMPORTANT. This can only be called while there are no journal writers,
+** and the journal is locked. That means it can only be called from
** do_journal_end, or by journal_release
*/
static int flush_journal_list(struct super_block *s,
@@ -1403,7 +1403,7 @@ static int flush_journal_list(struct sup
goto flush_older_and_return;
}
- /* start by putting the commit list on disk. This will also flush
+ /* start by putting the commit list on disk. This will also flush
** the commit lists of any olders transactions
*/
flush_commit_list(s, jl, 1);
@@ -1418,8 +1418,8 @@ static int flush_journal_list(struct sup
goto flush_older_and_return;
}
- /* loop through each cnode, see if we need to write it,
- ** or wait on a more recent transaction, or just ignore it
+ /* loop through each cnode, see if we need to write it,
+ ** or wait on a more recent transaction, or just ignore it
*/
if (atomic_read(&(journal->j_wcount)) != 0) {
reiserfs_panic(s, "journal-844", "journal list is flushing, "
@@ -1447,8 +1447,8 @@ static int flush_journal_list(struct sup
if (!pjl && cn->bh) {
saved_bh = cn->bh;
- /* we do this to make sure nobody releases the buffer while
- ** we are working with it
+ /* we do this to make sure nobody releases the buffer while
+ ** we are working with it
*/
get_bh(saved_bh);
@@ -1471,8 +1471,8 @@ static int flush_journal_list(struct sup
goto free_cnode;
}
- /* bh == NULL when the block got to disk on its own, OR,
- ** the block got freed in a future transaction
+ /* bh == NULL when the block got to disk on its own, OR,
+ ** the block got freed in a future transaction
*/
if (saved_bh == NULL) {
goto free_cnode;
@@ -1559,7 +1559,7 @@ static int flush_journal_list(struct sup
__FUNCTION__);
flush_older_and_return:
- /* before we can update the journal header block, we _must_ flush all
+ /* before we can update the journal header block, we _must_ flush all
** real blocks from all older transactions to disk. This is because
** once the header block is updated, this transaction will not be
** replayed after a crash
@@ -1569,7 +1569,7 @@ static int flush_journal_list(struct sup
}
err = journal->j_errno;
- /* before we can remove everything from the hash tables for this
+ /* before we can remove everything from the hash tables for this
** transaction, we must make sure it can never be replayed
**
** since we are only called from do_journal_end, we know for sure there
@@ -1989,9 +1989,9 @@ static int journal_compare_desc_commit(s
return 0;
}
-/* returns 0 if it did not find a description block
+/* 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
+** returns 1 if both desc and commit were valid
*/
static int journal_transaction_is_valid(struct super_block *p_s_sb,
struct buffer_head *d_bh,
@@ -2352,8 +2352,8 @@ static int journal_read(struct super_blo
bdevname(journal->j_dev_bd, b));
start = get_seconds();
- /* step 1, read in the journal header block. Check the transaction it says
- ** is the first unflushed, and if that transaction is not valid,
+ /* step 1, read in the journal header block. Check the transaction it says
+ ** is the first unflushed, and if that transaction is not valid,
** replay is done
*/
journal->j_header_bh = journal_bread(p_s_sb,
@@ -2378,8 +2378,8 @@ static int journal_read(struct super_blo
le32_to_cpu(jh->j_last_flush_trans_id));
valid_journal_header = 1;
- /* now, we try to read the first unflushed offset. If it is not valid,
- ** there is nothing more we can do, and it makes no sense to read
+ /* now, we try to read the first unflushed offset. If it is not valid,
+ ** there is nothing more we can do, and it makes no sense to read
** through the whole log.
*/
d_bh =
@@ -2749,7 +2749,7 @@ int journal_init(struct super_block *p_s
}
if (!journal->j_trans_max) {
- /*we have the file system was created by old version of mkreiserfs
+ /*we have the file system was created by old version of mkreiserfs
so this field contains zero value */
journal->j_trans_max = JOURNAL_TRANS_MAX_DEFAULT;
journal->j_max_batch = JOURNAL_MAX_BATCH_DEFAULT;
@@ -2876,7 +2876,7 @@ int journal_transaction_should_end(struc
return 0;
}
-/* this must be called inside a transaction, and requires the
+/* this must be called inside a transaction, and requires the
** kernel_lock to be held
*/
void reiserfs_block_writes(struct reiserfs_transaction_handle *th)
@@ -2997,7 +2997,7 @@ static int do_journal_begin_r(struct rei
now = get_seconds();
/* if there is no room in the journal OR
- ** if this transaction is too old, and we weren't called joinable, wait for it to finish before beginning
+ ** if this transaction is too old, and we weren't called joinable, wait for it to finish before beginning
** we don't sleep if there aren't other writers
*/
@@ -3197,7 +3197,7 @@ int journal_begin(struct reiserfs_transa
**
** if it was dirty, cleans and files onto the clean list. I can't let it be dirty again until the
** transaction is committed.
-**
+**
** if j_len, is bigger than j_len_alloc, it pushes j_len_alloc to 10 + j_len.
*/
int journal_mark_dirty(struct reiserfs_transaction_handle *th,
@@ -3247,7 +3247,7 @@ int journal_mark_dirty(struct reiserfs_t
atomic_read(&(journal->j_wcount)));
return 1;
}
- /* this error means I've screwed up, and we've overflowed the transaction.
+ /* this error means I've screwed up, and we've overflowed the transaction.
** Nothing can be done here, except make the FS readonly or panic.
*/
if (journal->j_len >= journal->j_trans_max) {
@@ -3336,7 +3336,7 @@ int journal_end(struct reiserfs_transact
}
}
-/* removes from the current transaction, relsing and descrementing any counters.
+/* removes from the current transaction, relsing and descrementing any counters.
** also files the removed buffer directly onto the clean list
**
** called by journal_mark_freed when a block has been deleted
@@ -3434,7 +3434,7 @@ static int can_dirty(struct reiserfs_jou
}
/* syncs the commit blocks, but does not force the real buffers to disk
-** will wait until the current transaction is done/committed before returning
+** will wait until the current transaction is done/committed before returning
*/
int journal_end_sync(struct reiserfs_transaction_handle *th,
struct super_block *p_s_sb, unsigned long nblocks)
@@ -3516,13 +3516,13 @@ int reiserfs_flush_old_commits(struct su
/*
** returns 0 if do_journal_end should return right away, returns 1 if do_journal_end should finish the commit
-**
-** if the current transaction is too old, but still has writers, this will wait on j_join_wait until all
+**
+** if the current transaction is too old, but still has writers, this will wait on j_join_wait until all
** the writers are done. By the time it wakes up, the transaction it was called has already ended, so it just
** flushes the commit list and returns 0.
**
** Won't batch when flush or commit_now is set. Also won't batch when others are waiting on j_join_wait.
-**
+**
** Note, we can't allow the journal_end to proceed while there are still writers in the log.
*/
static int check_journal_end(struct reiserfs_transaction_handle *th,
@@ -3550,7 +3550,7 @@ static int check_journal_end(struct reis
atomic_dec(&(journal->j_wcount));
}
- /* BUG, deal with case where j_len is 0, but people previously freed blocks need to be released
+ /* BUG, deal with case where j_len is 0, but people previously freed blocks need to be released
** will be dealt with by next transaction that actually writes something, but should be taken
** care of in this trans
*/
@@ -3559,7 +3559,7 @@ static int check_journal_end(struct reis
/* if wcount > 0, and we are called to with flush or commit_now,
** we wait on j_join_wait. We will wake up when the last writer has
** finished the transaction, and started it on its way to the disk.
- ** Then, we flush the commit or journal list, and just return 0
+ ** Then, we flush the commit or journal list, and just return 0
** because the rest of journal end was already done for this transaction.
*/
if (atomic_read(&(journal->j_wcount)) > 0) {
@@ -3630,7 +3630,7 @@ static int check_journal_end(struct reis
/*
** Does all the work that makes deleting blocks safe.
** when deleting a block mark BH_JNew, just remove it from the current transaction, clean it's buffer_head and move on.
-**
+**
** otherwise:
** set a bit for the block in the journal bitmap. That will prevent it from being allocated for unformatted nodes
** before this transaction has finished.
@@ -3687,7 +3687,7 @@ int journal_mark_freed(struct reiserfs_t
set_bit(BLOCK_FREED, &cn->state);
if (cn->bh) {
if (!cleaned) {
- /* remove_from_transaction will brelse the buffer if it was
+ /* remove_from_transaction will brelse the buffer if it was
** in the current trans
*/
clear_buffer_journal_dirty(cn->
@@ -3839,7 +3839,7 @@ extern struct tree_balance *cur_tb;
** be written to disk while we are altering it. So, we must:
** clean it
** wait on it.
-**
+**
*/
int reiserfs_prepare_for_journal(struct super_block *p_s_sb,
struct buffer_head *bh, int wait)
@@ -3881,7 +3881,7 @@ static void flush_old_journal_lists(stru
}
}
-/*
+/*
** long and ugly. If flush, will not return until all commit
** blocks and all real buffers in the trans are on disk.
** If no_async, won't return until all commit blocks are on disk.
@@ -3942,7 +3942,7 @@ static int do_journal_end(struct reiserf
wait_on_commit = 1;
}
- /* check_journal_end locks the journal, and unlocks if it does not return 1
+ /* check_journal_end locks the journal, and unlocks if it does not return 1
** it tells us if we should continue with the journal_end, or just return
*/
if (!check_journal_end(th, p_s_sb, nblocks, flags)) {
@@ -4039,7 +4039,7 @@ static int do_journal_end(struct reiserf
last_cn->next = jl_cn;
}
last_cn = jl_cn;
- /* make sure the block we are trying to log is not a block
+ /* make sure the block we are trying to log is not a block
of journal or reserved area */
if (is_block_in_log_or_reserved_area
@@ -4186,9 +4186,9 @@ static int do_journal_end(struct reiserf
} else if (!(jl->j_state & LIST_COMMIT_PENDING))
queue_delayed_work(commit_wq, &journal->j_work, HZ / 10);
- /* if the next transaction has any chance of wrapping, flush
- ** transactions that might get overwritten. If any journal lists are very
- ** old flush them as well.
+ /* if the next transaction has any chance of wrapping, flush
+ ** transactions that might get overwritten. If any journal lists are very
+ ** old flush them as well.
*/
first_jl:
list_for_each_safe(entry, safe, &journal->j_journal_list) {
--- a/fs/reiserfs/lbalance.c 2007-06-11 14:49:35.000000000 -0400
+++ b/fs/reiserfs/lbalance.c 2007-06-11 14:49:39.000000000 -0400
@@ -119,8 +119,8 @@ static void leaf_copy_dir_entries(struct
DEH_SIZE * copy_count + copy_records_len);
}
-/* Copy the first (if last_first == FIRST_TO_LAST) or last (last_first == LAST_TO_FIRST) item or
- part of it or nothing (see the return 0 below) from SOURCE to the end
+/* Copy the first (if last_first == FIRST_TO_LAST) or last (last_first == LAST_TO_FIRST) item or
+ part of it or nothing (see the return 0 below) from SOURCE to the end
(if last_first) or beginning (!last_first) of the DEST */
/* returns 1 if anything was copied, else 0 */
static int leaf_copy_boundary_item(struct buffer_info *dest_bi,
@@ -396,7 +396,7 @@ static void leaf_item_bottle(struct buff
else {
struct item_head n_ih;
- /* copy part of the body of the item number 'item_num' of SOURCE to the end of the DEST
+ /* copy part of the body of the item number 'item_num' of SOURCE to the end of the DEST
part defined by 'cpy_bytes'; create new item header; change old item_header (????);
n_ih = new item_header;
*/
@@ -426,7 +426,7 @@ static void leaf_item_bottle(struct buff
else {
struct item_head n_ih;
- /* copy part of the body of the item number 'item_num' of SOURCE to the begin of the DEST
+ /* copy part of the body of the item number 'item_num' of SOURCE to the begin of the DEST
part defined by 'cpy_bytes'; create new item header;
n_ih = new item_header;
*/
@@ -724,7 +724,7 @@ int leaf_shift_right(struct tree_balance
static void leaf_delete_items_entirely(struct buffer_info *bi,
int first, int del_num);
/* If del_bytes == -1, starting from position 'first' delete del_num items in whole in buffer CUR.
- If not.
+ If not.
If last_first == 0. Starting from position 'first' delete del_num-1 items in whole. Delete part of body of
the first item. Part defined by del_bytes. Don't delete first item header
If last_first == 1. Starting from position 'first+1' delete del_num-1 items in whole. Delete part of body of
@@ -783,7 +783,7 @@ void leaf_delete_items(struct buffer_inf
/* len = body len of item */
len = ih_item_len(ih);
- /* delete the part of the last item of the bh
+ /* delete the part of the last item of the bh
do not delete item header
*/
leaf_cut_from_buffer(cur_bi, B_NR_ITEMS(bh) - 1,
@@ -865,7 +865,7 @@ void leaf_insert_into_buf(struct buffer_
}
}
-/* paste paste_size bytes to affected_item_num-th item.
+/* paste paste_size bytes to affected_item_num-th item.
When item is a directory, this only prepare space for new entries */
void leaf_paste_in_buffer(struct buffer_info *bi, int affected_item_num,
int pos_in_item, int paste_size,
@@ -1022,7 +1022,7 @@ static int leaf_cut_entries(struct buffe
/* when cut item is part of regular file
pos_in_item - first byte that must be cut
cut_size - number of bytes to be cut beginning from pos_in_item
-
+
when cut item is part of directory
pos_in_item - number of first deleted entry
cut_size - count of deleted entries
@@ -1274,7 +1274,7 @@ void leaf_paste_entries(struct buffer_he
/* change item key if necessary (when we paste before 0-th entry */
if (!before) {
set_le_ih_k_offset(ih, deh_offset(new_dehs));
-/* memcpy (&ih->ih_key.k_offset,
+/* memcpy (&ih->ih_key.k_offset,
&new_dehs->deh_offset, SHORT_KEY_SIZE);*/
}
#ifdef CONFIG_REISERFS_CHECK
--- a/fs/reiserfs/namei.c 2007-06-11 14:49:38.000000000 -0400
+++ b/fs/reiserfs/namei.c 2007-06-11 14:49:39.000000000 -0400
@@ -106,7 +106,7 @@ key of the first directory entry in it.
This function first calls search_by_key, then, if item whose first
entry matches is not found it looks for the entry inside directory
item found by search_by_key. Fills the path to the entry, and to the
-entry position in the item
+entry position in the item
*/
@@ -370,7 +370,7 @@ static struct dentry *reiserfs_lookup(st
return d_splice_alias(inode, dentry);
}
-/*
+/*
** looks up the dentry of the parent directory for child.
** taken from ext2_get_parent
*/
@@ -409,7 +409,7 @@ struct dentry *reiserfs_get_parent(struc
return parent;
}
-/* add entry to the directory (entry can be hidden).
+/* add entry to the directory (entry can be hidden).
insert definition of when hidden directories are used here -Hans
@@ -567,7 +567,7 @@ static int drop_new_inode(struct inode *
return 0;
}
-/* utility function that does setup for reiserfs_new_inode.
+/* utility function that does setup for reiserfs_new_inode.
** DQUOT_INIT needs lots of credits so it's better to have it
** outside of a transaction, so we had to pull some bits of
** reiserfs_new_inode out into this func.
@@ -822,7 +822,7 @@ static inline int reiserfs_empty_dir(str
{
/* we can cheat because an old format dir cannot have
** EMPTY_DIR_SIZE, and a new format dir cannot have
- ** EMPTY_DIR_SIZE_V1. So, if the inode is either size,
+ ** EMPTY_DIR_SIZE_V1. So, if the inode is either size,
** regardless of disk format version, the directory is empty.
*/
if (inode->i_size != EMPTY_DIR_SIZE &&
@@ -1162,7 +1162,7 @@ static int reiserfs_link(struct dentry *
return retval;
}
-// de contains information pointing to an entry which
+// de contains information pointing to an entry which
static int de_still_valid(const char *name, int len,
struct reiserfs_dir_entry *de)
{
@@ -1206,10 +1206,10 @@ static void set_ino_in_dir_entry(struct
de->de_deh[de->de_entry_num].deh_objectid = key->k_objectid;
}
-/*
+/*
* process, that is going to call fix_nodes/do_balance must hold only
* one path. If it holds 2 or more, it can get into endless waiting in
- * get_empty_nodes or its clones
+ * get_empty_nodes or its clones
*/
static int reiserfs_rename(struct inode *old_dir, struct dentry *old_dentry,
struct inode *new_dir, struct dentry *new_dentry)
@@ -1263,7 +1263,7 @@ static int reiserfs_rename(struct inode
old_inode_mode = old_inode->i_mode;
if (S_ISDIR(old_inode_mode)) {
- // make sure, that directory being renamed has correct ".."
+ // make sure, that directory being renamed has correct ".."
// and that its new parent directory has not too many links
// already
@@ -1274,8 +1274,8 @@ static int reiserfs_rename(struct inode
}
}
- /* directory is renamed, its parent directory will be changed,
- ** so find ".." entry
+ /* directory is renamed, its parent directory will be changed,
+ ** so find ".." entry
*/
dot_dot_de.de_gen_number_bit_string = NULL;
retval =
@@ -1385,9 +1385,9 @@ static int reiserfs_rename(struct inode
this stuff, yes? Then, having
gathered everything into RAM we
should lock the buffers, yes? -Hans */
- /* probably. our rename needs to hold more
- ** than one path at once. The seals would
- ** have to be written to deal with multi-path
+ /* probably. our rename needs to hold more
+ ** than one path at once. The seals would
+ ** have to be written to deal with multi-path
** issues -chris
*/
/* sanity checking before doing the rename - avoid races many
@@ -1465,7 +1465,7 @@ static int reiserfs_rename(struct inode
}
if (S_ISDIR(old_inode_mode)) {
- // adjust ".." of renamed directory
+ // adjust ".." of renamed directory
set_ino_in_dir_entry(&dot_dot_de, INODE_PKEY(new_dir));
journal_mark_dirty(&th, new_dir->i_sb, dot_dot_de.de_bh);
--- a/fs/reiserfs/objectid.c 2007-06-11 14:49:35.000000000 -0400
+++ b/fs/reiserfs/objectid.c 2007-06-11 14:49:39.000000000 -0400
@@ -181,7 +181,7 @@ int reiserfs_convert_objectid_map_v1(str
if (cur_size > new_size) {
/* mark everyone used that was listed as free at the end of the objectid
- ** map
+ ** map
*/
objectid_map[new_size - 1] = objectid_map[cur_size - 1];
set_sb_oid_cursize(disk_sb, new_size);
--- a/fs/reiserfs/prints.c 2007-06-11 14:49:35.000000000 -0400
+++ b/fs/reiserfs/prints.c 2007-06-11 14:50:01.000000000 -0400
@@ -181,11 +181,11 @@ static char *is_there_reiserfs_struct(ch
appropriative printk. With this reiserfs_warning you can use format
specification for complex structures like you used to do with
printfs for integers, doubles and pointers. For instance, to print
- out key structure you have to write just:
- reiserfs_warning ("bad key %k", key);
- instead of
- printk ("bad key %lu %lu %lu %lu", key->k_dir_id, key->k_objectid,
- key->k_offset, key->k_uniqueness);
+ out key structure you have to write just:
+ reiserfs_warning ("bad key %k", key);
+ instead of
+ printk ("bad key %lu %lu %lu %lu", key->k_dir_id, key->k_objectid,
+ key->k_offset, key->k_uniqueness);
*/
static void prepare_error_buf(const char *fmt, va_list args)
@@ -247,11 +247,11 @@ static void prepare_error_buf(const char
}
/* in addition to usual conversion specifiers this accepts reiserfs
- specific conversion specifiers:
- %k to print little endian key,
- %K to print cpu key,
+ specific conversion specifiers:
+ %k to print little endian key,
+ %K to print cpu key,
%h to print item_head,
- %t to print directory entry
+ %t to print directory entry
%z to print block head (arg must be struct buffer_head *
%b to print buffer_head
*/
@@ -317,17 +317,17 @@ void reiserfs_debug(struct super_block *
maintainer-errorid. Don't bother with reusing errorids, there are
lots of numbers out there.
- Example:
-
+ Example:
+
reiserfs_panic(
p_sb, "reiser-29: reiserfs_new_blocknrs: "
"one of search_start or rn(%d) is equal to MAX_B_NUM,"
- "which means that we are optimizing location based on the bogus location of a temp buffer (%p).",
+ "which means that we are optimizing location based on the bogus location of a temp buffer (%p).",
rn, bh
);
Regular panic()s sometimes clear the screen before the message can
- be read, thus the need for the while loop.
+ be read, thus the need for the while loop.
Numbering scheme for panic used by Vladimir and Anatoly( Hans completely ignores this scheme, and considers it
pointless complexity):
--- a/fs/reiserfs/procfs.c 2007-06-11 14:49:34.000000000 -0400
+++ b/fs/reiserfs/procfs.c 2007-06-11 14:49:39.000000000 -0400
@@ -645,7 +645,7 @@ int reiserfs_global_version_in_proc(char
*
*/
-/*
+/*
* Make Linus happy.
* Local variables:
* c-indentation-style: "K&R"
--- a/fs/reiserfs/resize.c 2007-06-11 14:49:05.000000000 -0400
+++ b/fs/reiserfs/resize.c 2007-06-11 14:49:39.000000000 -0400
@@ -1,8 +1,8 @@
-/*
+/*
* Copyright 2000 by Hans Reiser, licensing governed by reiserfs/README
*/
-/*
+/*
* Written by Alexander Zarochentcev.
*
* The kernel part of the (on-line) reiserfs resizer.
@@ -100,7 +100,7 @@ int reiserfs_resize(struct super_block *
memcpy(jbitmap[i].bitmaps, jb->bitmaps, copy_size);
/* just in case vfree schedules on us, copy the new
- ** pointer into the journal struct before freeing the
+ ** pointer into the journal struct before freeing the
** old one
*/
node_tmp = jb->bitmaps;
--- a/fs/reiserfs/stree.c 2007-06-11 14:49:39.000000000 -0400
+++ b/fs/reiserfs/stree.c 2007-06-11 14:50:04.000000000 -0400
@@ -77,7 +77,7 @@ inline void copy_item_head(struct item_h
/* k1 is pointer to on-disk structure which is stored in little-endian
form. k2 is pointer to cpu variable. For key of items of the same
object this returns 0.
- Returns: -1 if key1 < key2
+ Returns: -1 if key1 < key2
0 if key1 == key2
1 if key1 > key2 */
inline int comp_short_keys(const struct reiserfs_key *le_key,
@@ -890,7 +890,7 @@ static inline int prepare_for_direct_ite
}
// new file gets truncated
if (get_inode_item_key_version(inode) == KEY_FORMAT_3_6) {
- //
+ //
round_len = ROUND_UP(new_file_length);
/* this was n_new_file_length < le_ih ... */
if (round_len < le_ih_k_offset(le_ih)) {
@@ -1446,7 +1446,7 @@ static int maybe_indirect_to_direct(stru
if (atomic_read(&p_s_inode->i_count) > 1 ||
!tail_has_to_be_packed(p_s_inode) ||
!page || (REISERFS_I(p_s_inode)->i_flags & i_nopack_mask)) {
- // leave tail in an unformatted node
+ // leave tail in an unformatted node
*p_c_mode = M_SKIP_BALANCING;
cut_bytes =
n_block_size - (n_new_file_size & (n_block_size - 1));
@@ -1829,7 +1829,7 @@ int reiserfs_do_truncate(struct reiserfs
/* While there are bytes to truncate and previous file item is presented in the tree. */
/*
- ** This loop could take a really long time, and could log
+ ** This loop could take a really long time, and could log
** many more blocks than a transaction can hold. So, we do a polite
** journal end here, and if the transaction needs ending, we make
** sure the file is consistent before ending the current trans
--- a/fs/reiserfs/super.c 2007-06-11 14:49:37.000000000 -0400
+++ b/fs/reiserfs/super.c 2007-06-11 14:49:39.000000000 -0400
@@ -739,7 +739,7 @@ static int reiserfs_getopt(struct super_
char **opt_arg, unsigned long *bit_flags)
{
char *p;
- /* foo=bar,
+ /* foo=bar,
^ ^ ^
| | +-- option_end
| +-- arg_start
@@ -1280,7 +1280,7 @@ static int read_super_block(struct super
}
//
// ok, reiserfs signature (old or new) found in at the given offset
- //
+ //
fs_blocksize = sb_blocksize(rs);
brelse(bh);
sb_set_blocksize(s, fs_blocksize);
@@ -1466,8 +1466,8 @@ static int what_hash(struct super_block
code = find_hash_out(s);
if (code != UNSET_HASH && reiserfs_hash_detect(s)) {
- /* detection has found the hash, and we must check against the
- ** mount options
+ /* detection has found the hash, and we must check against the
+ ** mount options
*/
if (reiserfs_rupasov_hash(s) && code != YURA_HASH) {
reiserfs_warning(s, "reiserfs-2507",
@@ -1499,7 +1499,7 @@ static int what_hash(struct super_block
}
}
- /* if we are mounted RW, and we have a new valid hash code, update
+ /* if we are mounted RW, and we have a new valid hash code, update
** the super
*/
if (code != UNSET_HASH &&
--- a/fs/reiserfs/tail_conversion.c 2007-06-11 14:49:35.000000000 -0400
+++ b/fs/reiserfs/tail_conversion.c 2007-06-11 14:50:04.000000000 -0400
@@ -46,7 +46,7 @@ int direct2indirect(struct reiserfs_tran
/* Set the key to search for the place for new unfm pointer */
make_cpu_key(&end_key, inode, tail_offset, TYPE_INDIRECT, 4);
- // FIXME: we could avoid this
+ // FIXME: we could avoid this
if (search_for_position_by_key(sb, &end_key, path) == POSITION_FOUND) {
reiserfs_error(sb, "PAP-14030",
"pasted or inserted byte exists in "
--- a/include/linux/reiserfs_fs_sb.h 2007-06-11 14:49:37.000000000 -0400
+++ b/include/linux/reiserfs_fs_sb.h 2007-06-11 14:49:39.000000000 -0400
@@ -14,7 +14,7 @@ typedef enum {
} reiserfs_super_block_flags;
/* struct reiserfs_super_block accessors/mutators
- * since this is a disk structure, it will always be in
+ * since this is a disk structure, it will always be in
* little endian format. */
#define sb_block_count(sbp) (le32_to_cpu((sbp)->s_v1.s_block_count))
#define set_sb_block_count(sbp,v) ((sbp)->s_v1.s_block_count = cpu_to_le32(v))
@@ -80,16 +80,16 @@ typedef enum {
/* LOGGING -- */
-/* These all interelate for performance.
+/* These all interelate for performance.
**
-** If the journal block count is smaller than n transactions, you lose speed.
+** If the journal block count is smaller than n transactions, you lose speed.
** I don't know what n is yet, I'm guessing 8-16.
**
** typical transaction size depends on the application, how often fsync is
-** called, and how many metadata blocks you dirty in a 30 second period.
+** called, and how many metadata blocks you dirty in a 30 second period.
** The more small files (<16k) you use, the larger your transactions will
** be.
-**
+**
** If your journal fills faster than dirty buffers get flushed to disk, it must flush them before allowing the journal
** to wrap, which slows things down. If you need high speed meta data updates, the journal should be big enough
** to prevent wrapping before dirty meta blocks get to disk.
@@ -239,7 +239,7 @@ struct reiserfs_journal {
struct reiserfs_list_bitmap j_list_bitmap[JOURNAL_NUM_BITMAPS]; /* array of bitmaps to record the deleted blocks */
struct reiserfs_journal_cnode *j_hash_table[JOURNAL_HASH_SIZE]; /* hash table for real buffer heads in current trans */
- struct reiserfs_journal_cnode *j_list_hash_table[JOURNAL_HASH_SIZE]; /* hash table for all the real buffer heads in all
+ struct reiserfs_journal_cnode *j_list_hash_table[JOURNAL_HASH_SIZE]; /* hash table for all the real buffer heads in all
the transactions */
struct list_head j_prealloc_list; /* list of inodes which have preallocated blocks */
int j_persistent_trans;
@@ -427,7 +427,7 @@ enum reiserfs_mount_options {
partition will be dealt with in a
manner of 3.5.x */
-/* -o hash={tea, rupasov, r5, detect} is meant for properly mounting
+/* -o hash={tea, rupasov, r5, detect} is meant for properly mounting
** reiserfs disks from 3.5.19 or earlier. 99% of the time, this option
** is not required. If the normal autodection code can't determine which
** hash to use (because both hashes had the same value for a file)
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 43+ messages in thread
* [patch 26/40] reiserfs: rename p_s_bh to bh
2007-06-11 19:03 [patch 00/40] reiserfs: patch queue (v2) jeffm
` (23 preceding siblings ...)
2007-06-11 19:03 ` [patch 24/40] reiserfs: strip trailing whitespace jeffm
@ 2007-06-11 19:03 ` jeffm
2007-06-11 19:03 ` [patch 27/40] reiserfs: rename p_s_inode to inode jeffm
` (15 subsequent siblings)
40 siblings, 0 replies; 43+ messages in thread
From: jeffm @ 2007-06-11 19:03 UTC (permalink / raw)
To: ReiserFS Mailing List
[-- Attachment #1: reiserfs-rename-p_s_bh.diff --]
[-- Type: text/plain, Size: 18696 bytes --]
This patch is a simple s/p_s_bh/bh/g to the reiserfs code. This is the second
in a series of patches to rip out some of the awful variable naming in
reiserfs.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
fs/reiserfs/fix_node.c | 88 ++++++++++++++++++++++----------------------
fs/reiserfs/stree.c | 62 +++++++++++++++----------------
include/linux/reiserfs_fs.h | 36 +++++++++---------
3 files changed, 93 insertions(+), 93 deletions(-)
--- a/fs/reiserfs/fix_node.c 2007-06-11 14:49:39.000000000 -0400
+++ b/fs/reiserfs/fix_node.c 2007-06-11 14:50:03.000000000 -0400
@@ -1885,7 +1885,7 @@ static int check_balance(int mode,
/* Check whether parent at the path is the really parent of the current node.*/
static int get_direct_parent(struct tree_balance *p_s_tb, int n_h)
{
- struct buffer_head *p_s_bh;
+ struct buffer_head *bh;
struct treepath *p_s_path = p_s_tb->tb_path;
int n_position,
n_path_offset = PATH_H_PATH_OFFSET(p_s_tb->tb_path, n_h);
@@ -1907,21 +1907,21 @@ static int get_direct_parent(struct tree
}
if (!B_IS_IN_TREE
- (p_s_bh = PATH_OFFSET_PBUFFER(p_s_path, n_path_offset - 1)))
+ (bh = PATH_OFFSET_PBUFFER(p_s_path, n_path_offset - 1)))
return REPEAT_SEARCH; /* Parent in the path is not in the tree. */
if ((n_position =
PATH_OFFSET_POSITION(p_s_path,
- n_path_offset - 1)) > B_NR_ITEMS(p_s_bh))
+ n_path_offset - 1)) > B_NR_ITEMS(bh))
return REPEAT_SEARCH;
- if (B_N_CHILD_NUM(p_s_bh, n_position) !=
+ if (B_N_CHILD_NUM(bh, n_position) !=
PATH_OFFSET_PBUFFER(p_s_path, n_path_offset)->b_blocknr)
/* Parent in the path is not parent of the current node in the tree. */
return REPEAT_SEARCH;
- if (buffer_locked(p_s_bh)) {
- __wait_on_buffer(p_s_bh);
+ if (buffer_locked(bh)) {
+ __wait_on_buffer(bh);
if (FILESYSTEM_CHANGED_TB(p_s_tb))
return REPEAT_SEARCH;
}
@@ -1941,29 +1941,29 @@ static int get_neighbors(struct tree_bal
n_path_offset = PATH_H_PATH_OFFSET(p_s_tb->tb_path, n_h + 1);
unsigned long n_son_number;
struct super_block *sb = p_s_tb->tb_sb;
- struct buffer_head *p_s_bh;
+ struct buffer_head *bh;
PROC_INFO_INC(sb, get_neighbors[n_h]);
if (p_s_tb->lnum[n_h]) {
/* We need left neighbor to balance S[n_h]. */
PROC_INFO_INC(sb, need_l_neighbor[n_h]);
- p_s_bh = PATH_OFFSET_PBUFFER(p_s_tb->tb_path, n_path_offset);
+ bh = PATH_OFFSET_PBUFFER(p_s_tb->tb_path, n_path_offset);
- RFALSE(p_s_bh == p_s_tb->FL[n_h] &&
+ RFALSE(bh == p_s_tb->FL[n_h] &&
!PATH_OFFSET_POSITION(p_s_tb->tb_path, n_path_offset),
"PAP-8270: invalid position in the parent");
n_child_position =
- (p_s_bh ==
+ (bh ==
p_s_tb->FL[n_h]) ? p_s_tb->lkey[n_h] : B_NR_ITEMS(p_s_tb->
FL[n_h]);
n_son_number = B_N_CHILD_NUM(p_s_tb->FL[n_h], n_child_position);
- p_s_bh = sb_bread(sb, n_son_number);
- if (!p_s_bh)
+ bh = sb_bread(sb, n_son_number);
+ if (!bh)
return IO_ERROR;
if (FILESYSTEM_CHANGED_TB(p_s_tb)) {
- brelse(p_s_bh);
+ brelse(bh);
PROC_INFO_INC(sb, get_neighbors_restart[n_h]);
return REPEAT_SEARCH;
}
@@ -1971,48 +1971,48 @@ static int get_neighbors(struct tree_bal
RFALSE(!B_IS_IN_TREE(p_s_tb->FL[n_h]) ||
n_child_position > B_NR_ITEMS(p_s_tb->FL[n_h]) ||
B_N_CHILD_NUM(p_s_tb->FL[n_h], n_child_position) !=
- p_s_bh->b_blocknr, "PAP-8275: invalid parent");
- RFALSE(!B_IS_IN_TREE(p_s_bh), "PAP-8280: invalid child");
+ bh->b_blocknr, "PAP-8275: invalid parent");
+ RFALSE(!B_IS_IN_TREE(bh), "PAP-8280: invalid child");
RFALSE(!n_h &&
- B_FREE_SPACE(p_s_bh) !=
- MAX_CHILD_SIZE(p_s_bh) -
+ B_FREE_SPACE(bh) !=
+ MAX_CHILD_SIZE(bh) -
dc_size(B_N_CHILD(p_s_tb->FL[0], n_child_position)),
"PAP-8290: invalid child size of left neighbor");
brelse(p_s_tb->L[n_h]);
- p_s_tb->L[n_h] = p_s_bh;
+ p_s_tb->L[n_h] = bh;
}
if (p_s_tb->rnum[n_h]) { /* We need right neighbor to balance S[n_path_offset]. */
PROC_INFO_INC(sb, need_r_neighbor[n_h]);
- p_s_bh = PATH_OFFSET_PBUFFER(p_s_tb->tb_path, n_path_offset);
+ bh = PATH_OFFSET_PBUFFER(p_s_tb->tb_path, n_path_offset);
- RFALSE(p_s_bh == p_s_tb->FR[n_h] &&
+ RFALSE(bh == p_s_tb->FR[n_h] &&
PATH_OFFSET_POSITION(p_s_tb->tb_path,
n_path_offset) >=
- B_NR_ITEMS(p_s_bh),
+ B_NR_ITEMS(bh),
"PAP-8295: invalid position in the parent");
n_child_position =
- (p_s_bh == p_s_tb->FR[n_h]) ? p_s_tb->rkey[n_h] + 1 : 0;
+ (bh == p_s_tb->FR[n_h]) ? p_s_tb->rkey[n_h] + 1 : 0;
n_son_number = B_N_CHILD_NUM(p_s_tb->FR[n_h], n_child_position);
- p_s_bh = sb_bread(sb, n_son_number);
- if (!p_s_bh)
+ bh = sb_bread(sb, n_son_number);
+ if (!bh)
return IO_ERROR;
if (FILESYSTEM_CHANGED_TB(p_s_tb)) {
- brelse(p_s_bh);
+ brelse(bh);
PROC_INFO_INC(sb, get_neighbors_restart[n_h]);
return REPEAT_SEARCH;
}
brelse(p_s_tb->R[n_h]);
- p_s_tb->R[n_h] = p_s_bh;
+ p_s_tb->R[n_h] = bh;
RFALSE(!n_h
- && B_FREE_SPACE(p_s_bh) !=
- MAX_CHILD_SIZE(p_s_bh) -
+ && B_FREE_SPACE(bh) !=
+ MAX_CHILD_SIZE(bh) -
dc_size(B_N_CHILD(p_s_tb->FR[0], n_child_position)),
"PAP-8300: invalid child size of right neighbor (%d != %d - %d)",
- B_FREE_SPACE(p_s_bh), MAX_CHILD_SIZE(p_s_bh),
+ B_FREE_SPACE(bh), MAX_CHILD_SIZE(bh),
dc_size(B_N_CHILD(p_s_tb->FR[0], n_child_position)));
}
@@ -2088,51 +2088,51 @@ static int get_mem_for_virtual_node(stru
#ifdef CONFIG_REISERFS_CHECK
static void tb_buffer_sanity_check(struct super_block *sb,
- struct buffer_head *p_s_bh,
+ struct buffer_head *bh,
const char *descr, int level)
{
- if (p_s_bh) {
- if (atomic_read(&(p_s_bh->b_count)) <= 0) {
+ if (bh) {
+ if (atomic_read(&(bh->b_count)) <= 0) {
reiserfs_panic(sb, "jmacd-1", "negative or zero "
"reference counter for buffer %s[%d] "
- "(%b)", descr, level, p_s_bh);
+ "(%b)", descr, level, bh);
}
- if (!buffer_uptodate(p_s_bh)) {
+ if (!buffer_uptodate(bh)) {
reiserfs_panic(sb, "jmacd-2", "buffer is not up "
"to date %s[%d] (%b)",
- descr, level, p_s_bh);
+ descr, level, bh);
}
- if (!B_IS_IN_TREE(p_s_bh)) {
+ if (!B_IS_IN_TREE(bh)) {
reiserfs_panic(sb, "jmacd-3", "buffer is not "
"in tree %s[%d] (%b)",
- descr, level, p_s_bh);
+ descr, level, bh);
}
- if (p_s_bh->b_bdev != sb->s_bdev) {
+ if (bh->b_bdev != sb->s_bdev) {
reiserfs_panic(sb, "jmacd-4", "buffer has wrong "
"device %s[%d] (%b)",
- descr, level, p_s_bh);
+ descr, level, bh);
}
- if (p_s_bh->b_size != sb->s_blocksize) {
+ if (bh->b_size != sb->s_blocksize) {
reiserfs_panic(sb, "jmacd-5", "buffer has wrong "
"blocksize %s[%d] (%b)",
- descr, level, p_s_bh);
+ descr, level, bh);
}
- if (p_s_bh->b_blocknr > SB_BLOCK_COUNT(sb)) {
+ if (bh->b_blocknr > SB_BLOCK_COUNT(sb)) {
reiserfs_panic(sb, "jmacd-6", "buffer block "
"number too high %s[%d] (%b)",
- descr, level, p_s_bh);
+ descr, level, bh);
}
}
}
#else
static void tb_buffer_sanity_check(struct super_block *sb,
- struct buffer_head *p_s_bh,
+ struct buffer_head *bh,
const char *descr, int level)
{;
}
--- a/fs/reiserfs/stree.c 2007-06-11 14:49:39.000000000 -0400
+++ b/fs/reiserfs/stree.c 2007-06-11 14:50:03.000000000 -0400
@@ -56,13 +56,13 @@
#include <linux/quotaops.h>
/* Does the buffer contain a disk block which is in the tree. */
-inline int B_IS_IN_TREE(const struct buffer_head *p_s_bh)
+inline int B_IS_IN_TREE(const struct buffer_head *bh)
{
- RFALSE(B_LEVEL(p_s_bh) > MAX_HEIGHT,
- "PAP-1010: block (%b) has too big level (%z)", p_s_bh, p_s_bh);
+ RFALSE(B_LEVEL(bh) > MAX_HEIGHT,
+ "PAP-1010: block (%b) has too big level (%z)", bh, bh);
- return (B_LEVEL(p_s_bh) != FREE_LEVEL);
+ return (B_LEVEL(bh) != FREE_LEVEL);
}
//
@@ -579,7 +579,7 @@ int search_by_key(struct super_block *sb
{
int n_block_number;
int expected_level;
- struct buffer_head *p_s_bh;
+ struct buffer_head *bh;
struct path_element *p_s_last_element;
int n_node_level, n_retval;
int right_neighbor_of_leaf_node;
@@ -626,15 +626,15 @@ int search_by_key(struct super_block *sb
/* Read the next tree node, and set the last element in the path to
have a pointer to it. */
- if ((p_s_bh = p_s_last_element->pe_buffer =
+ if ((bh = p_s_last_element->pe_buffer =
sb_getblk(sb, n_block_number))) {
- if (!buffer_uptodate(p_s_bh) && reada_count > 1) {
+ if (!buffer_uptodate(bh) && reada_count > 1) {
search_by_key_reada(sb, reada_bh,
reada_blocks, reada_count);
}
- ll_rw_block(READ, 1, &p_s_bh);
- wait_on_buffer(p_s_bh);
- if (!buffer_uptodate(p_s_bh))
+ ll_rw_block(READ, 1, &bh);
+ wait_on_buffer(bh);
+ if (!buffer_uptodate(bh))
goto io_error;
} else {
io_error:
@@ -651,8 +651,8 @@ int search_by_key(struct super_block *sb
to search is still in the tree rooted from the current buffer. If
not then repeat search from the root. */
if (fs_changed(fs_gen, sb) &&
- (!B_IS_IN_TREE(p_s_bh) ||
- B_LEVEL(p_s_bh) != expected_level ||
+ (!B_IS_IN_TREE(bh) ||
+ B_LEVEL(bh) != expected_level ||
!key_in_buffer(p_s_search_path, p_s_key, sb))) {
PROC_INFO_INC(sb, search_by_key_fs_changed);
PROC_INFO_INC(sb, search_by_key_restarted);
@@ -686,25 +686,25 @@ int search_by_key(struct super_block *sb
// make sure, that the node contents look like a node of
// certain level
- if (!is_tree_node(p_s_bh, expected_level)) {
+ if (!is_tree_node(bh, expected_level)) {
reiserfs_error(sb, "vs-5150",
"invalid format found in block %ld. "
- "Fsck?", p_s_bh->b_blocknr);
+ "Fsck?", bh->b_blocknr);
pathrelse(p_s_search_path);
return IO_ERROR;
}
/* ok, we have acquired next formatted node in the tree */
- n_node_level = B_LEVEL(p_s_bh);
+ n_node_level = B_LEVEL(bh);
- PROC_INFO_BH_STAT(sb, p_s_bh, n_node_level - 1);
+ PROC_INFO_BH_STAT(sb, bh, n_node_level - 1);
RFALSE(n_node_level < n_stop_level,
"vs-5152: tree level (%d) is less than stop level (%d)",
n_node_level, n_stop_level);
- n_retval = bin_search(p_s_key, B_N_PITEM_HEAD(p_s_bh, 0),
- B_NR_ITEMS(p_s_bh),
+ n_retval = bin_search(p_s_key, B_N_PITEM_HEAD(bh, 0),
+ B_NR_ITEMS(bh),
(n_node_level ==
DISK_LEAF_NODE_LEVEL) ? IH_SIZE :
KEY_SIZE,
@@ -726,13 +726,13 @@ int search_by_key(struct super_block *sb
an internal node. Now we calculate child block number by
position in the node. */
n_block_number =
- B_N_CHILD_NUM(p_s_bh, p_s_last_element->pe_position);
+ B_N_CHILD_NUM(bh, p_s_last_element->pe_position);
/* if we are going to read leaf nodes, try for read ahead as well */
if ((p_s_search_path->reada & PATH_READA) &&
n_node_level == DISK_LEAF_NODE_LEVEL + 1) {
int pos = p_s_last_element->pe_position;
- int limit = B_NR_ITEMS(p_s_bh);
+ int limit = B_NR_ITEMS(bh);
struct reiserfs_key *le_key;
if (p_s_search_path->reada & PATH_READA_BACK)
@@ -741,7 +741,7 @@ int search_by_key(struct super_block *sb
if (pos == limit)
break;
reada_blocks[reada_count++] =
- B_N_CHILD_NUM(p_s_bh, pos);
+ B_N_CHILD_NUM(bh, pos);
if (p_s_search_path->reada & PATH_READA_BACK)
pos--;
else
@@ -750,7 +750,7 @@ int search_by_key(struct super_block *sb
/*
* check to make sure we're in the same object
*/
- le_key = B_N_PDELIM_KEY(p_s_bh, pos);
+ le_key = B_N_PDELIM_KEY(bh, pos);
if (le32_to_cpu(le_key->k_objectid) !=
p_s_key->on_disk_key.k_objectid) {
break;
@@ -851,15 +851,15 @@ int search_for_position_by_key(struct su
/* Compare given item and item pointed to by the path. */
int comp_items(const struct item_head *stored_ih, const struct treepath *p_s_path)
{
- struct buffer_head *p_s_bh;
+ struct buffer_head *bh;
struct item_head *ih;
/* Last buffer at the path is not in the tree. */
- if (!B_IS_IN_TREE(p_s_bh = PATH_PLAST_BUFFER(p_s_path)))
+ if (!B_IS_IN_TREE(bh = PATH_PLAST_BUFFER(p_s_path)))
return 1;
/* Last path position is invalid. */
- if (PATH_LAST_POSITION(p_s_path) >= B_NR_ITEMS(p_s_bh))
+ if (PATH_LAST_POSITION(p_s_path) >= B_NR_ITEMS(bh))
return 1;
/* we need only to know, whether it is the same item */
@@ -959,7 +959,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(p_s_path);
- struct buffer_head *p_s_bh = PATH_PLAST_BUFFER(p_s_path);
+ struct buffer_head *bh = PATH_PLAST_BUFFER(p_s_path);
BUG_ON(!th->t_trans_id);
@@ -1003,7 +1003,7 @@ static char prepare_for_delete_or_cut(st
do {
need_re_search = 0;
*p_n_cut_size = 0;
- p_s_bh = PATH_PLAST_BUFFER(p_s_path);
+ bh = PATH_PLAST_BUFFER(p_s_path);
copy_item_head(&s_ih, PATH_PITEM_HEAD(p_s_path));
pos = I_UNFM_NUM(&s_ih);
@@ -1018,13 +1018,13 @@ static char prepare_for_delete_or_cut(st
break;
}
- unfm = (__u32 *)B_I_PITEM(p_s_bh, &s_ih) + pos - 1;
+ unfm = (__u32 *)B_I_PITEM(bh, &s_ih) + pos - 1;
block = get_block_num(unfm, 0);
if (block != 0) {
- reiserfs_prepare_for_journal(sb, p_s_bh, 1);
+ reiserfs_prepare_for_journal(sb, bh, 1);
put_block_num(unfm, 0, 0);
- journal_mark_dirty (th, sb, p_s_bh);
+ journal_mark_dirty (th, sb, bh);
reiserfs_free_block(th, inode, block, 1);
}
@@ -1048,7 +1048,7 @@ static char prepare_for_delete_or_cut(st
/* a trick. If the buffer has been logged, this will do nothing. If
** we've broken the loop without logging it, it will restore the
** buffer */
- reiserfs_restore_prepared_buffer(sb, p_s_bh);
+ reiserfs_restore_prepared_buffer(sb, bh);
} while (need_re_search &&
search_for_position_by_key(sb, p_s_item_key, p_s_path) == POSITION_FOUND);
pos_in_item(p_s_path) = pos * UNFM_P_SIZE;
--- a/include/linux/reiserfs_fs.h 2007-06-11 14:49:39.000000000 -0400
+++ b/include/linux/reiserfs_fs.h 2007-06-11 14:50:03.000000000 -0400
@@ -731,25 +731,25 @@ struct block_head {
#define DISK_LEAF_NODE_LEVEL 1 /* Leaf node level. */
/* Given the buffer head of a formatted node, resolve to the block head of that node. */
-#define B_BLK_HEAD(p_s_bh) ((struct block_head *)((p_s_bh)->b_data))
+#define B_BLK_HEAD(bh) ((struct block_head *)((bh)->b_data))
/* Number of items that are in buffer. */
-#define B_NR_ITEMS(p_s_bh) (blkh_nr_item(B_BLK_HEAD(p_s_bh)))
-#define B_LEVEL(p_s_bh) (blkh_level(B_BLK_HEAD(p_s_bh)))
-#define B_FREE_SPACE(p_s_bh) (blkh_free_space(B_BLK_HEAD(p_s_bh)))
-
-#define PUT_B_NR_ITEMS(p_s_bh,val) do { set_blkh_nr_item(B_BLK_HEAD(p_s_bh),val); } while (0)
-#define PUT_B_LEVEL(p_s_bh,val) do { set_blkh_level(B_BLK_HEAD(p_s_bh),val); } while (0)
-#define PUT_B_FREE_SPACE(p_s_bh,val) do { set_blkh_free_space(B_BLK_HEAD(p_s_bh),val); } while (0)
+#define B_NR_ITEMS(bh) (blkh_nr_item(B_BLK_HEAD(bh)))
+#define B_LEVEL(bh) (blkh_level(B_BLK_HEAD(bh)))
+#define B_FREE_SPACE(bh) (blkh_free_space(B_BLK_HEAD(bh)))
+
+#define PUT_B_NR_ITEMS(bh,val) do { set_blkh_nr_item(B_BLK_HEAD(bh),val); } while (0)
+#define PUT_B_LEVEL(bh,val) do { set_blkh_level(B_BLK_HEAD(bh),val); } while (0)
+#define PUT_B_FREE_SPACE(bh,val) do { set_blkh_free_space(B_BLK_HEAD(bh),val); } while (0)
/* Get right delimiting key. -- little endian */
-#define B_PRIGHT_DELIM_KEY(p_s_bh) (&(blk_right_delim_key(B_BLK_HEAD(p_s_bh))))
+#define B_PRIGHT_DELIM_KEY(bh) (&(blk_right_delim_key(B_BLK_HEAD(bh))))
/* Does the buffer contain a disk leaf. */
-#define B_IS_ITEMS_LEVEL(p_s_bh) (B_LEVEL(p_s_bh) == DISK_LEAF_NODE_LEVEL)
+#define B_IS_ITEMS_LEVEL(bh) (B_LEVEL(bh) == DISK_LEAF_NODE_LEVEL)
/* Does the buffer contain a disk internal node */
-#define B_IS_KEYS_LEVEL(p_s_bh) (B_LEVEL(p_s_bh) > DISK_LEAF_NODE_LEVEL \
- && B_LEVEL(p_s_bh) <= MAX_HEIGHT)
+#define B_IS_KEYS_LEVEL(bh) (B_LEVEL(bh) > DISK_LEAF_NODE_LEVEL \
+ && B_LEVEL(bh) <= MAX_HEIGHT)
/***************************************************************************/
/* STAT DATA */
@@ -1099,12 +1099,12 @@ struct disk_child {
#define put_dc_size(dc_p, val) do { (dc_p)->dc_size = cpu_to_le16(val); } while(0)
/* Get disk child by buffer header and position in the tree node. */
-#define B_N_CHILD(p_s_bh,n_pos) ((struct disk_child *)\
-((p_s_bh)->b_data+BLKH_SIZE+B_NR_ITEMS(p_s_bh)*KEY_SIZE+DC_SIZE*(n_pos)))
+#define B_N_CHILD(bh,n_pos) ((struct disk_child *)\
+((bh)->b_data+BLKH_SIZE+B_NR_ITEMS(bh)*KEY_SIZE+DC_SIZE*(n_pos)))
/* Get disk child number by buffer header and position in the tree node. */
-#define B_N_CHILD_NUM(p_s_bh,n_pos) (dc_block_number(B_N_CHILD(p_s_bh,n_pos)))
-#define PUT_B_N_CHILD_NUM(p_s_bh,n_pos, val) (put_dc_block_number(B_N_CHILD(p_s_bh,n_pos), val ))
+#define B_N_CHILD_NUM(bh,n_pos) (dc_block_number(B_N_CHILD(bh,n_pos)))
+#define PUT_B_N_CHILD_NUM(bh,n_pos, val) (put_dc_block_number(B_N_CHILD(bh,n_pos), val ))
/* maximal value of field child_size in structure disk_child */
/* child size is the combined size of all items and their headers */
@@ -1827,7 +1827,7 @@ int search_by_key(struct super_block *,
int search_for_position_by_key(struct super_block *sb,
const struct cpu_key *p_s_cpu_key,
struct treepath *p_s_search_path);
-extern void decrement_bcount(struct buffer_head *p_s_bh);
+extern void decrement_bcount(struct buffer_head *bh);
void decrement_counters_in_path(struct treepath *p_s_search_path);
void pathrelse(struct treepath *p_s_search_path);
int reiserfs_check_path(struct treepath *p);
@@ -1972,7 +1972,7 @@ int reiserfs_global_version_in_proc(char
#define PROC_INFO_MAX( sb, field, value ) VOID_V
#define PROC_INFO_INC( sb, field ) VOID_V
#define PROC_INFO_ADD( sb, field, val ) VOID_V
-#define PROC_INFO_BH_STAT( sb, p_s_bh, n_node_level ) VOID_V
+#define PROC_INFO_BH_STAT( sb, bh, n_node_level ) VOID_V
#endif
/* dir.c */
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 43+ messages in thread
* [patch 27/40] reiserfs: rename p_s_inode to inode
2007-06-11 19:03 [patch 00/40] reiserfs: patch queue (v2) jeffm
` (24 preceding siblings ...)
2007-06-11 19:03 ` [patch 26/40] reiserfs: rename p_s_bh to bh jeffm
@ 2007-06-11 19:03 ` jeffm
2007-06-11 19:03 ` [patch 28/40] reiserfs: rename p_s_tb to tb jeffm
` (14 subsequent siblings)
40 siblings, 0 replies; 43+ messages in thread
From: jeffm @ 2007-06-11 19:03 UTC (permalink / raw)
To: ReiserFS Mailing List
[-- Attachment #1: reiserfs-rename-p_s_inode.diff --]
[-- Type: text/plain, Size: 21676 bytes --]
This patch is a simple s/p_s_inode/inode/g to the reiserfs code. This is the
third in a series of patches to rip out some of the awful variable naming in
reiserfs.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
fs/reiserfs/file.c | 16 +++----
fs/reiserfs/inode.c | 42 +++++++++---------
fs/reiserfs/stree.c | 96 +++++++++++++++++++++---------------------
fs/reiserfs/tail_conversion.c | 16 +++----
include/linux/reiserfs_fs.h | 4 -
5 files changed, 87 insertions(+), 87 deletions(-)
--- a/fs/reiserfs/file.c 2007-06-11 14:49:39.000000000 -0400
+++ b/fs/reiserfs/file.c 2007-06-11 14:50:02.000000000 -0400
@@ -137,17 +137,17 @@ static void reiserfs_vfs_truncate_file(s
static int reiserfs_sync_file(struct file *p_s_filp,
struct dentry *p_s_dentry, int datasync)
{
- struct inode *p_s_inode = p_s_dentry->d_inode;
+ struct inode *inode = p_s_dentry->d_inode;
int n_err;
int barrier_done;
- BUG_ON(!S_ISREG(p_s_inode->i_mode));
- n_err = sync_mapping_buffers(p_s_inode->i_mapping);
- reiserfs_write_lock(p_s_inode->i_sb);
- barrier_done = reiserfs_commit_for_inode(p_s_inode);
- reiserfs_write_unlock(p_s_inode->i_sb);
- if (barrier_done != 1 && reiserfs_barrier_flush(p_s_inode->i_sb))
- blkdev_issue_flush(p_s_inode->i_sb->s_bdev, NULL);
+ BUG_ON(!S_ISREG(inode->i_mode));
+ n_err = sync_mapping_buffers(inode->i_mapping);
+ reiserfs_write_lock(inode->i_sb);
+ barrier_done = reiserfs_commit_for_inode(inode);
+ reiserfs_write_unlock(inode->i_sb);
+ if (barrier_done != 1 && reiserfs_barrier_flush(inode->i_sb))
+ blkdev_issue_flush(inode->i_sb->s_bdev, NULL);
if (barrier_done < 0)
return barrier_done;
return (n_err < 0) ? -EIO : 0;
--- a/fs/reiserfs/inode.c 2007-06-11 14:49:39.000000000 -0400
+++ b/fs/reiserfs/inode.c 2007-06-11 14:49:40.000000000 -0400
@@ -1994,7 +1994,7 @@ int reiserfs_new_inode(struct reiserfs_t
**
** on failure, nonzero is returned, page_result and bh_result are untouched.
*/
-static int grab_tail_page(struct inode *p_s_inode,
+static int grab_tail_page(struct inode *inode,
struct page **page_result,
struct buffer_head **bh_result)
{
@@ -2002,11 +2002,11 @@ static int grab_tail_page(struct inode *
/* we want the page with the last byte in the file,
** not the page that will hold the next byte for appending
*/
- unsigned long index = (p_s_inode->i_size - 1) >> PAGE_CACHE_SHIFT;
+ unsigned long index = (inode->i_size - 1) >> PAGE_CACHE_SHIFT;
unsigned long pos = 0;
unsigned long start = 0;
- unsigned long blocksize = p_s_inode->i_sb->s_blocksize;
- unsigned long offset = (p_s_inode->i_size) & (PAGE_CACHE_SIZE - 1);
+ unsigned long blocksize = inode->i_sb->s_blocksize;
+ unsigned long offset = (inode->i_size) & (PAGE_CACHE_SIZE - 1);
struct buffer_head *bh;
struct buffer_head *head;
struct page *page;
@@ -2020,7 +2020,7 @@ static int grab_tail_page(struct inode *
if ((offset & (blocksize - 1)) == 0) {
return -ENOENT;
}
- page = grab_cache_page(p_s_inode->i_mapping, index);
+ page = grab_cache_page(inode->i_mapping, index);
error = -ENOMEM;
if (!page) {
goto out;
@@ -2049,7 +2049,7 @@ static int grab_tail_page(struct inode *
** I've screwed up the code to find the buffer, or the code to
** call prepare_write
*/
- reiserfs_error(p_s_inode->i_sb, "clm-6000",
+ reiserfs_error(inode->i_sb, "clm-6000",
"error reading block %lu", bh->b_blocknr);
error = -EIO;
goto unlock;
@@ -2072,27 +2072,27 @@ static int grab_tail_page(struct inode *
**
** some code taken from block_truncate_page
*/
-int reiserfs_truncate_file(struct inode *p_s_inode, int update_timestamps)
+int reiserfs_truncate_file(struct inode *inode, int update_timestamps)
{
struct reiserfs_transaction_handle th;
/* we want the offset for the first byte after the end of the file */
- unsigned long offset = p_s_inode->i_size & (PAGE_CACHE_SIZE - 1);
- unsigned blocksize = p_s_inode->i_sb->s_blocksize;
+ unsigned long offset = inode->i_size & (PAGE_CACHE_SIZE - 1);
+ unsigned blocksize = inode->i_sb->s_blocksize;
unsigned length;
struct page *page = NULL;
int error;
struct buffer_head *bh = NULL;
int err2;
- reiserfs_write_lock(p_s_inode->i_sb);
+ reiserfs_write_lock(inode->i_sb);
- if (p_s_inode->i_size > 0) {
- if ((error = grab_tail_page(p_s_inode, &page, &bh))) {
+ if (inode->i_size > 0) {
+ if ((error = grab_tail_page(inode, &page, &bh))) {
// -ENOENT means we truncated past the end of the file,
// and get_block_create_0 could not find a block to read in,
// which is ok.
if (error != -ENOENT)
- reiserfs_error(p_s_inode->i_sb, "clm-6001",
+ reiserfs_error(inode->i_sb, "clm-6001",
"grab_tail_page failed %d",
error);
page = NULL;
@@ -2110,19 +2110,19 @@ int reiserfs_truncate_file(struct inode
/* it is enough to reserve space in transaction for 2 balancings:
one for "save" link adding and another for the first
cut_from_item. 1 is for update_sd */
- error = journal_begin(&th, p_s_inode->i_sb,
+ error = journal_begin(&th, inode->i_sb,
JOURNAL_PER_BALANCE_CNT * 2 + 1);
if (error)
goto out;
- reiserfs_update_inode_transaction(p_s_inode);
+ reiserfs_update_inode_transaction(inode);
if (update_timestamps)
/* we are doing real truncate: if the system crashes before the last
transaction of truncating gets committed - on reboot the file
either appears truncated properly or not truncated at all */
- add_save_link(&th, p_s_inode, 1);
- err2 = reiserfs_do_truncate(&th, p_s_inode, page, update_timestamps);
+ add_save_link(&th, inode, 1);
+ err2 = reiserfs_do_truncate(&th, inode, page, update_timestamps);
error =
- journal_end(&th, p_s_inode->i_sb, JOURNAL_PER_BALANCE_CNT * 2 + 1);
+ journal_end(&th, inode->i_sb, JOURNAL_PER_BALANCE_CNT * 2 + 1);
if (error)
goto out;
@@ -2133,7 +2133,7 @@ int reiserfs_truncate_file(struct inode
}
if (update_timestamps) {
- error = remove_save_link(p_s_inode, 1 /* truncate */ );
+ error = remove_save_link(inode, 1 /* truncate */ );
if (error)
goto out;
}
@@ -2152,14 +2152,14 @@ int reiserfs_truncate_file(struct inode
page_cache_release(page);
}
- reiserfs_write_unlock(p_s_inode->i_sb);
+ reiserfs_write_unlock(inode->i_sb);
return 0;
out:
if (page) {
unlock_page(page);
page_cache_release(page);
}
- reiserfs_write_unlock(p_s_inode->i_sb);
+ reiserfs_write_unlock(inode->i_sb);
return error;
}
--- a/fs/reiserfs/stree.c 2007-06-11 14:49:40.000000000 -0400
+++ b/fs/reiserfs/stree.c 2007-06-11 14:50:03.000000000 -0400
@@ -1143,10 +1143,10 @@ char head2type(struct item_head *ih)
/* Delete object item. */
int reiserfs_delete_item(struct reiserfs_transaction_handle *th, struct treepath *p_s_path, /* Path to the deleted item. */
const struct cpu_key *p_s_item_key, /* Key to search for the deleted item. */
- struct inode *p_s_inode, /* inode is here just to update i_blocks and quotas */
+ struct inode *inode, /* inode is here just to update i_blocks and quotas */
struct buffer_head *p_s_un_bh)
{ /* NULL or unformatted node pointer. */
- struct super_block *sb = p_s_inode->i_sb;
+ struct super_block *sb = inode->i_sb;
struct tree_balance s_del_balance;
struct item_head s_ih;
struct item_head *q_ih;
@@ -1170,10 +1170,10 @@ int reiserfs_delete_item(struct reiserfs
n_iter++;
c_mode =
#endif
- prepare_for_delete_or_cut(th, p_s_inode, p_s_path,
+ prepare_for_delete_or_cut(th, inode, p_s_path,
p_s_item_key, &n_removed,
&n_del_size,
- max_reiserfs_offset(p_s_inode));
+ max_reiserfs_offset(inode));
RFALSE(c_mode != M_DELETE, "PAP-5320: mode must be M_DELETE");
@@ -1214,7 +1214,7 @@ int reiserfs_delete_item(struct reiserfs
** split into multiple items, and we only want to decrement for
** the unfm node once
*/
- if (!S_ISLNK(p_s_inode->i_mode) && is_direct_le_ih(q_ih)) {
+ if (!S_ISLNK(inode->i_mode) && is_direct_le_ih(q_ih)) {
if ((le_ih_k_offset(q_ih) & (sb->s_blocksize - 1)) == 1) {
quota_cut_bytes = sb->s_blocksize + UNFM_P_SIZE;
} else {
@@ -1259,9 +1259,9 @@ int reiserfs_delete_item(struct reiserfs
#ifdef REISERQUOTA_DEBUG
reiserfs_debug(sb, REISERFS_DEBUG_CODE,
"reiserquota delete_item(): freeing %u, id=%u type=%c",
- quota_cut_bytes, p_s_inode->i_uid, head2type(&s_ih));
+ quota_cut_bytes, inode->i_uid, head2type(&s_ih));
#endif
- DQUOT_FREE_SPACE_NODIRTY(p_s_inode, quota_cut_bytes);
+ DQUOT_FREE_SPACE_NODIRTY(inode, quota_cut_bytes);
/* Return deleted body length */
return n_ret_value;
@@ -1427,25 +1427,25 @@ static void unmap_buffers(struct page *p
}
static int maybe_indirect_to_direct(struct reiserfs_transaction_handle *th,
- struct inode *p_s_inode,
+ struct inode *inode,
struct page *page,
struct treepath *p_s_path,
const struct cpu_key *p_s_item_key,
loff_t n_new_file_size, char *p_c_mode)
{
- struct super_block *sb = p_s_inode->i_sb;
+ struct super_block *sb = inode->i_sb;
int n_block_size = sb->s_blocksize;
int cut_bytes;
BUG_ON(!th->t_trans_id);
- BUG_ON(n_new_file_size != p_s_inode->i_size);
+ BUG_ON(n_new_file_size != inode->i_size);
/* the page being sent in could be NULL if there was an i/o error
** reading in the last block. The user will hit problems trying to
** read the file, but for now we just skip the indirect2direct
*/
- if (atomic_read(&p_s_inode->i_count) > 1 ||
- !tail_has_to_be_packed(p_s_inode) ||
- !page || (REISERFS_I(p_s_inode)->i_flags & i_nopack_mask)) {
+ if (atomic_read(&inode->i_count) > 1 ||
+ !tail_has_to_be_packed(inode) ||
+ !page || (REISERFS_I(inode)->i_flags & i_nopack_mask)) {
// leave tail in an unformatted node
*p_c_mode = M_SKIP_BALANCING;
cut_bytes =
@@ -1454,8 +1454,8 @@ static int maybe_indirect_to_direct(stru
return cut_bytes;
}
/* Permorm the conversion to a direct_item. */
- /*return indirect_to_direct (p_s_inode, p_s_path, p_s_item_key, n_new_file_size, p_c_mode); */
- return indirect2direct(th, p_s_inode, page, p_s_path, p_s_item_key,
+ /*return indirect_to_direct (inode, p_s_path, p_s_item_key, n_new_file_size, p_c_mode); */
+ return indirect2direct(th, inode, page, p_s_path, p_s_item_key,
n_new_file_size, p_c_mode);
}
@@ -1509,10 +1509,10 @@ static void indirect_to_direct_roll_back
int reiserfs_cut_from_item(struct reiserfs_transaction_handle *th,
struct treepath *p_s_path,
struct cpu_key *p_s_item_key,
- struct inode *p_s_inode,
+ struct inode *inode,
struct page *page, loff_t n_new_file_size)
{
- struct super_block *sb = p_s_inode->i_sb;
+ struct super_block *sb = inode->i_sb;
/* Every function which is going to call do_balance must first
create a tree_balance structure. Then it must fill up this
structure by using the init_tb_struct and fix_nodes functions.
@@ -1529,7 +1529,7 @@ int reiserfs_cut_from_item(struct reiser
BUG_ON(!th->t_trans_id);
- init_tb_struct(th, &s_cut_balance, p_s_inode->i_sb, p_s_path,
+ init_tb_struct(th, &s_cut_balance, inode->i_sb, p_s_path,
n_cut_size);
/* Repeat this loop until we either cut the item without needing
@@ -1541,7 +1541,7 @@ int reiserfs_cut_from_item(struct reiser
pointers. */
c_mode =
- prepare_for_delete_or_cut(th, p_s_inode, p_s_path,
+ prepare_for_delete_or_cut(th, inode, p_s_path,
p_s_item_key, &n_removed,
&n_cut_size, n_new_file_size);
if (c_mode == M_CONVERT) {
@@ -1551,7 +1551,7 @@ int reiserfs_cut_from_item(struct reiser
"PAP-5570: can not convert twice");
n_ret_value =
- maybe_indirect_to_direct(th, p_s_inode, page,
+ maybe_indirect_to_direct(th, inode, page,
p_s_path, p_s_item_key,
n_new_file_size, &c_mode);
if (c_mode == M_SKIP_BALANCING)
@@ -1616,7 +1616,7 @@ int reiserfs_cut_from_item(struct reiser
if (n_is_inode_locked) {
// FIXME: this seems to be not needed: we are always able
// to cut item
- indirect_to_direct_roll_back(th, p_s_inode, p_s_path);
+ indirect_to_direct_roll_back(th, inode, p_s_path);
}
if (n_ret_value == NO_DISK_SPACE)
reiserfs_warning(sb, "reiserfs-5092",
@@ -1643,12 +1643,12 @@ int reiserfs_cut_from_item(struct reiser
** item.
*/
p_le_ih = PATH_PITEM_HEAD(s_cut_balance.tb_path);
- if (!S_ISLNK(p_s_inode->i_mode) && is_direct_le_ih(p_le_ih)) {
+ if (!S_ISLNK(inode->i_mode) && is_direct_le_ih(p_le_ih)) {
if (c_mode == M_DELETE &&
(le_ih_k_offset(p_le_ih) & (sb->s_blocksize - 1)) ==
1) {
// FIXME: this is to keep 3.5 happy
- REISERFS_I(p_s_inode)->i_first_direct_byte = U32_MAX;
+ REISERFS_I(inode)->i_first_direct_byte = U32_MAX;
quota_cut_bytes = sb->s_blocksize + UNFM_P_SIZE;
} else {
quota_cut_bytes = 0;
@@ -1691,14 +1691,14 @@ int reiserfs_cut_from_item(struct reiser
** unmap and invalidate it
*/
unmap_buffers(page, tail_pos);
- REISERFS_I(p_s_inode)->i_flags &= ~i_pack_on_close_mask;
+ REISERFS_I(inode)->i_flags &= ~i_pack_on_close_mask;
}
#ifdef REISERQUOTA_DEBUG
- reiserfs_debug(p_s_inode->i_sb, REISERFS_DEBUG_CODE,
+ reiserfs_debug(inode->i_sb, REISERFS_DEBUG_CODE,
"reiserquota cut_from_item(): freeing %u id=%u type=%c",
- quota_cut_bytes, p_s_inode->i_uid, '?');
+ quota_cut_bytes, inode->i_uid, '?');
#endif
- DQUOT_FREE_SPACE_NODIRTY(p_s_inode, quota_cut_bytes);
+ DQUOT_FREE_SPACE_NODIRTY(inode, quota_cut_bytes);
return n_ret_value;
}
@@ -1719,7 +1719,7 @@ static void truncate_directory(struct re
/* Truncate file to the new size. Note, this must be called with a transaction
already started */
-int reiserfs_do_truncate(struct reiserfs_transaction_handle *th, struct inode *p_s_inode, /* ->i_size contains new
+int reiserfs_do_truncate(struct reiserfs_transaction_handle *th, struct inode *inode, /* ->i_size contains new
size */
struct page *page, /* up to date for last block */
int update_timestamps /* when it is called by
@@ -1739,35 +1739,35 @@ int reiserfs_do_truncate(struct reiserfs
BUG_ON(!th->t_trans_id);
if (!
- (S_ISREG(p_s_inode->i_mode) || S_ISDIR(p_s_inode->i_mode)
- || S_ISLNK(p_s_inode->i_mode)))
+ (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode)
+ || S_ISLNK(inode->i_mode)))
return 0;
- if (S_ISDIR(p_s_inode->i_mode)) {
+ if (S_ISDIR(inode->i_mode)) {
// deletion of directory - no need to update timestamps
- truncate_directory(th, p_s_inode);
+ truncate_directory(th, inode);
return 0;
}
/* Get new file size. */
- n_new_file_size = p_s_inode->i_size;
+ n_new_file_size = inode->i_size;
// FIXME: note, that key type is unimportant here
- make_cpu_key(&s_item_key, p_s_inode, max_reiserfs_offset(p_s_inode),
+ make_cpu_key(&s_item_key, inode, max_reiserfs_offset(inode),
TYPE_DIRECT, 3);
retval =
- search_for_position_by_key(p_s_inode->i_sb, &s_item_key,
+ search_for_position_by_key(inode->i_sb, &s_item_key,
&s_search_path);
if (retval == IO_ERROR) {
- reiserfs_error(p_s_inode->i_sb, "vs-5657",
+ reiserfs_error(inode->i_sb, "vs-5657",
"i/o failure occurred trying to truncate %K",
&s_item_key);
err = -EIO;
goto out;
}
if (retval == POSITION_FOUND || retval == FILE_NOT_FOUND) {
- reiserfs_error(p_s_inode->i_sb, "PAP-5660",
+ reiserfs_error(inode->i_sb, "PAP-5660",
"wrong result %d of search for %K", retval,
&s_item_key);
@@ -1784,7 +1784,7 @@ int reiserfs_do_truncate(struct reiserfs
else {
loff_t offset = le_ih_k_offset(p_le_ih);
int bytes =
- op_bytes_number(p_le_ih, p_s_inode->i_sb->s_blocksize);
+ op_bytes_number(p_le_ih, inode->i_sb->s_blocksize);
/* this may mismatch with real file size: if last direct item
had no padding zeros and last unformatted node had no free
@@ -1809,9 +1809,9 @@ int reiserfs_do_truncate(struct reiserfs
/* Cut or delete file item. */
n_deleted =
reiserfs_cut_from_item(th, &s_search_path, &s_item_key,
- p_s_inode, page, n_new_file_size);
+ inode, page, n_new_file_size);
if (n_deleted < 0) {
- reiserfs_warning(p_s_inode->i_sb, "vs-5665",
+ reiserfs_warning(inode->i_sb, "vs-5665",
"reiserfs_cut_from_item failed");
reiserfs_check_path(&s_search_path);
return 0;
@@ -1841,22 +1841,22 @@ int reiserfs_do_truncate(struct reiserfs
pathrelse(&s_search_path);
if (update_timestamps) {
- p_s_inode->i_mtime = p_s_inode->i_ctime =
+ inode->i_mtime = inode->i_ctime =
CURRENT_TIME_SEC;
}
- reiserfs_update_sd(th, p_s_inode);
+ reiserfs_update_sd(th, inode);
- err = journal_end(th, p_s_inode->i_sb, orig_len_alloc);
+ err = journal_end(th, inode->i_sb, orig_len_alloc);
if (err)
goto out;
- err = journal_begin(th, p_s_inode->i_sb,
+ err = journal_begin(th, inode->i_sb,
JOURNAL_FOR_FREE_BLOCK_AND_UPDATE_SD + JOURNAL_PER_BALANCE_CNT * 4) ;
if (err)
goto out;
- reiserfs_update_inode_transaction(p_s_inode);
+ reiserfs_update_inode_transaction(inode);
}
} while (n_file_size > ROUND_UP(n_new_file_size) &&
- search_for_position_by_key(p_s_inode->i_sb, &s_item_key,
+ search_for_position_by_key(inode->i_sb, &s_item_key,
&s_search_path) == POSITION_FOUND);
RFALSE(n_file_size > ROUND_UP(n_new_file_size),
@@ -1866,9 +1866,9 @@ int reiserfs_do_truncate(struct reiserfs
update_and_out:
if (update_timestamps) {
// this is truncate, not file closing
- p_s_inode->i_mtime = p_s_inode->i_ctime = CURRENT_TIME_SEC;
+ inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC;
}
- reiserfs_update_sd(th, p_s_inode);
+ reiserfs_update_sd(th, inode);
out:
pathrelse(&s_search_path);
--- a/fs/reiserfs/tail_conversion.c 2007-06-11 14:49:39.000000000 -0400
+++ b/fs/reiserfs/tail_conversion.c 2007-06-11 14:50:02.000000000 -0400
@@ -170,12 +170,12 @@ void reiserfs_unmap_buffer(struct buffer
what we expect from it (number of cut bytes). But when tail remains
in the unformatted node, we set mode to SKIP_BALANCING and unlock
inode */
-int indirect2direct(struct reiserfs_transaction_handle *th, struct inode *p_s_inode, struct page *page, struct treepath *p_s_path, /* path to the indirect item. */
+int indirect2direct(struct reiserfs_transaction_handle *th, struct inode *inode, struct page *page, struct treepath *p_s_path, /* path to the indirect item. */
const struct cpu_key *p_s_item_key, /* Key to look for unformatted node pointer to be cut. */
loff_t n_new_file_size, /* New file size. */
char *p_c_mode)
{
- struct super_block *sb = p_s_inode->i_sb;
+ struct super_block *sb = inode->i_sb;
struct item_head s_ih;
unsigned long n_block_size = sb->s_blocksize;
char *tail;
@@ -193,7 +193,7 @@ int indirect2direct(struct reiserfs_tran
copy_item_head(&s_ih, PATH_PITEM_HEAD(p_s_path));
tail_len = (n_new_file_size & (n_block_size - 1));
- if (get_inode_sd_version(p_s_inode) == STAT_DATA_V2)
+ if (get_inode_sd_version(inode) == STAT_DATA_V2)
round_tail_len = ROUND_UP(tail_len);
else
round_tail_len = tail_len;
@@ -228,7 +228,7 @@ int indirect2direct(struct reiserfs_tran
}
/* Set direct item header to insert. */
- make_le_item_head(&s_ih, NULL, get_inode_item_key_version(p_s_inode),
+ make_le_item_head(&s_ih, NULL, get_inode_item_key_version(inode),
pos1 + 1, TYPE_DIRECT, round_tail_len,
0xffff /*ih_free_space */ );
@@ -244,7 +244,7 @@ int indirect2direct(struct reiserfs_tran
set_cpu_key_k_type(&key, TYPE_DIRECT);
key.key_length = 4;
/* Insert tail as new direct item in the tree */
- if (reiserfs_insert_item(th, p_s_path, &key, &s_ih, p_s_inode,
+ if (reiserfs_insert_item(th, p_s_path, &key, &s_ih, inode,
tail ? tail : NULL) < 0) {
/* No disk memory. So we can not convert last unformatted node
to the direct item. In this case we used to adjust
@@ -258,7 +258,7 @@ int indirect2direct(struct reiserfs_tran
kunmap(page);
/* make sure to get the i_blocks changes from reiserfs_insert_item */
- reiserfs_update_sd(th, p_s_inode);
+ reiserfs_update_sd(th, inode);
// note: we have now the same as in above direct2indirect
// conversion: there are two keys which have matching first three
@@ -269,8 +269,8 @@ int indirect2direct(struct reiserfs_tran
*p_c_mode = M_CUT;
/* we store position of first direct item in the in-core inode */
- //mark_file_with_tail (p_s_inode, pos1 + 1);
- REISERFS_I(p_s_inode)->i_first_direct_byte = pos1 + 1;
+ //mark_file_with_tail (inode, pos1 + 1);
+ REISERFS_I(inode)->i_first_direct_byte = pos1 + 1;
return n_block_size - round_tail_len;
}
--- a/include/linux/reiserfs_fs.h 2007-06-11 14:49:40.000000000 -0400
+++ b/include/linux/reiserfs_fs.h 2007-06-11 14:50:03.000000000 -0400
@@ -1859,9 +1859,9 @@ int reiserfs_delete_item(struct reiserfs
void reiserfs_delete_solid_item(struct reiserfs_transaction_handle *th,
struct inode *inode, struct reiserfs_key *key);
int reiserfs_delete_object(struct reiserfs_transaction_handle *th,
- struct inode *p_s_inode);
+ struct inode *inode);
int reiserfs_do_truncate(struct reiserfs_transaction_handle *th,
- struct inode *p_s_inode, struct page *,
+ struct inode *inode, struct page *,
int update_timestamps);
#define i_block_size(inode) ((inode)->i_sb->s_blocksize)
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 43+ messages in thread
* [patch 28/40] reiserfs: rename p_s_tb to tb
2007-06-11 19:03 [patch 00/40] reiserfs: patch queue (v2) jeffm
` (25 preceding siblings ...)
2007-06-11 19:03 ` [patch 27/40] reiserfs: rename p_s_inode to inode jeffm
@ 2007-06-11 19:03 ` jeffm
2007-06-11 19:03 ` [patch 29/40] reiserfs: rename p_._ variables jeffm
` (13 subsequent siblings)
40 siblings, 0 replies; 43+ messages in thread
From: jeffm @ 2007-06-11 19:03 UTC (permalink / raw)
To: ReiserFS Mailing List
[-- Attachment #1: reiserfs-rename-p_s_tb.diff --]
[-- Type: text/plain, Size: 35669 bytes --]
This patch is a simple s/p_s_tb/tb/g to the reiserfs code. This is the fourth
in a series of patches to rip out some of the awful variable naming in
reiserfs.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
fs/reiserfs/fix_node.c | 446 ++++++++++++++++++++++----------------------
fs/reiserfs/stree.c | 20 -
include/linux/reiserfs_fs.h | 2
3 files changed, 234 insertions(+), 234 deletions(-)
--- a/fs/reiserfs/fix_node.c 2007-06-11 14:49:40.000000000 -0400
+++ b/fs/reiserfs/fix_node.c 2007-06-11 14:50:02.000000000 -0400
@@ -749,26 +749,26 @@ else \
-1, -1);\
}
-static void free_buffers_in_tb(struct tree_balance *p_s_tb)
+static void free_buffers_in_tb(struct tree_balance *tb)
{
int n_counter;
- pathrelse(p_s_tb->tb_path);
+ pathrelse(tb->tb_path);
for (n_counter = 0; n_counter < MAX_HEIGHT; n_counter++) {
- brelse(p_s_tb->L[n_counter]);
- brelse(p_s_tb->R[n_counter]);
- brelse(p_s_tb->FL[n_counter]);
- brelse(p_s_tb->FR[n_counter]);
- brelse(p_s_tb->CFL[n_counter]);
- brelse(p_s_tb->CFR[n_counter]);
-
- p_s_tb->L[n_counter] = NULL;
- p_s_tb->R[n_counter] = NULL;
- p_s_tb->FL[n_counter] = NULL;
- p_s_tb->FR[n_counter] = NULL;
- p_s_tb->CFL[n_counter] = NULL;
- p_s_tb->CFR[n_counter] = NULL;
+ brelse(tb->L[n_counter]);
+ brelse(tb->R[n_counter]);
+ brelse(tb->FL[n_counter]);
+ brelse(tb->FR[n_counter]);
+ brelse(tb->CFL[n_counter]);
+ brelse(tb->CFR[n_counter]);
+
+ tb->L[n_counter] = NULL;
+ tb->R[n_counter] = NULL;
+ tb->FL[n_counter] = NULL;
+ tb->FR[n_counter] = NULL;
+ tb->CFL[n_counter] = NULL;
+ tb->CFR[n_counter] = NULL;
}
}
@@ -778,14 +778,14 @@ static void free_buffers_in_tb(struct tr
* NO_DISK_SPACE - no disk space.
*/
/* The function is NOT SCHEDULE-SAFE! */
-static int get_empty_nodes(struct tree_balance *p_s_tb, int n_h)
+static int get_empty_nodes(struct tree_balance *tb, int n_h)
{
struct buffer_head *p_s_new_bh,
- *p_s_Sh = PATH_H_PBUFFER(p_s_tb->tb_path, n_h);
+ *p_s_Sh = PATH_H_PBUFFER(tb->tb_path, n_h);
b_blocknr_t *p_n_blocknr, a_n_blocknrs[MAX_AMOUNT_NEEDED] = { 0, };
int n_counter, n_number_of_freeblk, n_amount_needed, /* number of needed empty blocks */
n_retval = CARRY_ON;
- struct super_block *sb = p_s_tb->tb_sb;
+ struct super_block *sb = tb->tb_sb;
/* number_of_freeblk is the number of empty blocks which have been
acquired for use by the balancing algorithm minus the number of
@@ -803,15 +803,15 @@ static int get_empty_nodes(struct tree_b
the analysis or 0 if not restarted, then subtract the amount needed
by all of the levels of the tree below n_h. */
/* blknum includes S[n_h], so we subtract 1 in this calculation */
- for (n_counter = 0, n_number_of_freeblk = p_s_tb->cur_blknum;
+ for (n_counter = 0, n_number_of_freeblk = tb->cur_blknum;
n_counter < n_h; n_counter++)
n_number_of_freeblk -=
- (p_s_tb->blknum[n_counter]) ? (p_s_tb->blknum[n_counter] -
+ (tb->blknum[n_counter]) ? (tb->blknum[n_counter] -
1) : 0;
/* Allocate missing empty blocks. */
/* if p_s_Sh == 0 then we are getting a new root */
- n_amount_needed = (p_s_Sh) ? (p_s_tb->blknum[n_h] - 1) : 1;
+ n_amount_needed = (p_s_Sh) ? (tb->blknum[n_h] - 1) : 1;
/* Amount_needed = the amount that we need more than the amount that we have. */
if (n_amount_needed > n_number_of_freeblk)
n_amount_needed -= n_number_of_freeblk;
@@ -819,7 +819,7 @@ static int get_empty_nodes(struct tree_b
return CARRY_ON;
/* No need to check quota - is not allocated for blocks used for formatted nodes */
- if (reiserfs_new_form_blocknrs(p_s_tb, a_n_blocknrs,
+ if (reiserfs_new_form_blocknrs(tb, a_n_blocknrs,
n_amount_needed) == NO_DISK_SPACE)
return NO_DISK_SPACE;
@@ -838,14 +838,14 @@ static int get_empty_nodes(struct tree_b
p_s_new_bh);
/* Put empty buffers into the array. */
- RFALSE(p_s_tb->FEB[p_s_tb->cur_blknum],
+ RFALSE(tb->FEB[tb->cur_blknum],
"PAP-8141: busy slot for new buffer");
set_buffer_journal_new(p_s_new_bh);
- p_s_tb->FEB[p_s_tb->cur_blknum++] = p_s_new_bh;
+ tb->FEB[tb->cur_blknum++] = p_s_new_bh;
}
- if (n_retval == CARRY_ON && FILESYSTEM_CHANGED_TB(p_s_tb))
+ if (n_retval == CARRY_ON && FILESYSTEM_CHANGED_TB(tb))
n_retval = REPEAT_SEARCH;
return n_retval;
@@ -894,33 +894,33 @@ static int get_rfree(struct tree_balance
}
/* Check whether left neighbor is in memory. */
-static int is_left_neighbor_in_cache(struct tree_balance *p_s_tb, int n_h)
+static int is_left_neighbor_in_cache(struct tree_balance *tb, int n_h)
{
struct buffer_head *p_s_father, *left;
- struct super_block *sb = p_s_tb->tb_sb;
+ struct super_block *sb = tb->tb_sb;
b_blocknr_t n_left_neighbor_blocknr;
int n_left_neighbor_position;
- if (!p_s_tb->FL[n_h]) /* Father of the left neighbor does not exist. */
+ if (!tb->FL[n_h]) /* Father of the left neighbor does not exist. */
return 0;
/* Calculate father of the node to be balanced. */
- p_s_father = PATH_H_PBUFFER(p_s_tb->tb_path, n_h + 1);
+ p_s_father = PATH_H_PBUFFER(tb->tb_path, n_h + 1);
RFALSE(!p_s_father ||
!B_IS_IN_TREE(p_s_father) ||
- !B_IS_IN_TREE(p_s_tb->FL[n_h]) ||
+ !B_IS_IN_TREE(tb->FL[n_h]) ||
!buffer_uptodate(p_s_father) ||
- !buffer_uptodate(p_s_tb->FL[n_h]),
+ !buffer_uptodate(tb->FL[n_h]),
"vs-8165: F[h] (%b) or FL[h] (%b) is invalid",
- p_s_father, p_s_tb->FL[n_h]);
+ p_s_father, tb->FL[n_h]);
/* Get position of the pointer to the left neighbor into the left father. */
- n_left_neighbor_position = (p_s_father == p_s_tb->FL[n_h]) ?
- p_s_tb->lkey[n_h] : B_NR_ITEMS(p_s_tb->FL[n_h]);
+ n_left_neighbor_position = (p_s_father == tb->FL[n_h]) ?
+ tb->lkey[n_h] : B_NR_ITEMS(tb->FL[n_h]);
/* Get left neighbor block number. */
n_left_neighbor_blocknr =
- B_N_CHILD_NUM(p_s_tb->FL[n_h], n_left_neighbor_position);
+ B_N_CHILD_NUM(tb->FL[n_h], n_left_neighbor_position);
/* Look for the left neighbor in the cache. */
if ((left = sb_find_get_block(sb, n_left_neighbor_blocknr))) {
@@ -951,14 +951,14 @@ static void decrement_key(struct cpu_key
SCHEDULE_OCCURRED - schedule occurred while the function worked;
* CARRY_ON - schedule didn't occur while the function worked;
*/
-static int get_far_parent(struct tree_balance *p_s_tb,
+static int get_far_parent(struct tree_balance *tb,
int n_h,
struct buffer_head **pp_s_father,
struct buffer_head **pp_s_com_father, char c_lr_par)
{
struct buffer_head *p_s_parent;
INITIALIZE_PATH(s_path_to_neighbor_father);
- struct treepath *p_s_path = p_s_tb->tb_path;
+ struct treepath *p_s_path = tb->tb_path;
struct cpu_key s_lr_father_key;
int n_counter,
n_position = INT_MAX,
@@ -1003,9 +1003,9 @@ static int get_far_parent(struct tree_ba
if (n_counter == FIRST_PATH_ELEMENT_OFFSET) {
/* Check whether first buffer in the path is the root of the tree. */
if (PATH_OFFSET_PBUFFER
- (p_s_tb->tb_path,
+ (tb->tb_path,
FIRST_PATH_ELEMENT_OFFSET)->b_blocknr ==
- SB_ROOT_BLOCK(p_s_tb->tb_sb)) {
+ SB_ROOT_BLOCK(tb->tb_sb)) {
*pp_s_father = *pp_s_com_father = NULL;
return CARRY_ON;
}
@@ -1020,7 +1020,7 @@ static int get_far_parent(struct tree_ba
if (buffer_locked(*pp_s_com_father)) {
__wait_on_buffer(*pp_s_com_father);
- if (FILESYSTEM_CHANGED_TB(p_s_tb)) {
+ if (FILESYSTEM_CHANGED_TB(tb)) {
brelse(*pp_s_com_father);
return REPEAT_SEARCH;
}
@@ -1033,9 +1033,9 @@ static int get_far_parent(struct tree_ba
le_key2cpu_key(&s_lr_father_key,
B_N_PDELIM_KEY(*pp_s_com_father,
(c_lr_par ==
- LEFT_PARENTS) ? (p_s_tb->lkey[n_h - 1] =
+ LEFT_PARENTS) ? (tb->lkey[n_h - 1] =
n_position -
- 1) : (p_s_tb->rkey[n_h -
+ 1) : (tb->rkey[n_h -
1] =
n_position)));
@@ -1043,12 +1043,12 @@ static int get_far_parent(struct tree_ba
decrement_key(&s_lr_father_key);
if (search_by_key
- (p_s_tb->tb_sb, &s_lr_father_key, &s_path_to_neighbor_father,
+ (tb->tb_sb, &s_lr_father_key, &s_path_to_neighbor_father,
n_h + 1) == IO_ERROR)
// path is released
return IO_ERROR;
- if (FILESYSTEM_CHANGED_TB(p_s_tb)) {
+ if (FILESYSTEM_CHANGED_TB(tb)) {
pathrelse(&s_path_to_neighbor_father);
brelse(*pp_s_com_father);
return REPEAT_SEARCH;
@@ -1073,24 +1073,24 @@ static int get_far_parent(struct tree_ba
* Returns: SCHEDULE_OCCURRED - schedule occurred while the function worked;
* CARRY_ON - schedule didn't occur while the function worked;
*/
-static int get_parents(struct tree_balance *p_s_tb, int n_h)
+static int get_parents(struct tree_balance *tb, int n_h)
{
- struct treepath *p_s_path = p_s_tb->tb_path;
+ struct treepath *p_s_path = tb->tb_path;
int n_position,
n_ret_value,
- n_path_offset = PATH_H_PATH_OFFSET(p_s_tb->tb_path, n_h);
+ n_path_offset = PATH_H_PATH_OFFSET(tb->tb_path, n_h);
struct buffer_head *p_s_curf, *p_s_curcf;
/* Current node is the root of the tree or will be root of the tree */
if (n_path_offset <= FIRST_PATH_ELEMENT_OFFSET) {
/* The root can not have parents.
Release nodes which previously were obtained as parents of the current node neighbors. */
- brelse(p_s_tb->FL[n_h]);
- brelse(p_s_tb->CFL[n_h]);
- brelse(p_s_tb->FR[n_h]);
- brelse(p_s_tb->CFR[n_h]);
- p_s_tb->FL[n_h] = p_s_tb->CFL[n_h] = p_s_tb->FR[n_h] =
- p_s_tb->CFR[n_h] = NULL;
+ brelse(tb->FL[n_h]);
+ brelse(tb->CFL[n_h]);
+ brelse(tb->FR[n_h]);
+ brelse(tb->CFR[n_h]);
+ tb->FL[n_h] = tb->CFL[n_h] = tb->FR[n_h] =
+ tb->CFR[n_h] = NULL;
return CARRY_ON;
}
@@ -1102,22 +1102,22 @@ static int get_parents(struct tree_balan
PATH_OFFSET_PBUFFER(p_s_path, n_path_offset - 1);
get_bh(p_s_curf);
get_bh(p_s_curf);
- p_s_tb->lkey[n_h] = n_position - 1;
+ tb->lkey[n_h] = n_position - 1;
} else {
/* Calculate current parent of L[n_path_offset], which is the left neighbor of the current node.
Calculate current common parent of L[n_path_offset] and the current node. Note that
CFL[n_path_offset] not equal FL[n_path_offset] and CFL[n_path_offset] not equal F[n_path_offset].
Calculate lkey[n_path_offset]. */
- if ((n_ret_value = get_far_parent(p_s_tb, n_h + 1, &p_s_curf,
+ if ((n_ret_value = get_far_parent(tb, n_h + 1, &p_s_curf,
&p_s_curcf,
LEFT_PARENTS)) != CARRY_ON)
return n_ret_value;
}
- brelse(p_s_tb->FL[n_h]);
- p_s_tb->FL[n_h] = p_s_curf; /* New initialization of FL[n_h]. */
- brelse(p_s_tb->CFL[n_h]);
- p_s_tb->CFL[n_h] = p_s_curcf; /* New initialization of CFL[n_h]. */
+ brelse(tb->FL[n_h]);
+ tb->FL[n_h] = p_s_curf; /* New initialization of FL[n_h]. */
+ brelse(tb->CFL[n_h]);
+ tb->CFL[n_h] = p_s_curcf; /* New initialization of CFL[n_h]. */
RFALSE((p_s_curf && !B_IS_IN_TREE(p_s_curf)) ||
(p_s_curcf && !B_IS_IN_TREE(p_s_curcf)),
@@ -1131,7 +1131,7 @@ static int get_parents(struct tree_balan
Calculate current common parent of R[n_h] and current node. Note that CFR[n_h]
not equal FR[n_path_offset] and CFR[n_h] not equal F[n_h]. */
if ((n_ret_value =
- get_far_parent(p_s_tb, n_h + 1, &p_s_curf, &p_s_curcf,
+ get_far_parent(tb, n_h + 1, &p_s_curf, &p_s_curcf,
RIGHT_PARENTS)) != CARRY_ON)
return n_ret_value;
} else {
@@ -1141,14 +1141,14 @@ static int get_parents(struct tree_balan
PATH_OFFSET_PBUFFER(p_s_path, n_path_offset - 1);
get_bh(p_s_curf);
get_bh(p_s_curf);
- p_s_tb->rkey[n_h] = n_position;
+ tb->rkey[n_h] = n_position;
}
- brelse(p_s_tb->FR[n_h]);
- p_s_tb->FR[n_h] = p_s_curf; /* New initialization of FR[n_path_offset]. */
+ brelse(tb->FR[n_h]);
+ tb->FR[n_h] = p_s_curf; /* New initialization of FR[n_path_offset]. */
- brelse(p_s_tb->CFR[n_h]);
- p_s_tb->CFR[n_h] = p_s_curcf; /* New initialization of CFR[n_path_offset]. */
+ brelse(tb->CFR[n_h]);
+ tb->CFR[n_h] = p_s_curcf; /* New initialization of CFR[n_path_offset]. */
RFALSE((p_s_curf && !B_IS_IN_TREE(p_s_curf)) ||
(p_s_curcf && !B_IS_IN_TREE(p_s_curcf)),
@@ -1883,12 +1883,12 @@ static int check_balance(int mode,
}
/* Check whether parent at the path is the really parent of the current node.*/
-static int get_direct_parent(struct tree_balance *p_s_tb, int n_h)
+static int get_direct_parent(struct tree_balance *tb, int n_h)
{
struct buffer_head *bh;
- struct treepath *p_s_path = p_s_tb->tb_path;
+ struct treepath *p_s_path = tb->tb_path;
int n_position,
- n_path_offset = PATH_H_PATH_OFFSET(p_s_tb->tb_path, n_h);
+ n_path_offset = PATH_H_PATH_OFFSET(tb->tb_path, n_h);
/* We are in the root or in the new root. */
if (n_path_offset <= FIRST_PATH_ELEMENT_OFFSET) {
@@ -1897,7 +1897,7 @@ static int get_direct_parent(struct tree
"PAP-8260: invalid offset in the path");
if (PATH_OFFSET_PBUFFER(p_s_path, FIRST_PATH_ELEMENT_OFFSET)->
- b_blocknr == SB_ROOT_BLOCK(p_s_tb->tb_sb)) {
+ b_blocknr == SB_ROOT_BLOCK(tb->tb_sb)) {
/* Root is not changed. */
PATH_OFFSET_PBUFFER(p_s_path, n_path_offset - 1) = NULL;
PATH_OFFSET_POSITION(p_s_path, n_path_offset - 1) = 0;
@@ -1922,7 +1922,7 @@ static int get_direct_parent(struct tree
if (buffer_locked(bh)) {
__wait_on_buffer(bh);
- if (FILESYSTEM_CHANGED_TB(p_s_tb))
+ if (FILESYSTEM_CHANGED_TB(tb))
return REPEAT_SEARCH;
}
@@ -1935,85 +1935,85 @@ static int get_direct_parent(struct tree
* Returns: SCHEDULE_OCCURRED - schedule occurred while the function worked;
* CARRY_ON - schedule didn't occur while the function worked;
*/
-static int get_neighbors(struct tree_balance *p_s_tb, int n_h)
+static int get_neighbors(struct tree_balance *tb, int n_h)
{
int n_child_position,
- n_path_offset = PATH_H_PATH_OFFSET(p_s_tb->tb_path, n_h + 1);
+ n_path_offset = PATH_H_PATH_OFFSET(tb->tb_path, n_h + 1);
unsigned long n_son_number;
- struct super_block *sb = p_s_tb->tb_sb;
+ struct super_block *sb = tb->tb_sb;
struct buffer_head *bh;
PROC_INFO_INC(sb, get_neighbors[n_h]);
- if (p_s_tb->lnum[n_h]) {
+ if (tb->lnum[n_h]) {
/* We need left neighbor to balance S[n_h]. */
PROC_INFO_INC(sb, need_l_neighbor[n_h]);
- bh = PATH_OFFSET_PBUFFER(p_s_tb->tb_path, n_path_offset);
+ bh = PATH_OFFSET_PBUFFER(tb->tb_path, n_path_offset);
- RFALSE(bh == p_s_tb->FL[n_h] &&
- !PATH_OFFSET_POSITION(p_s_tb->tb_path, n_path_offset),
+ RFALSE(bh == tb->FL[n_h] &&
+ !PATH_OFFSET_POSITION(tb->tb_path, n_path_offset),
"PAP-8270: invalid position in the parent");
n_child_position =
(bh ==
- p_s_tb->FL[n_h]) ? p_s_tb->lkey[n_h] : B_NR_ITEMS(p_s_tb->
+ tb->FL[n_h]) ? tb->lkey[n_h] : B_NR_ITEMS(tb->
FL[n_h]);
- n_son_number = B_N_CHILD_NUM(p_s_tb->FL[n_h], n_child_position);
+ n_son_number = B_N_CHILD_NUM(tb->FL[n_h], n_child_position);
bh = sb_bread(sb, n_son_number);
if (!bh)
return IO_ERROR;
- if (FILESYSTEM_CHANGED_TB(p_s_tb)) {
+ if (FILESYSTEM_CHANGED_TB(tb)) {
brelse(bh);
PROC_INFO_INC(sb, get_neighbors_restart[n_h]);
return REPEAT_SEARCH;
}
- RFALSE(!B_IS_IN_TREE(p_s_tb->FL[n_h]) ||
- n_child_position > B_NR_ITEMS(p_s_tb->FL[n_h]) ||
- B_N_CHILD_NUM(p_s_tb->FL[n_h], n_child_position) !=
+ RFALSE(!B_IS_IN_TREE(tb->FL[n_h]) ||
+ n_child_position > B_NR_ITEMS(tb->FL[n_h]) ||
+ B_N_CHILD_NUM(tb->FL[n_h], n_child_position) !=
bh->b_blocknr, "PAP-8275: invalid parent");
RFALSE(!B_IS_IN_TREE(bh), "PAP-8280: invalid child");
RFALSE(!n_h &&
B_FREE_SPACE(bh) !=
MAX_CHILD_SIZE(bh) -
- dc_size(B_N_CHILD(p_s_tb->FL[0], n_child_position)),
+ dc_size(B_N_CHILD(tb->FL[0], n_child_position)),
"PAP-8290: invalid child size of left neighbor");
- brelse(p_s_tb->L[n_h]);
- p_s_tb->L[n_h] = bh;
+ brelse(tb->L[n_h]);
+ tb->L[n_h] = bh;
}
- if (p_s_tb->rnum[n_h]) { /* We need right neighbor to balance S[n_path_offset]. */
+ if (tb->rnum[n_h]) { /* We need right neighbor to balance S[n_path_offset]. */
PROC_INFO_INC(sb, need_r_neighbor[n_h]);
- bh = PATH_OFFSET_PBUFFER(p_s_tb->tb_path, n_path_offset);
+ bh = PATH_OFFSET_PBUFFER(tb->tb_path, n_path_offset);
- RFALSE(bh == p_s_tb->FR[n_h] &&
- PATH_OFFSET_POSITION(p_s_tb->tb_path,
+ RFALSE(bh == tb->FR[n_h] &&
+ PATH_OFFSET_POSITION(tb->tb_path,
n_path_offset) >=
B_NR_ITEMS(bh),
"PAP-8295: invalid position in the parent");
n_child_position =
- (bh == p_s_tb->FR[n_h]) ? p_s_tb->rkey[n_h] + 1 : 0;
- n_son_number = B_N_CHILD_NUM(p_s_tb->FR[n_h], n_child_position);
+ (bh == tb->FR[n_h]) ? tb->rkey[n_h] + 1 : 0;
+ n_son_number = B_N_CHILD_NUM(tb->FR[n_h], n_child_position);
bh = sb_bread(sb, n_son_number);
if (!bh)
return IO_ERROR;
- if (FILESYSTEM_CHANGED_TB(p_s_tb)) {
+ if (FILESYSTEM_CHANGED_TB(tb)) {
brelse(bh);
PROC_INFO_INC(sb, get_neighbors_restart[n_h]);
return REPEAT_SEARCH;
}
- brelse(p_s_tb->R[n_h]);
- p_s_tb->R[n_h] = bh;
+ brelse(tb->R[n_h]);
+ tb->R[n_h] = bh;
RFALSE(!n_h
&& B_FREE_SPACE(bh) !=
MAX_CHILD_SIZE(bh) -
- dc_size(B_N_CHILD(p_s_tb->FR[0], n_child_position)),
+ dc_size(B_N_CHILD(tb->FR[0], n_child_position)),
"PAP-8300: invalid child size of right neighbor (%d != %d - %d)",
B_FREE_SPACE(bh), MAX_CHILD_SIZE(bh),
- dc_size(B_N_CHILD(p_s_tb->FR[0], n_child_position)));
+ dc_size(B_N_CHILD(tb->FR[0], n_child_position)));
}
return CARRY_ON;
@@ -2143,7 +2143,7 @@ static int clear_all_dirty_bits(struct s
return reiserfs_prepare_for_journal(s, bh, 0);
}
-static int wait_tb_buffers_until_unlocked(struct tree_balance *p_s_tb)
+static int wait_tb_buffers_until_unlocked(struct tree_balance *tb)
{
struct buffer_head *locked;
#ifdef CONFIG_REISERFS_CHECK
@@ -2155,95 +2155,95 @@ static int wait_tb_buffers_until_unlocke
locked = NULL;
- for (i = p_s_tb->tb_path->path_length;
+ for (i = tb->tb_path->path_length;
!locked && i > ILLEGAL_PATH_ELEMENT_OFFSET; i--) {
- if (PATH_OFFSET_PBUFFER(p_s_tb->tb_path, i)) {
+ if (PATH_OFFSET_PBUFFER(tb->tb_path, i)) {
/* if I understand correctly, we can only be sure the last buffer
** in the path is in the tree --clm
*/
#ifdef CONFIG_REISERFS_CHECK
- if (PATH_PLAST_BUFFER(p_s_tb->tb_path) ==
- PATH_OFFSET_PBUFFER(p_s_tb->tb_path, i)) {
- tb_buffer_sanity_check(p_s_tb->tb_sb,
+ if (PATH_PLAST_BUFFER(tb->tb_path) ==
+ PATH_OFFSET_PBUFFER(tb->tb_path, i)) {
+ tb_buffer_sanity_check(tb->tb_sb,
PATH_OFFSET_PBUFFER
- (p_s_tb->tb_path,
+ (tb->tb_path,
i), "S",
- p_s_tb->tb_path->
+ tb->tb_path->
path_length - i);
}
#endif
- if (!clear_all_dirty_bits(p_s_tb->tb_sb,
+ if (!clear_all_dirty_bits(tb->tb_sb,
PATH_OFFSET_PBUFFER
- (p_s_tb->tb_path,
+ (tb->tb_path,
i))) {
locked =
- PATH_OFFSET_PBUFFER(p_s_tb->tb_path,
+ PATH_OFFSET_PBUFFER(tb->tb_path,
i);
}
}
}
- for (i = 0; !locked && i < MAX_HEIGHT && p_s_tb->insert_size[i];
+ for (i = 0; !locked && i < MAX_HEIGHT && tb->insert_size[i];
i++) {
- if (p_s_tb->lnum[i]) {
+ if (tb->lnum[i]) {
- if (p_s_tb->L[i]) {
- tb_buffer_sanity_check(p_s_tb->tb_sb,
- p_s_tb->L[i],
+ if (tb->L[i]) {
+ tb_buffer_sanity_check(tb->tb_sb,
+ tb->L[i],
"L", i);
if (!clear_all_dirty_bits
- (p_s_tb->tb_sb, p_s_tb->L[i]))
- locked = p_s_tb->L[i];
+ (tb->tb_sb, tb->L[i]))
+ locked = tb->L[i];
}
- if (!locked && p_s_tb->FL[i]) {
- tb_buffer_sanity_check(p_s_tb->tb_sb,
- p_s_tb->FL[i],
+ if (!locked && tb->FL[i]) {
+ tb_buffer_sanity_check(tb->tb_sb,
+ tb->FL[i],
"FL", i);
if (!clear_all_dirty_bits
- (p_s_tb->tb_sb, p_s_tb->FL[i]))
- locked = p_s_tb->FL[i];
+ (tb->tb_sb, tb->FL[i]))
+ locked = tb->FL[i];
}
- if (!locked && p_s_tb->CFL[i]) {
- tb_buffer_sanity_check(p_s_tb->tb_sb,
- p_s_tb->CFL[i],
+ if (!locked && tb->CFL[i]) {
+ tb_buffer_sanity_check(tb->tb_sb,
+ tb->CFL[i],
"CFL", i);
if (!clear_all_dirty_bits
- (p_s_tb->tb_sb, p_s_tb->CFL[i]))
- locked = p_s_tb->CFL[i];
+ (tb->tb_sb, tb->CFL[i]))
+ locked = tb->CFL[i];
}
}
- if (!locked && (p_s_tb->rnum[i])) {
+ if (!locked && (tb->rnum[i])) {
- if (p_s_tb->R[i]) {
- tb_buffer_sanity_check(p_s_tb->tb_sb,
- p_s_tb->R[i],
+ if (tb->R[i]) {
+ tb_buffer_sanity_check(tb->tb_sb,
+ tb->R[i],
"R", i);
if (!clear_all_dirty_bits
- (p_s_tb->tb_sb, p_s_tb->R[i]))
- locked = p_s_tb->R[i];
+ (tb->tb_sb, tb->R[i]))
+ locked = tb->R[i];
}
- if (!locked && p_s_tb->FR[i]) {
- tb_buffer_sanity_check(p_s_tb->tb_sb,
- p_s_tb->FR[i],
+ if (!locked && tb->FR[i]) {
+ tb_buffer_sanity_check(tb->tb_sb,
+ tb->FR[i],
"FR", i);
if (!clear_all_dirty_bits
- (p_s_tb->tb_sb, p_s_tb->FR[i]))
- locked = p_s_tb->FR[i];
+ (tb->tb_sb, tb->FR[i]))
+ locked = tb->FR[i];
}
- if (!locked && p_s_tb->CFR[i]) {
- tb_buffer_sanity_check(p_s_tb->tb_sb,
- p_s_tb->CFR[i],
+ if (!locked && tb->CFR[i]) {
+ tb_buffer_sanity_check(tb->tb_sb,
+ tb->CFR[i],
"CFR", i);
if (!clear_all_dirty_bits
- (p_s_tb->tb_sb, p_s_tb->CFR[i]))
- locked = p_s_tb->CFR[i];
+ (tb->tb_sb, tb->CFR[i]))
+ locked = tb->CFR[i];
}
}
}
@@ -2256,10 +2256,10 @@ static int wait_tb_buffers_until_unlocke
** --clm
*/
for (i = 0; !locked && i < MAX_FEB_SIZE; i++) {
- if (p_s_tb->FEB[i]) {
+ if (tb->FEB[i]) {
if (!clear_all_dirty_bits
- (p_s_tb->tb_sb, p_s_tb->FEB[i]))
- locked = p_s_tb->FEB[i];
+ (tb->tb_sb, tb->FEB[i]))
+ locked = tb->FEB[i];
}
}
@@ -2267,19 +2267,19 @@ static int wait_tb_buffers_until_unlocke
#ifdef CONFIG_REISERFS_CHECK
repeat_counter++;
if ((repeat_counter % 10000) == 0) {
- reiserfs_warning(p_s_tb->tb_sb, "reiserfs-8200",
+ reiserfs_warning(tb->tb_sb, "reiserfs-8200",
"too many iterations waiting "
"for buffer to unlock "
"(%b)", locked);
/* Don't loop forever. Try to recover from possible error. */
- return (FILESYSTEM_CHANGED_TB(p_s_tb)) ?
+ return (FILESYSTEM_CHANGED_TB(tb)) ?
REPEAT_SEARCH : CARRY_ON;
}
#endif
__wait_on_buffer(locked);
- if (FILESYSTEM_CHANGED_TB(p_s_tb)) {
+ if (FILESYSTEM_CHANGED_TB(tb)) {
return REPEAT_SEARCH;
}
}
@@ -2317,132 +2317,132 @@ static int wait_tb_buffers_until_unlocke
* -1 - if no_disk_space
*/
-int fix_nodes(int n_op_mode, struct tree_balance *p_s_tb, struct item_head *p_s_ins_ih, // item head of item being inserted
+int fix_nodes(int n_op_mode, struct tree_balance *tb, struct item_head *p_s_ins_ih, // item head of item being inserted
const void *data // inserted item or data to be pasted
)
{
- int n_ret_value, n_h, n_item_num = PATH_LAST_POSITION(p_s_tb->tb_path);
+ int n_ret_value, n_h, n_item_num = PATH_LAST_POSITION(tb->tb_path);
int n_pos_in_item;
/* we set wait_tb_buffers_run when we have to restore any dirty bits cleared
** during wait_tb_buffers_run
*/
int wait_tb_buffers_run = 0;
- struct buffer_head *p_s_tbS0 = PATH_PLAST_BUFFER(p_s_tb->tb_path);
+ struct buffer_head *tbS0 = PATH_PLAST_BUFFER(tb->tb_path);
- ++REISERFS_SB(p_s_tb->tb_sb)->s_fix_nodes;
+ ++REISERFS_SB(tb->tb_sb)->s_fix_nodes;
- n_pos_in_item = p_s_tb->tb_path->pos_in_item;
+ n_pos_in_item = tb->tb_path->pos_in_item;
- p_s_tb->fs_gen = get_generation(p_s_tb->tb_sb);
+ tb->fs_gen = get_generation(tb->tb_sb);
/* we prepare and log the super here so it will already be in the
** transaction when do_balance needs to change it.
** This way do_balance won't have to schedule when trying to prepare
** the super for logging
*/
- reiserfs_prepare_for_journal(p_s_tb->tb_sb,
- SB_BUFFER_WITH_SB(p_s_tb->tb_sb), 1);
- journal_mark_dirty(p_s_tb->transaction_handle, p_s_tb->tb_sb,
- SB_BUFFER_WITH_SB(p_s_tb->tb_sb));
- if (FILESYSTEM_CHANGED_TB(p_s_tb))
+ reiserfs_prepare_for_journal(tb->tb_sb,
+ SB_BUFFER_WITH_SB(tb->tb_sb), 1);
+ journal_mark_dirty(tb->transaction_handle, tb->tb_sb,
+ SB_BUFFER_WITH_SB(tb->tb_sb));
+ if (FILESYSTEM_CHANGED_TB(tb))
return REPEAT_SEARCH;
/* if it possible in indirect_to_direct conversion */
- if (buffer_locked(p_s_tbS0)) {
- __wait_on_buffer(p_s_tbS0);
- if (FILESYSTEM_CHANGED_TB(p_s_tb))
+ if (buffer_locked(tbS0)) {
+ __wait_on_buffer(tbS0);
+ if (FILESYSTEM_CHANGED_TB(tb))
return REPEAT_SEARCH;
}
#ifdef CONFIG_REISERFS_CHECK
if (cur_tb) {
print_cur_tb("fix_nodes");
- reiserfs_panic(p_s_tb->tb_sb, "PAP-8305",
+ reiserfs_panic(tb->tb_sb, "PAP-8305",
"there is pending do_balance");
}
- if (!buffer_uptodate(p_s_tbS0) || !B_IS_IN_TREE(p_s_tbS0)) {
- reiserfs_panic(p_s_tb->tb_sb, "PAP-8320", "S[0] (%b %z) is "
+ if (!buffer_uptodate(tbS0) || !B_IS_IN_TREE(tbS0)) {
+ reiserfs_panic(tb->tb_sb, "PAP-8320", "S[0] (%b %z) is "
"not uptodate at the beginning of fix_nodes "
"or not in tree (mode %c)",
- p_s_tbS0, p_s_tbS0, n_op_mode);
+ tbS0, tbS0, n_op_mode);
}
/* Check parameters. */
switch (n_op_mode) {
case M_INSERT:
- if (n_item_num <= 0 || n_item_num > B_NR_ITEMS(p_s_tbS0))
- reiserfs_panic(p_s_tb->tb_sb, "PAP-8330", "Incorrect "
+ if (n_item_num <= 0 || n_item_num > B_NR_ITEMS(tbS0))
+ reiserfs_panic(tb->tb_sb, "PAP-8330", "Incorrect "
"item number %d (in S0 - %d) in case "
"of insert", n_item_num,
- B_NR_ITEMS(p_s_tbS0));
+ B_NR_ITEMS(tbS0));
break;
case M_PASTE:
case M_DELETE:
case M_CUT:
- if (n_item_num < 0 || n_item_num >= B_NR_ITEMS(p_s_tbS0)) {
- print_block(p_s_tbS0, 0, -1, -1);
- reiserfs_panic(p_s_tb->tb_sb, "PAP-8335", "Incorrect "
+ if (n_item_num < 0 || n_item_num >= B_NR_ITEMS(tbS0)) {
+ print_block(tbS0, 0, -1, -1);
+ reiserfs_panic(tb->tb_sb, "PAP-8335", "Incorrect "
"item number(%d); mode = %c "
"insert_size = %d",
n_item_num, n_op_mode,
- p_s_tb->insert_size[0]);
+ tb->insert_size[0]);
}
break;
default:
- reiserfs_panic(p_s_tb->tb_sb, "PAP-8340", "Incorrect mode "
+ reiserfs_panic(tb->tb_sb, "PAP-8340", "Incorrect mode "
"of operation");
}
#endif
- if (get_mem_for_virtual_node(p_s_tb) == REPEAT_SEARCH)
+ if (get_mem_for_virtual_node(tb) == REPEAT_SEARCH)
// FIXME: maybe -ENOMEM when tb->vn_buf == 0? Now just repeat
return REPEAT_SEARCH;
/* Starting from the leaf level; for all levels n_h of the tree. */
- for (n_h = 0; n_h < MAX_HEIGHT && p_s_tb->insert_size[n_h]; n_h++) {
- if ((n_ret_value = get_direct_parent(p_s_tb, n_h)) != CARRY_ON) {
+ for (n_h = 0; n_h < MAX_HEIGHT && tb->insert_size[n_h]; n_h++) {
+ if ((n_ret_value = get_direct_parent(tb, n_h)) != CARRY_ON) {
goto repeat;
}
if ((n_ret_value =
- check_balance(n_op_mode, p_s_tb, n_h, n_item_num,
+ check_balance(n_op_mode, tb, n_h, n_item_num,
n_pos_in_item, p_s_ins_ih,
data)) != CARRY_ON) {
if (n_ret_value == NO_BALANCING_NEEDED) {
/* No balancing for higher levels needed. */
if ((n_ret_value =
- get_neighbors(p_s_tb, n_h)) != CARRY_ON) {
+ get_neighbors(tb, n_h)) != CARRY_ON) {
goto repeat;
}
if (n_h != MAX_HEIGHT - 1)
- p_s_tb->insert_size[n_h + 1] = 0;
+ tb->insert_size[n_h + 1] = 0;
/* ok, analysis and resource gathering are complete */
break;
}
goto repeat;
}
- if ((n_ret_value = get_neighbors(p_s_tb, n_h)) != CARRY_ON) {
+ if ((n_ret_value = get_neighbors(tb, n_h)) != CARRY_ON) {
goto repeat;
}
- if ((n_ret_value = get_empty_nodes(p_s_tb, n_h)) != CARRY_ON) {
+ if ((n_ret_value = get_empty_nodes(tb, n_h)) != CARRY_ON) {
goto repeat; /* No disk space, or schedule occurred and
analysis may be invalid and needs to be redone. */
}
- if (!PATH_H_PBUFFER(p_s_tb->tb_path, n_h)) {
+ if (!PATH_H_PBUFFER(tb->tb_path, n_h)) {
/* We have a positive insert size but no nodes exist on this
level, this means that we are creating a new root. */
- RFALSE(p_s_tb->blknum[n_h] != 1,
+ RFALSE(tb->blknum[n_h] != 1,
"PAP-8350: creating new empty root");
if (n_h < MAX_HEIGHT - 1)
- p_s_tb->insert_size[n_h + 1] = 0;
- } else if (!PATH_H_PBUFFER(p_s_tb->tb_path, n_h + 1)) {
- if (p_s_tb->blknum[n_h] > 1) {
+ tb->insert_size[n_h + 1] = 0;
+ } else if (!PATH_H_PBUFFER(tb->tb_path, n_h + 1)) {
+ if (tb->blknum[n_h] > 1) {
/* The tree needs to be grown, so this node S[n_h]
which is the root node is split into two nodes,
and a new node (S[n_h+1]) will be created to
@@ -2451,19 +2451,19 @@ int fix_nodes(int n_op_mode, struct tree
RFALSE(n_h == MAX_HEIGHT - 1,
"PAP-8355: attempt to create too high of a tree");
- p_s_tb->insert_size[n_h + 1] =
+ tb->insert_size[n_h + 1] =
(DC_SIZE +
- KEY_SIZE) * (p_s_tb->blknum[n_h] - 1) +
+ KEY_SIZE) * (tb->blknum[n_h] - 1) +
DC_SIZE;
} else if (n_h < MAX_HEIGHT - 1)
- p_s_tb->insert_size[n_h + 1] = 0;
+ tb->insert_size[n_h + 1] = 0;
} else
- p_s_tb->insert_size[n_h + 1] =
- (DC_SIZE + KEY_SIZE) * (p_s_tb->blknum[n_h] - 1);
+ tb->insert_size[n_h + 1] =
+ (DC_SIZE + KEY_SIZE) * (tb->blknum[n_h] - 1);
}
- if ((n_ret_value = wait_tb_buffers_until_unlocked(p_s_tb)) == CARRY_ON) {
- if (FILESYSTEM_CHANGED_TB(p_s_tb)) {
+ if ((n_ret_value = wait_tb_buffers_until_unlocked(tb)) == CARRY_ON) {
+ if (FILESYSTEM_CHANGED_TB(tb)) {
wait_tb_buffers_run = 1;
n_ret_value = REPEAT_SEARCH;
goto repeat;
@@ -2486,49 +2486,49 @@ int fix_nodes(int n_op_mode, struct tree
/* Release path buffers. */
if (wait_tb_buffers_run) {
- pathrelse_and_restore(p_s_tb->tb_sb, p_s_tb->tb_path);
+ pathrelse_and_restore(tb->tb_sb, tb->tb_path);
} else {
- pathrelse(p_s_tb->tb_path);
+ pathrelse(tb->tb_path);
}
/* brelse all resources collected for balancing */
for (i = 0; i < MAX_HEIGHT; i++) {
if (wait_tb_buffers_run) {
- reiserfs_restore_prepared_buffer(p_s_tb->tb_sb,
- p_s_tb->L[i]);
- reiserfs_restore_prepared_buffer(p_s_tb->tb_sb,
- p_s_tb->R[i]);
- reiserfs_restore_prepared_buffer(p_s_tb->tb_sb,
- p_s_tb->FL[i]);
- reiserfs_restore_prepared_buffer(p_s_tb->tb_sb,
- p_s_tb->FR[i]);
- reiserfs_restore_prepared_buffer(p_s_tb->tb_sb,
- p_s_tb->
+ reiserfs_restore_prepared_buffer(tb->tb_sb,
+ tb->L[i]);
+ reiserfs_restore_prepared_buffer(tb->tb_sb,
+ tb->R[i]);
+ reiserfs_restore_prepared_buffer(tb->tb_sb,
+ tb->FL[i]);
+ reiserfs_restore_prepared_buffer(tb->tb_sb,
+ tb->FR[i]);
+ reiserfs_restore_prepared_buffer(tb->tb_sb,
+ tb->
CFL[i]);
- reiserfs_restore_prepared_buffer(p_s_tb->tb_sb,
- p_s_tb->
+ reiserfs_restore_prepared_buffer(tb->tb_sb,
+ tb->
CFR[i]);
}
- brelse(p_s_tb->L[i]);
- brelse(p_s_tb->R[i]);
- brelse(p_s_tb->FL[i]);
- brelse(p_s_tb->FR[i]);
- brelse(p_s_tb->CFL[i]);
- brelse(p_s_tb->CFR[i]);
-
- p_s_tb->L[i] = NULL;
- p_s_tb->R[i] = NULL;
- p_s_tb->FL[i] = NULL;
- p_s_tb->FR[i] = NULL;
- p_s_tb->CFL[i] = NULL;
- p_s_tb->CFR[i] = NULL;
+ brelse(tb->L[i]);
+ brelse(tb->R[i]);
+ brelse(tb->FL[i]);
+ brelse(tb->FR[i]);
+ brelse(tb->CFL[i]);
+ brelse(tb->CFR[i]);
+
+ tb->L[i] = NULL;
+ tb->R[i] = NULL;
+ tb->FL[i] = NULL;
+ tb->FR[i] = NULL;
+ tb->CFL[i] = NULL;
+ tb->CFR[i] = NULL;
}
if (wait_tb_buffers_run) {
for (i = 0; i < MAX_FEB_SIZE; i++) {
- if (p_s_tb->FEB[i]) {
+ if (tb->FEB[i]) {
reiserfs_restore_prepared_buffer
- (p_s_tb->tb_sb, p_s_tb->FEB[i]);
+ (tb->tb_sb, tb->FEB[i]);
}
}
}
@@ -2537,7 +2537,7 @@ int fix_nodes(int n_op_mode, struct tree
}
-/* Anatoly will probably forgive me renaming p_s_tb to tb. I just
+/* Anatoly will probably forgive me renaming tb to tb. I just
wanted to make lines shorter */
void unfix_nodes(struct tree_balance *tb)
{
--- a/fs/reiserfs/stree.c 2007-06-11 14:49:40.000000000 -0400
+++ b/fs/reiserfs/stree.c 2007-06-11 14:50:02.000000000 -0400
@@ -1063,17 +1063,17 @@ static char prepare_for_delete_or_cut(st
}
/* Calculate number of bytes which will be deleted or cut during balance */
-static int calc_deleted_bytes_number(struct tree_balance *p_s_tb, char c_mode)
+static int calc_deleted_bytes_number(struct tree_balance *tb, char c_mode)
{
int n_del_size;
- struct item_head *p_le_ih = PATH_PITEM_HEAD(p_s_tb->tb_path);
+ struct item_head *p_le_ih = PATH_PITEM_HEAD(tb->tb_path);
if (is_statdata_le_ih(p_le_ih))
return 0;
n_del_size =
(c_mode ==
- M_DELETE) ? ih_item_len(p_le_ih) : -p_s_tb->insert_size[0];
+ M_DELETE) ? ih_item_len(p_le_ih) : -tb->insert_size[0];
if (is_direntry_le_ih(p_le_ih)) {
// return EMPTY_DIR_SIZE; /* We delete emty directoris only. */
// we can't use EMPTY_DIR_SIZE, as old format dirs have a different
@@ -1083,25 +1083,25 @@ static int calc_deleted_bytes_number(str
}
if (is_indirect_le_ih(p_le_ih))
- n_del_size = (n_del_size / UNFM_P_SIZE) * (PATH_PLAST_BUFFER(p_s_tb->tb_path)->b_size); // - get_ih_free_space (p_le_ih);
+ n_del_size = (n_del_size / UNFM_P_SIZE) * (PATH_PLAST_BUFFER(tb->tb_path)->b_size); // - get_ih_free_space (p_le_ih);
return n_del_size;
}
static void init_tb_struct(struct reiserfs_transaction_handle *th,
- struct tree_balance *p_s_tb,
+ struct tree_balance *tb,
struct super_block *sb,
struct treepath *p_s_path, int n_size)
{
BUG_ON(!th->t_trans_id);
- memset(p_s_tb, '\0', sizeof(struct tree_balance));
- p_s_tb->transaction_handle = th;
- p_s_tb->tb_sb = sb;
- p_s_tb->tb_path = p_s_path;
+ memset(tb, '\0', sizeof(struct tree_balance));
+ tb->transaction_handle = th;
+ tb->tb_sb = sb;
+ tb->tb_path = p_s_path;
PATH_OFFSET_PBUFFER(p_s_path, ILLEGAL_PATH_ELEMENT_OFFSET) = NULL;
PATH_OFFSET_POSITION(p_s_path, ILLEGAL_PATH_ELEMENT_OFFSET) = 0;
- p_s_tb->insert_size[0] = n_size;
+ tb->insert_size[0] = n_size;
}
void padd_item(char *item, int total_length, int length)
--- a/include/linux/reiserfs_fs.h 2007-06-11 14:49:40.000000000 -0400
+++ b/include/linux/reiserfs_fs.h 2007-06-11 14:50:02.000000000 -0400
@@ -1996,7 +1996,7 @@ extern const struct address_space_operat
/* fix_nodes.c */
-int fix_nodes(int n_op_mode, struct tree_balance *p_s_tb,
+int fix_nodes(int n_op_mode, struct tree_balance *tb,
struct item_head *p_s_ins_ih, const void *);
void unfix_nodes(struct tree_balance *);
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 43+ messages in thread
* [patch 29/40] reiserfs: rename p_._ variables
2007-06-11 19:03 [patch 00/40] reiserfs: patch queue (v2) jeffm
` (26 preceding siblings ...)
2007-06-11 19:03 ` [patch 28/40] reiserfs: rename p_s_tb to tb jeffm
@ 2007-06-11 19:03 ` jeffm
2007-06-11 19:03 ` [patch 30/40] reiserfs: rename _* variables jeffm
` (12 subsequent siblings)
40 siblings, 0 replies; 43+ messages in thread
From: jeffm @ 2007-06-11 19:03 UTC (permalink / raw)
To: ReiserFS Mailing List
[-- Attachment #1: reiserfs-rename-p_._.diff --]
[-- Type: text/plain, Size: 71987 bytes --]
This patch is a simple s/p_._//g to the reiserfs code. This is the fifth
in a series of patches to rip out some of the awful variable naming in
reiserfs.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
fs/reiserfs/file.c | 6
fs/reiserfs/fix_node.c | 170 ++++++++--------
fs/reiserfs/stree.c | 428 +++++++++++++++++++++---------------------
fs/reiserfs/tail_conversion.c | 26 +-
include/linux/reiserfs_fs.h | 46 ++--
5 files changed, 338 insertions(+), 338 deletions(-)
--- a/fs/reiserfs/file.c 2007-06-11 14:49:40.000000000 -0400
+++ b/fs/reiserfs/file.c 2007-06-11 14:50:02.000000000 -0400
@@ -134,10 +134,10 @@ static void reiserfs_vfs_truncate_file(s
* be removed...
*/
-static int reiserfs_sync_file(struct file *p_s_filp,
- struct dentry *p_s_dentry, int datasync)
+static int reiserfs_sync_file(struct file *filp,
+ struct dentry *dentry, int datasync)
{
- struct inode *inode = p_s_dentry->d_inode;
+ struct inode *inode = dentry->d_inode;
int n_err;
int barrier_done;
--- a/fs/reiserfs/fix_node.c 2007-06-11 14:49:40.000000000 -0400
+++ b/fs/reiserfs/fix_node.c 2007-06-11 14:50:02.000000000 -0400
@@ -780,9 +780,9 @@ static void free_buffers_in_tb(struct tr
/* The function is NOT SCHEDULE-SAFE! */
static int get_empty_nodes(struct tree_balance *tb, int n_h)
{
- struct buffer_head *p_s_new_bh,
- *p_s_Sh = PATH_H_PBUFFER(tb->tb_path, n_h);
- b_blocknr_t *p_n_blocknr, a_n_blocknrs[MAX_AMOUNT_NEEDED] = { 0, };
+ struct buffer_head *new_bh,
+ *Sh = PATH_H_PBUFFER(tb->tb_path, n_h);
+ b_blocknr_t *blocknr, a_n_blocknrs[MAX_AMOUNT_NEEDED] = { 0, };
int n_counter, n_number_of_freeblk, n_amount_needed, /* number of needed empty blocks */
n_retval = CARRY_ON;
struct super_block *sb = tb->tb_sb;
@@ -810,8 +810,8 @@ static int get_empty_nodes(struct tree_b
1) : 0;
/* Allocate missing empty blocks. */
- /* if p_s_Sh == 0 then we are getting a new root */
- n_amount_needed = (p_s_Sh) ? (tb->blknum[n_h] - 1) : 1;
+ /* if Sh == 0 then we are getting a new root */
+ n_amount_needed = (Sh) ? (tb->blknum[n_h] - 1) : 1;
/* Amount_needed = the amount that we need more than the amount that we have. */
if (n_amount_needed > n_number_of_freeblk)
n_amount_needed -= n_number_of_freeblk;
@@ -824,25 +824,25 @@ static int get_empty_nodes(struct tree_b
return NO_DISK_SPACE;
/* for each blocknumber we just got, get a buffer and stick it on FEB */
- for (p_n_blocknr = a_n_blocknrs, n_counter = 0;
- n_counter < n_amount_needed; p_n_blocknr++, n_counter++) {
+ for (blocknr = a_n_blocknrs, n_counter = 0;
+ n_counter < n_amount_needed; blocknr++, n_counter++) {
- RFALSE(!*p_n_blocknr,
+ RFALSE(!*blocknr,
"PAP-8135: reiserfs_new_blocknrs failed when got new blocks");
- p_s_new_bh = sb_getblk(sb, *p_n_blocknr);
- RFALSE(buffer_dirty(p_s_new_bh) ||
- buffer_journaled(p_s_new_bh) ||
- buffer_journal_dirty(p_s_new_bh),
+ new_bh = sb_getblk(sb, *blocknr);
+ RFALSE(buffer_dirty(new_bh) ||
+ buffer_journaled(new_bh) ||
+ buffer_journal_dirty(new_bh),
"PAP-8140: journlaled or dirty buffer %b for the new block",
- p_s_new_bh);
+ new_bh);
/* Put empty buffers into the array. */
RFALSE(tb->FEB[tb->cur_blknum],
"PAP-8141: busy slot for new buffer");
- set_buffer_journal_new(p_s_new_bh);
- tb->FEB[tb->cur_blknum++] = p_s_new_bh;
+ set_buffer_journal_new(new_bh);
+ tb->FEB[tb->cur_blknum++] = new_bh;
}
if (n_retval == CARRY_ON && FILESYSTEM_CHANGED_TB(tb))
@@ -896,7 +896,7 @@ static int get_rfree(struct tree_balance
/* Check whether left neighbor is in memory. */
static int is_left_neighbor_in_cache(struct tree_balance *tb, int n_h)
{
- struct buffer_head *p_s_father, *left;
+ struct buffer_head *father, *left;
struct super_block *sb = tb->tb_sb;
b_blocknr_t n_left_neighbor_blocknr;
int n_left_neighbor_position;
@@ -905,18 +905,18 @@ static int is_left_neighbor_in_cache(str
return 0;
/* Calculate father of the node to be balanced. */
- p_s_father = PATH_H_PBUFFER(tb->tb_path, n_h + 1);
+ father = PATH_H_PBUFFER(tb->tb_path, n_h + 1);
- RFALSE(!p_s_father ||
- !B_IS_IN_TREE(p_s_father) ||
+ RFALSE(!father ||
+ !B_IS_IN_TREE(father) ||
!B_IS_IN_TREE(tb->FL[n_h]) ||
- !buffer_uptodate(p_s_father) ||
+ !buffer_uptodate(father) ||
!buffer_uptodate(tb->FL[n_h]),
"vs-8165: F[h] (%b) or FL[h] (%b) is invalid",
- p_s_father, tb->FL[n_h]);
+ father, tb->FL[n_h]);
/* Get position of the pointer to the left neighbor into the left father. */
- n_left_neighbor_position = (p_s_father == tb->FL[n_h]) ?
+ n_left_neighbor_position = (father == tb->FL[n_h]) ?
tb->lkey[n_h] : B_NR_ITEMS(tb->FL[n_h]);
/* Get left neighbor block number. */
n_left_neighbor_blocknr =
@@ -937,10 +937,10 @@ static int is_left_neighbor_in_cache(str
#define LEFT_PARENTS 'l'
#define RIGHT_PARENTS 'r'
-static void decrement_key(struct cpu_key *p_s_key)
+static void decrement_key(struct cpu_key *key)
{
// call item specific function for this key
- item_ops[cpu_key_k_type(p_s_key)]->decrement_key(p_s_key);
+ item_ops[cpu_key_k_type(key)]->decrement_key(key);
}
/* Calculate far left/right parent of the left/right neighbor of the current node, that
@@ -953,17 +953,17 @@ static void decrement_key(struct cpu_key
*/
static int get_far_parent(struct tree_balance *tb,
int n_h,
- struct buffer_head **pp_s_father,
- struct buffer_head **pp_s_com_father, char c_lr_par)
+ struct buffer_head **pfather,
+ struct buffer_head **pcom_father, char c_lr_par)
{
- struct buffer_head *p_s_parent;
+ struct buffer_head *parent;
INITIALIZE_PATH(s_path_to_neighbor_father);
- struct treepath *p_s_path = tb->tb_path;
+ struct treepath *path = tb->tb_path;
struct cpu_key s_lr_father_key;
int n_counter,
n_position = INT_MAX,
n_first_last_position = 0,
- n_path_offset = PATH_H_PATH_OFFSET(p_s_path, n_h);
+ n_path_offset = PATH_H_PATH_OFFSET(path, n_h);
/* Starting from F[n_h] go upwards in the tree, and look for the common
ancestor of F[n_h], and its neighbor l/r, that should be obtained. */
@@ -976,25 +976,25 @@ static int get_far_parent(struct tree_ba
for (; n_counter > FIRST_PATH_ELEMENT_OFFSET; n_counter--) {
/* Check whether parent of the current buffer in the path is really parent in the tree. */
if (!B_IS_IN_TREE
- (p_s_parent = PATH_OFFSET_PBUFFER(p_s_path, n_counter - 1)))
+ (parent = PATH_OFFSET_PBUFFER(path, n_counter - 1)))
return REPEAT_SEARCH;
/* Check whether position in the parent is correct. */
if ((n_position =
- PATH_OFFSET_POSITION(p_s_path,
+ PATH_OFFSET_POSITION(path,
n_counter - 1)) >
- B_NR_ITEMS(p_s_parent))
+ B_NR_ITEMS(parent))
return REPEAT_SEARCH;
/* Check whether parent at the path really points to the child. */
- if (B_N_CHILD_NUM(p_s_parent, n_position) !=
- PATH_OFFSET_PBUFFER(p_s_path, n_counter)->b_blocknr)
+ if (B_N_CHILD_NUM(parent, n_position) !=
+ PATH_OFFSET_PBUFFER(path, n_counter)->b_blocknr)
return REPEAT_SEARCH;
/* Return delimiting key if position in the parent is not equal to first/last one. */
if (c_lr_par == RIGHT_PARENTS)
- n_first_last_position = B_NR_ITEMS(p_s_parent);
+ n_first_last_position = B_NR_ITEMS(parent);
if (n_position != n_first_last_position) {
- *pp_s_com_father = p_s_parent;
- get_bh(*pp_s_com_father);
- /*(*pp_s_com_father = p_s_parent)->b_count++; */
+ *pcom_father = parent;
+ get_bh(*pcom_father);
+ /*(*pcom_father = parent)->b_count++; */
break;
}
}
@@ -1006,22 +1006,22 @@ static int get_far_parent(struct tree_ba
(tb->tb_path,
FIRST_PATH_ELEMENT_OFFSET)->b_blocknr ==
SB_ROOT_BLOCK(tb->tb_sb)) {
- *pp_s_father = *pp_s_com_father = NULL;
+ *pfather = *pcom_father = NULL;
return CARRY_ON;
}
return REPEAT_SEARCH;
}
- RFALSE(B_LEVEL(*pp_s_com_father) <= DISK_LEAF_NODE_LEVEL,
+ RFALSE(B_LEVEL(*pcom_father) <= DISK_LEAF_NODE_LEVEL,
"PAP-8185: (%b %z) level too small",
- *pp_s_com_father, *pp_s_com_father);
+ *pcom_father, *pcom_father);
/* Check whether the common parent is locked. */
- if (buffer_locked(*pp_s_com_father)) {
- __wait_on_buffer(*pp_s_com_father);
+ if (buffer_locked(*pcom_father)) {
+ __wait_on_buffer(*pcom_father);
if (FILESYSTEM_CHANGED_TB(tb)) {
- brelse(*pp_s_com_father);
+ brelse(*pcom_father);
return REPEAT_SEARCH;
}
}
@@ -1031,7 +1031,7 @@ static int get_far_parent(struct tree_ba
/* Form key to get parent of the left/right neighbor. */
le_key2cpu_key(&s_lr_father_key,
- B_N_PDELIM_KEY(*pp_s_com_father,
+ B_N_PDELIM_KEY(*pcom_father,
(c_lr_par ==
LEFT_PARENTS) ? (tb->lkey[n_h - 1] =
n_position -
@@ -1050,14 +1050,14 @@ static int get_far_parent(struct tree_ba
if (FILESYSTEM_CHANGED_TB(tb)) {
pathrelse(&s_path_to_neighbor_father);
- brelse(*pp_s_com_father);
+ brelse(*pcom_father);
return REPEAT_SEARCH;
}
- *pp_s_father = PATH_PLAST_BUFFER(&s_path_to_neighbor_father);
+ *pfather = PATH_PLAST_BUFFER(&s_path_to_neighbor_father);
- RFALSE(B_LEVEL(*pp_s_father) != n_h + 1,
- "PAP-8190: (%b %z) level too small", *pp_s_father, *pp_s_father);
+ RFALSE(B_LEVEL(*pfather) != n_h + 1,
+ "PAP-8190: (%b %z) level too small", *pfather, *pfather);
RFALSE(s_path_to_neighbor_father.path_length <
FIRST_PATH_ELEMENT_OFFSET, "PAP-8192: path length is too small");
@@ -1075,11 +1075,11 @@ static int get_far_parent(struct tree_ba
*/
static int get_parents(struct tree_balance *tb, int n_h)
{
- struct treepath *p_s_path = tb->tb_path;
+ struct treepath *path = tb->tb_path;
int n_position,
n_ret_value,
n_path_offset = PATH_H_PATH_OFFSET(tb->tb_path, n_h);
- struct buffer_head *p_s_curf, *p_s_curcf;
+ struct buffer_head *curf, *curcf;
/* Current node is the root of the tree or will be root of the tree */
if (n_path_offset <= FIRST_PATH_ELEMENT_OFFSET) {
@@ -1095,64 +1095,64 @@ static int get_parents(struct tree_balan
}
/* Get parent FL[n_path_offset] of L[n_path_offset]. */
- if ((n_position = PATH_OFFSET_POSITION(p_s_path, n_path_offset - 1))) {
+ if ((n_position = PATH_OFFSET_POSITION(path, n_path_offset - 1))) {
/* Current node is not the first child of its parent. */
- /*(p_s_curf = p_s_curcf = PATH_OFFSET_PBUFFER(p_s_path, n_path_offset - 1))->b_count += 2; */
- p_s_curf = p_s_curcf =
- PATH_OFFSET_PBUFFER(p_s_path, n_path_offset - 1);
- get_bh(p_s_curf);
- get_bh(p_s_curf);
+ /*(curf = curcf = PATH_OFFSET_PBUFFER(path, n_path_offset - 1))->b_count += 2; */
+ curf = curcf =
+ PATH_OFFSET_PBUFFER(path, n_path_offset - 1);
+ get_bh(curf);
+ get_bh(curf);
tb->lkey[n_h] = n_position - 1;
} else {
/* Calculate current parent of L[n_path_offset], which is the left neighbor of the current node.
Calculate current common parent of L[n_path_offset] and the current node. Note that
CFL[n_path_offset] not equal FL[n_path_offset] and CFL[n_path_offset] not equal F[n_path_offset].
Calculate lkey[n_path_offset]. */
- if ((n_ret_value = get_far_parent(tb, n_h + 1, &p_s_curf,
- &p_s_curcf,
+ if ((n_ret_value = get_far_parent(tb, n_h + 1, &curf,
+ &curcf,
LEFT_PARENTS)) != CARRY_ON)
return n_ret_value;
}
brelse(tb->FL[n_h]);
- tb->FL[n_h] = p_s_curf; /* New initialization of FL[n_h]. */
+ tb->FL[n_h] = curf; /* New initialization of FL[n_h]. */
brelse(tb->CFL[n_h]);
- tb->CFL[n_h] = p_s_curcf; /* New initialization of CFL[n_h]. */
+ tb->CFL[n_h] = curcf; /* New initialization of CFL[n_h]. */
- RFALSE((p_s_curf && !B_IS_IN_TREE(p_s_curf)) ||
- (p_s_curcf && !B_IS_IN_TREE(p_s_curcf)),
- "PAP-8195: FL (%b) or CFL (%b) is invalid", p_s_curf, p_s_curcf);
+ RFALSE((curf && !B_IS_IN_TREE(curf)) ||
+ (curcf && !B_IS_IN_TREE(curcf)),
+ "PAP-8195: FL (%b) or CFL (%b) is invalid", curf, curcf);
/* Get parent FR[n_h] of R[n_h]. */
/* Current node is the last child of F[n_h]. FR[n_h] != F[n_h]. */
- if (n_position == B_NR_ITEMS(PATH_H_PBUFFER(p_s_path, n_h + 1))) {
+ if (n_position == B_NR_ITEMS(PATH_H_PBUFFER(path, n_h + 1))) {
/* Calculate current parent of R[n_h], which is the right neighbor of F[n_h].
Calculate current common parent of R[n_h] and current node. Note that CFR[n_h]
not equal FR[n_path_offset] and CFR[n_h] not equal F[n_h]. */
if ((n_ret_value =
- get_far_parent(tb, n_h + 1, &p_s_curf, &p_s_curcf,
+ get_far_parent(tb, n_h + 1, &curf, &curcf,
RIGHT_PARENTS)) != CARRY_ON)
return n_ret_value;
} else {
/* Current node is not the last child of its parent F[n_h]. */
- /*(p_s_curf = p_s_curcf = PATH_OFFSET_PBUFFER(p_s_path, n_path_offset - 1))->b_count += 2; */
- p_s_curf = p_s_curcf =
- PATH_OFFSET_PBUFFER(p_s_path, n_path_offset - 1);
- get_bh(p_s_curf);
- get_bh(p_s_curf);
+ /*(curf = curcf = PATH_OFFSET_PBUFFER(path, n_path_offset - 1))->b_count += 2; */
+ curf = curcf =
+ PATH_OFFSET_PBUFFER(path, n_path_offset - 1);
+ get_bh(curf);
+ get_bh(curf);
tb->rkey[n_h] = n_position;
}
brelse(tb->FR[n_h]);
- tb->FR[n_h] = p_s_curf; /* New initialization of FR[n_path_offset]. */
+ tb->FR[n_h] = curf; /* New initialization of FR[n_path_offset]. */
brelse(tb->CFR[n_h]);
- tb->CFR[n_h] = p_s_curcf; /* New initialization of CFR[n_path_offset]. */
+ tb->CFR[n_h] = curcf; /* New initialization of CFR[n_path_offset]. */
- RFALSE((p_s_curf && !B_IS_IN_TREE(p_s_curf)) ||
- (p_s_curcf && !B_IS_IN_TREE(p_s_curcf)),
- "PAP-8205: FR (%b) or CFR (%b) is invalid", p_s_curf, p_s_curcf);
+ RFALSE((curf && !B_IS_IN_TREE(curf)) ||
+ (curcf && !B_IS_IN_TREE(curcf)),
+ "PAP-8205: FR (%b) or CFR (%b) is invalid", curf, curcf);
return CARRY_ON;
}
@@ -1886,7 +1886,7 @@ static int check_balance(int mode,
static int get_direct_parent(struct tree_balance *tb, int n_h)
{
struct buffer_head *bh;
- struct treepath *p_s_path = tb->tb_path;
+ struct treepath *path = tb->tb_path;
int n_position,
n_path_offset = PATH_H_PATH_OFFSET(tb->tb_path, n_h);
@@ -1896,27 +1896,27 @@ static int get_direct_parent(struct tree
RFALSE(n_path_offset < FIRST_PATH_ELEMENT_OFFSET - 1,
"PAP-8260: invalid offset in the path");
- if (PATH_OFFSET_PBUFFER(p_s_path, FIRST_PATH_ELEMENT_OFFSET)->
+ if (PATH_OFFSET_PBUFFER(path, FIRST_PATH_ELEMENT_OFFSET)->
b_blocknr == SB_ROOT_BLOCK(tb->tb_sb)) {
/* Root is not changed. */
- PATH_OFFSET_PBUFFER(p_s_path, n_path_offset - 1) = NULL;
- PATH_OFFSET_POSITION(p_s_path, n_path_offset - 1) = 0;
+ PATH_OFFSET_PBUFFER(path, n_path_offset - 1) = NULL;
+ PATH_OFFSET_POSITION(path, n_path_offset - 1) = 0;
return CARRY_ON;
}
return REPEAT_SEARCH; /* Root is changed and we must recalculate the path. */
}
if (!B_IS_IN_TREE
- (bh = PATH_OFFSET_PBUFFER(p_s_path, n_path_offset - 1)))
+ (bh = PATH_OFFSET_PBUFFER(path, n_path_offset - 1)))
return REPEAT_SEARCH; /* Parent in the path is not in the tree. */
if ((n_position =
- PATH_OFFSET_POSITION(p_s_path,
+ PATH_OFFSET_POSITION(path,
n_path_offset - 1)) > B_NR_ITEMS(bh))
return REPEAT_SEARCH;
if (B_N_CHILD_NUM(bh, n_position) !=
- PATH_OFFSET_PBUFFER(p_s_path, n_path_offset)->b_blocknr)
+ PATH_OFFSET_PBUFFER(path, n_path_offset)->b_blocknr)
/* Parent in the path is not parent of the current node in the tree. */
return REPEAT_SEARCH;
@@ -2317,7 +2317,7 @@ static int wait_tb_buffers_until_unlocke
* -1 - if no_disk_space
*/
-int fix_nodes(int n_op_mode, struct tree_balance *tb, struct item_head *p_s_ins_ih, // item head of item being inserted
+int fix_nodes(int n_op_mode, struct tree_balance *tb, struct item_head *ins_ih, // item head of item being inserted
const void *data // inserted item or data to be pasted
)
{
@@ -2407,7 +2407,7 @@ int fix_nodes(int n_op_mode, struct tree
if ((n_ret_value =
check_balance(n_op_mode, tb, n_h, n_item_num,
- n_pos_in_item, p_s_ins_ih,
+ n_pos_in_item, ins_ih,
data)) != CARRY_ON) {
if (n_ret_value == NO_BALANCING_NEEDED) {
/* No balancing for higher levels needed. */
--- a/fs/reiserfs/stree.c 2007-06-11 14:49:40.000000000 -0400
+++ b/fs/reiserfs/stree.c 2007-06-11 14:50:02.000000000 -0400
@@ -68,10 +68,10 @@ inline int B_IS_IN_TREE(const struct buf
//
// to gets item head in le form
//
-inline void copy_item_head(struct item_head *p_v_to,
- const struct item_head *p_v_from)
+inline void copy_item_head(struct item_head *to,
+ const struct item_head *from)
{
- memcpy(p_v_to, p_v_from, IH_SIZE);
+ memcpy(to, from, IH_SIZE);
}
/* k1 is pointer to on-disk structure which is stored in little-endian
@@ -135,15 +135,15 @@ static inline int comp_keys(const struct
inline int comp_short_le_keys(const struct reiserfs_key *key1,
const struct reiserfs_key *key2)
{
- __u32 *p_s_1_u32, *p_s_2_u32;
+ __u32 *k1_u32, *k2_u32;
int n_key_length = REISERFS_SHORT_KEY_LEN;
- p_s_1_u32 = (__u32 *) key1;
- p_s_2_u32 = (__u32 *) key2;
- for (; n_key_length--; ++p_s_1_u32, ++p_s_2_u32) {
- if (le32_to_cpu(*p_s_1_u32) < le32_to_cpu(*p_s_2_u32))
+ k1_u32 = (__u32 *) key1;
+ k2_u32 = (__u32 *) key2;
+ for (; n_key_length--; ++k1_u32, ++k2_u32) {
+ if (le32_to_cpu(*k1_u32) < le32_to_cpu(*k2_u32))
return -1;
- if (le32_to_cpu(*p_s_1_u32) > le32_to_cpu(*p_s_2_u32))
+ if (le32_to_cpu(*k1_u32) > le32_to_cpu(*k2_u32))
return 1;
}
return 0;
@@ -174,8 +174,8 @@ inline int comp_le_keys(const struct rei
* Binary search toolkit function *
* Search for an item in the array by the item key *
* Returns: 1 if found, 0 if not found; *
- * *p_n_pos = number of the searched element if found, else the *
- * number of the first element that is larger than p_v_key. *
+ * *pos = number of the searched element if found, else the *
+ * number of the first element that is larger than key. *
**************************************************************************/
/* For those not familiar with binary search: n_lbound is the leftmost item that it
could be, n_rbound the rightmost item that it could be. We examine the item
@@ -184,28 +184,28 @@ inline int comp_le_keys(const struct rei
there are no possible items, and we have not found it. With each examination we
cut the number of possible items it could be by one more than half rounded down,
or we find it. */
-static inline int bin_search(const void *p_v_key, /* Key to search for. */
- const void *p_v_base, /* First item in the array. */
- int p_n_num, /* Number of items in the array. */
- int p_n_width, /* Item size in the array.
+static inline int bin_search(const void *key, /* Key to search for. */
+ const void *base, /* First item in the array. */
+ int num, /* Number of items in the array. */
+ int width, /* Item size in the array.
searched. Lest the reader be
confused, note that this is crafted
as a general function, and when it
is applied specifically to the array
- of item headers in a node, p_n_width
+ of item headers in a node, width
is actually the item header size not
the item size. */
- int *p_n_pos /* Number of the searched for element. */
+ int *pos /* Number of the searched for element. */
)
{
int n_rbound, n_lbound, n_j;
- for (n_j = ((n_rbound = p_n_num - 1) + (n_lbound = 0)) / 2;
+ for (n_j = ((n_rbound = num - 1) + (n_lbound = 0)) / 2;
n_lbound <= n_rbound; n_j = (n_rbound + n_lbound) / 2)
switch (comp_keys
- ((struct reiserfs_key *)((char *)p_v_base +
- n_j * p_n_width),
- (struct cpu_key *)p_v_key)) {
+ ((struct reiserfs_key *)((char *)base +
+ n_j * width),
+ (struct cpu_key *)key)) {
case -1:
n_lbound = n_j + 1;
continue;
@@ -213,13 +213,13 @@ static inline int bin_search(const void
n_rbound = n_j - 1;
continue;
case 0:
- *p_n_pos = n_j;
+ *pos = n_j;
return ITEM_FOUND; /* Key found in the array. */
}
/* bin_search did not find given key, it returns position of key,
that is minimal and greater than the given one. */
- *p_n_pos = n_lbound;
+ *pos = n_lbound;
return ITEM_NOT_FOUND;
}
@@ -243,12 +243,12 @@ static const struct reiserfs_key MAX_KEY
the path, there is no delimiting key in the tree (buffer is first or last buffer in tree), and in this
case we return a special key, either MIN_KEY or MAX_KEY. */
static inline const struct reiserfs_key *get_lkey(const struct treepath
- *p_s_chk_path,
+ *chk_path,
const struct super_block
*sb)
{
- int n_position, n_path_offset = p_s_chk_path->path_length;
- struct buffer_head *p_s_parent;
+ int n_position, n_path_offset = chk_path->path_length;
+ struct buffer_head *parent;
RFALSE(n_path_offset < FIRST_PATH_ELEMENT_OFFSET,
"PAP-5010: invalid offset in the path");
@@ -257,42 +257,42 @@ static inline const struct reiserfs_key
while (n_path_offset-- > FIRST_PATH_ELEMENT_OFFSET) {
RFALSE(!buffer_uptodate
- (PATH_OFFSET_PBUFFER(p_s_chk_path, n_path_offset)),
+ (PATH_OFFSET_PBUFFER(chk_path, n_path_offset)),
"PAP-5020: parent is not uptodate");
/* Parent at the path is not in the tree now. */
if (!B_IS_IN_TREE
- (p_s_parent =
- PATH_OFFSET_PBUFFER(p_s_chk_path, n_path_offset)))
+ (parent =
+ PATH_OFFSET_PBUFFER(chk_path, n_path_offset)))
return &MAX_KEY;
/* Check whether position in the parent is correct. */
if ((n_position =
- PATH_OFFSET_POSITION(p_s_chk_path,
+ PATH_OFFSET_POSITION(chk_path,
n_path_offset)) >
- B_NR_ITEMS(p_s_parent))
+ B_NR_ITEMS(parent))
return &MAX_KEY;
/* Check whether parent at the path really points to the child. */
- if (B_N_CHILD_NUM(p_s_parent, n_position) !=
- PATH_OFFSET_PBUFFER(p_s_chk_path,
+ if (B_N_CHILD_NUM(parent, n_position) !=
+ PATH_OFFSET_PBUFFER(chk_path,
n_path_offset + 1)->b_blocknr)
return &MAX_KEY;
/* Return delimiting key if position in the parent is not equal to zero. */
if (n_position)
- return B_N_PDELIM_KEY(p_s_parent, n_position - 1);
+ return B_N_PDELIM_KEY(parent, n_position - 1);
}
/* Return MIN_KEY if we are in the root of the buffer tree. */
- if (PATH_OFFSET_PBUFFER(p_s_chk_path, FIRST_PATH_ELEMENT_OFFSET)->
+ if (PATH_OFFSET_PBUFFER(chk_path, FIRST_PATH_ELEMENT_OFFSET)->
b_blocknr == SB_ROOT_BLOCK(sb))
return &MIN_KEY;
return &MAX_KEY;
}
/* Get delimiting key of the buffer at the path and its right neighbor. */
-inline const struct reiserfs_key *get_rkey(const struct treepath *p_s_chk_path,
+inline const struct reiserfs_key *get_rkey(const struct treepath *chk_path,
const struct super_block *sb)
{
- int n_position, n_path_offset = p_s_chk_path->path_length;
- struct buffer_head *p_s_parent;
+ int n_position, n_path_offset = chk_path->path_length;
+ struct buffer_head *parent;
RFALSE(n_path_offset < FIRST_PATH_ELEMENT_OFFSET,
"PAP-5030: invalid offset in the path");
@@ -300,31 +300,31 @@ inline const struct reiserfs_key *get_rk
while (n_path_offset-- > FIRST_PATH_ELEMENT_OFFSET) {
RFALSE(!buffer_uptodate
- (PATH_OFFSET_PBUFFER(p_s_chk_path, n_path_offset)),
+ (PATH_OFFSET_PBUFFER(chk_path, n_path_offset)),
"PAP-5040: parent is not uptodate");
/* Parent at the path is not in the tree now. */
if (!B_IS_IN_TREE
- (p_s_parent =
- PATH_OFFSET_PBUFFER(p_s_chk_path, n_path_offset)))
+ (parent =
+ PATH_OFFSET_PBUFFER(chk_path, n_path_offset)))
return &MIN_KEY;
/* Check whether position in the parent is correct. */
if ((n_position =
- PATH_OFFSET_POSITION(p_s_chk_path,
+ PATH_OFFSET_POSITION(chk_path,
n_path_offset)) >
- B_NR_ITEMS(p_s_parent))
+ B_NR_ITEMS(parent))
return &MIN_KEY;
/* Check whether parent at the path really points to the child. */
- if (B_N_CHILD_NUM(p_s_parent, n_position) !=
- PATH_OFFSET_PBUFFER(p_s_chk_path,
+ if (B_N_CHILD_NUM(parent, n_position) !=
+ PATH_OFFSET_PBUFFER(chk_path,
n_path_offset + 1)->b_blocknr)
return &MIN_KEY;
/* Return delimiting key if position in the parent is not the last one. */
- if (n_position != B_NR_ITEMS(p_s_parent))
- return B_N_PDELIM_KEY(p_s_parent, n_position);
+ if (n_position != B_NR_ITEMS(parent))
+ return B_N_PDELIM_KEY(parent, n_position);
}
/* Return MAX_KEY if we are in the root of the buffer tree. */
- if (PATH_OFFSET_PBUFFER(p_s_chk_path, FIRST_PATH_ELEMENT_OFFSET)->
+ if (PATH_OFFSET_PBUFFER(chk_path, FIRST_PATH_ELEMENT_OFFSET)->
b_blocknr == SB_ROOT_BLOCK(sb))
return &MAX_KEY;
return &MIN_KEY;
@@ -335,25 +335,25 @@ inline const struct reiserfs_key *get_rk
the path. These delimiting keys are stored at least one level above that buffer in the tree. If the
buffer is the first or last node in the tree order then one of the delimiting keys may be absent, and in
this case get_lkey and get_rkey return a special key which is MIN_KEY or MAX_KEY. */
-static inline int key_in_buffer(struct treepath *p_s_chk_path, /* Path which should be checked. */
- const struct cpu_key *p_s_key, /* Key which should be checked. */
+static inline int key_in_buffer(struct treepath *chk_path, /* Path which should be checked. */
+ const struct cpu_key *key, /* Key which should be checked. */
struct super_block *sb /* Super block pointer. */
)
{
- RFALSE(!p_s_key || p_s_chk_path->path_length < FIRST_PATH_ELEMENT_OFFSET
- || p_s_chk_path->path_length > MAX_HEIGHT,
+ RFALSE(!key || chk_path->path_length < FIRST_PATH_ELEMENT_OFFSET
+ || chk_path->path_length > MAX_HEIGHT,
"PAP-5050: pointer to the key(%p) is NULL or invalid path length(%d)",
- p_s_key, p_s_chk_path->path_length);
- RFALSE(!PATH_PLAST_BUFFER(p_s_chk_path)->b_bdev,
+ key, chk_path->path_length);
+ RFALSE(!PATH_PLAST_BUFFER(chk_path)->b_bdev,
"PAP-5060: device must not be NODEV");
- if (comp_keys(get_lkey(p_s_chk_path, sb), p_s_key) == 1)
+ if (comp_keys(get_lkey(chk_path, sb), key) == 1)
/* left delimiting key is bigger, that the key we look for */
return 0;
- // if ( comp_keys(p_s_key, get_rkey(p_s_chk_path, sb)) != -1 )
- if (comp_keys(get_rkey(p_s_chk_path, sb), p_s_key) != 1)
- /* p_s_key must be less than right delimitiing key */
+ // if ( comp_keys(key, get_rkey(chk_path, sb)) != -1 )
+ if (comp_keys(get_rkey(chk_path, sb), key) != 1)
+ /* key must be less than right delimitiing key */
return 0;
return 1;
}
@@ -369,34 +369,34 @@ int reiserfs_check_path(struct treepath
* dirty bits clean when preparing the buffer for the log.
* This version should only be called from fix_nodes() */
void pathrelse_and_restore(struct super_block *sb,
- struct treepath *p_s_search_path)
+ struct treepath *search_path)
{
- int n_path_offset = p_s_search_path->path_length;
+ int n_path_offset = search_path->path_length;
RFALSE(n_path_offset < ILLEGAL_PATH_ELEMENT_OFFSET,
"clm-4000: invalid path offset");
while (n_path_offset > ILLEGAL_PATH_ELEMENT_OFFSET) {
struct buffer_head *bh;
- bh = PATH_OFFSET_PBUFFER(p_s_search_path, n_path_offset--);
+ bh = PATH_OFFSET_PBUFFER(search_path, n_path_offset--);
reiserfs_restore_prepared_buffer(sb, bh);
brelse(bh);
}
- p_s_search_path->path_length = ILLEGAL_PATH_ELEMENT_OFFSET;
+ search_path->path_length = ILLEGAL_PATH_ELEMENT_OFFSET;
}
/* Drop the reference to each buffer in a path */
-void pathrelse(struct treepath *p_s_search_path)
+void pathrelse(struct treepath *search_path)
{
- int n_path_offset = p_s_search_path->path_length;
+ int n_path_offset = search_path->path_length;
RFALSE(n_path_offset < ILLEGAL_PATH_ELEMENT_OFFSET,
"PAP-5090: invalid path offset");
while (n_path_offset > ILLEGAL_PATH_ELEMENT_OFFSET)
- brelse(PATH_OFFSET_PBUFFER(p_s_search_path, n_path_offset--));
+ brelse(PATH_OFFSET_PBUFFER(search_path, n_path_offset--));
- p_s_search_path->path_length = ILLEGAL_PATH_ELEMENT_OFFSET;
+ search_path->path_length = ILLEGAL_PATH_ELEMENT_OFFSET;
}
static int is_leaf(char *buf, int blocksize, struct buffer_head *bh)
@@ -547,9 +547,9 @@ static void search_by_key_reada(struct s
* Algorithm SearchByKey *
* look for item in the Disk S+Tree by its key *
* Input: sb - super block *
- * p_s_key - pointer to the key to search *
+ * key - pointer to the key to search *
* Output: ITEM_FOUND, ITEM_NOT_FOUND or IO_ERROR *
- * p_s_search_path - path from the root to the needed leaf *
+ * search_path - path from the root to the needed leaf *
**************************************************************************/
/* This function fills up the path from the root to the leaf as it
@@ -566,8 +566,8 @@ static void search_by_key_reada(struct s
correctness of the top of the path but need not be checked for the
correctness of the bottom of the path */
/* The function is NOT SCHEDULE-SAFE! */
-int search_by_key(struct super_block *sb, const struct cpu_key *p_s_key, /* Key to search. */
- struct treepath *p_s_search_path,/* This structure was
+int search_by_key(struct super_block *sb, const struct cpu_key *key, /* Key to search. */
+ struct treepath *search_path,/* This structure was
allocated and initialized
by the calling
function. It is filled up
@@ -580,7 +580,7 @@ int search_by_key(struct super_block *sb
int n_block_number;
int expected_level;
struct buffer_head *bh;
- struct path_element *p_s_last_element;
+ struct path_element *last_element;
int n_node_level, n_retval;
int right_neighbor_of_leaf_node;
int fs_gen;
@@ -598,7 +598,7 @@ int search_by_key(struct super_block *sb
we must be careful to release all nodes in a path before we either
discard the path struct or re-use the path struct, as we do here. */
- pathrelse(p_s_search_path);
+ pathrelse(search_path);
right_neighbor_of_leaf_node = 0;
@@ -615,18 +615,18 @@ int search_by_key(struct super_block *sb
"%s: there were %d iterations of "
"while loop looking for key %K",
current->comm, n_repeat_counter,
- p_s_key);
+ key);
#endif
/* prep path to have another element added to it. */
- p_s_last_element =
- PATH_OFFSET_PELEMENT(p_s_search_path,
- ++p_s_search_path->path_length);
+ last_element =
+ PATH_OFFSET_PELEMENT(search_path,
+ ++search_path->path_length);
fs_gen = get_generation(sb);
/* Read the next tree node, and set the last element in the path to
have a pointer to it. */
- if ((bh = p_s_last_element->pe_buffer =
+ if ((bh = last_element->pe_buffer =
sb_getblk(sb, n_block_number))) {
if (!buffer_uptodate(bh) && reada_count > 1) {
search_by_key_reada(sb, reada_bh,
@@ -638,8 +638,8 @@ int search_by_key(struct super_block *sb
goto io_error;
} else {
io_error:
- p_s_search_path->path_length--;
- pathrelse(p_s_search_path);
+ search_path->path_length--;
+ pathrelse(search_path);
return IO_ERROR;
}
reada_count = 0;
@@ -653,12 +653,12 @@ int search_by_key(struct super_block *sb
if (fs_changed(fs_gen, sb) &&
(!B_IS_IN_TREE(bh) ||
B_LEVEL(bh) != expected_level ||
- !key_in_buffer(p_s_search_path, p_s_key, sb))) {
+ !key_in_buffer(search_path, key, sb))) {
PROC_INFO_INC(sb, search_by_key_fs_changed);
PROC_INFO_INC(sb, search_by_key_restarted);
PROC_INFO_INC(sb,
sbk_restarted[expected_level - 1]);
- pathrelse(p_s_search_path);
+ pathrelse(search_path);
/* Get the root block number so that we can repeat the search
starting from the root. */
@@ -670,11 +670,11 @@ int search_by_key(struct super_block *sb
continue;
}
- /* only check that the key is in the buffer if p_s_key is not
+ /* only check that the key is in the buffer if key is not
equal to the MAX_KEY. Latter case is only possible in
"finish_unfinished()" processing during mount. */
- RFALSE(comp_keys(&MAX_KEY, p_s_key) &&
- !key_in_buffer(p_s_search_path, p_s_key, sb),
+ RFALSE(comp_keys(&MAX_KEY, key) &&
+ !key_in_buffer(search_path, key, sb),
"PAP-5130: key is not in the buffer");
#ifdef CONFIG_REISERFS_CHECK
if (cur_tb) {
@@ -690,7 +690,7 @@ int search_by_key(struct super_block *sb
reiserfs_error(sb, "vs-5150",
"invalid format found in block %ld. "
"Fsck?", bh->b_blocknr);
- pathrelse(p_s_search_path);
+ pathrelse(search_path);
return IO_ERROR;
}
@@ -703,12 +703,12 @@ int search_by_key(struct super_block *sb
"vs-5152: tree level (%d) is less than stop level (%d)",
n_node_level, n_stop_level);
- n_retval = bin_search(p_s_key, B_N_PITEM_HEAD(bh, 0),
+ n_retval = bin_search(key, B_N_PITEM_HEAD(bh, 0),
B_NR_ITEMS(bh),
(n_node_level ==
DISK_LEAF_NODE_LEVEL) ? IH_SIZE :
KEY_SIZE,
- &(p_s_last_element->pe_position));
+ &(last_element->pe_position));
if (n_node_level == n_stop_level) {
return n_retval;
}
@@ -716,7 +716,7 @@ int search_by_key(struct super_block *sb
/* we are not in the stop level */
if (n_retval == ITEM_FOUND)
/* item has been found, so we choose the pointer which is to the right of the found one */
- p_s_last_element->pe_position++;
+ last_element->pe_position++;
/* if item was not found we choose the position which is to
the left of the found item. This requires no code,
@@ -726,23 +726,23 @@ int search_by_key(struct super_block *sb
an internal node. Now we calculate child block number by
position in the node. */
n_block_number =
- B_N_CHILD_NUM(bh, p_s_last_element->pe_position);
+ B_N_CHILD_NUM(bh, last_element->pe_position);
/* if we are going to read leaf nodes, try for read ahead as well */
- if ((p_s_search_path->reada & PATH_READA) &&
+ if ((search_path->reada & PATH_READA) &&
n_node_level == DISK_LEAF_NODE_LEVEL + 1) {
- int pos = p_s_last_element->pe_position;
+ int pos = last_element->pe_position;
int limit = B_NR_ITEMS(bh);
struct reiserfs_key *le_key;
- if (p_s_search_path->reada & PATH_READA_BACK)
+ if (search_path->reada & PATH_READA_BACK)
limit = 0;
while (reada_count < SEARCH_BY_KEY_READA) {
if (pos == limit)
break;
reada_blocks[reada_count++] =
B_N_CHILD_NUM(bh, pos);
- if (p_s_search_path->reada & PATH_READA_BACK)
+ if (search_path->reada & PATH_READA_BACK)
pos--;
else
pos++;
@@ -752,7 +752,7 @@ int search_by_key(struct super_block *sb
*/
le_key = B_N_PDELIM_KEY(bh, pos);
if (le32_to_cpu(le_key->k_objectid) !=
- p_s_key->on_disk_key.k_objectid) {
+ key->on_disk_key.k_objectid) {
break;
}
}
@@ -761,11 +761,11 @@ int search_by_key(struct super_block *sb
}
/* Form the path to an item and position in this item which contains
- file byte defined by p_s_key. If there is no such item
+ file byte defined by key. If there is no such item
corresponding to the key, we point the path to the item with
- maximal key less than p_s_key, and *p_n_pos_in_item is set to one
+ maximal key less than key, and *pos_in_item is set to one
past the last entry/byte in the item. If searching for entry in a
- directory item, and it is not found, *p_n_pos_in_item is set to one
+ directory item, and it is not found, *pos_in_item is set to one
entry more than the entry with maximal key which is less than the
sought key.
@@ -778,7 +778,7 @@ int search_by_key(struct super_block *sb
/* The function is NOT SCHEDULE-SAFE! */
int search_for_position_by_key(struct super_block *sb, /* Pointer to the super block. */
const struct cpu_key *p_cpu_key, /* Key to search (cpu variable) */
- struct treepath *p_s_search_path /* Filled up by this function. */
+ struct treepath *search_path /* Filled up by this function. */
)
{
struct item_head *p_le_ih; /* pointer to on-disk structure */
@@ -789,34 +789,34 @@ int search_for_position_by_key(struct su
/* If searching for directory entry. */
if (is_direntry_cpu_key(p_cpu_key))
- return search_by_entry_key(sb, p_cpu_key, p_s_search_path,
+ return search_by_entry_key(sb, p_cpu_key, search_path,
&de);
/* If not searching for directory entry. */
/* If item is found. */
- retval = search_item(sb, p_cpu_key, p_s_search_path);
+ retval = search_item(sb, p_cpu_key, search_path);
if (retval == IO_ERROR)
return retval;
if (retval == ITEM_FOUND) {
RFALSE(!ih_item_len
(B_N_PITEM_HEAD
- (PATH_PLAST_BUFFER(p_s_search_path),
- PATH_LAST_POSITION(p_s_search_path))),
+ (PATH_PLAST_BUFFER(search_path),
+ PATH_LAST_POSITION(search_path))),
"PAP-5165: item length equals zero");
- pos_in_item(p_s_search_path) = 0;
+ pos_in_item(search_path) = 0;
return POSITION_FOUND;
}
- RFALSE(!PATH_LAST_POSITION(p_s_search_path),
+ RFALSE(!PATH_LAST_POSITION(search_path),
"PAP-5170: position equals zero");
/* Item is not found. Set path to the previous item. */
p_le_ih =
- B_N_PITEM_HEAD(PATH_PLAST_BUFFER(p_s_search_path),
- --PATH_LAST_POSITION(p_s_search_path));
+ B_N_PITEM_HEAD(PATH_PLAST_BUFFER(search_path),
+ --PATH_LAST_POSITION(search_path));
n_blk_size = sb->s_blocksize;
if (comp_short_keys(&(p_le_ih->ih_key), p_cpu_key)) {
@@ -830,9 +830,9 @@ int search_for_position_by_key(struct su
/* Needed byte is contained in the item pointed to by the path. */
if (item_offset <= offset &&
item_offset + op_bytes_number(p_le_ih, n_blk_size) > offset) {
- pos_in_item(p_s_search_path) = offset - item_offset;
+ pos_in_item(search_path) = offset - item_offset;
if (is_indirect_le_ih(p_le_ih)) {
- pos_in_item(p_s_search_path) /= n_blk_size;
+ pos_in_item(search_path) /= n_blk_size;
}
return POSITION_FOUND;
}
@@ -840,30 +840,30 @@ int search_for_position_by_key(struct su
/* Needed byte is not contained in the item pointed to by the
path. Set pos_in_item out of the item. */
if (is_indirect_le_ih(p_le_ih))
- pos_in_item(p_s_search_path) =
+ pos_in_item(search_path) =
ih_item_len(p_le_ih) / UNFM_P_SIZE;
else
- pos_in_item(p_s_search_path) = ih_item_len(p_le_ih);
+ pos_in_item(search_path) = ih_item_len(p_le_ih);
return POSITION_NOT_FOUND;
}
/* Compare given item and item pointed to by the path. */
-int comp_items(const struct item_head *stored_ih, const struct treepath *p_s_path)
+int comp_items(const struct item_head *stored_ih, const struct treepath *path)
{
struct buffer_head *bh;
struct item_head *ih;
/* Last buffer at the path is not in the tree. */
- if (!B_IS_IN_TREE(bh = PATH_PLAST_BUFFER(p_s_path)))
+ if (!B_IS_IN_TREE(bh = PATH_PLAST_BUFFER(path)))
return 1;
/* Last path position is invalid. */
- if (PATH_LAST_POSITION(p_s_path) >= B_NR_ITEMS(bh))
+ if (PATH_LAST_POSITION(path) >= B_NR_ITEMS(bh))
return 1;
/* we need only to know, whether it is the same item */
- ih = get_ih(p_s_path);
+ ih = get_ih(path);
return memcmp(stored_ih, ih, IH_SIZE);
}
@@ -952,14 +952,14 @@ static inline int prepare_for_direntry_i
In case of file truncate calculate whether this item must be deleted/truncated or last
unformatted node of this item will be converted to a direct item.
This function returns a determination of what balance mode the calling function should employ. */
-static char prepare_for_delete_or_cut(struct reiserfs_transaction_handle *th, struct inode *inode, struct treepath *p_s_path, const struct cpu_key *p_s_item_key, int *p_n_removed, /* Number of unformatted nodes which were removed
+static char prepare_for_delete_or_cut(struct reiserfs_transaction_handle *th, struct inode *inode, struct treepath *path, const struct cpu_key *item_key, int *removed, /* Number of unformatted nodes which were removed
from end of the file. */
- int *p_n_cut_size, unsigned long long n_new_file_length /* MAX_KEY_OFFSET in case of delete. */
+ int *cut_size, unsigned long long n_new_file_length /* MAX_KEY_OFFSET in case of delete. */
)
{
struct super_block *sb = inode->i_sb;
- struct item_head *p_le_ih = PATH_PITEM_HEAD(p_s_path);
- struct buffer_head *bh = PATH_PLAST_BUFFER(p_s_path);
+ struct item_head *p_le_ih = PATH_PITEM_HEAD(path);
+ struct buffer_head *bh = PATH_PLAST_BUFFER(path);
BUG_ON(!th->t_trans_id);
@@ -969,20 +969,20 @@ static char prepare_for_delete_or_cut(st
RFALSE(n_new_file_length != max_reiserfs_offset(inode),
"PAP-5210: mode must be M_DELETE");
- *p_n_cut_size = -(IH_SIZE + ih_item_len(p_le_ih));
+ *cut_size = -(IH_SIZE + ih_item_len(p_le_ih));
return M_DELETE;
}
/* Directory item. */
if (is_direntry_le_ih(p_le_ih))
- return prepare_for_direntry_item(p_s_path, p_le_ih, inode,
+ return prepare_for_direntry_item(path, p_le_ih, inode,
n_new_file_length,
- p_n_cut_size);
+ cut_size);
/* Direct item. */
if (is_direct_le_ih(p_le_ih))
- return prepare_for_direct_item(p_s_path, p_le_ih, inode,
- n_new_file_length, p_n_cut_size);
+ return prepare_for_direct_item(path, p_le_ih, inode,
+ n_new_file_length, cut_size);
/* Case of an indirect item. */
{
@@ -1002,9 +1002,9 @@ static char prepare_for_delete_or_cut(st
do {
need_re_search = 0;
- *p_n_cut_size = 0;
- bh = PATH_PLAST_BUFFER(p_s_path);
- copy_item_head(&s_ih, PATH_PITEM_HEAD(p_s_path));
+ *cut_size = 0;
+ bh = PATH_PLAST_BUFFER(path);
+ copy_item_head(&s_ih, PATH_PITEM_HEAD(path));
pos = I_UNFM_NUM(&s_ih);
while (le_ih_k_offset (&s_ih) + (pos - 1) * blk_size > n_new_file_length) {
@@ -1013,7 +1013,7 @@ static char prepare_for_delete_or_cut(st
/* Each unformatted block deletion may involve one additional
* bitmap block into the transaction, thereby the initial
* journal space reservation might not be enough. */
- if (!delete && (*p_n_cut_size) != 0 &&
+ if (!delete && (*cut_size) != 0 &&
reiserfs_transaction_free_space(th) < JOURNAL_FOR_FREE_BLOCK_AND_UPDATE_SD) {
break;
}
@@ -1030,17 +1030,17 @@ static char prepare_for_delete_or_cut(st
cond_resched();
- if (item_moved (&s_ih, p_s_path)) {
+ if (item_moved (&s_ih, path)) {
need_re_search = 1;
break;
}
pos --;
- (*p_n_removed) ++;
- (*p_n_cut_size) -= UNFM_P_SIZE;
+ (*removed) ++;
+ (*cut_size) -= UNFM_P_SIZE;
if (pos == 0) {
- (*p_n_cut_size) -= IH_SIZE;
+ (*cut_size) -= IH_SIZE;
result = M_DELETE;
break;
}
@@ -1050,10 +1050,10 @@ static char prepare_for_delete_or_cut(st
** buffer */
reiserfs_restore_prepared_buffer(sb, bh);
} while (need_re_search &&
- search_for_position_by_key(sb, p_s_item_key, p_s_path) == POSITION_FOUND);
- pos_in_item(p_s_path) = pos * UNFM_P_SIZE;
+ search_for_position_by_key(sb, item_key, path) == POSITION_FOUND);
+ pos_in_item(path) = pos * UNFM_P_SIZE;
- if (*p_n_cut_size == 0) {
+ if (*cut_size == 0) {
/* Nothing were cut. maybe convert last unformatted node to the
* direct item? */
result = M_CONVERT;
@@ -1090,7 +1090,7 @@ static int calc_deleted_bytes_number(str
static void init_tb_struct(struct reiserfs_transaction_handle *th,
struct tree_balance *tb,
struct super_block *sb,
- struct treepath *p_s_path, int n_size)
+ struct treepath *path, int n_size)
{
BUG_ON(!th->t_trans_id);
@@ -1098,9 +1098,9 @@ static void init_tb_struct(struct reiser
memset(tb, '\0', sizeof(struct tree_balance));
tb->transaction_handle = th;
tb->tb_sb = sb;
- tb->tb_path = p_s_path;
- PATH_OFFSET_PBUFFER(p_s_path, ILLEGAL_PATH_ELEMENT_OFFSET) = NULL;
- PATH_OFFSET_POSITION(p_s_path, ILLEGAL_PATH_ELEMENT_OFFSET) = 0;
+ tb->tb_path = path;
+ PATH_OFFSET_PBUFFER(path, ILLEGAL_PATH_ELEMENT_OFFSET) = NULL;
+ PATH_OFFSET_POSITION(path, ILLEGAL_PATH_ELEMENT_OFFSET) = 0;
tb->insert_size[0] = n_size;
}
@@ -1141,10 +1141,10 @@ char head2type(struct item_head *ih)
#endif
/* Delete object item. */
-int reiserfs_delete_item(struct reiserfs_transaction_handle *th, struct treepath *p_s_path, /* Path to the deleted item. */
- const struct cpu_key *p_s_item_key, /* Key to search for the deleted item. */
+int reiserfs_delete_item(struct reiserfs_transaction_handle *th, struct treepath *path, /* Path to the deleted item. */
+ const struct cpu_key *item_key, /* Key to search for the deleted item. */
struct inode *inode, /* inode is here just to update i_blocks and quotas */
- struct buffer_head *p_s_un_bh)
+ struct buffer_head *un_bh)
{ /* NULL or unformatted node pointer. */
struct super_block *sb = inode->i_sb;
struct tree_balance s_del_balance;
@@ -1160,7 +1160,7 @@ int reiserfs_delete_item(struct reiserfs
BUG_ON(!th->t_trans_id);
- init_tb_struct(th, &s_del_balance, sb, p_s_path,
+ init_tb_struct(th, &s_del_balance, sb, path,
0 /*size is unknown */ );
while (1) {
@@ -1170,14 +1170,14 @@ int reiserfs_delete_item(struct reiserfs
n_iter++;
c_mode =
#endif
- prepare_for_delete_or_cut(th, inode, p_s_path,
- p_s_item_key, &n_removed,
+ prepare_for_delete_or_cut(th, inode, path,
+ item_key, &n_removed,
&n_del_size,
max_reiserfs_offset(inode));
RFALSE(c_mode != M_DELETE, "PAP-5320: mode must be M_DELETE");
- copy_item_head(&s_ih, PATH_PITEM_HEAD(p_s_path));
+ copy_item_head(&s_ih, PATH_PITEM_HEAD(path));
s_del_balance.insert_size[0] = n_del_size;
n_ret_value = fix_nodes(M_DELETE, &s_del_balance, NULL, NULL);
@@ -1188,13 +1188,13 @@ int reiserfs_delete_item(struct reiserfs
// file system changed, repeat search
n_ret_value =
- search_for_position_by_key(sb, p_s_item_key, p_s_path);
+ search_for_position_by_key(sb, item_key, path);
if (n_ret_value == IO_ERROR)
break;
if (n_ret_value == FILE_NOT_FOUND) {
reiserfs_warning(sb, "vs-5340",
"no items of the file %K found",
- p_s_item_key);
+ item_key);
break;
}
} /* while (1) */
@@ -1205,7 +1205,7 @@ int reiserfs_delete_item(struct reiserfs
}
// reiserfs_delete_item returns item length when success
n_ret_value = calc_deleted_bytes_number(&s_del_balance, M_DELETE);
- q_ih = get_ih(p_s_path);
+ q_ih = get_ih(path);
quota_cut_bytes = ih_item_len(q_ih);
/* hack so the quota code doesn't have to guess if the file
@@ -1222,7 +1222,7 @@ int reiserfs_delete_item(struct reiserfs
}
}
- if (p_s_un_bh) {
+ if (un_bh) {
int off;
char *data;
@@ -1240,16 +1240,16 @@ int reiserfs_delete_item(struct reiserfs
** The unformatted node must be dirtied later on. We can't be
** sure here if the entire tail has been deleted yet.
**
- ** p_s_un_bh is from the page cache (all unformatted nodes are
+ ** un_bh is from the page cache (all unformatted nodes are
** from the page cache) and might be a highmem page. So, we
- ** can't use p_s_un_bh->b_data.
+ ** can't use un_bh->b_data.
** -clm
*/
- data = kmap_atomic(p_s_un_bh->b_page, KM_USER0);
+ data = kmap_atomic(un_bh->b_page, KM_USER0);
off = ((le_ih_k_offset(&s_ih) - 1) & (PAGE_CACHE_SIZE - 1));
memcpy(data + off,
- B_I_PITEM(PATH_PLAST_BUFFER(p_s_path), &s_ih),
+ B_I_PITEM(PATH_PLAST_BUFFER(path), &s_ih),
n_ret_value);
kunmap_atomic(data, KM_USER0);
}
@@ -1429,9 +1429,9 @@ static void unmap_buffers(struct page *p
static int maybe_indirect_to_direct(struct reiserfs_transaction_handle *th,
struct inode *inode,
struct page *page,
- struct treepath *p_s_path,
- const struct cpu_key *p_s_item_key,
- loff_t n_new_file_size, char *p_c_mode)
+ struct treepath *path,
+ const struct cpu_key *item_key,
+ loff_t n_new_file_size, char *mode)
{
struct super_block *sb = inode->i_sb;
int n_block_size = sb->s_blocksize;
@@ -1447,16 +1447,16 @@ static int maybe_indirect_to_direct(stru
!tail_has_to_be_packed(inode) ||
!page || (REISERFS_I(inode)->i_flags & i_nopack_mask)) {
// leave tail in an unformatted node
- *p_c_mode = M_SKIP_BALANCING;
+ *mode = M_SKIP_BALANCING;
cut_bytes =
n_block_size - (n_new_file_size & (n_block_size - 1));
- pathrelse(p_s_path);
+ pathrelse(path);
return cut_bytes;
}
/* Permorm the conversion to a direct_item. */
- /*return indirect_to_direct (inode, p_s_path, p_s_item_key, n_new_file_size, p_c_mode); */
- return indirect2direct(th, inode, page, p_s_path, p_s_item_key,
- n_new_file_size, p_c_mode);
+ /*return indirect_to_direct (inode, path, item_key, n_new_file_size, mode); */
+ return indirect2direct(th, inode, page, path, item_key,
+ n_new_file_size, mode);
}
/* we did indirect_to_direct conversion. And we have inserted direct
@@ -1507,8 +1507,8 @@ static void indirect_to_direct_roll_back
/* (Truncate or cut entry) or delete object item. Returns < 0 on failure */
int reiserfs_cut_from_item(struct reiserfs_transaction_handle *th,
- struct treepath *p_s_path,
- struct cpu_key *p_s_item_key,
+ struct treepath *path,
+ struct cpu_key *item_key,
struct inode *inode,
struct page *page, loff_t n_new_file_size)
{
@@ -1529,7 +1529,7 @@ int reiserfs_cut_from_item(struct reiser
BUG_ON(!th->t_trans_id);
- init_tb_struct(th, &s_cut_balance, inode->i_sb, p_s_path,
+ init_tb_struct(th, &s_cut_balance, inode->i_sb, path,
n_cut_size);
/* Repeat this loop until we either cut the item without needing
@@ -1541,8 +1541,8 @@ int reiserfs_cut_from_item(struct reiser
pointers. */
c_mode =
- prepare_for_delete_or_cut(th, inode, p_s_path,
- p_s_item_key, &n_removed,
+ prepare_for_delete_or_cut(th, inode, path,
+ item_key, &n_removed,
&n_cut_size, n_new_file_size);
if (c_mode == M_CONVERT) {
/* convert last unformatted node to direct item or leave
@@ -1552,7 +1552,7 @@ int reiserfs_cut_from_item(struct reiser
n_ret_value =
maybe_indirect_to_direct(th, inode, page,
- p_s_path, p_s_item_key,
+ path, item_key,
n_new_file_size, &c_mode);
if (c_mode == M_SKIP_BALANCING)
/* tail has been left in the unformatted node */
@@ -1569,26 +1569,26 @@ int reiserfs_cut_from_item(struct reiser
inserting the new direct item. Now we are removing the
last unformatted node pointer. Set key to search for
it. */
- set_cpu_key_k_type(p_s_item_key, TYPE_INDIRECT);
- p_s_item_key->key_length = 4;
+ set_cpu_key_k_type(item_key, TYPE_INDIRECT);
+ item_key->key_length = 4;
n_new_file_size -=
(n_new_file_size & (sb->s_blocksize - 1));
tail_pos = n_new_file_size;
- set_cpu_key_k_offset(p_s_item_key, n_new_file_size + 1);
+ set_cpu_key_k_offset(item_key, n_new_file_size + 1);
if (search_for_position_by_key
- (sb, p_s_item_key,
- p_s_path) == POSITION_NOT_FOUND) {
- print_block(PATH_PLAST_BUFFER(p_s_path), 3,
- PATH_LAST_POSITION(p_s_path) - 1,
- PATH_LAST_POSITION(p_s_path) + 1);
+ (sb, item_key,
+ path) == POSITION_NOT_FOUND) {
+ print_block(PATH_PLAST_BUFFER(path), 3,
+ PATH_LAST_POSITION(path) - 1,
+ PATH_LAST_POSITION(path) + 1);
reiserfs_panic(sb, "PAP-5580", "item to "
"convert does not exist (%K)",
- p_s_item_key);
+ item_key);
}
continue;
}
if (n_cut_size == 0) {
- pathrelse(p_s_path);
+ pathrelse(path);
return 0;
}
@@ -1601,12 +1601,12 @@ int reiserfs_cut_from_item(struct reiser
PROC_INFO_INC(sb, cut_from_item_restarted);
n_ret_value =
- search_for_position_by_key(sb, p_s_item_key, p_s_path);
+ search_for_position_by_key(sb, item_key, path);
if (n_ret_value == POSITION_FOUND)
continue;
reiserfs_warning(sb, "PAP-5610", "item %K not found",
- p_s_item_key);
+ item_key);
unfix_nodes(&s_cut_balance);
return (n_ret_value == IO_ERROR) ? -EIO : -ENOENT;
} /* while */
@@ -1616,7 +1616,7 @@ int reiserfs_cut_from_item(struct reiser
if (n_is_inode_locked) {
// FIXME: this seems to be not needed: we are always able
// to cut item
- indirect_to_direct_roll_back(th, inode, p_s_path);
+ indirect_to_direct_roll_back(th, inode, path);
}
if (n_ret_value == NO_DISK_SPACE)
reiserfs_warning(sb, "reiserfs-5092",
@@ -1632,7 +1632,7 @@ int reiserfs_cut_from_item(struct reiser
/* Calculate number of bytes that need to be cut from the item. */
quota_cut_bytes =
(c_mode ==
- M_DELETE) ? ih_item_len(get_ih(p_s_path)) : -s_cut_balance.
+ M_DELETE) ? ih_item_len(get_ih(path)) : -s_cut_balance.
insert_size[0];
if (retval2 == -1)
n_ret_value = calc_deleted_bytes_number(&s_cut_balance, c_mode);
@@ -1878,7 +1878,7 @@ int reiserfs_do_truncate(struct reiserfs
#ifdef CONFIG_REISERFS_CHECK
// this makes sure, that we __append__, not overwrite or add holes
static void check_research_for_paste(struct treepath *path,
- const struct cpu_key *p_s_key)
+ const struct cpu_key *key)
{
struct item_head *found_ih = get_ih(path);
@@ -1886,35 +1886,35 @@ static void check_research_for_paste(str
if (le_ih_k_offset(found_ih) +
op_bytes_number(found_ih,
get_last_bh(path)->b_size) !=
- cpu_key_k_offset(p_s_key)
+ cpu_key_k_offset(key)
|| op_bytes_number(found_ih,
get_last_bh(path)->b_size) !=
pos_in_item(path))
reiserfs_panic(NULL, "PAP-5720", "found direct item "
"%h or position (%d) does not match "
"to key %K", found_ih,
- pos_in_item(path), p_s_key);
+ pos_in_item(path), key);
}
if (is_indirect_le_ih(found_ih)) {
if (le_ih_k_offset(found_ih) +
op_bytes_number(found_ih,
get_last_bh(path)->b_size) !=
- cpu_key_k_offset(p_s_key)
+ cpu_key_k_offset(key)
|| I_UNFM_NUM(found_ih) != pos_in_item(path)
|| get_ih_free_space(found_ih) != 0)
reiserfs_panic(NULL, "PAP-5730", "found indirect "
"item (%h) or position (%d) does not "
"match to key (%K)",
- found_ih, pos_in_item(path), p_s_key);
+ found_ih, pos_in_item(path), key);
}
}
#endif /* config reiserfs check */
/* Paste bytes to the existing item. Returns bytes number pasted into the item. */
-int reiserfs_paste_into_item(struct reiserfs_transaction_handle *th, struct treepath *p_s_search_path, /* Path to the pasted item. */
- const struct cpu_key *p_s_key, /* Key to search for the needed item. */
+int reiserfs_paste_into_item(struct reiserfs_transaction_handle *th, struct treepath *search_path, /* Path to the pasted item. */
+ const struct cpu_key *key, /* Key to search for the needed item. */
struct inode *inode, /* Inode item belongs to */
- const char *p_c_body, /* Pointer to the bytes to paste. */
+ const char *body, /* Pointer to the bytes to paste. */
int n_pasted_size)
{ /* Size of pasted bytes. */
struct tree_balance s_paste_balance;
@@ -1929,17 +1929,17 @@ int reiserfs_paste_into_item(struct reis
reiserfs_debug(inode->i_sb, REISERFS_DEBUG_CODE,
"reiserquota paste_into_item(): allocating %u id=%u type=%c",
n_pasted_size, inode->i_uid,
- key2type(&(p_s_key->on_disk_key)));
+ key2type(&(key->on_disk_key)));
#endif
if (DQUOT_ALLOC_SPACE_NODIRTY(inode, n_pasted_size)) {
- pathrelse(p_s_search_path);
+ pathrelse(search_path);
return -EDQUOT;
}
- init_tb_struct(th, &s_paste_balance, th->t_super, p_s_search_path,
+ init_tb_struct(th, &s_paste_balance, th->t_super, search_path,
n_pasted_size);
#ifdef DISPLACE_NEW_PACKING_LOCALITIES
- s_paste_balance.key = p_s_key->on_disk_key;
+ s_paste_balance.key = key->on_disk_key;
#endif
/* DQUOT_* can schedule, must check before the fix_nodes */
@@ -1949,13 +1949,13 @@ int reiserfs_paste_into_item(struct reis
while ((retval =
fix_nodes(M_PASTE, &s_paste_balance, NULL,
- p_c_body)) == REPEAT_SEARCH) {
+ body)) == REPEAT_SEARCH) {
search_again:
/* file system changed while we were in the fix_nodes */
PROC_INFO_INC(th->t_super, paste_into_item_restarted);
retval =
- search_for_position_by_key(th->t_super, p_s_key,
- p_s_search_path);
+ search_for_position_by_key(th->t_super, key,
+ search_path);
if (retval == IO_ERROR) {
retval = -EIO;
goto error_out;
@@ -1963,19 +1963,19 @@ int reiserfs_paste_into_item(struct reis
if (retval == POSITION_FOUND) {
reiserfs_warning(inode->i_sb, "PAP-5710",
"entry or pasted byte (%K) exists",
- p_s_key);
+ key);
retval = -EEXIST;
goto error_out;
}
#ifdef CONFIG_REISERFS_CHECK
- check_research_for_paste(p_s_search_path, p_s_key);
+ check_research_for_paste(search_path, key);
#endif
}
/* Perform balancing after all resources are collected by fix_nodes, and
accessing them will not risk triggering schedule. */
if (retval == CARRY_ON) {
- do_balance(&s_paste_balance, NULL /*ih */ , p_c_body, M_PASTE);
+ do_balance(&s_paste_balance, NULL /*ih */ , body, M_PASTE);
return 0;
}
retval = (retval == NO_DISK_SPACE) ? -ENOSPC : -EIO;
@@ -1986,16 +1986,16 @@ int reiserfs_paste_into_item(struct reis
reiserfs_debug(inode->i_sb, REISERFS_DEBUG_CODE,
"reiserquota paste_into_item(): freeing %u id=%u type=%c",
n_pasted_size, inode->i_uid,
- key2type(&(p_s_key->on_disk_key)));
+ key2type(&(key->on_disk_key)));
#endif
DQUOT_FREE_SPACE_NODIRTY(inode, n_pasted_size);
return retval;
}
/* Insert new item into the buffer at the path. */
-int reiserfs_insert_item(struct reiserfs_transaction_handle *th, struct treepath *p_s_path, /* Path to the inserteded item. */
- const struct cpu_key *key, struct item_head *p_s_ih, /* Pointer to the item header to insert. */
- struct inode *inode, const char *p_c_body)
+int reiserfs_insert_item(struct reiserfs_transaction_handle *th, struct treepath *path, /* Path to the inserteded item. */
+ const struct cpu_key *key, struct item_head *ih, /* Pointer to the item header to insert. */
+ struct inode *inode, const char *body)
{ /* Pointer to the bytes to insert. */
struct tree_balance s_ins_balance;
int retval;
@@ -2006,28 +2006,28 @@ int reiserfs_insert_item(struct reiserfs
if (inode) { /* Do we count quotas for item? */
fs_gen = get_generation(inode->i_sb);
- quota_bytes = ih_item_len(p_s_ih);
+ quota_bytes = ih_item_len(ih);
/* hack so the quota code doesn't have to guess if the file has
** a tail, links are always tails, so there's no guessing needed
*/
- if (!S_ISLNK(inode->i_mode) && is_direct_le_ih(p_s_ih)) {
+ if (!S_ISLNK(inode->i_mode) && is_direct_le_ih(ih)) {
quota_bytes = inode->i_sb->s_blocksize + UNFM_P_SIZE;
}
#ifdef REISERQUOTA_DEBUG
reiserfs_debug(inode->i_sb, REISERFS_DEBUG_CODE,
"reiserquota insert_item(): allocating %u id=%u type=%c",
- quota_bytes, inode->i_uid, head2type(p_s_ih));
+ quota_bytes, inode->i_uid, head2type(ih));
#endif
/* We can't dirty inode here. It would be immediately written but
* appropriate stat item isn't inserted yet... */
if (DQUOT_ALLOC_SPACE_NODIRTY(inode, quota_bytes)) {
- pathrelse(p_s_path);
+ pathrelse(path);
return -EDQUOT;
}
}
- init_tb_struct(th, &s_ins_balance, th->t_super, p_s_path,
- IH_SIZE + ih_item_len(p_s_ih));
+ init_tb_struct(th, &s_ins_balance, th->t_super, path,
+ IH_SIZE + ih_item_len(ih));
#ifdef DISPLACE_NEW_PACKING_LOCALITIES
s_ins_balance.key = key->on_disk_key;
#endif
@@ -2037,12 +2037,12 @@ int reiserfs_insert_item(struct reiserfs
}
while ((retval =
- fix_nodes(M_INSERT, &s_ins_balance, p_s_ih,
- p_c_body)) == REPEAT_SEARCH) {
+ fix_nodes(M_INSERT, &s_ins_balance, ih,
+ body)) == REPEAT_SEARCH) {
search_again:
/* file system changed while we were in the fix_nodes */
PROC_INFO_INC(th->t_super, insert_item_restarted);
- retval = search_item(th->t_super, key, p_s_path);
+ retval = search_item(th->t_super, key, path);
if (retval == IO_ERROR) {
retval = -EIO;
goto error_out;
@@ -2058,7 +2058,7 @@ int reiserfs_insert_item(struct reiserfs
/* make balancing after all resources will be collected at a time */
if (retval == CARRY_ON) {
- do_balance(&s_ins_balance, p_s_ih, p_c_body, M_INSERT);
+ do_balance(&s_ins_balance, ih, body, M_INSERT);
return 0;
}
@@ -2069,7 +2069,7 @@ int reiserfs_insert_item(struct reiserfs
#ifdef REISERQUOTA_DEBUG
reiserfs_debug(th->t_super, REISERFS_DEBUG_CODE,
"reiserquota insert_item(): freeing %u id=%u type=%c",
- quota_bytes, inode->i_uid, head2type(p_s_ih));
+ quota_bytes, inode->i_uid, head2type(ih));
#endif
if (inode)
DQUOT_FREE_SPACE_NODIRTY(inode, quota_bytes);
--- a/fs/reiserfs/tail_conversion.c 2007-06-11 14:49:40.000000000 -0400
+++ b/fs/reiserfs/tail_conversion.c 2007-06-11 14:50:02.000000000 -0400
@@ -170,10 +170,10 @@ void reiserfs_unmap_buffer(struct buffer
what we expect from it (number of cut bytes). But when tail remains
in the unformatted node, we set mode to SKIP_BALANCING and unlock
inode */
-int indirect2direct(struct reiserfs_transaction_handle *th, struct inode *inode, struct page *page, struct treepath *p_s_path, /* path to the indirect item. */
- const struct cpu_key *p_s_item_key, /* Key to look for unformatted node pointer to be cut. */
+int indirect2direct(struct reiserfs_transaction_handle *th, struct inode *inode, struct page *page, struct treepath *path, /* path to the indirect item. */
+ const struct cpu_key *item_key, /* Key to look for unformatted node pointer to be cut. */
loff_t n_new_file_size, /* New file size. */
- char *p_c_mode)
+ char *mode)
{
struct super_block *sb = inode->i_sb;
struct item_head s_ih;
@@ -187,10 +187,10 @@ int indirect2direct(struct reiserfs_tran
REISERFS_SB(sb)->s_indirect2direct++;
- *p_c_mode = M_SKIP_BALANCING;
+ *mode = M_SKIP_BALANCING;
/* store item head path points to. */
- copy_item_head(&s_ih, PATH_PITEM_HEAD(p_s_path));
+ copy_item_head(&s_ih, PATH_PITEM_HEAD(path));
tail_len = (n_new_file_size & (n_block_size - 1));
if (get_inode_sd_version(inode) == STAT_DATA_V2)
@@ -209,14 +209,14 @@ int indirect2direct(struct reiserfs_tran
tail = (char *)kmap(page); /* this can schedule */
- if (path_changed(&s_ih, p_s_path)) {
+ if (path_changed(&s_ih, path)) {
/* re-search indirect item */
- if (search_for_position_by_key(sb, p_s_item_key, p_s_path)
+ if (search_for_position_by_key(sb, item_key, path)
== POSITION_NOT_FOUND)
reiserfs_panic(sb, "PAP-5520",
"item to be converted %K does not exist",
- p_s_item_key);
- copy_item_head(&s_ih, PATH_PITEM_HEAD(p_s_path));
+ item_key);
+ copy_item_head(&s_ih, PATH_PITEM_HEAD(path));
#ifdef CONFIG_REISERFS_CHECK
pos = le_ih_k_offset(&s_ih) - 1 +
(ih_item_len(&s_ih) / UNFM_P_SIZE -
@@ -238,13 +238,13 @@ int indirect2direct(struct reiserfs_tran
*/
tail = tail + (pos & (PAGE_CACHE_SIZE - 1));
- PATH_LAST_POSITION(p_s_path)++;
+ PATH_LAST_POSITION(path)++;
- key = *p_s_item_key;
+ key = *item_key;
set_cpu_key_k_type(&key, TYPE_DIRECT);
key.key_length = 4;
/* Insert tail as new direct item in the tree */
- if (reiserfs_insert_item(th, p_s_path, &key, &s_ih, inode,
+ if (reiserfs_insert_item(th, path, &key, &s_ih, inode,
tail ? tail : NULL) < 0) {
/* No disk memory. So we can not convert last unformatted node
to the direct item. In this case we used to adjust
@@ -266,7 +266,7 @@ int indirect2direct(struct reiserfs_tran
/* We have inserted new direct item and must remove last
unformatted node. */
- *p_c_mode = M_CUT;
+ *mode = M_CUT;
/* we store position of first direct item in the in-core inode */
//mark_file_with_tail (inode, pos1 + 1);
--- a/include/linux/reiserfs_fs.h 2007-06-11 14:49:40.000000000 -0400
+++ b/include/linux/reiserfs_fs.h 2007-06-11 14:50:01.000000000 -0400
@@ -674,9 +674,9 @@ static inline void cpu_key_k_offset_dec(
#define is_indirect_cpu_ih(ih) (is_indirect_cpu_key (&((ih)->ih_key)))
#define is_statdata_cpu_ih(ih) (is_statdata_cpu_key (&((ih)->ih_key)))
-#define I_K_KEY_IN_ITEM(p_s_ih, p_s_key, n_blocksize) \
- ( ! COMP_SHORT_KEYS(p_s_ih, p_s_key) && \
- I_OFF_BYTE_IN_ITEM(p_s_ih, k_offset (p_s_key), n_blocksize) )
+#define I_K_KEY_IN_ITEM(ih, key, n_blocksize) \
+ ( ! COMP_SHORT_KEYS(ih, key) && \
+ I_OFF_BYTE_IN_ITEM(ih, k_offset (key), n_blocksize) )
/* maximal length of item */
#define MAX_ITEM_LEN(block_size) (block_size - BLKH_SIZE - IH_SIZE)
@@ -1175,33 +1175,33 @@ struct treepath {
struct treepath var = {.path_length = ILLEGAL_PATH_ELEMENT_OFFSET, .reada = 0,}
/* Get path element by path and path position. */
-#define PATH_OFFSET_PELEMENT(p_s_path,n_offset) ((p_s_path)->path_elements +(n_offset))
+#define PATH_OFFSET_PELEMENT(path,n_offset) ((path)->path_elements +(n_offset))
/* Get buffer header at the path by path and path position. */
-#define PATH_OFFSET_PBUFFER(p_s_path,n_offset) (PATH_OFFSET_PELEMENT(p_s_path,n_offset)->pe_buffer)
+#define PATH_OFFSET_PBUFFER(path,n_offset) (PATH_OFFSET_PELEMENT(path,n_offset)->pe_buffer)
/* Get position in the element at the path by path and path position. */
-#define PATH_OFFSET_POSITION(p_s_path,n_offset) (PATH_OFFSET_PELEMENT(p_s_path,n_offset)->pe_position)
+#define PATH_OFFSET_POSITION(path,n_offset) (PATH_OFFSET_PELEMENT(path,n_offset)->pe_position)
-#define PATH_PLAST_BUFFER(p_s_path) (PATH_OFFSET_PBUFFER((p_s_path), (p_s_path)->path_length))
+#define PATH_PLAST_BUFFER(path) (PATH_OFFSET_PBUFFER((path), (path)->path_length))
/* you know, to the person who didn't
write this the macro name does not
at first suggest what it does.
Maybe POSITION_FROM_PATH_END? Or
maybe we should just focus on
dumping paths... -Hans */
-#define PATH_LAST_POSITION(p_s_path) (PATH_OFFSET_POSITION((p_s_path), (p_s_path)->path_length))
+#define PATH_LAST_POSITION(path) (PATH_OFFSET_POSITION((path), (path)->path_length))
-#define PATH_PITEM_HEAD(p_s_path) B_N_PITEM_HEAD(PATH_PLAST_BUFFER(p_s_path),PATH_LAST_POSITION(p_s_path))
+#define PATH_PITEM_HEAD(path) B_N_PITEM_HEAD(PATH_PLAST_BUFFER(path),PATH_LAST_POSITION(path))
/* in do_balance leaf has h == 0 in contrast with path structure,
where root has level == 0. That is why we need these defines */
-#define PATH_H_PBUFFER(p_s_path, h) PATH_OFFSET_PBUFFER (p_s_path, p_s_path->path_length - (h)) /* tb->S[h] */
+#define PATH_H_PBUFFER(path, h) PATH_OFFSET_PBUFFER (path, path->path_length - (h)) /* tb->S[h] */
#define PATH_H_PPARENT(path, h) PATH_H_PBUFFER (path, (h) + 1) /* tb->F[h] or tb->S[0]->b_parent */
#define PATH_H_POSITION(path, h) PATH_OFFSET_POSITION (path, path->path_length - (h))
#define PATH_H_B_ITEM_ORDER(path, h) PATH_H_POSITION(path, h + 1) /* tb->S[h]->b_item_order */
-#define PATH_H_PATH_OFFSET(p_s_path, n_h) ((p_s_path)->path_length - (n_h))
+#define PATH_H_PATH_OFFSET(path, n_h) ((path)->path_length - (n_h))
#define get_last_bh(path) PATH_PLAST_BUFFER(path)
#define get_ih(path) PATH_PITEM_HEAD(path)
@@ -1491,7 +1491,7 @@ extern struct item_operations *item_ops[
#define COMP_SHORT_KEYS comp_short_keys
/* number of blocks pointed to by the indirect item */
-#define I_UNFM_NUM(p_s_ih) ( ih_item_len(p_s_ih) / UNFM_P_SIZE )
+#define I_UNFM_NUM(ih) ( ih_item_len(ih) / UNFM_P_SIZE )
/* the used space within the unformatted node corresponding to pos within the item pointed to by ih */
#define I_POS_UNFM_SIZE(ih,pos,size) (((pos) == I_UNFM_NUM(ih) - 1 ) ? (size) - ih_free_space(ih) : (size))
@@ -1782,8 +1782,8 @@ int reiserfs_convert_objectid_map_v1(str
/* stree.c */
int B_IS_IN_TREE(const struct buffer_head *);
-extern void copy_item_head(struct item_head *p_v_to,
- const struct item_head *p_v_from);
+extern void copy_item_head(struct item_head *to,
+ const struct item_head *from);
// first key is in cpu form, second - le
extern int comp_short_keys(const struct reiserfs_key *le_key,
@@ -1818,20 +1818,20 @@ static inline void copy_key(struct reise
memcpy(to, from, KEY_SIZE);
}
-int comp_items(const struct item_head *stored_ih, const struct treepath *p_s_path);
-const struct reiserfs_key *get_rkey(const struct treepath *p_s_chk_path,
+int comp_items(const struct item_head *stored_ih, const struct treepath *path);
+const struct reiserfs_key *get_rkey(const struct treepath *chk_path,
const struct super_block *sb);
int search_by_key(struct super_block *, const struct cpu_key *,
struct treepath *, int);
#define search_item(s,key,path) search_by_key (s, key, path, DISK_LEAF_NODE_LEVEL)
int search_for_position_by_key(struct super_block *sb,
- const struct cpu_key *p_s_cpu_key,
- struct treepath *p_s_search_path);
+ const struct cpu_key *cpu_key,
+ struct treepath *search_path);
extern void decrement_bcount(struct buffer_head *bh);
-void decrement_counters_in_path(struct treepath *p_s_search_path);
-void pathrelse(struct treepath *p_s_search_path);
+void decrement_counters_in_path(struct treepath *search_path);
+void pathrelse(struct treepath *search_path);
int reiserfs_check_path(struct treepath *p);
-void pathrelse_and_restore(struct super_block *s, struct treepath *p_s_search_path);
+void pathrelse_and_restore(struct super_block *s, struct treepath *search_path);
int reiserfs_insert_item(struct reiserfs_transaction_handle *th,
struct treepath *path,
@@ -1854,7 +1854,7 @@ int reiserfs_cut_from_item(struct reiser
int reiserfs_delete_item(struct reiserfs_transaction_handle *th,
struct treepath *path,
const struct cpu_key *key,
- struct inode *inode, struct buffer_head *p_s_un_bh);
+ struct inode *inode, struct buffer_head *un_bh);
void reiserfs_delete_solid_item(struct reiserfs_transaction_handle *th,
struct inode *inode, struct reiserfs_key *key);
@@ -1997,7 +1997,7 @@ extern const struct address_space_operat
/* fix_nodes.c */
int fix_nodes(int n_op_mode, struct tree_balance *tb,
- struct item_head *p_s_ins_ih, const void *);
+ struct item_head *ins_ih, const void *);
void unfix_nodes(struct tree_balance *);
/* prints.c */
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 43+ messages in thread
* [patch 30/40] reiserfs: rename _* variables
2007-06-11 19:03 [patch 00/40] reiserfs: patch queue (v2) jeffm
` (27 preceding siblings ...)
2007-06-11 19:03 ` [patch 29/40] reiserfs: rename p_._ variables jeffm
@ 2007-06-11 19:03 ` jeffm
2007-06-11 19:03 ` [patch 31/40] reiserfs: factor out buffer_info initialization jeffm
` (11 subsequent siblings)
40 siblings, 0 replies; 43+ messages in thread
From: jeffm @ 2007-06-11 19:03 UTC (permalink / raw)
To: ReiserFS Mailing List
[-- Attachment #1: reiserfs-rename-._.diff --]
[-- Type: text/plain, Size: 72650 bytes --]
This patch renames n_, c_, etc variables to something more sane. This is
the sixth in a series of patches to rip out some of the awful variable
naming in reiserfs.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
fs/reiserfs/file.c | 6
fs/reiserfs/fix_node.c | 454 +++++++++++++++++++++---------------------
fs/reiserfs/stree.c | 367 ++++++++++++++++-----------------
fs/reiserfs/tail_conversion.c | 30 +-
4 files changed, 427 insertions(+), 430 deletions(-)
--- a/fs/reiserfs/file.c 2007-06-11 14:49:40.000000000 -0400
+++ b/fs/reiserfs/file.c 2007-06-11 14:49:41.000000000 -0400
@@ -138,11 +138,11 @@ static int reiserfs_sync_file(struct fil
struct dentry *dentry, int datasync)
{
struct inode *inode = dentry->d_inode;
- int n_err;
+ int err;
int barrier_done;
BUG_ON(!S_ISREG(inode->i_mode));
- n_err = sync_mapping_buffers(inode->i_mapping);
+ err = sync_mapping_buffers(inode->i_mapping);
reiserfs_write_lock(inode->i_sb);
barrier_done = reiserfs_commit_for_inode(inode);
reiserfs_write_unlock(inode->i_sb);
@@ -150,7 +150,7 @@ static int reiserfs_sync_file(struct fil
blkdev_issue_flush(inode->i_sb->s_bdev, NULL);
if (barrier_done < 0)
return barrier_done;
- return (n_err < 0) ? -EIO : 0;
+ return (err < 0) ? -EIO : 0;
}
/* I really do not want to play with memory shortage right now, so
--- a/fs/reiserfs/fix_node.c 2007-06-11 14:49:40.000000000 -0400
+++ b/fs/reiserfs/fix_node.c 2007-06-11 14:50:01.000000000 -0400
@@ -751,24 +751,24 @@ else \
static void free_buffers_in_tb(struct tree_balance *tb)
{
- int n_counter;
+ int i;
pathrelse(tb->tb_path);
- for (n_counter = 0; n_counter < MAX_HEIGHT; n_counter++) {
- brelse(tb->L[n_counter]);
- brelse(tb->R[n_counter]);
- brelse(tb->FL[n_counter]);
- brelse(tb->FR[n_counter]);
- brelse(tb->CFL[n_counter]);
- brelse(tb->CFR[n_counter]);
-
- tb->L[n_counter] = NULL;
- tb->R[n_counter] = NULL;
- tb->FL[n_counter] = NULL;
- tb->FR[n_counter] = NULL;
- tb->CFL[n_counter] = NULL;
- tb->CFR[n_counter] = NULL;
+ for (i = 0; i < MAX_HEIGHT; i++) {
+ brelse(tb->L[i]);
+ brelse(tb->R[i]);
+ brelse(tb->FL[i]);
+ brelse(tb->FR[i]);
+ brelse(tb->CFL[i]);
+ brelse(tb->CFR[i]);
+
+ tb->L[i] = NULL;
+ tb->R[i] = NULL;
+ tb->FL[i] = NULL;
+ tb->FR[i] = NULL;
+ tb->CFL[i] = NULL;
+ tb->CFR[i] = NULL;
}
}
@@ -778,13 +778,13 @@ static void free_buffers_in_tb(struct tr
* NO_DISK_SPACE - no disk space.
*/
/* The function is NOT SCHEDULE-SAFE! */
-static int get_empty_nodes(struct tree_balance *tb, int n_h)
+static int get_empty_nodes(struct tree_balance *tb, int h)
{
struct buffer_head *new_bh,
- *Sh = PATH_H_PBUFFER(tb->tb_path, n_h);
- b_blocknr_t *blocknr, a_n_blocknrs[MAX_AMOUNT_NEEDED] = { 0, };
- int n_counter, n_number_of_freeblk, n_amount_needed, /* number of needed empty blocks */
- n_retval = CARRY_ON;
+ *Sh = PATH_H_PBUFFER(tb->tb_path, h);
+ b_blocknr_t *blocknr, blocknrs[MAX_AMOUNT_NEEDED] = { 0, };
+ int counter, number_of_freeblk, amount_needed, /* number of needed empty blocks */
+ retval = CARRY_ON;
struct super_block *sb = tb->tb_sb;
/* number_of_freeblk is the number of empty blocks which have been
@@ -793,7 +793,7 @@ static int get_empty_nodes(struct tree_b
number_of_freeblk = tb->cur_blknum can be non-zero if a schedule occurs
after empty blocks are acquired, and the balancing analysis is
then restarted, amount_needed is the number needed by this level
- (n_h) of the balancing analysis.
+ (h) of the balancing analysis.
Note that for systems with many processes writing, it would be
more layout optimal to calculate the total number needed by all
@@ -801,31 +801,31 @@ static int get_empty_nodes(struct tree_b
/* Initiate number_of_freeblk to the amount acquired prior to the restart of
the analysis or 0 if not restarted, then subtract the amount needed
- by all of the levels of the tree below n_h. */
- /* blknum includes S[n_h], so we subtract 1 in this calculation */
- for (n_counter = 0, n_number_of_freeblk = tb->cur_blknum;
- n_counter < n_h; n_counter++)
- n_number_of_freeblk -=
- (tb->blknum[n_counter]) ? (tb->blknum[n_counter] -
+ by all of the levels of the tree below h. */
+ /* blknum includes S[h], so we subtract 1 in this calculation */
+ for (counter = 0, number_of_freeblk = tb->cur_blknum;
+ counter < h; counter++)
+ number_of_freeblk -=
+ (tb->blknum[counter]) ? (tb->blknum[counter] -
1) : 0;
/* Allocate missing empty blocks. */
/* if Sh == 0 then we are getting a new root */
- n_amount_needed = (Sh) ? (tb->blknum[n_h] - 1) : 1;
+ amount_needed = (Sh) ? (tb->blknum[h] - 1) : 1;
/* Amount_needed = the amount that we need more than the amount that we have. */
- if (n_amount_needed > n_number_of_freeblk)
- n_amount_needed -= n_number_of_freeblk;
+ if (amount_needed > number_of_freeblk)
+ amount_needed -= number_of_freeblk;
else /* If we have enough already then there is nothing to do. */
return CARRY_ON;
/* No need to check quota - is not allocated for blocks used for formatted nodes */
- if (reiserfs_new_form_blocknrs(tb, a_n_blocknrs,
- n_amount_needed) == NO_DISK_SPACE)
+ if (reiserfs_new_form_blocknrs(tb, blocknrs,
+ amount_needed) == NO_DISK_SPACE)
return NO_DISK_SPACE;
/* for each blocknumber we just got, get a buffer and stick it on FEB */
- for (blocknr = a_n_blocknrs, n_counter = 0;
- n_counter < n_amount_needed; blocknr++, n_counter++) {
+ for (blocknr = blocknrs, counter = 0;
+ counter < amount_needed; blocknr++, counter++) {
RFALSE(!*blocknr,
"PAP-8135: reiserfs_new_blocknrs failed when got new blocks");
@@ -845,10 +845,10 @@ static int get_empty_nodes(struct tree_b
tb->FEB[tb->cur_blknum++] = new_bh;
}
- if (n_retval == CARRY_ON && FILESYSTEM_CHANGED_TB(tb))
- n_retval = REPEAT_SEARCH;
+ if (retval == CARRY_ON && FILESYSTEM_CHANGED_TB(tb))
+ retval = REPEAT_SEARCH;
- return n_retval;
+ return retval;
}
/* Get free space of the left neighbor, which is stored in the parent
@@ -894,35 +894,35 @@ static int get_rfree(struct tree_balance
}
/* Check whether left neighbor is in memory. */
-static int is_left_neighbor_in_cache(struct tree_balance *tb, int n_h)
+static int is_left_neighbor_in_cache(struct tree_balance *tb, int h)
{
struct buffer_head *father, *left;
struct super_block *sb = tb->tb_sb;
- b_blocknr_t n_left_neighbor_blocknr;
- int n_left_neighbor_position;
+ b_blocknr_t left_neighbor_blocknr;
+ int left_neighbor_position;
- if (!tb->FL[n_h]) /* Father of the left neighbor does not exist. */
+ if (!tb->FL[h]) /* Father of the left neighbor does not exist. */
return 0;
/* Calculate father of the node to be balanced. */
- father = PATH_H_PBUFFER(tb->tb_path, n_h + 1);
+ father = PATH_H_PBUFFER(tb->tb_path, h + 1);
RFALSE(!father ||
!B_IS_IN_TREE(father) ||
- !B_IS_IN_TREE(tb->FL[n_h]) ||
+ !B_IS_IN_TREE(tb->FL[h]) ||
!buffer_uptodate(father) ||
- !buffer_uptodate(tb->FL[n_h]),
+ !buffer_uptodate(tb->FL[h]),
"vs-8165: F[h] (%b) or FL[h] (%b) is invalid",
- father, tb->FL[n_h]);
+ father, tb->FL[h]);
/* Get position of the pointer to the left neighbor into the left father. */
- n_left_neighbor_position = (father == tb->FL[n_h]) ?
- tb->lkey[n_h] : B_NR_ITEMS(tb->FL[n_h]);
+ left_neighbor_position = (father == tb->FL[h]) ?
+ tb->lkey[h] : B_NR_ITEMS(tb->FL[h]);
/* Get left neighbor block number. */
- n_left_neighbor_blocknr =
- B_N_CHILD_NUM(tb->FL[n_h], n_left_neighbor_position);
+ left_neighbor_blocknr =
+ B_N_CHILD_NUM(tb->FL[h], left_neighbor_position);
/* Look for the left neighbor in the cache. */
- if ((left = sb_find_get_block(sb, n_left_neighbor_blocknr))) {
+ if ((left = sb_find_get_block(sb, left_neighbor_blocknr))) {
RFALSE(buffer_uptodate(left) && !B_IS_IN_TREE(left),
"vs-8170: left neighbor (%b %z) is not in the tree",
@@ -952,7 +952,7 @@ static void decrement_key(struct cpu_key
* CARRY_ON - schedule didn't occur while the function worked;
*/
static int get_far_parent(struct tree_balance *tb,
- int n_h,
+ int h,
struct buffer_head **pfather,
struct buffer_head **pcom_father, char c_lr_par)
{
@@ -960,38 +960,38 @@ static int get_far_parent(struct tree_ba
INITIALIZE_PATH(s_path_to_neighbor_father);
struct treepath *path = tb->tb_path;
struct cpu_key s_lr_father_key;
- int n_counter,
- n_position = INT_MAX,
- n_first_last_position = 0,
- n_path_offset = PATH_H_PATH_OFFSET(path, n_h);
+ int counter,
+ position = INT_MAX,
+ first_last_position = 0,
+ path_offset = PATH_H_PATH_OFFSET(path, h);
- /* Starting from F[n_h] go upwards in the tree, and look for the common
- ancestor of F[n_h], and its neighbor l/r, that should be obtained. */
+ /* Starting from F[h] go upwards in the tree, and look for the common
+ ancestor of F[h], and its neighbor l/r, that should be obtained. */
- n_counter = n_path_offset;
+ counter = path_offset;
- RFALSE(n_counter < FIRST_PATH_ELEMENT_OFFSET,
+ RFALSE(counter < FIRST_PATH_ELEMENT_OFFSET,
"PAP-8180: invalid path length");
- for (; n_counter > FIRST_PATH_ELEMENT_OFFSET; n_counter--) {
+ for (; counter > FIRST_PATH_ELEMENT_OFFSET; counter--) {
/* Check whether parent of the current buffer in the path is really parent in the tree. */
if (!B_IS_IN_TREE
- (parent = PATH_OFFSET_PBUFFER(path, n_counter - 1)))
+ (parent = PATH_OFFSET_PBUFFER(path, counter - 1)))
return REPEAT_SEARCH;
/* Check whether position in the parent is correct. */
- if ((n_position =
+ if ((position =
PATH_OFFSET_POSITION(path,
- n_counter - 1)) >
+ counter - 1)) >
B_NR_ITEMS(parent))
return REPEAT_SEARCH;
/* Check whether parent at the path really points to the child. */
- if (B_N_CHILD_NUM(parent, n_position) !=
- PATH_OFFSET_PBUFFER(path, n_counter)->b_blocknr)
+ if (B_N_CHILD_NUM(parent, position) !=
+ PATH_OFFSET_PBUFFER(path, counter)->b_blocknr)
return REPEAT_SEARCH;
/* Return delimiting key if position in the parent is not equal to first/last one. */
if (c_lr_par == RIGHT_PARENTS)
- n_first_last_position = B_NR_ITEMS(parent);
- if (n_position != n_first_last_position) {
+ first_last_position = B_NR_ITEMS(parent);
+ if (position != first_last_position) {
*pcom_father = parent;
get_bh(*pcom_father);
/*(*pcom_father = parent)->b_count++; */
@@ -1000,7 +1000,7 @@ static int get_far_parent(struct tree_ba
}
/* if we are in the root of the tree, then there is no common father */
- if (n_counter == FIRST_PATH_ELEMENT_OFFSET) {
+ if (counter == FIRST_PATH_ELEMENT_OFFSET) {
/* Check whether first buffer in the path is the root of the tree. */
if (PATH_OFFSET_PBUFFER
(tb->tb_path,
@@ -1033,18 +1033,18 @@ static int get_far_parent(struct tree_ba
le_key2cpu_key(&s_lr_father_key,
B_N_PDELIM_KEY(*pcom_father,
(c_lr_par ==
- LEFT_PARENTS) ? (tb->lkey[n_h - 1] =
- n_position -
- 1) : (tb->rkey[n_h -
+ LEFT_PARENTS) ? (tb->lkey[h - 1] =
+ position -
+ 1) : (tb->rkey[h -
1] =
- n_position)));
+ position)));
if (c_lr_par == LEFT_PARENTS)
decrement_key(&s_lr_father_key);
if (search_by_key
(tb->tb_sb, &s_lr_father_key, &s_path_to_neighbor_father,
- n_h + 1) == IO_ERROR)
+ h + 1) == IO_ERROR)
// path is released
return IO_ERROR;
@@ -1056,7 +1056,7 @@ static int get_far_parent(struct tree_ba
*pfather = PATH_PLAST_BUFFER(&s_path_to_neighbor_father);
- RFALSE(B_LEVEL(*pfather) != n_h + 1,
+ RFALSE(B_LEVEL(*pfather) != h + 1,
"PAP-8190: (%b %z) level too small", *pfather, *pfather);
RFALSE(s_path_to_neighbor_father.path_length <
FIRST_PATH_ELEMENT_OFFSET, "PAP-8192: path length is too small");
@@ -1066,89 +1066,89 @@ static int get_far_parent(struct tree_ba
return CARRY_ON;
}
-/* Get parents of neighbors of node in the path(S[n_path_offset]) and common parents of
- * S[n_path_offset] and L[n_path_offset]/R[n_path_offset]: F[n_path_offset], FL[n_path_offset],
- * FR[n_path_offset], CFL[n_path_offset], CFR[n_path_offset].
- * Calculate numbers of left and right delimiting keys position: lkey[n_path_offset], rkey[n_path_offset].
+/* Get parents of neighbors of node in the path(S[path_offset]) and common parents of
+ * S[path_offset] and L[path_offset]/R[path_offset]: F[path_offset], FL[path_offset],
+ * FR[path_offset], CFL[path_offset], CFR[path_offset].
+ * Calculate numbers of left and right delimiting keys position: lkey[path_offset], rkey[path_offset].
* Returns: SCHEDULE_OCCURRED - schedule occurred while the function worked;
* CARRY_ON - schedule didn't occur while the function worked;
*/
-static int get_parents(struct tree_balance *tb, int n_h)
+static int get_parents(struct tree_balance *tb, int h)
{
struct treepath *path = tb->tb_path;
- int n_position,
- n_ret_value,
- n_path_offset = PATH_H_PATH_OFFSET(tb->tb_path, n_h);
+ int position,
+ ret,
+ path_offset = PATH_H_PATH_OFFSET(tb->tb_path, h);
struct buffer_head *curf, *curcf;
/* Current node is the root of the tree or will be root of the tree */
- if (n_path_offset <= FIRST_PATH_ELEMENT_OFFSET) {
+ if (path_offset <= FIRST_PATH_ELEMENT_OFFSET) {
/* The root can not have parents.
Release nodes which previously were obtained as parents of the current node neighbors. */
- brelse(tb->FL[n_h]);
- brelse(tb->CFL[n_h]);
- brelse(tb->FR[n_h]);
- brelse(tb->CFR[n_h]);
- tb->FL[n_h] = tb->CFL[n_h] = tb->FR[n_h] =
- tb->CFR[n_h] = NULL;
+ brelse(tb->FL[h]);
+ brelse(tb->CFL[h]);
+ brelse(tb->FR[h]);
+ brelse(tb->CFR[h]);
+ tb->FL[h] = tb->CFL[h] = tb->FR[h] =
+ tb->CFR[h] = NULL;
return CARRY_ON;
}
- /* Get parent FL[n_path_offset] of L[n_path_offset]. */
- if ((n_position = PATH_OFFSET_POSITION(path, n_path_offset - 1))) {
+ /* Get parent FL[path_offset] of L[path_offset]. */
+ if ((position = PATH_OFFSET_POSITION(path, path_offset - 1))) {
/* Current node is not the first child of its parent. */
- /*(curf = curcf = PATH_OFFSET_PBUFFER(path, n_path_offset - 1))->b_count += 2; */
+ /*(curf = curcf = PATH_OFFSET_PBUFFER(path, path_offset - 1))->b_count += 2; */
curf = curcf =
- PATH_OFFSET_PBUFFER(path, n_path_offset - 1);
+ PATH_OFFSET_PBUFFER(path, path_offset - 1);
get_bh(curf);
get_bh(curf);
- tb->lkey[n_h] = n_position - 1;
+ tb->lkey[h] = position - 1;
} else {
- /* Calculate current parent of L[n_path_offset], which is the left neighbor of the current node.
- Calculate current common parent of L[n_path_offset] and the current node. Note that
- CFL[n_path_offset] not equal FL[n_path_offset] and CFL[n_path_offset] not equal F[n_path_offset].
- Calculate lkey[n_path_offset]. */
- if ((n_ret_value = get_far_parent(tb, n_h + 1, &curf,
+ /* Calculate current parent of L[path_offset], which is the left neighbor of the current node.
+ Calculate current common parent of L[path_offset] and the current node. Note that
+ CFL[path_offset] not equal FL[path_offset] and CFL[path_offset] not equal F[path_offset].
+ Calculate lkey[path_offset]. */
+ if ((ret = get_far_parent(tb, h + 1, &curf,
&curcf,
LEFT_PARENTS)) != CARRY_ON)
- return n_ret_value;
+ return ret;
}
- brelse(tb->FL[n_h]);
- tb->FL[n_h] = curf; /* New initialization of FL[n_h]. */
- brelse(tb->CFL[n_h]);
- tb->CFL[n_h] = curcf; /* New initialization of CFL[n_h]. */
+ brelse(tb->FL[h]);
+ tb->FL[h] = curf; /* New initialization of FL[h]. */
+ brelse(tb->CFL[h]);
+ tb->CFL[h] = curcf; /* New initialization of CFL[h]. */
RFALSE((curf && !B_IS_IN_TREE(curf)) ||
(curcf && !B_IS_IN_TREE(curcf)),
"PAP-8195: FL (%b) or CFL (%b) is invalid", curf, curcf);
-/* Get parent FR[n_h] of R[n_h]. */
+/* Get parent FR[h] of R[h]. */
-/* Current node is the last child of F[n_h]. FR[n_h] != F[n_h]. */
- if (n_position == B_NR_ITEMS(PATH_H_PBUFFER(path, n_h + 1))) {
-/* Calculate current parent of R[n_h], which is the right neighbor of F[n_h].
- Calculate current common parent of R[n_h] and current node. Note that CFR[n_h]
- not equal FR[n_path_offset] and CFR[n_h] not equal F[n_h]. */
- if ((n_ret_value =
- get_far_parent(tb, n_h + 1, &curf, &curcf,
+/* Current node is the last child of F[h]. FR[h] != F[h]. */
+ if (position == B_NR_ITEMS(PATH_H_PBUFFER(path, h + 1))) {
+/* Calculate current parent of R[h], which is the right neighbor of F[h].
+ Calculate current common parent of R[h] and current node. Note that CFR[h]
+ not equal FR[path_offset] and CFR[h] not equal F[h]. */
+ if ((ret =
+ get_far_parent(tb, h + 1, &curf, &curcf,
RIGHT_PARENTS)) != CARRY_ON)
- return n_ret_value;
+ return ret;
} else {
-/* Current node is not the last child of its parent F[n_h]. */
- /*(curf = curcf = PATH_OFFSET_PBUFFER(path, n_path_offset - 1))->b_count += 2; */
+/* Current node is not the last child of its parent F[h]. */
+ /*(curf = curcf = PATH_OFFSET_PBUFFER(path, path_offset - 1))->b_count += 2; */
curf = curcf =
- PATH_OFFSET_PBUFFER(path, n_path_offset - 1);
+ PATH_OFFSET_PBUFFER(path, path_offset - 1);
get_bh(curf);
get_bh(curf);
- tb->rkey[n_h] = n_position;
+ tb->rkey[h] = position;
}
- brelse(tb->FR[n_h]);
- tb->FR[n_h] = curf; /* New initialization of FR[n_path_offset]. */
+ brelse(tb->FR[h]);
+ tb->FR[h] = curf; /* New initialization of FR[path_offset]. */
- brelse(tb->CFR[n_h]);
- tb->CFR[n_h] = curcf; /* New initialization of CFR[n_path_offset]. */
+ brelse(tb->CFR[h]);
+ tb->CFR[h] = curcf; /* New initialization of CFR[path_offset]. */
RFALSE((curf && !B_IS_IN_TREE(curf)) ||
(curcf && !B_IS_IN_TREE(curcf)),
@@ -1216,7 +1216,7 @@ static int ip_check_balance(struct tree_
contains node being balanced. The mnemonic is
that the attempted change in node space used level
is levbytes bytes. */
- n_ret_value;
+ ret;
int lfree, sfree, rfree /* free space in L, S and R */ ;
@@ -1256,22 +1256,22 @@ static int ip_check_balance(struct tree_
if (!h)
reiserfs_panic(tb->tb_sb, "vs-8210",
"S[0] can not be 0");
- switch (n_ret_value = get_empty_nodes(tb, h)) {
+ switch (ret = get_empty_nodes(tb, h)) {
case CARRY_ON:
set_parameters(tb, h, 0, 0, 1, NULL, -1, -1);
return NO_BALANCING_NEEDED; /* no balancing for higher levels needed */
case NO_DISK_SPACE:
case REPEAT_SEARCH:
- return n_ret_value;
+ return ret;
default:
reiserfs_panic(tb->tb_sb, "vs-8215", "incorrect "
"return value of get_empty_nodes");
}
}
- if ((n_ret_value = get_parents(tb, h)) != CARRY_ON) /* get parents of S[h] neighbors. */
- return n_ret_value;
+ if ((ret = get_parents(tb, h)) != CARRY_ON) /* get parents of S[h] neighbors. */
+ return ret;
sfree = B_FREE_SPACE(Sh);
@@ -1558,7 +1558,7 @@ static int dc_check_balance_internal(str
/* Sh is the node whose balance is currently being checked,
and Fh is its father. */
struct buffer_head *Sh, *Fh;
- int maxsize, n_ret_value;
+ int maxsize, ret;
int lfree, rfree /* free space in L and R */ ;
Sh = PATH_H_PBUFFER(tb->tb_path, h);
@@ -1583,8 +1583,8 @@ static int dc_check_balance_internal(str
return CARRY_ON;
}
- if ((n_ret_value = get_parents(tb, h)) != CARRY_ON)
- return n_ret_value;
+ if ((ret = get_parents(tb, h)) != CARRY_ON)
+ return ret;
/* get free space of neighbors */
rfree = get_rfree(tb, h);
@@ -1741,7 +1741,7 @@ static int dc_check_balance_leaf(struct
attempted change in node space used level is levbytes bytes. */
int levbytes;
/* the maximal item size */
- int maxsize, n_ret_value;
+ int maxsize, ret;
/* S0 is the node whose balance is currently being checked,
and F0 is its father. */
struct buffer_head *S0, *F0;
@@ -1763,8 +1763,8 @@ static int dc_check_balance_leaf(struct
return NO_BALANCING_NEEDED;
}
- if ((n_ret_value = get_parents(tb, h)) != CARRY_ON)
- return n_ret_value;
+ if ((ret = get_parents(tb, h)) != CARRY_ON)
+ return ret;
/* get free space of neighbors */
rfree = get_rfree(tb, h);
@@ -1883,40 +1883,40 @@ static int check_balance(int mode,
}
/* Check whether parent at the path is the really parent of the current node.*/
-static int get_direct_parent(struct tree_balance *tb, int n_h)
+static int get_direct_parent(struct tree_balance *tb, int h)
{
struct buffer_head *bh;
struct treepath *path = tb->tb_path;
- int n_position,
- n_path_offset = PATH_H_PATH_OFFSET(tb->tb_path, n_h);
+ int position,
+ path_offset = PATH_H_PATH_OFFSET(tb->tb_path, h);
/* We are in the root or in the new root. */
- if (n_path_offset <= FIRST_PATH_ELEMENT_OFFSET) {
+ if (path_offset <= FIRST_PATH_ELEMENT_OFFSET) {
- RFALSE(n_path_offset < FIRST_PATH_ELEMENT_OFFSET - 1,
+ RFALSE(path_offset < FIRST_PATH_ELEMENT_OFFSET - 1,
"PAP-8260: invalid offset in the path");
if (PATH_OFFSET_PBUFFER(path, FIRST_PATH_ELEMENT_OFFSET)->
b_blocknr == SB_ROOT_BLOCK(tb->tb_sb)) {
/* Root is not changed. */
- PATH_OFFSET_PBUFFER(path, n_path_offset - 1) = NULL;
- PATH_OFFSET_POSITION(path, n_path_offset - 1) = 0;
+ PATH_OFFSET_PBUFFER(path, path_offset - 1) = NULL;
+ PATH_OFFSET_POSITION(path, path_offset - 1) = 0;
return CARRY_ON;
}
return REPEAT_SEARCH; /* Root is changed and we must recalculate the path. */
}
if (!B_IS_IN_TREE
- (bh = PATH_OFFSET_PBUFFER(path, n_path_offset - 1)))
+ (bh = PATH_OFFSET_PBUFFER(path, path_offset - 1)))
return REPEAT_SEARCH; /* Parent in the path is not in the tree. */
- if ((n_position =
+ if ((position =
PATH_OFFSET_POSITION(path,
- n_path_offset - 1)) > B_NR_ITEMS(bh))
+ path_offset - 1)) > B_NR_ITEMS(bh))
return REPEAT_SEARCH;
- if (B_N_CHILD_NUM(bh, n_position) !=
- PATH_OFFSET_PBUFFER(path, n_path_offset)->b_blocknr)
+ if (B_N_CHILD_NUM(bh, position) !=
+ PATH_OFFSET_PBUFFER(path, path_offset)->b_blocknr)
/* Parent in the path is not parent of the current node in the tree. */
return REPEAT_SEARCH;
@@ -1929,91 +1929,91 @@ static int get_direct_parent(struct tree
return CARRY_ON; /* Parent in the path is unlocked and really parent of the current node. */
}
-/* Using lnum[n_h] and rnum[n_h] we should determine what neighbors
- * of S[n_h] we
- * need in order to balance S[n_h], and get them if necessary.
+/* Using lnum[h] and rnum[h] we should determine what neighbors
+ * of S[h] we
+ * need in order to balance S[h], and get them if necessary.
* Returns: SCHEDULE_OCCURRED - schedule occurred while the function worked;
* CARRY_ON - schedule didn't occur while the function worked;
*/
-static int get_neighbors(struct tree_balance *tb, int n_h)
+static int get_neighbors(struct tree_balance *tb, int h)
{
- int n_child_position,
- n_path_offset = PATH_H_PATH_OFFSET(tb->tb_path, n_h + 1);
- unsigned long n_son_number;
+ int child_position,
+ path_offset = PATH_H_PATH_OFFSET(tb->tb_path, h + 1);
+ unsigned long son_number;
struct super_block *sb = tb->tb_sb;
struct buffer_head *bh;
- PROC_INFO_INC(sb, get_neighbors[n_h]);
+ PROC_INFO_INC(sb, get_neighbors[h]);
- if (tb->lnum[n_h]) {
- /* We need left neighbor to balance S[n_h]. */
- PROC_INFO_INC(sb, need_l_neighbor[n_h]);
- bh = PATH_OFFSET_PBUFFER(tb->tb_path, n_path_offset);
+ if (tb->lnum[h]) {
+ /* We need left neighbor to balance S[h]. */
+ PROC_INFO_INC(sb, need_l_neighbor[h]);
+ bh = PATH_OFFSET_PBUFFER(tb->tb_path, path_offset);
- RFALSE(bh == tb->FL[n_h] &&
- !PATH_OFFSET_POSITION(tb->tb_path, n_path_offset),
+ RFALSE(bh == tb->FL[h] &&
+ !PATH_OFFSET_POSITION(tb->tb_path, path_offset),
"PAP-8270: invalid position in the parent");
- n_child_position =
+ child_position =
(bh ==
- tb->FL[n_h]) ? tb->lkey[n_h] : B_NR_ITEMS(tb->
- FL[n_h]);
- n_son_number = B_N_CHILD_NUM(tb->FL[n_h], n_child_position);
- bh = sb_bread(sb, n_son_number);
+ tb->FL[h]) ? tb->lkey[h] : B_NR_ITEMS(tb->
+ FL[h]);
+ son_number = B_N_CHILD_NUM(tb->FL[h], child_position);
+ bh = sb_bread(sb, son_number);
if (!bh)
return IO_ERROR;
if (FILESYSTEM_CHANGED_TB(tb)) {
brelse(bh);
- PROC_INFO_INC(sb, get_neighbors_restart[n_h]);
+ PROC_INFO_INC(sb, get_neighbors_restart[h]);
return REPEAT_SEARCH;
}
- RFALSE(!B_IS_IN_TREE(tb->FL[n_h]) ||
- n_child_position > B_NR_ITEMS(tb->FL[n_h]) ||
- B_N_CHILD_NUM(tb->FL[n_h], n_child_position) !=
+ RFALSE(!B_IS_IN_TREE(tb->FL[h]) ||
+ child_position > B_NR_ITEMS(tb->FL[h]) ||
+ B_N_CHILD_NUM(tb->FL[h], child_position) !=
bh->b_blocknr, "PAP-8275: invalid parent");
RFALSE(!B_IS_IN_TREE(bh), "PAP-8280: invalid child");
- RFALSE(!n_h &&
+ RFALSE(!h &&
B_FREE_SPACE(bh) !=
MAX_CHILD_SIZE(bh) -
- dc_size(B_N_CHILD(tb->FL[0], n_child_position)),
+ dc_size(B_N_CHILD(tb->FL[0], child_position)),
"PAP-8290: invalid child size of left neighbor");
- brelse(tb->L[n_h]);
- tb->L[n_h] = bh;
+ brelse(tb->L[h]);
+ tb->L[h] = bh;
}
- if (tb->rnum[n_h]) { /* We need right neighbor to balance S[n_path_offset]. */
- PROC_INFO_INC(sb, need_r_neighbor[n_h]);
- bh = PATH_OFFSET_PBUFFER(tb->tb_path, n_path_offset);
+ if (tb->rnum[h]) { /* We need right neighbor to balance S[path_offset]. */
+ PROC_INFO_INC(sb, need_r_neighbor[h]);
+ bh = PATH_OFFSET_PBUFFER(tb->tb_path, path_offset);
- RFALSE(bh == tb->FR[n_h] &&
+ RFALSE(bh == tb->FR[h] &&
PATH_OFFSET_POSITION(tb->tb_path,
- n_path_offset) >=
+ path_offset) >=
B_NR_ITEMS(bh),
"PAP-8295: invalid position in the parent");
- n_child_position =
- (bh == tb->FR[n_h]) ? tb->rkey[n_h] + 1 : 0;
- n_son_number = B_N_CHILD_NUM(tb->FR[n_h], n_child_position);
- bh = sb_bread(sb, n_son_number);
+ child_position =
+ (bh == tb->FR[h]) ? tb->rkey[h] + 1 : 0;
+ son_number = B_N_CHILD_NUM(tb->FR[h], child_position);
+ bh = sb_bread(sb, son_number);
if (!bh)
return IO_ERROR;
if (FILESYSTEM_CHANGED_TB(tb)) {
brelse(bh);
- PROC_INFO_INC(sb, get_neighbors_restart[n_h]);
+ PROC_INFO_INC(sb, get_neighbors_restart[h]);
return REPEAT_SEARCH;
}
- brelse(tb->R[n_h]);
- tb->R[n_h] = bh;
+ brelse(tb->R[h]);
+ tb->R[h] = bh;
- RFALSE(!n_h
+ RFALSE(!h
&& B_FREE_SPACE(bh) !=
MAX_CHILD_SIZE(bh) -
- dc_size(B_N_CHILD(tb->FR[0], n_child_position)),
+ dc_size(B_N_CHILD(tb->FR[0], child_position)),
"PAP-8300: invalid child size of right neighbor (%d != %d - %d)",
B_FREE_SPACE(bh), MAX_CHILD_SIZE(bh),
- dc_size(B_N_CHILD(tb->FR[0], n_child_position)));
+ dc_size(B_N_CHILD(tb->FR[0], child_position)));
}
return CARRY_ON;
@@ -2317,12 +2317,12 @@ static int wait_tb_buffers_until_unlocke
* -1 - if no_disk_space
*/
-int fix_nodes(int n_op_mode, struct tree_balance *tb, struct item_head *ins_ih, // item head of item being inserted
+int fix_nodes(int op_mode, struct tree_balance *tb, struct item_head *ins_ih, // item head of item being inserted
const void *data // inserted item or data to be pasted
)
{
- int n_ret_value, n_h, n_item_num = PATH_LAST_POSITION(tb->tb_path);
- int n_pos_in_item;
+ int ret, h, item_num = PATH_LAST_POSITION(tb->tb_path);
+ int pos_in_item;
/* we set wait_tb_buffers_run when we have to restore any dirty bits cleared
** during wait_tb_buffers_run
@@ -2332,7 +2332,7 @@ int fix_nodes(int n_op_mode, struct tree
++REISERFS_SB(tb->tb_sb)->s_fix_nodes;
- n_pos_in_item = tb->tb_path->pos_in_item;
+ pos_in_item = tb->tb_path->pos_in_item;
tb->fs_gen = get_generation(tb->tb_sb);
@@ -2365,27 +2365,27 @@ int fix_nodes(int n_op_mode, struct tree
reiserfs_panic(tb->tb_sb, "PAP-8320", "S[0] (%b %z) is "
"not uptodate at the beginning of fix_nodes "
"or not in tree (mode %c)",
- tbS0, tbS0, n_op_mode);
+ tbS0, tbS0, op_mode);
}
/* Check parameters. */
- switch (n_op_mode) {
+ switch (op_mode) {
case M_INSERT:
- if (n_item_num <= 0 || n_item_num > B_NR_ITEMS(tbS0))
+ if (item_num <= 0 || item_num > B_NR_ITEMS(tbS0))
reiserfs_panic(tb->tb_sb, "PAP-8330", "Incorrect "
"item number %d (in S0 - %d) in case "
- "of insert", n_item_num,
+ "of insert", item_num,
B_NR_ITEMS(tbS0));
break;
case M_PASTE:
case M_DELETE:
case M_CUT:
- if (n_item_num < 0 || n_item_num >= B_NR_ITEMS(tbS0)) {
+ if (item_num < 0 || item_num >= B_NR_ITEMS(tbS0)) {
print_block(tbS0, 0, -1, -1);
reiserfs_panic(tb->tb_sb, "PAP-8335", "Incorrect "
"item number(%d); mode = %c "
"insert_size = %d",
- n_item_num, n_op_mode,
+ item_num, op_mode,
tb->insert_size[0]);
}
break;
@@ -2399,73 +2399,73 @@ int fix_nodes(int n_op_mode, struct tree
// FIXME: maybe -ENOMEM when tb->vn_buf == 0? Now just repeat
return REPEAT_SEARCH;
- /* Starting from the leaf level; for all levels n_h of the tree. */
- for (n_h = 0; n_h < MAX_HEIGHT && tb->insert_size[n_h]; n_h++) {
- if ((n_ret_value = get_direct_parent(tb, n_h)) != CARRY_ON) {
+ /* Starting from the leaf level; for all levels h of the tree. */
+ for (h = 0; h < MAX_HEIGHT && tb->insert_size[h]; h++) {
+ if ((ret = get_direct_parent(tb, h)) != CARRY_ON) {
goto repeat;
}
- if ((n_ret_value =
- check_balance(n_op_mode, tb, n_h, n_item_num,
- n_pos_in_item, ins_ih,
+ if ((ret =
+ check_balance(op_mode, tb, h, item_num,
+ pos_in_item, ins_ih,
data)) != CARRY_ON) {
- if (n_ret_value == NO_BALANCING_NEEDED) {
+ if (ret == NO_BALANCING_NEEDED) {
/* No balancing for higher levels needed. */
- if ((n_ret_value =
- get_neighbors(tb, n_h)) != CARRY_ON) {
+ if ((ret =
+ get_neighbors(tb, h)) != CARRY_ON) {
goto repeat;
}
- if (n_h != MAX_HEIGHT - 1)
- tb->insert_size[n_h + 1] = 0;
+ if (h != MAX_HEIGHT - 1)
+ tb->insert_size[h + 1] = 0;
/* ok, analysis and resource gathering are complete */
break;
}
goto repeat;
}
- if ((n_ret_value = get_neighbors(tb, n_h)) != CARRY_ON) {
+ if ((ret = get_neighbors(tb, h)) != CARRY_ON) {
goto repeat;
}
- if ((n_ret_value = get_empty_nodes(tb, n_h)) != CARRY_ON) {
+ if ((ret = get_empty_nodes(tb, h)) != CARRY_ON) {
goto repeat; /* No disk space, or schedule occurred and
analysis may be invalid and needs to be redone. */
}
- if (!PATH_H_PBUFFER(tb->tb_path, n_h)) {
+ if (!PATH_H_PBUFFER(tb->tb_path, h)) {
/* We have a positive insert size but no nodes exist on this
level, this means that we are creating a new root. */
- RFALSE(tb->blknum[n_h] != 1,
+ RFALSE(tb->blknum[h] != 1,
"PAP-8350: creating new empty root");
- if (n_h < MAX_HEIGHT - 1)
- tb->insert_size[n_h + 1] = 0;
- } else if (!PATH_H_PBUFFER(tb->tb_path, n_h + 1)) {
- if (tb->blknum[n_h] > 1) {
- /* The tree needs to be grown, so this node S[n_h]
+ if (h < MAX_HEIGHT - 1)
+ tb->insert_size[h + 1] = 0;
+ } else if (!PATH_H_PBUFFER(tb->tb_path, h + 1)) {
+ if (tb->blknum[h] > 1) {
+ /* The tree needs to be grown, so this node S[h]
which is the root node is split into two nodes,
- and a new node (S[n_h+1]) will be created to
+ and a new node (S[h+1]) will be created to
become the root node. */
- RFALSE(n_h == MAX_HEIGHT - 1,
+ RFALSE(h == MAX_HEIGHT - 1,
"PAP-8355: attempt to create too high of a tree");
- tb->insert_size[n_h + 1] =
+ tb->insert_size[h + 1] =
(DC_SIZE +
- KEY_SIZE) * (tb->blknum[n_h] - 1) +
+ KEY_SIZE) * (tb->blknum[h] - 1) +
DC_SIZE;
- } else if (n_h < MAX_HEIGHT - 1)
- tb->insert_size[n_h + 1] = 0;
+ } else if (h < MAX_HEIGHT - 1)
+ tb->insert_size[h + 1] = 0;
} else
- tb->insert_size[n_h + 1] =
- (DC_SIZE + KEY_SIZE) * (tb->blknum[n_h] - 1);
+ tb->insert_size[h + 1] =
+ (DC_SIZE + KEY_SIZE) * (tb->blknum[h] - 1);
}
- if ((n_ret_value = wait_tb_buffers_until_unlocked(tb)) == CARRY_ON) {
+ if ((ret = wait_tb_buffers_until_unlocked(tb)) == CARRY_ON) {
if (FILESYSTEM_CHANGED_TB(tb)) {
wait_tb_buffers_run = 1;
- n_ret_value = REPEAT_SEARCH;
+ ret = REPEAT_SEARCH;
goto repeat;
} else {
return CARRY_ON;
@@ -2532,7 +2532,7 @@ int fix_nodes(int n_op_mode, struct tree
}
}
}
- return n_ret_value;
+ return ret;
}
}
--- a/fs/reiserfs/stree.c 2007-06-11 14:49:40.000000000 -0400
+++ b/fs/reiserfs/stree.c 2007-06-11 14:49:41.000000000 -0400
@@ -136,11 +136,11 @@ inline int comp_short_le_keys(const stru
const struct reiserfs_key *key2)
{
__u32 *k1_u32, *k2_u32;
- int n_key_length = REISERFS_SHORT_KEY_LEN;
+ int key_length = REISERFS_SHORT_KEY_LEN;
k1_u32 = (__u32 *) key1;
k2_u32 = (__u32 *) key2;
- for (; n_key_length--; ++k1_u32, ++k2_u32) {
+ for (; key_length--; ++k1_u32, ++k2_u32) {
if (le32_to_cpu(*k1_u32) < le32_to_cpu(*k2_u32))
return -1;
if (le32_to_cpu(*k1_u32) > le32_to_cpu(*k2_u32))
@@ -174,13 +174,13 @@ inline int comp_le_keys(const struct rei
* Binary search toolkit function *
* Search for an item in the array by the item key *
* Returns: 1 if found, 0 if not found; *
- * *pos = number of the searched element if found, else the *
- * number of the first element that is larger than key. *
+ * *pos = number of the searched element if found, else the *
+ * number of the first element that is larger than key. *
**************************************************************************/
-/* For those not familiar with binary search: n_lbound is the leftmost item that it
- could be, n_rbound the rightmost item that it could be. We examine the item
- halfway between n_lbound and n_rbound, and that tells us either that we can increase
- n_lbound, or decrease n_rbound, or that we have found it, or if n_lbound <= n_rbound that
+/* For those not familiar with binary search: lbound is the leftmost item that it
+ could be, rbound the rightmost item that it could be. We examine the item
+ halfway between lbound and rbound, and that tells us either that we can increase
+ lbound, or decrease rbound, or that we have found it, or if lbound <= rbound that
there are no possible items, and we have not found it. With each examination we
cut the number of possible items it could be by one more than half rounded down,
or we find it. */
@@ -198,28 +198,27 @@ static inline int bin_search(const void
int *pos /* Number of the searched for element. */
)
{
- int n_rbound, n_lbound, n_j;
+ int rbound, lbound, j;
- for (n_j = ((n_rbound = num - 1) + (n_lbound = 0)) / 2;
- n_lbound <= n_rbound; n_j = (n_rbound + n_lbound) / 2)
+ for (j = ((rbound = num - 1) + (lbound = 0)) / 2;
+ lbound <= rbound; j = (rbound + lbound) / 2)
switch (comp_keys
- ((struct reiserfs_key *)((char *)base +
- n_j * width),
+ ((struct reiserfs_key *)((char *)base + j * width),
(struct cpu_key *)key)) {
case -1:
- n_lbound = n_j + 1;
+ lbound = j + 1;
continue;
case 1:
- n_rbound = n_j - 1;
+ rbound = j - 1;
continue;
case 0:
- *pos = n_j;
+ *pos = j;
return ITEM_FOUND; /* Key found in the array. */
}
/* bin_search did not find given key, it returns position of key,
that is minimal and greater than the given one. */
- *pos = n_lbound;
+ *pos = lbound;
return ITEM_NOT_FOUND;
}
@@ -242,43 +241,41 @@ static const struct reiserfs_key MAX_KEY
of the path, and going upwards. We must check the path's validity at each step. If the key is not in
the path, there is no delimiting key in the tree (buffer is first or last buffer in tree), and in this
case we return a special key, either MIN_KEY or MAX_KEY. */
-static inline const struct reiserfs_key *get_lkey(const struct treepath
- *chk_path,
- const struct super_block
- *sb)
+static inline const struct reiserfs_key *get_lkey(const struct treepath *chk_path,
+ const struct super_block *sb)
{
- int n_position, n_path_offset = chk_path->path_length;
+ int position, path_offset = chk_path->path_length;
struct buffer_head *parent;
- RFALSE(n_path_offset < FIRST_PATH_ELEMENT_OFFSET,
+ RFALSE(path_offset < FIRST_PATH_ELEMENT_OFFSET,
"PAP-5010: invalid offset in the path");
/* While not higher in path than first element. */
- while (n_path_offset-- > FIRST_PATH_ELEMENT_OFFSET) {
+ while (path_offset-- > FIRST_PATH_ELEMENT_OFFSET) {
RFALSE(!buffer_uptodate
- (PATH_OFFSET_PBUFFER(chk_path, n_path_offset)),
+ (PATH_OFFSET_PBUFFER(chk_path, path_offset)),
"PAP-5020: parent is not uptodate");
/* Parent at the path is not in the tree now. */
if (!B_IS_IN_TREE
(parent =
- PATH_OFFSET_PBUFFER(chk_path, n_path_offset)))
+ PATH_OFFSET_PBUFFER(chk_path, path_offset)))
return &MAX_KEY;
/* Check whether position in the parent is correct. */
- if ((n_position =
+ if ((position =
PATH_OFFSET_POSITION(chk_path,
- n_path_offset)) >
+ path_offset)) >
B_NR_ITEMS(parent))
return &MAX_KEY;
/* Check whether parent at the path really points to the child. */
- if (B_N_CHILD_NUM(parent, n_position) !=
+ if (B_N_CHILD_NUM(parent, position) !=
PATH_OFFSET_PBUFFER(chk_path,
- n_path_offset + 1)->b_blocknr)
+ path_offset + 1)->b_blocknr)
return &MAX_KEY;
/* Return delimiting key if position in the parent is not equal to zero. */
- if (n_position)
- return B_N_PDELIM_KEY(parent, n_position - 1);
+ if (position)
+ return B_N_PDELIM_KEY(parent, position - 1);
}
/* Return MIN_KEY if we are in the root of the buffer tree. */
if (PATH_OFFSET_PBUFFER(chk_path, FIRST_PATH_ELEMENT_OFFSET)->
@@ -291,37 +288,37 @@ static inline const struct reiserfs_key
inline const struct reiserfs_key *get_rkey(const struct treepath *chk_path,
const struct super_block *sb)
{
- int n_position, n_path_offset = chk_path->path_length;
+ int position, path_offset = chk_path->path_length;
struct buffer_head *parent;
- RFALSE(n_path_offset < FIRST_PATH_ELEMENT_OFFSET,
+ RFALSE(path_offset < FIRST_PATH_ELEMENT_OFFSET,
"PAP-5030: invalid offset in the path");
- while (n_path_offset-- > FIRST_PATH_ELEMENT_OFFSET) {
+ while (path_offset-- > FIRST_PATH_ELEMENT_OFFSET) {
RFALSE(!buffer_uptodate
- (PATH_OFFSET_PBUFFER(chk_path, n_path_offset)),
+ (PATH_OFFSET_PBUFFER(chk_path, path_offset)),
"PAP-5040: parent is not uptodate");
/* Parent at the path is not in the tree now. */
if (!B_IS_IN_TREE
(parent =
- PATH_OFFSET_PBUFFER(chk_path, n_path_offset)))
+ PATH_OFFSET_PBUFFER(chk_path, path_offset)))
return &MIN_KEY;
/* Check whether position in the parent is correct. */
- if ((n_position =
+ if ((position =
PATH_OFFSET_POSITION(chk_path,
- n_path_offset)) >
+ path_offset)) >
B_NR_ITEMS(parent))
return &MIN_KEY;
/* Check whether parent at the path really points to the child. */
- if (B_N_CHILD_NUM(parent, n_position) !=
+ if (B_N_CHILD_NUM(parent, position) !=
PATH_OFFSET_PBUFFER(chk_path,
- n_path_offset + 1)->b_blocknr)
+ path_offset + 1)->b_blocknr)
return &MIN_KEY;
/* Return delimiting key if position in the parent is not the last one. */
- if (n_position != B_NR_ITEMS(parent))
- return B_N_PDELIM_KEY(parent, n_position);
+ if (position != B_NR_ITEMS(parent))
+ return B_N_PDELIM_KEY(parent, position);
}
/* Return MAX_KEY if we are in the root of the buffer tree. */
if (PATH_OFFSET_PBUFFER(chk_path, FIRST_PATH_ELEMENT_OFFSET)->
@@ -371,14 +368,14 @@ int reiserfs_check_path(struct treepath
void pathrelse_and_restore(struct super_block *sb,
struct treepath *search_path)
{
- int n_path_offset = search_path->path_length;
+ int path_offset = search_path->path_length;
- RFALSE(n_path_offset < ILLEGAL_PATH_ELEMENT_OFFSET,
+ RFALSE(path_offset < ILLEGAL_PATH_ELEMENT_OFFSET,
"clm-4000: invalid path offset");
- while (n_path_offset > ILLEGAL_PATH_ELEMENT_OFFSET) {
+ while (path_offset > ILLEGAL_PATH_ELEMENT_OFFSET) {
struct buffer_head *bh;
- bh = PATH_OFFSET_PBUFFER(search_path, n_path_offset--);
+ bh = PATH_OFFSET_PBUFFER(search_path, path_offset--);
reiserfs_restore_prepared_buffer(sb, bh);
brelse(bh);
}
@@ -388,13 +385,13 @@ void pathrelse_and_restore(struct super_
/* Drop the reference to each buffer in a path */
void pathrelse(struct treepath *search_path)
{
- int n_path_offset = search_path->path_length;
+ int path_offset = search_path->path_length;
- RFALSE(n_path_offset < ILLEGAL_PATH_ELEMENT_OFFSET,
+ RFALSE(path_offset < ILLEGAL_PATH_ELEMENT_OFFSET,
"PAP-5090: invalid path offset");
- while (n_path_offset > ILLEGAL_PATH_ELEMENT_OFFSET)
- brelse(PATH_OFFSET_PBUFFER(search_path, n_path_offset--));
+ while (path_offset > ILLEGAL_PATH_ELEMENT_OFFSET)
+ brelse(PATH_OFFSET_PBUFFER(search_path, path_offset--));
search_path->path_length = ILLEGAL_PATH_ELEMENT_OFFSET;
}
@@ -572,16 +569,16 @@ int search_by_key(struct super_block *sb
by the calling
function. It is filled up
by this function. */
- int n_stop_level /* How far down the tree to search. To
+ int stop_level /* How far down the tree to search. To
stop at leaf level - set to
DISK_LEAF_NODE_LEVEL */
)
{
- int n_block_number;
+ int block_number;
int expected_level;
struct buffer_head *bh;
struct path_element *last_element;
- int n_node_level, n_retval;
+ int node_level, retval;
int right_neighbor_of_leaf_node;
int fs_gen;
struct buffer_head *reada_bh[SEARCH_BY_KEY_READA];
@@ -589,7 +586,7 @@ int search_by_key(struct super_block *sb
int reada_count = 0;
#ifdef CONFIG_REISERFS_CHECK
- int n_repeat_counter = 0;
+ int repeat_counter = 0;
#endif
PROC_INFO_INC(sb, search_by_key);
@@ -605,16 +602,16 @@ int search_by_key(struct super_block *sb
/* With each iteration of this loop we search through the items in the
current node, and calculate the next current node(next path element)
for the next iteration of this loop.. */
- n_block_number = SB_ROOT_BLOCK(sb);
+ block_number = SB_ROOT_BLOCK(sb);
expected_level = -1;
while (1) {
#ifdef CONFIG_REISERFS_CHECK
- if (!(++n_repeat_counter % 50000))
+ if (!(++repeat_counter % 50000))
reiserfs_warning(sb, "PAP-5100",
"%s: there were %d iterations of "
"while loop looking for key %K",
- current->comm, n_repeat_counter,
+ current->comm, repeat_counter,
key);
#endif
@@ -627,7 +624,7 @@ int search_by_key(struct super_block *sb
/* Read the next tree node, and set the last element in the path to
have a pointer to it. */
if ((bh = last_element->pe_buffer =
- sb_getblk(sb, n_block_number))) {
+ sb_getblk(sb, block_number))) {
if (!buffer_uptodate(bh) && reada_count > 1) {
search_by_key_reada(sb, reada_bh,
reada_blocks, reada_count);
@@ -662,7 +659,7 @@ int search_by_key(struct super_block *sb
/* Get the root block number so that we can repeat the search
starting from the root. */
- n_block_number = SB_ROOT_BLOCK(sb);
+ block_number = SB_ROOT_BLOCK(sb);
expected_level = -1;
right_neighbor_of_leaf_node = 0;
@@ -695,26 +692,26 @@ int search_by_key(struct super_block *sb
}
/* ok, we have acquired next formatted node in the tree */
- n_node_level = B_LEVEL(bh);
+ node_level = B_LEVEL(bh);
- PROC_INFO_BH_STAT(sb, bh, n_node_level - 1);
+ PROC_INFO_BH_STAT(sb, bh, node_level - 1);
- RFALSE(n_node_level < n_stop_level,
+ RFALSE(node_level < stop_level,
"vs-5152: tree level (%d) is less than stop level (%d)",
- n_node_level, n_stop_level);
+ node_level, stop_level);
- n_retval = bin_search(key, B_N_PITEM_HEAD(bh, 0),
+ retval = bin_search(key, B_N_PITEM_HEAD(bh, 0),
B_NR_ITEMS(bh),
- (n_node_level ==
+ (node_level ==
DISK_LEAF_NODE_LEVEL) ? IH_SIZE :
KEY_SIZE,
&(last_element->pe_position));
- if (n_node_level == n_stop_level) {
- return n_retval;
+ if (node_level == stop_level) {
+ return retval;
}
/* we are not in the stop level */
- if (n_retval == ITEM_FOUND)
+ if (retval == ITEM_FOUND)
/* item has been found, so we choose the pointer which is to the right of the found one */
last_element->pe_position++;
@@ -725,12 +722,12 @@ int search_by_key(struct super_block *sb
/* So we have chosen a position in the current node which is
an internal node. Now we calculate child block number by
position in the node. */
- n_block_number =
+ block_number =
B_N_CHILD_NUM(bh, last_element->pe_position);
/* if we are going to read leaf nodes, try for read ahead as well */
if ((search_path->reada & PATH_READA) &&
- n_node_level == DISK_LEAF_NODE_LEVEL + 1) {
+ node_level == DISK_LEAF_NODE_LEVEL + 1) {
int pos = last_element->pe_position;
int limit = B_NR_ITEMS(bh);
struct reiserfs_key *le_key;
@@ -782,7 +779,7 @@ int search_for_position_by_key(struct su
)
{
struct item_head *p_le_ih; /* pointer to on-disk structure */
- int n_blk_size;
+ int blk_size;
loff_t item_offset, offset;
struct reiserfs_dir_entry de;
int retval;
@@ -817,7 +814,7 @@ int search_for_position_by_key(struct su
p_le_ih =
B_N_PITEM_HEAD(PATH_PLAST_BUFFER(search_path),
--PATH_LAST_POSITION(search_path));
- n_blk_size = sb->s_blocksize;
+ blk_size = sb->s_blocksize;
if (comp_short_keys(&(p_le_ih->ih_key), p_cpu_key)) {
return FILE_NOT_FOUND;
@@ -829,10 +826,10 @@ int search_for_position_by_key(struct su
/* Needed byte is contained in the item pointed to by the path. */
if (item_offset <= offset &&
- item_offset + op_bytes_number(p_le_ih, n_blk_size) > offset) {
+ item_offset + op_bytes_number(p_le_ih, blk_size) > offset) {
pos_in_item(search_path) = offset - item_offset;
if (is_indirect_le_ih(p_le_ih)) {
- pos_in_item(search_path) /= n_blk_size;
+ pos_in_item(search_path) /= blk_size;
}
return POSITION_FOUND;
}
@@ -892,7 +889,7 @@ static inline int prepare_for_direct_ite
if (get_inode_item_key_version(inode) == KEY_FORMAT_3_6) {
//
round_len = ROUND_UP(new_file_length);
- /* this was n_new_file_length < le_ih ... */
+ /* this was new_file_length < le_ih ... */
if (round_len < le_ih_k_offset(le_ih)) {
*cut_size = -(IH_SIZE + ih_item_len(le_ih));
return M_DELETE; /* Delete this item. */
@@ -954,7 +951,7 @@ static inline int prepare_for_direntry_i
This function returns a determination of what balance mode the calling function should employ. */
static char prepare_for_delete_or_cut(struct reiserfs_transaction_handle *th, struct inode *inode, struct treepath *path, const struct cpu_key *item_key, int *removed, /* Number of unformatted nodes which were removed
from end of the file. */
- int *cut_size, unsigned long long n_new_file_length /* MAX_KEY_OFFSET in case of delete. */
+ int *cut_size, unsigned long long new_file_length /* MAX_KEY_OFFSET in case of delete. */
)
{
struct super_block *sb = inode->i_sb;
@@ -966,7 +963,7 @@ static char prepare_for_delete_or_cut(st
/* Stat_data item. */
if (is_statdata_le_ih(p_le_ih)) {
- RFALSE(n_new_file_length != max_reiserfs_offset(inode),
+ RFALSE(new_file_length != max_reiserfs_offset(inode),
"PAP-5210: mode must be M_DELETE");
*cut_size = -(IH_SIZE + ih_item_len(p_le_ih));
@@ -976,13 +973,13 @@ static char prepare_for_delete_or_cut(st
/* Directory item. */
if (is_direntry_le_ih(p_le_ih))
return prepare_for_direntry_item(path, p_le_ih, inode,
- n_new_file_length,
+ new_file_length,
cut_size);
/* Direct item. */
if (is_direct_le_ih(p_le_ih))
return prepare_for_direct_item(path, p_le_ih, inode,
- n_new_file_length, cut_size);
+ new_file_length, cut_size);
/* Case of an indirect item. */
{
@@ -993,10 +990,10 @@ static char prepare_for_delete_or_cut(st
int result = M_CUT;
int pos = 0;
- if ( n_new_file_length == max_reiserfs_offset (inode) ) {
+ if ( new_file_length == max_reiserfs_offset (inode) ) {
/* prepare_for_delete_or_cut() is called by
* reiserfs_delete_item() */
- n_new_file_length = 0;
+ new_file_length = 0;
delete = 1;
}
@@ -1007,7 +1004,7 @@ static char prepare_for_delete_or_cut(st
copy_item_head(&s_ih, PATH_PITEM_HEAD(path));
pos = I_UNFM_NUM(&s_ih);
- while (le_ih_k_offset (&s_ih) + (pos - 1) * blk_size > n_new_file_length) {
+ while (le_ih_k_offset (&s_ih) + (pos - 1) * blk_size > new_file_length) {
__u32 *unfm, block;
/* Each unformatted block deletion may involve one additional
@@ -1063,34 +1060,34 @@ static char prepare_for_delete_or_cut(st
}
/* Calculate number of bytes which will be deleted or cut during balance */
-static int calc_deleted_bytes_number(struct tree_balance *tb, char c_mode)
+static int calc_deleted_bytes_number(struct tree_balance *tb, char mode)
{
- int n_del_size;
+ int del_size;
struct item_head *p_le_ih = PATH_PITEM_HEAD(tb->tb_path);
if (is_statdata_le_ih(p_le_ih))
return 0;
- n_del_size =
- (c_mode ==
+ del_size =
+ (mode ==
M_DELETE) ? ih_item_len(p_le_ih) : -tb->insert_size[0];
if (is_direntry_le_ih(p_le_ih)) {
// return EMPTY_DIR_SIZE; /* We delete emty directoris only. */
// we can't use EMPTY_DIR_SIZE, as old format dirs have a different
// empty size. ick. FIXME, is this right?
//
- return n_del_size;
+ return del_size;
}
if (is_indirect_le_ih(p_le_ih))
- n_del_size = (n_del_size / UNFM_P_SIZE) * (PATH_PLAST_BUFFER(tb->tb_path)->b_size); // - get_ih_free_space (p_le_ih);
- return n_del_size;
+ del_size = (del_size / UNFM_P_SIZE) * (PATH_PLAST_BUFFER(tb->tb_path)->b_size); // - get_ih_free_space (p_le_ih);
+ return del_size;
}
static void init_tb_struct(struct reiserfs_transaction_handle *th,
struct tree_balance *tb,
struct super_block *sb,
- struct treepath *path, int n_size)
+ struct treepath *path, int size)
{
BUG_ON(!th->t_trans_id);
@@ -1101,7 +1098,7 @@ static void init_tb_struct(struct reiser
tb->tb_path = path;
PATH_OFFSET_PBUFFER(path, ILLEGAL_PATH_ELEMENT_OFFSET) = NULL;
PATH_OFFSET_POSITION(path, ILLEGAL_PATH_ELEMENT_OFFSET) = 0;
- tb->insert_size[0] = n_size;
+ tb->insert_size[0] = size;
}
void padd_item(char *item, int total_length, int length)
@@ -1151,11 +1148,11 @@ int reiserfs_delete_item(struct reiserfs
struct item_head s_ih;
struct item_head *q_ih;
int quota_cut_bytes;
- int n_ret_value, n_del_size, n_removed;
+ int ret_value, del_size, removed;
#ifdef CONFIG_REISERFS_CHECK
- char c_mode;
- int n_iter = 0;
+ char mode;
+ int iter = 0;
#endif
BUG_ON(!th->t_trans_id);
@@ -1164,34 +1161,34 @@ int reiserfs_delete_item(struct reiserfs
0 /*size is unknown */ );
while (1) {
- n_removed = 0;
+ removed = 0;
#ifdef CONFIG_REISERFS_CHECK
- n_iter++;
- c_mode =
+ iter++;
+ mode =
#endif
prepare_for_delete_or_cut(th, inode, path,
- item_key, &n_removed,
- &n_del_size,
+ item_key, &removed,
+ &del_size,
max_reiserfs_offset(inode));
- RFALSE(c_mode != M_DELETE, "PAP-5320: mode must be M_DELETE");
+ RFALSE(mode != M_DELETE, "PAP-5320: mode must be M_DELETE");
copy_item_head(&s_ih, PATH_PITEM_HEAD(path));
- s_del_balance.insert_size[0] = n_del_size;
+ s_del_balance.insert_size[0] = del_size;
- n_ret_value = fix_nodes(M_DELETE, &s_del_balance, NULL, NULL);
- if (n_ret_value != REPEAT_SEARCH)
+ ret_value = fix_nodes(M_DELETE, &s_del_balance, NULL, NULL);
+ if (ret_value != REPEAT_SEARCH)
break;
PROC_INFO_INC(sb, delete_item_restarted);
// file system changed, repeat search
- n_ret_value =
+ ret_value =
search_for_position_by_key(sb, item_key, path);
- if (n_ret_value == IO_ERROR)
+ if (ret_value == IO_ERROR)
break;
- if (n_ret_value == FILE_NOT_FOUND) {
+ if (ret_value == FILE_NOT_FOUND) {
reiserfs_warning(sb, "vs-5340",
"no items of the file %K found",
item_key);
@@ -1199,12 +1196,12 @@ int reiserfs_delete_item(struct reiserfs
}
} /* while (1) */
- if (n_ret_value != CARRY_ON) {
+ if (ret_value != CARRY_ON) {
unfix_nodes(&s_del_balance);
return 0;
}
// reiserfs_delete_item returns item length when success
- n_ret_value = calc_deleted_bytes_number(&s_del_balance, M_DELETE);
+ ret_value = calc_deleted_bytes_number(&s_del_balance, M_DELETE);
q_ih = get_ih(path);
quota_cut_bytes = ih_item_len(q_ih);
@@ -1250,7 +1247,7 @@ int reiserfs_delete_item(struct reiserfs
off = ((le_ih_k_offset(&s_ih) - 1) & (PAGE_CACHE_SIZE - 1));
memcpy(data + off,
B_I_PITEM(PATH_PLAST_BUFFER(path), &s_ih),
- n_ret_value);
+ ret_value);
kunmap_atomic(data, KM_USER0);
}
/* Perform balancing after all resources have been collected at once. */
@@ -1264,7 +1261,7 @@ int reiserfs_delete_item(struct reiserfs
DQUOT_FREE_SPACE_NODIRTY(inode, quota_cut_bytes);
/* Return deleted body length */
- return n_ret_value;
+ return ret_value;
}
/* Summary Of Mechanisms For Handling Collisions Between Processes:
@@ -1431,13 +1428,13 @@ static int maybe_indirect_to_direct(stru
struct page *page,
struct treepath *path,
const struct cpu_key *item_key,
- loff_t n_new_file_size, char *mode)
+ loff_t new_file_size, char *mode)
{
struct super_block *sb = inode->i_sb;
- int n_block_size = sb->s_blocksize;
+ int block_size = sb->s_blocksize;
int cut_bytes;
BUG_ON(!th->t_trans_id);
- BUG_ON(n_new_file_size != inode->i_size);
+ BUG_ON(new_file_size != inode->i_size);
/* the page being sent in could be NULL if there was an i/o error
** reading in the last block. The user will hit problems trying to
@@ -1449,14 +1446,14 @@ static int maybe_indirect_to_direct(stru
// leave tail in an unformatted node
*mode = M_SKIP_BALANCING;
cut_bytes =
- n_block_size - (n_new_file_size & (n_block_size - 1));
+ block_size - (new_file_size & (block_size - 1));
pathrelse(path);
return cut_bytes;
}
/* Permorm the conversion to a direct_item. */
- /*return indirect_to_direct (inode, path, item_key, n_new_file_size, mode); */
+ /*return indirect_to_direct (inode, path, item_key, new_file_size, mode); */
return indirect2direct(th, inode, page, path, item_key,
- n_new_file_size, mode);
+ new_file_size, mode);
}
/* we did indirect_to_direct conversion. And we have inserted direct
@@ -1510,7 +1507,7 @@ int reiserfs_cut_from_item(struct reiser
struct treepath *path,
struct cpu_key *item_key,
struct inode *inode,
- struct page *page, loff_t n_new_file_size)
+ struct page *page, loff_t new_file_size)
{
struct super_block *sb = inode->i_sb;
/* Every function which is going to call do_balance must first
@@ -1519,10 +1516,10 @@ int reiserfs_cut_from_item(struct reiser
After that we can make tree balancing. */
struct tree_balance s_cut_balance;
struct item_head *p_le_ih;
- int n_cut_size = 0, /* Amount to be cut. */
- n_ret_value = CARRY_ON, n_removed = 0, /* Number of the removed unformatted nodes. */
- n_is_inode_locked = 0;
- char c_mode; /* Mode of the balance. */
+ int cut_size = 0, /* Amount to be cut. */
+ ret_value = CARRY_ON, removed = 0, /* Number of the removed unformatted nodes. */
+ is_inode_locked = 0;
+ char mode; /* Mode of the balance. */
int retval2 = -1;
int quota_cut_bytes;
loff_t tail_pos = 0;
@@ -1530,7 +1527,7 @@ int reiserfs_cut_from_item(struct reiser
BUG_ON(!th->t_trans_id);
init_tb_struct(th, &s_cut_balance, inode->i_sb, path,
- n_cut_size);
+ cut_size);
/* Repeat this loop until we either cut the item without needing
to balance, or we fix_nodes without schedule occurring */
@@ -1540,30 +1537,30 @@ int reiserfs_cut_from_item(struct reiser
free unformatted nodes which are pointed to by the cut
pointers. */
- c_mode =
+ mode =
prepare_for_delete_or_cut(th, inode, path,
- item_key, &n_removed,
- &n_cut_size, n_new_file_size);
- if (c_mode == M_CONVERT) {
+ item_key, &removed,
+ &cut_size, new_file_size);
+ if (mode == M_CONVERT) {
/* convert last unformatted node to direct item or leave
tail in the unformatted node */
- RFALSE(n_ret_value != CARRY_ON,
+ RFALSE(ret_value != CARRY_ON,
"PAP-5570: can not convert twice");
- n_ret_value =
+ ret_value =
maybe_indirect_to_direct(th, inode, page,
path, item_key,
- n_new_file_size, &c_mode);
- if (c_mode == M_SKIP_BALANCING)
+ new_file_size, &mode);
+ if (mode == M_SKIP_BALANCING)
/* tail has been left in the unformatted node */
- return n_ret_value;
+ return ret_value;
- n_is_inode_locked = 1;
+ is_inode_locked = 1;
/* removing of last unformatted node will change value we
have to return to truncate. Save it */
- retval2 = n_ret_value;
- /*retval2 = sb->s_blocksize - (n_new_file_size & (sb->s_blocksize - 1)); */
+ retval2 = ret_value;
+ /*retval2 = sb->s_blocksize - (new_file_size & (sb->s_blocksize - 1)); */
/* So, we have performed the first part of the conversion:
inserting the new direct item. Now we are removing the
@@ -1571,10 +1568,10 @@ int reiserfs_cut_from_item(struct reiser
it. */
set_cpu_key_k_type(item_key, TYPE_INDIRECT);
item_key->key_length = 4;
- n_new_file_size -=
- (n_new_file_size & (sb->s_blocksize - 1));
- tail_pos = n_new_file_size;
- set_cpu_key_k_offset(item_key, n_new_file_size + 1);
+ new_file_size -=
+ (new_file_size & (sb->s_blocksize - 1));
+ tail_pos = new_file_size;
+ set_cpu_key_k_offset(item_key, new_file_size + 1);
if (search_for_position_by_key
(sb, item_key,
path) == POSITION_NOT_FOUND) {
@@ -1587,38 +1584,38 @@ int reiserfs_cut_from_item(struct reiser
}
continue;
}
- if (n_cut_size == 0) {
+ if (cut_size == 0) {
pathrelse(path);
return 0;
}
- s_cut_balance.insert_size[0] = n_cut_size;
+ s_cut_balance.insert_size[0] = cut_size;
- n_ret_value = fix_nodes(c_mode, &s_cut_balance, NULL, NULL);
- if (n_ret_value != REPEAT_SEARCH)
+ ret_value = fix_nodes(mode, &s_cut_balance, NULL, NULL);
+ if (ret_value != REPEAT_SEARCH)
break;
PROC_INFO_INC(sb, cut_from_item_restarted);
- n_ret_value =
+ ret_value =
search_for_position_by_key(sb, item_key, path);
- if (n_ret_value == POSITION_FOUND)
+ if (ret_value == POSITION_FOUND)
continue;
reiserfs_warning(sb, "PAP-5610", "item %K not found",
item_key);
unfix_nodes(&s_cut_balance);
- return (n_ret_value == IO_ERROR) ? -EIO : -ENOENT;
+ return (ret_value == IO_ERROR) ? -EIO : -ENOENT;
} /* while */
// check fix_nodes results (IO_ERROR or NO_DISK_SPACE)
- if (n_ret_value != CARRY_ON) {
- if (n_is_inode_locked) {
+ if (ret_value != CARRY_ON) {
+ if (is_inode_locked) {
// FIXME: this seems to be not needed: we are always able
// to cut item
indirect_to_direct_roll_back(th, inode, path);
}
- if (n_ret_value == NO_DISK_SPACE)
+ if (ret_value == NO_DISK_SPACE)
reiserfs_warning(sb, "reiserfs-5092",
"NO_DISK_SPACE");
unfix_nodes(&s_cut_balance);
@@ -1627,24 +1624,24 @@ int reiserfs_cut_from_item(struct reiser
/* go ahead and perform balancing */
- RFALSE(c_mode == M_PASTE || c_mode == M_INSERT, "invalid mode");
+ RFALSE(mode == M_PASTE || mode == M_INSERT, "invalid mode");
/* Calculate number of bytes that need to be cut from the item. */
quota_cut_bytes =
- (c_mode ==
+ (mode ==
M_DELETE) ? ih_item_len(get_ih(path)) : -s_cut_balance.
insert_size[0];
if (retval2 == -1)
- n_ret_value = calc_deleted_bytes_number(&s_cut_balance, c_mode);
+ ret_value = calc_deleted_bytes_number(&s_cut_balance, mode);
else
- n_ret_value = retval2;
+ ret_value = retval2;
/* For direct items, we only change the quota when deleting the last
** item.
*/
p_le_ih = PATH_PITEM_HEAD(s_cut_balance.tb_path);
if (!S_ISLNK(inode->i_mode) && is_direct_le_ih(p_le_ih)) {
- if (c_mode == M_DELETE &&
+ if (mode == M_DELETE &&
(le_ih_k_offset(p_le_ih) & (sb->s_blocksize - 1)) ==
1) {
// FIXME: this is to keep 3.5 happy
@@ -1655,7 +1652,7 @@ int reiserfs_cut_from_item(struct reiser
}
}
#ifdef CONFIG_REISERFS_CHECK
- if (n_is_inode_locked) {
+ if (is_inode_locked) {
struct item_head *le_ih =
PATH_PITEM_HEAD(s_cut_balance.tb_path);
/* we are going to complete indirect2direct conversion. Make
@@ -1665,13 +1662,13 @@ int reiserfs_cut_from_item(struct reiser
reiserfs_panic(sb, "vs-5652",
"item must be indirect %h", le_ih);
- if (c_mode == M_DELETE && ih_item_len(le_ih) != UNFM_P_SIZE)
+ if (mode == M_DELETE && ih_item_len(le_ih) != UNFM_P_SIZE)
reiserfs_panic(sb, "vs-5653", "completing "
"indirect2direct conversion indirect "
"item %h being deleted must be of "
"4 byte long", le_ih);
- if (c_mode == M_CUT
+ if (mode == M_CUT
&& s_cut_balance.insert_size[0] != -UNFM_P_SIZE) {
reiserfs_panic(sb, "vs-5654", "can not complete "
"indirect2direct conversion of %h "
@@ -1683,8 +1680,8 @@ int reiserfs_cut_from_item(struct reiser
}
#endif
- do_balance(&s_cut_balance, NULL, NULL, c_mode);
- if (n_is_inode_locked) {
+ do_balance(&s_cut_balance, NULL, NULL, mode);
+ if (is_inode_locked) {
/* we've done an indirect->direct conversion. when the data block
** was freed, it was removed from the list of blocks that must
** be flushed before the transaction commits, make sure to
@@ -1699,7 +1696,7 @@ int reiserfs_cut_from_item(struct reiser
quota_cut_bytes, inode->i_uid, '?');
#endif
DQUOT_FREE_SPACE_NODIRTY(inode, quota_cut_bytes);
- return n_ret_value;
+ return ret_value;
}
static void truncate_directory(struct reiserfs_transaction_handle *th,
@@ -1731,9 +1728,9 @@ int reiserfs_do_truncate(struct reiserfs
INITIALIZE_PATH(s_search_path); /* Path to the current object item. */
struct item_head *p_le_ih; /* Pointer to an item header. */
struct cpu_key s_item_key; /* Key to search for a previous file item. */
- loff_t n_file_size, /* Old file size. */
- n_new_file_size; /* New file size. */
- int n_deleted; /* Number of deleted or truncated bytes. */
+ loff_t file_size, /* Old file size. */
+ new_file_size; /* New file size. */
+ int deleted; /* Number of deleted or truncated bytes. */
int retval;
int err = 0;
@@ -1750,7 +1747,7 @@ int reiserfs_do_truncate(struct reiserfs
}
/* Get new file size. */
- n_new_file_size = inode->i_size;
+ new_file_size = inode->i_size;
// FIXME: note, that key type is unimportant here
make_cpu_key(&s_item_key, inode, max_reiserfs_offset(inode),
@@ -1780,7 +1777,7 @@ int reiserfs_do_truncate(struct reiserfs
/* Get real file size (total length of all file items) */
p_le_ih = PATH_PITEM_HEAD(&s_search_path);
if (is_statdata_le_ih(p_le_ih))
- n_file_size = 0;
+ file_size = 0;
else {
loff_t offset = le_ih_k_offset(p_le_ih);
int bytes =
@@ -1789,42 +1786,42 @@ int reiserfs_do_truncate(struct reiserfs
/* this may mismatch with real file size: if last direct item
had no padding zeros and last unformatted node had no free
space, this file would have this file size */
- n_file_size = offset + bytes - 1;
+ file_size = offset + bytes - 1;
}
/*
* are we doing a full truncate or delete, if so
* kick in the reada code
*/
- if (n_new_file_size == 0)
+ if (new_file_size == 0)
s_search_path.reada = PATH_READA | PATH_READA_BACK;
- if (n_file_size == 0 || n_file_size < n_new_file_size) {
+ if (file_size == 0 || file_size < new_file_size) {
goto update_and_out;
}
/* Update key to search for the last file item. */
- set_cpu_key_k_offset(&s_item_key, n_file_size);
+ set_cpu_key_k_offset(&s_item_key, file_size);
do {
/* Cut or delete file item. */
- n_deleted =
+ deleted =
reiserfs_cut_from_item(th, &s_search_path, &s_item_key,
- inode, page, n_new_file_size);
- if (n_deleted < 0) {
+ inode, page, new_file_size);
+ if (deleted < 0) {
reiserfs_warning(inode->i_sb, "vs-5665",
"reiserfs_cut_from_item failed");
reiserfs_check_path(&s_search_path);
return 0;
}
- RFALSE(n_deleted > n_file_size,
+ RFALSE(deleted > file_size,
"PAP-5670: reiserfs_cut_from_item: too many bytes deleted: deleted %d, file_size %lu, item_key %K",
- n_deleted, n_file_size, &s_item_key);
+ deleted, file_size, &s_item_key);
/* Change key to search the last file item. */
- n_file_size -= n_deleted;
+ file_size -= deleted;
- set_cpu_key_k_offset(&s_item_key, n_file_size);
+ set_cpu_key_k_offset(&s_item_key, file_size);
/* While there are bytes to truncate and previous file item is presented in the tree. */
@@ -1855,13 +1852,13 @@ int reiserfs_do_truncate(struct reiserfs
goto out;
reiserfs_update_inode_transaction(inode);
}
- } while (n_file_size > ROUND_UP(n_new_file_size) &&
+ } while (file_size > ROUND_UP(new_file_size) &&
search_for_position_by_key(inode->i_sb, &s_item_key,
&s_search_path) == POSITION_FOUND);
- RFALSE(n_file_size > ROUND_UP(n_new_file_size),
+ RFALSE(file_size > ROUND_UP(new_file_size),
"PAP-5680: truncate did not finish: new_file_size %Ld, current %Ld, oid %d",
- n_new_file_size, n_file_size, s_item_key.on_disk_key.k_objectid);
+ new_file_size, file_size, s_item_key.on_disk_key.k_objectid);
update_and_out:
if (update_timestamps) {
@@ -1915,7 +1912,7 @@ int reiserfs_paste_into_item(struct reis
const struct cpu_key *key, /* Key to search for the needed item. */
struct inode *inode, /* Inode item belongs to */
const char *body, /* Pointer to the bytes to paste. */
- int n_pasted_size)
+ int pasted_size)
{ /* Size of pasted bytes. */
struct tree_balance s_paste_balance;
int retval;
@@ -1928,16 +1925,16 @@ int reiserfs_paste_into_item(struct reis
#ifdef REISERQUOTA_DEBUG
reiserfs_debug(inode->i_sb, REISERFS_DEBUG_CODE,
"reiserquota paste_into_item(): allocating %u id=%u type=%c",
- n_pasted_size, inode->i_uid,
+ pasted_size, inode->i_uid,
key2type(&(key->on_disk_key)));
#endif
- if (DQUOT_ALLOC_SPACE_NODIRTY(inode, n_pasted_size)) {
+ if (DQUOT_ALLOC_SPACE_NODIRTY(inode, pasted_size)) {
pathrelse(search_path);
return -EDQUOT;
}
init_tb_struct(th, &s_paste_balance, th->t_super, search_path,
- n_pasted_size);
+ pasted_size);
#ifdef DISPLACE_NEW_PACKING_LOCALITIES
s_paste_balance.key = key->on_disk_key;
#endif
@@ -1985,10 +1982,10 @@ int reiserfs_paste_into_item(struct reis
#ifdef REISERQUOTA_DEBUG
reiserfs_debug(inode->i_sb, REISERFS_DEBUG_CODE,
"reiserquota paste_into_item(): freeing %u id=%u type=%c",
- n_pasted_size, inode->i_uid,
+ pasted_size, inode->i_uid,
key2type(&(key->on_disk_key)));
#endif
- DQUOT_FREE_SPACE_NODIRTY(inode, n_pasted_size);
+ DQUOT_FREE_SPACE_NODIRTY(inode, pasted_size);
return retval;
}
--- a/fs/reiserfs/tail_conversion.c 2007-06-11 14:49:40.000000000 -0400
+++ b/fs/reiserfs/tail_conversion.c 2007-06-11 14:49:41.000000000 -0400
@@ -26,7 +26,7 @@ int direct2indirect(struct reiserfs_tran
converted item. */
struct item_head ind_ih; /* new indirect item to be inserted or
key of unfm pointer to be pasted */
- int n_blk_size, n_retval; /* returned value for reiserfs_insert_item and clones */
+ int blk_size, retval; /* returned value for reiserfs_insert_item and clones */
unp_t unfm_ptr; /* Handle on an unformatted node
that will be inserted in the
tree. */
@@ -35,7 +35,7 @@ int direct2indirect(struct reiserfs_tran
REISERFS_SB(sb)->s_direct2indirect++;
- n_blk_size = sb->s_blocksize;
+ blk_size = sb->s_blocksize;
/* and key to search for append or insert pointer to the new
unformatted node. */
@@ -64,17 +64,17 @@ int direct2indirect(struct reiserfs_tran
set_ih_free_space(&ind_ih, 0); /* delete at nearest future */
put_ih_item_len(&ind_ih, UNFM_P_SIZE);
PATH_LAST_POSITION(path)++;
- n_retval =
+ retval =
reiserfs_insert_item(th, path, &end_key, &ind_ih, inode,
(char *)&unfm_ptr);
} else {
/* Paste into last indirect item of an object. */
- n_retval = reiserfs_paste_into_item(th, path, &end_key, inode,
+ retval = reiserfs_paste_into_item(th, path, &end_key, inode,
(char *)&unfm_ptr,
UNFM_P_SIZE);
}
- if (n_retval) {
- return n_retval;
+ if (retval) {
+ return retval;
}
// note: from here there are two keys which have matching first
// three key components. They only differ by the fourth one.
@@ -98,7 +98,7 @@ int direct2indirect(struct reiserfs_tran
RFALSE(!is_direct_le_ih(p_le_ih),
"vs-14055: direct item expected(%K), found %h",
&end_key, p_le_ih);
- tail_size = (le_ih_k_offset(p_le_ih) & (n_blk_size - 1))
+ tail_size = (le_ih_k_offset(p_le_ih) & (blk_size - 1))
+ ih_item_len(p_le_ih) - 1;
/* we only send the unbh pointer if the buffer is not up to date.
@@ -113,11 +113,11 @@ int direct2indirect(struct reiserfs_tran
} else {
up_to_date_bh = unbh;
}
- n_retval = reiserfs_delete_item(th, path, &end_key, inode,
+ retval = reiserfs_delete_item(th, path, &end_key, inode,
up_to_date_bh);
- total_tail += n_retval;
- if (tail_size == n_retval)
+ total_tail += retval;
+ if (tail_size == retval)
// done: file does not have direct items anymore
break;
@@ -129,7 +129,7 @@ int direct2indirect(struct reiserfs_tran
unsigned pgoff =
(tail_offset + total_tail - 1) & (PAGE_CACHE_SIZE - 1);
char *kaddr = kmap_atomic(up_to_date_bh->b_page, KM_USER0);
- memset(kaddr + pgoff, 0, n_blk_size - total_tail);
+ memset(kaddr + pgoff, 0, blk_size - total_tail);
kunmap_atomic(kaddr, KM_USER0);
}
@@ -177,7 +177,7 @@ int indirect2direct(struct reiserfs_tran
{
struct super_block *sb = inode->i_sb;
struct item_head s_ih;
- unsigned long n_block_size = sb->s_blocksize;
+ unsigned long block_size = sb->s_blocksize;
char *tail;
int tail_len, round_tail_len;
loff_t pos, pos1; /* position of first byte of the tail */
@@ -192,7 +192,7 @@ int indirect2direct(struct reiserfs_tran
/* store item head path points to. */
copy_item_head(&s_ih, PATH_PITEM_HEAD(path));
- tail_len = (n_new_file_size & (n_block_size - 1));
+ tail_len = (n_new_file_size & (block_size - 1));
if (get_inode_sd_version(inode) == STAT_DATA_V2)
round_tail_len = ROUND_UP(tail_len);
else
@@ -253,7 +253,7 @@ int indirect2direct(struct reiserfs_tran
unformatted node. For now i_size is considered as guard for
going out of file size */
kunmap(page);
- return n_block_size - round_tail_len;
+ return block_size - round_tail_len;
}
kunmap(page);
@@ -272,5 +272,5 @@ int indirect2direct(struct reiserfs_tran
//mark_file_with_tail (inode, pos1 + 1);
REISERFS_I(inode)->i_first_direct_byte = pos1 + 1;
- return n_block_size - round_tail_len;
+ return block_size - round_tail_len;
}
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 43+ messages in thread
* [patch 31/40] reiserfs: factor out buffer_info initialization
2007-06-11 19:03 [patch 00/40] reiserfs: patch queue (v2) jeffm
` (28 preceding siblings ...)
2007-06-11 19:03 ` [patch 30/40] reiserfs: rename _* variables jeffm
@ 2007-06-11 19:03 ` jeffm
2007-06-11 19:03 ` [patch 32/40] reiserfs: Turn tb->snum and tb->sbytes into an array jeffm
` (10 subsequent siblings)
40 siblings, 0 replies; 43+ messages in thread
From: jeffm @ 2007-06-11 19:03 UTC (permalink / raw)
To: ReiserFS Mailing List
[-- Attachment #1: reiserfs-simplify-buffer-info.diff --]
[-- Type: text/plain, Size: 11405 bytes --]
This is the first in a series of patches to make balance_leaf() not quite
so insane.
This patch factors out the open coded initializations of buffer_info
structures and defines a few initializers for the 4 cases they're used.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
fs/reiserfs/do_balan.c | 175 ++++++++++++++++---------------------------------
1 file changed, 60 insertions(+), 115 deletions(-)
--- a/fs/reiserfs/do_balan.c 2007-06-11 14:49:39.000000000 -0400
+++ b/fs/reiserfs/do_balan.c 2007-06-11 14:50:01.000000000 -0400
@@ -29,6 +29,43 @@ struct tree_balance *cur_tb = NULL; /* d
is interrupting do_balance */
#endif
+static inline void buffer_info_init_left(struct tree_balance *tb,
+ struct buffer_info *bi)
+{
+ bi->tb = tb;
+ bi->bi_bh = tb->L[0];
+ bi->bi_parent = tb->FL[0];
+ bi->bi_position = get_left_neighbor_position(tb, 0);
+}
+
+static inline void buffer_info_init_right(struct tree_balance *tb,
+ struct buffer_info *bi)
+{
+ bi->tb = tb;
+ bi->bi_bh = tb->R[0];
+ bi->bi_parent = tb->FR[0];
+ bi->bi_position = get_right_neighbor_position(tb, 0);
+}
+
+static inline void buffer_info_init_tbS0(struct tree_balance *tb,
+ struct buffer_info *bi)
+{
+ bi->tb = tb;
+ bi->bi_bh = PATH_PLAST_BUFFER(tb->tb_path);
+ bi->bi_parent = PATH_H_PPARENT(tb->tb_path, 0);
+ bi->bi_position = PATH_H_POSITION(tb->tb_path, 1);
+}
+
+static inline void buffer_info_init_bh(struct tree_balance *tb,
+ struct buffer_info *bi,
+ struct buffer_head *bh)
+{
+ bi->tb = tb;
+ bi->bi_bh = bh;
+ bi->bi_parent = NULL;
+ bi->bi_position = 0;
+}
+
inline void do_balance_mark_leaf_dirty(struct tree_balance *tb,
struct buffer_head *bh, int flag)
{
@@ -86,6 +123,7 @@ static int balance_leaf_when_delete(stru
"PAP-12010: tree can not be empty");
ih = B_N_PITEM_HEAD(tbS0, item_pos);
+ buffer_info_init_tbS0(tb, &bi);
/* Delete or truncate the item */
@@ -96,10 +134,6 @@ static int balance_leaf_when_delete(stru
"vs-12013: mode Delete, insert size %d, ih to be deleted %h",
-tb->insert_size[0], ih);
- bi.tb = tb;
- bi.bi_bh = tbS0;
- bi.bi_parent = PATH_H_PPARENT(tb->tb_path, 0);
- bi.bi_position = PATH_H_POSITION(tb->tb_path, 1);
leaf_delete_items(&bi, 0, item_pos, 1, -1);
if (!item_pos && tb->CFL[0]) {
@@ -121,10 +155,6 @@ static int balance_leaf_when_delete(stru
break;
case M_CUT:{ /* cut item in S[0] */
- bi.tb = tb;
- bi.bi_bh = tbS0;
- bi.bi_parent = PATH_H_PPARENT(tb->tb_path, 0);
- bi.bi_position = PATH_H_POSITION(tb->tb_path, 1);
if (is_direntry_le_ih(ih)) {
/* UFS unlink semantics are such that you can only delete one directory entry at a time. */
@@ -325,11 +355,7 @@ static int balance_leaf(struct tree_bala
ih_item_len(ih));
/* Insert new item into L[0] */
- bi.tb = tb;
- bi.bi_bh = tb->L[0];
- bi.bi_parent = tb->FL[0];
- bi.bi_position =
- get_left_neighbor_position(tb, 0);
+ buffer_info_init_left(tb, &bi);
leaf_insert_into_buf(&bi,
n + item_pos -
ret_val, ih, body,
@@ -369,11 +395,7 @@ static int balance_leaf(struct tree_bala
leaf_shift_left(tb, tb->lnum[0] - 1,
tb->lbytes);
/* Insert new item into L[0] */
- bi.tb = tb;
- bi.bi_bh = tb->L[0];
- bi.bi_parent = tb->FL[0];
- bi.bi_position =
- get_left_neighbor_position(tb, 0);
+ buffer_info_init_left(tb, &bi);
leaf_insert_into_buf(&bi,
n + item_pos -
ret_val, ih, body,
@@ -429,13 +451,7 @@ static int balance_leaf(struct tree_bala
}
/* Append given directory entry to directory item */
- bi.tb = tb;
- bi.bi_bh = tb->L[0];
- bi.bi_parent =
- tb->FL[0];
- bi.bi_position =
- get_left_neighbor_position
- (tb, 0);
+ buffer_info_init_left(tb, &bi);
leaf_paste_in_buffer
(&bi,
n + item_pos -
@@ -524,13 +540,7 @@ static int balance_leaf(struct tree_bala
(tbS0,
item_pos)));
/* Append to body of item in L[0] */
- bi.tb = tb;
- bi.bi_bh = tb->L[0];
- bi.bi_parent =
- tb->FL[0];
- bi.bi_position =
- get_left_neighbor_position
- (tb, 0);
+ buffer_info_init_left(tb, &bi);
leaf_paste_in_buffer
(&bi,
n + item_pos -
@@ -681,11 +691,7 @@ static int balance_leaf(struct tree_bala
leaf_shift_left(tb, tb->lnum[0],
tb->lbytes);
/* Append to body of item in L[0] */
- bi.tb = tb;
- bi.bi_bh = tb->L[0];
- bi.bi_parent = tb->FL[0];
- bi.bi_position =
- get_left_neighbor_position(tb, 0);
+ buffer_info_init_left(tb, &bi);
leaf_paste_in_buffer(&bi,
n + item_pos -
ret_val,
@@ -776,11 +782,7 @@ static int balance_leaf(struct tree_bala
set_le_ih_k_offset(ih, offset);
put_ih_item_len(ih, tb->rbytes);
/* Insert part of the item into R[0] */
- bi.tb = tb;
- bi.bi_bh = tb->R[0];
- bi.bi_parent = tb->FR[0];
- bi.bi_position =
- get_right_neighbor_position(tb, 0);
+ buffer_info_init_right(tb, &bi);
if ((old_len - tb->rbytes) > zeros_num) {
r_zeros_number = 0;
r_body =
@@ -817,11 +819,7 @@ static int balance_leaf(struct tree_bala
tb->rnum[0] - 1,
tb->rbytes);
/* Insert new item into R[0] */
- bi.tb = tb;
- bi.bi_bh = tb->R[0];
- bi.bi_parent = tb->FR[0];
- bi.bi_position =
- get_right_neighbor_position(tb, 0);
+ buffer_info_init_right(tb, &bi);
leaf_insert_into_buf(&bi,
item_pos - n +
tb->rnum[0] - 1,
@@ -881,13 +879,7 @@ static int balance_leaf(struct tree_bala
pos_in_item -
entry_count +
tb->rbytes - 1;
- bi.tb = tb;
- bi.bi_bh = tb->R[0];
- bi.bi_parent =
- tb->FR[0];
- bi.bi_position =
- get_right_neighbor_position
- (tb, 0);
+ buffer_info_init_right(tb, &bi);
leaf_paste_in_buffer
(&bi, 0,
paste_entry_position,
@@ -1019,12 +1011,7 @@ static int balance_leaf(struct tree_bala
(tb, tb->CFR[0], 0);
/* Append part of body into R[0] */
- bi.tb = tb;
- bi.bi_bh = tb->R[0];
- bi.bi_parent = tb->FR[0];
- bi.bi_position =
- get_right_neighbor_position
- (tb, 0);
+ buffer_info_init_right(tb, &bi);
if (n_rem > zeros_num) {
r_zeros_number = 0;
r_body =
@@ -1071,12 +1058,7 @@ static int balance_leaf(struct tree_bala
tb->rbytes);
/* append item in R[0] */
if (pos_in_item >= 0) {
- bi.tb = tb;
- bi.bi_bh = tb->R[0];
- bi.bi_parent = tb->FR[0];
- bi.bi_position =
- get_right_neighbor_position
- (tb, 0);
+ buffer_info_init_right(tb, &bi);
leaf_paste_in_buffer(&bi,
item_pos -
n +
@@ -1232,10 +1214,7 @@ static int balance_leaf(struct tree_bala
put_ih_item_len(ih, sbytes[i]);
/* Insert part of the item into S_new[i] before 0-th item */
- bi.tb = tb;
- bi.bi_bh = S_new[i];
- bi.bi_parent = NULL;
- bi.bi_position = 0;
+ buffer_info_init_bh(tb, &bi, S_new[i]);
if ((old_len - sbytes[i]) > zeros_num) {
r_zeros_number = 0;
@@ -1267,10 +1246,7 @@ static int balance_leaf(struct tree_bala
S_new[i]);
/* Insert new item into S_new[i] */
- bi.tb = tb;
- bi.bi_bh = S_new[i];
- bi.bi_parent = NULL;
- bi.bi_position = 0;
+ buffer_info_init_bh(tb, &bi, S_new[i]);
leaf_insert_into_buf(&bi,
item_pos - n +
snum[i] - 1, ih,
@@ -1327,10 +1303,7 @@ static int balance_leaf(struct tree_bala
sbytes[i] - 1,
S_new[i]);
/* Paste given directory entry to directory item */
- bi.tb = tb;
- bi.bi_bh = S_new[i];
- bi.bi_parent = NULL;
- bi.bi_position = 0;
+ buffer_info_init_bh(tb, &bi, S_new[i]);
leaf_paste_in_buffer
(&bi, 0,
pos_in_item -
@@ -1401,11 +1374,7 @@ static int balance_leaf(struct tree_bala
if (n_rem < 0)
n_rem = 0;
/* Append part of body into S_new[0] */
- bi.tb = tb;
- bi.bi_bh = S_new[i];
- bi.bi_parent = NULL;
- bi.bi_position = 0;
-
+ buffer_info_init_bh(tb, &bi, S_new[i]);
if (n_rem > zeros_num) {
r_zeros_number = 0;
r_body =
@@ -1490,10 +1459,7 @@ static int balance_leaf(struct tree_bala
ret_val);
/* paste into item */
- bi.tb = tb;
- bi.bi_bh = S_new[i];
- bi.bi_parent = NULL;
- bi.bi_position = 0;
+ buffer_info_init_bh(tb, &bi, S_new[i]);
leaf_paste_in_buffer(&bi,
item_pos - n +
snum[i],
@@ -1560,10 +1526,7 @@ static int balance_leaf(struct tree_bala
switch (flag) {
case M_INSERT: /* insert item into S[0] */
- bi.tb = tb;
- bi.bi_bh = tbS0;
- bi.bi_parent = PATH_H_PPARENT(tb->tb_path, 0);
- bi.bi_position = PATH_H_POSITION(tb->tb_path, 1);
+ buffer_info_init_tbS0(tb, &bi);
leaf_insert_into_buf(&bi, item_pos, ih, body,
zeros_num);
@@ -1590,14 +1553,7 @@ static int balance_leaf(struct tree_bala
"PAP-12260: insert_size is 0 already");
/* prepare space */
- bi.tb = tb;
- bi.bi_bh = tbS0;
- bi.bi_parent =
- PATH_H_PPARENT(tb->tb_path,
- 0);
- bi.bi_position =
- PATH_H_POSITION(tb->tb_path,
- 1);
+ buffer_info_init_tbS0(tb, &bi);
leaf_paste_in_buffer(&bi,
item_pos,
pos_in_item,
@@ -1645,14 +1601,7 @@ static int balance_leaf(struct tree_bala
RFALSE(tb->insert_size[0] <= 0,
"PAP-12275: insert size must not be %d",
tb->insert_size[0]);
- bi.tb = tb;
- bi.bi_bh = tbS0;
- bi.bi_parent =
- PATH_H_PPARENT(tb->tb_path,
- 0);
- bi.bi_position =
- PATH_H_POSITION(tb->tb_path,
- 1);
+ buffer_info_init_tbS0(tb, &bi);
leaf_paste_in_buffer(&bi,
item_pos,
pos_in_item,
@@ -1724,7 +1673,6 @@ void make_empty_node(struct buffer_info
struct buffer_head *get_FEB(struct tree_balance *tb)
{
int i;
- struct buffer_head *first_b;
struct buffer_info bi;
for (i = 0; i < MAX_FEB_SIZE; i++)
@@ -1734,16 +1682,13 @@ struct buffer_head *get_FEB(struct tree_
if (i == MAX_FEB_SIZE)
reiserfs_panic(tb->tb_sb, "vs-12300", "FEB list is empty");
- bi.tb = tb;
- bi.bi_bh = first_b = tb->FEB[i];
- bi.bi_parent = NULL;
- bi.bi_position = 0;
+ buffer_info_init_bh(tb, &bi, tb->FEB[i]);
make_empty_node(&bi);
- set_buffer_uptodate(first_b);
+ set_buffer_uptodate(tb->FEB[i]);
+ tb->used[i] = tb->FEB[i];
tb->FEB[i] = NULL;
- tb->used[i] = first_b;
- return (first_b);
+ return tb->used[i];
}
/* This is now used because reiserfs_free_block has to be able to
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 43+ messages in thread
* [patch 32/40] reiserfs: Turn tb->snum and tb->sbytes into an array
2007-06-11 19:03 [patch 00/40] reiserfs: patch queue (v2) jeffm
` (29 preceding siblings ...)
2007-06-11 19:03 ` [patch 31/40] reiserfs: factor out buffer_info initialization jeffm
@ 2007-06-11 19:03 ` jeffm
2007-06-11 19:03 ` [patch 33/40] reiserfs: split left balancing part of balance_leaf() off jeffm
` (9 subsequent siblings)
40 siblings, 0 replies; 43+ messages in thread
From: jeffm @ 2007-06-11 19:03 UTC (permalink / raw)
To: ReiserFS Mailing List
[-- Attachment #1: reiserfs-snum-sbytes-array --]
[-- Type: text/plain, Size: 17514 bytes --]
This patch turns tree_balance.s[12]num into snum[2] and
tree_balance.s[12]bytes into sbytes[2]. It doesn't have any effect now, but
will be used when balance_leaf is split up.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
fs/reiserfs/do_balan.c | 95 ++++++++++++++++++--------------------------
fs/reiserfs/fix_node.c | 28 ++++++------
fs/reiserfs/prints.c | 6 +-
include/linux/reiserfs_fs.h | 6 --
4 files changed, 59 insertions(+), 76 deletions(-)
--- a/fs/reiserfs/do_balan.c 2007-06-11 14:49:41.000000000 -0400
+++ b/fs/reiserfs/do_balan.c 2007-06-11 14:50:01.000000000 -0400
@@ -82,8 +82,8 @@ inline void do_balance_mark_leaf_dirty(s
else
if lnum is larger than 0 we put items into the left node
if rnum is larger than 0 we put items into the right node
- if snum1 is larger than 0 we put items into the new node s1
- if snum2 is larger than 0 we put items into the new node s2
+ if tb->snum[0] is larger than 0 we put items into the new node s1
+ if tb->snum[1] is larger than 0 we put items into the new node s2
Note that all *num* count new items being created.
It would be easier to read balance_leaf() if each of these summary
@@ -292,15 +292,6 @@ static int balance_leaf(struct tree_bala
of the affected item */
struct buffer_info bi;
struct buffer_head *S_new[2]; /* new nodes allocated to hold what could not fit into S */
- int snum[2]; /* number of items that will be placed
- into S_new (includes partially shifted
- items) */
- int sbytes[2]; /* if an item is partially shifted into S_new then
- if it is a directory item
- it is the number of entries from the item that are shifted into S_new
- else
- it is the number of bytes from the item that are shifted into S_new
- */
int n, i;
int ret_val;
int pos_in_item;
@@ -1161,16 +1152,10 @@ static int balance_leaf(struct tree_bala
}
/* Fill new nodes that appear in place of S[0] */
-
- /* I am told that this copying is because we need an array to enable
- the looping code. -Hans */
- snum[0] = tb->s1num, snum[1] = tb->s2num;
- sbytes[0] = tb->s1bytes;
- sbytes[1] = tb->s2bytes;
for (i = tb->blknum[0] - 2; i >= 0; i--) {
- RFALSE(!snum[i], "PAP-12200: snum[%d] == %d. Must be > 0", i,
- snum[i]);
+ RFALSE(!tb->snum[i], "PAP-12200: tb->snum[%d] == %d. Must be > 0", i,
+ tb->snum[i]);
/* here we shift from S to S_new nodes */
@@ -1184,16 +1169,16 @@ static int balance_leaf(struct tree_bala
switch (flag) {
case M_INSERT: /* insert item */
- if (n - snum[i] < item_pos) { /* new item or it's part falls to first new node S_new[i] */
- if (item_pos == n - snum[i] + 1 && sbytes[i] != -1) { /* part of new item falls into S_new[i] */
+ if (n - tb->snum[i] < item_pos) { /* new item or it's part falls to first new node S_new[i] */
+ if (item_pos == n - tb->snum[i] + 1 && tb->sbytes[i] != -1) { /* part of new item falls into S_new[i] */
int old_key_comp, old_len,
r_zeros_number;
const char *r_body;
int version;
- /* Move snum[i]-1 items from S[0] to S_new[i] */
+ /* Move tb->snum[i]-1 items from S[0] to S_new[i] */
leaf_move_items(LEAF_FROM_S_TO_SNEW, tb,
- snum[i] - 1, -1,
+ tb->snum[i] - 1, -1,
S_new[i]);
/* Remember key component and item length */
version = ih_version(ih);
@@ -1204,29 +1189,29 @@ static int balance_leaf(struct tree_bala
set_le_ih_k_offset(ih,
le_ih_k_offset(ih) +
((old_len -
- sbytes[i]) <<
+ tb->sbytes[i]) <<
(is_indirect_le_ih
(ih) ? tb->tb_sb->
s_blocksize_bits -
UNFM_P_SHIFT :
0)));
- put_ih_item_len(ih, sbytes[i]);
+ put_ih_item_len(ih, tb->sbytes[i]);
/* Insert part of the item into S_new[i] before 0-th item */
buffer_info_init_bh(tb, &bi, S_new[i]);
- if ((old_len - sbytes[i]) > zeros_num) {
+ if ((old_len - tb->sbytes[i]) > zeros_num) {
r_zeros_number = 0;
r_body =
body + (old_len -
- sbytes[i]) -
+ tb->sbytes[i]) -
zeros_num;
} else {
r_body = body;
r_zeros_number =
zeros_num - (old_len -
- sbytes[i]);
+ tb->sbytes[i]);
zeros_num -= r_zeros_number;
}
@@ -1236,20 +1221,20 @@ static int balance_leaf(struct tree_bala
/* Calculate key component and item length to insert into S[i] */
set_le_ih_k_offset(ih, old_key_comp);
put_ih_item_len(ih,
- old_len - sbytes[i]);
- tb->insert_size[0] -= sbytes[i];
+ old_len - tb->sbytes[i]);
+ tb->insert_size[0] -= tb->sbytes[i];
} else { /* whole new item falls into S_new[i] */
- /* Shift snum[0] - 1 items to S_new[i] (sbytes[i] of split item) */
+ /* Shift tb->snum[0] - 1 items to S_new[i] (tb->sbytes[i] of split item) */
leaf_move_items(LEAF_FROM_S_TO_SNEW, tb,
- snum[i] - 1, sbytes[i],
+ tb->snum[i] - 1, tb->sbytes[i],
S_new[i]);
/* Insert new item into S_new[i] */
buffer_info_init_bh(tb, &bi, S_new[i]);
leaf_insert_into_buf(&bi,
item_pos - n +
- snum[i] - 1, ih,
+ tb->snum[i] - 1, ih,
body, zeros_num);
zeros_num = tb->insert_size[0] = 0;
@@ -1259,14 +1244,14 @@ static int balance_leaf(struct tree_bala
else { /* new item or it part don't falls into S_new[i] */
leaf_move_items(LEAF_FROM_S_TO_SNEW, tb,
- snum[i], sbytes[i], S_new[i]);
+ tb->snum[i], tb->sbytes[i], S_new[i]);
}
break;
case M_PASTE: /* append item */
- if (n - snum[i] <= item_pos) { /* pasted item or part if it falls to S_new[i] */
- if (item_pos == n - snum[i] && sbytes[i] != -1) { /* we must shift part of the appended item */
+ if (n - tb->snum[i] <= item_pos) { /* pasted item or part if it falls to S_new[i] */
+ if (item_pos == n - tb->snum[i] && tb->sbytes[i] != -1) { /* we must shift part of the appended item */
struct item_head *aux_ih;
RFALSE(ih, "PAP-12210: ih must be 0");
@@ -1281,7 +1266,7 @@ static int balance_leaf(struct tree_bala
entry_count =
ih_entry_count(aux_ih);
- if (entry_count - sbytes[i] <
+ if (entry_count - tb->sbytes[i] <
pos_in_item
&& pos_in_item <=
entry_count) {
@@ -1290,17 +1275,17 @@ static int balance_leaf(struct tree_bala
RFALSE(!tb->
insert_size[0],
"PAP-12215: insert_size is already 0");
- RFALSE(sbytes[i] - 1 >=
+ RFALSE(tb->sbytes[i] - 1 >=
entry_count,
"PAP-12220: there are no so much entries (%d), only %d",
- sbytes[i] - 1,
+ tb->sbytes[i] - 1,
entry_count);
- /* Shift snum[i]-1 items in whole. Shift sbytes[i] directory entries from directory item number snum[i] */
+ /* Shift tb->snum[i]-1 items in whole. Shift tb->sbytes[i] directory entries from directory item number tb->snum[i] */
leaf_move_items
(LEAF_FROM_S_TO_SNEW,
- tb, snum[i],
- sbytes[i] - 1,
+ tb, tb->snum[i],
+ tb->sbytes[i] - 1,
S_new[i]);
/* Paste given directory entry to directory item */
buffer_info_init_bh(tb, &bi, S_new[i]);
@@ -1308,7 +1293,7 @@ static int balance_leaf(struct tree_bala
(&bi, 0,
pos_in_item -
entry_count +
- sbytes[i] - 1,
+ tb->sbytes[i] - 1,
tb->insert_size[0],
body, zeros_num);
/* paste new directory entry */
@@ -1319,7 +1304,7 @@ static int balance_leaf(struct tree_bala
-
entry_count
+
- sbytes
+ tb->sbytes
[i] -
1, 1,
(struct
@@ -1338,8 +1323,8 @@ static int balance_leaf(struct tree_bala
} else { /* new directory entry doesn't fall into S_new[i] */
leaf_move_items
(LEAF_FROM_S_TO_SNEW,
- tb, snum[i],
- sbytes[i],
+ tb, tb->snum[i],
+ tb->sbytes[i],
S_new[i]);
}
} else { /* regular object */
@@ -1358,19 +1343,19 @@ static int balance_leaf(struct tree_bala
/* Calculate number of bytes which must be shifted from appended item */
n_shift =
- sbytes[i] -
+ tb->sbytes[i] -
tb->insert_size[0];
if (n_shift < 0)
n_shift = 0;
leaf_move_items
(LEAF_FROM_S_TO_SNEW, tb,
- snum[i], n_shift,
+ tb->snum[i], n_shift,
S_new[i]);
/* Calculate number of bytes which must remain in body after append to S_new[i] */
n_rem =
tb->insert_size[0] -
- sbytes[i];
+ tb->sbytes[i];
if (n_rem < 0)
n_rem = 0;
/* Append part of body into S_new[0] */
@@ -1450,8 +1435,8 @@ static int balance_leaf(struct tree_bala
ret_val =
leaf_move_items(LEAF_FROM_S_TO_SNEW,
- tb, snum[i],
- sbytes[i],
+ tb, tb->snum[i],
+ tb->sbytes[i],
S_new[i]);
RFALSE(ret_val,
@@ -1462,7 +1447,7 @@ static int balance_leaf(struct tree_bala
buffer_info_init_bh(tb, &bi, S_new[i]);
leaf_paste_in_buffer(&bi,
item_pos - n +
- snum[i],
+ tb->snum[i],
pos_in_item,
tb->insert_size[0],
body, zeros_num);
@@ -1470,11 +1455,11 @@ static int balance_leaf(struct tree_bala
pasted =
B_N_PITEM_HEAD(S_new[i],
item_pos - n +
- snum[i]);
+ tb->snum[i]);
if (is_direntry_le_ih(pasted)) {
leaf_paste_entries(bi.bi_bh,
item_pos -
- n + snum[i],
+ n + tb->snum[i],
pos_in_item,
1,
(struct
@@ -1498,7 +1483,7 @@ static int balance_leaf(struct tree_bala
else { /* pasted item doesn't fall into S_new[i] */
leaf_move_items(LEAF_FROM_S_TO_SNEW, tb,
- snum[i], sbytes[i], S_new[i]);
+ tb->snum[i], tb->sbytes[i], S_new[i]);
}
break;
default: /* cases d and t */
--- a/fs/reiserfs/fix_node.c 2007-06-11 14:49:41.000000000 -0400
+++ b/fs/reiserfs/fix_node.c 2007-06-11 14:49:41.000000000 -0400
@@ -399,8 +399,8 @@ static int get_num_ver(int mode, struct
/* snum012 [0-2] - number of items, that lay
to S[0], first new node and second new node */
- snum012[3] = -1; /* s1bytes */
- snum012[4] = -1; /* s2bytes */
+ snum012[3] = -1; /* sbytes[0] */
+ snum012[4] = -1; /* sbytes[1] */
/* internal level */
if (h > 0) {
@@ -526,7 +526,7 @@ static int get_num_ver(int mode, struct
((split_item_positions[0] ==
split_item_positions[1]) ? snum012[3] : 0);
- // s2bytes
+ // sbytes[2]
snum012[4] =
op_unit_num(&vn->vn_vi[split_item_num]) - snum012[4] -
bytes_to_r - bytes_to_l - bytes_to_S1new;
@@ -554,7 +554,7 @@ static int get_num_ver(int mode, struct
((split_item_positions[0] == split_item_positions[1]
&& snum012[4] != -1) ? snum012[4] : 0);
- // s1bytes
+ // sbytes[0]
snum012[3] =
op_unit_num(&vn->vn_vi[split_item_num]) - snum012[3] -
bytes_to_r - bytes_to_l - bytes_to_S2new;
@@ -581,7 +581,7 @@ extern struct tree_balance *cur_tb;
* not shifted entirely
* rbytes number of bytes which flow to the right neighbor from the item that is not
* not shifted entirely
- * s1bytes number of bytes which flow to the first new node when S[0] splits (this number is contained in s012 array)
+ * sbytes[0] number of bytes which flow to the first new node when S[0] splits (this number is contained in s012 array)
*/
static void set_parameters(struct tree_balance *tb, int h, int lnum,
@@ -595,9 +595,9 @@ static void set_parameters(struct tree_b
if (h == 0) { /* only for leaf level */
if (s012 != NULL) {
tb->s0num = *s012++,
- tb->s1num = *s012++, tb->s2num = *s012++;
- tb->s1bytes = *s012++;
- tb->s2bytes = *s012;
+ tb->snum[0] = *s012++, tb->snum[1] = *s012++;
+ tb->sbytes[0] = *s012++;
+ tb->sbytes[2] = *s012;
}
tb->lbytes = lb;
tb->rbytes = rb;
@@ -1235,9 +1235,9 @@ static int ip_check_balance(struct tree_
nodes that might be created. */
/* we perform 8 calls to get_num_ver(). For each call we calculate five parameters.
- where 4th parameter is s1bytes and 5th - s2bytes
+ where 4th parameter is sbytes[0] and 5th - sbytes[2]
*/
- short snum012[40] = { 0, }; /* s0num, s1num, s2num for 8 cases
+ short snum012[40] = { 0, }; /* s0num, snum[0], snum[1] for 8 cases
0,1 - do not shift and do not shift but bottle
2 - shift only whole item to left
3 - shift to left and bottle as much as possible
@@ -1374,7 +1374,7 @@ static int ip_check_balance(struct tree_
/* calculate number of blocks S[h] must be split into when
nothing is shifted to the neighbors,
as well as number of items in each part of the split node (s012 numbers),
- and number of bytes (s1bytes) of the shared drop which flow to S1 if any */
+ and number of bytes (sbytes[0]) of the shared drop which flow to S1 if any */
nset = NOTHING_SHIFT_NO_FLOW;
nver = get_num_ver(vn->vn_mode, tb, h,
0, -1, h ? vn->vn_nr_item : 0, -1,
@@ -1395,7 +1395,7 @@ static int ip_check_balance(struct tree_
l_shift_num first items and l_shift_bytes of the right most
liquid item to be shifted are shifted to the left neighbor,
as well as number of items in each part of the splitted node (s012 numbers),
- and number of bytes (s1bytes) of the shared drop which flow to S1 if any
+ and number of bytes (sbytes[0]) of the shared drop which flow to S1 if any
*/
lset = LEFT_SHIFT_NO_FLOW;
lnver = get_num_ver(vn->vn_mode, tb, h,
@@ -1418,7 +1418,7 @@ static int ip_check_balance(struct tree_
r_shift_num first items and r_shift_bytes of the left most
liquid item to be shifted are shifted to the right neighbor,
as well as number of items in each part of the splitted node (s012 numbers),
- and number of bytes (s1bytes) of the shared drop which flow to S1 if any
+ and number of bytes (sbytes[0]) of the shared drop which flow to S1 if any
*/
rset = RIGHT_SHIFT_NO_FLOW;
rnver = get_num_ver(vn->vn_mode, tb, h,
@@ -1446,7 +1446,7 @@ static int ip_check_balance(struct tree_
/* calculate number of blocks S[h] must be split into when
items are shifted in both directions,
as well as number of items in each part of the splitted node (s012 numbers),
- and number of bytes (s1bytes) of the shared drop which flow to S1 if any
+ and number of bytes (sbytes[0]) of the shared drop which flow to S1 if any
*/
lrset = LR_SHIFT_NO_FLOW;
lrnver = get_num_ver(vn->vn_mode, tb, h,
--- a/fs/reiserfs/prints.c 2007-06-11 14:49:39.000000000 -0400
+++ b/fs/reiserfs/prints.c 2007-06-11 14:49:59.000000000 -0400
@@ -667,9 +667,9 @@ void store_print_tb(struct tree_balance
"* h * size * ln * lb * rn * rb * blkn * s0 * s1 * s1b * s2 * s2b * curb * lk * rk *\n"
"* 0 * %4d * %2d * %2d * %2d * %2d * %4d * %2d * %2d * %3d * %2d * %3d * %4d * %2d * %2d *\n",
tb->insert_size[0], tb->lnum[0], tb->lbytes, tb->rnum[0],
- tb->rbytes, tb->blknum[0], tb->s0num, tb->s1num, tb->s1bytes,
- tb->s2num, tb->s2bytes, tb->cur_blknum, tb->lkey[0],
- tb->rkey[0]);
+ tb->rbytes, tb->blknum[0], tb->s0num, tb->snum[0],
+ tb->sbytes[0], tb->snum[1], tb->sbytes[1], tb->cur_blknum,
+ tb->lkey[0], tb->rkey[0]);
/* this prints balance parameters for non-leaf levels */
h = 0;
--- a/include/linux/reiserfs_fs.h 2007-06-11 14:49:40.000000000 -0400
+++ b/include/linux/reiserfs_fs.h 2007-06-11 14:49:59.000000000 -0400
@@ -1366,17 +1366,15 @@ struct tree_balance {
/* fields that are used only for balancing leaves of the tree */
int cur_blknum; /* number of empty blocks having been already allocated */
int s0num; /* number of items that fall into left most node when S[0] splits */
- int s1num; /* number of items that fall into first new node when S[0] splits */
- int s2num; /* number of items that fall into second new node when S[0] splits */
+ int snum[2]; /* number of items that fall into first and second new node when S[0] splits */
int lbytes; /* number of bytes which can flow to the left neighbor from the left */
/* most liquid item that cannot be shifted from S[0] entirely */
/* if -1 then nothing will be partially shifted */
int rbytes; /* number of bytes which will flow to the right neighbor from the right */
/* most liquid item that cannot be shifted from S[0] entirely */
/* if -1 then nothing will be partially shifted */
- int s1bytes; /* number of bytes which flow to the first new node when S[0] splits */
+ int sbytes[2]; /* number of bytes which flow to the first and second new node when S[0] splits */
/* note: if S[0] splits into 3 nodes, then items do not need to be cut */
- int s2bytes;
struct buffer_head *buf_to_free[MAX_FREE_BLOCK]; /* buffers which are to be freed after do_balance finishes by unfix_nodes */
char *vn_buf; /* kmalloced memory. Used to create
virtual node and keep map of
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 43+ messages in thread
* [patch 33/40] reiserfs: split left balancing part of balance_leaf() off
2007-06-11 19:03 [patch 00/40] reiserfs: patch queue (v2) jeffm
` (30 preceding siblings ...)
2007-06-11 19:03 ` [patch 32/40] reiserfs: Turn tb->snum and tb->sbytes into an array jeffm
@ 2007-06-11 19:03 ` jeffm
2007-06-11 19:03 ` [patch 34/40] reiserfs: split right " jeffm
` (8 subsequent siblings)
40 siblings, 0 replies; 43+ messages in thread
From: jeffm @ 2007-06-11 19:03 UTC (permalink / raw)
To: ReiserFS Mailing List
[-- Attachment #1: reiserfs-split-balance_leaf-left.diff --]
[-- Type: text/plain, Size: 23611 bytes --]
This is the first in a set of 4 patches that split balance_leaf up into
a group of functions rather than the 2500 beast it once was.
This patch splits off the left-tree balancing behavior.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
fs/reiserfs/do_balan.c | 733 ++++++++++++++++++++-----------------------------
1 file changed, 313 insertions(+), 420 deletions(-)
--- a/fs/reiserfs/do_balan.c 2007-06-11 14:49:41.000000000 -0400
+++ b/fs/reiserfs/do_balan.c 2007-06-11 14:50:01.000000000 -0400
@@ -276,6 +276,317 @@ static int balance_leaf_when_delete(stru
return 0;
}
+/* Insert item into L[0] */
+static void
+bl_left_insert(struct tree_balance *tb, struct item_head *ih,
+ const char *body, int flag, int *zeros_num)
+{
+ int shift = 0;
+ int was_copied;
+ int new_item_len;
+ struct buffer_info bi;
+ int n = B_NR_ITEMS(tb->L[0]);
+ int item_pos = PATH_LAST_POSITION(tb->tb_path);
+
+ /* new item in whole falls into L[0] */
+ if (item_pos != tb->lnum[0] - 1 || tb->lbytes == -1) {
+ /* Shift lnum[0]-1 items to L[0] */
+ was_copied = leaf_shift_left(tb, tb->lnum[0] - 1, tb->lbytes);
+ /* Insert new item into L[0] */
+ buffer_info_init_left(tb, &bi);
+ leaf_insert_into_buf(&bi, n + item_pos - was_copied, ih, body,
+ *zeros_num);
+ tb->insert_size[0] = 0;
+ *zeros_num = 0;
+ return;
+ }
+
+ /* Only part of new item falls into L[0] */
+ was_copied = leaf_shift_left(tb, tb->lnum[0] - 1, -1);
+
+ /* Calculate item length to insert to S[0] */
+ new_item_len = ih_item_len(ih) - tb->lbytes;
+ /* Calculate and check item length to insert to L[0] */
+ put_ih_item_len(ih, ih_item_len(ih) - new_item_len);
+
+ RFALSE(ih_item_len(ih) <= 0, "PAP-12080: there is nothing to "
+ "insert into L[0]: ih_item_len=%d", ih_item_len(ih));
+
+ /* Insert new item into L[0] */
+ buffer_info_init_left(tb, &bi);
+ leaf_insert_into_buf(&bi, n + item_pos - was_copied, ih, body,
+ *zeros_num > ih_item_len(ih) ? ih_item_len(ih) :
+ *zeros_num);
+
+ /* Calculate key component, item length and body to insert into S[0] */
+ if (is_indirect_le_ih(ih))
+ shift = tb->tb_sb->s_blocksize_bits - UNFM_P_SHIFT;
+ set_le_ih_k_offset(ih, le_ih_k_offset(ih) + (tb->lbytes << shift));
+
+ put_ih_item_len(ih, new_item_len);
+ if (tb->lbytes > *zeros_num) {
+ body += (tb->lbytes - *zeros_num);
+ *zeros_num = 0;
+ } else
+ *zeros_num -= tb->lbytes;
+
+ RFALSE(ih_item_len(ih) <= 0, "PAP-12085: there is nothing to "
+ "insert into S[0]: ih_item_len=%d", ih_item_len(ih));
+}
+
+/* directory item */
+static void
+bl_left_paste_de_partial(struct tree_balance *tb, struct item_head *ih,
+ const char *body, int flag, int *zeros_num,
+ int *pos_in_item)
+{
+ struct item_head *pasted;
+ int l_pos_in_item = *pos_in_item;
+ int was_copied;
+ int item_pos = PATH_LAST_POSITION(tb->tb_path);
+ struct buffer_info bi;
+ int n = B_NR_ITEMS(tb->L[0]);
+
+ RFALSE(*zeros_num, "PAP-12090: invalid parameter "
+ "in case of a directory");
+
+ if (tb->lbytes <= *pos_in_item) {
+ /* new directory item doesn't fall into L[0] */
+ /* Shift lnum[0]-1 items in whole. Shift lbytes
+ * directory entries from directory item number
+ * lnum[0] */
+ leaf_shift_left(tb, tb->lnum[0], tb->lbytes);
+ /* Calculate new position to append in item body */
+ *pos_in_item -= tb->lbytes;
+ return;
+ }
+
+ /* new directory entry falls into L[0] */
+
+ /* Shift lnum[0] - 1 items in whole.
+ * Shift lbytes - 1 entries from given directory item */
+ was_copied = leaf_shift_left(tb, tb->lnum[0], tb->lbytes - 1);
+ if (was_copied && !item_pos) {
+ pasted = B_N_PITEM_HEAD(tb->L[0], B_NR_ITEMS(tb->L[0]) - 1);
+ l_pos_in_item += I_ENTRY_COUNT(pasted) - (tb->lbytes - 1);
+ }
+
+ /* Append given directory entry to directory item */
+ buffer_info_init_left(tb, &bi);
+ leaf_paste_in_buffer(&bi, n + item_pos - was_copied, l_pos_in_item,
+ tb->insert_size[0], body, *zeros_num);
+
+ /* previous string prepared space for pasting new
+ * entry, following string pastes this entry */
+
+ /* when we have merge directory item, pos_in_item
+ * has been changed too */
+
+ /* paste new directory entry. 1 is entry number */
+ leaf_paste_entries(bi.bi_bh,
+ n + item_pos - was_copied,
+ l_pos_in_item, 1,
+ (struct reiserfs_de_head *) body,
+ body + DEH_SIZE, tb->insert_size[0]);
+ tb->insert_size[0] = 0;
+
+ /* Calculate new position to append in item body */
+ *pos_in_item -= tb->lbytes;
+}
+
+static void
+bl_left_paste_non_de_partial(struct tree_balance *tb, struct item_head *ih,
+ const char *body, int flag, int *zeros_num,
+ int *pos_in_item)
+{
+ struct buffer_head *tbS0 = PATH_PLAST_BUFFER(tb->tb_path);
+ int item_pos = PATH_LAST_POSITION(tb->tb_path);
+ struct buffer_info bi;
+ int l_n, version, temp_l;
+ u64 offset;
+ int was_copied;
+ int n = B_NR_ITEMS(tb->L[0]);
+
+ /* regular object */
+ RFALSE(tb->lbytes <= 0, "PAP-12095: there is nothing to "
+ "shift to L[0]. lbytes=%d", tb->lbytes);
+ RFALSE(*pos_in_item != ih_item_len(B_N_PITEM_HEAD(tbS0, item_pos)),
+ "PAP-12100: incorrect position to paste: "
+ "item_len=%d, pos_in_item=%d",
+ ih_item_len(B_N_PITEM_HEAD(tbS0, item_pos)), *pos_in_item);
+
+ /* only part of the appended item will be in L[0] */
+ if (tb->lbytes < *pos_in_item) {
+ /* Calculate position in item for append in S[0] */
+ *pos_in_item -= tb->lbytes;
+
+ RFALSE(*pos_in_item <= 0,
+ "PAP-12125: no place for paste. pos_in_item=%d",
+ *pos_in_item);
+
+ /* Shift lnum[0] - 1 items in whole.
+ * Shift lbytes - 1 byte from item number lnum[0] */
+ leaf_shift_left(tb, tb->lnum[0], tb->lbytes);
+ return;
+ }
+
+ /* appended item will be in L[0] in whole */
+ /* this bytes number must be appended to the last item of L[h] */
+ l_n = tb->lbytes - *pos_in_item;
+
+ /* Calculate new insert_size[0] */
+ tb->insert_size[0] -= l_n;
+
+ RFALSE(tb-> insert_size[0] <= 0, "PAP-12105: there is "
+ "nothing to paste into L[0]. insert_size=%d",
+ tb->insert_size[0]);
+ was_copied = leaf_shift_left(tb, tb->lnum[0],
+ ih_item_len(B_N_PITEM_HEAD(tbS0, item_pos)));
+ /* Append to body of item in L[0] */
+ buffer_info_init_left(tb, &bi);
+ leaf_paste_in_buffer(&bi, n + item_pos - was_copied,
+ ih_item_len(B_N_PITEM_HEAD(tb->L[0],
+ n + item_pos -
+ was_copied)),
+ l_n, body,
+ *zeros_num > l_n ? l_n : *zeros_num);
+ /* 0-th item in S0 can be only of DIRECT type when l_n != 0 */
+ temp_l = l_n;
+ RFALSE(ih_item_len (B_N_PITEM_HEAD(tbS0, 0)),
+ "PAP-12106: item length must be 0");
+ RFALSE(comp_short_le_keys(B_N_PKEY(tbS0, 0),
+ B_N_PKEY(tb->L[0], n + item_pos - was_copied)),
+ "PAP-12107: items must be of the same file");
+ if (is_indirect_le_ih(B_N_PITEM_HEAD(tb->L[0],
+ n + item_pos - was_copied))) {
+ temp_l = l_n << (tb->tb_sb-> s_blocksize_bits - UNFM_P_SHIFT);
+ }
+ /* update key of first item in S0 */
+ version = ih_version(B_N_PITEM_HEAD(tbS0, 0));
+ set_le_key_k_offset(version, B_N_PKEY(tbS0, 0),
+ le_key_k_offset(version, B_N_PKEY(tbS0, 0)) +
+ temp_l);
+ /* update left delimiting key */
+ offset = le_key_k_offset(version,
+ B_N_PDELIM_KEY(tb->CFL[0], tb->lkey[0])) + temp_l;
+ set_le_key_k_offset(version, B_N_PDELIM_KEY(tb->CFL[0], tb->lkey[0]),
+ offset);
+
+ /* Calculate new body, position in item
+ * and insert_size[0] */
+ if (l_n > *zeros_num) {
+ body += (l_n - *zeros_num);
+ *zeros_num = 0;
+ } else
+ *zeros_num -= l_n;
+
+ *pos_in_item = 0;
+
+ RFALSE(comp_short_le_keys(B_N_PKEY(tbS0, 0),
+ B_N_PKEY(tb->L[0], B_NR_ITEMS(tb->L[0]) - 1))
+ || !op_is_left_mergeable(B_N_PKEY(tbS0, 0), tbS0->b_size)
+ || !op_is_left_mergeable(B_N_PDELIM_KEY (tb->CFL[0],
+ tb->lkey[0]), tbS0->b_size),
+ "PAP-12120: item must be merge-able with left neighboring item");
+}
+
+static void
+bl_left_paste_solid(struct tree_balance *tb, struct item_head *ih,
+ const char *body, int flag, int *zeros_num,
+ int *pos_in_item)
+{
+ int was_copied;
+ int item_pos = PATH_LAST_POSITION(tb->tb_path);
+ int n = B_NR_ITEMS(tb->L[0]);
+ struct buffer_head *tbS0 = PATH_PLAST_BUFFER(tb->tb_path);
+ struct buffer_info bi;
+ struct item_head *pasted;
+
+ /* appended item will be in L[0] in whole */
+ if (!item_pos &&
+ op_is_left_mergeable(B_N_PKEY(tbS0, 0), tbS0->b_size)) {
+ /* if we paste into first item of S[0] and it is
+ * left mergable */
+ /* then increment pos_in_item by the size of the
+ * last item in L[0] */
+ pasted = B_N_PITEM_HEAD(tb->L[0], n - 1);
+ if (is_direntry_le_ih(pasted))
+ *pos_in_item += ih_entry_count(pasted);
+ else
+ *pos_in_item += ih_item_len(pasted);
+ }
+
+ /* Shift lnum[0] - 1 items in whole. Shift lbytes - 1 byte
+ * from item number lnum[0] */
+ was_copied = leaf_shift_left(tb, tb->lnum[0], tb->lbytes);
+
+ /* Append to body of item in L[0] */
+ buffer_info_init_left(tb, &bi);
+ leaf_paste_in_buffer(&bi, n + item_pos - was_copied,
+ *pos_in_item, tb->insert_size[0], body,
+ *zeros_num);
+
+ /* if appended item is directory, paste entry */
+ pasted = B_N_PITEM_HEAD(tb->L[0], n + item_pos - was_copied);
+ if (is_direntry_le_ih(pasted))
+ leaf_paste_entries(bi.bi_bh, n + item_pos - was_copied,
+ *pos_in_item, 1,
+ (struct reiserfs_de_head *)body,
+ body + DEH_SIZE, tb->insert_size[0]);
+ /* if appended item is indirect item, put
+ * unformatted node into un list */
+ if (is_indirect_le_ih(pasted))
+ set_ih_free_space(pasted, 0);
+ tb->insert_size[0] = 0;
+ *zeros_num = 0;
+}
+
+/* Append item in L[0] */
+static void
+bl_left_paste(struct tree_balance *tb, struct item_head *ih,
+ const char *body, int flag, int *zeros_num,
+ int *pos_in_item)
+{
+ int item_pos = PATH_LAST_POSITION(tb->tb_path);
+ struct buffer_head *tbS0 = PATH_PLAST_BUFFER(tb->tb_path);
+
+ /* We must shift the part of the appended item */
+ if (item_pos == tb->lnum[0] - 1 && tb->lbytes != -1) {
+ if (is_direntry_le_ih(B_N_PITEM_HEAD(tbS0, item_pos)))
+ bl_left_paste_de_partial(tb, ih, body, flag, zeros_num,
+ pos_in_item);
+ else
+ bl_left_paste_non_de_partial(tb, ih, body, flag,
+ zeros_num, pos_in_item);
+ return;
+ } else {
+ bl_left_paste_solid(tb, ih, body, flag, zeros_num, pos_in_item);
+ }
+}
+
+/* Shift lnum[0] items from S[0] to the left neighbor L[0] */
+static void
+bl_left(struct tree_balance *tb, struct item_head *ih,
+ const char *body, int flag, int *zeros_num, int *pos_in_item)
+{
+ int item_pos = PATH_LAST_POSITION(tb->tb_path);
+
+ BUG_ON(flag != M_INSERT && flag != M_PASTE);
+
+ /* new item doesn't fall into L[0] */
+ if (item_pos >= tb->lnum[0]) {
+ leaf_shift_left(tb, tb->lnum[0], tb->lbytes);
+ return;
+ }
+
+ /* new item or it part falls to L[0], shift it too */
+ if (flag == M_INSERT)
+ bl_left_insert(tb, ih, body, flag, zeros_num);
+ else /* M_PASTE */
+ bl_left_paste(tb, ih, body, flag, zeros_num,
+ pos_in_item);
+}
+
static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item header of inserted item (this is on little endian) */
const char *body, /* body of inserted item or bytes to paste */
int flag, /* i - insert, d - delete, c - cut, p - paste
@@ -314,426 +625,8 @@ static int balance_leaf(struct tree_bala
&& is_indirect_le_ih(B_N_PITEM_HEAD(tbS0, item_pos)))
pos_in_item *= UNFM_P_SIZE;
- if (tb->lnum[0] > 0) {
- /* Shift lnum[0] items from S[0] to the left neighbor L[0] */
- if (item_pos < tb->lnum[0]) {
- /* new item or it part falls to L[0], shift it too */
- n = B_NR_ITEMS(tb->L[0]);
-
- switch (flag) {
- case M_INSERT: /* insert item into L[0] */
-
- if (item_pos == tb->lnum[0] - 1
- && tb->lbytes != -1) {
- /* part of new item falls into L[0] */
- int new_item_len;
- int version;
-
- ret_val =
- leaf_shift_left(tb, tb->lnum[0] - 1,
- -1);
-
- /* Calculate item length to insert to S[0] */
- new_item_len =
- ih_item_len(ih) - tb->lbytes;
- /* Calculate and check item length to insert to L[0] */
- put_ih_item_len(ih,
- ih_item_len(ih) -
- new_item_len);
-
- RFALSE(ih_item_len(ih) <= 0,
- "PAP-12080: there is nothing to insert into L[0]: ih_item_len=%d",
- ih_item_len(ih));
-
- /* Insert new item into L[0] */
- buffer_info_init_left(tb, &bi);
- leaf_insert_into_buf(&bi,
- n + item_pos -
- ret_val, ih, body,
- zeros_num >
- ih_item_len(ih) ?
- ih_item_len(ih) :
- zeros_num);
-
- version = ih_version(ih);
-
- /* Calculate key component, item length and body to insert into S[0] */
- set_le_ih_k_offset(ih,
- le_ih_k_offset(ih) +
- (tb->
- lbytes <<
- (is_indirect_le_ih
- (ih) ? tb->tb_sb->
- s_blocksize_bits -
- UNFM_P_SHIFT :
- 0)));
-
- put_ih_item_len(ih, new_item_len);
- if (tb->lbytes > zeros_num) {
- body +=
- (tb->lbytes - zeros_num);
- zeros_num = 0;
- } else
- zeros_num -= tb->lbytes;
-
- RFALSE(ih_item_len(ih) <= 0,
- "PAP-12085: there is nothing to insert into S[0]: ih_item_len=%d",
- ih_item_len(ih));
- } else {
- /* new item in whole falls into L[0] */
- /* Shift lnum[0]-1 items to L[0] */
- ret_val =
- leaf_shift_left(tb, tb->lnum[0] - 1,
- tb->lbytes);
- /* Insert new item into L[0] */
- buffer_info_init_left(tb, &bi);
- leaf_insert_into_buf(&bi,
- n + item_pos -
- ret_val, ih, body,
- zeros_num);
- tb->insert_size[0] = 0;
- zeros_num = 0;
- }
- break;
-
- case M_PASTE: /* append item in L[0] */
-
- if (item_pos == tb->lnum[0] - 1
- && tb->lbytes != -1) {
- /* we must shift the part of the appended item */
- if (is_direntry_le_ih
- (B_N_PITEM_HEAD(tbS0, item_pos))) {
-
- RFALSE(zeros_num,
- "PAP-12090: invalid parameter in case of a directory");
- /* directory item */
- if (tb->lbytes > pos_in_item) {
- /* new directory entry falls into L[0] */
- struct item_head
- *pasted;
- int l_pos_in_item =
- pos_in_item;
-
- /* Shift lnum[0] - 1 items in whole. Shift lbytes - 1 entries from given directory item */
- ret_val =
- leaf_shift_left(tb,
- tb->
- lnum
- [0],
- tb->
- lbytes
- -
- 1);
- if (ret_val
- && !item_pos) {
- pasted =
- B_N_PITEM_HEAD
- (tb->L[0],
- B_NR_ITEMS
- (tb->
- L[0]) -
- 1);
- l_pos_in_item +=
- I_ENTRY_COUNT
- (pasted) -
- (tb->
- lbytes -
- 1);
- }
-
- /* Append given directory entry to directory item */
- buffer_info_init_left(tb, &bi);
- leaf_paste_in_buffer
- (&bi,
- n + item_pos -
- ret_val,
- l_pos_in_item,
- tb->insert_size[0],
- body, zeros_num);
-
- /* previous string prepared space for pasting new entry, following string pastes this entry */
-
- /* when we have merge directory item, pos_in_item has been changed too */
-
- /* paste new directory entry. 1 is entry number */
- leaf_paste_entries(bi.
- bi_bh,
- n +
- item_pos
- -
- ret_val,
- l_pos_in_item,
- 1,
- (struct
- reiserfs_de_head
- *)
- body,
- body
- +
- DEH_SIZE,
- tb->
- insert_size
- [0]
- );
- tb->insert_size[0] = 0;
- } else {
- /* new directory item doesn't fall into L[0] */
- /* Shift lnum[0]-1 items in whole. Shift lbytes directory entries from directory item number lnum[0] */
- leaf_shift_left(tb,
- tb->
- lnum[0],
- tb->
- lbytes);
- }
- /* Calculate new position to append in item body */
- pos_in_item -= tb->lbytes;
- } else {
- /* regular object */
- RFALSE(tb->lbytes <= 0,
- "PAP-12095: there is nothing to shift to L[0]. lbytes=%d",
- tb->lbytes);
- RFALSE(pos_in_item !=
- ih_item_len
- (B_N_PITEM_HEAD
- (tbS0, item_pos)),
- "PAP-12100: incorrect position to paste: item_len=%d, pos_in_item=%d",
- ih_item_len
- (B_N_PITEM_HEAD
- (tbS0, item_pos)),
- pos_in_item);
-
- if (tb->lbytes >= pos_in_item) {
- /* appended item will be in L[0] in whole */
- int l_n;
-
- /* this bytes number must be appended to the last item of L[h] */
- l_n =
- tb->lbytes -
- pos_in_item;
-
- /* Calculate new insert_size[0] */
- tb->insert_size[0] -=
- l_n;
-
- RFALSE(tb->
- insert_size[0] <=
- 0,
- "PAP-12105: there is nothing to paste into L[0]. insert_size=%d",
- tb->
- insert_size[0]);
- ret_val =
- leaf_shift_left(tb,
- tb->
- lnum
- [0],
- ih_item_len
- (B_N_PITEM_HEAD
- (tbS0,
- item_pos)));
- /* Append to body of item in L[0] */
- buffer_info_init_left(tb, &bi);
- leaf_paste_in_buffer
- (&bi,
- n + item_pos -
- ret_val,
- ih_item_len
- (B_N_PITEM_HEAD
- (tb->L[0],
- n + item_pos -
- ret_val)), l_n,
- body,
- zeros_num >
- l_n ? l_n :
- zeros_num);
- /* 0-th item in S0 can be only of DIRECT type when l_n != 0 */
- {
- int version;
- int temp_l =
- l_n;
-
- RFALSE
- (ih_item_len
- (B_N_PITEM_HEAD
- (tbS0,
- 0)),
- "PAP-12106: item length must be 0");
- RFALSE
- (comp_short_le_keys
- (B_N_PKEY
- (tbS0, 0),
- B_N_PKEY
- (tb->L[0],
- n +
- item_pos
- -
- ret_val)),
- "PAP-12107: items must be of the same file");
- if (is_indirect_le_ih(B_N_PITEM_HEAD(tb->L[0], n + item_pos - ret_val))) {
- temp_l =
- l_n
- <<
- (tb->
- tb_sb->
- s_blocksize_bits
- -
- UNFM_P_SHIFT);
- }
- /* update key of first item in S0 */
- version =
- ih_version
- (B_N_PITEM_HEAD
- (tbS0, 0));
- set_le_key_k_offset
- (version,
- B_N_PKEY
- (tbS0, 0),
- le_key_k_offset
- (version,
- B_N_PKEY
- (tbS0,
- 0)) +
- temp_l);
- /* update left delimiting key */
- set_le_key_k_offset
- (version,
- B_N_PDELIM_KEY
- (tb->
- CFL[0],
- tb->
- lkey[0]),
- le_key_k_offset
- (version,
- B_N_PDELIM_KEY
- (tb->
- CFL[0],
- tb->
- lkey[0]))
- + temp_l);
- }
-
- /* Calculate new body, position in item and insert_size[0] */
- if (l_n > zeros_num) {
- body +=
- (l_n -
- zeros_num);
- zeros_num = 0;
- } else
- zeros_num -=
- l_n;
- pos_in_item = 0;
-
- RFALSE
- (comp_short_le_keys
- (B_N_PKEY(tbS0, 0),
- B_N_PKEY(tb->L[0],
- B_NR_ITEMS
- (tb->
- L[0]) -
- 1))
- ||
- !op_is_left_mergeable
- (B_N_PKEY(tbS0, 0),
- tbS0->b_size)
- ||
- !op_is_left_mergeable
- (B_N_PDELIM_KEY
- (tb->CFL[0],
- tb->lkey[0]),
- tbS0->b_size),
- "PAP-12120: item must be merge-able with left neighboring item");
- } else { /* only part of the appended item will be in L[0] */
-
- /* Calculate position in item for append in S[0] */
- pos_in_item -=
- tb->lbytes;
-
- RFALSE(pos_in_item <= 0,
- "PAP-12125: no place for paste. pos_in_item=%d",
- pos_in_item);
-
- /* Shift lnum[0] - 1 items in whole. Shift lbytes - 1 byte from item number lnum[0] */
- leaf_shift_left(tb,
- tb->
- lnum[0],
- tb->
- lbytes);
- }
- }
- } else { /* appended item will be in L[0] in whole */
-
- struct item_head *pasted;
-
- if (!item_pos && op_is_left_mergeable(B_N_PKEY(tbS0, 0), tbS0->b_size)) { /* if we paste into first item of S[0] and it is left mergable */
- /* then increment pos_in_item by the size of the last item in L[0] */
- pasted =
- B_N_PITEM_HEAD(tb->L[0],
- n - 1);
- if (is_direntry_le_ih(pasted))
- pos_in_item +=
- ih_entry_count
- (pasted);
- else
- pos_in_item +=
- ih_item_len(pasted);
- }
-
- /* Shift lnum[0] - 1 items in whole. Shift lbytes - 1 byte from item number lnum[0] */
- ret_val =
- leaf_shift_left(tb, tb->lnum[0],
- tb->lbytes);
- /* Append to body of item in L[0] */
- buffer_info_init_left(tb, &bi);
- leaf_paste_in_buffer(&bi,
- n + item_pos -
- ret_val,
- pos_in_item,
- tb->insert_size[0],
- body, zeros_num);
-
- /* if appended item is directory, paste entry */
- pasted =
- B_N_PITEM_HEAD(tb->L[0],
- n + item_pos -
- ret_val);
- if (is_direntry_le_ih(pasted))
- leaf_paste_entries(bi.bi_bh,
- n +
- item_pos -
- ret_val,
- pos_in_item,
- 1,
- (struct
- reiserfs_de_head
- *)body,
- body +
- DEH_SIZE,
- tb->
- insert_size
- [0]
- );
- /* if appended item is indirect item, put unformatted node into un list */
- if (is_indirect_le_ih(pasted))
- set_ih_free_space(pasted, 0);
- tb->insert_size[0] = 0;
- zeros_num = 0;
- }
- break;
- default: /* cases d and t */
- reiserfs_panic(tb->tb_sb, "PAP-12130",
- "lnum > 0: unexpected mode: %s(%d)",
- (flag ==
- M_DELETE) ? "DELETE" : ((flag ==
- M_CUT)
- ? "CUT"
- :
- "UNKNOWN"),
- flag);
- }
- } else {
- /* new item doesn't fall into L[0] */
- leaf_shift_left(tb, tb->lnum[0], tb->lbytes);
- }
- }
+ if (tb->lnum[0] > 0)
+ bl_left(tb, ih, body, flag, &zeros_num, &pos_in_item);
/* tb->lnum[0] > 0 */
/* Calculate new item position */
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 43+ messages in thread
* [patch 34/40] reiserfs: split right balancing part of balance_leaf() off
2007-06-11 19:03 [patch 00/40] reiserfs: patch queue (v2) jeffm
` (31 preceding siblings ...)
2007-06-11 19:03 ` [patch 33/40] reiserfs: split left balancing part of balance_leaf() off jeffm
@ 2007-06-11 19:03 ` jeffm
2007-06-11 19:03 ` [patch 35/40] reiserfs: split balance_leaf new node handling out jeffm
` (7 subsequent siblings)
40 siblings, 0 replies; 43+ messages in thread
From: jeffm @ 2007-06-11 19:03 UTC (permalink / raw)
To: ReiserFS Mailing List
[-- Attachment #1: reiserfs-split-balance_leaf-right.diff --]
[-- Type: text/plain, Size: 20677 bytes --]
This is the second in a set of 4 patches that split balance_leaf up into
a group of functions rather than the 2500 beast it once was.
This patch splits off the right-tree balancing behavior.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
fs/reiserfs/do_balan.c | 671 +++++++++++++++++++++----------------------------
1 file changed, 290 insertions(+), 381 deletions(-)
--- a/fs/reiserfs/do_balan.c 2007-06-11 14:49:41.000000000 -0400
+++ b/fs/reiserfs/do_balan.c 2007-06-11 14:50:00.000000000 -0400
@@ -587,6 +587,293 @@ bl_left(struct tree_balance *tb, struct
pos_in_item);
}
+static void
+bl_right_insert(struct tree_balance *tb, struct item_head *ih,
+ const char *body, int flag, int *zeros_num,
+ int item_pos)
+{
+ loff_t old_key_comp, old_len, r_zeros_number;
+ const char *r_body;
+ loff_t offset;
+ struct buffer_head *tbS0 = PATH_PLAST_BUFFER(tb->tb_path);
+ int n = B_NR_ITEMS(tbS0);
+ struct buffer_info bi;
+
+ /* Doesn't fall into R[0] */
+ if (n - tb->rnum[0] >= item_pos) {
+ leaf_shift_right(tb, tb->rnum[0], tb->rbytes);
+ return;
+ }
+
+ /* whole new item falls into R[0] */
+ if (item_pos != n - tb->rnum[0] + 1 || tb->rbytes == -1) {
+ /* Shift rnum[0]-1 items to R[0] */
+ leaf_shift_right(tb, tb->rnum[0] - 1, tb->rbytes);
+
+ /* Insert new item into R[0] */
+ buffer_info_init_right(tb, &bi);
+ leaf_insert_into_buf(&bi, item_pos - n + tb->rnum[0] - 1,
+ ih, body, *zeros_num);
+
+ if (item_pos - n + tb->rnum[0] - 1 == 0)
+ replace_key(tb, tb->CFR[0], tb->rkey[0], tb->R[0], 0);
+ *zeros_num = tb->insert_size[0] = 0;
+ return;
+ }
+
+ /* Only part of item falls into R[0] */
+
+ leaf_shift_right(tb, tb->rnum[0] - 1, -1);
+
+ /* Remember key component and item length */
+ old_key_comp = le_ih_k_offset(ih);
+ old_len = ih_item_len(ih);
+
+ /* Calculate key component and item length to insert into R[0] */
+ offset = le_ih_k_offset(ih) +
+ ((old_len - tb->rbytes) << (is_indirect_le_ih(ih)
+ ? tb->tb_sb->
+ s_blocksize_bits -
+ UNFM_P_SHIFT : 0));
+ set_le_ih_k_offset(ih, offset);
+ put_ih_item_len(ih, tb->rbytes);
+ /* Insert part of the item into R[0] */
+ buffer_info_init_right(tb, &bi);
+ if ((old_len - tb->rbytes) > *zeros_num) {
+ r_zeros_number = 0;
+ r_body = body + (old_len - tb->rbytes) - *zeros_num;
+ } else {
+ r_body = body;
+ r_zeros_number = *zeros_num - (old_len - tb->rbytes);
+ *zeros_num -= r_zeros_number;
+ }
+
+ leaf_insert_into_buf(&bi, 0, ih, r_body, r_zeros_number);
+
+ /* Replace right delimiting key by first key in R[0] */
+ replace_key(tb, tb->CFR[0], tb->rkey[0], tb->R[0], 0);
+
+ /* Calculate key component and item length to insert into S[0] */
+ set_le_ih_k_offset(ih, old_key_comp);
+ put_ih_item_len(ih, old_len - tb->rbytes);
+
+ tb->insert_size[0] -= tb->rbytes;
+}
+
+static void
+bl_right_paste_de_partial(struct tree_balance *tb, struct item_head *ih,
+ const char *body, int flag, int *zeros_num,
+ int item_pos, int *pos_in_item)
+{
+ struct buffer_head *tbS0 = PATH_PLAST_BUFFER(tb->tb_path);
+ struct buffer_info bi;
+ int paste_entry_position;
+ int entry_count;
+
+ RFALSE(*zeros_num, "PAP-12145: invalid parameter "
+ "in case of a directory");
+ entry_count = I_ENTRY_COUNT(B_N_PITEM_HEAD(tbS0,
+ item_pos));
+
+ if (entry_count - tb->rbytes >= *pos_in_item) {
+ leaf_shift_right(tb, tb->rnum[0], tb->rbytes);
+ return;
+ }
+
+ /* new directory entry falls into R[0] */
+ RFALSE(tb->rbytes - 1 >= entry_count
+ || !tb-> insert_size[0], "PAP-12150: no enough of entries "
+ "to shift to R[0]: rbytes=%d, entry_count=%d",
+ tb->rbytes, entry_count);
+
+ /* Shift rnum[0]-1 items in whole.
+ * Shift rbytes-1 directory entries from
+ * directory item number rnum[0] */
+ leaf_shift_right(tb, tb->rnum[0], tb->rbytes - 1);
+
+ /* Paste given directory entry to
+ * directory item */
+ paste_entry_position = *pos_in_item - entry_count + tb->rbytes - 1;
+ buffer_info_init_right(tb, &bi);
+ leaf_paste_in_buffer(&bi, 0, paste_entry_position, tb->insert_size[0],
+ body, *zeros_num);
+ /* paste entry */
+ leaf_paste_entries(bi.bi_bh, 0, paste_entry_position, 1,
+ (struct reiserfs_de_head *) body, body + DEH_SIZE,
+ tb->insert_size[0]);
+
+ /* change delimiting keys */
+ if (paste_entry_position == 0)
+ replace_key(tb, tb->CFR[0], tb->rkey[0], tb->R[0], 0);
+
+ tb->insert_size[0] = 0;
+ (*pos_in_item)++;
+}
+
+static void
+bl_right_paste_non_de_partial(struct tree_balance *tb, struct item_head *ih,
+ const char *body, int flag, int *zeros_num,
+ int item_pos, int *pos_in_item)
+{
+
+#ifdef CONFIG_REISERFS_CHECK
+ struct buffer_head *tbS0 = PATH_PLAST_BUFFER(tb->tb_path);
+#endif
+ struct buffer_info bi;
+ int n_shift, n_rem, r_zeros_number;
+ const char *r_body;
+ int version;
+ unsigned long temp_rem;
+ u64 offset;
+
+ /* Calculate number of bytes which must be
+ * shifted from appended item */
+ if ((n_shift = tb->rbytes - tb->insert_size[0]) < 0)
+ n_shift = 0;
+
+ RFALSE(*pos_in_item !=
+ ih_item_len(B_N_PITEM_HEAD(tbS0, item_pos)),
+ "PAP-12155: invalid position to paste. "
+ "ih_item_len=%d, pos_in_item=%d", *pos_in_item,
+ ih_item_len(B_N_PITEM_HEAD(tbS0, item_pos)));
+
+ leaf_shift_right(tb, tb->rnum[0], n_shift);
+ /* Calculate number of bytes which must remain
+ * in body after appending to R[0] */
+ if ((n_rem = tb->insert_size[0] - tb->rbytes) < 0)
+ n_rem = 0;
+
+ temp_rem = n_rem;
+ version = ih_version(B_N_PITEM_HEAD(tb->R[0], 0));
+ if (is_indirect_le_key(version, B_N_PKEY(tb->R[0], 0))) {
+ temp_rem = n_rem << (tb->tb_sb->s_blocksize_bits -
+ UNFM_P_SHIFT);
+ }
+ offset = le_key_k_offset(version, B_N_PKEY(tb->R[0], 0));
+ set_le_key_k_offset(version, B_N_PKEY(tb->R[0], 0), offset + temp_rem);
+
+ offset = le_key_k_offset (version,
+ B_N_PDELIM_KEY(tb->CFR[0], tb->rkey[0]));
+ set_le_key_k_offset(version, B_N_PDELIM_KEY(tb->CFR[0], tb->rkey[0]),
+ offset + temp_rem);
+ do_balance_mark_internal_dirty(tb, tb->CFR[0], 0);
+
+ /* Append part of body into R[0] */
+ buffer_info_init_right(tb, &bi);
+ if (n_rem > *zeros_num) {
+ r_zeros_number = 0;
+ r_body = body + n_rem - *zeros_num;
+ } else {
+ r_body = body;
+ r_zeros_number = *zeros_num - n_rem;
+ *zeros_num -= r_zeros_number;
+ }
+
+ leaf_paste_in_buffer(&bi, 0, n_shift, tb->insert_size[0] - n_rem,
+ r_body, r_zeros_number);
+
+ if (is_indirect_le_ih(B_N_PITEM_HEAD(tb->R[0], 0)))
+ set_ih_free_space(B_N_PITEM_HEAD(tb->R[0], 0), 0);
+
+ tb->insert_size[0] = n_rem;
+ if (!n_rem)
+ (*pos_in_item)++;
+}
+
+static void
+bl_right_paste_solid(struct tree_balance *tb, struct item_head *ih,
+ const char *body, int flag, int *zeros_num,
+ int item_pos, int *pos_in_item)
+{
+ struct item_head *pasted;
+ struct buffer_head *tbS0 = PATH_PLAST_BUFFER(tb->tb_path);
+ int n = B_NR_ITEMS(tbS0);
+ struct buffer_info bi;
+
+ /* pasted item in whole falls into R[0] */
+ leaf_shift_right(tb, tb->rnum[0], tb->rbytes);
+ /* append item in R[0] */
+ if (*pos_in_item >= 0) {
+ buffer_info_init_right(tb, &bi);
+ leaf_paste_in_buffer(&bi,
+ item_pos - n + tb->rnum[0],
+ *pos_in_item,
+ tb->insert_size[0], body,
+ *zeros_num);
+ }
+
+ /* paste new entry, if item is directory item */
+ pasted = B_N_PITEM_HEAD(tb->R[0], item_pos - n + tb->rnum[0]);
+ if (is_direntry_le_ih(pasted) && *pos_in_item >= 0) {
+ leaf_paste_entries(bi.bi_bh, item_pos - n + tb->rnum[0],
+ *pos_in_item, 1,
+ (struct reiserfs_de_head *)body,
+ body + DEH_SIZE, tb->insert_size[0]);
+
+ if (!*pos_in_item) {
+ RFALSE(item_pos - n + tb->rnum[0],
+ "PAP-12165: directory item must be "
+ "first item of node when pasting is "
+ "in 0th position");
+
+ /* update delimiting keys */
+ replace_key(tb, tb->CFR[0], tb->rkey[0],
+ tb->R[0], 0);
+ }
+ }
+
+ if (is_indirect_le_ih(pasted))
+ set_ih_free_space(pasted, 0);
+ *zeros_num = tb->insert_size[0] = 0;
+
+}
+
+static void
+bl_right_paste(struct tree_balance *tb,
+ struct item_head *ih, const char *body, int flag,
+ int *zeros_num, int item_pos, int *pos_in_item)
+{
+ struct buffer_head *tbS0 = PATH_PLAST_BUFFER(tb->tb_path);
+ int n = B_NR_ITEMS(tbS0);
+
+ if (n - tb->rnum[0] > item_pos) {
+ leaf_shift_right(tb, tb->rnum[0], tb->rbytes);
+ return;
+ }
+ /* pasted item or part of it falls to R[0] */
+ /* we must shift the part of the appended item */
+ if (item_pos == n - tb->rnum[0] && tb->rbytes != -1) {
+ if (is_direntry_le_ih(B_N_PITEM_HEAD(tbS0, item_pos)))
+ bl_right_paste_de_partial(tb, ih, body, flag,
+ zeros_num, item_pos,
+ pos_in_item);
+ else
+ bl_right_paste_non_de_partial(tb, ih, body, flag,
+ zeros_num, item_pos,
+ pos_in_item);
+ } else {
+ bl_right_paste_solid(tb, ih, body, flag, zeros_num, item_pos,
+ pos_in_item);
+ }
+}
+
+static void
+bl_right(struct tree_balance *tb, struct item_head *ih,
+ const char *body, int flag, int *zeros_num, int item_pos,
+ int *pos_in_item)
+{
+ BUG_ON(flag != M_INSERT && flag != M_PASTE);
+
+ /* shift rnum[0] items from S[0] to the right neighbor R[0] */
+ if (flag == M_INSERT)
+ bl_right_insert(tb, ih, body, flag, zeros_num,
+ item_pos);
+ else
+ bl_right_paste(tb, ih, body, flag, zeros_num,
+ item_pos, pos_in_item);
+}
+
+
static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item header of inserted item (this is on little endian) */
const char *body, /* body of inserted item or bytes to paste */
int flag, /* i - insert, d - delete, c - cut, p - paste
@@ -604,7 +891,6 @@ static int balance_leaf(struct tree_bala
struct buffer_info bi;
struct buffer_head *S_new[2]; /* new nodes allocated to hold what could not fit into S */
int n, i;
- int ret_val;
int pos_in_item;
int zeros_num;
@@ -632,386 +918,9 @@ static int balance_leaf(struct tree_bala
/* Calculate new item position */
item_pos -= (tb->lnum[0] - ((tb->lbytes != -1) ? 1 : 0));
- if (tb->rnum[0] > 0) {
- /* shift rnum[0] items from S[0] to the right neighbor R[0] */
- n = B_NR_ITEMS(tbS0);
- switch (flag) {
-
- case M_INSERT: /* insert item */
- if (n - tb->rnum[0] < item_pos) { /* new item or its part falls to R[0] */
- if (item_pos == n - tb->rnum[0] + 1 && tb->rbytes != -1) { /* part of new item falls into R[0] */
- loff_t old_key_comp, old_len,
- r_zeros_number;
- const char *r_body;
- int version;
- loff_t offset;
-
- leaf_shift_right(tb, tb->rnum[0] - 1,
- -1);
-
- version = ih_version(ih);
- /* Remember key component and item length */
- old_key_comp = le_ih_k_offset(ih);
- old_len = ih_item_len(ih);
-
- /* Calculate key component and item length to insert into R[0] */
- offset =
- le_ih_k_offset(ih) +
- ((old_len -
- tb->
- rbytes) << (is_indirect_le_ih(ih)
- ? tb->tb_sb->
- s_blocksize_bits -
- UNFM_P_SHIFT : 0));
- set_le_ih_k_offset(ih, offset);
- put_ih_item_len(ih, tb->rbytes);
- /* Insert part of the item into R[0] */
- buffer_info_init_right(tb, &bi);
- if ((old_len - tb->rbytes) > zeros_num) {
- r_zeros_number = 0;
- r_body =
- body + (old_len -
- tb->rbytes) -
- zeros_num;
- } else {
- r_body = body;
- r_zeros_number =
- zeros_num - (old_len -
- tb->rbytes);
- zeros_num -= r_zeros_number;
- }
-
- leaf_insert_into_buf(&bi, 0, ih, r_body,
- r_zeros_number);
-
- /* Replace right delimiting key by first key in R[0] */
- replace_key(tb, tb->CFR[0], tb->rkey[0],
- tb->R[0], 0);
-
- /* Calculate key component and item length to insert into S[0] */
- set_le_ih_k_offset(ih, old_key_comp);
- put_ih_item_len(ih,
- old_len - tb->rbytes);
-
- tb->insert_size[0] -= tb->rbytes;
-
- } else { /* whole new item falls into R[0] */
-
- /* Shift rnum[0]-1 items to R[0] */
- ret_val =
- leaf_shift_right(tb,
- tb->rnum[0] - 1,
- tb->rbytes);
- /* Insert new item into R[0] */
- buffer_info_init_right(tb, &bi);
- leaf_insert_into_buf(&bi,
- item_pos - n +
- tb->rnum[0] - 1,
- ih, body,
- zeros_num);
-
- if (item_pos - n + tb->rnum[0] - 1 == 0) {
- replace_key(tb, tb->CFR[0],
- tb->rkey[0],
- tb->R[0], 0);
-
- }
- zeros_num = tb->insert_size[0] = 0;
- }
- } else { /* new item or part of it doesn't fall into R[0] */
-
- leaf_shift_right(tb, tb->rnum[0], tb->rbytes);
- }
- break;
-
- case M_PASTE: /* append item */
-
- if (n - tb->rnum[0] <= item_pos) { /* pasted item or part of it falls to R[0] */
- if (item_pos == n - tb->rnum[0] && tb->rbytes != -1) { /* we must shift the part of the appended item */
- if (is_direntry_le_ih(B_N_PITEM_HEAD(tbS0, item_pos))) { /* we append to directory item */
- int entry_count;
-
- RFALSE(zeros_num,
- "PAP-12145: invalid parameter in case of a directory");
- entry_count =
- I_ENTRY_COUNT(B_N_PITEM_HEAD
- (tbS0,
- item_pos));
- if (entry_count - tb->rbytes <
- pos_in_item)
- /* new directory entry falls into R[0] */
- {
- int paste_entry_position;
-
- RFALSE(tb->rbytes - 1 >=
- entry_count
- || !tb->
- insert_size[0],
- "PAP-12150: no enough of entries to shift to R[0]: rbytes=%d, entry_count=%d",
- tb->rbytes,
- entry_count);
- /* Shift rnum[0]-1 items in whole. Shift rbytes-1 directory entries from directory item number rnum[0] */
- leaf_shift_right(tb,
- tb->
- rnum
- [0],
- tb->
- rbytes
- - 1);
- /* Paste given directory entry to directory item */
- paste_entry_position =
- pos_in_item -
- entry_count +
- tb->rbytes - 1;
- buffer_info_init_right(tb, &bi);
- leaf_paste_in_buffer
- (&bi, 0,
- paste_entry_position,
- tb->insert_size[0],
- body, zeros_num);
- /* paste entry */
- leaf_paste_entries(bi.
- bi_bh,
- 0,
- paste_entry_position,
- 1,
- (struct
- reiserfs_de_head
- *)
- body,
- body
- +
- DEH_SIZE,
- tb->
- insert_size
- [0]
- );
-
- if (paste_entry_position
- == 0) {
- /* change delimiting keys */
- replace_key(tb,
- tb->
- CFR
- [0],
- tb->
- rkey
- [0],
- tb->
- R
- [0],
- 0);
- }
-
- tb->insert_size[0] = 0;
- pos_in_item++;
- } else { /* new directory entry doesn't fall into R[0] */
-
- leaf_shift_right(tb,
- tb->
- rnum
- [0],
- tb->
- rbytes);
- }
- } else { /* regular object */
-
- int n_shift, n_rem,
- r_zeros_number;
- const char *r_body;
-
- /* Calculate number of bytes which must be shifted from appended item */
- if ((n_shift =
- tb->rbytes -
- tb->insert_size[0]) < 0)
- n_shift = 0;
-
- RFALSE(pos_in_item !=
- ih_item_len
- (B_N_PITEM_HEAD
- (tbS0, item_pos)),
- "PAP-12155: invalid position to paste. ih_item_len=%d, pos_in_item=%d",
- pos_in_item,
- ih_item_len
- (B_N_PITEM_HEAD
- (tbS0, item_pos)));
-
- leaf_shift_right(tb,
- tb->rnum[0],
- n_shift);
- /* Calculate number of bytes which must remain in body after appending to R[0] */
- if ((n_rem =
- tb->insert_size[0] -
- tb->rbytes) < 0)
- n_rem = 0;
-
- {
- int version;
- unsigned long temp_rem =
- n_rem;
-
- version =
- ih_version
- (B_N_PITEM_HEAD
- (tb->R[0], 0));
- if (is_indirect_le_key
- (version,
- B_N_PKEY(tb->R[0],
- 0))) {
- temp_rem =
- n_rem <<
- (tb->tb_sb->
- s_blocksize_bits
- -
- UNFM_P_SHIFT);
- }
- set_le_key_k_offset
- (version,
- B_N_PKEY(tb->R[0],
- 0),
- le_key_k_offset
- (version,
- B_N_PKEY(tb->R[0],
- 0)) +
- temp_rem);
- set_le_key_k_offset
- (version,
- B_N_PDELIM_KEY(tb->
- CFR
- [0],
- tb->
- rkey
- [0]),
- le_key_k_offset
- (version,
- B_N_PDELIM_KEY
- (tb->CFR[0],
- tb->rkey[0])) +
- temp_rem);
- }
-/* k_offset (B_N_PKEY(tb->R[0],0)) += n_rem;
- k_offset (B_N_PDELIM_KEY(tb->CFR[0],tb->rkey[0])) += n_rem;*/
- do_balance_mark_internal_dirty
- (tb, tb->CFR[0], 0);
-
- /* Append part of body into R[0] */
- buffer_info_init_right(tb, &bi);
- if (n_rem > zeros_num) {
- r_zeros_number = 0;
- r_body =
- body + n_rem -
- zeros_num;
- } else {
- r_body = body;
- r_zeros_number =
- zeros_num - n_rem;
- zeros_num -=
- r_zeros_number;
- }
-
- leaf_paste_in_buffer(&bi, 0,
- n_shift,
- tb->
- insert_size
- [0] -
- n_rem,
- r_body,
- r_zeros_number);
-
- if (is_indirect_le_ih
- (B_N_PITEM_HEAD
- (tb->R[0], 0))) {
-#if 0
- RFALSE(n_rem,
- "PAP-12160: paste more than one unformatted node pointer");
-#endif
- set_ih_free_space
- (B_N_PITEM_HEAD
- (tb->R[0], 0), 0);
- }
- tb->insert_size[0] = n_rem;
- if (!n_rem)
- pos_in_item++;
- }
- } else { /* pasted item in whole falls into R[0] */
-
- struct item_head *pasted;
-
- ret_val =
- leaf_shift_right(tb, tb->rnum[0],
- tb->rbytes);
- /* append item in R[0] */
- if (pos_in_item >= 0) {
- buffer_info_init_right(tb, &bi);
- leaf_paste_in_buffer(&bi,
- item_pos -
- n +
- tb->
- rnum[0],
- pos_in_item,
- tb->
- insert_size
- [0], body,
- zeros_num);
- }
-
- /* paste new entry, if item is directory item */
- pasted =
- B_N_PITEM_HEAD(tb->R[0],
- item_pos - n +
- tb->rnum[0]);
- if (is_direntry_le_ih(pasted)
- && pos_in_item >= 0) {
- leaf_paste_entries(bi.bi_bh,
- item_pos -
- n +
- tb->rnum[0],
- pos_in_item,
- 1,
- (struct
- reiserfs_de_head
- *)body,
- body +
- DEH_SIZE,
- tb->
- insert_size
- [0]
- );
- if (!pos_in_item) {
-
- RFALSE(item_pos - n +
- tb->rnum[0],
- "PAP-12165: directory item must be first item of node when pasting is in 0th position");
-
- /* update delimiting keys */
- replace_key(tb,
- tb->CFR[0],
- tb->rkey[0],
- tb->R[0],
- 0);
- }
- }
-
- if (is_indirect_le_ih(pasted))
- set_ih_free_space(pasted, 0);
- zeros_num = tb->insert_size[0] = 0;
- }
- } else { /* new item doesn't fall into R[0] */
-
- leaf_shift_right(tb, tb->rnum[0], tb->rbytes);
- }
- break;
- default: /* cases d and t */
- reiserfs_panic(tb->tb_sb, "PAP-12175",
- "rnum > 0: unexpected mode: %s(%d)",
- (flag ==
- M_DELETE) ? "DELETE" : ((flag ==
- M_CUT) ? "CUT"
- : "UNKNOWN"),
- flag);
- }
-
- }
+ if (tb->rnum[0] > 0)
+ bl_right(tb, ih, body, flag, &zeros_num, item_pos,
+ &pos_in_item);
/* tb->rnum[0] > 0 */
RFALSE(tb->blknum[0] > 3,
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 43+ messages in thread
* [patch 35/40] reiserfs: split balance_leaf new node handling out
2007-06-11 19:03 [patch 00/40] reiserfs: patch queue (v2) jeffm
` (32 preceding siblings ...)
2007-06-11 19:03 ` [patch 34/40] reiserfs: split right " jeffm
@ 2007-06-11 19:03 ` jeffm
2007-06-11 19:03 ` [patch 36/40] reiserfs: split out current node handling from balance_leaf jeffm
` (6 subsequent siblings)
40 siblings, 0 replies; 43+ messages in thread
From: jeffm @ 2007-06-11 19:03 UTC (permalink / raw)
To: ReiserFS Mailing List
[-- Attachment #1: reiserfs-split-balance_leaf-new_nodes.diff --]
[-- Type: text/plain, Size: 22557 bytes --]
This is the third in a set of 4 patches that split balance_leaf up into
a group of functions rather than the 2500 beast it once was.
This patch splits off the new node filling behavior.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
fs/reiserfs/do_balan.c | 693 +++++++++++++++++++++++--------------------------
1 file changed, 338 insertions(+), 355 deletions(-)
--- a/fs/reiserfs/do_balan.c 2007-06-11 14:49:42.000000000 -0400
+++ b/fs/reiserfs/do_balan.c 2007-06-11 14:50:00.000000000 -0400
@@ -873,6 +873,342 @@ bl_right(struct tree_balance *tb, struct
item_pos, pos_in_item);
}
+static void
+bl_new_nodes_insert(struct tree_balance *tb, struct item_head *ih,
+ const char *body, int flag,
+ struct item_head *insert_key, int *zeros_num,
+ int item_pos, int snum, int sbytes,
+ struct buffer_head *bh)
+{
+ struct buffer_head *tbS0 = PATH_PLAST_BUFFER(tb->tb_path);
+ int n = B_NR_ITEMS(tbS0);
+ struct buffer_info bi;
+ int old_key_comp, old_len, r_zeros_number;
+ const char *r_body;
+ int version;
+
+ if (n - snum >= item_pos) {
+ /* new item or it part don't falls into bh */
+ leaf_move_items(LEAF_FROM_S_TO_SNEW, tb, snum, sbytes, bh);
+ return;
+ }
+
+ if (item_pos != n - snum + 1 || sbytes == -1) {
+ /* Shift snum - 1 items to bh (sbytes of split item) */
+ leaf_move_items(LEAF_FROM_S_TO_SNEW, tb, snum - 1,
+ sbytes, bh);
+
+ /* Insert new item into bh */
+ buffer_info_init_bh(tb, &bi, bh);
+ leaf_insert_into_buf(&bi, item_pos - n + snum - 1,
+ ih, body, *zeros_num);
+
+ *zeros_num = tb->insert_size[0] = 0;
+ return;
+ }
+
+ /* new item or it's part falls to first new node bh */
+ /* part of new item falls into bh */
+
+ /* Move snum-1 items from S[0] to bh */
+ leaf_move_items(LEAF_FROM_S_TO_SNEW, tb,
+ snum - 1, -1, bh);
+
+ /* Remember key component and item length */
+ version = ih_version(ih);
+ old_key_comp = le_ih_k_offset(ih);
+ old_len = ih_item_len(ih);
+
+ /* Calculate key component and item length to
+ * insert into bh */
+ set_le_ih_k_offset(ih, le_ih_k_offset(ih) +
+ ((old_len - sbytes) <<
+ (is_indirect_le_ih
+ (ih) ? tb->tb_sb->s_blocksize_bits -
+ UNFM_P_SHIFT : 0)));
+
+ put_ih_item_len(ih, sbytes);
+
+ /* Insert part of the item into bh before 0-th item */
+ buffer_info_init_bh(tb, &bi, bh);
+
+ if ((old_len - sbytes) > *zeros_num) {
+ r_zeros_number = 0;
+ r_body = body + (old_len - sbytes) - *zeros_num;
+ } else {
+ r_body = body;
+ r_zeros_number = *zeros_num - (old_len - sbytes);
+ *zeros_num -= r_zeros_number;
+ }
+
+ leaf_insert_into_buf(&bi, 0, ih, r_body, r_zeros_number);
+
+ /* Calculate key component and item length to
+ * insert into S[i] */
+ set_le_ih_k_offset(ih, old_key_comp);
+ put_ih_item_len(ih, old_len - sbytes);
+ tb->insert_size[0] -= sbytes;
+}
+
+static void
+bl_new_nodes_paste_de_partial(struct tree_balance *tb, struct item_head *ih,
+ const char *body, int flag,
+ struct item_head *insert_key,
+ int *zeros_num, int item_pos,
+ int *pos_in_item,
+ int snum, int sbytes, struct buffer_head *bh)
+{
+ /* we append to directory item */
+ struct buffer_head *tbS0 = PATH_PLAST_BUFFER(tb->tb_path);
+ int entry_count;
+ struct buffer_info bi;
+ struct item_head *aux_ih = B_N_PITEM_HEAD(tbS0, item_pos);;
+
+ entry_count = ih_entry_count(aux_ih);
+
+ /* new directory entry doesn't fall into bh */
+ if (entry_count - sbytes >= *pos_in_item ||
+ *pos_in_item > entry_count) {
+ leaf_move_items(LEAF_FROM_S_TO_SNEW, tb,
+ snum, sbytes, bh);
+ return;
+ }
+
+ /* new directory entry falls into bh */
+ RFALSE(!tb-> insert_size[0],
+ "PAP-12215: insert_size is already 0");
+ RFALSE(sbytes - 1 >= entry_count,
+ "PAP-12220: there are no so much entries (%d), only %d",
+ sbytes - 1, entry_count);
+
+ /* Shift snum-1 items in whole. Shift
+ * sbytes directory entries from directory
+ * item number snum */
+ leaf_move_items(LEAF_FROM_S_TO_SNEW,
+ tb, snum, sbytes - 1,
+ bh);
+ /* Paste given directory entry to
+ * directory item */
+ buffer_info_init_bh(tb, &bi, bh);
+ leaf_paste_in_buffer(&bi, 0,
+ *pos_in_item - entry_count + sbytes - 1,
+ tb->insert_size[0], body, *zeros_num);
+ /* paste new directory entry */
+ leaf_paste_entries(bi.bi_bh, 0,
+ *pos_in_item - entry_count +
+ sbytes - 1, 1,
+ (struct reiserfs_de_head *)
+ body, body + DEH_SIZE,
+ tb->insert_size[0]);
+ tb->insert_size[0] = 0;
+ (*pos_in_item)++;
+}
+
+static void
+bl_new_nodes_paste_non_de_partial(struct tree_balance *tb,
+ struct item_head *ih,
+ const char *body, int flag,
+ struct item_head *insert_key,
+ int *zeros_num, int item_pos,
+ int *pos_in_item, int snum, int sbytes,
+ struct buffer_head *bh)
+{
+#ifdef CONFIG_REISERFS_CHECK
+ struct buffer_head *tbS0 = PATH_PLAST_BUFFER(tb->tb_path);
+#endif
+ int n_shift, n_rem, r_zeros_number;
+ const char *r_body;
+ struct item_head *tmp;
+ struct buffer_info bi;
+
+ RFALSE(*pos_in_item != ih_item_len(B_N_PITEM_HEAD(tbS0, item_pos))
+ || tb->insert_size[0] <= 0,
+ "PAP-12225", "item too short or insert_size <= 0");
+
+ /* Calculate number of bytes which must be shifted from appended item */
+ n_shift = sbytes - tb->insert_size[0];
+ if (n_shift < 0)
+ n_shift = 0;
+ leaf_move_items(LEAF_FROM_S_TO_SNEW, tb, snum, n_shift, bh);
+
+ /* Calculate number of bytes which must remain
+ * in body after append to bh */
+ n_rem = tb->insert_size[0] - sbytes;
+ if (n_rem < 0)
+ n_rem = 0;
+
+ /* Append part of body into bh */
+ buffer_info_init_bh(tb, &bi, bh);
+
+ if (n_rem > *zeros_num) {
+ r_zeros_number = 0;
+ r_body = body + n_rem - *zeros_num;
+ } else {
+ r_body = body;
+ r_zeros_number = *zeros_num - n_rem;
+ *zeros_num -= r_zeros_number;
+ }
+
+ leaf_paste_in_buffer(&bi, 0, n_shift, tb->insert_size[0] - n_rem,
+ r_body, r_zeros_number);
+
+ tmp = B_N_PITEM_HEAD(bh, 0);
+ if (is_indirect_le_ih(tmp)) {
+ set_ih_free_space(tmp, 0);
+ set_le_ih_k_offset(tmp, le_ih_k_offset(tmp) +
+ (n_rem << (tb->tb_sb->s_blocksize_bits - UNFM_P_SHIFT)));
+ } else {
+ set_le_ih_k_offset(tmp, le_ih_k_offset(tmp) + n_rem);
+ }
+
+ tb->insert_size[0] = n_rem;
+ if (!n_rem)
+ (*pos_in_item)++;
+}
+
+static void
+bl_new_nodes_paste_solid(struct tree_balance *tb, struct item_head *ih,
+ const char *body, int flag,
+ struct item_head *insert_key,
+ int *zeros_num, int item_pos,
+ int *pos_in_item, int snum, int sbytes,
+ struct buffer_head *bh)
+{
+ struct buffer_head *tbS0 = PATH_PLAST_BUFFER(tb->tb_path);
+ int n = B_NR_ITEMS(tbS0);
+ struct buffer_info bi;
+ struct item_head *pasted;
+ int was_copied;
+#ifdef CONFIG_REISERFS_CHECK
+ struct item_head *aux_ih = B_N_PITEM_HEAD(tbS0, item_pos);;
+
+ /* item falls wholly into bh */
+ if (!is_direntry_le_ih(aux_ih) && (*pos_in_item != ih_item_len(aux_ih)
+ || tb->insert_size[0] <= 0))
+ reiserfs_panic(tb->tb_sb, "PAP-12235", "pos_in_item must be "
+ "equal to ih_item_len");
+#endif
+
+ was_copied = leaf_move_items(LEAF_FROM_S_TO_SNEW, tb, snum,
+ sbytes, bh);
+
+ RFALSE(was_copied, "PAP-12240: unexpected value returned by "
+ "leaf_move_items (%d)", was_copied);
+
+ /* paste into item */
+ buffer_info_init_bh(tb, &bi, bh);
+ leaf_paste_in_buffer(&bi, item_pos - n + snum, *pos_in_item,
+ tb->insert_size[0], body, *zeros_num);
+
+ pasted = B_N_PITEM_HEAD(bh, item_pos - n + snum);
+ if (is_direntry_le_ih(pasted)) {
+ leaf_paste_entries(bi.bi_bh, item_pos - n + snum,
+ *pos_in_item, 1,
+ (struct reiserfs_de_head *)body,
+ body + DEH_SIZE, tb->insert_size[0]);
+ }
+
+ /* if we paste to indirect item update ih_free_space */
+ if (is_indirect_le_ih(pasted))
+ set_ih_free_space(pasted, 0);
+ *zeros_num = tb->insert_size[0] = 0;
+
+}
+
+static void
+bl_new_nodes_paste(struct tree_balance *tb, struct item_head *ih,
+ const char *body, int flag,
+ struct item_head *insert_key,
+ int *zeros_num, int item_pos,
+ int *pos_in_item, int snum, int sbytes,
+ struct buffer_head *bh)
+{
+ struct buffer_head *tbS0 = PATH_PLAST_BUFFER(tb->tb_path);
+ int n = B_NR_ITEMS(tbS0);
+ struct item_head *aux_ih = B_N_PITEM_HEAD(tbS0, item_pos);;
+
+ /* pasted item doesn't fall into bh */
+ if (n - snum > item_pos) {
+ leaf_move_items(LEAF_FROM_S_TO_SNEW, tb, snum, sbytes, bh);
+ return;
+ }
+ /* pasted item or part if it falls to bh */
+ /* we must shift part of the appended item */
+ if (item_pos == n - snum && sbytes != -1) {
+ RFALSE(ih, "PAP-12210: ih must be 0");
+
+ if (is_direntry_le_ih(aux_ih))
+ bl_new_nodes_paste_de_partial(tb, ih, body, flag,
+ insert_key, zeros_num,
+ item_pos, pos_in_item,
+ snum, sbytes, bh);
+ else
+ bl_new_nodes_paste_non_de_partial(tb, ih, body, flag,
+ insert_key,
+ zeros_num, item_pos,
+ pos_in_item, snum,
+ sbytes, bh);
+ } else {
+ bl_new_nodes_paste_solid(tb, ih, body, flag, insert_key,
+ zeros_num, item_pos, pos_in_item,
+ snum, sbytes, bh);
+ }
+}
+
+/* @snum: number of items that will be placed into bh
+ * (includes partially shifted items)
+ * @sbytes: if an item is partially shifted into bh then
+ * if it is a directory item:
+ * it is the number of entries from the item that are
+ * shifted into bh
+ * else
+ * it is the number of bytes from the item that are
+ * shifted into bh
+ */
+static void
+bl_new_nodes(struct tree_balance *tb, struct item_head *ih,
+ const char *body, int flag,
+ struct item_head *insert_key,
+ struct buffer_head **insert_ptr, int *zeros_num,
+ int item_pos, int *pos_in_item)
+{
+ int i;
+
+ BUG_ON(flag != M_INSERT && flag != M_PASTE);
+
+ /* Fill new nodes that appear in place of S[0] */
+ for (i = tb->blknum[0] - 2; i >= 0; i--) {
+ struct buffer_head *bh;
+ RFALSE(!tb->snum[i], "PAP-12200: snum[%d] == %d. Must be > 0",
+ i, tb->snum[i]);
+
+ /* Use new node since it won't fit in S */
+ bh = get_FEB(tb);
+
+ /* initialized block type and tree level */
+ set_blkh_level(B_BLK_HEAD(bh), DISK_LEAF_NODE_LEVEL);
+
+ if (flag == M_INSERT)
+ bl_new_nodes_insert(tb, ih, body, flag,
+ insert_key, zeros_num,
+ item_pos, tb->snum[i],
+ tb->sbytes[i], bh);
+ else
+ bl_new_nodes_paste(tb, ih, body, flag,
+ insert_key, zeros_num,
+ item_pos, pos_in_item,
+ tb->snum[i],
+ tb->sbytes[i], bh);
+
+ memcpy(insert_key + i, B_N_PKEY(bh, 0), KEY_SIZE);
+ insert_ptr[i] = bh;
+
+ RFALSE(!buffer_journaled(bh)
+ || buffer_journal_dirty(bh)
+ || buffer_dirty(bh),
+ "PAP-12247: bad state for new buffer : (%b)", bh);
+ }
+}
static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item header of inserted item (this is on little endian) */
const char *body, /* body of inserted item or bytes to paste */
@@ -889,8 +1225,6 @@ static int balance_leaf(struct tree_bala
int item_pos = PATH_LAST_POSITION(tb->tb_path); /* index into the array of item headers in S[0]
of the affected item */
struct buffer_info bi;
- struct buffer_head *S_new[2]; /* new nodes allocated to hold what could not fit into S */
- int n, i;
int pos_in_item;
int zeros_num;
@@ -953,359 +1287,8 @@ static int balance_leaf(struct tree_bala
return 0;
}
- /* Fill new nodes that appear in place of S[0] */
- for (i = tb->blknum[0] - 2; i >= 0; i--) {
-
- RFALSE(!tb->snum[i], "PAP-12200: tb->snum[%d] == %d. Must be > 0", i,
- tb->snum[i]);
-
- /* here we shift from S to S_new nodes */
-
- S_new[i] = get_FEB(tb);
-
- /* initialized block type and tree level */
- set_blkh_level(B_BLK_HEAD(S_new[i]), DISK_LEAF_NODE_LEVEL);
-
- n = B_NR_ITEMS(tbS0);
-
- switch (flag) {
- case M_INSERT: /* insert item */
-
- if (n - tb->snum[i] < item_pos) { /* new item or it's part falls to first new node S_new[i] */
- if (item_pos == n - tb->snum[i] + 1 && tb->sbytes[i] != -1) { /* part of new item falls into S_new[i] */
- int old_key_comp, old_len,
- r_zeros_number;
- const char *r_body;
- int version;
-
- /* Move tb->snum[i]-1 items from S[0] to S_new[i] */
- leaf_move_items(LEAF_FROM_S_TO_SNEW, tb,
- tb->snum[i] - 1, -1,
- S_new[i]);
- /* Remember key component and item length */
- version = ih_version(ih);
- old_key_comp = le_ih_k_offset(ih);
- old_len = ih_item_len(ih);
-
- /* Calculate key component and item length to insert into S_new[i] */
- set_le_ih_k_offset(ih,
- le_ih_k_offset(ih) +
- ((old_len -
- tb->sbytes[i]) <<
- (is_indirect_le_ih
- (ih) ? tb->tb_sb->
- s_blocksize_bits -
- UNFM_P_SHIFT :
- 0)));
-
- put_ih_item_len(ih, tb->sbytes[i]);
-
- /* Insert part of the item into S_new[i] before 0-th item */
- buffer_info_init_bh(tb, &bi, S_new[i]);
-
- if ((old_len - tb->sbytes[i]) > zeros_num) {
- r_zeros_number = 0;
- r_body =
- body + (old_len -
- tb->sbytes[i]) -
- zeros_num;
- } else {
- r_body = body;
- r_zeros_number =
- zeros_num - (old_len -
- tb->sbytes[i]);
- zeros_num -= r_zeros_number;
- }
-
- leaf_insert_into_buf(&bi, 0, ih, r_body,
- r_zeros_number);
-
- /* Calculate key component and item length to insert into S[i] */
- set_le_ih_k_offset(ih, old_key_comp);
- put_ih_item_len(ih,
- old_len - tb->sbytes[i]);
- tb->insert_size[0] -= tb->sbytes[i];
- } else { /* whole new item falls into S_new[i] */
-
- /* Shift tb->snum[0] - 1 items to S_new[i] (tb->sbytes[i] of split item) */
- leaf_move_items(LEAF_FROM_S_TO_SNEW, tb,
- tb->snum[i] - 1, tb->sbytes[i],
- S_new[i]);
-
- /* Insert new item into S_new[i] */
- buffer_info_init_bh(tb, &bi, S_new[i]);
- leaf_insert_into_buf(&bi,
- item_pos - n +
- tb->snum[i] - 1, ih,
- body, zeros_num);
-
- zeros_num = tb->insert_size[0] = 0;
- }
- }
-
- else { /* new item or it part don't falls into S_new[i] */
-
- leaf_move_items(LEAF_FROM_S_TO_SNEW, tb,
- tb->snum[i], tb->sbytes[i], S_new[i]);
- }
- break;
-
- case M_PASTE: /* append item */
-
- if (n - tb->snum[i] <= item_pos) { /* pasted item or part if it falls to S_new[i] */
- if (item_pos == n - tb->snum[i] && tb->sbytes[i] != -1) { /* we must shift part of the appended item */
- struct item_head *aux_ih;
-
- RFALSE(ih, "PAP-12210: ih must be 0");
-
- if (is_direntry_le_ih
- (aux_ih =
- B_N_PITEM_HEAD(tbS0, item_pos))) {
- /* we append to directory item */
-
- int entry_count;
-
- entry_count =
- ih_entry_count(aux_ih);
-
- if (entry_count - tb->sbytes[i] <
- pos_in_item
- && pos_in_item <=
- entry_count) {
- /* new directory entry falls into S_new[i] */
-
- RFALSE(!tb->
- insert_size[0],
- "PAP-12215: insert_size is already 0");
- RFALSE(tb->sbytes[i] - 1 >=
- entry_count,
- "PAP-12220: there are no so much entries (%d), only %d",
- tb->sbytes[i] - 1,
- entry_count);
-
- /* Shift tb->snum[i]-1 items in whole. Shift tb->sbytes[i] directory entries from directory item number tb->snum[i] */
- leaf_move_items
- (LEAF_FROM_S_TO_SNEW,
- tb, tb->snum[i],
- tb->sbytes[i] - 1,
- S_new[i]);
- /* Paste given directory entry to directory item */
- buffer_info_init_bh(tb, &bi, S_new[i]);
- leaf_paste_in_buffer
- (&bi, 0,
- pos_in_item -
- entry_count +
- tb->sbytes[i] - 1,
- tb->insert_size[0],
- body, zeros_num);
- /* paste new directory entry */
- leaf_paste_entries(bi.
- bi_bh,
- 0,
- pos_in_item
- -
- entry_count
- +
- tb->sbytes
- [i] -
- 1, 1,
- (struct
- reiserfs_de_head
- *)
- body,
- body
- +
- DEH_SIZE,
- tb->
- insert_size
- [0]
- );
- tb->insert_size[0] = 0;
- pos_in_item++;
- } else { /* new directory entry doesn't fall into S_new[i] */
- leaf_move_items
- (LEAF_FROM_S_TO_SNEW,
- tb, tb->snum[i],
- tb->sbytes[i],
- S_new[i]);
- }
- } else { /* regular object */
-
- int n_shift, n_rem,
- r_zeros_number;
- const char *r_body;
-
- RFALSE(pos_in_item !=
- ih_item_len
- (B_N_PITEM_HEAD
- (tbS0, item_pos))
- || tb->insert_size[0] <=
- 0,
- "PAP-12225: item too short or insert_size <= 0");
-
- /* Calculate number of bytes which must be shifted from appended item */
- n_shift =
- tb->sbytes[i] -
- tb->insert_size[0];
- if (n_shift < 0)
- n_shift = 0;
- leaf_move_items
- (LEAF_FROM_S_TO_SNEW, tb,
- tb->snum[i], n_shift,
- S_new[i]);
-
- /* Calculate number of bytes which must remain in body after append to S_new[i] */
- n_rem =
- tb->insert_size[0] -
- tb->sbytes[i];
- if (n_rem < 0)
- n_rem = 0;
- /* Append part of body into S_new[0] */
- buffer_info_init_bh(tb, &bi, S_new[i]);
- if (n_rem > zeros_num) {
- r_zeros_number = 0;
- r_body =
- body + n_rem -
- zeros_num;
- } else {
- r_body = body;
- r_zeros_number =
- zeros_num - n_rem;
- zeros_num -=
- r_zeros_number;
- }
-
- leaf_paste_in_buffer(&bi, 0,
- n_shift,
- tb->
- insert_size
- [0] -
- n_rem,
- r_body,
- r_zeros_number);
- {
- struct item_head *tmp;
-
- tmp =
- B_N_PITEM_HEAD(S_new
- [i],
- 0);
- if (is_indirect_le_ih
- (tmp)) {
- set_ih_free_space
- (tmp, 0);
- set_le_ih_k_offset
- (tmp,
- le_ih_k_offset
- (tmp) +
- (n_rem <<
- (tb->
- tb_sb->
- s_blocksize_bits
- -
- UNFM_P_SHIFT)));
- } else {
- set_le_ih_k_offset
- (tmp,
- le_ih_k_offset
- (tmp) +
- n_rem);
- }
- }
-
- tb->insert_size[0] = n_rem;
- if (!n_rem)
- pos_in_item++;
- }
- } else
- /* item falls wholly into S_new[i] */
- {
- int ret_val;
- struct item_head *pasted;
-
-#ifdef CONFIG_REISERFS_CHECK
- struct item_head *ih =
- B_N_PITEM_HEAD(tbS0, item_pos);
-
- if (!is_direntry_le_ih(ih)
- && (pos_in_item != ih_item_len(ih)
- || tb->insert_size[0] <= 0))
- reiserfs_panic(tb->tb_sb,
- "PAP-12235",
- "pos_in_item must be equal to ih_item_len");
-#endif /* CONFIG_REISERFS_CHECK */
-
- ret_val =
- leaf_move_items(LEAF_FROM_S_TO_SNEW,
- tb, tb->snum[i],
- tb->sbytes[i],
- S_new[i]);
-
- RFALSE(ret_val,
- "PAP-12240: unexpected value returned by leaf_move_items (%d)",
- ret_val);
-
- /* paste into item */
- buffer_info_init_bh(tb, &bi, S_new[i]);
- leaf_paste_in_buffer(&bi,
- item_pos - n +
- tb->snum[i],
- pos_in_item,
- tb->insert_size[0],
- body, zeros_num);
-
- pasted =
- B_N_PITEM_HEAD(S_new[i],
- item_pos - n +
- tb->snum[i]);
- if (is_direntry_le_ih(pasted)) {
- leaf_paste_entries(bi.bi_bh,
- item_pos -
- n + tb->snum[i],
- pos_in_item,
- 1,
- (struct
- reiserfs_de_head
- *)body,
- body +
- DEH_SIZE,
- tb->
- insert_size
- [0]
- );
- }
-
- /* if we paste to indirect item update ih_free_space */
- if (is_indirect_le_ih(pasted))
- set_ih_free_space(pasted, 0);
- zeros_num = tb->insert_size[0] = 0;
- }
- }
-
- else { /* pasted item doesn't fall into S_new[i] */
-
- leaf_move_items(LEAF_FROM_S_TO_SNEW, tb,
- tb->snum[i], tb->sbytes[i], S_new[i]);
- }
- break;
- default: /* cases d and t */
- reiserfs_panic(tb->tb_sb, "PAP-12245",
- "blknum > 2: unexpected mode: %s(%d)",
- (flag ==
- M_DELETE) ? "DELETE" : ((flag ==
- M_CUT) ? "CUT"
- : "UNKNOWN"),
- flag);
- }
-
- memcpy(insert_key + i, B_N_PKEY(S_new[i], 0), KEY_SIZE);
- insert_ptr[i] = S_new[i];
-
- RFALSE(!buffer_journaled(S_new[i])
- || buffer_journal_dirty(S_new[i])
- || buffer_dirty(S_new[i]), "PAP-12247: S_new[%d] : (%b)",
- i, S_new[i]);
- }
+ bl_new_nodes(tb, ih, body, flag, insert_key, insert_ptr,
+ &zeros_num, item_pos, &pos_in_item);
/* if the affected item was not wholly shifted then we perform all necessary operations on that part or whole of the
affected item which remains in S */
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 43+ messages in thread
* [patch 36/40] reiserfs: split out current node handling from balance_leaf
2007-06-11 19:03 [patch 00/40] reiserfs: patch queue (v2) jeffm
` (33 preceding siblings ...)
2007-06-11 19:03 ` [patch 35/40] reiserfs: split balance_leaf new node handling out jeffm
@ 2007-06-11 19:03 ` jeffm
2007-06-11 19:03 ` [patch 37/40] reiserfs: clean up bl_when_delete jeffm
` (5 subsequent siblings)
40 siblings, 0 replies; 43+ messages in thread
From: jeffm @ 2007-06-11 19:03 UTC (permalink / raw)
To: ReiserFS Mailing List
[-- Attachment #1: reiserfs-split-balance_leaf-remainder.diff --]
[-- Type: text/plain, Size: 9950 bytes --]
This is the last in a set of 4 patches that split balance_leaf up into
a group of functions rather than the 2500 beast it once was.
This patch splits off the current node balancing behavior.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
fs/reiserfs/do_balan.c | 273 +++++++++++++++++++++++++------------------------
1 file changed, 142 insertions(+), 131 deletions(-)
--- a/fs/reiserfs/do_balan.c 2007-06-11 14:49:42.000000000 -0400
+++ b/fs/reiserfs/do_balan.c 2007-06-11 14:50:00.000000000 -0400
@@ -1210,6 +1210,146 @@ bl_new_nodes(struct tree_balance *tb, st
}
}
+/* insert item into S[0] */
+static void
+bl_current_node_insert(struct tree_balance *tb, struct item_head *ih,
+ const char *body, int flag, int zeros_num,
+ int item_pos)
+{
+ struct buffer_info bi;
+ struct buffer_head *tbS0 = PATH_PLAST_BUFFER(tb->tb_path);
+ buffer_info_init_tbS0(tb, &bi);
+ leaf_insert_into_buf(&bi, item_pos, ih, body, zeros_num);
+
+ /* If we insert the first key change the delimiting key */
+ /* CFL[0] can be 0 in reiserfsck */
+ if (item_pos == 0 && tb->CFL[0])
+ replace_key(tb, tb->CFL[0], tb->lkey[0], tbS0, 0);
+}
+
+static void
+bl_current_node_paste_de_partial(struct tree_balance *tb,
+ struct item_head *ih, const char *body,
+ int flag, int zeros_num, int item_pos,
+ int pos_in_item)
+{
+ struct buffer_head *tbS0 = PATH_PLAST_BUFFER(tb->tb_path);
+ struct item_head *pasted = B_N_PITEM_HEAD(tbS0, item_pos);
+ struct buffer_info bi;
+
+ if (pos_in_item < 0 || pos_in_item > ih_entry_count(pasted))
+ return;
+
+ RFALSE(!tb->insert_size[0],
+ "PAP-12260: insert_size is 0 already");
+
+ /* prepare space */
+ buffer_info_init_tbS0(tb, &bi);
+ leaf_paste_in_buffer(&bi, item_pos, pos_in_item, tb->insert_size[0],
+ body, zeros_num);
+
+ /* paste entry */
+ leaf_paste_entries(bi.bi_bh, item_pos, pos_in_item, 1,
+ (struct reiserfs_de_head *)body, body + DEH_SIZE,
+ tb->insert_size[0]);
+
+ if (!item_pos && !pos_in_item) {
+ RFALSE(!tb->CFL[0] || !tb->L[0],
+ "PAP-12270: CFL[0]/L[0] must be specified");
+ if (tb->CFL[0])
+ replace_key(tb, tb->CFL[0], tb->lkey[0], tbS0, 0);
+ }
+ tb->insert_size[0] = 0;
+}
+
+static void
+bl_current_node_paste_non_de_partial(struct tree_balance *tb,
+ struct item_head *ih,
+ const char *body, int flag,
+ int zeros_num, int item_pos,
+ int pos_in_item)
+{
+ struct buffer_head *tbS0 = PATH_PLAST_BUFFER(tb->tb_path);
+ struct item_head *pasted = B_N_PITEM_HEAD(tbS0, item_pos);
+ struct buffer_info bi;
+
+#ifdef CONFIG_REISERFS_CHECK
+ if (pos_in_item != ih_item_len(pasted)) {
+ if (tb->insert_size[0]) {
+ print_cur_tb("12285");
+ reiserfs_panic(tb->tb_sb, "PAP-12285",
+ "insert_size must be 0 (%d)",
+ tb->insert_size[0]);
+ }
+ return;
+ }
+#endif
+ RFALSE(tb->insert_size[0] <= 0,
+ "PAP-12275: insert size must not be %d", tb->insert_size[0]);
+ buffer_info_init_tbS0(tb, &bi);
+ leaf_paste_in_buffer(&bi, item_pos, pos_in_item, tb->insert_size[0],
+ body, zeros_num);
+
+ if (is_indirect_le_ih(pasted)) {
+#if 0
+ RFALSE(tb->insert_size[0] != UNFM_P_SIZE, "PAP-12280",
+ "insert_size for indirect item must be %d, not %d",
+ UNFM_P_SIZE, tb->insert_size[0]);
+#endif
+ set_ih_free_space (pasted, 0);
+ }
+ tb->insert_size[0] = 0;
+}
+
+static void
+bl_current_node_paste(struct tree_balance *tb, struct item_head *ih,
+ const char *body, int flag, int zeros_num,
+ int item_pos, int pos_in_item)
+{
+ struct buffer_head *tbS0 = PATH_PLAST_BUFFER(tb->tb_path);
+ struct item_head *pasted = B_N_PITEM_HEAD(tbS0, item_pos);
+ /* when directory, may be new entry already pasted */
+ if (is_direntry_le_ih(pasted))
+ bl_current_node_paste_de_partial(tb, ih, body, flag,
+ zeros_num, item_pos,
+ pos_in_item);
+ else
+ bl_current_node_paste_non_de_partial(tb, ih, body, flag,
+ zeros_num, item_pos,
+ pos_in_item);
+#ifdef CONFIG_REISERFS_CHECK
+ if (tb->insert_size[0]) {
+ print_cur_tb("12290");
+ reiserfs_panic(tb->tb_sb,
+ "PAP-12290", "insert_size is still not 0 (%d)",
+ tb->insert_size[0]);
+ }
+#endif /* CONFIG_REISERFS_CHECK */
+}
+
+/* If the affected item was not wholly shifted then we perform all
+ * necessary operations on that part or whole of the affected item
+ * which remains in S */
+static void
+bl_current_node(struct tree_balance *tb, struct item_head *ih,
+ const char *body, int flag, int zeros_num, int item_pos,
+ int pos_in_item)
+{
+ BUG_ON(flag != M_INSERT && flag != M_PASTE);
+
+ /* if we must insert or append into buffer S[0] */
+ if (item_pos < 0 || item_pos >= tb->s0num)
+ return;
+
+ if (flag == M_INSERT)
+ bl_current_node_insert(tb, ih, body, flag, zeros_num,
+ item_pos);
+ else
+ bl_current_node_paste(tb, ih, body, flag, zeros_num,
+ item_pos, pos_in_item);
+}
+
+
static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item header of inserted item (this is on little endian) */
const char *body, /* body of inserted item or bytes to paste */
int flag, /* i - insert, d - delete, c - cut, p - paste
@@ -1224,7 +1364,6 @@ static int balance_leaf(struct tree_bala
struct buffer_head *tbS0 = PATH_PLAST_BUFFER(tb->tb_path);
int item_pos = PATH_LAST_POSITION(tb->tb_path); /* index into the array of item headers in S[0]
of the affected item */
- struct buffer_info bi;
int pos_in_item;
int zeros_num;
@@ -1290,137 +1429,9 @@ static int balance_leaf(struct tree_bala
bl_new_nodes(tb, ih, body, flag, insert_key, insert_ptr,
&zeros_num, item_pos, &pos_in_item);
- /* if the affected item was not wholly shifted then we perform all necessary operations on that part or whole of the
- affected item which remains in S */
- if (0 <= item_pos && item_pos < tb->s0num) { /* if we must insert or append into buffer S[0] */
-
- switch (flag) {
- case M_INSERT: /* insert item into S[0] */
- buffer_info_init_tbS0(tb, &bi);
- leaf_insert_into_buf(&bi, item_pos, ih, body,
- zeros_num);
-
- /* If we insert the first key change the delimiting key */
- if (item_pos == 0) {
- if (tb->CFL[0]) /* can be 0 in reiserfsck */
- replace_key(tb, tb->CFL[0], tb->lkey[0],
- tbS0, 0);
-
- }
- break;
+ bl_current_node(tb, ih, body, flag, zeros_num, item_pos,
+ pos_in_item);
- case M_PASTE:{ /* append item in S[0] */
- struct item_head *pasted;
-
- pasted = B_N_PITEM_HEAD(tbS0, item_pos);
- /* when directory, may be new entry already pasted */
- if (is_direntry_le_ih(pasted)) {
- if (pos_in_item >= 0 &&
- pos_in_item <=
- ih_entry_count(pasted)) {
-
- RFALSE(!tb->insert_size[0],
- "PAP-12260: insert_size is 0 already");
-
- /* prepare space */
- buffer_info_init_tbS0(tb, &bi);
- leaf_paste_in_buffer(&bi,
- item_pos,
- pos_in_item,
- tb->
- insert_size
- [0], body,
- zeros_num);
-
- /* paste entry */
- leaf_paste_entries(bi.bi_bh,
- item_pos,
- pos_in_item,
- 1,
- (struct
- reiserfs_de_head
- *)body,
- body +
- DEH_SIZE,
- tb->
- insert_size
- [0]
- );
- if (!item_pos && !pos_in_item) {
- RFALSE(!tb->CFL[0]
- || !tb->L[0],
- "PAP-12270: CFL[0]/L[0] must be specified");
- if (tb->CFL[0]) {
- replace_key(tb,
- tb->
- CFL
- [0],
- tb->
- lkey
- [0],
- tbS0,
- 0);
-
- }
- }
- tb->insert_size[0] = 0;
- }
- } else { /* regular object */
- if (pos_in_item == ih_item_len(pasted)) {
-
- RFALSE(tb->insert_size[0] <= 0,
- "PAP-12275: insert size must not be %d",
- tb->insert_size[0]);
- buffer_info_init_tbS0(tb, &bi);
- leaf_paste_in_buffer(&bi,
- item_pos,
- pos_in_item,
- tb->
- insert_size
- [0], body,
- zeros_num);
-
- if (is_indirect_le_ih(pasted)) {
-#if 0
- RFALSE(tb->
- insert_size[0] !=
- UNFM_P_SIZE,
- "PAP-12280: insert_size for indirect item must be %d, not %d",
- UNFM_P_SIZE,
- tb->
- insert_size[0]);
-#endif
- set_ih_free_space
- (pasted, 0);
- }
- tb->insert_size[0] = 0;
- }
-#ifdef CONFIG_REISERFS_CHECK
- else {
- if (tb->insert_size[0]) {
- print_cur_tb("12285");
- reiserfs_panic(tb->
- tb_sb,
- "PAP-12285", "insert_size must be 0 (%d)",
- tb->
- insert_size
- [0]);
- }
- }
-#endif /* CONFIG_REISERFS_CHECK */
-
- }
- } /* case M_PASTE: */
- }
- }
-#ifdef CONFIG_REISERFS_CHECK
- if (flag == M_PASTE && tb->insert_size[0]) {
- print_cur_tb("12290");
- reiserfs_panic(tb->tb_sb,
- "PAP-12290", "insert_size is still not 0 (%d)",
- tb->insert_size[0]);
- }
-#endif /* CONFIG_REISERFS_CHECK */
return 0;
} /* Leaf level of the tree is balanced (end of balance_leaf) */
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 43+ messages in thread
* [patch 37/40] reiserfs: clean up bl_when_delete
2007-06-11 19:03 [patch 00/40] reiserfs: patch queue (v2) jeffm
` (34 preceding siblings ...)
2007-06-11 19:03 ` [patch 36/40] reiserfs: split out current node handling from balance_leaf jeffm
@ 2007-06-11 19:03 ` jeffm
2007-06-11 19:03 ` [patch 38/40] reiserfs: clean up balancing modes jeffm
` (4 subsequent siblings)
40 siblings, 0 replies; 43+ messages in thread
From: jeffm @ 2007-06-11 19:03 UTC (permalink / raw)
To: ReiserFS Mailing List
[-- Attachment #1: reiserfs-split-balance_leaf.diff --]
[-- Type: text/plain, Size: 3449 bytes --]
Signed-off-by: Jeff Mahoney <jeffm@suse.com.
---
fs/reiserfs/do_balan.c | 71 ++++++++++++++++++++++---------------------------
1 file changed, 33 insertions(+), 38 deletions(-)
--- a/fs/reiserfs/do_balan.c 2007-06-11 14:49:42.000000000 -0400
+++ b/fs/reiserfs/do_balan.c 2007-06-11 14:49:59.000000000 -0400
@@ -115,6 +115,13 @@ static int balance_leaf_when_delete(stru
int n;
struct item_head *ih;
+ if (flag != M_DELETE && flag != M_CUT) {
+ print_cur_tb("12040");
+ reiserfs_panic(tb->tb_sb, "PAP-12040",
+ "unexpected mode: %s(%d)",
+ tb_mode_names(flag), flag);
+ }
+
RFALSE(tb->FR[0] && B_LEVEL(tb->FR[0]) != DISK_LEAF_NODE_LEVEL + 1,
"vs- 12000: level: wrong FR %z", tb->FR[0]);
RFALSE(tb->blknum[0] > 1,
@@ -127,9 +134,7 @@ static int balance_leaf_when_delete(stru
/* Delete or truncate the item */
- switch (flag) {
- case M_DELETE: /* delete item in S[0] */
-
+ if (flag == M_DELETE) {
RFALSE(ih_item_len(ih) + IH_SIZE != -tb->insert_size[0],
"vs-12013: mode Delete, insert size %d, ih to be deleted %h",
-tb->insert_size[0], ih);
@@ -151,44 +156,34 @@ static int balance_leaf_when_delete(stru
RFALSE(!item_pos && !tb->CFL[0],
"PAP-12020: tb->CFL[0]==%p, tb->L[0]==%p", tb->CFL[0],
tb->L[0]);
+ } else { /* M_CUT */
+ if (is_direntry_le_ih(ih)) {
- break;
-
- case M_CUT:{ /* cut item in S[0] */
- if (is_direntry_le_ih(ih)) {
-
- /* UFS unlink semantics are such that you can only delete one directory entry at a time. */
- /* when we cut a directory tb->insert_size[0] means number of entries to be cut (always 1) */
- tb->insert_size[0] = -1;
- leaf_cut_from_buffer(&bi, item_pos, pos_in_item,
- -tb->insert_size[0]);
-
- RFALSE(!item_pos && !pos_in_item && !tb->CFL[0],
- "PAP-12030: can not change delimiting key. CFL[0]=%p",
- tb->CFL[0]);
-
- if (!item_pos && !pos_in_item && tb->CFL[0]) {
- replace_key(tb, tb->CFL[0], tb->lkey[0],
- tbS0, 0);
- }
- } else {
- leaf_cut_from_buffer(&bi, item_pos, pos_in_item,
- -tb->insert_size[0]);
-
- RFALSE(!ih_item_len(ih),
- "PAP-12035: cut must leave non-zero dynamic length of item");
+ /* UFS unlink semantics are such that
+ * you can only delete one directory entry
+ * at a time. */
+ /* when we cut a directory tb->insert_size[0]
+ * means number of entries to be cut
+ * (always 1) */
+ tb->insert_size[0] = -1;
+ leaf_cut_from_buffer(&bi, item_pos, pos_in_item,
+ -tb->insert_size[0]);
+
+ RFALSE(!item_pos && !pos_in_item && !tb->CFL[0],
+ "PAP-12030: can not change delimiting key. CFL[0]=%p",
+ tb->CFL[0]);
+
+ if (!item_pos && !pos_in_item && tb->CFL[0]) {
+ replace_key(tb, tb->CFL[0], tb->lkey[0],
+ tbS0, 0);
}
- break;
- }
+ } else {
+ leaf_cut_from_buffer(&bi, item_pos, pos_in_item,
+ -tb->insert_size[0]);
- default:
- print_cur_tb("12040");
- reiserfs_panic(tb->tb_sb, "PAP-12040",
- "unexpected mode: %s(%d)",
- (flag ==
- M_PASTE) ? "PASTE" : ((flag ==
- M_INSERT) ? "INSERT" :
- "UNKNOWN"), flag);
+ RFALSE(!ih_item_len(ih), "PAP-12035: cut must "
+ "leave non-zero dynamic length of item");
+ }
}
/* the rule is that no shifting occurs unless by shifting a node can be freed */
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 43+ messages in thread
* [patch 38/40] reiserfs: clean up balancing modes
2007-06-11 19:03 [patch 00/40] reiserfs: patch queue (v2) jeffm
` (35 preceding siblings ...)
2007-06-11 19:03 ` [patch 37/40] reiserfs: clean up bl_when_delete jeffm
@ 2007-06-11 19:03 ` jeffm
2007-06-11 19:03 ` [patch 39/40] reiserfs: split bl_when_delete jeffm
` (3 subsequent siblings)
40 siblings, 0 replies; 43+ messages in thread
From: jeffm @ 2007-06-11 19:03 UTC (permalink / raw)
To: ReiserFS Mailing List
[-- Attachment #1: reiserfs-cleanup-balancing-modes.diff --]
[-- Type: text/plain, Size: 2824 bytes --]
This patch turns the character balancing modes into an enum, since the
letter itself is irrelevant.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
fs/reiserfs/prints.c | 17 +++++++++++++++++
include/linux/reiserfs_fs.h | 34 ++++++++++++++++------------------
2 files changed, 33 insertions(+), 18 deletions(-)
--- a/fs/reiserfs/prints.c 2007-06-11 14:49:41.000000000 -0400
+++ b/fs/reiserfs/prints.c 2007-06-11 14:49:43.000000000 -0400
@@ -14,6 +14,23 @@ static char error_buf[1024];
static char fmt_buf[1024];
static char off_buf[80];
+const char *tb_mode_names(enum tb_modes mode)
+{
+ char * const names[] = {
+ "INSERT",
+ "PASTE",
+ "DELETE",
+ "CUT",
+ "INTERNAL",
+ "SKIP_BALANCING",
+ "CONVERT",
+ };
+
+ if (mode >= M_MAX_MODES)
+ return "UNKNOWN";
+ return names[mode];
+}
+
static char *reiserfs_cpu_offset(struct cpu_key *key)
{
if (cpu_key_k_type(key) == TYPE_DIRENTRY)
--- a/include/linux/reiserfs_fs.h 2007-06-11 14:49:41.000000000 -0400
+++ b/include/linux/reiserfs_fs.h 2007-06-11 14:49:43.000000000 -0400
@@ -1388,27 +1388,24 @@ struct tree_balance {
struct in_core_key key; /* key pointer, to pass to block allocator or
another low-level subsystem */
#endif
+ struct bl_context *context;
};
/* These are modes of balancing */
-
-/* When inserting an item. */
-#define M_INSERT 'i'
-/* When inserting into (directories only) or appending onto an already
- existant item. */
-#define M_PASTE 'p'
-/* When deleting an item. */
-#define M_DELETE 'd'
-/* When truncating an item or removing an entry from a (directory) item. */
-#define M_CUT 'c'
-
-/* used when balancing on leaf level skipped (in reiserfsck) */
-#define M_INTERNAL 'n'
-
-/* When further balancing is not needed, then do_balance does not need
- to be called. */
-#define M_SKIP_BALANCING 's'
-#define M_CONVERT 'v'
+enum tb_modes {
+ M_INSERT = 0, /* When inserting an item. */
+ M_PASTE, /* When inserting into (directories only) or
+ * appending onto an already existant item. */
+ M_DELETE, /* When deleting an item. */
+ M_CUT, /* When truncating an item or removing an entry
+ * from a (directory) item. */
+ M_INTERNAL, /* used when balancing on leaf level
+ * skipped (in reiserfsck) */
+ M_SKIP_BALANCING, /* When further balancing is not needed,
+ * then do_balance does not need to be called. */
+ M_CONVERT,
+ M_MAX_MODES
+};
/* modes of leaf_move_items */
#define LEAF_FROM_S_TO_L 0
@@ -2027,6 +2024,7 @@ void check_leaf(struct buffer_head *bh);
void check_internal(struct buffer_head *bh);
void print_statistics(struct super_block *s);
char *reiserfs_hashname(int code);
+const char *tb_mode_names(enum tb_modes);
/* lbalance.c */
int leaf_move_items(int shift_mode, struct tree_balance *tb, int mov_num,
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 43+ messages in thread
* [patch 39/40] reiserfs: split bl_when_delete
2007-06-11 19:03 [patch 00/40] reiserfs: patch queue (v2) jeffm
` (36 preceding siblings ...)
2007-06-11 19:03 ` [patch 38/40] reiserfs: clean up balancing modes jeffm
@ 2007-06-11 19:03 ` jeffm
2007-06-11 19:03 ` [patch 40/40] reiserfs: reorganize do_balan.c comments jeffm
` (2 subsequent siblings)
40 siblings, 0 replies; 43+ messages in thread
From: jeffm @ 2007-06-11 19:03 UTC (permalink / raw)
To: ReiserFS Mailing List
[-- Attachment #1: reiserfs-balance_leaf_when_cut_or_delete.diff --]
[-- Type: text/plain, Size: 8601 bytes --]
This patch splits bl_when_delete into two functions so that
it is more easily readable.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
fs/reiserfs/do_balan.c | 147 +++++++++++++++++++++++++------------------------
1 file changed, 77 insertions(+), 70 deletions(-)
--- a/fs/reiserfs/do_balan.c 2007-06-11 14:49:42.000000000 -0400
+++ b/fs/reiserfs/do_balan.c 2007-06-11 14:49:59.000000000 -0400
@@ -9,7 +9,7 @@
/* and using buffers obtained after all above. */
/**
- ** balance_leaf_when_delete
+ ** bl_when_delete
** balance_leaf
** do_balance
**
@@ -78,7 +78,7 @@ inline void do_balance_mark_leaf_dirty(s
/* summary:
if deleting something ( tb->insert_size[0] < 0 )
- return(balance_leaf_when_delete()); (flag d handled here)
+ return(bl_when_delete()); (flag d handled here)
else
if lnum is larger than 0 we put items into the left node
if rnum is larger than 0 we put items into the right node
@@ -88,7 +88,7 @@ Note that all *num* count new items bein
It would be easier to read balance_leaf() if each of these summary
lines was a separate procedure rather than being inlined. I think
-that there are many passages here and in balance_leaf_when_delete() in
+that there are many passages here and in bl_when_delete() in
which two calls to one procedure can replace two passages, and it
might save cache space and improve software maintenance costs to do so.
@@ -99,6 +99,54 @@ be performed by do_balance.
-Hans */
+/* L[0] must be joined with S[0] */
+static int bl_delete_merge_left(struct tree_balance *tb)
+{
+ struct buffer_head *tbS0 = PATH_PLAST_BUFFER(tb->tb_path);
+ int n = B_NR_ITEMS(tbS0);
+
+ /* R[0] must be also joined with S[0] */
+ if (tb->rnum[0] == -1) {
+ if (tb->FR[0] == PATH_H_PPARENT(tb->tb_path, 0)) {
+ /* all contents of all the 3 buffers will be in L[0] */
+ if (PATH_H_POSITION(tb->tb_path, 1) == 0 &&
+ B_NR_ITEMS(tb->FR[0]) > 1)
+ replace_key(tb, tb->CFL[0], tb->lkey[0],
+ tb->FR[0], 1);
+
+ leaf_move_items(LEAF_FROM_S_TO_L, tb, n, -1, NULL);
+ leaf_move_items(LEAF_FROM_R_TO_L, tb,
+ B_NR_ITEMS(tb->R[0]), -1, NULL);
+
+ reiserfs_invalidate_buffer(tb, tbS0);
+ reiserfs_invalidate_buffer(tb, tb->R[0]);
+
+ return 0;
+ }
+ /* all contents of all the 3 buffers will be in R[0] */
+ leaf_move_items(LEAF_FROM_S_TO_R, tb, n, -1, NULL);
+ leaf_move_items(LEAF_FROM_L_TO_R, tb, B_NR_ITEMS(tb->L[0]),
+ -1, NULL);
+
+ /* right_delimiting_key is correct in R[0] */
+ replace_key(tb, tb->CFR[0], tb->rkey[0], tb->R[0], 0);
+
+ reiserfs_invalidate_buffer(tb, tbS0);
+ reiserfs_invalidate_buffer(tb, tb->L[0]);
+
+ return -1;
+ }
+
+ RFALSE(tb->rnum[0] != 0,
+ "PAP-12045: rnum must be 0 (%d)", tb->rnum[0]);
+
+ /* all contents of L[0] and S[0] will be in L[0] */
+ leaf_shift_left(tb, n, -1);
+ reiserfs_invalidate_buffer(tb, tbS0);
+ return 0;
+
+}
+
/* Balance leaf node in case of delete or cut: insert_size[0] < 0
*
* lnum, rnum can have values >= -1
@@ -106,14 +154,13 @@ be performed by do_balance.
* 0 means that nothing should be done with the neighbor
* >0 means to shift entirely or partly the specified number of items to the neighbor
*/
-static int balance_leaf_when_delete(struct tree_balance *tb, int flag)
+static int bl_when_delete(struct tree_balance *tb, int flag)
{
- struct buffer_head *tbS0 = PATH_PLAST_BUFFER(tb->tb_path);
int item_pos = PATH_LAST_POSITION(tb->tb_path);
- int pos_in_item = tb->tb_path->pos_in_item;
+ int n, pos_in_item = tb->tb_path->pos_in_item;
+ struct buffer_head *tbS0 = PATH_PLAST_BUFFER(tb->tb_path);
+ struct item_head *ih = B_N_PITEM_HEAD(tbS0, item_pos);
struct buffer_info bi;
- int n;
- struct item_head *ih;
if (flag != M_DELETE && flag != M_CUT) {
print_cur_tb("12040");
@@ -129,22 +176,20 @@ static int balance_leaf_when_delete(stru
RFALSE(!tb->blknum[0] && !PATH_H_PPARENT(tb->tb_path, 0),
"PAP-12010: tree can not be empty");
- ih = B_N_PITEM_HEAD(tbS0, item_pos);
buffer_info_init_tbS0(tb, &bi);
/* Delete or truncate the item */
-
if (flag == M_DELETE) {
RFALSE(ih_item_len(ih) + IH_SIZE != -tb->insert_size[0],
- "vs-12013: mode Delete, insert size %d, ih to be deleted %h",
- -tb->insert_size[0], ih);
+ "vs-12013: mode Delete, insert size %d, "
+ "ih to be deleted %h", -tb->insert_size[0], ih);
leaf_delete_items(&bi, 0, item_pos, 1, -1);
if (!item_pos && tb->CFL[0]) {
if (B_NR_ITEMS(tbS0)) {
- replace_key(tb, tb->CFL[0], tb->lkey[0], tbS0,
- 0);
+ replace_key(tb, tb->CFL[0], tb->lkey[0],
+ tbS0, 0);
} else {
if (!PATH_H_POSITION(tb->tb_path, 1))
replace_key(tb, tb->CFL[0], tb->lkey[0],
@@ -170,8 +215,8 @@ static int balance_leaf_when_delete(stru
-tb->insert_size[0]);
RFALSE(!item_pos && !pos_in_item && !tb->CFL[0],
- "PAP-12030: can not change delimiting key. CFL[0]=%p",
- tb->CFL[0]);
+ "PAP-12030: can not change delimiting key. "
+ "CFL[0]=%p", tb->CFL[0]);
if (!item_pos && !pos_in_item && tb->CFL[0]) {
replace_key(tb, tb->CFL[0], tb->lkey[0],
@@ -186,69 +231,31 @@ static int balance_leaf_when_delete(stru
}
}
- /* the rule is that no shifting occurs unless by shifting a node can be freed */
+ /* the rule is that no shifting occurs unless by
+ * shifting a node can be freed */
n = B_NR_ITEMS(tbS0);
- if (tb->lnum[0]) { /* L[0] takes part in balancing */
- if (tb->lnum[0] == -1) { /* L[0] must be joined with S[0] */
- if (tb->rnum[0] == -1) { /* R[0] must be also joined with S[0] */
- if (tb->FR[0] == PATH_H_PPARENT(tb->tb_path, 0)) {
- /* all contents of all the 3 buffers will be in L[0] */
- if (PATH_H_POSITION(tb->tb_path, 1) == 0
- && 1 < B_NR_ITEMS(tb->FR[0]))
- replace_key(tb, tb->CFL[0],
- tb->lkey[0],
- tb->FR[0], 1);
-
- leaf_move_items(LEAF_FROM_S_TO_L, tb, n,
- -1, NULL);
- leaf_move_items(LEAF_FROM_R_TO_L, tb,
- B_NR_ITEMS(tb->R[0]),
- -1, NULL);
-
- reiserfs_invalidate_buffer(tb, tbS0);
- reiserfs_invalidate_buffer(tb,
- tb->R[0]);
-
- return 0;
- }
- /* all contents of all the 3 buffers will be in R[0] */
- leaf_move_items(LEAF_FROM_S_TO_R, tb, n, -1,
- NULL);
- leaf_move_items(LEAF_FROM_L_TO_R, tb,
- B_NR_ITEMS(tb->L[0]), -1, NULL);
-
- /* right_delimiting_key is correct in R[0] */
- replace_key(tb, tb->CFR[0], tb->rkey[0],
- tb->R[0], 0);
-
- reiserfs_invalidate_buffer(tb, tbS0);
- reiserfs_invalidate_buffer(tb, tb->L[0]);
-
- return -1;
- }
-
- RFALSE(tb->rnum[0] != 0,
- "PAP-12045: rnum must be 0 (%d)", tb->rnum[0]);
- /* all contents of L[0] and S[0] will be in L[0] */
- leaf_shift_left(tb, n, -1);
-
- reiserfs_invalidate_buffer(tb, tbS0);
-
- return 0;
- }
- /* a part of contents of S[0] will be in L[0] and the rest part of S[0] will be in R[0] */
+ /* L[0] takes part in balancing */
+ if (tb->lnum[0]) {
+ /* L[0] must be joined with S[0] */
+ if (tb->lnum[0] == -1)
+ return bl_delete_merge_left(tb);
+ /* a part of contents of S[0] will be in L[0] and
+ * the rest part of S[0] will be in R[0] */
RFALSE((tb->lnum[0] + tb->rnum[0] < n) ||
(tb->lnum[0] + tb->rnum[0] > n + 1),
- "PAP-12050: rnum(%d) and lnum(%d) and item number(%d) in S[0] are not consistent",
+ "PAP-12050: rnum(%d) and lnum(%d) and "
+ "item number(%d) in S[0] are not consistent",
tb->rnum[0], tb->lnum[0], n);
RFALSE((tb->lnum[0] + tb->rnum[0] == n) &&
(tb->lbytes != -1 || tb->rbytes != -1),
- "PAP-12055: bad rbytes (%d)/lbytes (%d) parameters when items are not split",
+ "PAP-12055: bad rbytes (%d)/lbytes (%d) "
+ "parameters when items are not split",
tb->rbytes, tb->lbytes);
RFALSE((tb->lnum[0] + tb->rnum[0] == n + 1) &&
(tb->lbytes < 1 || tb->rbytes != -1),
- "PAP-12060: bad rbytes (%d)/lbytes (%d) parameters when items are split",
+ "PAP-12060: bad rbytes (%d)/lbytes (%d) "
+ "parameters when items are split",
tb->rbytes, tb->lbytes);
leaf_shift_left(tb, tb->lnum[0], tb->lbytes);
@@ -1366,7 +1373,7 @@ static int balance_leaf(struct tree_bala
/* Make balance in case insert_size[0] < 0 */
if (tb->insert_size[0] < 0)
- return balance_leaf_when_delete(tb, flag);
+ return bl_when_delete(tb, flag);
zeros_num = 0;
if (flag == M_INSERT && body == 0)
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 43+ messages in thread
* [patch 40/40] reiserfs: reorganize do_balan.c comments
2007-06-11 19:03 [patch 00/40] reiserfs: patch queue (v2) jeffm
` (37 preceding siblings ...)
2007-06-11 19:03 ` [patch 39/40] reiserfs: split bl_when_delete jeffm
@ 2007-06-11 19:03 ` jeffm
2007-06-11 19:20 ` [patch 00/40] reiserfs: patch queue (v2) Jeff Mahoney
2007-06-14 19:41 ` Jeff Mahoney
40 siblings, 0 replies; 43+ messages in thread
From: jeffm @ 2007-06-11 19:03 UTC (permalink / raw)
To: ReiserFS Mailing List
[-- Attachment #1: reiserfs-balance_leaf_comment.diff --]
[-- Type: text/plain, Size: 13687 bytes --]
This patch just shuffles some comments around to make them more useful,
as well as formatted in a more readable manner.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
fs/reiserfs/do_balan.c | 233 ++++++++++++++++++++++---------------------------
1 file changed, 108 insertions(+), 125 deletions(-)
--- a/fs/reiserfs/do_balan.c 2007-05-30 17:54:46.000000000 -0400
+++ b/fs/reiserfs/do_balan.c 2007-05-30 17:54:47.000000000 -0400
@@ -1,20 +1,47 @@
/*
* Copyright 2000 by Hans Reiser, licensing governed by reiserfs/README
+ *
+ * Big rule: Nothing performed during balance_leaf() may schedule. This
+ * is to ensure that the tree will be stable during the entire balancing
+ * run. This is clearly suboptimal for multithreaded use, but making
+ * the tree locking more scalable is a huge project that nobody has
+ * decided to take on yet.
+ *
+ * Summary:
+ * if deleting/cutting something ( tb->insert_size[0] < 0 )
+ * return(bl_when_delete());
+ * else
+ * if lnum is larger than 0 we put items into the left node
+ * if rnum is larger than 0 we put items into the right node
+ * if tb->snum[0] is larger than 0 we put items into the new node s1
+ * if tb->snum[1] is larger than 0 we put items into the new node s2
+ * Note that all *num* count new items being created.
+ *
+ * Some interesting rules of balancing:
+ *
+ * we delete a maximum of two nodes per level per balancing: we never
+ * delete R, when we delete two of three nodes L, S, R then we move
+ * them into R.
+ *
+ * we only delete L if we are deleting two nodes, if we delete only
+ * one node we delete S
+ *
+ * if we shift leaves then we shift as much as we can: this is a
+ * deliberate policy of extremism in node packing which results in
+ * higher average utilization after repeated random balance operations
+ * at the cost of more memory copies and more balancing as a result of
+ * small insertions to full nodes.
+ *
+ * if we shift internal nodes we try to evenly balance the node
+ * utilization, with consequent less balancing at the cost of lower
+ * utilization.
+ *
+ * one could argue that the policy for directories in leaves should be
+ * that of internal nodes, but we will wait until another day to
+ * evaluate this.... It would be nice to someday measure and prove
+ * these assumptions as to what is optimal....
*/
-/* Now we have all buffers that must be used in balancing of the tree */
-/* Further calculations can not cause schedule(), and thus the buffer */
-/* tree will be stable until the balancing will be finished */
-/* balance the tree according to the analysis made before, */
-/* and using buffers obtained after all above. */
-
-/**
- ** bl_when_delete
- ** balance_leaf
- ** do_balance
- **
- **/
-
#include <asm/uaccess.h>
#include <linux/time.h>
#include <linux/reiserfs_fs.h>
@@ -76,29 +103,6 @@ inline void do_balance_mark_leaf_dirty(s
#define do_balance_mark_internal_dirty do_balance_mark_leaf_dirty
#define do_balance_mark_sb_dirty do_balance_mark_leaf_dirty
-/* summary:
- if deleting something ( tb->insert_size[0] < 0 )
- return(bl_when_delete()); (flag d handled here)
- else
- if lnum is larger than 0 we put items into the left node
- if rnum is larger than 0 we put items into the right node
- if tb->snum[0] is larger than 0 we put items into the new node s1
- if tb->snum[1] is larger than 0 we put items into the new node s2
-Note that all *num* count new items being created.
-
-It would be easier to read balance_leaf() if each of these summary
-lines was a separate procedure rather than being inlined. I think
-that there are many passages here and in bl_when_delete() in
-which two calls to one procedure can replace two passages, and it
-might save cache space and improve software maintenance costs to do so.
-
-Vladimir made the perceptive comment that we should offload most of
-the decision making in this function into fix_nodes/check_balance, and
-then create some sort of structure in tb that says what actions should
-be performed by do_balance.
-
--Hans */
-
/* L[0] must be joined with S[0] */
static int bl_delete_merge_left(struct tree_balance *tb)
{
@@ -1352,20 +1356,30 @@ bl_current_node(struct tree_ba
}
-static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item header of inserted item (this is on little endian) */
- const char *body, /* body of inserted item or bytes to paste */
- int flag, /* i - insert, d - delete, c - cut, p - paste
- (see comment to do_balance) */
- struct item_head *insert_key, /* in our processing of one level we sometimes determine what
- must be inserted into the next higher level. This insertion
- consists of a key or two keys and their corresponding
- pointers */
- struct buffer_head **insert_ptr /* inserted node-ptrs for the next level */
- )
+/*
+ * balance_leaf(): The core driver for balancing the leaf level of reiserfs
+ * s-trees. This function completes successfully or panics.
+ * Upon successful completion, the leaf level is balanced.
+ *
+ * @tb: tree balance struct containing state of this balance
+ * @ih: item header of inserted item (this is on little endian)
+ * @body: body of inserted item or bytes to paste
+ * @flag: One of M_INSERT, M_PASTE, M_DELETE, or M_CUT
+ * @insert_key: In our processing of one level we sometimes determine what
+ * must be inserted into the next higher level. This insertion
+ * consists of a key or two keys and their corresponding
+ * pointers
+ * @insert_ptr: inserted node-ptrs for the next level
+ */
+static int balance_leaf(struct tree_balance *tb, struct item_head *ih,
+ const char *body, int flag,
+ struct item_head *insert_key,
+ struct buffer_head **insert_ptr)
{
struct buffer_head *tbS0 = PATH_PLAST_BUFFER(tb->tb_path);
- int item_pos = PATH_LAST_POSITION(tb->tb_path); /* index into the array of item headers in S[0]
- of the affected item */
+ /* index into the array of item headers in S[0]
+ * of the affected item */
+ int item_pos = PATH_LAST_POSITION(tb->tb_path);
int pos_in_item;
int zeros_num;
@@ -1435,7 +1449,7 @@ static int balance_leaf(struct tree_bala
pos_in_item);
return 0;
-} /* Leaf level of the tree is balanced (end of balance_leaf) */
+} /* Leaf level of the tree is balanced (end of balance_leaf) */
/* Make empty node */
void make_empty_node(struct buffer_info *bi)
@@ -1449,7 +1463,7 @@ void make_empty_node(struct buffer_info
set_blkh_free_space(blkh, MAX_CHILD_SIZE(bi->bi_bh));
if (bi->bi_parent)
- B_N_CHILD(bi->bi_parent, bi->bi_position)->dc_size = 0; /* Endian safe if 0 */
+ B_N_CHILD(bi->bi_parent, bi->bi_position)->dc_size = 0;
}
/* Get first empty buffer */
@@ -1490,7 +1504,8 @@ static void store_thrown(struct tree_bal
get_bh(bh); /* free_thrown puts this */
return;
}
- reiserfs_warning(tb->tb_sb, "reiserfs-12321", "too many thrown buffers");
+ reiserfs_warning(tb->tb_sb, "reiserfs-12321",
+ "too many thrown buffers");
}
static void free_thrown(struct tree_balance *tb)
@@ -1504,7 +1519,8 @@ static void free_thrown(struct tree_bala
reiserfs_warning(tb->tb_sb, "reiserfs-12322",
"called with dirty buffer %d",
blocknr);
- brelse(tb->thrown[i]); /* incremented in store_thrown */
+ /* incremented in store_thrown */
+ brelse(tb->thrown[i]);
reiserfs_free_block(tb->transaction_handle, NULL,
blocknr, 0);
}
@@ -1530,9 +1546,8 @@ void replace_key(struct tree_balance *tb
RFALSE(dest == NULL || src == NULL,
"vs-12305: source or destination buffer is 0 (src=%p, dest=%p)",
src, dest);
- RFALSE(!B_IS_KEYS_LEVEL(dest),
- "vs-12310: invalid level (%z) for destination buffer. dest must be leaf",
- dest);
+ RFALSE(!B_IS_KEYS_LEVEL(dest), "vs-12310: invalid level (%z) "
+ "for destination buffer. dest must be leaf", dest);
RFALSE(n_dest < 0 || n_src < 0,
"vs-12315: src(%d) or dest(%d) key number < 0", n_src, n_dest);
RFALSE(n_dest >= B_NR_ITEMS(dest) || n_src >= B_NR_ITEMS(src),
@@ -1723,39 +1738,6 @@ static void check_internal_levels(struct
#endif
-/* Now we have all of the buffers that must be used in balancing of
- the tree. We rely on the assumption that schedule() will not occur
- while do_balance works. ( Only interrupt handlers are acceptable.)
- We balance the tree according to the analysis made before this,
- using buffers already obtained. For SMP support it will someday be
- necessary to add ordered locking of tb. */
-
-/* Some interesting rules of balancing:
-
- we delete a maximum of two nodes per level per balancing: we never
- delete R, when we delete two of three nodes L, S, R then we move
- them into R.
-
- we only delete L if we are deleting two nodes, if we delete only
- one node we delete S
-
- if we shift leaves then we shift as much as we can: this is a
- deliberate policy of extremism in node packing which results in
- higher average utilization after repeated random balance operations
- at the cost of more memory copies and more balancing as a result of
- small insertions to full nodes.
-
- if we shift internal nodes we try to evenly balance the node
- utilization, with consequent less balancing at the cost of lower
- utilization.
-
- one could argue that the policy for directories in leaves should be
- that of internal nodes, but we will wait until another day to
- evaluate this.... It would be nice to someday measure and prove
- these assumptions as to what is optimal....
-
-*/
-
static inline void do_balance_starts(struct tree_balance *tb)
{
/* use print_cur_tb() to see initial state of struct
@@ -1794,43 +1776,45 @@ static inline void do_balance_completed(
free_thrown(tb);
}
-void do_balance(struct tree_balance *tb, /* tree_balance structure */
- struct item_head *ih, /* item header of inserted item */
- const char *body, /* body of inserted item or bytes to paste */
- int flag)
-{ /* i - insert, d - delete
- c - cut, p - paste
-
- Cut means delete part of an item
- (includes removing an entry from a
- directory).
-
- Delete means delete whole item.
-
- Insert means add a new item into the
- tree.
-
- Paste means to append to the end of an
- existing file or to insert a directory
- entry. */
- int child_pos, /* position of a child node in its parent */
- h; /* level of the tree being processed */
- struct item_head insert_key[2]; /* in our processing of one level
- we sometimes determine what
- must be inserted into the next
- higher level. This insertion
- consists of a key or two keys
- and their corresponding
- pointers */
- struct buffer_head *insert_ptr[2]; /* inserted node-ptrs for the next
- level */
+/*
+ * do_balance(): The driver function for tree balancing. We balance the leaf
+ * level first, and then update the internal tree to match.
+ *
+ * @tb: struct tree_balance containing state of balancing
+ * @ih: item header of inserted item
+ * @body: body of inserted item or bytes to paste
+ * @flag: One of M_INSERT, M_PASTE, M_DELETE, or M_CUT:
+ * M_INSERT: Add a new item to the tree
+ * M_PASTE: Extend an existing item, e.g. appending a file or
+ * adding a new directory entry
+ * M_DELETE: Delete the entire item
+ * M_CUT: Delete part of an item, e.g. removing a directory entry
+ */
+void do_balance(struct tree_balance *tb, struct item_head *ih,
+ const char *body, int flag)
+{
+ /* position of a child node in its parent */
+ int child_pos = PATH_H_B_ITEM_ORDER(tb->tb_path, 0);
+
+ /* level of the tree being processed */
+ int h;
+
+ /* in our processing of one level we sometimes determine what
+ * must be inserted into the next higher level. This insertion
+ * consists of a key or two keys and their corresponding pointers */
+ struct item_head insert_key[2];
+
+ /* Buffers added to the leaf level that must be tracked for
+ * balancing the internal levels. */
+ struct buffer_head *insert_ptr[2];
tb->tb_mode = flag;
tb->need_balance_dirty = 0;
- if (FILESYSTEM_CHANGED_TB(tb)) {
- reiserfs_panic(tb->tb_sb, "clm-6000", "fs generation has changed");
- }
+ if (FILESYSTEM_CHANGED_TB(tb))
+ reiserfs_panic(tb->tb_sb, "clm-6000",
+ "fs generation has changed");
+
/* if we have no real work to do */
if (!tb->insert_size[0]) {
reiserfs_warning(tb->tb_sb, "PAP-12350",
@@ -1845,8 +1829,7 @@ void do_balance(struct tree_balance *tb,
/* balance leaf returns 0 except if combining L R and S into
one node. see balance_internal() for explanation of this
line of code. */
- child_pos = PATH_H_B_ITEM_ORDER(tb->tb_path, 0) +
- balance_leaf(tb, ih, body, flag, insert_key, insert_ptr);
+ child_pos += balance_leaf(tb, ih, body, flag, insert_key, insert_ptr);
#ifdef CONFIG_REISERFS_CHECK
check_after_balance_leaf(tb);
@@ -1854,8 +1837,8 @@ void do_balance(struct tree_balance *tb,
/* Balance internal level of the tree. */
for (h = 1; h < MAX_HEIGHT && tb->insert_size[h]; h++)
- child_pos =
- balance_internal(tb, h, child_pos, insert_key, insert_ptr);
+ child_pos = balance_internal(tb, h, child_pos,
+ insert_key, insert_ptr);
do_balance_completed(tb);
--
Jeff Mahoney
SUSE Labs
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [patch 00/40] reiserfs: patch queue (v2)
2007-06-11 19:03 [patch 00/40] reiserfs: patch queue (v2) jeffm
` (38 preceding siblings ...)
2007-06-11 19:03 ` [patch 40/40] reiserfs: reorganize do_balan.c comments jeffm
@ 2007-06-11 19:20 ` Jeff Mahoney
2007-06-14 19:41 ` Jeff Mahoney
40 siblings, 0 replies; 43+ messages in thread
From: Jeff Mahoney @ 2007-06-11 19:20 UTC (permalink / raw)
To: jeffm; +Cc: ReiserFS Mailing List
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
jeffm@suse.com wrote:
> Hi all -
>
> The following are a series of patches that have been kicking around for a
> while. I thought I'd just put them out there to gauge interest and to get
> some testing before submitting to -mm.
>
> I've re-ordered a few of the patches. This is actually four distinct,
> unrelated, though context-dependent, patch series. I've moved the trivial
> changes to the front of the list to better reflect that.
Five, of course. :)
The next time I mail the series out, I'll split them up so that I don't
need to keep dropping 40 patches on the list. They're divided up on the
FTP site now.
- -Jeff
- --
Jeff Mahoney
SUSE Labs
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org
iD8DBQFGbaB5LPWxlyuTD7IRAplzAJ9FzNXqFSuUHr93LGIR5vFQ8S/CxgCcDbFS
dwHuhG72z3LHuWAG1c403C4=
=Sg9p
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [patch 03/40] reiserfs: use is_reusable to catch corruption
2007-06-11 19:03 ` [patch 03/40] reiserfs: use is_reusable to catch corruption jeffm
@ 2007-06-13 15:54 ` Jeff Mahoney
0 siblings, 0 replies; 43+ messages in thread
From: Jeff Mahoney @ 2007-06-13 15:54 UTC (permalink / raw)
Cc: ReiserFS Mailing List
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
jeffm@suse.com wrote:
> + if (sb_block_count(REISERFS_SB(s)->s_rs) > blocks) {
> + reiserfs_error(th->t_super, "bitmap-4072",
> + "Trying to free block outside file system "
> + "boundaries (%lu > %lu)",
> + block, blocks);
> + return;
> + }
Should be:
if (block > sb_block_count(REISERFS_SB(s)->s_rs)) {
reiserfs_error(th->t_super, "bitmap-4072",
"Trying to free block outside file system "
"boundaries (%lu > %lu)",
block, sb_block_count(REISERFS_SB(s)->s_rs));
return;
Too many balls in the air.
- -Jeff
- --
Jeff Mahoney
SUSE Labs
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org
iD8DBQFGcBMgLPWxlyuTD7IRAjgWAKCQMKvTGYkYtv2kQmA5kCFqzFvtJACgkdxM
4FGl1fbMzWx/ONgjmoVtW1M=
=xFYz
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [patch 00/40] reiserfs: patch queue (v2)
2007-06-11 19:03 [patch 00/40] reiserfs: patch queue (v2) jeffm
` (39 preceding siblings ...)
2007-06-11 19:20 ` [patch 00/40] reiserfs: patch queue (v2) Jeff Mahoney
@ 2007-06-14 19:41 ` Jeff Mahoney
40 siblings, 0 replies; 43+ messages in thread
From: Jeff Mahoney @ 2007-06-14 19:41 UTC (permalink / raw)
To: ReiserFS Mailing List
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
jeffm@suse.com wrote:
> * Clean up do_balan.c (31-40)
> - Factor out buffer_info initializations.
> - Turn tb->s[12]num and tb[12]bytes into an array.
> - Split balance_leaf from the 2500 line beast to more manageable chunks.
> - Clean up balance_leaf_when_delete.
> - Clean up comments.
Consider these unusable. They've been reliably introducing corruption on
my local machine.
- -Jeff
- --
Jeff Mahoney
SUSE Labs
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org
iD4DBQFGcZnULPWxlyuTD7IRAtpmAJd6y6x4+OQ3kvWO2tnsBCfD4SZfAKCZb3E+
sNkwhvMQEugLia0axi/18w==
=MK4x
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 43+ messages in thread
end of thread, other threads:[~2007-06-14 19:41 UTC | newest]
Thread overview: 43+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-11 19:03 [patch 00/40] reiserfs: patch queue (v2) jeffm
2007-06-11 19:03 ` [patch 01/40] reiserfs: fix up lockdep warnings jeffm
2007-06-11 19:03 ` [patch 02/40] reiserfs: dont use BUG when panicking jeffm
2007-06-11 19:03 ` [patch 03/40] reiserfs: use is_reusable to catch corruption jeffm
2007-06-13 15:54 ` Jeff Mahoney
2007-06-11 19:03 ` [patch 04/40] reiserfs: make bitmap use cached first zero bit jeffm
2007-06-11 19:03 ` [patch 05/40] reiserfs: use more consistent printk formatting jeffm
2007-06-11 19:03 ` [patch 06/40] reiserfs: make some warnings informational jeffm
2007-06-11 19:03 ` [patch 07/40] reiserfs: rework reiserfs_warning jeffm
2007-06-11 19:03 ` [patch 08/40] reiserfs: rework reiserfs_panic jeffm
2007-06-11 19:03 ` [patch 09/40] reiserfs: rearrange journal abort jeffm
2007-06-11 19:03 ` [patch 10/40] reiserfs: introduce reiserfs_error() jeffm
2007-06-11 19:03 ` [patch 11/40] reiserfs: use reiserfs_error() jeffm
2007-06-11 19:03 ` [patch 12/40] reiserfs: simplify xattr internal file lookups/opens jeffm
2007-06-11 19:03 ` [patch 13/40] reiserfs: eliminate per-super xattr lock jeffm
2007-06-11 19:03 ` [patch 14/40] reiserfs: make per-inode xattr locking more fine grained jeffm
2007-06-11 19:03 ` [patch 15/40] reiserfs: remove i_has_xattr_dir jeffm
2007-06-11 19:03 ` [patch 16/40] reiserfs: remove link detection code jeffm
2007-06-11 19:03 ` [patch 17/40] reiserfs: use generic xattr handlers jeffm
2007-06-11 19:03 ` [patch 18/40] reiserfs: use better open options for internal files jeffm
2007-06-11 19:03 ` [patch 19/40] reiserfs: add per-file data=ordered mode and use it for xattrs jeffm
2007-06-11 19:03 ` [patch 20/40] reiserfs: journaled xattrs jeffm
2007-06-11 19:03 ` [patch 21/40] reiserfs: use generic readdir for operations across all xattrs jeffm
2007-06-11 19:03 ` [patch 22/40] reiserfs: add atomic addition of selinux attributes during inode creation jeffm
2007-06-11 19:03 ` [patch 23/40] reiserfs: cleanup path functions jeffm
2007-06-11 19:03 ` [patch 24/40] reiserfs: strip trailing whitespace jeffm
2007-06-11 19:03 ` [patch 26/40] reiserfs: rename p_s_bh to bh jeffm
2007-06-11 19:03 ` [patch 27/40] reiserfs: rename p_s_inode to inode jeffm
2007-06-11 19:03 ` [patch 28/40] reiserfs: rename p_s_tb to tb jeffm
2007-06-11 19:03 ` [patch 29/40] reiserfs: rename p_._ variables jeffm
2007-06-11 19:03 ` [patch 30/40] reiserfs: rename _* variables jeffm
2007-06-11 19:03 ` [patch 31/40] reiserfs: factor out buffer_info initialization jeffm
2007-06-11 19:03 ` [patch 32/40] reiserfs: Turn tb->snum and tb->sbytes into an array jeffm
2007-06-11 19:03 ` [patch 33/40] reiserfs: split left balancing part of balance_leaf() off jeffm
2007-06-11 19:03 ` [patch 34/40] reiserfs: split right " jeffm
2007-06-11 19:03 ` [patch 35/40] reiserfs: split balance_leaf new node handling out jeffm
2007-06-11 19:03 ` [patch 36/40] reiserfs: split out current node handling from balance_leaf jeffm
2007-06-11 19:03 ` [patch 37/40] reiserfs: clean up bl_when_delete jeffm
2007-06-11 19:03 ` [patch 38/40] reiserfs: clean up balancing modes jeffm
2007-06-11 19:03 ` [patch 39/40] reiserfs: split bl_when_delete jeffm
2007-06-11 19:03 ` [patch 40/40] reiserfs: reorganize do_balan.c comments jeffm
2007-06-11 19:20 ` [patch 00/40] reiserfs: patch queue (v2) Jeff Mahoney
2007-06-14 19:41 ` Jeff Mahoney
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.