]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - fs/f2fs/segment.h
f2fs: reclaim prefree segments periodically
[karo-tx-linux.git] / fs / f2fs / segment.h
index bdd10eab8c40d7c25fc24eebbeed2a0f705e902b..abe7094c4f7a661a4fe82a7f8c0479863a8eb697 100644 (file)
@@ -14,6 +14,8 @@
 #define NULL_SEGNO                     ((unsigned int)(~0))
 #define NULL_SECNO                     ((unsigned int)(~0))
 
+#define DEF_RECLAIM_PREFREE_SEGMENTS   100     /* 200MB of prefree segments */
+
 /* L: Logical segment # in volume, R: Relative segment # in main area */
 #define GET_L2R_SEGNO(free_i, segno)   (segno - free_i->start_segno)
 #define GET_R2L_SEGNO(free_i, segno)   (segno + free_i->start_segno)
@@ -90,6 +92,8 @@
        (blk_addr << ((sbi)->log_blocksize - F2FS_LOG_SECTOR_SIZE))
 #define SECTOR_TO_BLOCK(sbi, sectors)                                  \
        (sectors >> ((sbi)->log_blocksize - F2FS_LOG_SECTOR_SIZE))
+#define MAX_BIO_BLOCKS(max_hw_blocks)                                  \
+       (min((int)max_hw_blocks, BIO_MAX_PAGES))
 
 /* during checkpoint, bio_private is used to synchronize the last bio */
 struct bio_private {
@@ -470,6 +474,11 @@ static inline bool has_not_enough_free_secs(struct f2fs_sb_info *sbi, int freed)
                                                reserved_sections(sbi)));
 }
 
+static inline bool excess_prefree_segs(struct f2fs_sb_info *sbi)
+{
+       return (prefree_segments(sbi) > SM_I(sbi)->rec_prefree_segments);
+}
+
 static inline int utilization(struct f2fs_sb_info *sbi)
 {
        return div_u64((u64)valid_user_blocks(sbi) * 100, sbi->user_block_count);