X-Spam-Checker-Version: SpamAssassin 3.4.0-r929098 (2010-03-30) on oss.sgi.com X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=unavailable version=3.4.0-r929098 Received: from cuda.sgi.com (cuda1.sgi.com [192.48.157.11]) by oss.sgi.com (8.14.3/8.14.3/SuSE Linux 0.8) with ESMTP id q1H5cps9055447 for ; Thu, 16 Feb 2012 23:38:52 -0600 X-ASG-Debug-ID: 1329457128-04bdf002ce1f790001-7TOuyN Received: from mail-bk0-f53.google.com (mail-bk0-f53.google.com [209.85.214.53]) by cuda.sgi.com with ESMTP id dLHRVRUuCdcFmuwG (version=TLSv1 cipher=RC4-SHA bits=128 verify=NO); Thu, 16 Feb 2012 21:38:49 -0800 (PST) X-Barracuda-Envelope-From: linkinjeon@gmail.com X-Barracuda-Apparent-Source-IP: 209.85.214.53 Received: by bkcit16 with SMTP id it16so3040877bkc.26 for ; Thu, 16 Feb 2012 21:38:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=qdGLMu/h6UdTWfq14kTLvs8zPQ+2CS7QoFgBY4EuB5g=; b=jGH4OYhYkW0f2WLw5au88HKXlfC1NFZCK6S5pOmTkZFD+OtBUeraetq2K3yO/S/him Pv6JPEHQtLTlPCnZQTim1sSY9DpLH1vhgAbtFZx4QXyms+gkJZC0MpORiJO3ou0TBshP idlrWJP3qXaBxNyUVOj9qbwg43PpnlEDRp0ug= MIME-Version: 1.0 Received: by 10.204.128.143 with SMTP id k15mr3593403bks.101.1329457128171; Thu, 16 Feb 2012 21:38:48 -0800 (PST) Received: by 10.204.58.80 with HTTP; Thu, 16 Feb 2012 21:38:48 -0800 (PST) In-Reply-To: References: <1329306980-17997-1-git-send-email-amit.sahrawat83@gmail.com> Date: Fri, 17 Feb 2012 14:38:48 +0900 Message-ID: Subject: Re: [PATCH 1/1] xfs: fix buffer flushing during log unmount From: Namjae Jeon X-ASG-Orig-Subj: Re: [PATCH 1/1] xfs: fix buffer flushing during log unmount To: Dave Chinner , Christoph Hellwig Cc: Ben Myers , Alex Elder , xfs-masters@oss.sgi.com, xfs@oss.sgi.com, linux-kernel@vger.kernel.org, Amit Sahrawat Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Barracuda-Connect: mail-bk0-f53.google.com[209.85.214.53] X-Barracuda-Start-Time: 1329457129 X-Barracuda-Encrypted: RC4-SHA X-Barracuda-URL: http://192.48.157.11:80/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at sgi.com X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using per-user scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=1.3 tests=DKIM_SIGNED, DKIM_VERIFIED X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.2.88752 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- -0.00 DKIM_VERIFIED Domain Keys Identified Mail: signature passes verification 0.00 DKIM_SIGNED Domain Keys Identified Mail: message has a signature Hi. Dave, Christoph. Would you please review this patch ? Thanks. 2012/2/15 Amit Sahrawat : > Errror logs on 3.0.18 > Architecture: ARM > Just tried to mount a corrupted USB HDD - which resulted in the below > mentioned behaviour. > > #> mount -t xfs /dev/sdb3 /mnt/ > XFS (sdb3): Mounting Filesystem > XFS (sdb3): Starting recovery (logdev: internal) > e420d000: 3f b5 ce 5d 15 3b 64 e2 bb b4 f2 9b a0 97 f5 f4 =C2=A0?..].;d..= ....... > XFS (sdb3): Internal error xfs_btree_check_sblock at line 120 of file > fs/xfs/xfs_btree.c. =C2=A0Caller 0xc012c444 > > [] (unwind_backtrace+0x0/0xe4) from [] > (xfs_corruption_error+0x54/0x70) > [] (xfs_corruption_error+0x54/0x70) from [] > (xfs_btree_check_sblock+0xe4/0xf8) > [] (xfs_btree_check_sblock+0xe4/0xf8) from [] > (xfs_btree_read_buf_block+0x78/0x98) > [] (xfs_btree_read_buf_block+0x78/0x98) from [] > (xfs_btree_rshift+0xb0/0x508) > [] (xfs_btree_rshift+0xb0/0x508) from [] > (xfs_btree_make_block_unfull+0xbc/0x168) > [] (xfs_btree_make_block_unfull+0xbc/0x168) from > [] (xfs_btree_insrec+0x1e4/0x504) > [] (xfs_btree_insrec+0x1e4/0x504) from [] > (xfs_btree_insert+0x64/0x15c) > [] (xfs_btree_insert+0x64/0x15c) from [] > (xfs_free_ag_extent+0x478/0x5a8) > [] (xfs_free_ag_extent+0x478/0x5a8) from [] > (xfs_free_extent+0xcc/0x108) > [] (xfs_free_extent+0xcc/0x108) from [] > (xlog_recover_process_efi+0x168/0x1d4) > [] (xlog_recover_process_efi+0x168/0x1d4) from [] > (xlog_recover_process_efis+0x60/0xac) > [] (xlog_recover_process_efis+0x60/0xac) from [] > (xlog_recover_finish+0x18/0x90) > [] (xlog_recover_finish+0x18/0x90) from [] > (xfs_mountfs+0x4c8/0x5c4) > [] (xfs_mountfs+0x4c8/0x5c4) from [] > (xfs_fs_fill_super+0x150/0x244) > [] (xfs_fs_fill_super+0x150/0x244) from [] > (mount_bdev+0x120/0x19c) > [] (mount_bdev+0x120/0x19c) from [] (xfs_fs_mount+0x1= 0/0x18) > [] (xfs_fs_mount+0x10/0x18) from [] (mount_fs+0x10/0x= b8) > [] (mount_fs+0x10/0xb8) from [] (vfs_kern_mount+0x50/= 0x88) > [] (vfs_kern_mount+0x50/0x88) from [] > (do_kern_mount+0x34/0xc8) > [] (do_kern_mount+0x34/0xc8) from [] (do_mount+0x620/= 0x688) > [] (do_mount+0x620/0x688) from [] (sys_mount+0x84/0xc= 4) > [] (sys_mount+0x84/0xc4) from [] (ret_fast_syscall+0x= 0/0x30) > XFS (sdb3): Corruption detected. Unmount and run xfs_repair > XFS (sdb3): Internal error xfs_trans_cancel at line 1928 of file > fs/xfs/xfs_trans.c. =C2=A0Caller 0xc014d314 > > [] (unwind_backtrace+0x0/0xe4) from [] > (xfs_trans_cancel+0x70/0xfc) > [] (xfs_trans_cancel+0x70/0xfc) from [] > (xlog_recover_process_efi+0x1c8/0x1d4) > [] (xlog_recover_process_efi+0x1c8/0x1d4) from [] > (xlog_recover_process_efis+0x60/0xac) > [] (xlog_recover_process_efis+0x60/0xac) from [] > (xlog_recover_finish+0x18/0x90) > [] (xlog_recover_finish+0x18/0x90) from [] > (xfs_mountfs+0x4c8/0x5c4) > [] (xfs_mountfs+0x4c8/0x5c4) from [] > (xfs_fs_fill_super+0x150/0x244) > [] (xfs_fs_fill_super+0x150/0x244) from [] > (mount_bdev+0x120/0x19c) > [] (mount_bdev+0x120/0x19c) from [] (xfs_fs_mount+0x1= 0/0x18) > [] (xfs_fs_mount+0x10/0x18) from [] (mount_fs+0x10/0x= b8) > [] (mount_fs+0x10/0xb8) from [] (vfs_kern_mount+0x50/= 0x88) > [] (vfs_kern_mount+0x50/0x88) from [] > (do_kern_mount+0x34/0xc8) > [] (do_kern_mount+0x34/0xc8) from [] (do_mount+0x620/= 0x688) > [] (do_mount+0x620/0x688) from [] (sys_mount+0x84/0xc= 4) > [] (sys_mount+0x84/0xc4) from [] (ret_fast_syscall+0x= 0/0x30) > XFS (sdb3): xfs_do_force_shutdown(0x8) called from line 1929 of file > fs/xfs/xfs_trans.c. =C2=A0Return address =3D 0xc0156e48 > XFS (sdb3): Corruption of in-memory data detected. =C2=A0Shutting down fi= lesystem > XFS (sdb3): Please umount the filesystem and rectify the problem(s) > XFS (sdb3): Failed to recover EFIs > XFS (sdb3): log mount finish failed > Unable to handle kernel paging request at virtual address ffffffff > pgd =3D e80bc000 > [ffffffff] *pgd=3D68ffc821, *pte=3D00000000, *ppte=3D00000000 > Internal error: Oops: 17 [#1] PREEMPT SMP > Modules linked in: > CPU: 1 =C2=A0 =C2=A0Not tainted =C2=A0(3.0.18 #17) > PC is at strnlen+0x10/0x28 > LR is at string+0x34/0xcc > pc : [] =C2=A0 =C2=A0lr : [] =C2=A0 =C2=A0psr: a00000= 93 > sp : e424fca0 =C2=A0ip : 00000000 =C2=A0fp : 00000400 > r10: e424fd8c =C2=A0r9 : 00000002 =C2=A0r8 : ffffffff > r7 : 00000000 =C2=A0r6 : 0000ffff =C2=A0r5 : c03abca8 =C2=A0r4 : c03ab8b0 > r3 : 00000000 =C2=A0r2 : ffffffff =C2=A0r1 : ffffffff =C2=A0r0 : ffffffff > Flags: NzCv =C2=A0IRQs off =C2=A0FIQs on =C2=A0Mode SVC_32 =C2=A0ISA ARM = =C2=A0Segment user > Control: 10c53c7d =C2=A0Table: 680bc04a =C2=A0DAC: 00000015 > Process mount (pid: 656, stack limit =3D 0xe424e2f0) > Stack: (0xe424fca0 to 0xe4250000) > ... > ... > ffe0: 00000000 be88470c 000436dc 00009604 a0000010 be884b4f 45d65600 0400= 0000 > [] (strnlen+0x10/0x28) from [] (string+0x34/0xcc) > [] (string+0x34/0xcc) from [] (vsnprintf+0x1bc/0x344) > [] (vsnprintf+0x1bc/0x344) from [] (vscnprintf+0xc/0x= 24) > [] (vscnprintf+0xc/0x24) from [] (vprintk+0x14c/0x3fc= ) > [] (vprintk+0x14c/0x3fc) from [] (printk+0x18/0x24) > [] (printk+0x18/0x24) from [] (xfs_alert_tag+0x64/0x9= 8) > [] (xfs_alert_tag+0x64/0x98) from [] > (xfs_trans_ail_delete_bulk+0x74/0x118) > [] (xfs_trans_ail_delete_bulk+0x74/0x118) from [] > (xfs_buf_iodone+0x2c/0x38) > [] (xfs_buf_iodone+0x2c/0x38) from [] > (xfs_buf_do_callbacks+0x28/0x38) > [] (xfs_buf_do_callbacks+0x28/0x38) from [] > (xfs_buf_iodone_callbacks+0x13c/0x164) > [] (xfs_buf_iodone_callbacks+0x13c/0x164) from [] > (xfs_buf_iodone_work+0x1c/0x40) > [] (xfs_buf_iodone_work+0x1c/0x40) from [] > (xfs_bioerror+0x44/0x4c) > [] (xfs_bioerror+0x44/0x4c) from [] > (xfs_flush_buftarg+0xcc/0x148) > [] (xfs_flush_buftarg+0xcc/0x148) from [] > (xfs_free_buftarg+0x20/0x5c) > [] (xfs_free_buftarg+0x20/0x5c) from [] > (xfs_fs_fill_super+0x1cc/0x244) > [] (xfs_fs_fill_super+0x1cc/0x244) from [] > (mount_bdev+0x120/0x19c) > [] (mount_bdev+0x120/0x19c) from [] (xfs_fs_mount+0x1= 0/0x18) > [] (xfs_fs_mount+0x10/0x18) from [] (mount_fs+0x10/0x= b8) > [] (mount_fs+0x10/0xb8) from [] (vfs_kern_mount+0x50/= 0x88) > [] (vfs_kern_mount+0x50/0x88) from [] > (do_kern_mount+0x34/0xc8) > [] (do_kern_mount+0x34/0xc8) from [] (do_mount+0x620/= 0x688) > [] (do_mount+0x620/0x688) from [] (sys_mount+0x84/0xc= 4) > [] (sys_mount+0x84/0xc4) from [] (ret_fast_syscall+0x= 0/0x30) > Code: e3a03000 e1510003 e0832000 0a000003 (e7d0c003) > ---[ end trace 9fae26d925820746 ]--- > note: mount[656] exited with preempt_count 2 > Segmentation fault > #> > #> > > Regards, > Amit Sahrawat > > On Wed, Feb 15, 2012 at 5:26 PM, Amit Sahrawat > wrote: >> Whenever there is a mount/unmount failure - there is a chance of calling= the >> callbacks functions once - transaction ail mount pointer is destroyed. S= o, it results >> in NULL pointer exception followed by hang. So, before unmount of the lo= g - flush all >> the pending buffers. >> >> Signed-off-by: Amit Sahrawat >> Signed-off-by: Namjae Jeon >> --- >> =C2=A0fs/xfs/xfs_log.c =C2=A0 | =C2=A0 10 ++++++++++ >> =C2=A0fs/xfs/xfs_mount.c | =C2=A0 =C2=A09 --------- >> =C2=A02 files changed, 10 insertions(+), 9 deletions(-) >> >> diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c >> index e2cc356..b924a5b 100644 >> --- a/fs/xfs/xfs_log.c >> +++ b/fs/xfs/xfs_log.c >> @@ -739,6 +739,16 @@ xfs_log_unmount_write(xfs_mount_t *mp) >> =C2=A0void >> =C2=A0xfs_log_unmount(xfs_mount_t *mp) >> =C2=A0{ >> + =C2=A0 =C2=A0 =C2=A0 int error =3D 0; >> + =C2=A0 =C2=A0 =C2=A0 /* >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0* Make sure all buffers have been flushed a= nd completed before >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0* unmounting the log. >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0*/ >> + =C2=A0 =C2=A0 =C2=A0 error =3D xfs_flush_buftarg(mp->m_ddev_targp, 1); >> + =C2=A0 =C2=A0 =C2=A0 if (error) >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 cmn_err(CE_WARN, "%d = busy buffers during log unmount.", error); >> + =C2=A0 =C2=A0 =C2=A0 xfs_wait_buftarg(mp->m_ddev_targp); >> + >> =C2=A0 =C2=A0 =C2=A0 =C2=A0xfs_trans_ail_destroy(mp); >> =C2=A0 =C2=A0 =C2=A0 =C2=A0xlog_dealloc_log(mp->m_log); >> =C2=A0} >> diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c >> index d06afbc..3bd2246 100644 >> --- a/fs/xfs/xfs_mount.c >> +++ b/fs/xfs/xfs_mount.c >> @@ -1519,15 +1519,6 @@ xfs_unmountfs( >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"Freespace may not be correct on n= ext mount."); >> =C2=A0 =C2=A0 =C2=A0 =C2=A0xfs_unmountfs_writesb(mp); >> >> - =C2=A0 =C2=A0 =C2=A0 /* >> - =C2=A0 =C2=A0 =C2=A0 =C2=A0* Make sure all buffers have been flushed a= nd completed before >> - =C2=A0 =C2=A0 =C2=A0 =C2=A0* unmounting the log. >> - =C2=A0 =C2=A0 =C2=A0 =C2=A0*/ >> - =C2=A0 =C2=A0 =C2=A0 error =3D xfs_flush_buftarg(mp->m_ddev_targp, 1); >> - =C2=A0 =C2=A0 =C2=A0 if (error) >> - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 xfs_warn(mp, "%d busy= buffers during unmount.", error); >> - =C2=A0 =C2=A0 =C2=A0 xfs_wait_buftarg(mp->m_ddev_targp); >> - >> =C2=A0 =C2=A0 =C2=A0 =C2=A0xfs_log_unmount_write(mp); >> =C2=A0 =C2=A0 =C2=A0 =C2=A0xfs_log_unmount(mp); >> =C2=A0 =C2=A0 =C2=A0 =C2=A0xfs_uuid_unmount(mp); >> -- >> 1.7.2.3 >>