From: Greg Kroah-Hartman Date: Wed, 14 Feb 2018 14:25:00 +0000 (+0100) Subject: 3.18-stable patches X-Git-Tag: v4.15.4~40 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=07cf334bac16259e5643f6979c63bb3663a394de;p=thirdparty%2Fkernel%2Fstable-queue.git 3.18-stable patches added patches: kernfs-fix-regression-in-kernfs_fop_write-caused-by-wrong-type.patch mtd-nand-fix-nand_do_read_oob-return-value.patch nfs-add-a-cond_resched-to-nfs_commit_release_pages.patch nfs-commit-direct-writes-even-if-they-fail-partially.patch --- diff --git a/queue-3.18/kernfs-fix-regression-in-kernfs_fop_write-caused-by-wrong-type.patch b/queue-3.18/kernfs-fix-regression-in-kernfs_fop_write-caused-by-wrong-type.patch new file mode 100644 index 00000000000..da3d3dda6f6 --- /dev/null +++ b/queue-3.18/kernfs-fix-regression-in-kernfs_fop_write-caused-by-wrong-type.patch @@ -0,0 +1,43 @@ +From ba87977a49913129962af8ac35b0e13e0fa4382d Mon Sep 17 00:00:00 2001 +From: Ivan Vecera +Date: Fri, 19 Jan 2018 09:18:54 +0100 +Subject: kernfs: fix regression in kernfs_fop_write caused by wrong type + +From: Ivan Vecera + +commit ba87977a49913129962af8ac35b0e13e0fa4382d upstream. + +Commit b7ce40cff0b9 ("kernfs: cache atomic_write_len in +kernfs_open_file") changes type of local variable 'len' from ssize_t +to size_t. This change caused that the *ppos value is updated also +when the previous write callback failed. + +Mentioned snippet: +... +len = ops->write(...); <- return value can be negative +... +if (len > 0) <- true here in this case + *ppos += len; +... + +Fixes: b7ce40cff0b9 ("kernfs: cache atomic_write_len in kernfs_open_file") +Acked-by: Tejun Heo +Signed-off-by: Ivan Vecera +Signed-off-by: Al Viro +Signed-off-by: Greg Kroah-Hartman + +--- + fs/kernfs/file.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/fs/kernfs/file.c ++++ b/fs/kernfs/file.c +@@ -267,7 +267,7 @@ static ssize_t kernfs_fop_write(struct f + { + struct kernfs_open_file *of = kernfs_of(file); + const struct kernfs_ops *ops; +- size_t len; ++ ssize_t len; + char *buf; + + if (of->atomic_write_len) { diff --git a/queue-3.18/mtd-nand-fix-nand_do_read_oob-return-value.patch b/queue-3.18/mtd-nand-fix-nand_do_read_oob-return-value.patch new file mode 100644 index 00000000000..0b249c1aace --- /dev/null +++ b/queue-3.18/mtd-nand-fix-nand_do_read_oob-return-value.patch @@ -0,0 +1,59 @@ +From 87e89ce8d0d14f573c068c61bec2117751fb5103 Mon Sep 17 00:00:00 2001 +From: Miquel Raynal +Date: Fri, 12 Jan 2018 10:13:36 +0100 +Subject: mtd: nand: Fix nand_do_read_oob() return value + +From: Miquel Raynal + +commit 87e89ce8d0d14f573c068c61bec2117751fb5103 upstream. + +Starting from commit 041e4575f034 ("mtd: nand: handle ECC errors in +OOB"), nand_do_read_oob() (from the NAND core) did return 0 or a +negative error, and the MTD layer expected it. + +However, the trend for the NAND layer is now to return an error or a +positive number of bitflips. Deciding which status to return to the user +belongs to the MTD layer. + +Commit e47f68587b82 ("mtd: check for max_bitflips in mtd_read_oob()") +brought this logic to the mtd_read_oob() function while the return value +coming from nand_do_read_oob() (called by the ->_read_oob() hook) was +left unchanged. + +Fixes: e47f68587b82 ("mtd: check for max_bitflips in mtd_read_oob()") +Signed-off-by: Miquel Raynal +Signed-off-by: Boris Brezillon +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/mtd/nand/nand_base.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +--- a/drivers/mtd/nand/nand_base.c ++++ b/drivers/mtd/nand/nand_base.c +@@ -1872,6 +1872,7 @@ static int nand_write_oob_syndrome(struc + static int nand_do_read_oob(struct mtd_info *mtd, loff_t from, + struct mtd_oob_ops *ops) + { ++ unsigned int max_bitflips = 0; + int page, realpage, chipnr; + struct nand_chip *chip = mtd->priv; + struct mtd_ecc_stats stats; +@@ -1932,6 +1933,8 @@ static int nand_do_read_oob(struct mtd_i + nand_wait_ready(mtd); + } + ++ max_bitflips = max_t(unsigned int, max_bitflips, ret); ++ + readlen -= len; + if (!readlen) + break; +@@ -1957,7 +1960,7 @@ static int nand_do_read_oob(struct mtd_i + if (mtd->ecc_stats.failed - stats.failed) + return -EBADMSG; + +- return mtd->ecc_stats.corrected - stats.corrected ? -EUCLEAN : 0; ++ return max_bitflips; + } + + /** diff --git a/queue-3.18/nfs-add-a-cond_resched-to-nfs_commit_release_pages.patch b/queue-3.18/nfs-add-a-cond_resched-to-nfs_commit_release_pages.patch new file mode 100644 index 00000000000..244ac338bbe --- /dev/null +++ b/queue-3.18/nfs-add-a-cond_resched-to-nfs_commit_release_pages.patch @@ -0,0 +1,32 @@ +From 7f1bda447c9bd48b415acedba6b830f61591601f Mon Sep 17 00:00:00 2001 +From: Trond Myklebust +Date: Mon, 18 Dec 2017 14:39:13 -0500 +Subject: NFS: Add a cond_resched() to nfs_commit_release_pages() + +From: Trond Myklebust + +commit 7f1bda447c9bd48b415acedba6b830f61591601f upstream. + +The commit list can get very large, and so we need a cond_resched() +in nfs_commit_release_pages() in order to ensure we don't hog the CPU +for excessive periods of time. + +Reported-by: Mike Galbraith +Signed-off-by: Trond Myklebust +Signed-off-by: Greg Kroah-Hartman + +--- + fs/nfs/write.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/fs/nfs/write.c ++++ b/fs/nfs/write.c +@@ -1646,6 +1646,8 @@ static void nfs_commit_release_pages(str + set_bit(NFS_CONTEXT_RESEND_WRITES, &req->wb_context->flags); + next: + nfs_unlock_and_release_request(req); ++ /* Latency breaker */ ++ cond_resched(); + } + nfss = NFS_SERVER(data->inode); + if (atomic_long_read(&nfss->writeback) < NFS_CONGESTION_OFF_THRESH) diff --git a/queue-3.18/nfs-commit-direct-writes-even-if-they-fail-partially.patch b/queue-3.18/nfs-commit-direct-writes-even-if-they-fail-partially.patch new file mode 100644 index 00000000000..882aa398ccc --- /dev/null +++ b/queue-3.18/nfs-commit-direct-writes-even-if-they-fail-partially.patch @@ -0,0 +1,40 @@ +From 1b8d97b0a837beaf48a8449955b52c650a7114b4 Mon Sep 17 00:00:00 2001 +From: "J. Bruce Fields" +Date: Tue, 16 Jan 2018 10:08:00 -0500 +Subject: NFS: commit direct writes even if they fail partially + +From: J. Bruce Fields + +commit 1b8d97b0a837beaf48a8449955b52c650a7114b4 upstream. + +If some of the WRITE calls making up an O_DIRECT write syscall fail, +we neglect to commit, even if some of the WRITEs succeed. + +We also depend on the commit code to free the reference count on the +nfs_page taken in the "if (request_commit)" case at the end of +nfs_direct_write_completion(). The problem was originally noticed +because ENOSPC's encountered partway through a write would result in a +closed file being sillyrenamed when it should have been unlinked. + +Signed-off-by: J. Bruce Fields +Signed-off-by: Trond Myklebust +Signed-off-by: Greg Kroah-Hartman + +--- + fs/nfs/direct.c | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +--- a/fs/nfs/direct.c ++++ b/fs/nfs/direct.c +@@ -716,10 +716,8 @@ static void nfs_direct_write_completion( + + spin_lock(&dreq->lock); + +- if (test_bit(NFS_IOHDR_ERROR, &hdr->flags)) { +- dreq->flags = 0; ++ if (test_bit(NFS_IOHDR_ERROR, &hdr->flags)) + dreq->error = hdr->error; +- } + if (dreq->error == 0) { + dreq->count += hdr->good_bytes; + if (nfs_write_need_commit(hdr)) { diff --git a/queue-3.18/series b/queue-3.18/series index 4c60f07ed5e..7ffb7e321d2 100644 --- a/queue-3.18/series +++ b/queue-3.18/series @@ -24,3 +24,7 @@ usbip-vhci-stop-printing-kernel-pointer-addresses-in-messages.patch dccp-cve-2017-8824-use-after-free-in-dccp-code.patch media-dvb-usb-v2-lmedm04-improve-logic-checking-of-warm-start.patch media-dvb-usb-v2-lmedm04-move-ts2020-attach-to-dm04_lme2510_tuner.patch +mtd-nand-fix-nand_do_read_oob-return-value.patch +nfs-add-a-cond_resched-to-nfs_commit_release_pages.patch +nfs-commit-direct-writes-even-if-they-fail-partially.patch +kernfs-fix-regression-in-kernfs_fop_write-caused-by-wrong-type.patch