Commit 0dff0b1b authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] reiserfs: fix problem when fs is out of space

From: Oleg Drokin <green@namesys.com>

This patch fixes various bad stuff that happens when you write to full or
almost full reiserfs filesystem.
parent 3491b2bc
...@@ -910,11 +910,11 @@ void reiserfs_release_claimed_blocks( ...@@ -910,11 +910,11 @@ void reiserfs_release_claimed_blocks(
int reiserfs_can_fit_pages ( struct super_block *sb /* superblock of filesystem int reiserfs_can_fit_pages ( struct super_block *sb /* superblock of filesystem
to estimate space */ ) to estimate space */ )
{ {
b_blocknr_t space; int space;
spin_lock(&REISERFS_SB(sb)->bitmap_lock); spin_lock(&REISERFS_SB(sb)->bitmap_lock);
space = (SB_FREE_BLOCKS(sb) - REISERFS_SB(sb)->reserved_blocks) >> ( PAGE_CACHE_SHIFT - sb->s_blocksize_bits); space = (SB_FREE_BLOCKS(sb) - REISERFS_SB(sb)->reserved_blocks) >> ( PAGE_CACHE_SHIFT - sb->s_blocksize_bits);
spin_unlock(&REISERFS_SB(sb)->bitmap_lock); spin_unlock(&REISERFS_SB(sb)->bitmap_lock);
return space; return space>0?space:0;
} }
...@@ -1085,6 +1085,8 @@ ssize_t reiserfs_file_write( struct file *file, /* the file we are going to writ ...@@ -1085,6 +1085,8 @@ ssize_t reiserfs_file_write( struct file *file, /* the file we are going to writ
// 100% of disk space anyway. // 100% of disk space anyway.
write_bytes = min_t(int, count, inode->i_sb->s_blocksize - (pos & (inode->i_sb->s_blocksize - 1))); write_bytes = min_t(int, count, inode->i_sb->s_blocksize - (pos & (inode->i_sb->s_blocksize - 1)));
num_pages = 1; num_pages = 1;
// No blocks were claimed before, so do it now.
reiserfs_claim_blocks_to_be_allocated(inode->i_sb, 1 << (PAGE_CACHE_SHIFT - inode->i_blkbits));
} }
/* Prepare for writing into the region, read in all the /* Prepare for writing into the region, read in all the
......
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