file.c (60b2b4ee2bc01dd052f99fa9d65da2232102ef8e) | file.c (2ef79ecb5e906d87475d3e0c49b22425499a89f3) |
---|---|
1/* 2 * fs/f2fs/file.c 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 --- 1683 unchanged lines hidden (view full) --- 1692 f2fs_msg(F2FS_I_SB(inode)->sb, KERN_WARNING, 1693 "Unexpected flush for atomic writes: ino=%lu, npages=%u", 1694 inode->i_ino, get_dirty_pages(inode)); 1695 ret = filemap_write_and_wait_range(inode->i_mapping, 0, LLONG_MAX); 1696 if (ret) 1697 goto out; 1698skip_flush: 1699 set_inode_flag(inode, FI_ATOMIC_FILE); | 1/* 2 * fs/f2fs/file.c 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 --- 1683 unchanged lines hidden (view full) --- 1692 f2fs_msg(F2FS_I_SB(inode)->sb, KERN_WARNING, 1693 "Unexpected flush for atomic writes: ino=%lu, npages=%u", 1694 inode->i_ino, get_dirty_pages(inode)); 1695 ret = filemap_write_and_wait_range(inode->i_mapping, 0, LLONG_MAX); 1696 if (ret) 1697 goto out; 1698skip_flush: 1699 set_inode_flag(inode, FI_ATOMIC_FILE); |
1700 clear_inode_flag(inode, FI_ATOMIC_REVOKE_REQUEST); |
|
1700 f2fs_update_time(F2FS_I_SB(inode), REQ_TIME); 1701 1702 F2FS_I(inode)->inmem_task = current; 1703 stat_inc_atomic_write(inode); 1704 stat_update_max_atomic_write(inode); 1705out: 1706 up_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]); 1707 inode_unlock(inode); --- 25 unchanged lines hidden (view full) --- 1733 if (f2fs_is_atomic_file(inode)) { 1734 ret = commit_inmem_pages(inode); 1735 if (ret) 1736 goto err_out; 1737 1738 ret = f2fs_do_sync_file(filp, 0, LLONG_MAX, 0, true); 1739 if (!ret) { 1740 clear_inode_flag(inode, FI_ATOMIC_FILE); | 1701 f2fs_update_time(F2FS_I_SB(inode), REQ_TIME); 1702 1703 F2FS_I(inode)->inmem_task = current; 1704 stat_inc_atomic_write(inode); 1705 stat_update_max_atomic_write(inode); 1706out: 1707 up_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]); 1708 inode_unlock(inode); --- 25 unchanged lines hidden (view full) --- 1734 if (f2fs_is_atomic_file(inode)) { 1735 ret = commit_inmem_pages(inode); 1736 if (ret) 1737 goto err_out; 1738 1739 ret = f2fs_do_sync_file(filp, 0, LLONG_MAX, 0, true); 1740 if (!ret) { 1741 clear_inode_flag(inode, FI_ATOMIC_FILE); |
1742 F2FS_I(inode)->i_gc_failures[GC_FAILURE_ATOMIC] = 0; |
|
1741 stat_dec_atomic_write(inode); 1742 } 1743 } else { 1744 ret = f2fs_do_sync_file(filp, 0, LLONG_MAX, 1, false); 1745 } 1746err_out: | 1743 stat_dec_atomic_write(inode); 1744 } 1745 } else { 1746 ret = f2fs_do_sync_file(filp, 0, LLONG_MAX, 1, false); 1747 } 1748err_out: |
1749 if (is_inode_flag_set(inode, FI_ATOMIC_REVOKE_REQUEST)) { 1750 clear_inode_flag(inode, FI_ATOMIC_REVOKE_REQUEST); 1751 ret = -EINVAL; 1752 } |
|
1747 up_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]); 1748 inode_unlock(inode); 1749 mnt_drop_write_file(filp); 1750 return ret; 1751} 1752 1753static int f2fs_ioc_start_volatile_write(struct file *filp) 1754{ --- 960 unchanged lines hidden (view full) --- 2715 2716int f2fs_pin_file_control(struct inode *inode, bool inc) 2717{ 2718 struct f2fs_inode_info *fi = F2FS_I(inode); 2719 struct f2fs_sb_info *sbi = F2FS_I_SB(inode); 2720 2721 /* Use i_gc_failures for normal file as a risk signal. */ 2722 if (inc) | 1753 up_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]); 1754 inode_unlock(inode); 1755 mnt_drop_write_file(filp); 1756 return ret; 1757} 1758 1759static int f2fs_ioc_start_volatile_write(struct file *filp) 1760{ --- 960 unchanged lines hidden (view full) --- 2721 2722int f2fs_pin_file_control(struct inode *inode, bool inc) 2723{ 2724 struct f2fs_inode_info *fi = F2FS_I(inode); 2725 struct f2fs_sb_info *sbi = F2FS_I_SB(inode); 2726 2727 /* Use i_gc_failures for normal file as a risk signal. */ 2728 if (inc) |
2723 f2fs_i_gc_failures_write(inode, fi->i_gc_failures + 1); | 2729 f2fs_i_gc_failures_write(inode, 2730 fi->i_gc_failures[GC_FAILURE_PIN] + 1); |
2724 | 2731 |
2725 if (fi->i_gc_failures > sbi->gc_pin_file_threshold) { | 2732 if (fi->i_gc_failures[GC_FAILURE_PIN] > sbi->gc_pin_file_threshold) { |
2726 f2fs_msg(sbi->sb, KERN_WARNING, 2727 "%s: Enable GC = ino %lx after %x GC trials\n", | 2733 f2fs_msg(sbi->sb, KERN_WARNING, 2734 "%s: Enable GC = ino %lx after %x GC trials\n", |
2728 __func__, inode->i_ino, fi->i_gc_failures); | 2735 __func__, inode->i_ino, 2736 fi->i_gc_failures[GC_FAILURE_PIN]); |
2729 clear_inode_flag(inode, FI_PIN_FILE); 2730 return -EAGAIN; 2731 } 2732 return 0; 2733} 2734 2735static int f2fs_ioc_set_pin_file(struct file *filp, unsigned long arg) 2736{ --- 21 unchanged lines hidden (view full) --- 2758 2759 if (should_update_outplace(inode, NULL)) { 2760 ret = -EINVAL; 2761 goto out; 2762 } 2763 2764 if (!pin) { 2765 clear_inode_flag(inode, FI_PIN_FILE); | 2737 clear_inode_flag(inode, FI_PIN_FILE); 2738 return -EAGAIN; 2739 } 2740 return 0; 2741} 2742 2743static int f2fs_ioc_set_pin_file(struct file *filp, unsigned long arg) 2744{ --- 21 unchanged lines hidden (view full) --- 2766 2767 if (should_update_outplace(inode, NULL)) { 2768 ret = -EINVAL; 2769 goto out; 2770 } 2771 2772 if (!pin) { 2773 clear_inode_flag(inode, FI_PIN_FILE); |
2766 F2FS_I(inode)->i_gc_failures = 1; | 2774 F2FS_I(inode)->i_gc_failures[GC_FAILURE_PIN] = 1; |
2767 goto done; 2768 } 2769 2770 if (f2fs_pin_file_control(inode, false)) { 2771 ret = -EAGAIN; 2772 goto out; 2773 } 2774 ret = f2fs_convert_inline_inode(inode); 2775 if (ret) 2776 goto out; 2777 2778 set_inode_flag(inode, FI_PIN_FILE); | 2775 goto done; 2776 } 2777 2778 if (f2fs_pin_file_control(inode, false)) { 2779 ret = -EAGAIN; 2780 goto out; 2781 } 2782 ret = f2fs_convert_inline_inode(inode); 2783 if (ret) 2784 goto out; 2785 2786 set_inode_flag(inode, FI_PIN_FILE); |
2779 ret = F2FS_I(inode)->i_gc_failures; | 2787 ret = F2FS_I(inode)->i_gc_failures[GC_FAILURE_PIN]; |
2780done: 2781 f2fs_update_time(F2FS_I_SB(inode), REQ_TIME); 2782out: 2783 inode_unlock(inode); 2784 mnt_drop_write_file(filp); 2785 return ret; 2786} 2787 2788static int f2fs_ioc_get_pin_file(struct file *filp, unsigned long arg) 2789{ 2790 struct inode *inode = file_inode(filp); 2791 __u32 pin = 0; 2792 2793 if (is_inode_flag_set(inode, FI_PIN_FILE)) | 2788done: 2789 f2fs_update_time(F2FS_I_SB(inode), REQ_TIME); 2790out: 2791 inode_unlock(inode); 2792 mnt_drop_write_file(filp); 2793 return ret; 2794} 2795 2796static int f2fs_ioc_get_pin_file(struct file *filp, unsigned long arg) 2797{ 2798 struct inode *inode = file_inode(filp); 2799 __u32 pin = 0; 2800 2801 if (is_inode_flag_set(inode, FI_PIN_FILE)) |
2794 pin = F2FS_I(inode)->i_gc_failures; | 2802 pin = F2FS_I(inode)->i_gc_failures[GC_FAILURE_PIN]; |
2795 return put_user(pin, (u32 __user *)arg); 2796} 2797 2798int f2fs_precache_extents(struct inode *inode) 2799{ 2800 struct f2fs_inode_info *fi = F2FS_I(inode); 2801 struct f2fs_map_blocks map; 2802 pgoff_t m_next_extent; --- 219 unchanged lines hidden --- | 2803 return put_user(pin, (u32 __user *)arg); 2804} 2805 2806int f2fs_precache_extents(struct inode *inode) 2807{ 2808 struct f2fs_inode_info *fi = F2FS_I(inode); 2809 struct f2fs_map_blocks map; 2810 pgoff_t m_next_extent; --- 219 unchanged lines hidden --- |