f2fs: return error when accessing insane flie offset
[linux-2.6-block.git] / fs / f2fs / segment.h
index 010f336a75730e5920d67a38d04b64cebc59bf57..b9b4f85ffeb6a8399e21f24b2f400e4b55ca2c2e 100644 (file)
 #define IS_DATASEG(t)  ((t) <= CURSEG_COLD_DATA)
 #define IS_NODESEG(t)  ((t) >= CURSEG_HOT_NODE)
 
+#define IS_HOT(t)      ((t) == CURSEG_HOT_NODE || (t) == CURSEG_HOT_DATA)
+#define IS_WARM(t)     ((t) == CURSEG_WARM_NODE || (t) == CURSEG_WARM_DATA)
+#define IS_COLD(t)     ((t) == CURSEG_COLD_NODE || (t) == CURSEG_COLD_DATA)
+
 #define IS_CURSEG(sbi, seg)                                            \
        (((seg) == CURSEG_I(sbi, CURSEG_HOT_DATA)->segno) ||    \
         ((seg) == CURSEG_I(sbi, CURSEG_WARM_DATA)->segno) ||   \
@@ -488,11 +492,6 @@ static inline int overprovision_segments(struct f2fs_sb_info *sbi)
        return SM_I(sbi)->ovp_segments;
 }
 
-static inline int overprovision_sections(struct f2fs_sb_info *sbi)
-{
-       return GET_SEC_FROM_SEG(sbi, (unsigned int)overprovision_segments(sbi));
-}
-
 static inline int reserved_sections(struct f2fs_sb_info *sbi)
 {
        return GET_SEC_FROM_SEG(sbi, (unsigned int)reserved_segments(sbi));
@@ -573,6 +572,10 @@ static inline bool need_inplace_update_policy(struct inode *inode,
        if (test_opt(sbi, LFS))
                return false;
 
+       /* if this is cold file, we should overwrite to avoid fragmentation */
+       if (file_is_cold(inode))
+               return true;
+
        if (policy & (0x1 << F2FS_IPU_FORCE))
                return true;
        if (policy & (0x1 << F2FS_IPU_SSR) && need_SSR(sbi))