Commit 33b5a586 authored by Oleg Drokin's avatar Oleg Drokin

stree.c, inode.c, file.c:

  reiserfs: move BKL further down the call chain into reiserfs_truncate_file. From Josh MacDonald
parent 586985c4
...@@ -66,9 +66,7 @@ static int reiserfs_file_release (struct inode * inode, struct file * filp) ...@@ -66,9 +66,7 @@ static int reiserfs_file_release (struct inode * inode, struct file * filp)
} }
static void reiserfs_vfs_truncate_file(struct inode *inode) { static void reiserfs_vfs_truncate_file(struct inode *inode) {
lock_kernel();
reiserfs_truncate_file(inode, 1) ; reiserfs_truncate_file(inode, 1) ;
unlock_kernel();
} }
/* Sync a reiserfs file. */ /* Sync a reiserfs file. */
......
...@@ -1738,7 +1738,6 @@ static int grab_tail_page(struct inode *p_s_inode, ...@@ -1738,7 +1738,6 @@ static int grab_tail_page(struct inode *p_s_inode,
void reiserfs_truncate_file(struct inode *p_s_inode, int update_timestamps) { void reiserfs_truncate_file(struct inode *p_s_inode, int update_timestamps) {
struct reiserfs_transaction_handle th ; struct reiserfs_transaction_handle th ;
int windex ; int windex ;
/* we want the offset for the first byte after the end of the file */ /* we want the offset for the first byte after the end of the file */
unsigned long offset = p_s_inode->i_size & (PAGE_CACHE_SIZE - 1) ; unsigned long offset = p_s_inode->i_size & (PAGE_CACHE_SIZE - 1) ;
unsigned blocksize = p_s_inode->i_sb->s_blocksize ; unsigned blocksize = p_s_inode->i_sb->s_blocksize ;
...@@ -1747,6 +1746,8 @@ void reiserfs_truncate_file(struct inode *p_s_inode, int update_timestamps) { ...@@ -1747,6 +1746,8 @@ void reiserfs_truncate_file(struct inode *p_s_inode, int update_timestamps) {
int error ; int error ;
struct buffer_head *bh = NULL ; struct buffer_head *bh = NULL ;
lock_kernel ();
if (p_s_inode->i_size > 0) { if (p_s_inode->i_size > 0) {
if ((error = grab_tail_page(p_s_inode, &page, &bh))) { if ((error = grab_tail_page(p_s_inode, &page, &bh))) {
// -ENOENT means we truncated past the end of the file, // -ENOENT means we truncated past the end of the file,
...@@ -1800,7 +1801,7 @@ void reiserfs_truncate_file(struct inode *p_s_inode, int update_timestamps) { ...@@ -1800,7 +1801,7 @@ void reiserfs_truncate_file(struct inode *p_s_inode, int update_timestamps) {
page_cache_release(page) ; page_cache_release(page) ;
} }
return ; unlock_kernel ();
} }
static int map_block_for_writepage(struct inode *inode, static int map_block_for_writepage(struct inode *inode,
......
...@@ -1715,13 +1715,13 @@ void reiserfs_do_truncate (struct reiserfs_transaction_handle *th, ...@@ -1715,13 +1715,13 @@ void reiserfs_do_truncate (struct reiserfs_transaction_handle *th,
/* Cut or delete file item. */ /* Cut or delete file item. */
n_deleted = reiserfs_cut_from_item(th, &s_search_path, &s_item_key, p_s_inode, page, n_new_file_size); n_deleted = reiserfs_cut_from_item(th, &s_search_path, &s_item_key, p_s_inode, page, n_new_file_size);
if (n_deleted < 0) { if (n_deleted < 0) {
reiserfs_warning ("vs-5665: reiserfs_truncate_file: cut_from_item failed"); reiserfs_warning ("vs-5665: reiserfs_do_truncate: reiserfs_cut_from_item failed");
reiserfs_check_path(&s_search_path) ; reiserfs_check_path(&s_search_path) ;
return; return;
} }
RFALSE( n_deleted > n_file_size, RFALSE( n_deleted > n_file_size,
"PAP-5670: reiserfs_truncate_file returns too big number: deleted %d, file_size %lu, item_key %K", "PAP-5670: reiserfs_cut_from_item: too many bytes deleted: deleted %d, file_size %lu, item_key %K",
n_deleted, n_file_size, &s_item_key); n_deleted, n_file_size, &s_item_key);
/* Change key to search the last file item. */ /* Change key to search the last file item. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment