From 202d9528b7430042398bd89765e8133f4bace2c5 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 8 Sep 2008 23:15:48 -0400 Subject: [PATCH] Update delalloc ENOSPC patch comments for clarity --- ...node-to-journal-handle-after-block-alloca.patch | 13 ++++++------- ext4-Add-percpu-dirty-block-accounting.patch | 11 ++++++----- ...sure-all-the-block-allocation-paths-reser.patch | 22 ++++++++++------------ ...y-block-allocation-if-we-have-free-blocks.patch | 11 ++++++----- ext4-Retry-block-reservation.patch | 15 +++++++-------- ext4-Signed-arithematic-fix.patch | 7 ++++--- ...h-to-non-delalloc-mode-when-we-are-low-on.patch | 14 +++++++------- ext4_i_disksize_lock_race_fix.patch | 21 ++++++++++----------- ext4_nonmballoc_reservation_ENOSPC_fix.patch | 5 +++-- 9 files changed, 59 insertions(+), 60 deletions(-) diff --git a/ext4-Add-inode-to-journal-handle-after-block-alloca.patch b/ext4-Add-inode-to-journal-handle-after-block-alloca.patch index 44e1262c..6ca1b96c 100644 --- a/ext4-Add-inode-to-journal-handle-after-block-alloca.patch +++ b/ext4-Add-inode-to-journal-handle-after-block-alloca.patch @@ -1,15 +1,14 @@ From: Aneesh Kumar K.V -ext4: Add inode to journal handle after block allocation for ordered mode - -This make sure when we have block allocation failure -we don't have inode inode added to the journal handle. -So journal commit will not include the inode for which -block allocation failed. +ext4: Don't add the inode to journal handle until after the block is allocated +Make sure we don't add the inode to the journal handle until after the +block allocation, so that a journal commit will not include the inode in +case of block allocation failure. + Signed-off-by: Aneesh Kumar K.V Signed-off-by: Mingming Cao - +Signed-off-by: "Theodore Ts'o" --- fs/ext4/balloc.c | 2 +- fs/ext4/inode.c | 36 +++++++++++++++--------------------- diff --git a/ext4-Add-percpu-dirty-block-accounting.patch b/ext4-Add-percpu-dirty-block-accounting.patch index d0a1ab44..53081817 100644 --- a/ext4-Add-percpu-dirty-block-accounting.patch +++ b/ext4-Add-percpu-dirty-block-accounting.patch @@ -2,14 +2,15 @@ ext4: Add percpu dirty block accounting. From: Aneesh Kumar K.V -This patch add dirty block accounting using percpu_counters. -Delayed allocation block reservation is now done by updating -dirty block counter. In the later patch we switch to non -delalloc mode if the filesystem free blocks is < that -150 % of total filesystem dirty blocks +This patch adds dirty block accounting using percpu_counters. Delayed +allocation block reservation is now done by updating dirty block +counter. In the later patch we switch to non delalloc mode if the +filesystem free blocks is greater than 150% of total filesystem dirty +blocks Signed-off-by: Aneesh Kumar K.V Signed-off-by: Mingming Cao +Signed-off-by: "Theodore Ts'o" --- fs/ext4/balloc.c | 59 +++++++++++++++++++++++++++++++++--------------------- fs/ext4/ext4_sb.h | 1 diff --git a/ext4-Make-sure-all-the-block-allocation-paths-reser.patch b/ext4-Make-sure-all-the-block-allocation-paths-reser.patch index ccc57eb9..74d2082d 100644 --- a/ext4-Make-sure-all-the-block-allocation-paths-reser.patch +++ b/ext4-Make-sure-all-the-block-allocation-paths-reser.patch @@ -1,20 +1,18 @@ 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 update 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. +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. +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 +Signed-off-by: "Theodore Ts'o" --- fs/ext4/balloc.c | 58 ++++++++++++++++++++++++++++++++++++++-------------- fs/ext4/ext4.h | 13 +++++++++++ diff --git a/ext4-Retry-block-allocation-if-we-have-free-blocks.patch b/ext4-Retry-block-allocation-if-we-have-free-blocks.patch index 0502c497..2722e99e 100644 --- a/ext4-Retry-block-allocation-if-we-have-free-blocks.patch +++ b/ext4-Retry-block-allocation-if-we-have-free-blocks.patch @@ -1,15 +1,16 @@ From: Aneesh Kumar K.V + ext4: Retry block allocation if we have free blocks left -When we truncate files, the meta-data blocks released -are not reused untill we commit the truncate transaction. -That means delayed get_block request will return ENOSPC -even if we have free blocks left. Force a journal commit -and retry block allocation if we get ENOSPC with free +When we truncate files, the meta-data blocks released are not reused +untill we commit the truncate transaction. That means delayed get_block +request will return ENOSPC even if we have free blocks left. Force a +journal commit and retry block allocation if we get ENOSPC with free blocks left. Signed-off-by: Aneesh Kumar K.V Signed-off-by: Mingming Cao +Signed-off-by: "Theodore Ts'o" --- fs/ext4/inode.c | 81 +++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 57 insertions(+), 24 deletions(-) diff --git a/ext4-Retry-block-reservation.patch b/ext4-Retry-block-reservation.patch index 6ef6890e..acc92d56 100644 --- a/ext4-Retry-block-reservation.patch +++ b/ext4-Retry-block-reservation.patch @@ -2,17 +2,16 @@ ext4: Retry block reservation From: Aneesh Kumar K.V -During block reservation if we don't have enough -blocks left, retry block reservation with smaller -block count. This make sure we try fallocate -and DIO with smaller request size and don't fail early. -The delayed allocation reservation cannot try with smaller -block count. So retry block reservation to handle temporary -disk full conditions. Also print free blocks details if we -fail block allocation during writepages. +During block reservation if we don't have enough blocks left, retry +block reservation with smaller block counts. This makes sure we try +fallocate and DIO with smaller request size and don't fail early. The +delayed allocation reservation cannot try with smaller block count. So +retry block reservation to handle temporary disk full conditions. Also +print free blocks details if we fail block allocation during writepages. Signed-off-by: Aneesh Kumar K.V Signed-off-by: Mingming Cao +Signed-off-by: "Theodore Ts'o" --- fs/ext4/balloc.c | 8 +++++++- fs/ext4/inode.c | 14 +++++++++++--- diff --git a/ext4-Signed-arithematic-fix.patch b/ext4-Signed-arithematic-fix.patch index 32a1047b..5ce20221 100644 --- a/ext4-Signed-arithematic-fix.patch +++ b/ext4-Signed-arithematic-fix.patch @@ -2,12 +2,13 @@ ext4: Signed arithematic fix From: Aneesh Kumar K.V -This patch converts some usage of ext4_fsblk_t to s64 -This is needed so that some of the sign conversion works -as expected in if loops. +This patch converts some usage of ext4_fsblk_t to s64. This is needed +so that some of the sign conversion works as expected in if loops. Signed-off-by: Aneesh Kumar K.V Signed-off-by: Mingming Cao +Signed-off-by: "Theodore Ts'o" + diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c index 87b198c..e4274aa 100644 --- a/fs/ext4/balloc.c diff --git a/ext4-Switch-to-non-delalloc-mode-when-we-are-low-on.patch b/ext4-Switch-to-non-delalloc-mode-when-we-are-low-on.patch index e5aa7e85..450f9a33 100644 --- a/ext4-Switch-to-non-delalloc-mode-when-we-are-low-on.patch +++ b/ext4-Switch-to-non-delalloc-mode-when-we-are-low-on.patch @@ -2,16 +2,16 @@ ext4: Switch to non delalloc mode when we are low on free blocks count. From: Aneesh Kumar K.V -delayed allocation allocate blocks during writepages. That also -means we cannot handle block allocation failures. Switch to -non - delalloc when we are running low on free blocks. -Delayed allocation need to do aggressive meta-data block reservation -considering that the requested blocks can all be discontiguous. -Switching to non-delalloc avoids that. Also we can satisfy -partial write in non-delalloc mode. +The delayed allocation code allocates blocks during writepages(), which +can not handle block allocation failures. To deal with this, we switch +away from delayed allocation mode when we are running low on free bocks. +This also allows us to avoid needing to reserve a large number of +meta-data blocks in case all of the requested blocks are discontiguous, Signed-off-by: Aneesh Kumar K.V Signed-off-by: Mingming Cao +Signed-off-by: "Theodore Ts'o" + --- fs/ext4/inode.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/ext4_i_disksize_lock_race_fix.patch b/ext4_i_disksize_lock_race_fix.patch index 38783a36..8f68abd0 100644 --- a/ext4_i_disksize_lock_race_fix.patch +++ b/ext4_i_disksize_lock_race_fix.patch @@ -2,20 +2,19 @@ ext4: Properly update i_disksize. From: Aneesh Kumar K.V -With delayed allocation we use i_data_sem to update -i_disksize. We need to update i_disksize only -if the new size specified is greater than the -current value and we need to make sure we don't -race with other i_disksize update. With delayed -allocation we will switch to nondelalloc write_begin -if we are low on free blocks. That means nondelalloc -write_begin also need to use the same locking. +With delayed allocation we use i_data_sem to update i_disksize. We need +to update i_disksize only if the new size specified is greater than the +current value and we need to make sure we don't race with other +i_disksize update. With delayed allocation we will switch to the +write_begin function for non-delayed allocation if we are low on free +blocks. That means write_begin function for non-delayed allocation also +needs to use the same locking. -We also need to check and update i_disksize even -if the new size is less that inode.i_size because -of delayed allocation. +We also need to check and update i_disksize even if the new size is less +that inode.i_size because of delayed allocation. Signed-off-by: Aneesh Kumar K.V +Signed-off-by: "Theodore Ts'o" --- fs/ext4/ext4.h | 11 ++++++++++ fs/ext4/extents.c | 9 ++++---- diff --git a/ext4_nonmballoc_reservation_ENOSPC_fix.patch b/ext4_nonmballoc_reservation_ENOSPC_fix.patch index d2b90c76..62e35ce1 100644 --- a/ext4_nonmballoc_reservation_ENOSPC_fix.patch +++ b/ext4_nonmballoc_reservation_ENOSPC_fix.patch @@ -5,10 +5,10 @@ From: Aneesh Kumar K.V We run into ENOSPC error on nonmballoc ext4, even when there is free blocks on the filesystem. -The patch include two changes +The patch includes two changes: a) Set reservation to NULL if we trying to allocate near group_target_block -from the goal group if the free block in the group is less than windowsz. +from the goal group if the free block in the group is less than windows. This should give us a better chance to allocate near group_target_block. This also ensures that if we are not allocating near group_target_block then we don't trun off reservation. This should enable us to allocate @@ -18,6 +18,7 @@ b) we don't need to check the window size if the block reservation is off. Signed-off-by: Aneesh Kumar K.V Signed-off-by: Mingming Cao +Signed-off-by: "Theodore Ts'o" --- fs/ext4/balloc.c | 18 ++++++++++-------- 1 files changed, 10 insertions(+), 8 deletions(-) -- 2.11.4.GIT