From patchwork Wed Jun 26 22:13:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 2789041 Return-Path: X-Original-To: patchwork-ocfs2-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 55158C0AB1 for ; Wed, 26 Jun 2013 22:14:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5B64520257 for ; Wed, 26 Jun 2013 22:14:42 +0000 (UTC) Received: from aserp1040.oracle.com (aserp1040.oracle.com [141.146.126.69]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 27D9420246 for ; Wed, 26 Jun 2013 22:14:41 +0000 (UTC) Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r5QME69X021632 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 26 Jun 2013 22:14:07 GMT Received: from oss.oracle.com (oss-external.oracle.com [137.254.96.51]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r5QME5ec023136 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 26 Jun 2013 22:14:05 GMT Received: from localhost ([127.0.0.1] helo=oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1UrxyX-00014e-2B; Wed, 26 Jun 2013 15:14:05 -0700 Received: from ucsinet22.oracle.com ([156.151.31.94]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1UrxyF-00014A-7D for ocfs2-devel@oss.oracle.com; Wed, 26 Jun 2013 15:13:47 -0700 Received: from userp1030.oracle.com (userp1030.oracle.com [156.151.31.80]) by ucsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r5QMDkXD000816 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 26 Jun 2013 22:13:46 GMT Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) by userp1030.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r5QMBEu7001498 for ; Wed, 26 Jun 2013 22:11:14 GMT Received: from akpm3.mtv.corp.google.com (unknown [216.239.45.95]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 76DAF85B; Wed, 26 Jun 2013 22:13:45 +0000 (UTC) Date: Wed, 26 Jun 2013 15:13:44 -0700 From: Andrew Morton To: Jeff Liu Message-Id: <20130626151344.dce1dd08ef614437d510c707@linux-foundation.org> In-Reply-To: <51C2933D.9030300@oracle.com> References: <51C2933D.9030300@oracle.com> X-Mailer: Sylpheed 3.2.0beta5 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 X-Flow-Control-Info: class=Pass-to-MM reputation=ipRisk-All ip=140.211.169.12 ct-class=T1 ct-vol1=0 ct-vol2=4 ct-vol3=4 ct-risk=10 ct-spam1=0 ct-spam2=0 ct-bulk=83 rcpts=1 size=4856 X-Sendmail-CM-Score: 0.00% X-Sendmail-CM-Analysis: v=2.1 cv=TK98FTVa c=1 sm=1 tr=0 a=5MPDoNpceV4HFXFrvkM3CQ==:117 a=5MPDoNpceV4HFXFrvkM3CQ==:17 a=YA7mm5pjgFoA:10 a=NEiEQogP1MkA:10 a=kj9zAlcOel0A:10 a=Z4Rwk6OoAAAA:8 a=1XWaLZrsAAAA:8 a=ag1SF4gXAAAA:8 a=1vSpLbYd51IA:10 a=yPCof4ZbAAAA:8 a=l3 a5OBCZd1UyBfmixCwA:9 a=CjuIK1q_8ugA:10 a=7DSvI1NPTFQA:10 X-Sendmail-CT-Classification: not spam X-Sendmail-CT-RefID: str=0001.0A090203.51CB679A.003F:SCFSTAT19734153, ss=1, re=-4.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 Cc: Ocfs2-Devel Subject: Re: [Ocfs2-devel] [PATCH v2] ocfs2: Rework transaction rollback in ocfs2_relink_block_group() X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ocfs2-devel-bounces@oss.oracle.com Errors-To: ocfs2-devel-bounces@oss.oracle.com X-Source-IP: acsinet21.oracle.com [141.146.126.237] X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Thu, 20 Jun 2013 13:29:33 +0800 Jeff Liu wrote: > From: Jie Liu > > In ocfs2_relink_block_group(), we roll back all those changes if > notify intent to modify buffers for metadata update failed even > if the relevant buffer has not yet been modified/got dirty at that > point, that are not quite right because of: > > - None buffer has been modified/dirty if failed to call > ocfs2_journal_access_gd() against the previous block group buffer > - Only the previous block group buffer has got dirty if failed to > call ocfs2_journal_access_gd() against the block group buffer > - There is no need to roll back the change for file entry buffer at all > > Those problems will not cause anything wrong but unnecessary. > This patch fix them and kill the useless bg_ptr variable as well. > > ... > > --- a/fs/ocfs2/suballoc.c > +++ b/fs/ocfs2/suballoc.c > @@ -1422,7 +1422,7 @@ static int ocfs2_relink_block_group(handle_t *handle, > int status; > /* there is a really tiny chance the journal calls could fail, > * but we wouldn't want inconsistent blocks in *any* case. */ > - u64 fe_ptr, bg_ptr, prev_bg_ptr; > + u64 bg_ptr, prev_bg_ptr; > struct ocfs2_dinode *fe = (struct ocfs2_dinode *) fe_bh->b_data; > struct ocfs2_group_desc *bg = (struct ocfs2_group_desc *) bg_bh->b_data; > struct ocfs2_group_desc *prev_bg = (struct ocfs2_group_desc *) prev_bg_bh->b_data; > @@ -1437,7 +1437,6 @@ static int ocfs2_relink_block_group(handle_t *handle, > (unsigned long long)le64_to_cpu(bg->bg_blkno), > (unsigned long long)le64_to_cpu(prev_bg->bg_blkno)); > > - fe_ptr = le64_to_cpu(fe->id2.i_chain.cl_recs[chain].c_blkno); > bg_ptr = le64_to_cpu(bg->bg_next_group); > prev_bg_ptr = le64_to_cpu(prev_bg->bg_next_group); > > @@ -1446,7 +1445,7 @@ static int ocfs2_relink_block_group(handle_t *handle, > OCFS2_JOURNAL_ACCESS_WRITE); > if (status < 0) { > mlog_errno(status); > - goto out_rollback; > + goto out; > } > > prev_bg->bg_next_group = bg->bg_next_group; > @@ -1456,7 +1455,7 @@ static int ocfs2_relink_block_group(handle_t *handle, > bg_bh, OCFS2_JOURNAL_ACCESS_WRITE); > if (status < 0) { > mlog_errno(status); > - goto out_rollback; > + goto out_rollback_prev_bg; > } > > bg->bg_next_group = fe->id2.i_chain.cl_recs[chain].c_blkno; > @@ -1466,21 +1465,21 @@ static int ocfs2_relink_block_group(handle_t *handle, > fe_bh, OCFS2_JOURNAL_ACCESS_WRITE); > if (status < 0) { > mlog_errno(status); > - goto out_rollback; > + goto out_rollback_bg; > } > > fe->id2.i_chain.cl_recs[chain].c_blkno = bg->bg_blkno; > ocfs2_journal_dirty(handle, fe_bh); > > -out_rollback: > - if (status < 0) { > - fe->id2.i_chain.cl_recs[chain].c_blkno = cpu_to_le64(fe_ptr); > - bg->bg_next_group = cpu_to_le64(bg_ptr); > - prev_bg->bg_next_group = cpu_to_le64(prev_bg_ptr); > - } > +out: > + return status; > > - if (status) > - mlog_errno(status); > +out_rollback_bg: > + bg->bg_next_group = cpu_to_le64(bg_ptr); > +out_rollback_prev_bg: > + prev_bg->bg_next_group = cpu_to_le64(prev_bg_ptr); > + > + mlog_errno(status); We already called mlog_errno() for this status in all cases. How does this look? btw, the ocfs2 source and executable cold be made about half the size if mlog_errno() were to immediately return if status>=0. --- a/fs/ocfs2/suballoc.c~ocfs2-rework-transaction-rollback-in-ocfs2_relink_block_group-fix +++ a/fs/ocfs2/suballoc.c @@ -1443,44 +1443,38 @@ static int ocfs2_relink_block_group(hand status = ocfs2_journal_access_gd(handle, INODE_CACHE(alloc_inode), prev_bg_bh, OCFS2_JOURNAL_ACCESS_WRITE); - if (status < 0) { - mlog_errno(status); + if (status < 0) goto out; - } prev_bg->bg_next_group = bg->bg_next_group; ocfs2_journal_dirty(handle, prev_bg_bh); status = ocfs2_journal_access_gd(handle, INODE_CACHE(alloc_inode), bg_bh, OCFS2_JOURNAL_ACCESS_WRITE); - if (status < 0) { - mlog_errno(status); + if (status < 0) goto out_rollback_prev_bg; - } bg->bg_next_group = fe->id2.i_chain.cl_recs[chain].c_blkno; ocfs2_journal_dirty(handle, bg_bh); status = ocfs2_journal_access_di(handle, INODE_CACHE(alloc_inode), fe_bh, OCFS2_JOURNAL_ACCESS_WRITE); - if (status < 0) { - mlog_errno(status); + if (status < 0) goto out_rollback_bg; - } fe->id2.i_chain.cl_recs[chain].c_blkno = bg->bg_blkno; ocfs2_journal_dirty(handle, fe_bh); out: + if (status < 0) + mlog_errno(status); return status; out_rollback_bg: bg->bg_next_group = cpu_to_le64(bg_ptr); out_rollback_prev_bg: prev_bg->bg_next_group = cpu_to_le64(prev_bg_ptr); - - mlog_errno(status); - return status; + goto out; }