summaryrefslogtreecommitdiffstats
path: root/fs/ext4/super.c
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2015-06-21 01:25:29 -0400
committerTheodore Ts'o <tytso@mit.edu>2015-06-21 01:25:29 -0400
commitc5e298ae53dc2eb69f2f7153be03454c8a33c658 (patch)
tree07bd2e74badcff3d55627b2f315b1640bbde15d8 /fs/ext4/super.c
parent89d96a6f8e6491f24fc8f99fd6ae66820e85c6c1 (diff)
downloadlinux-c5e298ae53dc2eb69f2f7153be03454c8a33c658.tar.gz
linux-c5e298ae53dc2eb69f2f7153be03454c8a33c658.tar.bz2
linux-c5e298ae53dc2eb69f2f7153be03454c8a33c658.zip
ext4: prevent ext4_quota_write() from failing due to ENOSPC
In order to prevent quota block tracking to be inaccurate when ext4_quota_write() fails with ENOSPC, we make two changes. The quota file can now use the reserved block (since the quota file is arguably file system metadata), and ext4_quota_write() now uses ext4_should_retry_alloc() to retry the block allocation after a commit has completed and released some blocks for allocation. This fixes failures of xfstests generic/270: Quota error (device vdc): write_blk: dquota write failed Quota error (device vdc): qtree_write_dquot: Error -28 occurred while creating quota Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/super.c')
-rw-r--r--fs/ext4/super.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 2858ac09f5a3..bd4df9d379b2 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -5438,6 +5438,7 @@ static ssize_t ext4_quota_write(struct super_block *sb, int type,
struct inode *inode = sb_dqopt(sb)->files[type];
ext4_lblk_t blk = off >> EXT4_BLOCK_SIZE_BITS(sb);
int err, offset = off & (sb->s_blocksize - 1);
+ int retries = 0;
struct buffer_head *bh;
handle_t *handle = journal_current_handle();
@@ -5458,7 +5459,12 @@ static ssize_t ext4_quota_write(struct super_block *sb, int type,
return -EIO;
}
- bh = ext4_bread(handle, inode, blk, 1);
+ do {
+ bh = ext4_bread(handle, inode, blk,
+ EXT4_GET_BLOCKS_CREATE |
+ EXT4_GET_BLOCKS_METADATA_NOFAIL);
+ } while (IS_ERR(bh) && (PTR_ERR(bh) == -ENOSPC) &&
+ ext4_should_retry_alloc(inode->i_sb, &retries));
if (IS_ERR(bh))
return PTR_ERR(bh);
if (!bh)