* [PATCH 1/1] fs/affs/file.c: unlock/release page on error
@ 2015-03-20 3:19 Taesoo Kim
2015-03-20 21:13 ` Fabian Frederick
0 siblings, 1 reply; 5+ messages in thread
From: Taesoo Kim @ 2015-03-20 3:19 UTC (permalink / raw)
To: akpm, fabf, viro, geert, jack, linux-fsdevel, linux-kernel; +Cc: Taesoo Kim
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 <tsgatesv@gmail.com>
---
fs/affs/file.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/fs/affs/file.c b/fs/affs/file.c
index d2468bf..15d07a0 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;
+ }
tmp = min(bsize - boff, to - from);
BUG_ON(boff + tmp > bsize || tmp > bsize);
memcpy(AFFS_DATA(bh) + boff, data + from, tmp);
@@ -712,8 +714,10 @@ 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;
+ }
}
while (from + bsize <= to) {
prev_bh = bh;
@@ -790,6 +794,7 @@ done:
if (tmp > inode->i_size)
inode->i_size = AFFS_I(inode)->mmu_private = tmp;
+err:
unlock_page(page);
page_cache_release(page);
--
2.3.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] fs/affs/file.c: unlock/release page on error
2015-03-20 3:19 [PATCH 1/1] fs/affs/file.c: unlock/release page on error Taesoo Kim
@ 2015-03-20 21:13 ` Fabian Frederick
0 siblings, 0 replies; 5+ messages in thread
From: Fabian Frederick @ 2015-03-20 21:13 UTC (permalink / raw)
To: akpm, Taesoo Kim, linux-kernel, viro, jack, geert, linux-fsdevel
> On 20 March 2015 at 04:19 Taesoo Kim <tsgatesv@gmail.com> 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 <tsgatesv@gmail.com>
> ---
> fs/affs/file.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/fs/affs/file.c b/fs/affs/file.c
> index d2468bf..15d07a0 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;
> + }
> tmp = min(bsize - boff, to - from);
> BUG_ON(boff + tmp > bsize || tmp > bsize);
> memcpy(AFFS_DATA(bh) + boff, data + from, tmp);
> @@ -712,8 +714,10 @@ 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;
> + }
> }
> while (from + bsize <= to) {
> prev_bh = bh;
> @@ -790,6 +794,7 @@ done:
> if (tmp > inode->i_size)
> inode->i_size = AFFS_I(inode)->mmu_private = tmp;
>
> +err:
> unlock_page(page);
> page_cache_release(page);
>
> --
> 2.3.3
>
Patch looks good. Maybe you could use more explicit labels like
err_first_bh instead of err
err_bh instead of out
Regards,
Fabian
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/1] fs/affs/file.c: unlock/release page on error
@ 2015-03-21 17:31 Taesoo Kim
2015-03-21 19:51 ` Fabian Frederick
0 siblings, 1 reply; 5+ messages in thread
From: Taesoo Kim @ 2015-03-21 17:31 UTC (permalink / raw)
To: akpm, fabf, viro, geert, jack, linux-fsdevel, linux-kernel
Cc: taesoo, changwoo, sanidhya, blee, csong84, Taesoo Kim
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 <tsgatesv@gmail.com>
---
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] fs/affs/file.c: unlock/release page on error
2015-03-21 17:31 Taesoo Kim
@ 2015-03-21 19:51 ` Fabian Frederick
2015-03-21 20:05 ` Taesoo Kim
0 siblings, 1 reply; 5+ messages in thread
From: Fabian Frederick @ 2015-03-21 19:51 UTC (permalink / raw)
To: akpm, Taesoo Kim, linux-kernel, viro, jack, geert, linux-fsdevel
Cc: taesoo, csong84, blee, sanidhya, changwoo
> On 21 March 2015 at 18:31 Taesoo Kim <tsgatesv@gmail.com> 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 <tsgatesv@gmail.com>
> ---
> 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
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] fs/affs/file.c: unlock/release page on error
2015-03-21 19:51 ` Fabian Frederick
@ 2015-03-21 20:05 ` Taesoo Kim
0 siblings, 0 replies; 5+ messages in thread
From: Taesoo Kim @ 2015-03-21 20:05 UTC (permalink / raw)
To: Fabian Frederick
Cc: akpm, Taesoo Kim, linux-kernel, viro, jack, geert, linux-fsdevel,
csong84, blee, sanidhya, changwoo
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 <tsgatesv@gmail.com> 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 <tsgatesv@gmail.com>
> > ---
> > 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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-03-21 20:05 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-20 3:19 [PATCH 1/1] fs/affs/file.c: unlock/release page on error Taesoo Kim
2015-03-20 21:13 ` Fabian Frederick
-- strict thread matches above, loose matches on Subject: below --
2015-03-21 17:31 Taesoo Kim
2015-03-21 19:51 ` Fabian Frederick
2015-03-21 20:05 ` Taesoo Kim
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).