Re: [PATCH v3 06/10] writeback: introduce super_operations->write_metadata

Jan Kara
2017-12-19T12:21:10Z

On Mon 11-12-17 16:55:31, Josef Bacik wrote:
> @@ -1621,12 +1647,18 @@ static long writeback_sb_inodes(struct super_block *sb,
> * background threshold and other termination conditions.
> */
> if (wrote) {
> - if (time_is_before_jiffies(start_time + HZ / 10UL))
> - break;
> - if (work->nr_pages <= 0)
> + if (time_is_before_jiffies(start_time + HZ / 10UL) ||
> + work->nr_pages <= 0) {
> + done = true;
> break;
> + }
> }
> }
> + if (!done && sb->s_op->write_metadata) {
> + spin_unlock(&wb->list_lock);
> + wrote += writeback_sb_metadata(sb, wb, work);
> + spin_lock(&wb->list_lock);
> + }
> return wrote;
> }

One thing I've notice when looking at this patch again: This duplicates the
metadata writeback done in __writeback_inodes_wb(). So you probably need a
new helper function like writeback_sb() that will call writeback_sb_inodes()
and handle metadata writeback and call that from wb_writeback() instead of
writeback_sb_inodes() directly.

Honza

> @@ -1635,6 +1667,7 @@ static long __writeback_inodes_wb(struct bdi_writeback *wb,
> {
> unsigned long start_time = jiffies;
> long wrote = 0;
> + bool done = false;
>
> while (!list_empty(&wb->b_io)) {
> struct inode *inode = wb_inode(wb->b_io.prev);
> @@ -1654,12 +1687,39 @@ static long __writeback_inodes_wb(struct bdi_writeback *wb,
>
> /* refer to the same tests at the end of writeback_sb_inodes */
> if (wrote) {
> - if (time_is_before_jiffies(start_time + HZ / 10UL))
> - break;
> - if (work->nr_pages <= 0)
> + if (time_is_before_jiffies(start_time + HZ / 10UL) ||
> + work->nr_pages <= 0) {
> + done = true;
> break;
> + }
> }
> }
> +
> + if (!done && wb_stat(wb, WB_METADATA_DIRTY_BYTES)) {
> + LIST_HEAD(list);
> +
> + spin_unlock(&wb->list_lock);
> + spin_lock(&wb->bdi->sb_list_lock);
> + list_splice_init(&wb->bdi->dirty_sb_list, &list);
> + while (!list_empty(&list)) {
> + struct super_block *sb;
> +
> + sb = list_first_entry(&list, struct super_block,
> + s_bdi_dirty_list);
> + list_move_tail(&sb->s_bdi_dirty_list,
> + &wb->bdi->dirty_sb_list);
> + if (!sb->s_op->write_metadata)
> + continue;
> + if (!trylock_super(sb))
> + continue;
> + spin_unlock(&wb->bdi->sb_list_lock);
> + wrote += writeback_sb_metadata(sb, wb, work);
> + spin_lock(&wb->bdi->sb_list_lock);
> + up_read(&sb->s_umount);
> + }
> + spin_unlock(&wb->bdi->sb_list_lock);
> + spin_lock(&wb->list_lock);
> + }
> /* Leave any unwritten inodes on b_io */
> return wrote;
> }
--
Jan Kara <jack@suse.com>
SUSE Labs, CR