From mboxrd@z Thu Jan 1 00:00:00 1970 From: Curt Wohlgemuth Subject: Re: [PATCH 6/8] vfs: Make sys_sync writeout also block device inodes Date: Wed, 20 Jun 2012 07:23:56 -0700 Message-ID: References: <1325807186-3397-1-git-send-email-jack@suse.cz> <1325807186-3397-7-git-send-email-jack@suse.cz> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: linux-fsdevel@vger.kernel.org, Christoph Hellwig , Al Viro To: Jan Kara Return-path: Received: from mail-qc0-f174.google.com ([209.85.216.174]:55972 "EHLO mail-qc0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753410Ab2FTOX5 convert rfc822-to-8bit (ORCPT ); Wed, 20 Jun 2012 10:23:57 -0400 Received: by qcro28 with SMTP id o28so4209873qcr.19 for ; Wed, 20 Jun 2012 07:23:56 -0700 (PDT) In-Reply-To: <1325807186-3397-7-git-send-email-jack@suse.cz> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Hi Jan: Was there ever a resolution for this patch and the series? I looked for but found no ack/nack for V4 of your "Cleanup and improve sync" patch series. We've been carrying a crappy hack/patch to sync all block device inodes in order to allow lilo to not break, and it'd be nice to have a real fix for it upstream. Thanks, Curt On Thu, Jan 5, 2012 at 3:46 PM, Jan Kara wrote: > In case block device does not have filesystem mounted on it, sys_sync= will just > ignore it and doesn't writeout its dirty pages. This is because write= back code > avoids writing inodes from superblock without backing device and > blockdev_superblock is such a superblock. =A0Since it's unexpected th= at sync > doesn't writeout dirty data for block devices be nice to users and ch= ange the > behavior to do so. So now we iterate over all block devices on blockd= ev_super > instead of iterating over all superblocks when syncing block devices. > > Reviewed-by: Christoph Hellwig > Signed-off-by: Jan Kara > --- > =A0fs/sync.c | =A0 58 +++++++++++++++++++++++++++++++++++++++++++++++= ++++------- > =A01 files changed, 51 insertions(+), 7 deletions(-) > > diff --git a/fs/sync.c b/fs/sync.c > index e62a57b..ccaaa1b 100644 > --- a/fs/sync.c > +++ b/fs/sync.c > @@ -86,10 +86,54 @@ static void sync_fs_one_sb(struct super_block *sb= , void *arg) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0sb->s_op->sync_fs(sb, *(int *)arg); > =A0} > > -static void sync_blkdev_one_sb(struct super_block *sb, void *arg) > +/* > + * We go through all existing block devices so that even devices wit= hout > + * filesystem mounted are synced. > + */ > +static void sync_all_bdevs(int wait) > =A0{ > - =A0 =A0 =A0 if (!(sb->s_flags & MS_RDONLY)) > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 __sync_blockdev(sb->s_bdev, *(int *)arg= ); > + =A0 =A0 =A0 struct inode *inode, *old_inode =3D NULL; > + > + =A0 =A0 =A0 spin_lock(&inode_sb_list_lock); > + =A0 =A0 =A0 list_for_each_entry(inode, &blockdev_superblock->s_inod= es, i_sb_list) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct address_space *mapping =3D inode= ->i_mapping; > + > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 spin_lock(&inode->i_lock); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (inode->i_state & (I_FREEING|I_WILL_= =46REE|I_NEW) || > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 mapping->nrpages =3D=3D 0) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 spin_unlock(&inode->i_l= ock); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 continue; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 __iget(inode); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 spin_unlock(&inode->i_lock); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 spin_unlock(&inode_sb_list_lock); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* We hold a reference to 'inode' so = it couldn't have been > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* removed from s_inodes list while w= e dropped the > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* inode_sb_list_lock. =A0We cannot i= put the inode now as we can > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* be holding the last reference and = we cannot iput it under > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* inode_sb_list_lock. So we keep the= reference and iput it > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* later. > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0*/ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 iput(old_inode); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 old_inode =3D inode; > + > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 __sync_blockdev(I_BDEV(inode), wait); > + > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 spin_lock(&inode_sb_list_lock); > + =A0 =A0 =A0 } > + =A0 =A0 =A0 spin_unlock(&inode_sb_list_lock); > + =A0 =A0 =A0 iput(old_inode); > +} > + > +static void flush_one_bdev(struct block_device *bdev, void *arg) > +{ > + =A0 =A0 =A0 __sync_blockdev(bdev, 0); > +} > + > +static void sync_one_bdev(struct block_device *bdev, void *arg) > +{ > + =A0 =A0 =A0 sync_blockdev(bdev); > =A0} > > =A0/* > @@ -103,10 +147,10 @@ SYSCALL_DEFINE0(sync) > =A0 =A0 =A0 =A0wakeup_flusher_threads(0, WB_REASON_SYNC); > =A0 =A0 =A0 =A0iterate_supers(writeback_inodes_one_sb, NULL); > =A0 =A0 =A0 =A0iterate_supers(sync_fs_one_sb, &nowait); > - =A0 =A0 =A0 iterate_supers(sync_blkdev_one_sb, &nowait); > + =A0 =A0 =A0 iterate_bdevs(flush_one_bdev, NULL); > =A0 =A0 =A0 =A0iterate_supers(sync_inodes_one_sb, NULL); > =A0 =A0 =A0 =A0iterate_supers(sync_fs_one_sb, &wait); > - =A0 =A0 =A0 iterate_supers(sync_blkdev_one_sb, &wait); > + =A0 =A0 =A0 iterate_bdevs(sync_one_bdev, NULL); > =A0 =A0 =A0 =A0if (unlikely(laptop_mode)) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0laptop_sync_completion(); > =A0 =A0 =A0 =A0return 0; > @@ -122,10 +166,10 @@ static void do_sync_work(struct work_struct *wo= rk) > =A0 =A0 =A0 =A0 */ > =A0 =A0 =A0 =A0iterate_supers(sync_inodes_one_sb, &nowait); > =A0 =A0 =A0 =A0iterate_supers(sync_fs_one_sb, &nowait); > - =A0 =A0 =A0 iterate_supers(sync_blkdev_one_sb, &nowait); > + =A0 =A0 =A0 sync_all_bdevs(nowait); > =A0 =A0 =A0 =A0iterate_supers(sync_inodes_one_sb, &nowait); > =A0 =A0 =A0 =A0iterate_supers(sync_fs_one_sb, &nowait); > - =A0 =A0 =A0 iterate_supers(sync_blkdev_one_sb, &nowait); > + =A0 =A0 =A0 sync_all_bdevs(nowait); > =A0 =A0 =A0 =A0printk("Emergency Sync complete\n"); > =A0 =A0 =A0 =A0kfree(work); > =A0} > -- > 1.7.1 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-fsdev= el" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at =A0http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel= " in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html