From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Tue, 19 Dec 2017 13:21:04 +0100 From: Jan Kara To: Josef Bacik Cc: hannes@cmpxchg.org, linux-mm@kvack.org, akpm@linux-foundation.org, jack@suse.cz, linux-fsdevel@vger.kernel.org, kernel-team@fb.com, linux-btrfs@vger.kernel.org, Josef Bacik Subject: Re: [PATCH v3 06/10] writeback: introduce super_operations->write_metadata Message-ID: <20171219122104.GF2277@quack2.suse.cz> References: <1513029335-5112-1-git-send-email-josef@toxicpanda.com> <1513029335-5112-7-git-send-email-josef@toxicpanda.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1513029335-5112-7-git-send-email-josef@toxicpanda.com> Sender: owner-linux-mm@kvack.org List-ID: 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 SUSE Labs, CR -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org