diff options
author | Steven Whitehouse <swhiteho@redhat.com> | 2006-03-31 15:34:58 -0500 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2006-03-31 15:34:58 -0500 |
commit | 86579dd06deecfa6ac88d5e84e4d63c397cd6f6d (patch) | |
tree | b4475d3ccde53015ad84a06e4e55e64591171b75 /fs/reiserfs | |
parent | 7ea9ea832212c4a755650f7c7cc1ff0b63292a41 (diff) | |
parent | a0f067802576d4eb4c65d40b8ee7d6ea3c81dd61 (diff) |
Merge branch 'master'
Diffstat (limited to 'fs/reiserfs')
-rw-r--r-- | fs/reiserfs/dir.c | 2 | ||||
-rw-r--r-- | fs/reiserfs/file.c | 14 | ||||
-rw-r--r-- | fs/reiserfs/fix_node.c | 4 | ||||
-rw-r--r-- | fs/reiserfs/inode.c | 9 | ||||
-rw-r--r-- | fs/reiserfs/item_ops.c | 2 | ||||
-rw-r--r-- | fs/reiserfs/journal.c | 21 | ||||
-rw-r--r-- | fs/reiserfs/prints.c | 11 | ||||
-rw-r--r-- | fs/reiserfs/procfs.c | 2 | ||||
-rw-r--r-- | fs/reiserfs/stree.c | 210 | ||||
-rw-r--r-- | fs/reiserfs/super.c | 11 | ||||
-rw-r--r-- | fs/reiserfs/xattr_acl.c | 4 |
11 files changed, 119 insertions, 171 deletions
diff --git a/fs/reiserfs/dir.c b/fs/reiserfs/dir.c index d71ac6579289..973c819f8033 100644 --- a/fs/reiserfs/dir.c +++ b/fs/reiserfs/dir.c | |||
@@ -18,7 +18,7 @@ static int reiserfs_readdir(struct file *, void *, filldir_t); | |||
18 | static int reiserfs_dir_fsync(struct file *filp, struct dentry *dentry, | 18 | static int reiserfs_dir_fsync(struct file *filp, struct dentry *dentry, |
19 | int datasync); | 19 | int datasync); |
20 | 20 | ||
21 | struct file_operations reiserfs_dir_operations = { | 21 | const struct file_operations reiserfs_dir_operations = { |
22 | .read = generic_read_dir, | 22 | .read = generic_read_dir, |
23 | .readdir = reiserfs_readdir, | 23 | .readdir = reiserfs_readdir, |
24 | .fsync = reiserfs_dir_fsync, | 24 | .fsync = reiserfs_dir_fsync, |
diff --git a/fs/reiserfs/file.c b/fs/reiserfs/file.c index be12879bb179..cf6e1cf40351 100644 --- a/fs/reiserfs/file.c +++ b/fs/reiserfs/file.c | |||
@@ -1532,7 +1532,7 @@ static ssize_t reiserfs_file_write(struct file *file, /* the file we are going t | |||
1532 | buf += write_bytes; | 1532 | buf += write_bytes; |
1533 | *ppos = pos += write_bytes; | 1533 | *ppos = pos += write_bytes; |
1534 | count -= write_bytes; | 1534 | count -= write_bytes; |
1535 | balance_dirty_pages_ratelimited(inode->i_mapping); | 1535 | balance_dirty_pages_ratelimited_nr(inode->i_mapping, num_pages); |
1536 | } | 1536 | } |
1537 | 1537 | ||
1538 | /* this is only true on error */ | 1538 | /* this is only true on error */ |
@@ -1546,10 +1546,10 @@ static ssize_t reiserfs_file_write(struct file *file, /* the file we are going t | |||
1546 | } | 1546 | } |
1547 | } | 1547 | } |
1548 | 1548 | ||
1549 | if ((file->f_flags & O_SYNC) || IS_SYNC(inode)) | 1549 | if (likely(res >= 0) && |
1550 | res = | 1550 | (unlikely((file->f_flags & O_SYNC) || IS_SYNC(inode)))) |
1551 | generic_osync_inode(inode, file->f_mapping, | 1551 | res = generic_osync_inode(inode, file->f_mapping, |
1552 | OSYNC_METADATA | OSYNC_DATA); | 1552 | OSYNC_METADATA | OSYNC_DATA); |
1553 | 1553 | ||
1554 | mutex_unlock(&inode->i_mutex); | 1554 | mutex_unlock(&inode->i_mutex); |
1555 | reiserfs_async_progress_wait(inode->i_sb); | 1555 | reiserfs_async_progress_wait(inode->i_sb); |
@@ -1566,7 +1566,7 @@ static ssize_t reiserfs_aio_write(struct kiocb *iocb, const char __user * buf, | |||
1566 | return generic_file_aio_write(iocb, buf, count, pos); | 1566 | return generic_file_aio_write(iocb, buf, count, pos); |
1567 | } | 1567 | } |
1568 | 1568 | ||
1569 | struct file_operations reiserfs_file_operations = { | 1569 | const struct file_operations reiserfs_file_operations = { |
1570 | .read = generic_file_read, | 1570 | .read = generic_file_read, |
1571 | .write = reiserfs_file_write, | 1571 | .write = reiserfs_file_write, |
1572 | .ioctl = reiserfs_ioctl, | 1572 | .ioctl = reiserfs_ioctl, |
@@ -1576,6 +1576,8 @@ struct file_operations reiserfs_file_operations = { | |||
1576 | .sendfile = generic_file_sendfile, | 1576 | .sendfile = generic_file_sendfile, |
1577 | .aio_read = generic_file_aio_read, | 1577 | .aio_read = generic_file_aio_read, |
1578 | .aio_write = reiserfs_aio_write, | 1578 | .aio_write = reiserfs_aio_write, |
1579 | .splice_read = generic_file_splice_read, | ||
1580 | .splice_write = generic_file_splice_write, | ||
1579 | }; | 1581 | }; |
1580 | 1582 | ||
1581 | struct inode_operations reiserfs_file_inode_operations = { | 1583 | struct inode_operations reiserfs_file_inode_operations = { |
diff --git a/fs/reiserfs/fix_node.c b/fs/reiserfs/fix_node.c index aa22588019ec..5600d3d60cf7 100644 --- a/fs/reiserfs/fix_node.c +++ b/fs/reiserfs/fix_node.c | |||
@@ -191,9 +191,7 @@ static void create_virtual_node(struct tree_balance *tb, int h) | |||
191 | "vs-8045: create_virtual_node: rdkey %k, affected item==%d (mode==%c) Must be %c", | 191 | "vs-8045: create_virtual_node: rdkey %k, affected item==%d (mode==%c) Must be %c", |
192 | key, vn->vn_affected_item_num, | 192 | key, vn->vn_affected_item_num, |
193 | vn->vn_mode, M_DELETE); | 193 | vn->vn_mode, M_DELETE); |
194 | } else | 194 | } |
195 | /* we can delete directory item, that has only one directory entry in it */ | ||
196 | ; | ||
197 | } | 195 | } |
198 | #endif | 196 | #endif |
199 | 197 | ||
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c index d60f6238c66a..9857e50f85e7 100644 --- a/fs/reiserfs/inode.c +++ b/fs/reiserfs/inode.c | |||
@@ -466,7 +466,6 @@ static int reiserfs_get_block_create_0(struct inode *inode, sector_t block, | |||
466 | direct_IO request. */ | 466 | direct_IO request. */ |
467 | static int reiserfs_get_blocks_direct_io(struct inode *inode, | 467 | static int reiserfs_get_blocks_direct_io(struct inode *inode, |
468 | sector_t iblock, | 468 | sector_t iblock, |
469 | unsigned long max_blocks, | ||
470 | struct buffer_head *bh_result, | 469 | struct buffer_head *bh_result, |
471 | int create) | 470 | int create) |
472 | { | 471 | { |
@@ -2793,7 +2792,7 @@ static int invalidatepage_can_drop(struct inode *inode, struct buffer_head *bh) | |||
2793 | } | 2792 | } |
2794 | 2793 | ||
2795 | /* clm -- taken from fs/buffer.c:block_invalidate_page */ | 2794 | /* clm -- taken from fs/buffer.c:block_invalidate_page */ |
2796 | static int reiserfs_invalidatepage(struct page *page, unsigned long offset) | 2795 | static void reiserfs_invalidatepage(struct page *page, unsigned long offset) |
2797 | { | 2796 | { |
2798 | struct buffer_head *head, *bh, *next; | 2797 | struct buffer_head *head, *bh, *next; |
2799 | struct inode *inode = page->mapping->host; | 2798 | struct inode *inode = page->mapping->host; |
@@ -2832,10 +2831,12 @@ static int reiserfs_invalidatepage(struct page *page, unsigned long offset) | |||
2832 | * The get_block cached value has been unconditionally invalidated, | 2831 | * The get_block cached value has been unconditionally invalidated, |
2833 | * so real IO is not possible anymore. | 2832 | * so real IO is not possible anymore. |
2834 | */ | 2833 | */ |
2835 | if (!offset && ret) | 2834 | if (!offset && ret) { |
2836 | ret = try_to_release_page(page, 0); | 2835 | ret = try_to_release_page(page, 0); |
2836 | /* maybe should BUG_ON(!ret); - neilb */ | ||
2837 | } | ||
2837 | out: | 2838 | out: |
2838 | return ret; | 2839 | return; |
2839 | } | 2840 | } |
2840 | 2841 | ||
2841 | static int reiserfs_set_page_dirty(struct page *page) | 2842 | static int reiserfs_set_page_dirty(struct page *page) |
diff --git a/fs/reiserfs/item_ops.c b/fs/reiserfs/item_ops.c index e237cd668e5b..7a88adbceef6 100644 --- a/fs/reiserfs/item_ops.c +++ b/fs/reiserfs/item_ops.c | |||
@@ -275,7 +275,7 @@ static void indirect_print_item(struct item_head *ih, char *item) | |||
275 | int j; | 275 | int j; |
276 | __le32 *unp; | 276 | __le32 *unp; |
277 | __u32 prev = INT_MAX; | 277 | __u32 prev = INT_MAX; |
278 | int num; | 278 | int num = 0; |
279 | 279 | ||
280 | unp = (__le32 *) item; | 280 | unp = (__le32 *) item; |
281 | 281 | ||
diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c index 5a9d2722fa0a..1b73529b8099 100644 --- a/fs/reiserfs/journal.c +++ b/fs/reiserfs/journal.c | |||
@@ -2227,6 +2227,9 @@ static int journal_read_transaction(struct super_block *p_s_sb, | |||
2227 | journal->j_start = cur_dblock - SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb); | 2227 | journal->j_start = cur_dblock - SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb); |
2228 | journal->j_last_flush_trans_id = trans_id; | 2228 | journal->j_last_flush_trans_id = trans_id; |
2229 | journal->j_trans_id = trans_id + 1; | 2229 | journal->j_trans_id = trans_id + 1; |
2230 | /* check for trans_id overflow */ | ||
2231 | if (journal->j_trans_id == 0) | ||
2232 | journal->j_trans_id = 10; | ||
2230 | brelse(c_bh); | 2233 | brelse(c_bh); |
2231 | brelse(d_bh); | 2234 | brelse(d_bh); |
2232 | kfree(log_blocks); | 2235 | kfree(log_blocks); |
@@ -2450,6 +2453,9 @@ static int journal_read(struct super_block *p_s_sb) | |||
2450 | journal->j_start = le32_to_cpu(jh->j_first_unflushed_offset); | 2453 | journal->j_start = le32_to_cpu(jh->j_first_unflushed_offset); |
2451 | journal->j_trans_id = | 2454 | journal->j_trans_id = |
2452 | le32_to_cpu(jh->j_last_flush_trans_id) + 1; | 2455 | le32_to_cpu(jh->j_last_flush_trans_id) + 1; |
2456 | /* check for trans_id overflow */ | ||
2457 | if (journal->j_trans_id == 0) | ||
2458 | journal->j_trans_id = 10; | ||
2453 | journal->j_last_flush_trans_id = | 2459 | journal->j_last_flush_trans_id = |
2454 | le32_to_cpu(jh->j_last_flush_trans_id); | 2460 | le32_to_cpu(jh->j_last_flush_trans_id); |
2455 | journal->j_mount_id = le32_to_cpu(jh->j_mount_id) + 1; | 2461 | journal->j_mount_id = le32_to_cpu(jh->j_mount_id) + 1; |
@@ -3873,8 +3879,8 @@ static int do_journal_end(struct reiserfs_transaction_handle *th, | |||
3873 | int cur_write_start = 0; /* start index of current log write */ | 3879 | int cur_write_start = 0; /* start index of current log write */ |
3874 | int old_start; | 3880 | int old_start; |
3875 | int i; | 3881 | int i; |
3876 | int flush = flags & FLUSH_ALL; | 3882 | int flush; |
3877 | int wait_on_commit = flags & WAIT; | 3883 | int wait_on_commit; |
3878 | struct reiserfs_journal_list *jl, *temp_jl; | 3884 | struct reiserfs_journal_list *jl, *temp_jl; |
3879 | struct list_head *entry, *safe; | 3885 | struct list_head *entry, *safe; |
3880 | unsigned long jindex; | 3886 | unsigned long jindex; |
@@ -3884,6 +3890,13 @@ static int do_journal_end(struct reiserfs_transaction_handle *th, | |||
3884 | BUG_ON(th->t_refcount > 1); | 3890 | BUG_ON(th->t_refcount > 1); |
3885 | BUG_ON(!th->t_trans_id); | 3891 | BUG_ON(!th->t_trans_id); |
3886 | 3892 | ||
3893 | /* protect flush_older_commits from doing mistakes if the | ||
3894 | transaction ID counter gets overflowed. */ | ||
3895 | if (th->t_trans_id == ~0UL) | ||
3896 | flags |= FLUSH_ALL | COMMIT_NOW | WAIT; | ||
3897 | flush = flags & FLUSH_ALL; | ||
3898 | wait_on_commit = flags & WAIT; | ||
3899 | |||
3887 | put_fs_excl(); | 3900 | put_fs_excl(); |
3888 | current->journal_info = th->t_handle_save; | 3901 | current->journal_info = th->t_handle_save; |
3889 | reiserfs_check_lock_depth(p_s_sb, "journal end"); | 3902 | reiserfs_check_lock_depth(p_s_sb, "journal end"); |
@@ -4105,7 +4118,9 @@ static int do_journal_end(struct reiserfs_transaction_handle *th, | |||
4105 | journal->j_first = NULL; | 4118 | journal->j_first = NULL; |
4106 | journal->j_len = 0; | 4119 | journal->j_len = 0; |
4107 | journal->j_trans_start_time = 0; | 4120 | journal->j_trans_start_time = 0; |
4108 | journal->j_trans_id++; | 4121 | /* check for trans_id overflow */ |
4122 | if (++journal->j_trans_id == 0) | ||
4123 | journal->j_trans_id = 10; | ||
4109 | journal->j_current_jl->j_trans_id = journal->j_trans_id; | 4124 | journal->j_current_jl->j_trans_id = journal->j_trans_id; |
4110 | journal->j_must_wait = 0; | 4125 | journal->j_must_wait = 0; |
4111 | journal->j_len_alloc = 0; | 4126 | journal->j_len_alloc = 0; |
diff --git a/fs/reiserfs/prints.c b/fs/reiserfs/prints.c index d55e164bd5c2..27bd3a1df2ad 100644 --- a/fs/reiserfs/prints.c +++ b/fs/reiserfs/prints.c | |||
@@ -143,7 +143,7 @@ static void sprintf_buffer_head(char *buf, struct buffer_head *bh) | |||
143 | char b[BDEVNAME_SIZE]; | 143 | char b[BDEVNAME_SIZE]; |
144 | 144 | ||
145 | sprintf(buf, | 145 | sprintf(buf, |
146 | "dev %s, size %d, blocknr %llu, count %d, state 0x%lx, page %p, (%s, %s, %s)", | 146 | "dev %s, size %zd, blocknr %llu, count %d, state 0x%lx, page %p, (%s, %s, %s)", |
147 | bdevname(bh->b_bdev, b), bh->b_size, | 147 | bdevname(bh->b_bdev, b), bh->b_size, |
148 | (unsigned long long)bh->b_blocknr, atomic_read(&(bh->b_count)), | 148 | (unsigned long long)bh->b_blocknr, atomic_read(&(bh->b_count)), |
149 | bh->b_state, bh->b_page, | 149 | bh->b_state, bh->b_page, |
@@ -601,8 +601,7 @@ void store_print_tb(struct tree_balance *tb) | |||
601 | tb->tb_mode, PATH_LAST_POSITION(tb->tb_path), | 601 | tb->tb_mode, PATH_LAST_POSITION(tb->tb_path), |
602 | tb->tb_path->pos_in_item); | 602 | tb->tb_path->pos_in_item); |
603 | 603 | ||
604 | for (h = 0; h < sizeof(tb->insert_size) / sizeof(tb->insert_size[0]); | 604 | for (h = 0; h < ARRAY_SIZE(tb->insert_size); h++) { |
605 | h++) { | ||
606 | if (PATH_H_PATH_OFFSET(tb->tb_path, h) <= | 605 | if (PATH_H_PATH_OFFSET(tb->tb_path, h) <= |
607 | tb->tb_path->path_length | 606 | tb->tb_path->path_length |
608 | && PATH_H_PATH_OFFSET(tb->tb_path, | 607 | && PATH_H_PATH_OFFSET(tb->tb_path, |
@@ -658,15 +657,13 @@ void store_print_tb(struct tree_balance *tb) | |||
658 | 657 | ||
659 | /* print FEB list (list of buffers in form (bh (b_blocknr, b_count), that will be used for new nodes) */ | 658 | /* print FEB list (list of buffers in form (bh (b_blocknr, b_count), that will be used for new nodes) */ |
660 | h = 0; | 659 | h = 0; |
661 | for (i = 0; i < sizeof(tb->FEB) / sizeof(tb->FEB[0]); i++) | 660 | for (i = 0; i < ARRAY_SIZE(tb->FEB); i++) |
662 | sprintf(print_tb_buf + strlen(print_tb_buf), | 661 | sprintf(print_tb_buf + strlen(print_tb_buf), |
663 | "%p (%llu %d)%s", tb->FEB[i], | 662 | "%p (%llu %d)%s", tb->FEB[i], |
664 | tb->FEB[i] ? (unsigned long long)tb->FEB[i]-> | 663 | tb->FEB[i] ? (unsigned long long)tb->FEB[i]-> |
665 | b_blocknr : 0ULL, | 664 | b_blocknr : 0ULL, |
666 | tb->FEB[i] ? atomic_read(&(tb->FEB[i]->b_count)) : 0, | 665 | tb->FEB[i] ? atomic_read(&(tb->FEB[i]->b_count)) : 0, |
667 | (i == | 666 | (i == ARRAY_SIZE(tb->FEB) - 1) ? "\n" : ", "); |
668 | sizeof(tb->FEB) / sizeof(tb->FEB[0]) - | ||
669 | 1) ? "\n" : ", "); | ||
670 | 667 | ||
671 | sprintf(print_tb_buf + strlen(print_tb_buf), | 668 | sprintf(print_tb_buf + strlen(print_tb_buf), |
672 | "======================== the end ====================================\n"); | 669 | "======================== the end ====================================\n"); |
diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c index ef6caed9336b..731688e1cfe3 100644 --- a/fs/reiserfs/procfs.c +++ b/fs/reiserfs/procfs.c | |||
@@ -470,7 +470,7 @@ static int r_open(struct inode *inode, struct file *file) | |||
470 | return ret; | 470 | return ret; |
471 | } | 471 | } |
472 | 472 | ||
473 | static struct file_operations r_file_operations = { | 473 | static const struct file_operations r_file_operations = { |
474 | .open = r_open, | 474 | .open = r_open, |
475 | .read = seq_read, | 475 | .read = seq_read, |
476 | .llseek = seq_lseek, | 476 | .llseek = seq_lseek, |
diff --git a/fs/reiserfs/stree.c b/fs/reiserfs/stree.c index e2d08d7bcffc..d2b25e1ba6e9 100644 --- a/fs/reiserfs/stree.c +++ b/fs/reiserfs/stree.c | |||
@@ -981,6 +981,8 @@ static inline int prepare_for_direntry_item(struct path *path, | |||
981 | return M_CUT; | 981 | return M_CUT; |
982 | } | 982 | } |
983 | 983 | ||
984 | #define JOURNAL_FOR_FREE_BLOCK_AND_UPDATE_SD (2 * JOURNAL_PER_BALANCE_CNT + 1) | ||
985 | |||
984 | /* If the path points to a directory or direct item, calculate mode and the size cut, for balance. | 986 | /* If the path points to a directory or direct item, calculate mode and the size cut, for balance. |
985 | If the path points to an indirect item, remove some number of its unformatted nodes. | 987 | If the path points to an indirect item, remove some number of its unformatted nodes. |
986 | In case of file truncate calculate whether this item must be deleted/truncated or last | 988 | In case of file truncate calculate whether this item must be deleted/truncated or last |
@@ -1020,148 +1022,79 @@ static char prepare_for_delete_or_cut(struct reiserfs_transaction_handle *th, st | |||
1020 | 1022 | ||
1021 | /* Case of an indirect item. */ | 1023 | /* Case of an indirect item. */ |
1022 | { | 1024 | { |
1023 | int n_unfm_number, /* Number of the item unformatted nodes. */ | 1025 | int blk_size = p_s_sb->s_blocksize; |
1024 | n_counter, n_blk_size; | 1026 | struct item_head s_ih; |
1025 | __le32 *p_n_unfm_pointer; /* Pointer to the unformatted node number. */ | 1027 | int need_re_search; |
1026 | __u32 tmp; | 1028 | int delete = 0; |
1027 | struct item_head s_ih; /* Item header. */ | 1029 | int result = M_CUT; |
1028 | char c_mode; /* Returned mode of the balance. */ | 1030 | int pos = 0; |
1029 | int need_research; | 1031 | |
1030 | 1032 | if ( n_new_file_length == max_reiserfs_offset (inode) ) { | |
1031 | n_blk_size = p_s_sb->s_blocksize; | 1033 | /* prepare_for_delete_or_cut() is called by |
1032 | 1034 | * reiserfs_delete_item() */ | |
1033 | /* Search for the needed object indirect item until there are no unformatted nodes to be removed. */ | 1035 | n_new_file_length = 0; |
1034 | do { | 1036 | delete = 1; |
1035 | need_research = 0; | 1037 | } |
1036 | p_s_bh = PATH_PLAST_BUFFER(p_s_path); | 1038 | |
1037 | /* Copy indirect item header to a temp variable. */ | 1039 | do { |
1038 | copy_item_head(&s_ih, PATH_PITEM_HEAD(p_s_path)); | 1040 | need_re_search = 0; |
1039 | /* Calculate number of unformatted nodes in this item. */ | 1041 | *p_n_cut_size = 0; |
1040 | n_unfm_number = I_UNFM_NUM(&s_ih); | 1042 | p_s_bh = PATH_PLAST_BUFFER(p_s_path); |
1041 | 1043 | copy_item_head(&s_ih, PATH_PITEM_HEAD(p_s_path)); | |
1042 | RFALSE(!is_indirect_le_ih(&s_ih) || !n_unfm_number || | 1044 | pos = I_UNFM_NUM(&s_ih); |
1043 | pos_in_item(p_s_path) + 1 != n_unfm_number, | ||
1044 | "PAP-5240: invalid item %h " | ||
1045 | "n_unfm_number = %d *p_n_pos_in_item = %d", | ||
1046 | &s_ih, n_unfm_number, pos_in_item(p_s_path)); | ||
1047 | |||
1048 | /* Calculate balance mode and position in the item to remove unformatted nodes. */ | ||
1049 | if (n_new_file_length == max_reiserfs_offset(inode)) { /* Case of delete. */ | ||
1050 | pos_in_item(p_s_path) = 0; | ||
1051 | *p_n_cut_size = -(IH_SIZE + ih_item_len(&s_ih)); | ||
1052 | c_mode = M_DELETE; | ||
1053 | } else { /* Case of truncate. */ | ||
1054 | if (n_new_file_length < le_ih_k_offset(&s_ih)) { | ||
1055 | pos_in_item(p_s_path) = 0; | ||
1056 | *p_n_cut_size = | ||
1057 | -(IH_SIZE + ih_item_len(&s_ih)); | ||
1058 | c_mode = M_DELETE; /* Delete this item. */ | ||
1059 | } else { | ||
1060 | /* indirect item must be truncated starting from *p_n_pos_in_item-th position */ | ||
1061 | pos_in_item(p_s_path) = | ||
1062 | (n_new_file_length + n_blk_size - | ||
1063 | le_ih_k_offset(&s_ih)) >> p_s_sb-> | ||
1064 | s_blocksize_bits; | ||
1065 | |||
1066 | RFALSE(pos_in_item(p_s_path) > | ||
1067 | n_unfm_number, | ||
1068 | "PAP-5250: invalid position in the item"); | ||
1069 | |||
1070 | /* Either convert last unformatted node of indirect item to direct item or increase | ||
1071 | its free space. */ | ||
1072 | if (pos_in_item(p_s_path) == | ||
1073 | n_unfm_number) { | ||
1074 | *p_n_cut_size = 0; /* Nothing to cut. */ | ||
1075 | return M_CONVERT; /* Maybe convert last unformatted node to the direct item. */ | ||
1076 | } | ||
1077 | /* Calculate size to cut. */ | ||
1078 | *p_n_cut_size = | ||
1079 | -(ih_item_len(&s_ih) - | ||
1080 | pos_in_item(p_s_path) * | ||
1081 | UNFM_P_SIZE); | ||
1082 | |||
1083 | c_mode = M_CUT; /* Cut from this indirect item. */ | ||
1084 | } | ||
1085 | } | ||
1086 | 1045 | ||
1087 | RFALSE(n_unfm_number <= pos_in_item(p_s_path), | 1046 | while (le_ih_k_offset (&s_ih) + (pos - 1) * blk_size > n_new_file_length) { |
1088 | "PAP-5260: invalid position in the indirect item"); | 1047 | __u32 *unfm, block; |
1089 | |||
1090 | /* pointers to be cut */ | ||
1091 | n_unfm_number -= pos_in_item(p_s_path); | ||
1092 | /* Set pointer to the last unformatted node pointer that is to be cut. */ | ||
1093 | p_n_unfm_pointer = | ||
1094 | (__le32 *) B_I_PITEM(p_s_bh, | ||
1095 | &s_ih) + I_UNFM_NUM(&s_ih) - | ||
1096 | 1 - *p_n_removed; | ||
1097 | |||
1098 | /* We go through the unformatted nodes pointers of the indirect | ||
1099 | item and look for the unformatted nodes in the cache. If we | ||
1100 | found some of them we free it, zero corresponding indirect item | ||
1101 | entry and log buffer containing that indirect item. For this we | ||
1102 | need to prepare last path element for logging. If some | ||
1103 | unformatted node has b_count > 1 we must not free this | ||
1104 | unformatted node since it is in use. */ | ||
1105 | reiserfs_prepare_for_journal(p_s_sb, p_s_bh, 1); | ||
1106 | // note: path could be changed, first line in for loop takes care | ||
1107 | // of it | ||
1108 | 1048 | ||
1109 | for (n_counter = *p_n_removed; | 1049 | /* Each unformatted block deletion may involve one additional |
1110 | n_counter < n_unfm_number; | 1050 | * bitmap block into the transaction, thereby the initial |
1111 | n_counter++, p_n_unfm_pointer--) { | 1051 | * journal space reservation might not be enough. */ |
1052 | if (!delete && (*p_n_cut_size) != 0 && | ||
1053 | reiserfs_transaction_free_space(th) < JOURNAL_FOR_FREE_BLOCK_AND_UPDATE_SD) { | ||
1054 | break; | ||
1055 | } | ||
1112 | 1056 | ||
1113 | cond_resched(); | 1057 | unfm = (__u32 *)B_I_PITEM(p_s_bh, &s_ih) + pos - 1; |
1114 | if (item_moved(&s_ih, p_s_path)) { | 1058 | block = get_block_num(unfm, 0); |
1115 | need_research = 1; | ||
1116 | break; | ||
1117 | } | ||
1118 | RFALSE(p_n_unfm_pointer < | ||
1119 | (__le32 *) B_I_PITEM(p_s_bh, &s_ih) | ||
1120 | || p_n_unfm_pointer > | ||
1121 | (__le32 *) B_I_PITEM(p_s_bh, | ||
1122 | &s_ih) + | ||
1123 | I_UNFM_NUM(&s_ih) - 1, | ||
1124 | "vs-5265: pointer out of range"); | ||
1125 | |||
1126 | /* Hole, nothing to remove. */ | ||
1127 | if (!get_block_num(p_n_unfm_pointer, 0)) { | ||
1128 | (*p_n_removed)++; | ||
1129 | continue; | ||
1130 | } | ||
1131 | 1059 | ||
1132 | (*p_n_removed)++; | 1060 | if (block != 0) { |
1061 | reiserfs_prepare_for_journal(p_s_sb, p_s_bh, 1); | ||
1062 | put_block_num(unfm, 0, 0); | ||
1063 | journal_mark_dirty (th, p_s_sb, p_s_bh); | ||
1064 | reiserfs_free_block(th, inode, block, 1); | ||
1065 | } | ||
1133 | 1066 | ||
1134 | tmp = get_block_num(p_n_unfm_pointer, 0); | 1067 | cond_resched(); |
1135 | put_block_num(p_n_unfm_pointer, 0, 0); | ||
1136 | journal_mark_dirty(th, p_s_sb, p_s_bh); | ||
1137 | reiserfs_free_block(th, inode, tmp, 1); | ||
1138 | if (item_moved(&s_ih, p_s_path)) { | ||
1139 | need_research = 1; | ||
1140 | break; | ||
1141 | } | ||
1142 | } | ||
1143 | 1068 | ||
1144 | /* a trick. If the buffer has been logged, this | 1069 | if (item_moved (&s_ih, p_s_path)) { |
1145 | ** will do nothing. If we've broken the loop without | 1070 | need_re_search = 1; |
1146 | ** logging it, it will restore the buffer | 1071 | break; |
1147 | ** | 1072 | } |
1148 | */ | 1073 | |
1149 | reiserfs_restore_prepared_buffer(p_s_sb, p_s_bh); | 1074 | pos --; |
1150 | 1075 | (*p_n_removed) ++; | |
1151 | /* This loop can be optimized. */ | 1076 | (*p_n_cut_size) -= UNFM_P_SIZE; |
1152 | } while ((*p_n_removed < n_unfm_number || need_research) && | 1077 | |
1153 | search_for_position_by_key(p_s_sb, p_s_item_key, | 1078 | if (pos == 0) { |
1154 | p_s_path) == | 1079 | (*p_n_cut_size) -= IH_SIZE; |
1155 | POSITION_FOUND); | 1080 | result = M_DELETE; |
1156 | 1081 | break; | |
1157 | RFALSE(*p_n_removed < n_unfm_number, | 1082 | } |
1158 | "PAP-5310: indirect item is not found"); | 1083 | } |
1159 | RFALSE(item_moved(&s_ih, p_s_path), | 1084 | /* a trick. If the buffer has been logged, this will do nothing. If |
1160 | "after while, comp failed, retry"); | 1085 | ** we've broken the loop without logging it, it will restore the |
1161 | 1086 | ** buffer */ | |
1162 | if (c_mode == M_CUT) | 1087 | reiserfs_restore_prepared_buffer(p_s_sb, p_s_bh); |
1163 | pos_in_item(p_s_path) *= UNFM_P_SIZE; | 1088 | } while (need_re_search && |
1164 | return c_mode; | 1089 | search_for_position_by_key(p_s_sb, p_s_item_key, p_s_path) == POSITION_FOUND); |
1090 | pos_in_item(p_s_path) = pos * UNFM_P_SIZE; | ||
1091 | |||
1092 | if (*p_n_cut_size == 0) { | ||
1093 | /* Nothing were cut. maybe convert last unformatted node to the | ||
1094 | * direct item? */ | ||
1095 | result = M_CONVERT; | ||
1096 | } | ||
1097 | return result; | ||
1165 | } | 1098 | } |
1166 | } | 1099 | } |
1167 | 1100 | ||
@@ -1948,7 +1881,8 @@ int reiserfs_do_truncate(struct reiserfs_transaction_handle *th, struct inode *p | |||
1948 | ** sure the file is consistent before ending the current trans | 1881 | ** sure the file is consistent before ending the current trans |
1949 | ** and starting a new one | 1882 | ** and starting a new one |
1950 | */ | 1883 | */ |
1951 | if (journal_transaction_should_end(th, th->t_blocks_allocated)) { | 1884 | if (journal_transaction_should_end(th, 0) || |
1885 | reiserfs_transaction_free_space(th) <= JOURNAL_FOR_FREE_BLOCK_AND_UPDATE_SD) { | ||
1952 | int orig_len_alloc = th->t_blocks_allocated; | 1886 | int orig_len_alloc = th->t_blocks_allocated; |
1953 | decrement_counters_in_path(&s_search_path); | 1887 | decrement_counters_in_path(&s_search_path); |
1954 | 1888 | ||
@@ -1962,7 +1896,7 @@ int reiserfs_do_truncate(struct reiserfs_transaction_handle *th, struct inode *p | |||
1962 | if (err) | 1896 | if (err) |
1963 | goto out; | 1897 | goto out; |
1964 | err = journal_begin(th, p_s_inode->i_sb, | 1898 | err = journal_begin(th, p_s_inode->i_sb, |
1965 | JOURNAL_PER_BALANCE_CNT * 6); | 1899 | JOURNAL_FOR_FREE_BLOCK_AND_UPDATE_SD + JOURNAL_PER_BALANCE_CNT * 4) ; |
1966 | if (err) | 1900 | if (err) |
1967 | goto out; | 1901 | goto out; |
1968 | reiserfs_update_inode_transaction(p_s_inode); | 1902 | reiserfs_update_inode_transaction(p_s_inode); |
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c index d63da756eb49..cae2abbc0c71 100644 --- a/fs/reiserfs/super.c +++ b/fs/reiserfs/super.c | |||
@@ -521,7 +521,8 @@ static int init_inodecache(void) | |||
521 | reiserfs_inode_cachep = kmem_cache_create("reiser_inode_cache", | 521 | reiserfs_inode_cachep = kmem_cache_create("reiser_inode_cache", |
522 | sizeof(struct | 522 | sizeof(struct |
523 | reiserfs_inode_info), | 523 | reiserfs_inode_info), |
524 | 0, SLAB_RECLAIM_ACCOUNT, | 524 | 0, (SLAB_RECLAIM_ACCOUNT| |
525 | SLAB_MEM_SPREAD), | ||
525 | init_once, NULL); | 526 | init_once, NULL); |
526 | if (reiserfs_inode_cachep == NULL) | 527 | if (reiserfs_inode_cachep == NULL) |
527 | return -ENOMEM; | 528 | return -ENOMEM; |
@@ -684,14 +685,14 @@ static const arg_desc_t logging_mode[] = { | |||
684 | (1 << REISERFS_DATA_ORDERED | 1 << REISERFS_DATA_WRITEBACK)}, | 685 | (1 << REISERFS_DATA_ORDERED | 1 << REISERFS_DATA_WRITEBACK)}, |
685 | {"writeback", 1 << REISERFS_DATA_WRITEBACK, | 686 | {"writeback", 1 << REISERFS_DATA_WRITEBACK, |
686 | (1 << REISERFS_DATA_ORDERED | 1 << REISERFS_DATA_LOG)}, | 687 | (1 << REISERFS_DATA_ORDERED | 1 << REISERFS_DATA_LOG)}, |
687 | {NULL, 0} | 688 | {.value = NULL} |
688 | }; | 689 | }; |
689 | 690 | ||
690 | /* possible values for -o barrier= */ | 691 | /* possible values for -o barrier= */ |
691 | static const arg_desc_t barrier_mode[] = { | 692 | static const arg_desc_t barrier_mode[] = { |
692 | {"none", 1 << REISERFS_BARRIER_NONE, 1 << REISERFS_BARRIER_FLUSH}, | 693 | {"none", 1 << REISERFS_BARRIER_NONE, 1 << REISERFS_BARRIER_FLUSH}, |
693 | {"flush", 1 << REISERFS_BARRIER_FLUSH, 1 << REISERFS_BARRIER_NONE}, | 694 | {"flush", 1 << REISERFS_BARRIER_FLUSH, 1 << REISERFS_BARRIER_NONE}, |
694 | {NULL, 0} | 695 | {.value = NULL} |
695 | }; | 696 | }; |
696 | 697 | ||
697 | /* possible values for "-o block-allocator=" and bits which are to be set in | 698 | /* possible values for "-o block-allocator=" and bits which are to be set in |
@@ -889,7 +890,7 @@ static int reiserfs_parse_options(struct super_block *s, char *options, /* strin | |||
889 | {"acl",.setmask = 1 << REISERFS_UNSUPPORTED_OPT}, | 890 | {"acl",.setmask = 1 << REISERFS_UNSUPPORTED_OPT}, |
890 | {"noacl",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT}, | 891 | {"noacl",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT}, |
891 | #endif | 892 | #endif |
892 | {"nolog",}, /* This is unsupported */ | 893 | {.option_name = "nolog"}, |
893 | {"replayonly",.setmask = 1 << REPLAYONLY}, | 894 | {"replayonly",.setmask = 1 << REPLAYONLY}, |
894 | {"block-allocator",.arg_required = 'a',.values = balloc}, | 895 | {"block-allocator",.arg_required = 'a',.values = balloc}, |
895 | {"data",.arg_required = 'd',.values = logging_mode}, | 896 | {"data",.arg_required = 'd',.values = logging_mode}, |
@@ -907,7 +908,7 @@ static int reiserfs_parse_options(struct super_block *s, char *options, /* strin | |||
907 | {"grpjquota",.arg_required = | 908 | {"grpjquota",.arg_required = |
908 | 'g' | (1 << REISERFS_OPT_ALLOWEMPTY),.values = NULL}, | 909 | 'g' | (1 << REISERFS_OPT_ALLOWEMPTY),.values = NULL}, |
909 | {"jqfmt",.arg_required = 'f',.values = NULL}, | 910 | {"jqfmt",.arg_required = 'f',.values = NULL}, |
910 | {NULL,} | 911 | {.option_name = NULL} |
911 | }; | 912 | }; |
912 | 913 | ||
913 | *blocks = 0; | 914 | *blocks = 0; |
diff --git a/fs/reiserfs/xattr_acl.c b/fs/reiserfs/xattr_acl.c index ab8894c3b9e5..58c418fbca2c 100644 --- a/fs/reiserfs/xattr_acl.c +++ b/fs/reiserfs/xattr_acl.c | |||
@@ -182,7 +182,7 @@ struct posix_acl *reiserfs_get_acl(struct inode *inode, int type) | |||
182 | { | 182 | { |
183 | char *name, *value; | 183 | char *name, *value; |
184 | struct posix_acl *acl, **p_acl; | 184 | struct posix_acl *acl, **p_acl; |
185 | size_t size; | 185 | int size; |
186 | int retval; | 186 | int retval; |
187 | struct reiserfs_inode_info *reiserfs_i = REISERFS_I(inode); | 187 | struct reiserfs_inode_info *reiserfs_i = REISERFS_I(inode); |
188 | 188 | ||
@@ -206,7 +206,7 @@ struct posix_acl *reiserfs_get_acl(struct inode *inode, int type) | |||
206 | return posix_acl_dup(*p_acl); | 206 | return posix_acl_dup(*p_acl); |
207 | 207 | ||
208 | size = reiserfs_xattr_get(inode, name, NULL, 0); | 208 | size = reiserfs_xattr_get(inode, name, NULL, 0); |
209 | if ((int)size < 0) { | 209 | if (size < 0) { |
210 | if (size == -ENODATA || size == -ENOSYS) { | 210 | if (size == -ENODATA || size == -ENOSYS) { |
211 | *p_acl = ERR_PTR(-ENODATA); | 211 | *p_acl = ERR_PTR(-ENODATA); |
212 | return NULL; | 212 | return NULL; |