From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751795AbbCUUFL (ORCPT ); Sat, 21 Mar 2015 16:05:11 -0400 Received: from mail-qg0-f49.google.com ([209.85.192.49]:34622 "EHLO mail-qg0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751646AbbCUUFI (ORCPT ); Sat, 21 Mar 2015 16:05:08 -0400 Date: Sat, 21 Mar 2015 16:05:04 -0400 From: Taesoo Kim To: Fabian Frederick Cc: akpm@linux-foundation.org, Taesoo Kim , linux-kernel@vger.kernel.org, viro@zeniv.linux.org.uk, jack@suse.cz, geert@linux-m68k.org, linux-fsdevel@vger.kernel.org, csong84@gatech.edu, blee@gatech.edu, sanidhya@gatech.edu, changwoo@gatech.edu Subject: Re: [PATCH 1/1] fs/affs/file.c: unlock/release page on error Message-ID: <20150321200504.GB5170@taesoo.org> References: <1426959063-9329-1-git-send-email-tsgatesv@gmail.com> <2067582645.204975.1426967515410.open-xchange@webmail.nmp.proximus.be> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <2067582645.204975.1426967515410.open-xchange@webmail.nmp.proximus.be> User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thank you for letting us know. We will definitely do it for the next time. Thanks again for checking this out. Taesoo On 03/21/15 at 08:51pm, Fabian Frederick wrote: > > > > On 21 March 2015 at 18:31 Taesoo Kim wrote: > > > > > > When affs_bread_ino() fails, correctly unlock the page and > > release the page cache with proper error value. All write_end() > > should unlock/release the page that was locked by write_beg(). > > > > Signed-off-by: Taesoo Kim > > --- > >  fs/affs/file.c | 19 ++++++++++++------- > >  1 file changed, 12 insertions(+), 7 deletions(-) > > > > diff --git a/fs/affs/file.c b/fs/affs/file.c > > index d2468bf..a91795e 100644 > > --- a/fs/affs/file.c > > +++ b/fs/affs/file.c > > @@ -699,8 +699,10 @@ static int affs_write_end_ofs(struct file *file, struct > > address_space *mapping, > >       boff = tmp % bsize; > >       if (boff) { > >               bh = affs_bread_ino(inode, bidx, 0); > > -             if (IS_ERR(bh)) > > -                     return PTR_ERR(bh); > > +             if (IS_ERR(bh)) { > > +                     written = PTR_ERR(bh); > > +                     goto err_first_bh; > > +             } > >               tmp = min(bsize - boff, to - from); > >               BUG_ON(boff + tmp > bsize || tmp > bsize); > >               memcpy(AFFS_DATA(bh) + boff, data + from, tmp); > > @@ -712,14 +714,16 @@ static int affs_write_end_ofs(struct file *file, struct > > address_space *mapping, > >               bidx++; > >       } else if (bidx) { > >               bh = affs_bread_ino(inode, bidx - 1, 0); > > -             if (IS_ERR(bh)) > > -                     return PTR_ERR(bh); > > +             if (IS_ERR(bh)) { > > +                     written = PTR_ERR(bh); > > +                     goto err_first_bh; > > +             } > >       } > >       while (from + bsize <= to) { > >               prev_bh = bh; > >               bh = affs_getemptyblk_ino(inode, bidx); > >               if (IS_ERR(bh)) > > -                     goto out; > > +                     goto err_bh; > >               memcpy(AFFS_DATA(bh), data + from, bsize); > >               if (buffer_new(bh)) { > >                       AFFS_DATA_HEAD(bh)->ptype = cpu_to_be32(T_DATA); > > @@ -751,7 +755,7 @@ static int affs_write_end_ofs(struct file *file, struct > > address_space *mapping, > >               prev_bh = bh; > >               bh = affs_bread_ino(inode, bidx, 1); > >               if (IS_ERR(bh)) > > -                     goto out; > > +                     goto err_bh; > >               tmp = min(bsize, to - from); > >               BUG_ON(tmp > bsize); > >               memcpy(AFFS_DATA(bh), data + from, tmp); > > @@ -790,12 +794,13 @@ done: > >       if (tmp > inode->i_size) > >               inode->i_size = AFFS_I(inode)->mmu_private = tmp; > >  > > +err_first_bh: > >       unlock_page(page); > >       page_cache_release(page); > >  > >       return written; > >  > > -out: > > +err_bh: > >       bh = prev_bh; > >       if (!written) > >               written = PTR_ERR(bh); > > -- > > 2.3.3 > > > > Hi Taesoo, > >         Your patch is ok for me but we generally send a new message > for an update with the version in title and explain updates > done to it after ---. Here's an example of an AFFS V2 patch: >   > http://marc.info/?l=linux-kernel&m=142316316001752&w=2 > > Regards, > Fabian