aboutsummaryrefslogtreecommitdiffstats
path: root/fs/reiserfs/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/reiserfs/file.c')
-rw-r--r--fs/reiserfs/file.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/fs/reiserfs/file.c b/fs/reiserfs/file.c
index ad6fa964b0e7..be12879bb179 100644
--- a/fs/reiserfs/file.c
+++ b/fs/reiserfs/file.c
@@ -192,6 +192,8 @@ static int reiserfs_allocate_blocks_for_region(struct reiserfs_transaction_handl
192 192
193 allocated_blocks = kmalloc((blocks_to_allocate + will_prealloc) * 193 allocated_blocks = kmalloc((blocks_to_allocate + will_prealloc) *
194 sizeof(b_blocknr_t), GFP_NOFS); 194 sizeof(b_blocknr_t), GFP_NOFS);
195 if (!allocated_blocks)
196 return -ENOMEM;
195 197
196 /* First we compose a key to point at the writing position, we want to do 198 /* First we compose a key to point at the writing position, we want to do
197 that outside of any locking region. */ 199 that outside of any locking region. */
@@ -1285,6 +1287,23 @@ static ssize_t reiserfs_file_write(struct file *file, /* the file we are going t
1285 struct reiserfs_transaction_handle th; 1287 struct reiserfs_transaction_handle th;
1286 th.t_trans_id = 0; 1288 th.t_trans_id = 0;
1287 1289
1290 /* If a filesystem is converted from 3.5 to 3.6, we'll have v3.5 items
1291 * lying around (most of the disk, in fact). Despite the filesystem
1292 * now being a v3.6 format, the old items still can't support large
1293 * file sizes. Catch this case here, as the rest of the VFS layer is
1294 * oblivious to the different limitations between old and new items.
1295 * reiserfs_setattr catches this for truncates. This chunk is lifted
1296 * from generic_write_checks. */
1297 if (get_inode_item_key_version (inode) == KEY_FORMAT_3_5 &&
1298 *ppos + count > MAX_NON_LFS) {
1299 if (*ppos >= MAX_NON_LFS) {
1300 send_sig(SIGXFSZ, current, 0);
1301 return -EFBIG;
1302 }
1303 if (count > MAX_NON_LFS - (unsigned long)*ppos)
1304 count = MAX_NON_LFS - (unsigned long)*ppos;
1305 }
1306
1288 if (file->f_flags & O_DIRECT) { // Direct IO needs treatment 1307 if (file->f_flags & O_DIRECT) { // Direct IO needs treatment
1289 ssize_t result, after_file_end = 0; 1308 ssize_t result, after_file_end = 0;
1290 if ((*ppos + count >= inode->i_size) 1309 if ((*ppos + count >= inode->i_size)
@@ -1445,13 +1464,11 @@ static ssize_t reiserfs_file_write(struct file *file, /* the file we are going t
1445 partially overwritten pages, if needed. And lock the pages, 1464 partially overwritten pages, if needed. And lock the pages,
1446 so that nobody else can access these until we are done. 1465 so that nobody else can access these until we are done.
1447 We get number of actual blocks needed as a result. */ 1466 We get number of actual blocks needed as a result. */
1448 blocks_to_allocate = 1467 res = reiserfs_prepare_file_region_for_write(inode, pos,
1449 reiserfs_prepare_file_region_for_write(inode, pos, 1468 num_pages,
1450 num_pages, 1469 write_bytes,
1451 write_bytes, 1470 prepared_pages);
1452 prepared_pages); 1471 if (res < 0) {
1453 if (blocks_to_allocate < 0) {
1454 res = blocks_to_allocate;
1455 reiserfs_release_claimed_blocks(inode->i_sb, 1472 reiserfs_release_claimed_blocks(inode->i_sb,
1456 num_pages << 1473 num_pages <<
1457 (PAGE_CACHE_SHIFT - 1474 (PAGE_CACHE_SHIFT -
@@ -1459,6 +1476,8 @@ static ssize_t reiserfs_file_write(struct file *file, /* the file we are going t
1459 break; 1476 break;
1460 } 1477 }
1461 1478
1479 blocks_to_allocate = res;
1480
1462 /* First we correct our estimate of how many blocks we need */ 1481 /* First we correct our estimate of how many blocks we need */
1463 reiserfs_release_claimed_blocks(inode->i_sb, 1482 reiserfs_release_claimed_blocks(inode->i_sb,
1464 (num_pages << 1483 (num_pages <<