aboutsummaryrefslogtreecommitdiffstats
path: root/fs/reiserfs/inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/reiserfs/inode.c')
-rw-r--r--fs/reiserfs/inode.c43
1 files changed, 22 insertions, 21 deletions
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index d106edaef64f..b090d2dd2a8e 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -1987,7 +1987,7 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
1987** 1987**
1988** on failure, nonzero is returned, page_result and bh_result are untouched. 1988** on failure, nonzero is returned, page_result and bh_result are untouched.
1989*/ 1989*/
1990static int grab_tail_page(struct inode *p_s_inode, 1990static int grab_tail_page(struct inode *inode,
1991 struct page **page_result, 1991 struct page **page_result,
1992 struct buffer_head **bh_result) 1992 struct buffer_head **bh_result)
1993{ 1993{
@@ -1995,11 +1995,11 @@ static int grab_tail_page(struct inode *p_s_inode,
1995 /* we want the page with the last byte in the file, 1995 /* we want the page with the last byte in the file,
1996 ** not the page that will hold the next byte for appending 1996 ** not the page that will hold the next byte for appending
1997 */ 1997 */
1998 unsigned long index = (p_s_inode->i_size - 1) >> PAGE_CACHE_SHIFT; 1998 unsigned long index = (inode->i_size - 1) >> PAGE_CACHE_SHIFT;
1999 unsigned long pos = 0; 1999 unsigned long pos = 0;
2000 unsigned long start = 0; 2000 unsigned long start = 0;
2001 unsigned long blocksize = p_s_inode->i_sb->s_blocksize; 2001 unsigned long blocksize = inode->i_sb->s_blocksize;
2002 unsigned long offset = (p_s_inode->i_size) & (PAGE_CACHE_SIZE - 1); 2002 unsigned long offset = (inode->i_size) & (PAGE_CACHE_SIZE - 1);
2003 struct buffer_head *bh; 2003 struct buffer_head *bh;
2004 struct buffer_head *head; 2004 struct buffer_head *head;
2005 struct page *page; 2005 struct page *page;
@@ -2013,7 +2013,7 @@ static int grab_tail_page(struct inode *p_s_inode,
2013 if ((offset & (blocksize - 1)) == 0) { 2013 if ((offset & (blocksize - 1)) == 0) {
2014 return -ENOENT; 2014 return -ENOENT;
2015 } 2015 }
2016 page = grab_cache_page(p_s_inode->i_mapping, index); 2016 page = grab_cache_page(inode->i_mapping, index);
2017 error = -ENOMEM; 2017 error = -ENOMEM;
2018 if (!page) { 2018 if (!page) {
2019 goto out; 2019 goto out;
@@ -2042,7 +2042,7 @@ static int grab_tail_page(struct inode *p_s_inode,
2042 ** I've screwed up the code to find the buffer, or the code to 2042 ** I've screwed up the code to find the buffer, or the code to
2043 ** call prepare_write 2043 ** call prepare_write
2044 */ 2044 */
2045 reiserfs_error(p_s_inode->i_sb, "clm-6000", 2045 reiserfs_error(inode->i_sb, "clm-6000",
2046 "error reading block %lu", bh->b_blocknr); 2046 "error reading block %lu", bh->b_blocknr);
2047 error = -EIO; 2047 error = -EIO;
2048 goto unlock; 2048 goto unlock;
@@ -2065,27 +2065,28 @@ static int grab_tail_page(struct inode *p_s_inode,
2065** 2065**
2066** some code taken from block_truncate_page 2066** some code taken from block_truncate_page
2067*/ 2067*/
2068int reiserfs_truncate_file(struct inode *p_s_inode, int update_timestamps) 2068int reiserfs_truncate_file(struct inode *inode, int update_timestamps)
2069{ 2069{
2070 struct reiserfs_transaction_handle th; 2070 struct reiserfs_transaction_handle th;
2071 /* we want the offset for the first byte after the end of the file */ 2071 /* we want the offset for the first byte after the end of the file */
2072 unsigned long offset = p_s_inode->i_size & (PAGE_CACHE_SIZE - 1); 2072 unsigned long offset = inode->i_size & (PAGE_CACHE_SIZE - 1);
2073 unsigned blocksize = p_s_inode->i_sb->s_blocksize; 2073 unsigned blocksize = inode->i_sb->s_blocksize;
2074 unsigned length; 2074 unsigned length;
2075 struct page *page = NULL; 2075 struct page *page = NULL;
2076 int error; 2076 int error;
2077 struct buffer_head *bh = NULL; 2077 struct buffer_head *bh = NULL;
2078 int err2; 2078 int err2;
2079 2079
2080 reiserfs_write_lock(p_s_inode->i_sb); 2080 reiserfs_write_lock(inode->i_sb);
2081 2081
2082 if (p_s_inode->i_size > 0) { 2082 if (inode->i_size > 0) {
2083 if ((error = grab_tail_page(p_s_inode, &page, &bh))) { 2083 error = grab_tail_page(inode, &page, &bh);
2084 if (error) {
2084 // -ENOENT means we truncated past the end of the file, 2085 // -ENOENT means we truncated past the end of the file,
2085 // and get_block_create_0 could not find a block to read in, 2086 // and get_block_create_0 could not find a block to read in,
2086 // which is ok. 2087 // which is ok.
2087 if (error != -ENOENT) 2088 if (error != -ENOENT)
2088 reiserfs_error(p_s_inode->i_sb, "clm-6001", 2089 reiserfs_error(inode->i_sb, "clm-6001",
2089 "grab_tail_page failed %d", 2090 "grab_tail_page failed %d",
2090 error); 2091 error);
2091 page = NULL; 2092 page = NULL;
@@ -2103,19 +2104,19 @@ int reiserfs_truncate_file(struct inode *p_s_inode, int update_timestamps)
2103 /* it is enough to reserve space in transaction for 2 balancings: 2104 /* it is enough to reserve space in transaction for 2 balancings:
2104 one for "save" link adding and another for the first 2105 one for "save" link adding and another for the first
2105 cut_from_item. 1 is for update_sd */ 2106 cut_from_item. 1 is for update_sd */
2106 error = journal_begin(&th, p_s_inode->i_sb, 2107 error = journal_begin(&th, inode->i_sb,
2107 JOURNAL_PER_BALANCE_CNT * 2 + 1); 2108 JOURNAL_PER_BALANCE_CNT * 2 + 1);
2108 if (error) 2109 if (error)
2109 goto out; 2110 goto out;
2110 reiserfs_update_inode_transaction(p_s_inode); 2111 reiserfs_update_inode_transaction(inode);
2111 if (update_timestamps) 2112 if (update_timestamps)
2112 /* we are doing real truncate: if the system crashes before the last 2113 /* we are doing real truncate: if the system crashes before the last
2113 transaction of truncating gets committed - on reboot the file 2114 transaction of truncating gets committed - on reboot the file
2114 either appears truncated properly or not truncated at all */ 2115 either appears truncated properly or not truncated at all */
2115 add_save_link(&th, p_s_inode, 1); 2116 add_save_link(&th, inode, 1);
2116 err2 = reiserfs_do_truncate(&th, p_s_inode, page, update_timestamps); 2117 err2 = reiserfs_do_truncate(&th, inode, page, update_timestamps);
2117 error = 2118 error =
2118 journal_end(&th, p_s_inode->i_sb, JOURNAL_PER_BALANCE_CNT * 2 + 1); 2119 journal_end(&th, inode->i_sb, JOURNAL_PER_BALANCE_CNT * 2 + 1);
2119 if (error) 2120 if (error)
2120 goto out; 2121 goto out;
2121 2122
@@ -2126,7 +2127,7 @@ int reiserfs_truncate_file(struct inode *p_s_inode, int update_timestamps)
2126 } 2127 }
2127 2128
2128 if (update_timestamps) { 2129 if (update_timestamps) {
2129 error = remove_save_link(p_s_inode, 1 /* truncate */ ); 2130 error = remove_save_link(inode, 1 /* truncate */);
2130 if (error) 2131 if (error)
2131 goto out; 2132 goto out;
2132 } 2133 }
@@ -2145,14 +2146,14 @@ int reiserfs_truncate_file(struct inode *p_s_inode, int update_timestamps)
2145 page_cache_release(page); 2146 page_cache_release(page);
2146 } 2147 }
2147 2148
2148 reiserfs_write_unlock(p_s_inode->i_sb); 2149 reiserfs_write_unlock(inode->i_sb);
2149 return 0; 2150 return 0;
2150 out: 2151 out:
2151 if (page) { 2152 if (page) {
2152 unlock_page(page); 2153 unlock_page(page);
2153 page_cache_release(page); 2154 page_cache_release(page);
2154 } 2155 }
2155 reiserfs_write_unlock(p_s_inode->i_sb); 2156 reiserfs_write_unlock(inode->i_sb);
2156 return error; 2157 return error;
2157} 2158}
2158 2159