Jeff's ReiserFS Patch Queue
cover Jeff's ReiserFS Patch Queue
Hi all -
I'd like to submit my reiserfs patch queue for inclusion into 2.6.30. I've received a bunch of requests from Christoph asking me to do this over the past two years. They needed some cleaning up (done), and there was one final crash that prevented me from submitting to 2.6.27 and 2.6.28, which has now been fixed. These patches have been in several openSUSE releases and, outside of the now-fixed crash, they've been stable. Once this is applied, I expect reiserfs to be in deep maintenance-only mode.
There are 35 patches in several groups:
- Quick fixes
- Implement mount count and expiry in the superblock.
- Audit commit id's to always be unsigned ints
- Better error handling and reporting
- Standardizes error output
- Adds more robust error handling where it will currently panic
- Extended attribute rework
- Cleans up the code
- Improves locking
- Journals extended attributes
- Adds selinux support
- Uses generic xattr helpers
- Code cleanups
- Simplifies the buffer_info struct usage
- Kills off decrement_bcount and cleans up surrounding code
- Strips whitespace
- Kills off the stupid variable name prefixing
Please apply.
-Jeff
--
Jeff Mahoney
SUSE Labs
PATCH 1/35 reiserfs: add support for mount count incrementing
The following patch adds the fields for tracking mount counts and last fsck timestamps to the superblock. It also increments the mount count on every read-write mount. Reiserfsprogs 3.6.21 added support for these fields.
--- fs/reiserfs/super.c | 6 +++++- include/linux/reiserfs_fs.h | 6 +++++- include/linux/reiserfs_fs_sb.h | 3 +++ 3 files changed, 13 insertions(+), 2 deletions(-)
fs/reiserfs/super.c +5 -1
@@ -1280,6 +1280,8 @@ static int reiserfs_remount(struct superREISERFS_SB (s)->s_mount_state =sb_umount_state (rs); s->s_flags &= ~MS_RDONLY ;set_sb_umount_state (rs,REISERFS_ERROR_FS ); +if (!old_format_only (s)) +set_sb_mnt_count (rs,sb_mnt_count (rs) +1 );/* mark_buffer_dirty (SB_BUFFER_WITH_SB (s), 1); */ journal_mark_dirty (&th, s,SB_BUFFER_WITH_SB (s));REISERFS_SB (s)->s_mount_state =REISERFS_VALID_FS ;
@@ -1819,7 +1821,9 @@ static int reiserfs_fill_super(struct su }else if (!silent) {reiserfs_info (s,"using 3.5.x disk format\n" ); } - } + }else +set_sb_mnt_count (rs,sb_mnt_count (rs) +1 ); +journal_mark_dirty (&th, s,SB_BUFFER_WITH_SB (s)); errval =journal_end (&th, s,1 );
include/linux/reiserfs_fs.h +5 -1
@@ -171,7 +171,11 @@ struct reiserfs_super_block {__le32 s_flags;/* Right now used only by inode-attributes, if enabled */ unsigned char s_uuid[16 ];/* filesystem unique identifier */ unsigned char s_label[16 ];/* filesystem volume label */ -char s_unused[88 ];/* zero filled by mkreiserfs and +__le16 s_mnt_count;/* Count of mounts since last fsck */ +__le16 s_max_mnt_count;/* Maximum mounts before check */ +__le32 s_lastcheck;/* Timestamp of last fsck */ +__le32 s_check_interval;/* Interval between checks */ +char s_unused[76 ];/* zero filled by mkreiserfs and * reiserfs_convert_objectid_map_v1() * so any additions must be updated * there as well. */
include/linux/reiserfs_fs_sb.h +3 -0
@@ -73,6 +73,9 @@ typedef enum {#define sb_version (sbp) (le16_to_cpu((sbp)->s_v1.s_version))#define set_sb_version (sbp,v) ((sbp)->s_v1.s_version = cpu_to_le16(v)) +#define sb_mnt_count (sbp) (le16_to_cpu((sbp)->s_mnt_count)) +#define set_sb_mnt_count (sbp, v) ((sbp)->s_mnt_count = cpu_to_le16(v)) +#define sb_reserved_for_journal (sbp) \ (le16_to_cpu((sbp)->s_v1.s_reserved_for_journal))#define set_sb_reserved_for_journal (sbp,v) \
PATCH 2/35 reiserfs: audit transaction ids to always be unsigned ints
In reply to Jeff MahoneyThis patch fixes up the reiserfs code such that transaction ids are always unsigned ints. In places they can currently be signed ints or unsigned longs.
The former just causes an annoying clm-2200 warning and may join a transaction when it should wait.
The latter is just for correctness since the disk format uses a 32-bit transaction id. There aren't any runtime problems that result from it not wrapping at the correct location since the value is truncated correctly even on big endian systems. The 0 value might make it to disk, but the mount-time checks will bump it to 10 itself.
--- fs/reiserfs/journal.c | 46 ++++++++++++++++++++--------------------- fs/reiserfs/procfs.c | 4 +-- include/linux/reiserfs_fs.h | 2 - include/linux/reiserfs_fs_i.h | 2 - include/linux/reiserfs_fs_sb.h | 8 +++---- 5 files changed, 31 insertions(+), 31 deletions(-)
fs/reiserfs/journal.c +23 -23
@@ -574,7 +574,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,"trans id %u, refcount at %d" , jl->j_trans_id, jl->j_refcount); }if (--jl->j_refcount ==0 )
@@ -599,7 +599,7 @@ static void cleanup_freed_for_journal_li }static int journal_list_still_alive (struct super_block *s, -unsigned long trans_id) +unsigned int trans_id) {struct reiserfs_journal *journal =SB_JOURNAL (s);struct list_head *entry = &journal->j_journal_list;
@@ -933,9 +933,9 @@ static int flush_older_commits(struct sustruct reiserfs_journal_list *other_jl;struct reiserfs_journal_list *first_jl;struct list_head *entry; -unsigned long trans_id = jl->j_trans_id; -unsigned long other_trans_id; -unsigned long first_trans_id; +unsigned int trans_id = jl->j_trans_id; +unsigned int other_trans_id; +unsigned int first_trans_id; find_first:/*
@@ -1014,7 +1014,7 @@ static int flush_commit_list(struct supeint i;b_blocknr_t bn;struct buffer_head *tbh =NULL ; -unsigned long trans_id = jl->j_trans_id; +unsigned int trans_id = jl->j_trans_id;struct reiserfs_journal *journal =SB_JOURNAL (s);int barrier =0 ;int retval =0 ;
@@ -1275,7 +1275,7 @@ static void remove_all_from_journal_list*/ static int _update_journal_header_block (struct super_block *p_s_sb,unsigned long offset, -unsigned long trans_id) +unsigned int trans_id) {struct reiserfs_journal_header *jh;struct reiserfs_journal *journal =SB_JOURNAL (p_s_sb);
@@ -1329,7 +1329,7 @@ static int _update_journal_header_block(static int update_journal_header_block (struct super_block *p_s_sb,unsigned long offset, -unsigned long trans_id) +unsigned int trans_id) {return _update_journal_header_block (p_s_sb, offset, trans_id); }
@@ -1344,7 +1344,7 @@ static int flush_older_journal_lists(strstruct list_head *entry;struct reiserfs_journal_list *other_jl;struct reiserfs_journal *journal =SB_JOURNAL (p_s_sb); -unsigned long trans_id = jl->j_trans_id; +unsigned int trans_id = jl->j_trans_id;/* we know we are the only ones flushing things, no extra race * protection is required.
@@ -1758,13 +1758,13 @@ static int dirty_one_transaction(structstatic int kupdate_transactions (struct super_block *s,struct reiserfs_journal_list *jl,struct reiserfs_journal_list **next_jl, -unsigned long *next_trans_id, +unsigned int *next_trans_id,int num_blocks,int num_trans) {int ret =0 ;int written =0 ;int transactions_flushed =0 ; -unsigned long orig_trans_id = jl->j_trans_id; +unsigned int orig_trans_id = jl->j_trans_id;struct buffer_chunk chunk;struct list_head *entry;struct reiserfs_journal *journal =SB_JOURNAL (s);
@@ -1833,7 +1833,7 @@ static int flush_used_journal_lists(struint limit =256 ;struct reiserfs_journal_list *tjl;struct reiserfs_journal_list *flush_jl; -unsigned long trans_id; +unsigned int trans_id;struct reiserfs_journal *journal =SB_JOURNAL (s); flush_jl = tjl = jl;
@@ -2023,7 +2023,7 @@ static int journal_compare_desc_commit(s*/ static int journal_transaction_is_valid (struct super_block *p_s_sb,struct buffer_head *d_bh, -unsigned long *oldest_invalid_trans_id, +unsigned int *oldest_invalid_trans_id,unsigned long *newest_mount_id) {struct reiserfs_journal_desc *desc;
@@ -2124,18 +2124,18 @@ static void brelse_array(struct buffer_hstatic int journal_read_transaction (struct super_block *p_s_sb,unsigned long cur_dblock,unsigned long oldest_start, -unsigned long oldest_trans_id, +unsigned int oldest_trans_id,unsigned long newest_mount_id) {struct reiserfs_journal *journal =SB_JOURNAL (p_s_sb);struct reiserfs_journal_desc *desc;struct reiserfs_journal_commit *commit; -unsigned long trans_id =0 ; +unsigned int trans_id =0 ;struct buffer_head *c_bh;struct buffer_head *d_bh;struct buffer_head **log_blocks =NULL ;struct buffer_head **real_blocks =NULL ; -unsigned long trans_offset; +unsigned int trans_offset;int i;int trans_half;
@@ -2356,8 +2356,8 @@ static int journal_read(struct super_blo {struct reiserfs_journal *journal =SB_JOURNAL (p_s_sb);struct reiserfs_journal_desc *desc; -unsigned long oldest_trans_id =0 ; -unsigned long oldest_invalid_trans_id =0 ; +unsigned int oldest_trans_id =0 ; +unsigned int oldest_invalid_trans_id =0 ;time_t start;unsigned long oldest_start =0 ;unsigned long cur_dblock =0 ;
@@ -2970,7 +2970,7 @@ static void wake_queued_writers(struct swake_up (&journal->j_join_wait); } -static void let_transaction_grow (struct super_block *sb,unsigned long trans_id) +static void let_transaction_grow (struct super_block *sb,unsigned int trans_id) {struct reiserfs_journal *journal =SB_JOURNAL (sb);unsigned long bcount = journal->j_bcount;
@@ -3001,7 +3001,7 @@ static int do_journal_begin_r(struct rei int join) {time_t now =get_seconds (); -int old_trans_id; +unsigned int old_trans_id;struct reiserfs_journal *journal =SB_JOURNAL (p_s_sb);struct reiserfs_transaction_handle myth;int sched_count =0 ;
@@ -3824,7 +3824,7 @@ static int __commit_trans_jl(struct inodint reiserfs_commit_for_inode (struct inode *inode) { -unsigned long id =REISERFS_I (inode)->i_trans_id; +unsigned int id =REISERFS_I (inode)->i_trans_id;struct reiserfs_journal_list *jl =REISERFS_I (inode)->i_jl;/* for the whole inode, assume unset id means it was
@@ -3938,7 +3938,7 @@ static int do_journal_end(struct reiserfstruct reiserfs_journal_list *jl, *temp_jl;struct list_head *entry, *safe;unsigned long jindex; -unsigned long commit_trans_id; +unsigned int commit_trans_id;int trans_half;BUG_ON (th->t_refcount >1 );
@@ -3946,7 +3946,7 @@ static int do_journal_end(struct reiserf/* protect flush_older_commits from doing mistakes if the transaction ID counter gets overflowed. */ -if (th->t_trans_id == ~0UL ) +if (th->t_trans_id == ~0U ) flags |=FLUSH_ALL |COMMIT_NOW |WAIT ; flush = flags &FLUSH_ALL ; wait_on_commit = flags &WAIT ;
fs/reiserfs/procfs.c +2 -2
@@ -321,7 +321,7 @@ static int show_journal(struct seq_file/* incore fields */ "j_1st_reserved_block: \t%i\n" "j_state: \t%li\n" -"j_trans_id: \t%lu\n" +"j_trans_id: \t%u\n" "j_mount_id: \t%lu\n" "j_start: \t%lu\n" "j_len: \t%lu\n"
@@ -329,7 +329,7 @@ static int show_journal(struct seq_file"j_wcount: \t%i\n" "j_bcount: \t%lu\n" "j_first_unflushed_offset: \t%lu\n" -"j_last_flush_trans_id: \t%lu\n" +"j_last_flush_trans_id: \t%u\n" "j_trans_start_time: \t%li\n" "j_list_bitmap_index: \t%i\n" "j_must_wait: \t%i\n"
include/linux/reiserfs_fs.h +1 -1
@@ -1676,7 +1676,7 @@ struct reiserfs_transaction_handle {int t_refcount;int t_blocks_logged;/* number of blocks this writer has logged */ int t_blocks_allocated;/* number of blocks this writer allocated */ -unsigned long t_trans_id;/* sanity check, equals the current trans id */ +unsigned int t_trans_id;/* sanity check, equals the current trans id */ void *t_handle_save;/* save existing current->journal_info */ unsigned displace_new_blocks:1; /* if new block allocation occurres, that blockshould be displaced from others */
include/linux/reiserfs_fs_i.h +1 -1
@@ -51,7 +51,7 @@ struct reiserfs_inode_info {/* we use these for fsync or O_SYNC to decide which transaction ** needs to be committed in order for this inode to be properly ** flushed */ -unsigned long i_trans_id; +unsigned int i_trans_id;struct reiserfs_journal_list *i_jl;struct mutex i_mmap;#ifdef CONFIG_REISERFS_FS_POSIX_ACL
include/linux/reiserfs_fs_sb.h +4 -4
@@ -156,7 +156,7 @@ struct reiserfs_journal_list {atomic_t j_commit_left;atomic_t j_older_commits_done;/* all commits older than this on disk */ struct mutex j_commit_mutex; -unsigned long j_trans_id; +unsigned int j_trans_id;time_t j_timestamp;struct reiserfs_list_bitmap *j_list_bitmap;struct buffer_head *j_commit_bh;/* commit buffer head */
@@ -185,7 +185,7 @@ struct reiserfs_journal {int j_1st_reserved_block;/* first block on s_dev of reserved area journal */ unsigned long j_state; -unsigned long j_trans_id; +unsigned int j_trans_id;unsigned long j_mount_id;unsigned long j_start;/* start of current waiting commit (index into j_ap_blocks) */ unsigned long j_len;/* length of current waiting commit */
@@ -226,10 +226,10 @@ struct reiserfs_journal {int j_num_work_lists;/* number that need attention from kreiserfsd */ /* debugging to make sure things are flushed in order */ -int j_last_flush_id; +unsigned int j_last_flush_id;/* debugging to make sure things are committed in order */ -int j_last_commit_id; +unsigned int j_last_commit_id;struct list_head j_bitmap_nodes;struct list_head j_dirty_buffers;
PATCH 3/35 reiserfs: use buffer_info for leaf_paste_entries
In reply to Jeff Mahoney This patch makes leaf_paste_entries more consistent with respect to the other leaf operations. Using buffer_info instead of buffer_head directly allows us to get a superblock pointer for use in error handling.
--- fs/reiserfs/do_balan.c | 17 +++++++---------- fs/reiserfs/lbalance.c | 5 +++-- include/linux/reiserfs_fs.h | 2 +- 3 files changed, 11 insertions(+), 13 deletions(-)
fs/reiserfs/do_balan.c +7 -10
@@ -449,8 +449,7 @@ static int balance_leaf(struct tree_bala/* 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, + leaf_paste_entries(&bi, n + item_pos -
@@ -699,7 +698,7 @@ static int balance_leaf(struct tree_bala n + item_pos - ret_val);if (is_direntry_le_ih (pasted)) - leaf_paste_entries(bi.bi_bh, + leaf_paste_entries(&bi, n + item_pos - ret_val,
@@ -894,8 +893,7 @@ static int balance_leaf(struct tree_bala tb->insert_size[0 ], body, zeros_num);/* paste entry */ - leaf_paste_entries(bi. - bi_bh, + leaf_paste_entries(&bi, 0, paste_entry_position, 1,
@@ -1096,7 +1094,7 @@ static int balance_leaf(struct tree_bala tb->rnum[0]);if (is_direntry_le_ih (pasted) && pos_in_item >=0 ) { - leaf_paste_entries(bi.bi_bh, + leaf_paste_entries(&bi, item_pos - n + tb->rnum[0],
@@ -1339,8 +1337,7 @@ static int balance_leaf(struct tree_bala tb->insert_size[0 ], body, zeros_num);/* paste new directory entry */ - leaf_paste_entries(bi. - bi_bh, + leaf_paste_entries(&bi, 0, pos_in_item -
@@ -1505,7 +1502,7 @@ static int balance_leaf(struct tree_bala item_pos - n + snum[i]);if (is_direntry_le_ih (pasted)) { - leaf_paste_entries(bi.bi_bh, + leaf_paste_entries(&bi, item_pos - n + snum[i], pos_in_item,
@@ -1606,7 +1603,7 @@ static int balance_leaf(struct tree_bala zeros_num);/* paste entry */ - leaf_paste_entries(bi.bi_bh, + leaf_paste_entries(&bi, item_pos, pos_in_item, 1,
fs/reiserfs/lbalance.c +3 -2
@@ -111,7 +111,7 @@ static void leaf_copy_dir_entries(struct item_num_in_dest = (last_first ==FIRST_TO_LAST ) ? (B_NR_ITEMS (dest) -1 ) :0 ; - leaf_paste_entries(dest_bi->bi_bh, item_num_in_dest, + leaf_paste_entries(dest_bi, item_num_in_dest, (last_first == FIRST_TO_LAST) ? I_ENTRY_COUNT(B_N_PITEM_HEAD(dest, item_num_in_dest))
@@ -1191,7 +1191,7 @@ static void leaf_delete_items_entirely(s }/* paste new_entry_count entries (new_dehs, records) into position before to item_num-th item */ -void leaf_paste_entries(struct buffer_head *bh, +void leaf_paste_entries(struct buffer_info *bi, int item_num, int before, int new_entry_count,
@@ -1203,6 +1203,7 @@ void leaf_paste_entries(struct buffer_hestruct reiserfs_de_head *deh;char *insert_point;int i, old_entry_num; +struct buffer_head *bh = bi->bi_bh;if (new_entry_count ==0 )return ;
include/linux/reiserfs_fs.h +1 -1
@@ -2026,7 +2026,7 @@ void leaf_paste_in_buffer(struct buffer_ int zeros_number);void leaf_cut_from_buffer (struct buffer_info *bi,int cut_item_num,int pos_in_item,int cut_size); -void leaf_paste_entries (struct buffer_head *bh,int item_num,int before, +void leaf_paste_entries (struct buffer_info *bi,int item_num,int before,int new_entry_count,struct reiserfs_de_head *new_dehs,const char *records,int paste_size);/* ibalance.c */
PATCH 4/35 reiserfs: use more consistent printk formatting
In reply to Jeff MahoneyThe 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.
--
fs/reiserfs/prints.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
fs/reiserfs/prints.c +14 -14
@@ -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 }
@@ -368,15 +368,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);
PATCH 5/35 reiserfs: make some warnings informational
In reply to Jeff Mahoney 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.
--
fs/reiserfs/bitmap.c | 6 +++--- fs/reiserfs/super.c | 14 ++++++-------- fs/reiserfs/xattr.c | 10 ++++------ 3 files changed, 13 insertions(+), 17 deletions(-)
fs/reiserfs/bitmap.c +3 -3
@@ -40,8 +40,8 @@#define SET_OPTION (optname) \ do { \ - reiserfs_warning(s, "reiserfs: option \"%s\" is set", #optname); \ - set_bit(_ALLOC_ ## optname , &SB_ALLOC_OPTS(s)); \ + 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) \ test_bit(_ALLOC_ ## optname , &SB_ALLOC_OPTS(s))
@@ -636,7 +636,7 @@ int reiserfs_parse_alloc_options(structreturn 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 ; }
fs/reiserfs/super.c +6 -8
@@ -1380,13 +1380,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 "
@@ -1465,8 +1463,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));
fs/reiserfs/xattr.c +4 -6
@@ -1182,12 +1182,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 ;
PATCH 6/35 reiserfs: rework reiserfs_warning
In reply to Jeff Mahoney 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.
--
fs/reiserfs/bitmap.c | 52 +++----- fs/reiserfs/do_balan.c | 40 +++--- fs/reiserfs/file.c | 2 fs/reiserfs/fix_node.c | 14 +- fs/reiserfs/inode.c | 60 ++++----- fs/reiserfs/item_ops.c | 60 +++++---- fs/reiserfs/journal.c | 174 +++++++++++++++------------- 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 | 257 ++++++++++++++++++++++-------------------- fs/reiserfs/tail_conversion.c | 6 fs/reiserfs/xattr.c | 21 ++- include/linux/reiserfs_fs.h | 9 - 17 files changed, 454 insertions(+), 426 deletions(-)
fs/reiserfs/bitmap.c +23 -29
@@ -64,8 +64,8 @@ int is_reusable(struct super_block *s, bunsigned int bmap_count =reiserfs_bmap_count (s);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 ; }
@@ -79,30 +79,29 @@ int is_reusable(struct super_block *s, bb_blocknr_t bmap1 =REISERFS_SB (s)->s_sbh->b_blocknr +1 ;if (block >= bmap1 && block <= bmap1 + bmap_count) { -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, bmap_count);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, bmap_count);return 0 ; } }if (bmap >= bmap_count) { -reiserfs_warning (s, -"vs-4030: is_reusable: there is no so many bitmap blocks: " -"block=%lu, bitmap_nr=%u" , block, bmap); +reiserfs_warning (s,"vs-4030" ,"bitmap for requested block " +"is out of range: block=%lu, bitmap_nr=%u" , + 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 ; }
@@ -154,8 +153,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 ; }
@@ -400,11 +399,8 @@ static void _reiserfs_free_block(structget_bit_address (s, block, &nr, &offset);if (nr >=reiserfs_bmap_count (s)) { -reiserfs_warning (s,"vs-4075: reiserfs_free_block: " -"block %lu is out of range on %s " -"(nr=%u,max=%u)" , block, -reiserfs_bdevname (s), nr, -reiserfs_bmap_count (s)); +reiserfs_warning (s,"vs-4075" ,"block %lu is out of range" , + block);return ; }
@@ -416,9 +412,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);
@@ -477,9 +472,8 @@ static void __discard_prealloc(struct reBUG_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." , - __func__); +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);
@@ -515,9 +509,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." , - __func__); +reiserfs_warning (th->t_super,"zam-4001" , +"inode is in prealloc list but has " +"no preallocated blocks." ); }#endif __discard_prealloc (th, ei);
@@ -631,8 +625,8 @@ int reiserfs_parse_alloc_options(structcontinue ; } -reiserfs_warning (s,"zam-4001: %s : unknown option - %s" , - __func__, this_char); +reiserfs_warning (s,"zam-4001" ,"unknown option - %s" , + this_char);return 1 ; }
fs/reiserfs/do_balan.c +20 -20
@@ -1752,15 +1752,16 @@ static void store_thrown(struct tree_balint 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)
@@ -1771,8 +1772,8 @@ static void free_thrown(struct tree_balaif (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,
@@ -1877,13 +1878,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 ;
@@ -1902,18 +1902,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;
@@ -1952,7 +1953,7 @@ static void check_after_balance_leaf(strPATH_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,
@@ -2104,9 +2105,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 ; }
fs/reiserfs/file.c +1 -1
@@ -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);
fs/reiserfs/fix_node.c +7 -7
@@ -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, structif (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 */
@@ -2268,9 +2268,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. */
fs/reiserfs/inode.c +29 -31
154 lines not on this page · raw message
fs/reiserfs/item_ops.c +32 -28
153 lines not on this page · raw message
fs/reiserfs/journal.c +93 -81
420 lines not on this page · raw message
fs/reiserfs/lbalance.c +8 -4
@@ -1288,12 +1288,16 @@ void leaf_paste_entries(struct buffer_in 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 ); } }
fs/reiserfs/namei.c +21 -24
99 lines not on this page · raw message
fs/reiserfs/objectid.c +2 -3
@@ -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" , __func__); +reiserfs_warning (s,"reiserfs-15100" ,"no more object ids" );reiserfs_restore_prepared_buffer (s,SB_BUFFER_WITH_SB (s));return 0 ; }
@@ -160,8 +160,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); }
fs/reiserfs/prints.c +7 -4
@@ -264,14 +264,17 @@ static void prepare_error_buf(const charva_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 */
fs/reiserfs/procfs.c +2 -3
@@ -503,7 +503,7 @@ int reiserfs_proc_info_init(struct superadd_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 ; }
@@ -559,8 +559,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 ; }
fs/reiserfs/stree.c +50 -57
258 lines not on this page · raw message
fs/reiserfs/super.c +137 -120
594 lines not on this page · raw message
fs/reiserfs/tail_conversion.c +3 -3
@@ -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 ; }
fs/reiserfs/xattr.c +13 -8
@@ -259,7 +259,8 @@ static int __xattr_readdir(struct inode 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);
@@ -598,7 +599,7 @@ reiserfs_xattr_get(const struct inode *iif (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));
@@ -618,7 +619,7 @@ reiserfs_xattr_get(const struct inode *iif (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 ;
@@ -652,7 +653,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,
@@ -750,7 +752,7 @@ int reiserfs_delete_xattrs(struct inodereiserfs_write_unlock_xattrs (inode->i_sb);dput (root); }else { -reiserfs_warning (inode->i_sb, +reiserfs_warning (inode->i_sb,"jdm-20006" ,"Couldn't remove all entries in directory" ); }unlock_kernel ();
@@ -1154,7 +1156,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;
@@ -1201,8 +1204,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 ; } }
include/linux/reiserfs_fs.h +6 -3
@@ -79,7 +79,10 @@ struct fid;*/ #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, __func__, fmt, ##args)/* assertions handling */ /** always check a condition and panic if it's false. */
@@ -558,7 +561,7 @@ static inline int uniqueness2type(__u32case 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 ;
@@ -578,7 +581,7 @@ static inline __u32 type2uniqueness(intcase 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 ; }
PATCH 7/35 reiserfs: prepare_error_buf wrongly consumes va_arg
In reply to Jeff Mahoneyvsprintf will consume varargs on its own. Skipping them manually results in garbage in the error buffer, or Oopses in the case of pointers.
This patch removes the advancement and fixes a number of bugs where crashes were observed as side effects of a regular error report.
---
fs/reiserfs/prints.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
fs/reiserfs/prints.c +3 -9
@@ -157,19 +157,16 @@ static void sprintf_disk_child(char *buf dc_size(dc)); } -static char *is_there_reiserfs_struct (char *fmt,int *what,int *skip) +static char *is_there_reiserfs_struct (char *fmt,int *what) {char *k = fmt; - *skip =0 ; -while ((k =strchr (k,'%' )) !=NULL ) {if (k[1 ] =='k' || k[1 ] =='K' || k[1 ] =='h' || k[1 ] =='t' || k[1 ] =='z' || k[1 ] =='b' || k[1 ] =='y' || k[1 ] =='a' ) { *what = k[1 ];break ; } - (*skip)++; k++; }return k;
@@ -193,18 +190,15 @@ static void prepare_error_buf(const charchar *fmt1 = fmt_buf;char *k;char *p = error_buf; -int i, j, what, skip; +int what;strcpy (fmt1, fmt); -while ((k =is_there_reiserfs_struct (fmt1, &what, &skip)) !=NULL ) { +while ((k =is_there_reiserfs_struct (fmt1, &what)) !=NULL ) { *k =0 ; p +=vsprintf (p, fmt1, args); -for (i =0 ; i < skip; i++) - j =va_arg (args, int); -switch (what) {case 'k' : sprintf_le_key(p, va_arg(args, struct reiserfs_key *));
PATCH 8/35 reiserfs: eliminate reiserfs_warning from uniqueness functions
In reply to Jeff Mahoney uniqueness2type and type2uniquness issue a warning when the value is unknown. When called from reiserfs_warning, this causes a re-entrancy problem and deadlocks on the error buffer lock.
--- include/linux/reiserfs_fs.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
include/linux/reiserfs_fs.h +2 -5
@@ -560,10 +560,8 @@ static inline int uniqueness2type(__u32return TYPE_DIRECT ;case V1_DIRENTRY_UNIQUENESS :return TYPE_DIRENTRY ; -default : -reiserfs_warning (NULL ,"vs-500" ,"unknown uniqueness %d" , - uniqueness);case V1_ANY_UNIQUENESS : +default :return TYPE_ANY ; } }
@@ -580,9 +578,8 @@ static inline __u32 type2uniqueness(intreturn V1_DIRECT_UNIQUENESS ;case TYPE_DIRENTRY :return V1_DIRENTRY_UNIQUENESS ; -default : -reiserfs_warning (NULL ,"vs-501" ,"unknown type %d" , type);case TYPE_ANY : +default :return V1_ANY_UNIQUENESS ; } }
PATCH 9/35 reiserfs: add locking around error buffer
In reply to Jeff MahoneyThe formatting of the error buffer is race prone. It uses static buffers for both formatting and output. While overwriting the error buffer can product garbled output, overwriting the format buffer with incompatible % directives can cause crashes.
--- fs/reiserfs/prints.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/reiserfs/prints.c +4 -1
@@ -184,7 +184,7 @@ static char *is_there_reiserfs_struct(chprintk ("bad key %lu %lu %lu %lu", key->k_dir_id, key->k_objectid, key->k_offset, key->k_uniqueness); */ - +static DEFINE_SPINLOCK (error_lock);static void prepare_error_buf (const char *fmt,va_list args) {char *fmt1 = fmt_buf;
@@ -192,6 +192,8 @@ static void prepare_error_buf(const charchar *p = error_buf;int what; +spin_lock (&error_lock); +strcpy (fmt1, fmt);while ((k =is_there_reiserfs_struct (fmt1, &what)) !=NULL ) {
@@ -237,6 +239,7 @@ static void prepare_error_buf(const char fmt1 = k +2 ; }vsprintf (p, fmt1, args); +spin_unlock (&error_lock); }
Re: [patch 09/35 error-handling] reiserfs: add locking around error buffer
Quoted 4 lines · Jeff Mahoney
The formatting of the error buffer is race prone. It uses static buffers for both formatting and output. While overwriting the error buffer can product garbled output, overwriting the format buffer with incompatible % directives can cause crashes.
Really? Just curious but could you describe the steps how a garbled printk can leads to a crash?
Thanks,
-Andi
Signature · 1 line
[email protected] -- Speaking for myself only.
Re: [patch 09/35 error-handling] reiserfs: add locking around error buffer
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 9 lines · Andi Kleen
Quoted 4 lines · Jeff Mahoney
The formatting of the error buffer is race prone. It uses static buffers for both formatting and output. While overwriting the error buffer can product garbled output, overwriting the format buffer with incompatible % directives can cause crashes.
Really? Just curious but could you describe the steps how a garbled printk can leads to a crash?
Yeah, I was surprised by this one as well, but I was convinced by seeing too many crashes that ended in prepare_error_buf with no other explanation.
Reiserfs has this really hacky way of formatting extended pointer types where it copies the format buffer into a static buffer. If another thread copies its format string into the format buffer while the first thread is formatting its output, it can hit a pointer format that will consume whatever happens to be on the stack whether it's valid or not.
I posted patches implementing extensible pointer types for printk to avoid problems like this, but nobody commented on them. prepare_error_buf() depends on undefined varargs behavior that just happens to work. Something changed recently where I had to change it stop consuming args manually, which is in another patch.
- -Jeff
- --
Jeff Mahoney
SUSE Labs
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org
iEYEARECAAYFAknRHlcACgkQLPWxlyuTD7JgtACgiLRbO1IGhvKjmg6wCcZDhR9i jkwAn0e81mXl6JvgZqmKqK8f09fApaoq
=fB0H
-----END PGP SIGNATURE-----
PATCH 10/35 reiserfs: rework reiserfs_panic
In reply to Jeff Mahoney 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 | 67 +++++++++++++++++++++-------------------- fs/reiserfs/fix_node.c | 68 +++++++++++++++++++++--------------------- fs/reiserfs/ibalance.c | 12 +++---- fs/reiserfs/inode.c | 3 - fs/reiserfs/item_ops.c | 8 +++- fs/reiserfs/journal.c | 57 +++++++++++++++++------------------ fs/reiserfs/lbalance.c | 27 +++++++++------- fs/reiserfs/namei.c | 18 ++++------- fs/reiserfs/objectid.c | 3 - fs/reiserfs/prints.c | 33 +++++++++----------- fs/reiserfs/stree.c | 49 ++++++++++++++---------------- fs/reiserfs/tail_conversion.c | 10 ++---- include/linux/reiserfs_fs.h | 28 +++++++++++++---- 13 files changed, 200 insertions(+), 183 deletions(-)
fs/reiserfs/do_balan.c +35 -32
@@ -153,8 +153,8 @@ static int balance_leaf_when_delete(strudefault :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" :
@@ -721,8 +721,9 @@ 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)
@@ -1134,8 +1135,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"
@@ -1165,8 +1166,8 @@ static int balance_leaf(struct tree_balanot 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 );
@@ -1472,7 +1473,10 @@ static int balance_leaf(struct tree_bala && (pos_in_item != ih_item_len(ih_check) || 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 */ leaf_mi =
@@ -1532,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"
@@ -1678,10 +1682,11 @@ static int balance_leaf(struct tree_balaprint_cur_tb ("12285" );reiserfs_panic (tb-> tb_sb, -"PAP-12285: balance_leaf: insert_size must be 0 (%d)" , - tb-> - insert_size - [0]); +"PAP-12285" , +"insert_size " +"must be 0 " +"(%d)" , + tb->insert_size[0]); } }#endif /* CONFIG_REISERFS_CHECK */
@@ -1694,11 +1699,10 @@ static int balance_leaf(struct tree_balaif (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)" , +"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) */
@@ -1729,8 +1733,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];
@@ -1871,8 +1874,8 @@ static void check_internal_node(struct sfor (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); } }
@@ -1894,9 +1897,10 @@ static int check_before_balancing(structint 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
@@ -1928,8 +1932,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 ]) {
@@ -1938,8 +1942,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) &&
@@ -1964,8 +1968,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" ); } }
@@ -2100,8 +2103,8 @@ 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 ]) {
fs/reiserfs/fix_node.c +35 -33
143 lines not on this page · raw message
fs/reiserfs/ibalance.c +6 -6
@@ -105,8 +105,8 @@ static void internal_define_dest_src_infbreak ;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_deletereturn ; } -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_balancestruct 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);
fs/reiserfs/inode.c +1 -2
@@ -1283,8 +1283,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)) {
fs/reiserfs/item_ops.c +5 -3
@@ -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); }
fs/reiserfs/journal.c +29 -28
144 lines not on this page · raw message
fs/reiserfs/lbalance.c +15 -12
@@ -168,10 +168,11 @@ static int leaf_copy_boundary_item(strucif (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(ibreak ;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 || !dest_bi->bi_bh, "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 */
fs/reiserfs/namei.c +8 -10
@@ -145,10 +145,9 @@ int search_by_entry_key(struct super_bloif (!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 */
@@ -1193,15 +1192,14 @@ static int entry_points_to_object(constif (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 ; }
@@ -1315,8 +1313,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);
fs/reiserfs/objectid.c +1 -2
@@ -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
fs/reiserfs/prints.c +16 -17
@@ -356,14 +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); +#ifdef CONFIG_REISERFS_CHECK dump_stack (); - -panic (KERN_EMERG "REISERFS: panic (device %s): %s\n" , -reiserfs_bdevname (sb), error_buf); +#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, ...)
@@ -684,12 +691,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); }
@@ -700,21 +705,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); }
fs/reiserfs/stree.c +23 -26
97 lines not on this page · raw message
fs/reiserfs/tail_conversion.c +4 -6
@@ -92,8 +92,7 @@ int direct2indirect(struct reiserfs_tranlast 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 }
include/linux/reiserfs_fs.h +22 -6
@@ -86,11 +86,14 @@ void __reiserfs_warning(struct super_blo/* assertions handling */ /** always check a condition and panic if it's false. */ -#define __RASSERT( cond, scond, format, args... ) \ -if( !( cond ) ) \ - reiserfs_panic( NULL, "reiserfs[%i]: assertion " scond " failed at " \ - __FILE__ ":%i:%s: " format "\n", \ - in_interrupt() ? -1 : task_pid_nr(current), __LINE__ , __func__ , ##args ) +#define __RASSERT(cond, scond, format, args...) \ +do { \ + if (!(cond)) \ + reiserfs_panic(NULL, "assertion failure", "(" #cond ") at " \ + __FILE__ ":%i:%s: " format "\n", \ + in_interrupt() ? -1 : task_pid_nr(current), \ + __LINE__, __func__ , ##args); \ +} while (0) #define RASSERT(cond, format, args...) __RASSERT(cond, #cond, format, ##args)
@@ -1448,6 +1451,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? |
@@ -1988,8 +2001,11 @@ int fix_nodes(int n_op_mode, struct treevoid 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, __func__, 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);
PATCH 11/35 reiserfs: rearrange journal abort
In reply to Jeff Mahoney 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.
--- fs/reiserfs/journal.c | 23 ++++------------------- fs/reiserfs/prints.c | 2 +- include/linux/reiserfs_fs.h | 2 +- 3 files changed, 6 insertions(+), 21 deletions(-)
fs/reiserfs/journal.c +4 -19
@@ -4295,14 +4295,15 @@ static int do_journal_end(struct reiserfreturn 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);
@@ -4312,19 +4313,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) -{ -__reiserfs_journal_abort_soft (sb, errno); -}
fs/reiserfs/prints.c +1 -1
@@ -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,
include/linux/reiserfs_fs.h +1 -1
@@ -1771,7 +1771,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 *,unsigned int );
PATCH 12/35 reiserfs: introduce reiserfs_error()
In reply to Jeff Mahoney 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.
--
fs/reiserfs/prints.c | 25 +++++++++++++++++++++++++ include/linux/reiserfs_fs.h | 4 ++++ 2 files changed, 29 insertions(+)
fs/reiserfs/prints.c +25 -0
@@ -373,6 +373,31 @@ 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); + +BUG_ON (sb ==NULL ); + +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);
include/linux/reiserfs_fs.h +4 -0
@@ -2006,6 +2006,10 @@ void __reiserfs_panic(struct super_block __attribute__ ((noreturn)); #define reiserfs_panic(s, id, fmt, args...) \ __reiserfs_panic(s, id, __func__, 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, __func__, 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);
PATCH 13/35 reiserfs: use reiserfs_error()
In reply to Jeff MahoneyThis patch makes many paths that are currently using warnings to handle the error.
--
fs/reiserfs/bitmap.c | 56 +++++++++++++++++++++--------------------- fs/reiserfs/inode.c | 45 +++++++++++++++------------------ fs/reiserfs/lbalance.c | 20 +++++++-------- fs/reiserfs/namei.c | 24 +++++++++--------- fs/reiserfs/objectid.c | 4 +-- fs/reiserfs/stree.c | 26 +++++++++---------- fs/reiserfs/super.c | 15 +++++------ fs/reiserfs/tail_conversion.c | 6 ++-- fs/reiserfs/xattr.c | 21 +++++++-------- 9 files changed, 107 insertions(+), 110 deletions(-)
fs/reiserfs/bitmap.c +29 -27
@@ -64,9 +64,9 @@ int is_reusable(struct super_block *s, bunsigned int bmap_count =reiserfs_bmap_count (s);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 ; }
@@ -79,30 +79,30 @@ int is_reusable(struct super_block *s, bb_blocknr_t bmap1 =REISERFS_SB (s)->s_sbh->b_blocknr +1 ;if (block >= bmap1 && block <= bmap1 + bmap_count) { -reiserfs_warning (s,"vs-4019" ,"bitmap block %lu(%u) " -"can't be freed or reused" , - block, bmap_count); +reiserfs_error (s,"vs-4019" ,"bitmap block %lu(%u) " +"can't be freed or reused" , + block, bmap_count);return 0 ; } }else {if (offset ==0 ) { -reiserfs_warning (s,"vs-4020" ,"bitmap block %lu(%u) " -"can't be freed or reused" , - block, bmap_count); +reiserfs_error (s,"vs-4020" ,"bitmap block %lu(%u) " +"can't be freed or reused" , + block, bmap_count);return 0 ; } }if (bmap >= bmap_count) { -reiserfs_warning (s,"vs-4030" ,"bitmap for requested block " -"is out of range: block=%lu, bitmap_nr=%u" , - block, bmap); +reiserfs_error (s,"vs-4030" ,"bitmap for requested block " +"is out of range: block=%lu, bitmap_nr=%u" , + 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 ; }
@@ -153,8 +153,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 ; }
@@ -399,8 +399,8 @@ static void _reiserfs_free_block(structget_bit_address (s, block, &nr, &offset);if (nr >=reiserfs_bmap_count (s)) { -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 ; }
@@ -412,8 +412,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);
@@ -440,7 +440,7 @@ void reiserfs_free_block(struct reiserfsreturn ;if (block >sb_block_count (REISERFS_SB (s)->s_rs)) { -reiserfs_panic (th->t_super,"bitmap-4072" , +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));
@@ -472,8 +472,8 @@ static void __discard_prealloc(struct reBUG_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);
@@ -509,9 +509,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);
@@ -1214,7 +1214,9 @@ void reiserfs_cache_bitmap_metadata(struunsigned long *cur = (unsigned long *)(bh->b_data + bh->b_size);/* The first bit must ALWAYS be 1 */ -BUG_ON (!reiserfs_test_le_bit (0 , (unsigned long *)bh->b_data)); +if (!reiserfs_test_le_bit (0 , (unsigned long *)bh->b_data)) +reiserfs_error (sb,"reiserfs-2025" ,"bitmap block %lu is " +"corrupted: first bit must be 1" , bh->b_blocknr); info->free_count =0 ;
fs/reiserfs/inode.c +21 -24
87 lines not on this page · raw message
fs/reiserfs/lbalance.c +10 -10
@@ -1291,17 +1291,17 @@ void leaf_paste_entries(struct buffer_in 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 (sb_from_bi (bi),"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 (sb_from_bi (bi),"vs-10250" , +"directory item (%h) " +"corrupted (cur(%d) %a, " +"next %a)" , + ih, i, deh + i, deh + i + 1); } }#endif
fs/reiserfs/namei.c +12 -12
@@ -120,8 +120,8 @@ int search_by_entry_key(struct super_bloswitch (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_blodefault :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 insearch_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 ; }
@@ -481,9 +481,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 ;
@@ -899,9 +899,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 ;
@@ -1494,8 +1494,8 @@ static int reiserfs_rename(struct inodeif (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;
fs/reiserfs/objectid.c +2 -2
@@ -159,8 +159,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)
fs/reiserfs/stree.c +13 -13
@@ -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 ; }
@@ -1336,9 +1336,9 @@ void reiserfs_delete_solid_item(struct rwhile (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 ) {
@@ -1737,7 +1737,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 );
@@ -1790,16 +1790,16 @@ int reiserfs_do_truncate(struct reiserfssearch_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;
fs/reiserfs/super.c +7 -8
@@ -195,9 +195,8 @@ static int finish_unfinished(struct supewhile (!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 ; }
@@ -378,9 +377,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 ; }
@@ -393,8 +392,8 @@ void add_save_link(struct reiserfs_transreiserfs_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 |=
fs/reiserfs/tail_conversion.c +3 -3
@@ -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 ; }
fs/reiserfs/xattr.c +10 -11
@@ -259,8 +259,8 @@ static int __xattr_readdir(struct inode 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);
@@ -653,15 +653,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 ; }
PATCH 14/35 reiserfs: small variable cleanup
In reply to Jeff MahoneyThis patch removes the xinode and mapping variables from reiserfs_xattr_{get,set}.
--- fs/reiserfs/xattr.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-)
fs/reiserfs/xattr.c +8 -12
@@ -420,10 +420,8 @@ reiserfs_xattr_set(struct inode *inode,struct dentry *dentry;struct page *page;char *data; -struct address_space *mapping;size_t file_pos =0 ;size_t buffer_pos =0 ; -struct inode *xinode;struct iattr newattrs;__u32 xahash =0 ;
@@ -441,11 +439,10 @@ reiserfs_xattr_set(struct inode *inode, goto out; } - xinode = dentry->d_inode;REISERFS_I (inode)->i_flags |= i_has_xattr_dir;/* we need to copy it off.. */ -if (xinode->i_nlink >1 ) { +if (dentry->d_inode->i_nlink >1 ) {dput (dentry); err =reiserfs_xattr_del (inode, name);if (err <0 )
@@ -459,12 +456,11 @@ 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_nested (&xinode->i_mutex,I_MUTEX_XATTR ); +mutex_lock_nested (&dentry->d_inode->i_mutex,I_MUTEX_XATTR ); err =notify_change (dentry, &newattrs);if (err) goto out_filp; - mapping = xinode->i_mapping;while (buffer_pos < buffer_size || buffer_pos ==0 ) {size_t chunk;size_t skip =0 ;
@@ -474,7 +470,8 @@ reiserfs_xattr_set(struct inode *inode,else chunk = buffer_size - buffer_pos; - page =reiserfs_get_page (xinode, file_pos >>PAGE_CACHE_SHIFT ); + page =reiserfs_get_page (dentry->d_inode, + file_pos >>PAGE_CACHE_SHIFT );if (IS_ERR (page)) { err =PTR_ERR (page); goto out_filp;
@@ -521,7 +518,7 @@ reiserfs_xattr_set(struct inode *inode, } out_filp: -mutex_unlock (&xinode->i_mutex); +mutex_unlock (&dentry->d_inode->i_mutex);dput (dentry); out:
@@ -541,7 +538,6 @@ reiserfs_xattr_get(const struct inode *isize_t file_pos =0 ;size_t buffer_pos =0 ;struct page *page; -struct inode *xinode;__u32 hash =0 ;if (name ==NULL )
@@ -558,8 +554,7 @@ reiserfs_xattr_get(const struct inode *i goto out; } - xinode = dentry->d_inode; - isize = xinode->i_size; + isize =i_size_read (dentry->d_inode);REISERFS_I (inode)->i_flags |= i_has_xattr_dir;/* Just return the size needed */
@@ -582,7 +577,8 @@ reiserfs_xattr_get(const struct inode *ielse chunk = isize - file_pos; - page =reiserfs_get_page (xinode, file_pos >>PAGE_CACHE_SHIFT ); + page =reiserfs_get_page (dentry->d_inode, + file_pos >>PAGE_CACHE_SHIFT );if (IS_ERR (page)) { err =PTR_ERR (page); goto out_dput;
PATCH 15/35 reiserfs: xattr reiserfs_get_page takes offset instead of index
In reply to Jeff Mahoney This patch changes reiserfs_get_page to take an
offset rather than an index since no callers calculate the index differently.
--- fs/reiserfs/xattr.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
fs/reiserfs/xattr.c +4 -6
@@ -376,14 +376,14 @@ static inline void reiserfs_put_page(strpage_cache_release (page); } -static struct page *reiserfs_get_page (struct inode *dir,unsigned long n) +static struct page *reiserfs_get_page (struct inode *dir,size_t n) {struct address_space *mapping = dir->i_mapping;struct page *page;/* We can deadlock if we try to free dentries, and an unlink/rmdir has just occured - GFP_NOFS avoids this */ mapping_set_gfp_mask (mapping,GFP_NOFS ); - page =read_mapping_page (mapping, n,NULL ); + page =read_mapping_page (mapping, n >>PAGE_CACHE_SHIFT ,NULL );if (!IS_ERR (page)) {kmap (page);if (PageError (page))
@@ -470,8 +470,7 @@ reiserfs_xattr_set(struct inode *inode,else chunk = buffer_size - buffer_pos; - page =reiserfs_get_page (dentry->d_inode, - file_pos >>PAGE_CACHE_SHIFT ); + page =reiserfs_get_page (dentry->d_inode, file_pos);if (IS_ERR (page)) { err =PTR_ERR (page); goto out_filp;
@@ -577,8 +576,7 @@ reiserfs_xattr_get(const struct inode *ielse chunk = isize - file_pos; - page =reiserfs_get_page (dentry->d_inode, - file_pos >>PAGE_CACHE_SHIFT ); + page =reiserfs_get_page (dentry->d_inode, file_pos);if (IS_ERR (page)) { err =PTR_ERR (page); goto out_dput;
PATCH 16/35 reiserfs: remove link detection code
In reply to Jeff MahoneyEarly 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.
--- fs/reiserfs/xattr.c | 13 ------------- 1 file changed, 13 deletions(-)
fs/reiserfs/xattr.c +0 -13
@@ -432,7 +432,6 @@ reiserfs_xattr_set(struct inode *inode,if (buffer && buffer_size) xahash =xattr_hash (buffer, buffer_size); - open_file: dentry =get_xa_file_dentry (inode, name, flags);if (IS_ERR (dentry)) { err =PTR_ERR (dentry);
@@ -441,18 +440,6 @@ reiserfs_xattr_set(struct inode *inode,REISERFS_I (inode)->i_flags |= i_has_xattr_dir; -/* we need to copy it off.. */ -if (dentry->d_inode->i_nlink >1 ) { -dput (dentry); - 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 ;
PATCH 17/35 reiserfs: remove IS_PRIVATE helpers
In reply to Jeff Mahoney There are a number of helper functions for marking a reiserfs inode private that were leftover from reiserfs did its own thing wrt to private inodes. S_PRIVATE has been in the kernel for some time, so this patch removes the helpers and uses IS_PRIVATE instead.
--- fs/reiserfs/inode.c | 5 ++--- fs/reiserfs/namei.c | 7 ++++--- fs/reiserfs/xattr.c | 14 ++++++-------- fs/reiserfs/xattr_acl.c | 6 +++--- fs/reiserfs/xattr_security.c | 8 ++++---- fs/reiserfs/xattr_trusted.c | 8 ++++---- include/linux/reiserfs_xattr.h | 8 -------- 7 files changed, 23 insertions(+), 33 deletions(-)
fs/reiserfs/inode.c +2 -3
@@ -1932,9 +1932,8 @@ int reiserfs_new_inode(struct reiserfs_treiserfs_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); - } + }else if (IS_PRIVATE (dir)) + inode->i_flags |=S_PRIVATE ;reiserfs_update_sd (th, inode);
reiserfs_check_path(&path_to_key);
fs/reiserfs/namei.c +4 -3
@@ -358,9 +358,10 @@ static struct dentry *reiserfs_lookup(streturn ERR_PTR (-EACCES ); } -/* Propogate the priv_object flag so we know we're in the priv tree */ -if (is_reiserfs_priv_object (dir)) -reiserfs_mark_inode_private (inode); +/* Propogate the private flag so we know we're +* in the priv tree */ +if (IS_PRIVATE (dir)) + inode->i_flags |=S_PRIVATE ; }reiserfs_write_unlock (dir->i_sb);if (retval ==IO_ERROR ) {
fs/reiserfs/xattr.c +6 -8
@@ -633,14 +633,14 @@ __reiserfs_xattr_del(struct dentry *xadiif (S_ISDIR (dentry->d_inode->i_mode)) goto out_file; -if (!is_reiserfs_priv_object (dentry->d_inode)) { +if (!IS_PRIVATE (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) ?"" : +IS_PRIVATE (xadir->d_inode) ?"" :"not " );dput (dentry);return -EIO ;
@@ -701,8 +701,7 @@ int reiserfs_delete_xattrs(struct inodeint 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 || +if (IS_PRIVATE (inode) ||get_inode_sd_version (inode) ==STAT_DATA_V1 || !reiserfs_xattrs (inode->i_sb)) {return 0 ; }
@@ -786,8 +785,7 @@ int reiserfs_chown_xattrs(struct inode *unsigned int ia_valid = attrs->ia_valid;/* Skip out, an xattr has no xattrs associated with it */ -if (is_reiserfs_priv_object (inode) || -get_inode_sd_version (inode) ==STAT_DATA_V1 || +if (IS_PRIVATE (inode) ||get_inode_sd_version (inode) ==STAT_DATA_V1 || !reiserfs_xattrs (inode->i_sb)) {return 0 ; }
@@ -1178,7 +1176,7 @@ int reiserfs_xattr_init(struct super_bloif (!err && dentry) { s->s_root->d_op = &xattr_lookup_poison_ops; -reiserfs_mark_inode_private (dentry->d_inode); + dentry->d_inode->i_flags |=S_PRIVATE ;REISERFS_SB (s)->priv_root = dentry; }else if (!(mount_flags &MS_RDONLY )) {/* xattrs are unavailable */ /* If we're read-only it just means that the dir hasn't been
@@ -1239,7 +1237,7 @@ int reiserfs_permission(struct inode *in* We don't do permission checks on the internal objects. * Permissions are determined by the "owning" object. */ -if (is_reiserfs_priv_object (inode)) +if (IS_PRIVATE (inode))return 0 ;/*
fs/reiserfs/xattr_acl.c +3 -3
@@ -335,8 +335,8 @@ reiserfs_inherit_default_acl(struct inod/* Don't apply ACLs to objects in the .reiserfs_priv tree.. This * would be useless since permissions are ignored, and a pain because * it introduces locking cycles */ -if (is_reiserfs_priv_object (dir)) { -reiserfs_mark_inode_private (inode); +if (IS_PRIVATE (dir)) { + inode->i_flags |=S_PRIVATE ; goto apply_umask; }
@@ -401,7 +401,7 @@ reiserfs_inherit_default_acl(struct inodint reiserfs_cache_default_acl (struct inode *inode) {int ret =0 ; -if (reiserfs_posixacl (inode->i_sb) && !is_reiserfs_priv_object (inode)) { +if (reiserfs_posixacl (inode->i_sb) && !IS_PRIVATE (inode)) {struct posix_acl *acl;reiserfs_read_lock_xattr_i (inode);reiserfs_read_lock_xattrs (inode->i_sb);
fs/reiserfs/xattr_security.c +4 -4
@@ -12,7 +12,7 @@ security_get(struct inode *inode, constif (strlen (name) <sizeof (XATTR_SECURITY_PREFIX ))return -EINVAL ; -if (is_reiserfs_priv_object (inode)) +if (IS_PRIVATE (inode))return -EPERM ;return reiserfs_xattr_get (inode, name, buffer, size);
@@ -25,7 +25,7 @@ security_set(struct inode *inode, constif (strlen (name) <sizeof (XATTR_SECURITY_PREFIX ))return -EINVAL ; -if (is_reiserfs_priv_object (inode)) +if (IS_PRIVATE (inode))return -EPERM ;return reiserfs_xattr_set (inode, name, buffer, size, flags);
@@ -36,7 +36,7 @@ static int security_del(struct inode *inif (strlen (name) <sizeof (XATTR_SECURITY_PREFIX ))return -EINVAL ; -if (is_reiserfs_priv_object (inode)) +if (IS_PRIVATE (inode))return -EPERM ;return 0 ;
@@ -47,7 +47,7 @@ security_list(struct inode *inode, const {int len = namelen; -if (is_reiserfs_priv_object (inode)) +if (IS_PRIVATE (inode))return 0 ;if (out)
fs/reiserfs/xattr_trusted.c +4 -4
@@ -16,7 +16,7 @@ trusted_get(struct inode *inode, const cif (!reiserfs_xattrs (inode->i_sb))return -EOPNOTSUPP ; -if (!(capable (CAP_SYS_ADMIN ) ||is_reiserfs_priv_object (inode))) +if (!(capable (CAP_SYS_ADMIN ) ||IS_PRIVATE (inode)))return -EPERM ;return reiserfs_xattr_get (inode, name, buffer, size);
@@ -32,7 +32,7 @@ trusted_set(struct inode *inode, const cif (!reiserfs_xattrs (inode->i_sb))return -EOPNOTSUPP ; -if (!(capable (CAP_SYS_ADMIN ) ||is_reiserfs_priv_object (inode))) +if (!(capable (CAP_SYS_ADMIN ) ||IS_PRIVATE (inode)))return -EPERM ;return reiserfs_xattr_set (inode, name, buffer, size, flags);
@@ -46,7 +46,7 @@ static int trusted_del(struct inode *inoif (!reiserfs_xattrs (inode->i_sb))return -EOPNOTSUPP ; -if (!(capable (CAP_SYS_ADMIN ) ||is_reiserfs_priv_object (inode))) +if (!(capable (CAP_SYS_ADMIN ) ||IS_PRIVATE (inode)))return -EPERM ;return 0 ;
@@ -60,7 +60,7 @@ trusted_list(struct inode *inode, constif (!reiserfs_xattrs (inode->i_sb))return 0 ; -if (!(capable (CAP_SYS_ADMIN ) ||is_reiserfs_priv_object (inode))) +if (!(capable (CAP_SYS_ADMIN ) ||IS_PRIVATE (inode)))return 0 ;if (out)
include/linux/reiserfs_xattr.h +0 -8
@@ -44,7 +44,6 @@ struct reiserfs_xattr_handler { };#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)ssize_t reiserfs_getxattr (struct dentry *dentry,const char *name,void *buffer,size_t size);
@@ -104,11 +103,6 @@ static inline void reiserfs_read_unlock_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);
@@ -116,8 +110,6 @@ static inline void reiserfs_init_xattr_r#else -#define is_reiserfs_priv_object (inode) 0 -#define reiserfs_mark_inode_private (inode) do {;} while(0)#define reiserfs_getxattr NULL#define reiserfs_setxattr NULL#define reiserfs_listxattr NULL
PATCH 18/35 reiserfs: Clean up xattrs when REISERFS_FS_XATTR is unset
In reply to Jeff Mahoney The current reiserfs xattr implementation will not clean up old xattr files if files are deleted when REISERFS_FS_XATTR is unset. This results in inaccessible lost files, wasting space.
This patch compiles in basic xattr knowledge, such as how to delete them and change ownership for quota tracking. If the file system has never used xattrs, then the operation is quite fast: it returns immediately when it sees there is no .reiserfs_priv directory.
--- fs/reiserfs/Makefile | 4 fs/reiserfs/xattr.c | 801 +++++++++++++++++++++-------------------- include/linux/reiserfs_fs_sb.h | 2 include/linux/reiserfs_xattr.h | 29 - 4 files changed, 423 insertions(+), 413 deletions(-)
fs/reiserfs/Makefile +2 -2
@@ -7,10 +7,10 @@ obj-$(CONFIG_REISERFS_FS) += reiserfs.o reiserfs-objs := bitmap.o do_balan.o namei.o inode.o file.o dir.o fix_node.o \ super.o prints.o objectid.o lbalance.o ibalance.o stree.o \ hashes.o tail_conversion.o journal.o resize.o \ - item_ops.o ioctl.o procfs.o + item_ops.o ioctl.o procfs.o xattr.o ifeq ($(CONFIG_REISERFS_FS_XATTR),y) -reiserfs-objs += xattr.o xattr_user.o xattr_trusted.o +reiserfs-objs += xattr_user.o xattr_trusted.o endif ifeq ($(CONFIG_REISERFS_FS_SECURITY),y)
fs/reiserfs/xattr.c +414 -387
889 lines not on this page · raw message
include/linux/reiserfs_fs_sb.h +1 -1
@@ -401,8 +401,8 @@ struct reiserfs_sb_info {int reserved_blocks;/* amount of blocks reserved for further allocations */ spinlock_t bitmap_lock;/* this lock on now only used to protect reserved_blocks variable */ struct dentry *priv_root;/* root of /.reiserfs_priv */ -#ifdef CONFIG_REISERFS_FS_XATTR struct dentry *xattr_root;/* root of /.reiserfs_priv/.xa */ +#ifdef CONFIG_REISERFS_FS_XATTR struct rw_semaphore xattr_dir_sem;#endif int j_errno;
include/linux/reiserfs_xattr.h +6 -23
@@ -43,6 +43,12 @@ struct reiserfs_xattr_handler {struct list_head handlers; }; +int reiserfs_xattr_register_handlers (void )__init ; +void reiserfs_xattr_unregister_handlers (void ); +int reiserfs_xattr_init (struct super_block *sb,int mount_flags); +int reiserfs_delete_xattrs (struct inode *inode); +int reiserfs_chown_xattrs (struct inode *inode,struct iattr *attrs); +#ifdef CONFIG_REISERFS_FS_XATTR #define has_xattr_dir (inode) (REISERFS_I(inode)->i_flags & i_has_xattr_dir) ssize_t reiserfs_getxattr(struct dentry *dentry, const char *name,
@@ -51,9 +57,6 @@ int reiserfs_setxattr(struct dentry *den const void *value, size_t size, int flags);ssize_t reiserfs_listxattr (struct dentry *dentry,char *buffer,size_t size);int reiserfs_removexattr (struct dentry *dentry,const char *name); -int reiserfs_delete_xattrs (struct inode *inode); -int reiserfs_chown_xattrs (struct inode *inode,struct iattr *attrs); -int reiserfs_xattr_init (struct super_block *sb,int mount_flags);int reiserfs_permission (struct inode *inode,int mask);int reiserfs_xattr_del (struct inode *,const char *);
@@ -64,9 +67,6 @@ extern struct reiserfs_xattr_handler useextern 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 ); -static inline void reiserfs_write_lock_xattrs (struct super_block *sb) {down_write (&REISERFS_XATTR_DIR_SEM (sb));
@@ -121,23 +121,6 @@ static inline void reiserfs_init_xattr_r#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 ; -}; -static inline int reiserfs_chown_xattrs (struct inode *inode, -struct iattr *attrs) -{ -return 0 ; -}; -static inline int reiserfs_xattr_init (struct super_block *sb,int mount_flags) -{ - sb->s_flags = (sb->s_flags & ~MS_POSIXACL );/* to be sure */ -return 0 ; -};static inline void reiserfs_init_xattr_rwsem (struct inode *inode) { }
Re: [patch 18/35 xattr-rework] reiserfs: Clean up xattrs when REISERFS_FS_XATTR is unset
Quoted 8 lines · Jeff Mahoney
The current reiserfs xattr implementation will not clean up old xattr files if files are deleted when
REISERFS_FS_XATTRis unset. This results in inaccessible lost files, wasting space.This patch compiles in basic xattr knowledge, such as how to delete them and change ownership for quota tracking. If the file system has never used xattrs, then the operation is quite fast: it returns immediately when it sees there is no .reiserfs_priv directory.
What about just making xattr suppose unconditional? That's what most never filesystems do, and it really shouldn't be a whole lot of code.
PATCH 19/35 reiserfs: simplify xattr internal file lookups/opens
In reply to Jeff MahoneyThe 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.
---
fs/reiserfs/xattr.c | 262 ++++++++++++++++++++++++++-------------------------- 1 file changed, 135 insertions(+), 127 deletions(-)
fs/reiserfs/xattr.c +135 -127
@@ -44,100 +44,123 @@#include <net/checksum.h> #include <linux/smp_lock.h> #include <linux/stat.h> +#include <linux/quotaops.h> -#define FL_READONLY 128 -#define FL_DIR_SEM_HELD 256#define PRIVROOT_NAME ".reiserfs_priv"#define XAROOT_NAME "xattrs" -/* 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) +/* Helpers for inode ops. We do this so that we don't have all the VFS +* overhead and also for proper i_mutex annotation. +* dir->i_mutex must be held for all of them. */ +static int xattr_create (struct inode *dir,struct dentry *dentry,int mode) { -struct dentry *privroot =dget (REISERFS_SB (sb)->priv_root); -struct dentry *xaroot; +BUG_ON (!mutex_is_locked (&dir->i_mutex)); +DQUOT_INIT (dir); +return dir->i_op->create (dir, dentry, mode,NULL ); +} -/* This needs to be created at mount-time */ -if (!privroot) -return ERR_PTR (-ENODATA ); +static int xattr_mkdir (struct inode *dir,struct dentry *dentry,int mode) +{ +BUG_ON (!mutex_is_locked (&dir->i_mutex)); +DQUOT_INIT (dir); +return dir->i_op->mkdir (dir, dentry, mode); +} -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; - } +/* We use I_MUTEX_CHILD here to silence lockdep. It's safe because xattr +* mutation ops aren't called during rename or splace, which are the +* only other users of I_MUTEX_CHILD. It violates the ordering, but that's +* better than allocating another subclass just for this code. */ +static int xattr_unlink (struct inode *dir,struct dentry *dentry) +{ +int error; +BUG_ON (!mutex_is_locked (&dir->i_mutex)); +DQUOT_INIT (dir); - xaroot =lookup_one_len (XAROOT_NAME , privroot,strlen (XAROOT_NAME )); -if (IS_ERR (xaroot)) { - goto out; - }else if (!xaroot->d_inode) { +mutex_lock_nested (&dentry->d_inode->i_mutex,I_MUTEX_CHILD ); + error = dir->i_op->unlink (dir, dentry); +mutex_unlock (&dentry->d_inode->i_mutex); + +if (!error) +d_delete (dentry); +return error; +} + +static int xattr_rmdir (struct inode *dir,struct dentry *dentry) +{ +int error; +BUG_ON (!mutex_is_locked (&dir->i_mutex)); +DQUOT_INIT (dir); + +mutex_lock_nested (&dentry->d_inode->i_mutex,I_MUTEX_CHILD ); +dentry_unhash (dentry); + error = dir->i_op->rmdir (dir, dentry); +if (!error) + dentry->d_inode->i_flags |=S_DEAD ; +mutex_unlock (&dentry->d_inode->i_mutex); +if (!error) +d_delete (dentry); +dput (dentry); + +return error; +} + + +#define xattr_may_create (flags) (!flags || flags & XATTR_CREATE) + +/* Returns and possibly creates the xattr dir. */ +static struct dentry *lookup_or_create_dir (struct dentry *parent, +const char *name,int flags) +{ +struct dentry *dentry; +BUG_ON (!parent); + + dentry =lookup_one_len (name, parent,strlen (name)); +if (IS_ERR (dentry)) +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)) { +mutex_lock_nested (&parent->d_inode->i_mutex, +I_MUTEX_XATTR ); + err =xattr_mkdir (parent->d_inode, dentry,0700 ); +mutex_unlock (&parent->d_inode->i_mutex); + } +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; +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; + }/*
@@ -302,13 +325,11 @@ staticint xattr_readdir (struct inode *inode,filldir_t filler,void *buf) {int res = -ENOENT ; -mutex_lock_nested (&inode->i_mutex,I_MUTEX_XATTR );if (!IS_DEADDIR (inode)) {lock_kernel (); res =__xattr_readdir (inode, buf, filler);unlock_kernel (); } -mutex_unlock (&inode->i_mutex);return res; }
@@ -345,9 +366,7 @@ __reiserfs_xattr_del(struct dentry *xadireturn -EIO ; } - err = dir->i_op->unlink (dir, dentry); -if (!err) -d_delete (dentry); + err =xattr_unlink (dir, dentry); out_file:dput (dentry);
@@ -381,7 +400,7 @@ int reiserfs_delete_xattrs(struct inodereturn 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);
@@ -391,25 +410,25 @@ int reiserfs_delete_xattrs(struct inodereturn 0 ; } -lock_kernel (); +mutex_lock_nested (&dir->d_inode->i_mutex,I_MUTEX_XATTR ); err =xattr_readdir (dir->d_inode, reiserfs_delete_xattrs_filler, dir); -if (err) { -unlock_kernel (); +mutex_unlock (&dir->d_inode->i_mutex); +if (err) goto out_dir; - }/* 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); - err =vfs_rmdir (root->d_inode, dir); +mutex_lock_nested (&root->d_inode->i_mutex,I_MUTEX_XATTR ); + err =xattr_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-20006" ,"Couldn't remove all entries in directory" ); } -unlock_kernel (); out_dir:dput (dir);
@@ -445,8 +464,11 @@ reiserfs_chown_xattrs_filler(void *buf,return -ENODATA ; } -if (!S_ISDIR (xafile->d_inode->i_mode)) +if (!S_ISDIR (xafile->d_inode->i_mode)) { +mutex_lock_nested (&xafile->d_inode->i_mutex,I_MUTEX_CHILD ); err =notify_change (xafile, attrs); +mutex_unlock (&xafile->d_inode->i_mutex); + }dput (xafile);return err;
@@ -464,38 +486,31 @@ 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 ) err =PTR_ERR (dir); goto out; - }else if (!dir->d_inode) { -dput (dir); - goto out; - } - -lock_kernel (); + }else if (!dir->d_inode) + goto out_dir; attrs->ia_valid &= (ATTR_UID |ATTR_GID |ATTR_CTIME ); buf.xadir = dir; buf.attrs = attrs; buf.inode = inode; +mutex_lock_nested (&dir->d_inode->i_mutex,I_MUTEX_XATTR ); err =xattr_readdir (dir->d_inode, reiserfs_chown_xattrs_filler, &buf); -if (err) { -unlock_kernel (); - goto out_dir; - } - err =notify_change (dir, attrs); -unlock_kernel (); +if (!err) + err =notify_change (dir, attrs); +mutex_unlock (&dir->d_inode->i_mutex); + attrs->ia_valid = ia_valid; out_dir:dput (dir); - out: - attrs->ia_valid = ia_valid;return err; }
@@ -513,47 +528,35 @@ static struct dentry *get_xa_file_dentryint err =0 ; xadir =open_xa_dir (inode, flags); -if (IS_ERR (xadir)) { +if (IS_ERR (xadir))return ERR_CAST (xadir); - }else if (xadir && !xadir->d_inode) { -dput (xadir); -return ERR_PTR (-ENODATA ); - } xafile =lookup_one_len (name, xadir,strlen (name));if (IS_ERR (xafile)) { -dput (xadir); -return ERR_CAST (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)) { +mutex_lock_nested (&xadir->d_inode->i_mutex, +I_MUTEX_XATTR ); + err =xattr_create (xadir->d_inode, xafile, +0700 |S_IFREG ); +mutex_unlock (&xadir->d_inode->i_mutex); } } +if (err) +dput (xafile); out:dput (xadir);if (err) - xafile =ERR_PTR (err); -else if (!xafile->d_inode) { -dput (xafile); - xafile =ERR_PTR (-ENODATA ); - } +return ERR_PTR (err);return xafile; }
@@ -633,6 +636,7 @@ reiserfs_xattr_set(struct inode *inode, newattrs.ia_valid =ATTR_SIZE |ATTR_CTIME ;mutex_lock_nested (&dentry->d_inode->i_mutex,I_MUTEX_XATTR ); err =notify_change (dentry, &newattrs); +mutex_unlock (&dentry->d_inode->i_mutex);if (err) goto out_filp;
@@ -692,7 +696,6 @@ reiserfs_xattr_set(struct inode *inode, } out_filp: -mutex_unlock (&dentry->d_inode->i_mutex);dput (dentry); out:
@@ -722,7 +725,7 @@ reiserfs_xattr_get(const struct inode *iif (get_inode_sd_version (inode) ==STAT_DATA_V1 )return -EOPNOTSUPP ; - dentry =get_xa_file_dentry (inode, name,FL_READONLY ); + dentry =get_xa_file_dentry (inode, name,XATTR_REPLACE );if (IS_ERR (dentry)) { err =PTR_ERR (dentry); goto out;
@@ -806,13 +809,15 @@ int reiserfs_xattr_del(struct inode *inostruct 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; } +mutex_lock_nested (&dir->d_inode->i_mutex,I_MUTEX_XATTR ); err =__reiserfs_xattr_del (dir, name,strlen (name)); +mutex_unlock (&dir->d_inode->i_mutex);dput (dir);if (!err) {
@@ -826,6 +831,7 @@ int reiserfs_xattr_del(struct inode *ino/* Actual operations that are exported to VFS-land */ +static struct reiserfs_xattr_handler *find_xattr_handler_prefix (const char *);/* * Inode operation getxattr() * Preliminary locking: we down dentry->d_inode->i_mutex
@@ -978,7 +984,7 @@ ssize_t reiserfs_listxattr(struct dentryreiserfs_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);
@@ -994,7 +1000,9 @@ ssize_t reiserfs_listxattr(struct dentryREISERFS_I (dentry->d_inode)->i_flags |= i_has_xattr_dir; +mutex_lock_nested (&dir->d_inode->i_mutex,I_MUTEX_XATTR ); err =xattr_readdir (dir->d_inode, reiserfs_listxattr_filler, &buf); +mutex_unlock (&dir->d_inode->i_mutex);if (err) goto out_dir;
@@ -1146,7 +1154,7 @@ static int create_privroot(struct dentryint err;struct inode *inode = dentry->d_parent->d_inode;mutex_lock_nested (&inode->i_mutex,I_MUTEX_XATTR ); - err = inode->i_op->mkdir (inode, dentry,0700 ); + err =xattr_mkdir (inode, dentry,0700 );mutex_unlock (&inode->i_mutex);if (err) {dput (dentry);
PATCH 20/35 reiserfs: eliminate per-super xattr lock
In reply to Jeff Mahoney 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.
--
fs/reiserfs/inode.c | 14 ------- fs/reiserfs/namei.c | 29 ---------------- fs/reiserfs/super.c | 4 -- fs/reiserfs/xattr.c | 70 +++++++++++++++++++------------------- fs/reiserfs/xattr_acl.c | 74 ++++++++++++++++++----------------------- include/linux/reiserfs_fs.h | 3 - include/linux/reiserfs_fs_sb.h | 3 - include/linux/reiserfs_xattr.h | 28 ++------------- 8 files changed, 74 insertions(+), 151 deletions(-)
fs/reiserfs/inode.c +1 -13
@@ -1957,19 +1957,7 @@ int reiserfs_new_inode(struct reiserfs_t inode->i_nlink =0 ; th->t_trans_id =0 ;/* so the caller can't use this handle later */ unlock_new_inode (inode);/* OK to do even if we hadn't locked it */ - -/* 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; }
fs/reiserfs/namei.c +0 -29
@@ -609,9 +609,6 @@ static int reiserfs_create(struct inodereiserfs_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);
@@ -624,11 +621,6 @@ static int reiserfs_create(struct inodeif (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;
@@ -655,8 +647,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; }
@@ -686,9 +676,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);
@@ -702,11 +689,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);
@@ -736,8 +718,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; }
@@ -767,8 +747,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) {
@@ -790,11 +768,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);
@@ -824,8 +797,6 @@ static int reiserfs_mkdir(struct inode *unlock_new_inode (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; }
fs/reiserfs/super.c +0 -4
@@ -1646,10 +1646,6 @@ static int reiserfs_fill_super(struct suREISERFS_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);
fs/reiserfs/xattr.c +35 -35
184 lines not on this page · raw message
fs/reiserfs/xattr_acl.c +33 -41
136 lines not on this page · raw message
include/linux/reiserfs_fs.h +0 -3
@@ -2224,7 +2224,4 @@ int reiserfs_unpack(struct inode *inode,#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 */
include/linux/reiserfs_fs_sb.h +0 -3
@@ -403,9 +403,6 @@ struct reiserfs_sb_info {spinlock_t bitmap_lock;/* this lock on now only used to protect reserved_blocks variable */ struct dentry *priv_root;/* root of /.reiserfs_priv */ struct dentry *xattr_root;/* root of /.reiserfs_priv/.xa */ -#ifdef CONFIG_REISERFS_FS_XATTR -struct rw_semaphore xattr_dir_sem; -#endif int j_errno;#ifdef CONFIG_QUOTA char *s_qf_names[MAXQUOTAS ];
include/linux/reiserfs_xattr.h +5 -23
@@ -67,45 +67,27 @@ extern struct reiserfs_xattr_handler useextern struct reiserfs_xattr_handler trusted_handler;extern struct reiserfs_xattr_handler security_handler; -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); +down_write (&REISERFS_I (inode)->i_xattr_sem); }static inline void reiserfs_write_unlock_xattr_i (struct inode *inode) { -up_write (&REISERFS_I (inode)->xattr_sem); +up_write (&REISERFS_I (inode)->i_xattr_sem); }static inline void reiserfs_read_lock_xattr_i (struct inode *inode) { -down_read (&REISERFS_I (inode)->xattr_sem); +down_read (&REISERFS_I (inode)->i_xattr_sem); }static inline void reiserfs_read_unlock_xattr_i (struct inode *inode) { -up_read (&REISERFS_I (inode)->xattr_sem); +up_read (&REISERFS_I (inode)->i_xattr_sem); }static inline void reiserfs_init_xattr_rwsem (struct inode *inode) { -init_rwsem (&REISERFS_I (inode)->xattr_sem); +init_rwsem (&REISERFS_I (inode)->i_xattr_sem); }#else
PATCH 21/35 reiserfs: make per-inode xattr locking more fine grained
In reply to Jeff Mahoney 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.
--
fs/reiserfs/xattr.c | 114 +++++++++++++++++++---------------------- fs/reiserfs/xattr_acl.c | 7 -- include/linux/reiserfs_fs_i.h | 2 include/linux/reiserfs_xattr.h | 22 ------- 4 files changed, 55 insertions(+), 90 deletions(-)
fs/reiserfs/xattr_acl.c +1 -6
@@ -418,9 +418,7 @@ int reiserfs_cache_default_acl(struct inint ret =0 ;if (reiserfs_posixacl (inode->i_sb) && !IS_PRIVATE (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 *inoif (!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; }
fs/reiserfs/xattr.c +53 -61
304 lines not on this page · raw message
include/linux/reiserfs_fs_i.h +1 -1
@@ -59,7 +59,7 @@ struct reiserfs_inode_info {struct posix_acl *i_acl_default;#endif #ifdef CONFIG_REISERFS_FS_XATTR -struct rw_semaphore xattr_sem; +struct rw_semaphore i_xattr_sem;#endif struct inode vfs_inode; };
include/linux/reiserfs_xattr.h +0 -22
@@ -67,24 +67,6 @@ extern struct reiserfs_xattr_handler useextern struct reiserfs_xattr_handler trusted_handler;extern struct reiserfs_xattr_handler security_handler; -static inline void reiserfs_write_lock_xattr_i (struct inode *inode) -{ -down_write (&REISERFS_I (inode)->i_xattr_sem); -} -static inline void reiserfs_write_unlock_xattr_i (struct inode *inode) -{ -up_write (&REISERFS_I (inode)->i_xattr_sem); -} -static inline void reiserfs_read_lock_xattr_i (struct inode *inode) -{ -down_read (&REISERFS_I (inode)->i_xattr_sem); -} - -static inline void reiserfs_read_unlock_xattr_i (struct inode *inode) -{ -up_read (&REISERFS_I (inode)->i_xattr_sem); -} -static inline void reiserfs_init_xattr_rwsem (struct inode *inode) {init_rwsem (&REISERFS_I (inode)->i_xattr_sem);
@@ -96,10 +78,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
PATCH 22/35 reiserfs: remove i_has_xattr_dir
In reply to Jeff Mahoney With the changes to xattr root locking, the i_has_xattr_dir flag is no longer needed. This patch removes it.
--- fs/reiserfs/xattr.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
fs/reiserfs/xattr.c +1 -8
@@ -459,10 +459,7 @@ int reiserfs_delete_xattrs(struct inodedput (root); out: -if (!err) -REISERFS_I (inode)->i_flags = -REISERFS_I (inode)->i_flags & ~i_has_xattr_dir; -else +if (err)reiserfs_warning (inode->i_sb,"jdm-20004" ,"Couldn't remove all xattrs (%d)\n" , err);return err;
@@ -660,7 +657,6 @@ reiserfs_xattr_set(struct inode *inode,down_write (&REISERFS_I (inode)->i_xattr_sem); xahash =xattr_hash (buffer, buffer_size); -REISERFS_I (inode)->i_flags |= i_has_xattr_dir;/* Resize it so we're ok to write there */ newattrs.ia_size = buffer_size;
@@ -769,7 +765,6 @@ reiserfs_xattr_get(const struct inode *idown_read (&REISERFS_I (inode)->i_xattr_sem); isize =i_size_read (dentry->d_inode); -REISERFS_I (inode)->i_flags |= i_has_xattr_dir;/* Just return the size needed */ if (buffer ==NULL ) {
@@ -999,8 +994,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; -mutex_lock_nested (&dir->d_inode->i_mutex,I_MUTEX_XATTR ); err =xattr_readdir (dir->d_inode, reiserfs_listxattr_filler, &buf);mutex_unlock (&dir->d_inode->i_mutex);
PATCH 23/35 reiserfs: use generic xattr handlers
In reply to Jeff MahoneyChristoph 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.
Update 7/26/07: Added missing dput() to deletion path. Update 8/30/07: Added missing mark_inode_dirty when i_mode is used to
represent an ACL and no previous ACL existed.
---
fs/reiserfs/super.c | 7 fs/reiserfs/xattr.c | 467 ++++++++++++++++------------------------- fs/reiserfs/xattr_acl.c | 79 ++---- fs/reiserfs/xattr_security.c | 26 -- fs/reiserfs/xattr_trusted.c | 45 --- fs/reiserfs/xattr_user.c | 31 -- include/linux/reiserfs_acl.h | 16 - include/linux/reiserfs_fs_sb.h | 3 include/linux/reiserfs_xattr.h | 25 -- 9 files changed, 258 insertions(+), 441 deletions(-)
fs/reiserfs/super.c +0 -7
@@ -2261,9 +2261,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);
@@ -2274,9 +2271,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 ();
@@ -2286,7 +2280,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);
fs/reiserfs/xattr_acl.c +31 -48
119 lines not on this page · raw message
fs/reiserfs/xattr.c +191 -276
655 lines not on this page · raw message
fs/reiserfs/xattr_security.c +8 -18
@@ -31,35 +31,25 @@ security_set(struct inode *inode, constreturn 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_PRIVATE (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_PRIVATE (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, };
fs/reiserfs/xattr_trusted.c +11 -34
71 lines not on this page · raw message
fs/reiserfs/xattr_user.c +8 -23
@@ -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 -static int user_get (struct inode *inode,const char *name,void *buffer,size_t size) {
@@ -25,7 +21,6 @@ static int user_set(struct inode *inode, const char *name, const void *buffer, size_t size, int flags) { - if (strlen(name) < sizeof(XATTR_USER_PREFIX)) return -EINVAL;
@@ -34,33 +29,23 @@ user_set(struct inode *inode, const charreturn 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 ; - -if (!reiserfs_xattrs_user (inode->i_sb)) -return -EOPNOTSUPP ; -return 0 ; -} +const size_t len = name_len +1 ; -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, };
include/linux/reiserfs_acl.h +2 -14
@@ -52,10 +52,8 @@ int reiserfs_acl_chmod(struct inode *inoint 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 *reiserfsreturn 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 ;
include/linux/reiserfs_fs_sb.h +1 -2
@@ -450,7 +450,6 @@ enum reiserfs_mount_options {REISERFS_NO_UNHASHED_RELOCATION ,REISERFS_HASHED_RELOCATION ,REISERFS_ATTRS , -REISERFS_XATTRS ,REISERFS_XATTRS_USER ,REISERFS_POSIXACL , REISERFS_BARRIER_NONE,
@@ -488,7 +487,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))
include/linux/reiserfs_xattr.h +6 -19
@@ -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; -}; -int reiserfs_xattr_register_handlers (void )__init ;void reiserfs_xattr_unregister_handlers (void );int reiserfs_xattr_init (struct super_block *sb,int mount_flags);
@@ -59,13 +45,14 @@ ssize_t reiserfs_listxattr(struct dentryint reiserfs_removexattr (struct dentry *dentry,const char *name);int reiserfs_permission (struct inode *inode,int mask); -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 );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; +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_init_xattr_rwsem (struct inode *inode) {
PATCH 24/35 reiserfs: journaled xattrs
In reply to Jeff MahoneyDeadlocks 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.
--
fs/reiserfs/inode.c | 3 - fs/reiserfs/namei.c | 14 +---- fs/reiserfs/xattr.c | 39 +++++++++++---- fs/reiserfs/xattr_acl.c | 105 +++++++++++++++++++++++++++++++---------- include/linux/reiserfs_acl.h | 3 - include/linux/reiserfs_fs.h | 4 + include/linux/reiserfs_xattr.h | 40 ++++++++++++++- 7 files changed, 159 insertions(+), 49 deletions(-)
fs/reiserfs/inode.c +1 -2
@@ -1919,9 +1919,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);
fs/reiserfs/namei.c +3 -11
@@ -607,15 +607,13 @@ static int reiserfs_create(struct inode2 * (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);
@@ -669,7 +667,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 ;
@@ -679,8 +676,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);
@@ -737,7 +733,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 */
@@ -749,8 +744,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);
@@ -1037,8 +1031,6 @@ static int reiserfs_symlink(struct inodememcpy (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);
fs/reiserfs/xattr_acl.c +81 -24
169 lines not on this page · raw message
fs/reiserfs/xattr.c +30 -9
@@ -632,8 +632,9 @@ out_dput:* 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 dentry *dentry;
@@ -723,14 +724,34 @@ out_unlock:return err; } -int -reiserfs_xattr_set (struct inode *inode,const char *name,const void *buffer, -size_t buffer_size,int flags) +/* 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) { -int err =__reiserfs_xattr_set (inode, name, buffer, buffer_size, flags); -if (err == -ENODATA ) - err =0 ; -return err; + +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; }/*
include/linux/reiserfs_acl.h +2 -1
@@ -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;
include/linux/reiserfs_fs.h +4 -0
@@ -1615,6 +1615,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)
include/linux/reiserfs_xattr.h +38 -2
@@ -46,14 +46,50 @@ int reiserfs_removexattr(struct dentry *int reiserfs_permission (struct inode *inode,int mask);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 (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;extern struct xattr_handler reiserfs_xattr_security_handler; +#define xattr_size (size) ((size) + sizeof(struct reiserfs_xattr_header)) +static inline loff_t reiserfs_xattr_nblocks (struct inode *inode,loff_t size) +{ +loff_t ret =0 ; +if (reiserfs_file_data_log (inode)) { + ret =_ROUND_UP (xattr_size (size), inode->i_sb->s_blocksize); + ret >>= inode->i_sb->s_blocksize_bits; + } +return ret; +} + +/* 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; +} +static inline void reiserfs_init_xattr_rwsem (struct inode *inode) {init_rwsem (&REISERFS_I (inode)->i_xattr_sem);
PATCH 25/35 reiserfs: use generic readdir for operations across all xattrs
In reply to Jeff Mahoney 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.
--
fs/reiserfs/dir.c | 28 +-- fs/reiserfs/xattr.c | 402 ++++++++++++-------------------------------- include/linux/reiserfs_fs.h | 1 3 files changed, 131 insertions(+), 300 deletions(-)
fs/reiserfs/dir.c +15 -13
@@ -41,10 +41,10 @@ static int reiserfs_dir_fsync(struct fil#define store_ih (where,what) copy_item_head (where, what) -// -static int reiserfs_readdir (struct file *filp,void *dirent,filldir_t filldir) +int reiserfs_readdir_dentry (struct dentry *dentry,void *dirent, +filldir_t filldir,loff_t *pos) { -struct inode *inode = filp->f_path.dentry->d_inode; +struct inode *inode = 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;
@@ -64,13 +64,9 @@ static int reiserfs_readdir(struct file/* form key for search the next directory entry using f_pos field of file structure */ -make_cpu_key (&pos_key, inode, - (filp->f_pos) ? (filp->f_pos) :DOT_OFFSET ,TYPE_DIRENTRY , -3 ); +make_cpu_key (&pos_key, inode, *pos ?:DOT_OFFSET ,TYPE_DIRENTRY ,3 ); next_pos =cpu_key_k_offset (&pos_key); -/* reiserfs_warning (inode->i_sb, "reiserfs_readdir 1: f_pos = %Ld", filp->f_pos); */ - path_to_entry.reada =PATH_READA ;while (1 ) { research:
@@ -144,7 +140,7 @@ static int reiserfs_readdir(struct file/* Ignore the .reiserfs_priv entry */ if (reiserfs_xattrs (inode->i_sb) && !old_format_only (inode->i_sb) && - filp->f_path.dentry == inode->i_sb->s_root && + dentry == inode->i_sb->s_root &&REISERFS_SB (inode->i_sb)->priv_root &&REISERFS_SB (inode->i_sb)->priv_root->d_inode && deh_objectid(deh) ==
@@ -156,7 +152,7 @@ static int reiserfs_readdir(struct file } d_off =deh_offset (deh); - filp->f_pos = d_off; + *pos = d_off; d_ino =deh_objectid (deh);if (d_reclen <=32 ) { local_buf = small_buf;
@@ -223,15 +219,21 @@ static int reiserfs_readdir(struct file }/* while */ - end: - filp->f_pos = next_pos; +end: + *pos = next_pos;pathrelse (&path_to_entry);reiserfs_check_path (&path_to_entry); - out: +out:reiserfs_write_unlock (inode->i_sb);return ret; } +static int reiserfs_readdir (struct file *file,void *dirent,filldir_t filldir) +{ +struct dentry *dentry = file->f_path.dentry; +return reiserfs_readdir_dentry (dentry, dirent, filldir, &file->f_pos); +} +/* compose directory item containing "." and ".." entries (entries are not aligned to 4 byte boundary) */ /* the last four params are LE */
fs/reiserfs/xattr.c +115 -287
463 lines not on this page · raw message
include/linux/reiserfs_fs.h +1 -0
@@ -1984,6 +1984,7 @@ extern const struct inode_operations reiextern const struct inode_operations reiserfs_symlink_inode_operations;extern const struct inode_operations reiserfs_special_inode_operations;extern const struct file_operations reiserfs_dir_operations; +int reiserfs_readdir_dentry (struct dentry *,void *,filldir_t ,loff_t *);/* tail_conversion.c */ int direct2indirect(struct reiserfs_transaction_handle *, struct inode *,
PATCH 26/35 reiserfs: add atomic addition of selinux attributes during inode creation
In reply to Jeff MahoneySome 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.
--
fs/reiserfs/inode.c | 16 +++++++++++- fs/reiserfs/namei.c | 37 +++++++++++++++++++++++++--- fs/reiserfs/xattr_security.c | 54 +++++++++++++++++++++++++++++++++++++++++ include/linux/reiserfs_fs.h | 4 ++- include/linux/reiserfs_xattr.h | 32 ++++++++++++++++++++++++ 5 files changed, 137 insertions(+), 6 deletions(-)
fs/reiserfs/inode.c +15 -1
@@ -1756,7 +1756,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;struct reiserfs_iget_args args;
@@ -1934,6 +1935,19 @@ int reiserfs_new_inode(struct reiserfs_t }else if (IS_PRIVATE (dir)) inode->i_flags |=S_PRIVATE ; +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; + } + } +reiserfs_update_sd (th, inode);reiserfs_check_path (&path_to_key);
fs/reiserfs/namei.c +33 -4
@@ -607,6 +607,7 @@ static int reiserfs_create(struct inode2 * (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 ;
@@ -614,6 +615,12 @@ static int reiserfs_create(struct inodenew_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);
@@ -624,7 +631,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;
@@ -662,6 +669,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 +
@@ -677,6 +685,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);
@@ -687,7 +701,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; }
@@ -728,6 +742,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 +
@@ -745,6 +760,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);
@@ -761,7 +782,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;
@@ -1002,6 +1023,7 @@ static int reiserfs_symlink(struct inodechar *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 =
@@ -1014,6 +1036,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)) {
@@ -1040,7 +1069,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;
fs/reiserfs/xattr_security.c +54 -0
66 lines not on this page · raw message
include/linux/reiserfs_fs.h +3 -1
@@ -1915,10 +1915,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);
include/linux/reiserfs_xattr.h +32 -0
@@ -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>
@@ -54,6 +60,14 @@ int reiserfs_xattr_set_handle(struct reiextern 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 #define xattr_size (size) ((size) + sizeof(struct reiserfs_xattr_header))static inline loff_t reiserfs_xattr_nblocks (struct inode *inode,loff_t size)
@@ -109,6 +123,24 @@ 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 */
PATCH 27/35 reiserfs: factor out buffer_info initialization
In reply to Jeff Mahoney 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.
--- fs/reiserfs/do_balan.c | 175 ++++++++++++++++--------------------------------- 1 file changed, 60 insertions(+), 115 deletions(-)
fs/reiserfs/do_balan.c +60 -115
@@ -29,6 +29,43 @@ struct tree_balance *cur_tb = NULL; /* dis 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(strubreak ;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_balaleaf_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 -
@@ -523,13 +539,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 -
@@ -680,11 +690,7 @@ static int balance_leaf(struct tree_balaleaf_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_balaset_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,
@@ -1018,12 +1010,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 =
@@ -1070,12 +1057,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 +
@@ -1231,10 +1213,7 @@ static int balance_leaf(struct tree_balaput_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 ;
@@ -1266,10 +1245,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,
@@ -1326,10 +1302,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 -
@@ -1399,11 +1372,7 @@ static int balance_leaf(struct tree_balaif (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 leaf_mi);/* 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_balaswitch (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_balaRFALSE (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,
@@ -1725,7 +1674,6 @@ void make_empty_node(struct buffer_infostruct 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++)
@@ -1735,16 +1683,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
PATCH 28/35 reiserfs: cleanup path functions
In reply to Jeff MahoneyThis 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.
---
fs/reiserfs/fix_node.c | 58 ++++++++++++++++++++++++------------------------ fs/reiserfs/stree.c | 59 ++++++++++--------------------------------------- 2 files changed, 43 insertions(+), 74 deletions(-)
fs/reiserfs/fix_node.c +30 -28
@@ -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 ; } }
@@ -1022,7 +1023,7 @@ static int get_far_parent(struct tree_baif (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 ; } }
@@ -1050,8 +1051,8 @@ static int get_far_parent(struct tree_bareturn 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 ; }
@@ -1063,7 +1064,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 ; }
@@ -1086,10 +1087,10 @@ static int get_parents(struct tree_balanif (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 ;
@@ -1115,9 +1116,9 @@ static int get_parents(struct tree_balanreturn 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)) ||
@@ -1145,10 +1146,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)) ||
@@ -1964,7 +1965,7 @@ static int get_neighbors(struct tree_balif (!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 ; }
@@ -1980,7 +1981,7 @@ static int get_neighbors(struct tree_baldc_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; }
@@ -2001,11 +2002,11 @@ static int get_neighbors(struct tree_balif (!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
@@ -2511,16 +2512,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 ; }
fs/reiserfs/stree.c +13 -46
105 lines not on this page · raw message
PATCH 29/35 reiserfs: strip trailing whitespace
In reply to Jeff MahoneyThis patch strips trailing whitespace from the reiserfs code.
--- fs/reiserfs/README | 4 - fs/reiserfs/do_balan.c | 14 ++-- fs/reiserfs/file.c | 8 +- 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 | 120 ++++++++++++++++++++--------------------- 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, 184 insertions(+), 184 deletions(-)
fs/reiserfs/README +2 -2
@@ -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
fs/reiserfs/do_balan.c +7 -7
@@ -76,21 +76,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
@@ -288,15 +288,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
@@ -1983,7 +1983,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
fs/reiserfs/file.c +4 -4
@@ -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) {
@@ -223,7 +223,7 @@ int reiserfs_commit_page(struct inode *i }/* 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
fs/reiserfs/fix_node.c +19 -19
@@ -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, structint 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;
@@ -1204,7 +1204,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.
@@ -1239,7 +1239,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
@@ -1288,7 +1288,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)
@@ -1349,13 +1349,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 */
@@ -1545,7 +1545,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.
@@ -1728,7 +1728,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.
@@ -1822,7 +1822,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.
@@ -1851,7 +1851,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.
@@ -2296,15 +2296,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 *
@@ -2316,7 +2316,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
fs/reiserfs/hashes.c +1 -1
@@ -7,7 +7,7 @@* (see Applied Cryptography, 2nd edition, p448). * * Jeremy Fitzhardinge <[email protected]> 1998 -* +* * Jeremy has agreed to the contents of reiserfs/README. -Hans * Yura's function is added (04/07/2000) */
fs/reiserfs/ibalance.c +5 -5
@@ -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_itemsif (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)
fs/reiserfs/inode.c +26 -26
166 lines not on this page · raw message
fs/reiserfs/ioctl.c +1 -1
@@ -189,7 +189,7 @@ int reiserfs_unpack(struct inode *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 ;
fs/reiserfs/journal.c +60 -60
345 lines not on this page · raw message
fs/reiserfs/lbalance.c +9 -9
@@ -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 buffelse {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 buffelse {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_balancestatic 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
@@ -1275,7 +1275,7 @@ void leaf_paste_entries(struct buffer_in/* 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
fs/reiserfs/namei.c +15 -15
@@ -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 */
@@ -371,7 +371,7 @@ static struct dentry *reiserfs_lookup(streturn d_splice_alias (inode, dentry); } -/* +/* ** looks up the dentry of the parent directory for child. ** taken from ext2_get_parent */
@@ -401,7 +401,7 @@ struct dentry *reiserfs_get_parent(strucreturn d_obtain_alias (inode); } -/* 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
@@ -559,7 +559,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.
@@ -820,7 +820,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 inodethis 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);
fs/reiserfs/objectid.c +1 -1
@@ -180,7 +180,7 @@ int reiserfs_convert_objectid_map_v1(strif (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);
fs/reiserfs/prints.c +13 -13
@@ -181,11 +181,11 @@ static char *is_there_reiserfs_struct(chappropriative 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 DEFINE_SPINLOCK (error_lock);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):
fs/reiserfs/procfs.c +1 -1
@@ -633,7 +633,7 @@ int reiserfs_global_version_in_proc(char* */ -/* +/* * Make Linus happy. * Local variables: * c-indentation-style: "K&R"
fs/reiserfs/resize.c +3 -3
@@ -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.
@@ -101,7 +101,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;
fs/reiserfs/stree.c +4 -4
@@ -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)) {
@@ -1443,7 +1443,7 @@ static int maybe_indirect_to_direct(struif (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 ));
@@ -1826,7 +1826,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
fs/reiserfs/super.c +5 -5
@@ -767,7 +767,7 @@ static int reiserfs_getopt(struct super_ char **opt_arg, unsigned long *bit_flags) { char *p; -/* foo=bar, +/* foo=bar, ^ ^ ^ | | +-- option_end | +-- arg_start
@@ -1357,7 +1357,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);
@@ -1543,8 +1543,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",
@@ -1576,7 +1576,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 &&
fs/reiserfs/tail_conversion.c +1 -1
@@ -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 "
include/linux/reiserfs_fs_sb.h +7 -7
@@ -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))
@@ -83,16 +83,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.
@@ -242,7 +242,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;
@@ -426,7 +426,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)
PATCH 30/35 reiserfs: rename p_s_sb to sb
In reply to Jeff MahoneyThis patch is a simple s/p_s_sb/sb/g to the reiserfs code. This is the first in a series of patches to rip out some of the awful variable naming in reiserfs.
---
fs/reiserfs/fix_node.c | 46 +- fs/reiserfs/fix_node.c | 46 +- fs/reiserfs/journal.c | 735 ++++++++++++++++++++---------------------- fs/reiserfs/stree.c | 126 +++---- fs/reiserfs/tail_conversion.c | 16 include/linux/reiserfs_fs.h | 14 5 files changed, 468 insertions(+), 469 deletions(-)
fs/reiserfs/fix_node.c +23 -23
@@ -785,7 +785,7 @@ static int get_empty_nodes(struct tree_bb_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 *p_s_sb = p_s_tb->tb_sb; +struct super_block *sb = p_s_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
@@ -830,7 +830,7 @@ static int get_empty_nodes(struct tree_bRFALSE (!*p_n_blocknr,"PAP-8135: reiserfs_new_blocknrs failed when got new blocks" ); - p_s_new_bh =sb_getblk (p_s_sb, *p_n_blocknr); + 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),
@@ -899,7 +899,7 @@ static int get_rfree(struct tree_balancestatic int is_left_neighbor_in_cache (struct tree_balance *p_s_tb,int n_h) {struct buffer_head *p_s_father, *left; -struct super_block *p_s_sb = p_s_tb->tb_sb; +struct super_block *sb = p_s_tb->tb_sb;b_blocknr_t n_left_neighbor_blocknr;int n_left_neighbor_position;
@@ -924,7 +924,7 @@ static int is_left_neighbor_in_cache(str n_left_neighbor_blocknr =B_N_CHILD_NUM (p_s_tb->FL[n_h], n_left_neighbor_position);/* Look for the left neighbor in the cache. */ -if ((left =sb_find_get_block (p_s_sb, n_left_neighbor_blocknr))) { +if ((left =sb_find_get_block (sb, n_left_neighbor_blocknr))) { RFALSE(buffer_uptodate(left) && !B_IS_IN_TREE(left), "vs-8170: left neighbor (%b %z) is not in the tree",
@@ -1942,14 +1942,14 @@ static int get_neighbors(struct tree_balint n_child_position, n_path_offset =PATH_H_PATH_OFFSET (p_s_tb->tb_path, n_h +1 );unsigned long n_son_number; -struct super_block *p_s_sb = p_s_tb->tb_sb; +struct super_block *sb = p_s_tb->tb_sb;struct buffer_head *p_s_bh; -PROC_INFO_INC (p_s_sb, get_neighbors[n_h]); +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 (p_s_sb, need_l_neighbor[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); RFALSE(p_s_bh == p_s_tb->FL[n_h] &&
@@ -1961,12 +1961,12 @@ static int get_neighbors(struct tree_bal 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 (p_s_sb, n_son_number); + p_s_bh =sb_bread (sb, n_son_number);if (!p_s_bh)return IO_ERROR ;if (FILESYSTEM_CHANGED_TB (p_s_tb)) {brelse (p_s_bh); -PROC_INFO_INC (p_s_sb, get_neighbors_restart[n_h]); +PROC_INFO_INC (sb, get_neighbors_restart[n_h]);return REPEAT_SEARCH ; }
@@ -1986,7 +1986,7 @@ static int get_neighbors(struct tree_bal }if (p_s_tb->rnum[n_h]) {/* We need right neighbor to balance S[n_path_offset]. */ -PROC_INFO_INC (p_s_sb, need_r_neighbor[n_h]); +PROC_INFO_INC (sb, need_r_neighbor[n_h]); p_s_bh =PATH_OFFSET_PBUFFER (p_s_tb->tb_path, n_path_offset); RFALSE(p_s_bh == p_s_tb->FR[n_h] &&
@@ -1998,12 +1998,12 @@ static int get_neighbors(struct tree_bal n_child_position = (p_s_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 (p_s_sb, n_son_number); + p_s_bh =sb_bread (sb, n_son_number);if (!p_s_bh)return IO_ERROR ;if (FILESYSTEM_CHANGED_TB (p_s_tb)) {brelse (p_s_bh); -PROC_INFO_INC (p_s_sb, get_neighbors_restart[n_h]); +PROC_INFO_INC (sb, get_neighbors_restart[n_h]);return REPEAT_SEARCH ; }brelse (p_s_tb->R[n_h]);
@@ -2089,51 +2089,51 @@ static int get_mem_for_virtual_node(stru }#ifdef CONFIG_REISERFS_CHECK -static void tb_buffer_sanity_check (struct super_block *p_s_sb, +static void tb_buffer_sanity_check (struct super_block *sb,struct buffer_head *p_s_bh,const char *descr,int level) {if (p_s_bh) {if (atomic_read (&(p_s_bh->b_count)) <=0 ) { -reiserfs_panic (p_s_sb,"jmacd-1" ,"negative or zero " +reiserfs_panic (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" ,"buffer is not up " +reiserfs_panic (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" ,"buffer is not " +reiserfs_panic (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" ,"buffer has wrong " +if (p_s_bh->b_bdev != sb->s_bdev) { +reiserfs_panic (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" ,"buffer has wrong " +if (p_s_bh->b_size != sb->s_blocksize) { +reiserfs_panic (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" ,"buffer block " +if (p_s_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); } } }#else -static void tb_buffer_sanity_check (struct super_block *p_s_sb, +static void tb_buffer_sanity_check (struct super_block *sb,struct buffer_head *p_s_bh,const char *descr,int level) {;
fs/reiserfs/journal.c +367 -368
2,020 lines not on this page · raw message
fs/reiserfs/stree.c +63 -63
413 lines not on this page · raw message
fs/reiserfs/tail_conversion.c +8 -8
@@ -175,9 +175,9 @@ int indirect2direct(struct reiserfs_tranloff_t n_new_file_size,/* New file size. */ char *p_c_mode) { - struct super_block *p_s_sb = p_s_inode->i_sb; + struct super_block *sb = p_s_inode->i_sb;struct item_head s_ih; -unsigned long n_block_size = p_s_sb->s_blocksize; +unsigned long n_block_size = sb->s_blocksize;char *tail;int tail_len, round_tail_len;loff_t pos, pos1;/* position of first byte of the tail */
@@ -185,7 +185,7 @@ int indirect2direct(struct reiserfs_tranBUG_ON (!th->t_trans_id); -REISERFS_SB (p_s_sb)->s_indirect2direct++; +REISERFS_SB (sb)->s_indirect2direct++; *p_c_mode =M_SKIP_BALANCING ;
@@ -200,7 +200,7 @@ int indirect2direct(struct reiserfs_tran pos =le_ih_k_offset (&s_ih) -1 + (ih_item_len (&s_ih) /UNFM_P_SIZE - -1 ) * p_s_sb->s_blocksize; +1 ) * sb->s_blocksize; pos1 = pos;// we are protected by i_mutex. The tail can not disapper, not
@@ -211,18 +211,18 @@ int indirect2direct(struct reiserfs_tranif (path_changed (&s_ih, p_s_path)) {/* re-search indirect item */ -if (search_for_position_by_key (p_s_sb, p_s_item_key, p_s_path) +if (search_for_position_by_key (sb, p_s_item_key, p_s_path) ==POSITION_NOT_FOUND ) -reiserfs_panic (p_s_sb,"PAP-5520" , +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));#ifdef CONFIG_REISERFS_CHECK pos =le_ih_k_offset (&s_ih) -1 + (ih_item_len (&s_ih) /UNFM_P_SIZE - -1 ) * p_s_sb->s_blocksize; +1 ) * sb->s_blocksize;if (pos != pos1) -reiserfs_panic (p_s_sb,"vs-5530" ,"tail position " +reiserfs_panic (sb,"vs-5530" ,"tail position " "changed while we were reading it" );#endif }
include/linux/reiserfs_fs.h +7 -7
@@ -1769,12 +1769,12 @@ int journal_end_sync(struct reiserfs_traint journal_mark_freed (struct reiserfs_transaction_handle *,struct super_block *,b_blocknr_t blocknr);int journal_transaction_should_end (struct reiserfs_transaction_handle *,int ); -int reiserfs_in_journal (struct super_block *p_s_sb,unsigned int bmap_nr, -int bit_nr,int searchall,b_blocknr_t *next); +int reiserfs_in_journal (struct super_block *sb,unsigned int bmap_nr, +int bit_nr,int searchall,b_blocknr_t *next);int journal_begin (struct reiserfs_transaction_handle *, -struct super_block *p_s_sb,unsigned long ); +struct super_block *sb,unsigned long );int journal_join_abort (struct reiserfs_transaction_handle *, -struct super_block *p_s_sb,unsigned long ); +struct super_block *sb,unsigned long );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,
@@ -1830,11 +1830,11 @@ static inline void copy_key(struct reiseint 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, -const struct super_block *p_s_sb); +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 *p_s_sb, +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);
@@ -1978,7 +1978,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 ( p_s_sb, p_s_bh, n_node_level ) VOID_V +#define PROC_INFO_BH_STAT (sb, p_s_bh, n_node_level) VOID_V#endif /* dir.c */
PATCH 31/35 reiserfs: rename p_s_bh to bh
In reply to Jeff MahoneyThis 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.
---
fs/reiserfs/fix_node.c | 94 ++++++++++++++++++++------------------------ fs/reiserfs/stree.c | 63 ++++++++++++++--------------- include/linux/reiserfs_fs.h | 37 ++++++++--------- 3 files changed, 94 insertions(+), 100 deletions(-)
fs/reiserfs/fix_node.c +44 -50
@@ -1887,7 +1887,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);
@@ -1909,21 +1909,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 ; }
@@ -1943,29 +1943,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 ; }
@@ -1973,48 +1973,48 @@ static int get_neighbors(struct tree_balRFALSE (!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))); }
@@ -2090,51 +2090,45 @@ 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) {; }
fs/reiserfs/stree.c +31 -32
175 lines not on this page · raw message
include/linux/reiserfs_fs.h +19 -18
@@ -751,25 +751,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 */
@@ -1119,12 +1119,13 @@ 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 */
@@ -1837,7 +1838,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);
@@ -1978,7 +1979,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 */
PATCH 32/35 reiserfs: rename p_s_inode to inode
In reply to Jeff MahoneyThis 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.
---
fs/reiserfs/file.c | 16 +++--- fs/reiserfs/inode.c | 43 ++++++++--------- fs/reiserfs/stree.c | 103 +++++++++++++++++++++--------------------- fs/reiserfs/tail_conversion.c | 18 ++++--- include/linux/reiserfs_fs.h | 4 - 5 files changed, 95 insertions(+), 89 deletions(-)
fs/reiserfs/file.c +8 -8
@@ -137,17 +137,17 @@ static void reiserfs_vfs_truncate_file(sstatic 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 ;
fs/reiserfs/inode.c +22 -21
121 lines not on this page · raw message
fs/reiserfs/stree.c +53 -50
276 lines not on this page · raw message
fs/reiserfs/tail_conversion.c +10 -8
@@ -170,12 +170,14 @@ void reiserfs_unmap_buffer(struct bufferwhat 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 +195,7 @@ int indirect2direct(struct reiserfs_trancopy_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 +230,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 +246,7 @@ int indirect2direct(struct reiserfs_transet_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 +260,7 @@ int indirect2direct(struct reiserfs_trankunmap (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 +271,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; }
include/linux/reiserfs_fs.h +2 -2
@@ -1870,9 +1870,9 @@ int reiserfs_delete_item(struct reiserfsvoid 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)
Re: [patch 32/35 code-cleanup] reiserfs: rename p_s_inode to inode
fs/reiserfs/file.c static void reiserfs_vfs_truncate_file(s · line 142
Quoted 11 lines · Jeff Mahoney
fs/reiserfs/file.c +1
-1@@ -137,17 +137,17 @@ static void reiserfs_vfs_truncate_file(sstatic 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;
Didn't you miss one here?
-Andi
Signature · 1 line
[email protected] -- Speaking for myself only.
Re: [patch 32/35 code-cleanup] reiserfs: rename p_s_inode to inode
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 13 lines · Andi Kleen
fs/reiserfs/file.c static void reiserfs_vfs_truncate_file(s · line 142
Quoted 10 lines · Jeff Mahoney
fs/reiserfs/file.c +1
-1@@ -137,17 +137,17 @@ static void reiserfs_vfs_truncate_file(sstatic 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;Didn't you miss one here?
Nope. This renamed p_s_inode, and that's a p_s_dentry. That one gets handled in reiserfs: rename p_._ variables.
- -Jeff
- --
Jeff Mahoney
SUSE Labs
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org
iEYEARECAAYFAknRGvIACgkQLPWxlyuTD7ItdQCgiuVxsIJVzXv66VzTNuRmfF0n VNgAoJZHYLAtS6mj4Uzxb2+WL/J5Pv+y
=fQ5U
-----END PGP SIGNATURE-----
PATCH 33/35 reiserfs: rename p_s_tb to tb
In reply to Jeff MahoneyThis 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.
---
fs/reiserfs/fix_node.c | 482 ++++++++++++++++++++++---------------------- fs/reiserfs/stree.c | 21 + include/linux/reiserfs_fs.h | 2 3 files changed, 254 insertions(+), 251 deletions(-)
fs/reiserfs/fix_node.c +242 -240
@@ -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_bthe 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_breturn 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;
@@ -896,33 +896,34 @@ 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. */ +/* Father of the left neighbor does not exist. */ +if (!tb->FL[n_h])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))) {
@@ -953,14 +954,14 @@ static void decrement_key(struct cpu_keySCHEDULE_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,
@@ -1005,9 +1006,9 @@ static int get_far_parent(struct tree_baif (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 ; }
@@ -1022,7 +1023,7 @@ static int get_far_parent(struct tree_baif (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 ; }
@@ -1035,9 +1036,9 @@ static int get_far_parent(struct tree_bale_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)));
@@ -1045,12 +1046,12 @@ static int get_far_parent(struct tree_badecrement_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 ;
@@ -1075,24 +1076,26 @@ 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] =NULL ; + tb->CFL[n_h] =NULL ; + tb->FR[n_h] =NULL ; + tb->CFR[n_h] =NULL ;return CARRY_ON ; }
@@ -1104,22 +1107,22 @@ static int get_parents(struct tree_balanPATH_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)),
@@ -1133,7 +1136,7 @@ static int get_parents(struct tree_balanCalculate 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 {
@@ -1143,14 +1146,16 @@ static int get_parents(struct tree_balanPATH_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]); +/* New initialization of FR[n_path_offset]. */ + tb->FR[n_h] = p_s_curf; -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]); +/* New initialization of CFR[n_path_offset]. */ + tb->CFR[n_h] = p_s_curcf; RFALSE((p_s_curf && !B_IS_IN_TREE(p_s_curf)) || (p_s_curcf && !B_IS_IN_TREE(p_s_curcf)),
@@ -1885,12 +1890,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 ) {
@@ -1899,7 +1904,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 ;
@@ -1924,7 +1929,7 @@ static int get_direct_parent(struct treeif (buffer_locked (bh)) {__wait_on_buffer (bh); -if (FILESYSTEM_CHANGED_TB (p_s_tb)) +if (FILESYSTEM_CHANGED_TB (tb))return REPEAT_SEARCH ; }
@@ -1937,85 +1942,86 @@ 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]. */ +/* We need right neighbor to balance S[n_path_offset]. */ +if (tb->rnum[n_h]) {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 ;
@@ -2139,7 +2145,7 @@ static int clear_all_dirty_bits(struct sreturn 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
@@ -2151,95 +2157,94 @@ 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]; } } }
@@ -2252,10 +2257,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]; } }
@@ -2263,21 +2268,20 @@ 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 ; - } } }while (locked);
@@ -2307,138 +2311,136 @@ static int wait_tb_buffers_until_unlocke* tb tree_balance structure; * inum item number in S[h]; * pos_in_item - comment this if you can -* ins_ih & ins_sd are used when inserting +* ins_ih item head of item being inserted +* data inserted item or data to be pasted * Returns: 1 - schedule occurred while the function worked; * 0 - schedule didn't occur while the function worked; * -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 -const void *data// inserted item or data to be pasted - ) +int fix_nodes (int n_op_mode,struct tree_balance *tb, +struct item_head *p_s_ins_ih,const void *data) { -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++) { + n_ret_value =get_direct_parent (tb, n_h); +if (n_ret_value !=CARRY_ON ) goto repeat; - } -if ((n_ret_value = -check_balance (n_op_mode, p_s_tb, n_h, n_item_num, - n_pos_in_item, p_s_ins_ih, - data)) !=CARRY_ON ) { + n_ret_value =check_balance (n_op_mode, tb, n_h, n_item_num, + n_pos_in_item, p_s_ins_ih, data); +if (n_ret_value !=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 ) { + n_ret_value =get_neighbors (tb, n_h); +if (n_ret_value !=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 ) { + n_ret_value =get_neighbors (tb, n_h); +if (n_ret_value !=CARRY_ON ) goto repeat; - } -if ((n_ret_value =get_empty_nodes (p_s_tb, n_h)) !=CARRY_ON ) { - goto repeat;/* No disk space, or schedule occurred and -analysis may be invalid and needs to be redone. */ - } +/* No disk space, or schedule occurred and analysis may be +* invalid and needs to be redone. */ + n_ret_value =get_empty_nodes (tb, n_h); +if (n_ret_value !=CARRY_ON ) + goto repeat; -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
@@ -2447,19 +2449,20 @@ int fix_nodes(int n_op_mode, struct treeRFALSE (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)) { + n_ret_value =wait_tb_buffers_until_unlocked (tb); +if (n_ret_value ==CARRY_ON ) { +if (FILESYSTEM_CHANGED_TB (tb)) { wait_tb_buffers_run =1 ; n_ret_value =REPEAT_SEARCH ; goto repeat;
@@ -2482,50 +2485,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]); } }return n_ret_value;
@@ -2533,7 +2535,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) {
fs/reiserfs/stree.c +11 -10
@@ -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,26 @@ 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);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)
include/linux/reiserfs_fs.h +1 -1
@@ -2004,7 +2004,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 *);
PATCH 34/35 reiserfs: rename p_._ variables
In reply to Jeff MahoneyThis 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.
---
fs/reiserfs/file.c | 6 fs/reiserfs/fix_node.c | 169 +++++++-------- fs/reiserfs/stree.c | 472 +++++++++++++++++++++--------------------- fs/reiserfs/tail_conversion.c | 28 +- include/linux/reiserfs_fs.h | 46 ++-- 5 files changed, 365 insertions(+), 356 deletions(-)
fs/reiserfs/file.c +3 -3
@@ -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;
fs/reiserfs/fix_node.c +84 -85
371 lines not on this page · raw message
fs/reiserfs/stree.c +240 -232
1,127 lines not on this page · raw message
fs/reiserfs/tail_conversion.c +15 -13
@@ -172,10 +172,12 @@ void reiserfs_unmap_buffer(struct bufferinode */ 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. */ +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;
@@ -189,10 +191,10 @@ int indirect2direct(struct reiserfs_tranREISERFS_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 )
@@ -211,14 +213,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 -
@@ -240,13 +242,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
@@ -268,7 +270,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); */
include/linux/reiserfs_fs.h +23 -23
114 lines not on this page · raw message
PATCH 35/35 reiserfs: rename [cn]_* variables
In reply to Jeff MahoneyThis 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.
---
fs/reiserfs/file.c | 6 fs/reiserfs/fix_node.c | 474 +++++++++++++++++++++--------------------- fs/reiserfs/stree.c | 370 ++++++++++++++++---------------- fs/reiserfs/tail_conversion.c | 30 +- 4 files changed, 438 insertions(+), 442 deletions(-)
fs/reiserfs/file.c +3 -3
@@ -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 filblkdev_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 ; }/* taken fs/buffer.c:__block_commit_write */
fs/reiserfs/fix_node.c +237 -237
842 lines not on this page · raw message
fs/reiserfs/stree.c +183 -187
918 lines not on this page · raw message
fs/reiserfs/tail_conversion.c +15 -15
@@ -26,7 +26,7 @@ int direct2indirect(struct reiserfs_tranconverted 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_tranREISERFS_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_transet_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_tranRFALSE (!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_tranunsigned 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 ); }
@@ -181,7 +181,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 */
@@ -196,7 +196,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
@@ -257,7 +257,7 @@ int indirect2direct(struct reiserfs_tranunformatted 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);
@@ -276,5 +276,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; }
Quoted 2 lines · Jeff Mahoney
I'd like to submit my reiserfs patch queue for inclusion into 2.6.30.
Hmm. Looks fine, and I merged it. I had a number of mostly trivial conflicts (most due to the quota name cleanup to lower-case, with some header file export cleanup conflicts added in), but they looked fairly straightforward and I compile-tested the end result.
I don't have any reiserfs filesystems left, though, so you should really double-check the end result.
Quoted 2 lines
Once this is applied, I expect reiserfs to be in deep maintenance-only mode.
Heh, I hadn't expected even this.
Linus
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 11 lines · Linus Torvalds
Quoted 1 line · Jeff Mahoney
I'd like to submit my reiserfs patch queue for inclusion into 2.6.30.
Hmm. Looks fine, and I merged it. I had a number of mostly trivial conflicts (most due to the quota name cleanup to lower-case, with some header file export cleanup conflicts added in), but they looked fairly straightforward and I compile-tested the end result.
I don't have any reiserfs filesystems left, though, so you should really double-check the end result.
Great, thanks! I realized just after I submitted that I didn't adjust context to the last few days of mainline. The merge looks good except for an added space in reiserfs_delete_inode. I've appended the patch for that.
Quoted 4 lines
Quoted 2 lines
Once this is applied, I expect reiserfs to be in deep maintenance-only mode.
Heh, I hadn't expected even this.
Hopefully it won't be. I still have to support reiserfs for our enterprise releases, though. :)
- -Jeff
- ---
fs/reiserfs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
- --- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -52,7 +52,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)
vfs_dq_free_inode(inode);
if (journal_end(&th, inode->i_sb, jbegin_count))
- --
Jeff Mahoney
SUSE Labs
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org
iEYEARECAAYFAknRJLQACgkQLPWxlyuTD7IuOgCbBmWsC7seMVyE7TLD2gejcHgz c9EAn2Ey64m2xNZ8R53lWqvAiWlX4UcP
=Ugl0
-----END PGP SIGNATURE-----
Quoted 4 lines · Linus Torvalds
Quoted 2 lines
Once this is applied, I expect reiserfs to be in deep maintenance-only mode.
Heh, I hadn't expected even this.
Note, there are BKL-removal patches in the works by Frédéric Weisbecker, for the tip:kill-the-BKL topic branch.
Reiser3 is the heaviest (and most non-trivial) BKL user amongst all the filesystems, its BKL use is recursive and it frequently relies on the implicit dropping of the BKL at various blocking points both for correctness and for performance reasons.
There might be something worth posting+reviewing soon.
Ingo
--
To unsubscribe from this list: send the line "unsubscribe reiserfs-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 9 lines · Ingo Molnar
Quoted 3 lines · Linus Torvalds
Quoted 2 lines
Once this is applied, I expect reiserfs to be in deep maintenance-only mode.
Heh, I hadn't expected even this.
Note, there are BKL-removal patches in the works by Frédéric Weisbecker, for the tip:kill-the-BKL topic branch.
Quoted 6 lines
Reiser3 is the heaviest (and most non-trivial) BKL user amongst all the filesystems, its BKL use is recursive and it frequently relies on the implicit dropping of the BKL at various blocking points both for correctness and for performance reasons.
There might be something worth posting+reviewing soon.
Oh interesting. I'm glad someone is working on this. I've started to several times and decided to focus my efforts on things outside of reiserfs instead. The reiserfs usage of the BKL has always been a black mark.
- -Jeff
- --
Jeff Mahoney
SUSE Labs
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org
iEYEARECAAYFAknTlkIACgkQLPWxlyuTD7IAsQCfSNKuHk7oL8KhZK1InW7b189z K4kAn3lINkZFMg89wJbwSiLZEfeQLLJA
=grqX
-----END PGP SIGNATURE-----
--
To unsubscribe from this list: send the line "unsubscribe reiserfs-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 18 lines · Jeff Mahoney
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1Quoted 14 lines · Ingo Molnar
Quoted 3 lines · Linus Torvalds
Quoted 2 lines
Once this is applied, I expect reiserfs to be in deep maintenance-only mode.
Heh, I hadn't expected even this.
Note, there are BKL-removal patches in the works by Frédéric Weisbecker, for the tip:kill-the-BKL topic branch.
Reiser3 is the heaviest (and most non-trivial) BKL user amongst all the filesystems, its BKL use is recursive and it frequently relies on the implicit dropping of the BKL at various blocking points both for correctness and for performance reasons.
Quoted 6 lines
Quoted 1 line
There might be something worth posting+reviewing soon.
Oh interesting. I'm glad someone is working on this. I've started to several times and decided to focus my efforts on things outside of reiserfs instead. The reiserfs usage of the BKL has always been a black mark.
I'll let Frederic describe it but AFAIK the patch is working fine with the BKL as a mutex and no lockdep complaints or lockups. The main focus is now on finding the performance affecting spots, because Frederic's main desktop is on reiserfs and he does not accept a slowdown :)
Ingo
--
To unsubscribe from this list: send the line "unsubscribe reiserfs-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 28 lines · Ingo Molnar
Quoted 18 lines · Jeff Mahoney
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1Quoted 14 lines · Ingo Molnar
Quoted 3 lines · Linus Torvalds
Quoted 2 lines
Once this is applied, I expect reiserfs to be in deep maintenance-only mode.
Heh, I hadn't expected even this.
Note, there are BKL-removal patches in the works by Frédéric Weisbecker, for the tip:kill-the-BKL topic branch.
Reiser3 is the heaviest (and most non-trivial) BKL user amongst all the filesystems, its BKL use is recursive and it frequently relies on the implicit dropping of the BKL at various blocking points both for correctness and for performance reasons.
Quoted 6 lines
Quoted 1 line
There might be something worth posting+reviewing soon.
Oh interesting. I'm glad someone is working on this. I've started to several times and decided to focus my efforts on things outside of reiserfs instead. The reiserfs usage of the BKL has always been a black mark.
Quoted 5 lines
I'll let Frederic describe it but AFAIK the patch is working fine with the BKL as a mutex and no lockdep complaints or lockups. The main focus is now on finding the performance affecting spots, because Frederic's main desktop is on reiserfs and he does not accept a slowdown :)
Hehe :-)
No actually I would accept a tiny slowdown but I fear that the common reiserfs users wouldn't.
I'm still working on this and once it's ready enough for an RFC patch, I'll explain how is done the conversion to a mutex.
Stay tuned.
Quoted 1 line
Ingo
--
To unsubscribe from this list: send the line "unsubscribe reiserfs-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 9 lines · Frederic Weisbecker
Quoted 5 lines
I'll let Frederic describe it but AFAIK the patch is working fine with the BKL as a mutex and no lockdep complaints or lockups. The main focus is now on finding the performance affecting spots, because Frederic's main desktop is on reiserfs and he does not accept a slowdown :)
Hehe :-)
No actually I would accept a tiny slowdown but I fear that the common reiserfs users wouldn't.
We run big(ish) imap servers with up to 80 reiserfs partitions spread over a bunch of SCSI or SAS attached external drive units. I'm actually surprised that the BKL isn't causing us much pain (load is amazingly low considering how many users are on these boxes - at least now that we have 32Gb RAM and 64 bit kernels).
Are you still using an "entire reiserfs subsystem" mutex, or per-filesystem locking? If it's per filesystem, then I suspect we'll be big fans!
Quoted 4 lines
I'm still working on this and once it's ready enough for an RFC patch, I'll explain how is done the conversion to a mutex.
Stay tuned.
Sure will!
Thanks,
Bron.
Quoted 17 lines · Bron Gondwana
Quoted 9 lines · Frederic Weisbecker
Quoted 5 lines
I'll let Frederic describe it but AFAIK the patch is working fine with the BKL as a mutex and no lockdep complaints or lockups. The main focus is now on finding the performance affecting spots, because Frederic's main desktop is on reiserfs and he does not accept a slowdown :)
Hehe :-)
No actually I would accept a tiny slowdown but I fear that the common reiserfs users wouldn't.We run big(ish) imap servers with up to 80 reiserfs partitions spread over a bunch of SCSI or SAS attached external drive units. I'm actually surprised that the BKL isn't causing us much pain (load is amazingly low considering how many users are on these boxes - at least now that we have 32Gb RAM and 64 bit kernels).
Quoted 3 lines
Are you still using an "entire reiserfs subsystem" mutex, or per-filesystem locking? If it's per filesystem, then I suspect we'll be big fans!
Yeah. It is per superblock :-)
Frederic.
Quoted 11 lines
Quoted 5 lines
I'm still working on this and once it's ready enough for an RFC patch, I'll explain how is done the conversion to a mutex.
Stay tuned.
Sure will!
Thanks,
Bron.