* [PATCH] affs: add kunmap in error path
@ 2016-02-02 1:55 Insu Yun
2016-02-02 2:24 ` Al Viro
0 siblings, 1 reply; 3+ messages in thread
From: Insu Yun @ 2016-02-02 1:55 UTC (permalink / raw)
To: akpm, viro, fabf, osandov, geert, tsgatesv, linux-fsdevel, linux-kernel
Cc: taesoo, yeongjin.jang, insu, changwoo, Insu Yun
When error occurs, it needs to unmap page.
Signed-off-by: Insu Yun <wuninsu@gmail.com>
---
fs/affs/file.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/fs/affs/file.c b/fs/affs/file.c
index 0548c53..fa4f24e 100644
--- a/fs/affs/file.c
+++ b/fs/affs/file.c
@@ -520,8 +520,10 @@ affs_do_readpage_ofs(struct page *page, unsigned to)
while (pos < to) {
bh = affs_bread_ino(inode, bidx, 0);
- if (IS_ERR(bh))
+ if (IS_ERR(bh)) {
+ kunmap(page);
return PTR_ERR(bh);
+ }
tmp = min(bsize - boff, to - pos);
BUG_ON(pos + tmp > to || tmp > bsize);
memcpy(data + pos, AFFS_DATA(bh) + boff, tmp);
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] affs: add kunmap in error path
2016-02-02 1:55 [PATCH] affs: add kunmap in error path Insu Yun
@ 2016-02-02 2:24 ` Al Viro
2016-02-02 2:28 ` Al Viro
0 siblings, 1 reply; 3+ messages in thread
From: Al Viro @ 2016-02-02 2:24 UTC (permalink / raw)
To: Insu Yun
Cc: akpm, fabf, osandov, geert, tsgatesv, linux-fsdevel,
linux-kernel, taesoo, yeongjin.jang, insu, changwoo
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] affs: add kunmap in error path
2016-02-02 2:24 ` Al Viro
@ 2016-02-02 2:28 ` Al Viro
0 siblings, 0 replies; 3+ messages in thread
From: Al Viro @ 2016-02-02 2:28 UTC (permalink / raw)
To: Insu Yun
Cc: akpm, fabf, osandov, geert, tsgatesv, linux-fsdevel,
linux-kernel, taesoo, yeongjin.jang, insu, changwoo
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;
}
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-02-02 2:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-02 1:55 [PATCH] affs: add kunmap in error path Insu Yun
2016-02-02 2:24 ` Al Viro
2016-02-02 2:28 ` Al Viro
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).