From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Tue, 2 Feb 2016 02:28:05 +0000 From: Al Viro To: Insu Yun Cc: akpm@linux-foundation.org, fabf@skynet.be, osandov@osandov.com, geert@linux-m68k.org, tsgatesv@gmail.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, taesoo@gatech.edu, yeongjin.jang@gatech.edu, insu@gatech.edu, changwoo@gatech.edu Subject: Re: [PATCH] affs: add kunmap in error path Message-ID: <20160202022805.GN17997@ZenIV.linux.org.uk> References: <1454378117-14999-1-git-send-email-wuninsu@gmail.com> <20160202022436.GM17997@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160202022436.GM17997@ZenIV.linux.org.uk> Sender: linux-kernel-owner@vger.kernel.org List-ID: On Tue, Feb 02, 2016 at 02:24:36AM +0000, Al Viro wrote: > On Mon, Feb 01, 2016 at 08:55:17PM -0500, Insu Yun wrote: > > When error occurs, it needs to unmap page. > > Point, but... I'm not sure there's any point in keeping it mapped all > along. After all, what we are doing is a bunch of memcpy() into the > parts of page, so kmap_atomic()/kunmap_atomic() just around memcpy > would do just fine. IOW, something like this (completely untested): diff --git a/fs/affs/file.c b/fs/affs/file.c index 0548c53..22fc7c8 100644 --- a/fs/affs/file.c +++ b/fs/affs/file.c @@ -511,8 +511,6 @@ affs_do_readpage_ofs(struct page *page, unsigned to) pr_debug("%s(%lu, %ld, 0, %d)\n", __func__, inode->i_ino, page->index, to); BUG_ON(to > PAGE_CACHE_SIZE); - kmap(page); - data = page_address(page); bsize = AFFS_SB(sb)->s_data_blksize; tmp = page->index << PAGE_CACHE_SHIFT; bidx = tmp / bsize; @@ -524,14 +522,15 @@ affs_do_readpage_ofs(struct page *page, unsigned to) return PTR_ERR(bh); tmp = min(bsize - boff, to - pos); BUG_ON(pos + tmp > to || tmp > bsize); + data = kmap_atomic(page); memcpy(data + pos, AFFS_DATA(bh) + boff, tmp); + kunmap_atomic(data); affs_brelse(bh); bidx++; pos += tmp; boff = 0; } flush_dcache_page(page); - kunmap(page); return 0; }