ext4: Make sure all the block allocation paths reserve blocks
With delayed allocation we need to make sure block are reserved before we attempt to allocate them. Otherwise we get block allocation failure (ENOSPC) during writepages which cannot be handled. This would mean silent data loss (We do a printk stating data will be lost). This patch updates the DIO and fallocate code path to do block reservation before block allocation. This is needed to make sure parallel DIO and fallocate request doesn't take block out of delayed reserve space. When free blocks count go below a threshold we switch to a slow patch which looks at other CPU's accumulated percpu counter values. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
This commit is contained in:

committed by
Theodore Ts'o

parent
c4a0c46ec9
commit
a30d542a00
@@ -983,6 +983,8 @@ extern ext4_fsblk_t ext4_new_blocks(handle_t *handle, struct inode *inode,
|
||||
unsigned long *count, int *errp);
|
||||
extern ext4_fsblk_t ext4_old_new_blocks(handle_t *handle, struct inode *inode,
|
||||
ext4_fsblk_t goal, unsigned long *count, int *errp);
|
||||
extern int ext4_claim_free_blocks(struct ext4_sb_info *sbi,
|
||||
ext4_fsblk_t nblocks);
|
||||
extern ext4_fsblk_t ext4_has_free_blocks(struct ext4_sb_info *sbi,
|
||||
ext4_fsblk_t nblocks);
|
||||
extern void ext4_free_blocks(handle_t *handle, struct inode *inode,
|
||||
@@ -1207,6 +1209,17 @@ do { \
|
||||
__ext4_std_error((sb), __func__, (errno)); \
|
||||
} while (0)
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
/* Each CPU can accumulate FBC_BATCH blocks in their local
|
||||
* counters. So we need to make sure we have free blocks more
|
||||
* than FBC_BATCH * nr_cpu_ids. Also add a window of 4 times.
|
||||
*/
|
||||
#define EXT4_FREEBLOCKS_WATERMARK (4 * (FBC_BATCH * nr_cpu_ids))
|
||||
#else
|
||||
#define EXT4_FREEBLOCKS_WATERMARK 0
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Inodes and files operations
|
||||
*/
|
||||
|
Reference in New Issue
Block a user