* [PATCH] mtd:Fix issue where write_cached_data() fails but write() still returns success
@ 2020-03-20 3:15 Xiaoming Ni
2020-03-24 22:05 ` Miquel Raynal
2020-03-24 22:06 ` Miquel Raynal
0 siblings, 2 replies; 4+ messages in thread
From: Xiaoming Ni @ 2020-03-20 3:15 UTC (permalink / raw)
To: miquel.raynal, richard, vigneshr
Cc: linux-mtd, zhangweimin12, wangle6, nixiaoming, linux-kernel
mtdblock_flush()
-->write_cached_data()
--->erase_write()
mtdblock: erase of region [0x40000, 0x20000] on "xxx" failed
Because mtdblock_flush() always returns 0,
even if write_cached_data() fails and data is not written to the device,
syscall_write() still returns success
Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com>
---
drivers/mtd/mtdblock.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/mtd/mtdblock.c b/drivers/mtd/mtdblock.c
index c06b532..078e0f6 100644
--- a/drivers/mtd/mtdblock.c
+++ b/drivers/mtd/mtdblock.c
@@ -294,12 +294,13 @@ static void mtdblock_release(struct mtd_blktrans_dev *mbd)
static int mtdblock_flush(struct mtd_blktrans_dev *dev)
{
struct mtdblk_dev *mtdblk = container_of(dev, struct mtdblk_dev, mbd);
+ int ret;
mutex_lock(&mtdblk->cache_mutex);
- write_cached_data(mtdblk);
+ ret = write_cached_data(mtdblk);
mutex_unlock(&mtdblk->cache_mutex);
mtd_sync(dev->mtd);
- return 0;
+ return ret;
}
static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
--
1.8.5.6
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] mtd:Fix issue where write_cached_data() fails but write() still returns success
2020-03-20 3:15 [PATCH] mtd:Fix issue where write_cached_data() fails but write() still returns success Xiaoming Ni
@ 2020-03-24 22:05 ` Miquel Raynal
2020-03-24 22:06 ` Miquel Raynal
1 sibling, 0 replies; 4+ messages in thread
From: Miquel Raynal @ 2020-03-24 22:05 UTC (permalink / raw)
To: Xiaoming Ni, miquel.raynal, richard, vigneshr
Cc: zhangweimin12, linux-mtd, wangle6, linux-kernel
On Fri, 2020-03-20 at 03:15:11 UTC, Xiaoming Ni wrote:
> mtdblock_flush()
> -->write_cached_data()
> --->erase_write()
> mtdblock: erase of region [0x40000, 0x20000] on "xxx" failed
>
> Because mtdblock_flush() always returns 0,
> even if write_cached_data() fails and data is not written to the device,
> syscall_write() still returns success
>
> Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com>
Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.
Miquel
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mtd:Fix issue where write_cached_data() fails but write() still returns success
2020-03-20 3:15 [PATCH] mtd:Fix issue where write_cached_data() fails but write() still returns success Xiaoming Ni
2020-03-24 22:05 ` Miquel Raynal
@ 2020-03-24 22:06 ` Miquel Raynal
2020-03-25 7:53 ` Xiaoming Ni
1 sibling, 1 reply; 4+ messages in thread
From: Miquel Raynal @ 2020-03-24 22:06 UTC (permalink / raw)
To: Xiaoming Ni
Cc: zhangweimin12, vigneshr, richard, wangle6, linux-kernel, linux-mtd
Hi Xiaoming,
Xiaoming Ni <nixiaoming@huawei.com> wrote on Fri, 20 Mar 2020 11:15:11
+0800:
> mtdblock_flush()
> -->write_cached_data()
> --->erase_write()
> mtdblock: erase of region [0x40000, 0x20000] on "xxx" failed
>
> Because mtdblock_flush() always returns 0,
> even if write_cached_data() fails and data is not written to the device,
> syscall_write() still returns success
I reworded a bit the commit log and also added a ' ' after 'mtd:' in
the title when applying.
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mtd:Fix issue where write_cached_data() fails but write() still returns success
2020-03-24 22:06 ` Miquel Raynal
@ 2020-03-25 7:53 ` Xiaoming Ni
0 siblings, 0 replies; 4+ messages in thread
From: Xiaoming Ni @ 2020-03-25 7:53 UTC (permalink / raw)
To: Miquel Raynal
Cc: zhangweimin12, vigneshr, richard, wangle6, linux-kernel, linux-mtd
On 2020/3/25 6:06, Miquel Raynal wrote:
> Hi Xiaoming,
>
> Xiaoming Ni <nixiaoming@huawei.com> wrote on Fri, 20 Mar 2020 11:15:11
> +0800:
>
>> mtdblock_flush()
>> -->write_cached_data()
>> --->erase_write()
>> mtdblock: erase of region [0x40000, 0x20000] on "xxx" failed
>>
>> Because mtdblock_flush() always returns 0,
>> even if write_cached_data() fails and data is not written to the device,
>> syscall_write() still returns success
>
> I reworded a bit the commit log and also added a ' ' after 'mtd:' in
> the title when applying.
>
> Thanks,
> Miquèl
Your revised commit log is more accurate and clearer, thanks for your
correction
Thanks.
Xiaoming Ni
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-03-25 7:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-20 3:15 [PATCH] mtd:Fix issue where write_cached_data() fails but write() still returns success Xiaoming Ni
2020-03-24 22:05 ` Miquel Raynal
2020-03-24 22:06 ` Miquel Raynal
2020-03-25 7:53 ` Xiaoming Ni
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).