f2fs.h (22ad0b6ab46683975c6da032f1c2593066c7b3bd) f2fs.h (55523519bc7227e651fd4febeb3aafdd22b8af1c)
1/*
2 * fs/f2fs/f2fs.h
3 *
4 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * http://www.samsung.com/
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as

--- 938 unchanged lines hidden (view full) ---

947
948 /* For fault injection */
949#ifdef CONFIG_F2FS_FAULT_INJECTION
950 struct f2fs_fault_info fault_info;
951#endif
952};
953
954#ifdef CONFIG_F2FS_FAULT_INJECTION
1/*
2 * fs/f2fs/f2fs.h
3 *
4 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * http://www.samsung.com/
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as

--- 938 unchanged lines hidden (view full) ---

947
948 /* For fault injection */
949#ifdef CONFIG_F2FS_FAULT_INJECTION
950 struct f2fs_fault_info fault_info;
951#endif
952};
953
954#ifdef CONFIG_F2FS_FAULT_INJECTION
955#define f2fs_show_injection_info(type) \
956 printk("%sF2FS-fs : inject %s in %s of %pF\n", \
957 KERN_INFO, fault_name[type], \
958 __func__, __builtin_return_address(0))
955static inline bool time_to_inject(struct f2fs_sb_info *sbi, int type)
956{
957 struct f2fs_fault_info *ffi = &sbi->fault_info;
958
959 if (!ffi->inject_rate)
960 return false;
961
962 if (!IS_FAULT_SET(ffi, type))
963 return false;
964
965 atomic_inc(&ffi->inject_ops);
966 if (atomic_read(&ffi->inject_ops) >= ffi->inject_rate) {
967 atomic_set(&ffi->inject_ops, 0);
959static inline bool time_to_inject(struct f2fs_sb_info *sbi, int type)
960{
961 struct f2fs_fault_info *ffi = &sbi->fault_info;
962
963 if (!ffi->inject_rate)
964 return false;
965
966 if (!IS_FAULT_SET(ffi, type))
967 return false;
968
969 atomic_inc(&ffi->inject_ops);
970 if (atomic_read(&ffi->inject_ops) >= ffi->inject_rate) {
971 atomic_set(&ffi->inject_ops, 0);
968 printk("%sF2FS-fs : inject %s in %pF\n",
969 KERN_INFO,
970 fault_name[type],
971 __builtin_return_address(0));
972 return true;
973 }
974 return false;
975}
976#endif
977
978/* For write statistics. Suppose sector size is 512 bytes,
979 * and the return value is in kbytes. s is of struct f2fs_sb_info.

--- 292 unchanged lines hidden (view full) ---

1272
1273static inline void f2fs_i_blocks_write(struct inode *, blkcnt_t, bool);
1274static inline bool inc_valid_block_count(struct f2fs_sb_info *sbi,
1275 struct inode *inode, blkcnt_t *count)
1276{
1277 blkcnt_t diff;
1278
1279#ifdef CONFIG_F2FS_FAULT_INJECTION
972 return true;
973 }
974 return false;
975}
976#endif
977
978/* For write statistics. Suppose sector size is 512 bytes,
979 * and the return value is in kbytes. s is of struct f2fs_sb_info.

--- 292 unchanged lines hidden (view full) ---

1272
1273static inline void f2fs_i_blocks_write(struct inode *, blkcnt_t, bool);
1274static inline bool inc_valid_block_count(struct f2fs_sb_info *sbi,
1275 struct inode *inode, blkcnt_t *count)
1276{
1277 blkcnt_t diff;
1278
1279#ifdef CONFIG_F2FS_FAULT_INJECTION
1280 if (time_to_inject(sbi, FAULT_BLOCK))
1280 if (time_to_inject(sbi, FAULT_BLOCK)) {
1281 f2fs_show_injection_info(FAULT_BLOCK);
1281 return false;
1282 return false;
1283 }
1282#endif
1283 /*
1284 * let's increase this in prior to actual block count change in order
1285 * for f2fs_sync_file to avoid data races when deciding checkpoint.
1286 */
1287 percpu_counter_add(&sbi->alloc_valid_block_count, (*count));
1288
1289 spin_lock(&sbi->stat_lock);

--- 223 unchanged lines hidden (view full) ---

1513 pgoff_t index, bool for_write)
1514{
1515#ifdef CONFIG_F2FS_FAULT_INJECTION
1516 struct page *page = find_lock_page(mapping, index);
1517
1518 if (page)
1519 return page;
1520
1284#endif
1285 /*
1286 * let's increase this in prior to actual block count change in order
1287 * for f2fs_sync_file to avoid data races when deciding checkpoint.
1288 */
1289 percpu_counter_add(&sbi->alloc_valid_block_count, (*count));
1290
1291 spin_lock(&sbi->stat_lock);

--- 223 unchanged lines hidden (view full) ---

1515 pgoff_t index, bool for_write)
1516{
1517#ifdef CONFIG_F2FS_FAULT_INJECTION
1518 struct page *page = find_lock_page(mapping, index);
1519
1520 if (page)
1521 return page;
1522
1521 if (time_to_inject(F2FS_M_SB(mapping), FAULT_PAGE_ALLOC))
1523 if (time_to_inject(F2FS_M_SB(mapping), FAULT_PAGE_ALLOC)) {
1524 f2fs_show_injection_info(FAULT_PAGE_ALLOC);
1522 return NULL;
1525 return NULL;
1526 }
1523#endif
1524 if (!for_write)
1525 return grab_cache_page(mapping, index);
1526 return grab_cache_page_write_begin(mapping, index, AOP_FLAG_NOFS);
1527}
1528
1529static inline void f2fs_copy_page(struct page *src, struct page *dst)
1530{

--- 459 unchanged lines hidden (view full) ---

1990
1991 return S_ISREG(inode->i_mode);
1992}
1993
1994static inline void *f2fs_kmalloc(struct f2fs_sb_info *sbi,
1995 size_t size, gfp_t flags)
1996{
1997#ifdef CONFIG_F2FS_FAULT_INJECTION
1527#endif
1528 if (!for_write)
1529 return grab_cache_page(mapping, index);
1530 return grab_cache_page_write_begin(mapping, index, AOP_FLAG_NOFS);
1531}
1532
1533static inline void f2fs_copy_page(struct page *src, struct page *dst)
1534{

--- 459 unchanged lines hidden (view full) ---

1994
1995 return S_ISREG(inode->i_mode);
1996}
1997
1998static inline void *f2fs_kmalloc(struct f2fs_sb_info *sbi,
1999 size_t size, gfp_t flags)
2000{
2001#ifdef CONFIG_F2FS_FAULT_INJECTION
1998 if (time_to_inject(sbi, FAULT_KMALLOC))
2002 if (time_to_inject(sbi, FAULT_KMALLOC)) {
2003 f2fs_show_injection_info(FAULT_KMALLOC);
1999 return NULL;
2004 return NULL;
2005 }
2000#endif
2001 return kmalloc(size, flags);
2002}
2003
2004static inline void *f2fs_kvmalloc(size_t size, gfp_t flags)
2005{
2006 void *ret;
2007

--- 651 unchanged lines hidden ---
2006#endif
2007 return kmalloc(size, flags);
2008}
2009
2010static inline void *f2fs_kvmalloc(size_t size, gfp_t flags)
2011{
2012 void *ret;
2013

--- 651 unchanged lines hidden ---