Centralize how we synchronize a lazytime update into the actual on-disk timestamp into a single helper.
Unified · Split
| @@ -1711,6 +1711,16 @@ static void requeue_inode(struct inode *inode, struct bdi_writeback *wb, · 1710 unmodified lines | |||
| 1711 | } | 1711 | } |
| 1712 | } | 1712 | } |
| 1713 | 1713 | ||
| 1714 | bool sync_lazytime(struct inode *inode) | ||
| 1715 | { | ||
| 1716 | if (!(inode_state_read_once(inode) & I_DIRTY_TIME)) | ||
| 1717 | return false; | ||
| 1718 | |||
| 1719 | trace_writeback_lazytime(inode); | ||
| 1720 | mark_inode_dirty_sync(inode); | ||
| 1721 | return true; | ||
| 1722 | } | ||
| 1723 | |||
| 1714 | /* | 1724 | /* |
| 1715 | * Write out an inode and its dirty pages (or some of its dirty pages, depending | 1725 | * Write out an inode and its dirty pages (or some of its dirty pages, depending |
| 1716 | * on @wbc->nr_to_write), and clear the relevant dirty flags from i_state. | 1726 | * on @wbc->nr_to_write), and clear the relevant dirty flags from i_state. |
| @@ -1750,17 +1760,15 @@ __writeback_single_inode(struct inode *inode, struct writeback_control *wbc) · 33 unmodified lines | |||
| 1750 | } | 1760 | } |
| 1751 | 1761 | ||
| 1752 | /* | 1762 | /* |
| 1753 | * If the inode has dirty timestamps and we need to write them, call | 1763 | * For data integrity writeback, or when the dirty interval expired, |
| 1754 | * mark_inode_dirty_sync() to notify the filesystem about it and to | 1764 | * ask the file system to propagata lazy timestamp updates into real |
| 1755 | * change I_DIRTY_TIME into I_DIRTY_SYNC. | 1765 | * dirty state. |
| 1756 | */ | 1766 | */ |
| 1757 | if ((inode_state_read_once(inode) & I_DIRTY_TIME) && | 1767 | if ((inode_state_read_once(inode) & I_DIRTY_TIME) && |
| 1758 | (wbc->sync_mode == WB_SYNC_ALL || | 1768 | (wbc->sync_mode == WB_SYNC_ALL || |
| 1759 | time_after(jiffies, inode->dirtied_time_when + | 1769 | time_after(jiffies, inode->dirtied_time_when + |
| 1760 | dirtytime_expire_interval * HZ))) { | 1770 | dirtytime_expire_interval * HZ))) |
| 1761 | trace_writeback_lazytime(inode); | 1771 | sync_lazytime(inode); |
| 1762 | mark_inode_dirty_sync(inode); | ||
| 1763 | } | ||
| 1764 | 1772 | ||
| 1765 | /* | 1773 | /* |
| 1766 | * Get and clear the dirty flags from i_state. This needs to be done | 1774 | * Get and clear the dirty flags from i_state. This needs to be done |
| @@ -1979,11 +1979,8 @@ retry: · 1978 unmodified lines | |||
| 1979 | if (atomic_add_unless(&inode->i_count, -1, 1)) | 1979 | if (atomic_add_unless(&inode->i_count, -1, 1)) |
| 1980 | return; | 1980 | return; |
| 1981 | 1981 | ||
| 1982 | if ((inode_state_read_once(inode) & I_DIRTY_TIME) && inode->i_nlink) { | 1982 | if (inode->i_nlink && sync_lazytime(inode)) |
| 1983 | trace_writeback_lazytime_iput(inode); | ||
| 1984 | mark_inode_dirty_sync(inode); | ||
| 1985 | goto retry; | 1983 | goto retry; |
| 1986 | } | ||
| 1987 | 1984 | ||
| 1988 | spin_lock(&inode->i_lock); | 1985 | spin_lock(&inode->i_lock); |
| 1989 | if (unlikely((inode_state_read(inode) & I_DIRTY_TIME) && inode->i_nlink)) { | 1986 | if (unlikely((inode_state_read(inode) & I_DIRTY_TIME) && inode->i_nlink)) { |
| @@ -214,7 +214,8 @@ bool in_group_or_capable(struct mnt_idmap *idmap, · 213 unmodified lines | |||
| 214 | /* | 214 | /* |
| 215 | * fs-writeback.c | 215 | * fs-writeback.c |
| 216 | */ | 216 | */ |
| 217 | extern long get_nr_dirty_inodes(void); | 217 | long get_nr_dirty_inodes(void); |
| 218 | bool sync_lazytime(struct inode *inode); | ||
| 218 | 219 | ||
| 219 | /* | 220 | /* |
| 220 | * dcache.c | 221 | * dcache.c |
| @@ -183,8 +183,8 @@ int vfs_fsync_range(struct file *file, loff_t start, loff_t end, int datasync) · 182 unmodified lines | |||
| 183 | 183 | ||
| 184 | if (!file->f_op->fsync) | 184 | if (!file->f_op->fsync) |
| 185 | return -EINVAL; | 185 | return -EINVAL; |
| 186 | if (!datasync && (inode_state_read_once(inode) & I_DIRTY_TIME)) | 186 | if (!datasync) |
| 187 | mark_inode_dirty_sync(inode); | 187 | sync_lazytime(inode); |
| 188 | return file->f_op->fsync(file, start, end, datasync); | 188 | return file->f_op->fsync(file, start, end, datasync); |
| 189 | } | 189 | } |
| 190 | EXPORT_SYMBOL(vfs_fsync_range); | 190 | EXPORT_SYMBOL(vfs_fsync_range); |
| @@ -856,12 +856,6 @@ DEFINE_EVENT(writeback_inode_template, writeback_lazytime, · 855 unmodified lines | |||
| 856 | TP_ARGS(inode) | 856 | TP_ARGS(inode) |
| 857 | ); | 857 | ); |
| 858 | 858 | ||
| 859 | DEFINE_EVENT(writeback_inode_template, writeback_lazytime_iput, | ||
| 860 | TP_PROTO(struct inode *inode), | ||
| 861 | |||
| 862 | TP_ARGS(inode) | ||
| 863 | ); | ||
| 864 | |||
| 865 | DEFINE_EVENT(writeback_inode_template, writeback_dirty_inode_enqueue, | 859 | DEFINE_EVENT(writeback_inode_template, writeback_dirty_inode_enqueue, |
| 866 | 860 | ||
| 867 | TP_PROTO(struct inode *inode), | 861 | TP_PROTO(struct inode *inode), |