Kernel
Threads by month
- ----- 2025 -----
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
March 2022
- 18 participants
- 67 discussions

09 Mar '22
From: "Darrick J. Wong" <darrick.wong(a)oracle.com>
mainline inclusion
from mainline-v5.11-rc4
commit 6da1b4b1ab36d80a3994fd4811c8381de10af604
category: bugfix
bugzilla: 185867 https://gitee.com/openeuler/kernel/issues/I4KIAO
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?…
--------------------------------
When overlayfs is running on top of xfs and the user unlinks a file in
the overlay, overlayfs will create a whiteout inode and ask xfs to
"rename" the whiteout file atop the one being unlinked. If the file
being unlinked loses its one nlink, we then have to put the inode on the
unlinked list.
This requires us to grab the AGI buffer of the whiteout inode to take it
off the unlinked list (which is where whiteouts are created) and to grab
the AGI buffer of the file being deleted. If the whiteout was created
in a higher numbered AG than the file being deleted, we'll lock the AGIs
in the wrong order and deadlock.
Therefore, grab all the AGI locks we think we'll need ahead of time, and
in order of increasing AG number per the locking rules.
Reported-by: wenli xie <wlxie7296(a)gmail.com>
Fixes: 93597ae8dac0 ("xfs: Fix deadlock between AGI and AGF when target_ip exists in xfs_rename()")
Signed-off-by: Darrick J. Wong <darrick.wong(a)oracle.com>
Reviewed-by: Brian Foster <bfoster(a)redhat.com>
Signed-off-by: Guo Xuenan <guoxuenan(a)huawei.com>
Reviewed-by: Lihong Kou <koulihong(a)huawei.com>
Signed-off-by: Zheng Zengkai <zhengzengkai(a)huawei.com>
---
fs/xfs/libxfs/xfs_dir2.h | 2 --
fs/xfs/libxfs/xfs_dir2_sf.c | 2 +-
fs/xfs/xfs_inode.c | 42 ++++++++++++++++++++++---------------
3 files changed, 26 insertions(+), 20 deletions(-)
diff --git a/fs/xfs/libxfs/xfs_dir2.h b/fs/xfs/libxfs/xfs_dir2.h
index e55378640b05..d03e6098ded9 100644
--- a/fs/xfs/libxfs/xfs_dir2.h
+++ b/fs/xfs/libxfs/xfs_dir2.h
@@ -47,8 +47,6 @@ extern int xfs_dir_lookup(struct xfs_trans *tp, struct xfs_inode *dp,
extern int xfs_dir_removename(struct xfs_trans *tp, struct xfs_inode *dp,
struct xfs_name *name, xfs_ino_t ino,
xfs_extlen_t tot);
-extern bool xfs_dir2_sf_replace_needblock(struct xfs_inode *dp,
- xfs_ino_t inum);
extern int xfs_dir_replace(struct xfs_trans *tp, struct xfs_inode *dp,
struct xfs_name *name, xfs_ino_t inum,
xfs_extlen_t tot);
diff --git a/fs/xfs/libxfs/xfs_dir2_sf.c b/fs/xfs/libxfs/xfs_dir2_sf.c
index 2463b5d73447..8c4f76bba88b 100644
--- a/fs/xfs/libxfs/xfs_dir2_sf.c
+++ b/fs/xfs/libxfs/xfs_dir2_sf.c
@@ -1018,7 +1018,7 @@ xfs_dir2_sf_removename(
/*
* Check whether the sf dir replace operation need more blocks.
*/
-bool
+static bool
xfs_dir2_sf_replace_needblock(
struct xfs_inode *dp,
xfs_ino_t inum)
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index af54224ebbe7..b72dd3f67ca7 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -3212,7 +3212,7 @@ xfs_rename(
struct xfs_trans *tp;
struct xfs_inode *wip = NULL; /* whiteout inode */
struct xfs_inode *inodes[__XFS_SORT_INODES];
- struct xfs_buf *agibp;
+ int i;
int num_inodes = __XFS_SORT_INODES;
bool new_parent = (src_dp != target_dp);
bool src_is_directory = S_ISDIR(VFS_I(src_ip)->i_mode);
@@ -3325,6 +3325,30 @@ xfs_rename(
}
}
+ /*
+ * Lock the AGI buffers we need to handle bumping the nlink of the
+ * whiteout inode off the unlinked list and to handle dropping the
+ * nlink of the target inode. Per locking order rules, do this in
+ * increasing AG order and before directory block allocation tries to
+ * grab AGFs because we grab AGIs before AGFs.
+ *
+ * The (vfs) caller must ensure that if src is a directory then
+ * target_ip is either null or an empty directory.
+ */
+ for (i = 0; i < num_inodes && inodes[i] != NULL; i++) {
+ if (inodes[i] == wip ||
+ (inodes[i] == target_ip &&
+ (VFS_I(target_ip)->i_nlink == 1 || src_is_directory))) {
+ struct xfs_buf *bp;
+ xfs_agnumber_t agno;
+
+ agno = XFS_INO_TO_AGNO(mp, inodes[i]->i_ino);
+ error = xfs_read_agi(mp, tp, agno, &bp);
+ if (error)
+ goto out_trans_cancel;
+ }
+ }
+
/*
* Directory entry creation below may acquire the AGF. Remove
* the whiteout from the unlinked list first to preserve correct
@@ -3377,22 +3401,6 @@ xfs_rename(
* In case there is already an entry with the same
* name at the destination directory, remove it first.
*/
-
- /*
- * Check whether the replace operation will need to allocate
- * blocks. This happens when the shortform directory lacks
- * space and we have to convert it to a block format directory.
- * When more blocks are necessary, we must lock the AGI first
- * to preserve locking order (AGI -> AGF).
- */
- if (xfs_dir2_sf_replace_needblock(target_dp, src_ip->i_ino)) {
- error = xfs_read_agi(mp, tp,
- XFS_INO_TO_AGNO(mp, target_ip->i_ino),
- &agibp);
- if (error)
- goto out_trans_cancel;
- }
-
error = xfs_dir_replace(tp, target_dp, target_name,
src_ip->i_ino, spaceres);
if (error)
--
2.20.1
1
27

[PATCH openEuler-1.0-LTS 1/3] block: add a switch for precise iostat accounting
by Yang Yingliang 09 Mar '22
by Yang Yingliang 09 Mar '22
09 Mar '22
From: Zhang Wensheng <zhangwensheng5(a)huawei.com>
hulk inclusion
category: bugfix
bugzilla: 39265, https://gitee.com/openeuler/kernel/issues/I4WC06
CVE: NA
-----------------------------------------------
When the inflight IOs are slow and no new IOs are issued, we expect
iostat could manifest the IO hang problem. However after
commit 9c6dea45e6f7 ("block: delete part_round_stats and switch to less
precise counting"), io_tick and time_in_queue will not be updated until
the end of IO, and the avgqu-sz and %util columns of iostat will be zero.
To fix it, we could fallback to the implementation before commit
9c6dea45e6f7, but it may cause performance regression on NVMe device
or bio-based device (due to overhead of inflight calculation),
so add a switch to control whether or not to use precise iostat
accounting. It can be enabled by adding "precise_iostat=1" in kernel
boot cmdline. When precise accouting is enabled, io_tick and time_in_queue
will be updated when accessing /proc/diskstats and
/sys/block/sdX/sdXN/stat.
Fixes: 9c6dea45e6f7 ("block: delete part_round_stats and switch to less precise counting")
Signed-off-by: Zhang Wensheng <zhangwensheng5(a)huawei.com>
Reviewed-by: Jason Yan <yanaijie(a)huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang(a)huawei.com>
---
block/bio.c | 8 ++++++--
block/blk-core.c | 30 +++++++++++++++++++++++++++---
block/blk-merge.c | 2 ++
block/genhd.c | 7 +++++++
block/partition-generic.c | 8 ++++++++
include/linux/blkdev.h | 1 +
6 files changed, 51 insertions(+), 5 deletions(-)
diff --git a/block/bio.c b/block/bio.c
index d94243411ef30..b50d3b59c79b4 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1706,9 +1706,13 @@ void generic_end_io_acct(struct request_queue *q, int req_op,
const int sgrp = op_stat_group(req_op);
int cpu = part_stat_lock();
- update_io_ticks(cpu, part, now);
+ if (precise_iostat) {
+ part_round_stats(q, cpu, part);
+ } else {
+ update_io_ticks(cpu, part, now);
+ part_stat_add(cpu, part, time_in_queue, duration);
+ }
part_stat_add(cpu, part, nsecs[sgrp], jiffies_to_nsecs(duration));
- part_stat_add(cpu, part, time_in_queue, duration);
part_dec_in_flight(q, part, op_is_write(req_op));
part_stat_unlock();
diff --git a/block/blk-core.c b/block/blk-core.c
index 41d0b09e9a673..df733e8caa6a1 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -56,6 +56,20 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(block_unplug);
DEFINE_IDA(blk_queue_ida);
+bool precise_iostat;
+static int __init precise_iostat_setup(char *str)
+{
+ bool precise;
+
+ if (!strtobool(str, &precise)) {
+ precise_iostat = precise;
+ pr_info("precise iostat %d\n", precise_iostat);
+ }
+
+ return 1;
+}
+__setup("precise_iostat=", precise_iostat_setup);
+
/*
* For the allocated request tables
*/
@@ -1700,8 +1714,13 @@ static void part_round_stats_single(struct request_queue *q, int cpu,
struct hd_struct *part, unsigned long now,
unsigned int inflight)
{
- if (inflight)
+ if (inflight) {
+ if (precise_iostat) {
+ __part_stat_add(cpu, part, time_in_queue,
+ inflight * (now - part->stamp));
+ }
__part_stat_add(cpu, part, io_ticks, (now - part->stamp));
+ }
part->stamp = now;
}
@@ -2771,10 +2790,15 @@ void blk_account_io_done(struct request *req, u64 now)
cpu = part_stat_lock();
part = req->part;
- update_io_ticks(cpu, part, jiffies);
+ if (!precise_iostat) {
+ update_io_ticks(cpu, part, jiffies);
+ part_stat_add(cpu, part, time_in_queue,
+ nsecs_to_jiffies64(now - req->start_time_ns));
+ } else {
+ part_round_stats(req->q, cpu, part);
+ }
part_stat_inc(cpu, part, ios[sgrp]);
part_stat_add(cpu, part, nsecs[sgrp], now - req->start_time_ns);
- part_stat_add(cpu, part, time_in_queue, nsecs_to_jiffies64(now - req->start_time_ns));
part_dec_in_flight(req->q, part, rq_data_dir(req));
hd_struct_put(part);
diff --git a/block/blk-merge.c b/block/blk-merge.c
index 4c17c1031e34f..d2fabe1fdf326 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -669,6 +669,8 @@ static void blk_account_io_merge(struct request *req)
cpu = part_stat_lock();
part = req->part;
+ if (precise_iostat)
+ part_round_stats(req->q, cpu, part);
part_dec_in_flight(req->q, part, rq_data_dir(req));
hd_struct_put(part);
diff --git a/block/genhd.c b/block/genhd.c
index 183612cbbd6b7..e7b97fdb41731 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -1352,6 +1352,7 @@ static int diskstats_show(struct seq_file *seqf, void *v)
struct hd_struct *hd;
char buf[BDEVNAME_SIZE];
unsigned int inflight[2];
+ int cpu;
/*
if (&disk_to_dev(gp)->kobj.entry == block_class.devices.next)
@@ -1363,6 +1364,12 @@ static int diskstats_show(struct seq_file *seqf, void *v)
disk_part_iter_init(&piter, gp, DISK_PITER_INCL_EMPTY_PART0);
while ((hd = disk_part_iter_next(&piter))) {
+ if (precise_iostat) {
+ cpu = part_stat_lock();
+ part_round_stats(gp->queue, cpu, hd);
+ part_stat_unlock();
+ }
+
part_in_flight(gp->queue, hd, inflight);
seq_printf(seqf, "%4d %7d %s "
"%lu %lu %lu %u "
diff --git a/block/partition-generic.c b/block/partition-generic.c
index 739c0cc5fd222..c4ac7a8c77dc5 100644
--- a/block/partition-generic.c
+++ b/block/partition-generic.c
@@ -18,6 +18,7 @@
#include <linux/ctype.h>
#include <linux/genhd.h>
#include <linux/blktrace_api.h>
+#include <linux/blkdev.h>
#include "partitions/check.h"
@@ -121,6 +122,13 @@ ssize_t part_stat_show(struct device *dev,
struct hd_struct *p = dev_to_part(dev);
struct request_queue *q = part_to_disk(p)->queue;
unsigned int inflight[2];
+ int cpu;
+
+ if (precise_iostat) {
+ cpu = part_stat_lock();
+ part_round_stats(q, cpu, p);
+ part_stat_unlock();
+ }
part_in_flight(q, p, inflight);
return sprintf(buf,
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 28ea02865ecc1..a86659e78d987 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -28,6 +28,7 @@
#include <linux/scatterlist.h>
#include <linux/blkzoned.h>
+extern bool precise_iostat;
struct module;
struct scsi_ioctl_command;
--
2.25.1
1
2

[PATCH openEuler-5.10] Revert "efi/libstub: arm64: Relax 2M alignment again for relocatable kernels"
by Zheng Zengkai 09 Mar '22
by Zheng Zengkai 09 Mar '22
09 Mar '22
From: Yang Yingliang <yangyingliang(a)huawei.com>
hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4VSGH
CVE: NA
--------------------------------
This reverts commit c6d2a109d90440e9e5e927a740128a35acf9d0b5.
I got the following messages when booting kernel:
EFI stub: Booting Linux Kernel...
EFI stub: EFI_RNG_PROTOCOL unavailable, KASLR will be disabled
EFI stub: Using DTB from configuration table
EFI stub: Exiting boot services and installing virtual address map...
...
[ 0.000000] CPU features: kernel page table isolation forced ON by KASLR
[ 0.000000] CPU features: detected: Kernel page table isolation (KPTI)
[ 3.393380] KASLR disabled due to lack of seed
KPTI is forced on by KASLR, but in fact KASLR is not enabled, it's
because kaslr_offset() returns non-zero in kaslr_requires_kpti().
To avoid this problem, when efi kaslr is disabled, make image
MIN_KIMG_ALIGN align which is used to get KASLR offset in
primary_entry(), so kaslr_offset() will returns 0.
Signed-off-by: Yang Yingliang <yangyingliang(a)huawei.com>
Reviewed-by: Xie XiuQi <xiexiuqi(a)huawei.com>
Signed-off-by: Zheng Zengkai <zhengzengkai(a)huawei.com>
---
drivers/firmware/efi/libstub/arm64-stub.c | 28 ++++++++++++-----------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/drivers/firmware/efi/libstub/arm64-stub.c b/drivers/firmware/efi/libstub/arm64-stub.c
index c1b57dfb1277..aa796324fd62 100644
--- a/drivers/firmware/efi/libstub/arm64-stub.c
+++ b/drivers/firmware/efi/libstub/arm64-stub.c
@@ -79,6 +79,18 @@ static bool check_image_region(u64 base, u64 size)
return ret;
}
+/*
+ * Although relocatable kernels can fix up the misalignment with respect to
+ * MIN_KIMG_ALIGN, the resulting virtual text addresses are subtly out of
+ * sync with those recorded in the vmlinux when kaslr is disabled but the
+ * image required relocation anyway. Therefore retain 2M alignment unless
+ * KASLR is in use.
+ */
+static u64 min_kimg_align(void)
+{
+ return efi_nokaslr ? MIN_KIMG_ALIGN : EFI_KIMG_ALIGN;
+}
+
efi_status_t handle_kernel_image(unsigned long *image_addr,
unsigned long *image_size,
unsigned long *reserve_addr,
@@ -89,16 +101,6 @@ efi_status_t handle_kernel_image(unsigned long *image_addr,
unsigned long kernel_size, kernel_memsize = 0;
u32 phys_seed = 0;
- /*
- * Although relocatable kernels can fix up the misalignment with
- * respect to MIN_KIMG_ALIGN, the resulting virtual text addresses are
- * subtly out of sync with those recorded in the vmlinux when kaslr is
- * disabled but the image required relocation anyway. Therefore retain
- * 2M alignment if KASLR was explicitly disabled, even if it was not
- * going to be activated to begin with.
- */
- u64 min_kimg_align = efi_nokaslr ? MIN_KIMG_ALIGN : EFI_KIMG_ALIGN;
-
if (IS_ENABLED(CONFIG_RANDOMIZE_BASE)) {
if (!efi_nokaslr) {
status = efi_get_random_bytes(sizeof(phys_seed),
@@ -132,7 +134,7 @@ efi_status_t handle_kernel_image(unsigned long *image_addr,
* If KASLR is enabled, and we have some randomness available,
* locate the kernel at a randomized offset in physical memory.
*/
- status = efi_random_alloc(*reserve_size, min_kimg_align,
+ status = efi_random_alloc(*reserve_size, min_kimg_align(),
reserve_addr, phys_seed);
} else {
status = EFI_OUT_OF_RESOURCES;
@@ -141,7 +143,7 @@ efi_status_t handle_kernel_image(unsigned long *image_addr,
if (status != EFI_SUCCESS) {
if (!check_image_region((u64)_text, kernel_memsize)) {
efi_err("FIRMWARE BUG: Image BSS overlaps adjacent EFI memory region\n");
- } else if (IS_ALIGNED((u64)_text, min_kimg_align)) {
+ } else if (IS_ALIGNED((u64)_text, min_kimg_align())) {
/*
* Just execute from wherever we were loaded by the
* UEFI PE/COFF loader if the alignment is suitable.
@@ -152,7 +154,7 @@ efi_status_t handle_kernel_image(unsigned long *image_addr,
}
status = efi_allocate_pages_aligned(*reserve_size, reserve_addr,
- ULONG_MAX, min_kimg_align);
+ ULONG_MAX, min_kimg_align());
if (status != EFI_SUCCESS) {
efi_err("Failed to relocate kernel\n");
--
2.20.1
1
0

[PATCH openEuler-5.10 01/12] crypto: hisilicon/sec - fix the aead software fallback for engine
by Zheng Zengkai 09 Mar '22
by Zheng Zengkai 09 Mar '22
09 Mar '22
From: Kai Ye <yekai13(a)huawei.com>
mainline inclusion
from mainline-crypto-master
commit 0a2a464f863187f97e96ebc6384c052cafd4a54c
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4W4WU
CVE: NA
--------------------------------
Due to the subreq pointer misuse the private context memory. The aead
soft crypto occasionally casues the OS panic as setting the 64K page.
Here is fix it.
Fixes: 6c46a3297bea ("crypto: hisilicon/sec - add fallback tfm...")
Signed-off-by: Kai Ye <yekai13(a)huawei.com>
Signed-off-by: Herbert Xu <herbert(a)gondor.apana.org.au>
Signed-off-by: Yang Shen <shenyang39(a)huawei.com>
Reviewed-by: Xiu Jianfeng <xiujianfeng(a)huawei.com>
Signed-off-by: Zheng Zengkai <zhengzengkai(a)huawei.com>
---
drivers/crypto/hisilicon/sec2/sec_crypto.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/drivers/crypto/hisilicon/sec2/sec_crypto.c b/drivers/crypto/hisilicon/sec2/sec_crypto.c
index f77be0e6cf65..bf5668ce2a80 100644
--- a/drivers/crypto/hisilicon/sec2/sec_crypto.c
+++ b/drivers/crypto/hisilicon/sec2/sec_crypto.c
@@ -2295,9 +2295,10 @@ static int sec_aead_soft_crypto(struct sec_ctx *ctx,
struct aead_request *aead_req,
bool encrypt)
{
- struct aead_request *subreq = aead_request_ctx(aead_req);
struct sec_auth_ctx *a_ctx = &ctx->a_ctx;
struct device *dev = ctx->dev;
+ struct aead_request *subreq;
+ int ret;
/* Kunpeng920 aead mode not support input 0 size */
if (!a_ctx->fallback_aead_tfm) {
@@ -2305,6 +2306,10 @@ static int sec_aead_soft_crypto(struct sec_ctx *ctx,
return -EINVAL;
}
+ subreq = aead_request_alloc(a_ctx->fallback_aead_tfm, GFP_KERNEL);
+ if (!subreq)
+ return -ENOMEM;
+
aead_request_set_tfm(subreq, a_ctx->fallback_aead_tfm);
aead_request_set_callback(subreq, aead_req->base.flags,
aead_req->base.complete, aead_req->base.data);
@@ -2312,8 +2317,13 @@ static int sec_aead_soft_crypto(struct sec_ctx *ctx,
aead_req->cryptlen, aead_req->iv);
aead_request_set_ad(subreq, aead_req->assoclen);
- return encrypt ? crypto_aead_encrypt(subreq) :
- crypto_aead_decrypt(subreq);
+ if (encrypt)
+ ret = crypto_aead_encrypt(subreq);
+ else
+ ret = crypto_aead_decrypt(subreq);
+ aead_request_free(subreq);
+
+ return ret;
}
static int sec_aead_crypto(struct aead_request *a_req, bool encrypt)
--
2.20.1
1
11

[PATCH openEuler-1.0-LTS 1/2] bfq: fix use-after-free in bfq_dispatch_request
by Yang Yingliang 08 Mar '22
by Yang Yingliang 08 Mar '22
08 Mar '22
From: Zhang Wensheng <zhangwensheng5(a)huawei.com>
hulk inclusion
category: bugfix
bugzilla: 185755, https://gitee.com/openeuler/kernel/issues/I4WLYZ
CVE:NA
Reference: https://lore.kernel.org/lkml/8b6032c7-c971-d79b-4a41-271d3cc0efdd@huawei.co…
--------------------------------
KASAN reports a use-after-free report when doing normal scsi-mq test
[69832.239032] ==================================================================
[69832.241810] BUG: KASAN: use-after-free in bfq_dispatch_request+0x1045/0x44b0
[69832.243267] Read of size 8 at addr ffff88802622ba88 by task kworker/3:1H/155
[69832.244656]
[69832.245007] CPU: 3 PID: 155 Comm: kworker/3:1H Not tainted 5.10.0-10295-g576c6382529e #8
[69832.246626] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014
[69832.249069] Workqueue: kblockd blk_mq_run_work_fn
[69832.250022] Call Trace:
[69832.250541] dump_stack+0x9b/0xce
[69832.251232] ? bfq_dispatch_request+0x1045/0x44b0
[69832.252243] print_address_description.constprop.6+0x3e/0x60
[69832.253381] ? __cpuidle_text_end+0x5/0x5
[69832.254211] ? vprintk_func+0x6b/0x120
[69832.254994] ? bfq_dispatch_request+0x1045/0x44b0
[69832.255952] ? bfq_dispatch_request+0x1045/0x44b0
[69832.256914] kasan_report.cold.9+0x22/0x3a
[69832.257753] ? bfq_dispatch_request+0x1045/0x44b0
[69832.258755] check_memory_region+0x1c1/0x1e0
[69832.260248] bfq_dispatch_request+0x1045/0x44b0
[69832.261181] ? bfq_bfqq_expire+0x2440/0x2440
[69832.262032] ? blk_mq_delay_run_hw_queues+0xf9/0x170
[69832.263022] __blk_mq_do_dispatch_sched+0x52f/0x830
[69832.264011] ? blk_mq_sched_request_inserted+0x100/0x100
[69832.265101] __blk_mq_sched_dispatch_requests+0x398/0x4f0
[69832.266206] ? blk_mq_do_dispatch_ctx+0x570/0x570
[69832.267147] ? __switch_to+0x5f4/0xee0
[69832.267898] blk_mq_sched_dispatch_requests+0xdf/0x140
[69832.268946] __blk_mq_run_hw_queue+0xc0/0x270
[69832.269840] blk_mq_run_work_fn+0x51/0x60
[69832.278170] process_one_work+0x6d4/0xfe0
[69832.278984] worker_thread+0x91/0xc80
[69832.279726] ? __kthread_parkme+0xb0/0x110
[69832.280554] ? process_one_work+0xfe0/0xfe0
[69832.281414] kthread+0x32d/0x3f0
[69832.282082] ? kthread_park+0x170/0x170
[69832.282849] ret_from_fork+0x1f/0x30
[69832.283573]
[69832.283886] Allocated by task 7725:
[69832.284599] kasan_save_stack+0x19/0x40
[69832.285385] __kasan_kmalloc.constprop.2+0xc1/0xd0
[69832.286350] kmem_cache_alloc_node+0x13f/0x460
[69832.287237] bfq_get_queue+0x3d4/0x1140
[69832.287993] bfq_get_bfqq_handle_split+0x103/0x510
[69832.289015] bfq_init_rq+0x337/0x2d50
[69832.289749] bfq_insert_requests+0x304/0x4e10
[69832.290634] blk_mq_sched_insert_requests+0x13e/0x390
[69832.291629] blk_mq_flush_plug_list+0x4b4/0x760
[69832.292538] blk_flush_plug_list+0x2c5/0x480
[69832.293392] io_schedule_prepare+0xb2/0xd0
[69832.294209] io_schedule_timeout+0x13/0x80
[69832.295014] wait_for_common_io.constprop.1+0x13c/0x270
[69832.296137] submit_bio_wait+0x103/0x1a0
[69832.296932] blkdev_issue_discard+0xe6/0x160
[69832.297794] blk_ioctl_discard+0x219/0x290
[69832.298614] blkdev_common_ioctl+0x50a/0x1750
[69832.304715] blkdev_ioctl+0x470/0x600
[69832.305474] block_ioctl+0xde/0x120
[69832.306232] vfs_ioctl+0x6c/0xc0
[69832.306877] __se_sys_ioctl+0x90/0xa0
[69832.307629] do_syscall_64+0x2d/0x40
[69832.308362] entry_SYSCALL_64_after_hwframe+0x44/0xa9
[69832.309382]
[69832.309701] Freed by task 155:
[69832.310328] kasan_save_stack+0x19/0x40
[69832.311121] kasan_set_track+0x1c/0x30
[69832.311868] kasan_set_free_info+0x1b/0x30
[69832.312699] __kasan_slab_free+0x111/0x160
[69832.313524] kmem_cache_free+0x94/0x460
[69832.314367] bfq_put_queue+0x582/0x940
[69832.315112] __bfq_bfqd_reset_in_service+0x166/0x1d0
[69832.317275] bfq_bfqq_expire+0xb27/0x2440
[69832.318084] bfq_dispatch_request+0x697/0x44b0
[69832.318991] __blk_mq_do_dispatch_sched+0x52f/0x830
[69832.319984] __blk_mq_sched_dispatch_requests+0x398/0x4f0
[69832.321087] blk_mq_sched_dispatch_requests+0xdf/0x140
[69832.322225] __blk_mq_run_hw_queue+0xc0/0x270
[69832.323114] blk_mq_run_work_fn+0x51/0x60
[69832.323942] process_one_work+0x6d4/0xfe0
[69832.324772] worker_thread+0x91/0xc80
[69832.325518] kthread+0x32d/0x3f0
[69832.326205] ret_from_fork+0x1f/0x30
[69832.326932]
[69832.338297] The buggy address belongs to the object at ffff88802622b968
[69832.338297] which belongs to the cache bfq_queue of size 512
[69832.340766] The buggy address is located 288 bytes inside of
[69832.340766] 512-byte region [ffff88802622b968, ffff88802622bb68)
[69832.343091] The buggy address belongs to the page:
[69832.344097] page:ffffea0000988a00 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88802622a528 pfn:0x26228
[69832.346214] head:ffffea0000988a00 order:2 compound_mapcount:0 compound_pincount:0
[69832.347719] flags: 0x1fffff80010200(slab|head)
[69832.348625] raw: 001fffff80010200 ffffea0000dbac08 ffff888017a57650 ffff8880179fe840
[69832.354972] raw: ffff88802622a528 0000000000120008 00000001ffffffff 0000000000000000
[69832.356547] page dumped because: kasan: bad access detected
[69832.357652]
[69832.357970] Memory state around the buggy address:
[69832.358926] ffff88802622b980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[69832.360358] ffff88802622ba00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[69832.361810] >ffff88802622ba80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[69832.363273] ^
[69832.363975] ffff88802622bb00: fb fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc
[69832.375960] ffff88802622bb80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[69832.377405] ==================================================================
In bfq_dispatch_requestfunction, it may have function call:
bfq_dispatch_request
__bfq_dispatch_request
bfq_select_queue
bfq_bfqq_expire
__bfq_bfqd_reset_in_service
bfq_put_queue
kmem_cache_free
In this function call, in_serv_queue has beed expired and meet the
conditions to free. In the function bfq_dispatch_request, the address
of in_serv_queue pointing to has been released. For getting the value
of idle_timer_disabled, it will get flags value from the address which
in_serv_queue pointing to, then the problem of use-after-free happens;
Fix the problem by check in_serv_queue == bfqd->in_service_queue, to
get the value of idle_timer_disabled if in_serve_queue is equel to
bfqd->in_service_queue. If the space of in_serv_queue pointing has
been released, this judge will aviod use-after-free problem.
And if in_serv_queue may be expired or finished, the idle_timer_disabled
will be false which would not give effects to bfq_update_dispatch_stats.
Reported-by: Hulk Robot <hulkci(a)huawei.com>
Signed-off-by: Zhang Wensheng <zhangwensheng5(a)huawei.com>
Reviewed-by: Jens Axboe <axboe(a)kernel.dk>
Reviewed-by: Laibin Qiu <qiulaibin(a)huawei.com>
Reviewed-by: Jason Yan <yanaijie(a)huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang(a)huawei.com>
---
block/bfq-iosched.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
index fe4255698d810..8f4275d1b11a3 100644
--- a/block/bfq-iosched.c
+++ b/block/bfq-iosched.c
@@ -4140,7 +4140,7 @@ static struct request *bfq_dispatch_request(struct blk_mq_hw_ctx *hctx)
struct bfq_data *bfqd = hctx->queue->elevator->elevator_data;
struct request *rq;
struct bfq_queue *in_serv_queue;
- bool waiting_rq, idle_timer_disabled;
+ bool waiting_rq, idle_timer_disabled = false;
spin_lock_irq(&bfqd->lock);
@@ -4148,14 +4148,15 @@ static struct request *bfq_dispatch_request(struct blk_mq_hw_ctx *hctx)
waiting_rq = in_serv_queue && bfq_bfqq_wait_request(in_serv_queue);
rq = __bfq_dispatch_request(hctx);
-
- idle_timer_disabled =
- waiting_rq && !bfq_bfqq_wait_request(in_serv_queue);
+ if (in_serv_queue == bfqd->in_service_queue) {
+ idle_timer_disabled =
+ waiting_rq && !bfq_bfqq_wait_request(in_serv_queue);
+ }
spin_unlock_irq(&bfqd->lock);
-
- bfq_update_dispatch_stats(hctx->queue, rq, in_serv_queue,
- idle_timer_disabled);
+ bfq_update_dispatch_stats(hctx->queue, rq,
+ idle_timer_disabled ? in_serv_queue : NULL,
+ idle_timer_disabled);
return rq;
}
--
2.25.1
1
1

08 Mar '22
From: Zhihao Cheng <chengzhihao1(a)huawei.com>
From: Max Kellermann <max.kellermann(a)ionos.com>
mainline inclusion
from mainline-v5.17-rc6
commit 9d2231c5d74e13b2a0546fee6737ee4446017903
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4WUKP?from=project-issue
CVE: CVE-2022-0847
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/l…
--------------------------------
The functions copy_page_to_iter_pipe() and push_pipe() can both
allocate a new pipe_buffer, but the "flags" member initializer is
missing.
Fixes: 241699cd72a8 ("new iov_iter flavour: pipe-backed")
To: Alexander Viro <viro(a)zeniv.linux.org.uk>
To: linux-fsdevel(a)vger.kernel.org
To: linux-kernel(a)vger.kernel.org
Cc: stable(a)vger.kernel.org
Signed-off-by: Max Kellermann <max.kellermann(a)ionos.com>
Signed-off-by: Al Viro <viro(a)zeniv.linux.org.uk>
Signed-off-by: Zhihao Cheng <chengzhihao1(a)huawei.com>
Reviewed-by: Zhang Yi <yi.zhang(a)huawei.com>
---
lib/iov_iter.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index b364231b5fc8..1b0a349fbcd9 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -407,6 +407,7 @@ static size_t copy_page_to_iter_pipe(struct page *page, size_t offset, size_t by
return 0;
buf->ops = &page_cache_pipe_buf_ops;
+ buf->flags = 0;
get_page(page);
buf->page = page;
buf->offset = offset;
@@ -543,6 +544,7 @@ static size_t push_pipe(struct iov_iter *i, size_t size,
break;
buf->ops = &default_pipe_buf_ops;
+ buf->flags = 0;
buf->page = page;
buf->offset = 0;
buf->len = min_t(ssize_t, left, PAGE_SIZE);
2
1

[PATCH openEuler-5.10] lib/iov_iter: initialize "flags" in new pipe_buffer
by Zheng Zengkai 08 Mar '22
by Zheng Zengkai 08 Mar '22
08 Mar '22
From: Max Kellermann <max.kellermann(a)ionos.com>
mainline inclusion
from mainline-v5.17-rc6
commit 9d2231c5d74e13b2a0546fee6737ee4446017903
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4WUKP?from=project-issue
CVE: CVE-2022-0847
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/l…
--------------------------------
The functions copy_page_to_iter_pipe() and push_pipe() can both
allocate a new pipe_buffer, but the "flags" member initializer is
missing.
Fixes: 241699cd72a8 ("new iov_iter flavour: pipe-backed")
To: Alexander Viro <viro(a)zeniv.linux.org.uk>
To: linux-fsdevel(a)vger.kernel.org
To: linux-kernel(a)vger.kernel.org
Cc: stable(a)vger.kernel.org
Signed-off-by: Max Kellermann <max.kellermann(a)ionos.com>
Signed-off-by: Al Viro <viro(a)zeniv.linux.org.uk>
Signed-off-by: Zhihao Cheng <chengzhihao1(a)huawei.com>
Reviewed-by: Zhang Yi <yi.zhang(a)huawei.com>
Signed-off-by: Zheng Zengkai <zhengzengkai(a)huawei.com>
---
lib/iov_iter.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index b364231b5fc8..1b0a349fbcd9 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -407,6 +407,7 @@ static size_t copy_page_to_iter_pipe(struct page *page, size_t offset, size_t by
return 0;
buf->ops = &page_cache_pipe_buf_ops;
+ buf->flags = 0;
get_page(page);
buf->page = page;
buf->offset = offset;
@@ -543,6 +544,7 @@ static size_t push_pipe(struct iov_iter *i, size_t size,
break;
buf->ops = &default_pipe_buf_ops;
+ buf->flags = 0;
buf->page = page;
buf->offset = 0;
buf->len = min_t(ssize_t, left, PAGE_SIZE);
--
2.20.1
1
0
From: Yu Kuai <yukuai3(a)huawei.com>
From: Christoph Hellwig <hch(a)lst.de>
mainline inclusion
from mainline-v5.11-rc1
commit 6b3ba9762f9f9f651873af34481ca20e4a6791e7
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4SA9G
---------------------------
Merge three hidden gendisk checks into one.
Signed-off-by: Christoph Hellwig <hch(a)lst.de>
Reviewed-by: Hannes Reinecke <hare(a)suse.de>
Signed-off-by: Jens Axboe <axboe(a)kernel.dk>
Signed-off-by: Yu Kuai <yukuai3(a)huawei.com>
---
block/genhd.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/block/genhd.c b/block/genhd.c
index 6566eacc807d..2a61dcd98d73 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -904,6 +904,9 @@ void del_gendisk(struct gendisk *disk)
might_sleep();
+ if (WARN_ON_ONCE(!disk->queue))
+ return;
+
blk_integrity_del(disk);
disk_del_events(disk);
@@ -926,20 +929,18 @@ void del_gendisk(struct gendisk *disk)
disk->flags &= ~GENHD_FL_UP;
up_write(&disk->lookup_sem);
- if (!(disk->flags & GENHD_FL_HIDDEN))
+ if (!(disk->flags & GENHD_FL_HIDDEN)) {
sysfs_remove_link(&disk_to_dev(disk)->kobj, "bdi");
- if (disk->queue) {
+
/*
* Unregister bdi before releasing device numbers (as they can
* get reused and we'd get clashes in sysfs).
*/
- if (!(disk->flags & GENHD_FL_HIDDEN))
- bdi_unregister(disk->queue->backing_dev_info);
- blk_unregister_queue(disk);
- } else {
- WARN_ON(1);
+ bdi_unregister(disk->queue->backing_dev_info);
}
+ blk_unregister_queue(disk);
+
if (!(disk->flags & GENHD_FL_HIDDEN))
blk_unregister_region(disk_devt(disk), disk->minors);
/*
From patchwork Wed Jan 26 08:35:24 2022
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Yu Kuai <yukuai3(a)huawei.com>
X-Patchwork-Id: 152657
Return-Path: <yukuai3(a)huawei.com>
Received: from dggems704-chm.china.huawei.com (10.3.19.181) by
dggems702-chm.china.huawei.com (10.3.19.179) with Microsoft SMTP Server
(version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
15.1.2308.21 via Mailbox Transport; Wed, 26 Jan 2022 16:24:48 +0800
Received: from kwepemm600009.china.huawei.com (7.193.23.164) by
dggems704-chm.china.huawei.com (10.3.19.181) with Microsoft SMTP Server
(version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
15.1.2308.21; Wed, 26 Jan 2022 16:24:47 +0800
Received: from huawei.com (10.175.127.227) by kwepemm600009.china.huawei.com
(7.193.23.164) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Wed, 26 Jan
2022 16:24:46 +0800
From: Yu Kuai <yukuai3(a)huawei.com>
To: <zhengzengkai(a)huawei.com>, <xiexiuqi(a)huawei.com>, <patchwork(a)huawei.com>
CC: <yukuai3(a)huawei.com>, <yi.zhang(a)huawei.com>, <houtao1(a)huawei.com>,
<chenxiaosong2(a)huawei.com>, <chengzhihao1(a)huawei.com>,
<libaokun1(a)huawei.com>, <luomeng12(a)huawei.com>, <yanaijie(a)huawei.com>,
<yangerkun(a)huawei.com>, <yebin10(a)huawei.com>, <yuyufen(a)huawei.com>,
<zhangxiaoxu5(a)huawei.com>, <zhengbin13(a)huawei.com>, <koulihong(a)huawei.com>,
<qiulaibin(a)huawei.com>, <zhengliang6(a)huawei.com>
Subject: [PATCH OLK-5.10 02/12] block: fold register_disk into device_add_disk
Date: Wed, 26 Jan 2022 16:35:24 +0800
Message-ID: <20220126083534.4016012-3-yukuai3(a)huawei.com>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <20220126083534.4016012-1-yukuai3(a)huawei.com>
References: <20220126083534.4016012-1-yukuai3(a)huawei.com>
Content-Type: text/plain
X-MS-Exchange-Organization-Network-Message-Id:
3218969e-1bda-4724-aaa8-08d9e0a55088
X-MS-Exchange-Organization-AuthSource: kwepemm600009.china.huawei.com
X-MS-Exchange-Organization-AuthAs: Internal
X-MS-Exchange-Organization-AuthMechanism: 07
X-Originating-IP: [10.175.127.227]
X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To
kwepemm600009.china.huawei.com (7.193.23.164)
X-MS-Exchange-Transport-EndToEndLatency: 00:00:01.8705511
X-MS-Exchange-Processed-By-BccFoldering: 15.01.2308.021
MIME-Version: 1.0
From: Christoph Hellwig <hch(a)lst.de>
mainline inclusion
from mainline-v5.15-rc1
commit 52b85909f85d06efa69aaf4210e72467f1f58d2b
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4SA9G
---------------------------
There is no real reason these should be separate. Also simplify the
groups assignment a bit.
Signed-off-by: Christoph Hellwig <hch(a)lst.de>
Signed-off-by: Yu Kuai <yukuai3(a)huawei.com>
---
block/genhd.c | 129 +++++++++++++++++++++++---------------------------
1 file changed, 58 insertions(+), 71 deletions(-)
diff --git a/block/genhd.c b/block/genhd.c
index 2a61dcd98d73..c0e1639131d9 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -700,69 +700,6 @@ static void disk_scan_partitions(struct gendisk *disk)
blkdev_put(bdev, FMODE_READ);
}
-static void register_disk(struct device *parent, struct gendisk *disk,
- const struct attribute_group **groups)
-{
- struct device *ddev = disk_to_dev(disk);
- struct disk_part_iter piter;
- struct hd_struct *part;
- int err;
-
- ddev->parent = parent;
-
- dev_set_name(ddev, "%s", disk->disk_name);
-
- /* delay uevents, until we scanned partition table */
- dev_set_uevent_suppress(ddev, 1);
-
- if (groups) {
- WARN_ON(ddev->groups);
- ddev->groups = groups;
- }
- if (device_add(ddev))
- return;
- if (!sysfs_deprecated) {
- err = sysfs_create_link(block_depr, &ddev->kobj,
- kobject_name(&ddev->kobj));
- if (err) {
- device_del(ddev);
- return;
- }
- }
-
- /*
- * avoid probable deadlock caused by allocating memory with
- * GFP_KERNEL in runtime_resume callback of its all ancestor
- * devices
- */
- pm_runtime_set_memalloc_noio(ddev, true);
-
- disk->part0.holder_dir = kobject_create_and_add("holders", &ddev->kobj);
- disk->slave_dir = kobject_create_and_add("slaves", &ddev->kobj);
-
- if (disk->flags & GENHD_FL_HIDDEN)
- return;
-
- disk_scan_partitions(disk);
-
- /* announce disk after possible partitions are created */
- dev_set_uevent_suppress(ddev, 0);
- kobject_uevent(&ddev->kobj, KOBJ_ADD);
-
- /* announce possible partitions */
- disk_part_iter_init(&piter, disk, 0);
- while ((part = disk_part_iter_next(&piter)))
- kobject_uevent(&part_to_dev(part)->kobj, KOBJ_ADD);
- disk_part_iter_exit(&piter);
-
- if (disk->queue->backing_dev_info->dev) {
- err = sysfs_create_link(&ddev->kobj,
- &disk->queue->backing_dev_info->dev->kobj,
- "bdi");
- WARN_ON(err);
- }
-}
-
/**
* __device_add_disk - add disk information to kernel list
* @parent: parent device for the disk
@@ -779,8 +716,11 @@ static void __device_add_disk(struct device *parent, struct gendisk *disk,
const struct attribute_group **groups,
bool register_queue)
{
+ struct device *ddev = disk_to_dev(disk);
+ struct disk_part_iter piter;
+ struct hd_struct *part;
dev_t devt;
- int retval;
+ int ret;
/*
* The disk queue should now be all set with enough information about
@@ -801,8 +741,8 @@ static void __device_add_disk(struct device *parent, struct gendisk *disk,
disk->flags |= GENHD_FL_UP;
- retval = blk_alloc_devt(&disk->part0, &devt);
- if (retval) {
+ ret = blk_alloc_devt(&disk->part0, &devt);
+ if (ret) {
WARN_ON(1);
return;
}
@@ -820,18 +760,65 @@ static void __device_add_disk(struct device *parent, struct gendisk *disk,
disk->flags |= GENHD_FL_NO_PART_SCAN;
} else {
struct backing_dev_info *bdi = disk->queue->backing_dev_info;
- struct device *dev = disk_to_dev(disk);
- int ret;
/* Register BDI before referencing it from bdev */
- dev->devt = devt;
+ ddev->devt = devt;
ret = bdi_register(bdi, "%u:%u", MAJOR(devt), MINOR(devt));
WARN_ON(ret);
- bdi_set_owner(bdi, dev);
+ bdi_set_owner(bdi, ddev);
blk_register_region(disk_devt(disk), disk->minors, NULL,
exact_match, exact_lock, disk);
}
- register_disk(parent, disk, groups);
+
+ /* delay uevents, until we scanned partition table */
+ dev_set_uevent_suppress(ddev, 1);
+
+ ddev->parent = parent;
+ ddev->groups = groups;
+ dev_set_name(ddev, "%s", disk->disk_name);
+
+ if (device_add(ddev))
+ return;
+ if (!sysfs_deprecated) {
+ ret = sysfs_create_link(block_depr, &ddev->kobj,
+ kobject_name(&ddev->kobj));
+ if (ret) {
+ device_del(ddev);
+ return;
+ }
+ }
+
+ /*
+ * avoid probable deadlock caused by allocating memory with
+ * GFP_KERNEL in runtime_resume callback of its all ancestor
+ * devices
+ */
+ pm_runtime_set_memalloc_noio(ddev, true);
+
+ disk->part0.holder_dir = kobject_create_and_add("holders", &ddev->kobj);
+ disk->slave_dir = kobject_create_and_add("slaves", &ddev->kobj);
+
+ if (!(disk->flags & GENHD_FL_HIDDEN)) {
+ disk_scan_partitions(disk);
+
+ /* announce disk after possible partitions are created */
+ dev_set_uevent_suppress(ddev, 0);
+ kobject_uevent(&ddev->kobj, KOBJ_ADD);
+
+ /* announce possible partitions */
+ disk_part_iter_init(&piter, disk, 0);
+ while ((part = disk_part_iter_next(&piter)))
+ kobject_uevent(&part_to_dev(part)->kobj, KOBJ_ADD);
+ disk_part_iter_exit(&piter);
+
+ if (disk->queue->backing_dev_info->dev) {
+ ret = sysfs_create_link(&ddev->kobj,
+ &disk->queue->backing_dev_info->dev->kobj,
+ "bdi");
+ WARN_ON(ret);
+ }
+ }
+
if (register_queue)
blk_register_queue(disk);
From patchwork Wed Jan 26 08:35:25 2022
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Yu Kuai <yukuai3(a)huawei.com>
X-Patchwork-Id: 152658
Return-Path: <yukuai3(a)huawei.com>
Received: from dggems706-chm.china.huawei.com (10.3.19.183) by
dggems702-chm.china.huawei.com (10.3.19.179) with Microsoft SMTP Server
(version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
15.1.2308.21 via Mailbox Transport; Wed, 26 Jan 2022 16:24:49 +0800
Received: from kwepemm600009.china.huawei.com (7.193.23.164) by
dggems706-chm.china.huawei.com (10.3.19.183) with Microsoft SMTP Server
(version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
15.1.2308.21; Wed, 26 Jan 2022 16:24:49 +0800
Received: from huawei.com (10.175.127.227) by kwepemm600009.china.huawei.com
(7.193.23.164) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Wed, 26 Jan
2022 16:24:47 +0800
From: Yu Kuai <yukuai3(a)huawei.com>
To: <zhengzengkai(a)huawei.com>, <xiexiuqi(a)huawei.com>, <patchwork(a)huawei.com>
CC: <yukuai3(a)huawei.com>, <yi.zhang(a)huawei.com>, <houtao1(a)huawei.com>,
<chenxiaosong2(a)huawei.com>, <chengzhihao1(a)huawei.com>,
<libaokun1(a)huawei.com>, <luomeng12(a)huawei.com>, <yanaijie(a)huawei.com>,
<yangerkun(a)huawei.com>, <yebin10(a)huawei.com>, <yuyufen(a)huawei.com>,
<zhangxiaoxu5(a)huawei.com>, <zhengbin13(a)huawei.com>, <koulihong(a)huawei.com>,
<qiulaibin(a)huawei.com>, <zhengliang6(a)huawei.com>
Subject: [PATCH OLK-5.10 03/12] block: set GENHD_FL_UP last in
__device_add_disk()
Date: Wed, 26 Jan 2022 16:35:25 +0800
Message-ID: <20220126083534.4016012-4-yukuai3(a)huawei.com>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <20220126083534.4016012-1-yukuai3(a)huawei.com>
References: <20220126083534.4016012-1-yukuai3(a)huawei.com>
Content-Type: text/plain
X-MS-Exchange-Organization-Network-Message-Id:
d49516fb-3c05-44d0-73f3-08d9e0a55156
X-MS-Exchange-Organization-AuthSource: kwepemm600009.china.huawei.com
X-MS-Exchange-Organization-AuthAs: Internal
X-MS-Exchange-Organization-AuthMechanism: 07
X-Originating-IP: [10.175.127.227]
X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To
kwepemm600009.china.huawei.com (7.193.23.164)
X-MS-Exchange-Transport-EndToEndLatency: 00:00:01.7552871
X-MS-Exchange-Processed-By-BccFoldering: 15.01.2308.021
MIME-Version: 1.0
hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4SA9G
---------------------------
The flag will be checked before operations on the block device, thus
don't set the flag is some errors occurred.
Signed-off-by: Yu Kuai <yukuai3(a)huawei.com>
---
block/genhd.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/block/genhd.c b/block/genhd.c
index c0e1639131d9..59bdb43ccf17 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -739,8 +739,6 @@ static void __device_add_disk(struct device *parent, struct gendisk *disk,
WARN_ON(!disk->minors &&
!(disk->flags & (GENHD_FL_EXT_DEVT | GENHD_FL_HIDDEN)));
- disk->flags |= GENHD_FL_UP;
-
ret = blk_alloc_devt(&disk->part0, &devt);
if (ret) {
WARN_ON(1);
@@ -830,6 +828,8 @@ static void __device_add_disk(struct device *parent, struct gendisk *disk,
disk_add_events(disk);
blk_integrity_add(disk);
+
+ disk->flags |= GENHD_FL_UP;
}
void device_add_disk(struct device *parent, struct gendisk *disk,
From patchwork Wed Jan 26 08:35:26 2022
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Yu Kuai <yukuai3(a)huawei.com>
X-Patchwork-Id: 152659
Return-Path: <yukuai3(a)huawei.com>
Received: from dggems705-chm.china.huawei.com (10.3.19.182) by
dggems702-chm.china.huawei.com (10.3.19.179) with Microsoft SMTP Server
(version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
15.1.2308.21 via Mailbox Transport; Wed, 26 Jan 2022 16:24:50 +0800
Received: from kwepemm600009.china.huawei.com (7.193.23.164) by
dggems705-chm.china.huawei.com (10.3.19.182) with Microsoft SMTP Server
(version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
15.1.2308.21; Wed, 26 Jan 2022 16:24:50 +0800
Received: from huawei.com (10.175.127.227) by kwepemm600009.china.huawei.com
(7.193.23.164) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Wed, 26 Jan
2022 16:24:49 +0800
From: Yu Kuai <yukuai3(a)huawei.com>
To: <zhengzengkai(a)huawei.com>, <xiexiuqi(a)huawei.com>, <patchwork(a)huawei.com>
CC: <yukuai3(a)huawei.com>, <yi.zhang(a)huawei.com>, <houtao1(a)huawei.com>,
<chenxiaosong2(a)huawei.com>, <chengzhihao1(a)huawei.com>,
<libaokun1(a)huawei.com>, <luomeng12(a)huawei.com>, <yanaijie(a)huawei.com>,
<yangerkun(a)huawei.com>, <yebin10(a)huawei.com>, <yuyufen(a)huawei.com>,
<zhangxiaoxu5(a)huawei.com>, <zhengbin13(a)huawei.com>, <koulihong(a)huawei.com>,
<qiulaibin(a)huawei.com>, <zhengliang6(a)huawei.com>
Subject: [PATCH OLK-5.10 04/12] block: call bdi_register() later in
__device_add_disk()
Date: Wed, 26 Jan 2022 16:35:26 +0800
Message-ID: <20220126083534.4016012-5-yukuai3(a)huawei.com>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <20220126083534.4016012-1-yukuai3(a)huawei.com>
References: <20220126083534.4016012-1-yukuai3(a)huawei.com>
Content-Type: text/plain
X-MS-Exchange-Organization-Network-Message-Id:
1a9bddc2-3045-4a62-422a-08d9e0a55221
X-MS-Exchange-Organization-AuthSource: kwepemm600009.china.huawei.com
X-MS-Exchange-Organization-AuthAs: Internal
X-MS-Exchange-Organization-AuthMechanism: 07
X-Originating-IP: [10.175.127.227]
X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To
kwepemm600009.china.huawei.com (7.193.23.164)
X-MS-Exchange-Transport-EndToEndLatency: 00:00:01.8140598
X-MS-Exchange-Processed-By-BccFoldering: 15.01.2308.021
MIME-Version: 1.0
hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4SA9G
---------------------------
This will simplify error handling going forward.
Conflict: "ddev->devt = devt" must be set before add_disk().
Signed-off-by: Yu Kuai <yukuai3(a)huawei.com>
---
block/genhd.c | 35 +++++++++++++++++------------------
1 file changed, 17 insertions(+), 18 deletions(-)
diff --git a/block/genhd.c b/block/genhd.c
index 59bdb43ccf17..b0a6214fdbe1 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -749,24 +749,8 @@ static void __device_add_disk(struct device *parent, struct gendisk *disk,
disk_alloc_events(disk);
- if (disk->flags & GENHD_FL_HIDDEN) {
- /*
- * Don't let hidden disks show up in /proc/partitions,
- * and don't bother scanning for partitions either.
- */
- disk->flags |= GENHD_FL_SUPPRESS_PARTITION_INFO;
- disk->flags |= GENHD_FL_NO_PART_SCAN;
- } else {
- struct backing_dev_info *bdi = disk->queue->backing_dev_info;
-
- /* Register BDI before referencing it from bdev */
+ if (!(disk->flags & GENHD_FL_HIDDEN))
ddev->devt = devt;
- ret = bdi_register(bdi, "%u:%u", MAJOR(devt), MINOR(devt));
- WARN_ON(ret);
- bdi_set_owner(bdi, ddev);
- blk_register_region(disk_devt(disk), disk->minors, NULL,
- exact_match, exact_lock, disk);
- }
/* delay uevents, until we scanned partition table */
dev_set_uevent_suppress(ddev, 1);
@@ -796,7 +780,22 @@ static void __device_add_disk(struct device *parent, struct gendisk *disk,
disk->part0.holder_dir = kobject_create_and_add("holders", &ddev->kobj);
disk->slave_dir = kobject_create_and_add("slaves", &ddev->kobj);
- if (!(disk->flags & GENHD_FL_HIDDEN)) {
+ if (disk->flags & GENHD_FL_HIDDEN) {
+ /*
+ * Don't let hidden disks show up in /proc/partitions,
+ * and don't bother scanning for partitions either.
+ */
+ disk->flags |= GENHD_FL_SUPPRESS_PARTITION_INFO;
+ disk->flags |= GENHD_FL_NO_PART_SCAN;
+ } else {
+ struct backing_dev_info *bdi = disk->queue->backing_dev_info;
+
+ ret = bdi_register(bdi, "%u:%u", MAJOR(devt), MINOR(devt));
+ WARN_ON(ret);
+ bdi_set_owner(bdi, ddev);
+ blk_register_region(disk_devt(disk), disk->minors, NULL,
+ exact_match, exact_lock, disk);
+
disk_scan_partitions(disk);
/* announce disk after possible partitions are created */
From patchwork Wed Jan 26 08:35:27 2022
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Yu Kuai <yukuai3(a)huawei.com>
X-Patchwork-Id: 152660
Return-Path: <yukuai3(a)huawei.com>
Received: from dggems701-chm.china.huawei.com (10.3.19.178) by
dggems702-chm.china.huawei.com (10.3.19.179) with Microsoft SMTP Server
(version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
15.1.2308.21 via Mailbox Transport; Wed, 26 Jan 2022 16:24:52 +0800
Received: from kwepemm600009.china.huawei.com (7.193.23.164) by
dggems701-chm.china.huawei.com (10.3.19.178) with Microsoft SMTP Server
(version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
15.1.2308.21; Wed, 26 Jan 2022 16:24:51 +0800
Received: from huawei.com (10.175.127.227) by kwepemm600009.china.huawei.com
(7.193.23.164) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Wed, 26 Jan
2022 16:24:50 +0800
From: Yu Kuai <yukuai3(a)huawei.com>
To: <zhengzengkai(a)huawei.com>, <xiexiuqi(a)huawei.com>, <patchwork(a)huawei.com>
CC: <yukuai3(a)huawei.com>, <yi.zhang(a)huawei.com>, <houtao1(a)huawei.com>,
<chenxiaosong2(a)huawei.com>, <chengzhihao1(a)huawei.com>,
<libaokun1(a)huawei.com>, <luomeng12(a)huawei.com>, <yanaijie(a)huawei.com>,
<yangerkun(a)huawei.com>, <yebin10(a)huawei.com>, <yuyufen(a)huawei.com>,
<zhangxiaoxu5(a)huawei.com>, <zhengbin13(a)huawei.com>, <koulihong(a)huawei.com>,
<qiulaibin(a)huawei.com>, <zhengliang6(a)huawei.com>
Subject: [PATCH OLK-5.10 05/12] block: create the bdi link earlier in
device_add_disk
Date: Wed, 26 Jan 2022 16:35:27 +0800
Message-ID: <20220126083534.4016012-6-yukuai3(a)huawei.com>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <20220126083534.4016012-1-yukuai3(a)huawei.com>
References: <20220126083534.4016012-1-yukuai3(a)huawei.com>
Content-Type: text/plain
X-MS-Exchange-Organization-Network-Message-Id:
fad6c294-ac99-4316-207b-08d9e0a552ea
X-MS-Exchange-Organization-AuthSource: kwepemm600009.china.huawei.com
X-MS-Exchange-Organization-AuthAs: Internal
X-MS-Exchange-Organization-AuthMechanism: 07
X-Originating-IP: [10.175.127.227]
X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To
kwepemm600009.china.huawei.com (7.193.23.164)
X-MS-Exchange-Transport-EndToEndLatency: 00:00:01.8454101
X-MS-Exchange-Processed-By-BccFoldering: 15.01.2308.021
MIME-Version: 1.0
From: Christoph Hellwig <hch(a)lst.de>
mainline inclusion
from mainline-v5.15-rc1
commit 9d5ee6767c85762205b788ed1245f21fafd6c504
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4SA9G
---------------------------
This will simplify error handling going forward.
Signed-off-by: Christoph Hellwig <hch(a)lst.de>
Signed-off-by: Yu Kuai <yukuai3(a)huawei.com>
---
block/genhd.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/block/genhd.c b/block/genhd.c
index b0a6214fdbe1..b875de09dd09 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -796,6 +796,13 @@ static void __device_add_disk(struct device *parent, struct gendisk *disk,
blk_register_region(disk_devt(disk), disk->minors, NULL,
exact_match, exact_lock, disk);
+ if (disk->queue->backing_dev_info->dev) {
+ ret = sysfs_create_link(&ddev->kobj,
+ &disk->queue->backing_dev_info->dev->kobj,
+ "bdi");
+ WARN_ON(ret);
+ }
+
disk_scan_partitions(disk);
/* announce disk after possible partitions are created */
@@ -807,13 +814,6 @@ static void __device_add_disk(struct device *parent, struct gendisk *disk,
while ((part = disk_part_iter_next(&piter)))
kobject_uevent(&part_to_dev(part)->kobj, KOBJ_ADD);
disk_part_iter_exit(&piter);
-
- if (disk->queue->backing_dev_info->dev) {
- ret = sysfs_create_link(&ddev->kobj,
- &disk->queue->backing_dev_info->dev->kobj,
- "bdi");
- WARN_ON(ret);
- }
}
if (register_queue)
From patchwork Wed Jan 26 08:35:28 2022
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Yu Kuai <yukuai3(a)huawei.com>
X-Patchwork-Id: 152661
Return-Path: <yukuai3(a)huawei.com>
Received: from dggems702-chm.china.huawei.com (10.3.19.179) by
dggems702-chm.china.huawei.com (10.3.19.179) with Microsoft SMTP Server
(version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
15.1.2308.21 via Mailbox Transport; Wed, 26 Jan 2022 16:24:53 +0800
Received: from kwepemm600009.china.huawei.com (7.193.23.164) by
dggems702-chm.china.huawei.com (10.3.19.179) with Microsoft SMTP Server
(version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
15.1.2308.21; Wed, 26 Jan 2022 16:24:53 +0800
Received: from huawei.com (10.175.127.227) by kwepemm600009.china.huawei.com
(7.193.23.164) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Wed, 26 Jan
2022 16:24:51 +0800
From: Yu Kuai <yukuai3(a)huawei.com>
To: <zhengzengkai(a)huawei.com>, <xiexiuqi(a)huawei.com>, <patchwork(a)huawei.com>
CC: <yukuai3(a)huawei.com>, <yi.zhang(a)huawei.com>, <houtao1(a)huawei.com>,
<chenxiaosong2(a)huawei.com>, <chengzhihao1(a)huawei.com>,
<libaokun1(a)huawei.com>, <luomeng12(a)huawei.com>, <yanaijie(a)huawei.com>,
<yangerkun(a)huawei.com>, <yebin10(a)huawei.com>, <yuyufen(a)huawei.com>,
<zhangxiaoxu5(a)huawei.com>, <zhengbin13(a)huawei.com>, <koulihong(a)huawei.com>,
<qiulaibin(a)huawei.com>, <zhengliang6(a)huawei.com>
Subject: [PATCH OLK-5.10 06/12] block: call blk_integrity_add earlier in
device_add_disk
Date: Wed, 26 Jan 2022 16:35:28 +0800
Message-ID: <20220126083534.4016012-7-yukuai3(a)huawei.com>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <20220126083534.4016012-1-yukuai3(a)huawei.com>
References: <20220126083534.4016012-1-yukuai3(a)huawei.com>
Content-Type: text/plain
X-MS-Exchange-Organization-Network-Message-Id:
e89abd69-efcc-473e-5645-08d9e0a553b4
X-MS-Exchange-Organization-AuthSource: kwepemm600009.china.huawei.com
X-MS-Exchange-Organization-AuthAs: Internal
X-MS-Exchange-Organization-AuthMechanism: 07
X-Originating-IP: [10.175.127.227]
X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To
kwepemm600009.china.huawei.com (7.193.23.164)
X-MS-Exchange-Transport-EndToEndLatency: 00:00:01.7513136
X-MS-Exchange-Processed-By-BccFoldering: 15.01.2308.021
MIME-Version: 1.0
From: Christoph Hellwig <hch(a)lst.de>
mainline inclusion
from mainline-v5.15-rc1
commit bab53f6b617d9f530978d6e3693f88e586d81a8a
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4SA9G
---------------------------
Doing all the sysfs file creation before adding the bdev and thus
allowing it to be opened will simplify the about to be added error
handling.
Signed-off-by: Christoph Hellwig <hch(a)lst.de>
Signed-off-by: Yu Kuai <yukuai3(a)huawei.com>
---
block/genhd.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/block/genhd.c b/block/genhd.c
index b875de09dd09..aa109986a6b0 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -777,6 +777,8 @@ static void __device_add_disk(struct device *parent, struct gendisk *disk,
*/
pm_runtime_set_memalloc_noio(ddev, true);
+ blk_integrity_add(disk);
+
disk->part0.holder_dir = kobject_create_and_add("holders", &ddev->kobj);
disk->slave_dir = kobject_create_and_add("slaves", &ddev->kobj);
@@ -826,7 +828,6 @@ static void __device_add_disk(struct device *parent, struct gendisk *disk,
WARN_ON_ONCE(!blk_get_queue(disk->queue));
disk_add_events(disk);
- blk_integrity_add(disk);
disk->flags |= GENHD_FL_UP;
}
From patchwork Wed Jan 26 08:35:29 2022
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Yu Kuai <yukuai3(a)huawei.com>
X-Patchwork-Id: 152662
Return-Path: <yukuai3(a)huawei.com>
Received: from dggems703-chm.china.huawei.com (10.3.19.180) by
dggems702-chm.china.huawei.com (10.3.19.179) with Microsoft SMTP Server
(version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
15.1.2308.21 via Mailbox Transport; Wed, 26 Jan 2022 16:24:54 +0800
Received: from kwepemm600009.china.huawei.com (7.193.23.164) by
dggems703-chm.china.huawei.com (10.3.19.180) with Microsoft SMTP Server
(version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
15.1.2308.21; Wed, 26 Jan 2022 16:24:54 +0800
Received: from huawei.com (10.175.127.227) by kwepemm600009.china.huawei.com
(7.193.23.164) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Wed, 26 Jan
2022 16:24:53 +0800
From: Yu Kuai <yukuai3(a)huawei.com>
To: <zhengzengkai(a)huawei.com>, <xiexiuqi(a)huawei.com>, <patchwork(a)huawei.com>
CC: <yukuai3(a)huawei.com>, <yi.zhang(a)huawei.com>, <houtao1(a)huawei.com>,
<chenxiaosong2(a)huawei.com>, <chengzhihao1(a)huawei.com>,
<libaokun1(a)huawei.com>, <luomeng12(a)huawei.com>, <yanaijie(a)huawei.com>,
<yangerkun(a)huawei.com>, <yebin10(a)huawei.com>, <yuyufen(a)huawei.com>,
<zhangxiaoxu5(a)huawei.com>, <zhengbin13(a)huawei.com>, <koulihong(a)huawei.com>,
<qiulaibin(a)huawei.com>, <zhengliang6(a)huawei.com>
Subject: [PATCH OLK-5.10 07/12] block: return errors from blk_integrity_add
Date: Wed, 26 Jan 2022 16:35:29 +0800
Message-ID: <20220126083534.4016012-8-yukuai3(a)huawei.com>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <20220126083534.4016012-1-yukuai3(a)huawei.com>
References: <20220126083534.4016012-1-yukuai3(a)huawei.com>
Content-Type: text/plain
X-MS-Exchange-Organization-Network-Message-Id:
85f46a94-096f-4839-b1f3-08d9e0a5547e
X-MS-Exchange-Organization-AuthSource: kwepemm600009.china.huawei.com
X-MS-Exchange-Organization-AuthAs: Internal
X-MS-Exchange-Organization-AuthMechanism: 07
X-Originating-IP: [10.175.127.227]
X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To
kwepemm600009.china.huawei.com (7.193.23.164)
X-MS-Exchange-Transport-EndToEndLatency: 00:00:01.7611417
X-MS-Exchange-Processed-By-BccFoldering: 15.01.2308.021
MIME-Version: 1.0
From: Luis Chamberlain <mcgrof(a)kernel.org>
mainline inclusion
from mainline-v5.15-rc1
commit 614310c9c8ca15359f4e71a5bbd9165897b4d54e
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4SA9G
---------------------------
Prepare for proper error handling in add_disk.
Signed-off-by: Luis Chamberlain <mcgrof(a)kernel.org>
[hch: split from a larger patch]
Signed-off-by: Christoph Hellwig <hch(a)lst.de>
Reviewed-by: Hannes Reinecke <hare(a)suse.de>
Link: https://lore.kernel.org/r/20210818144542.19305-8-hch@lst.de
Signed-off-by: Jens Axboe <axboe(a)kernel.dk>
Signed-off-by: Yu Kuai <yukuai3(a)huawei.com>
---
block/blk-integrity.c | 12 +++++++-----
block/blk.h | 5 +++--
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/block/blk-integrity.c b/block/blk-integrity.c
index 9e83159f5a52..16d5d5338392 100644
--- a/block/blk-integrity.c
+++ b/block/blk-integrity.c
@@ -438,13 +438,15 @@ void blk_integrity_unregister(struct gendisk *disk)
}
EXPORT_SYMBOL(blk_integrity_unregister);
-void blk_integrity_add(struct gendisk *disk)
+int blk_integrity_add(struct gendisk *disk)
{
- if (kobject_init_and_add(&disk->integrity_kobj, &integrity_ktype,
- &disk_to_dev(disk)->kobj, "%s", "integrity"))
- return;
+ int ret;
- kobject_uevent(&disk->integrity_kobj, KOBJ_ADD);
+ ret = kobject_init_and_add(&disk->integrity_kobj, &integrity_ktype,
+ &disk_to_dev(disk)->kobj, "%s", "integrity");
+ if (!ret)
+ kobject_uevent(&disk->integrity_kobj, KOBJ_ADD);
+ return ret;
}
void blk_integrity_del(struct gendisk *disk)
diff --git a/block/blk.h b/block/blk.h
index cd39fd0c93f1..80bb41a43120 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -134,7 +134,7 @@ static inline bool integrity_req_gap_front_merge(struct request *req,
bip_next->bip_vec[0].bv_offset);
}
-void blk_integrity_add(struct gendisk *);
+int blk_integrity_add(struct gendisk *disk);
void blk_integrity_del(struct gendisk *);
#else /* CONFIG_BLK_DEV_INTEGRITY */
static inline bool blk_integrity_merge_rq(struct request_queue *rq,
@@ -168,8 +168,9 @@ static inline bool bio_integrity_endio(struct bio *bio)
static inline void bio_integrity_free(struct bio *bio)
{
}
-static inline void blk_integrity_add(struct gendisk *disk)
+static inline int blk_integrity_add(struct gendisk *disk)
{
+ return 0;
}
static inline void blk_integrity_del(struct gendisk *disk)
{
From patchwork Wed Jan 26 08:35:30 2022
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Yu Kuai <yukuai3(a)huawei.com>
X-Patchwork-Id: 152663
Return-Path: <yukuai3(a)huawei.com>
Received: from dggems704-chm.china.huawei.com (10.3.19.181) by
dggems702-chm.china.huawei.com (10.3.19.179) with Microsoft SMTP Server
(version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
15.1.2308.21 via Mailbox Transport; Wed, 26 Jan 2022 16:24:56 +0800
Received: from kwepemm600009.china.huawei.com (7.193.23.164) by
dggems704-chm.china.huawei.com (10.3.19.181) with Microsoft SMTP Server
(version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
15.1.2308.21; Wed, 26 Jan 2022 16:24:55 +0800
Received: from huawei.com (10.175.127.227) by kwepemm600009.china.huawei.com
(7.193.23.164) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Wed, 26 Jan
2022 16:24:54 +0800
From: Yu Kuai <yukuai3(a)huawei.com>
To: <zhengzengkai(a)huawei.com>, <xiexiuqi(a)huawei.com>, <patchwork(a)huawei.com>
CC: <yukuai3(a)huawei.com>, <yi.zhang(a)huawei.com>, <houtao1(a)huawei.com>,
<chenxiaosong2(a)huawei.com>, <chengzhihao1(a)huawei.com>,
<libaokun1(a)huawei.com>, <luomeng12(a)huawei.com>, <yanaijie(a)huawei.com>,
<yangerkun(a)huawei.com>, <yebin10(a)huawei.com>, <yuyufen(a)huawei.com>,
<zhangxiaoxu5(a)huawei.com>, <zhengbin13(a)huawei.com>, <koulihong(a)huawei.com>,
<qiulaibin(a)huawei.com>, <zhengliang6(a)huawei.com>
Subject: [PATCH OLK-5.10 08/12] block: return errors from disk_alloc_events
Date: Wed, 26 Jan 2022 16:35:30 +0800
Message-ID: <20220126083534.4016012-9-yukuai3(a)huawei.com>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <20220126083534.4016012-1-yukuai3(a)huawei.com>
References: <20220126083534.4016012-1-yukuai3(a)huawei.com>
Content-Type: text/plain
X-MS-Exchange-Organization-Network-Message-Id:
2664ecdf-dfd3-496d-02da-08d9e0a55548
X-MS-Exchange-Organization-AuthSource: kwepemm600009.china.huawei.com
X-MS-Exchange-Organization-AuthAs: Internal
X-MS-Exchange-Organization-AuthMechanism: 07
X-Originating-IP: [10.175.127.227]
X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To
kwepemm600009.china.huawei.com (7.193.23.164)
X-MS-Exchange-Transport-EndToEndLatency: 00:00:01.7000588
X-MS-Exchange-Processed-By-BccFoldering: 15.01.2308.021
MIME-Version: 1.0
From: Luis Chamberlain <mcgrof(a)kernel.org>
mainline inclusion
from mainline-v5.15-rc1
commit 92e7755ebc69233e25a2d1b760aeff536dc4016b
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4SA9G
---------------------------
Prepare for proper error handling in add_disk.
Signed-off-by: Luis Chamberlain <mcgrof(a)kernel.org>
[hch: split from a larger patch]
Signed-off-by: Christoph Hellwig <hch(a)lst.de>
Reviewed-by: Hannes Reinecke <hare(a)suse.de>
Link: https://lore.kernel.org/r/20210818144542.19305-9-hch@lst.de
Signed-off-by: Jens Axboe <axboe(a)kernel.dk>
Signed-off-by: Yu Kuai <yukuai3(a)huawei.com>
---
block/genhd.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/block/genhd.c b/block/genhd.c
index aa109986a6b0..ec1e2fe27249 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -40,7 +40,7 @@ static DEFINE_IDR(ext_devt_idr);
static void disk_check_events(struct disk_events *ev,
unsigned int *clearing_ptr);
-static void disk_alloc_events(struct gendisk *disk);
+static int disk_alloc_events(struct gendisk *disk);
static void disk_add_events(struct gendisk *disk);
static void disk_del_events(struct gendisk *disk);
static void disk_release_events(struct gendisk *disk);
@@ -2311,17 +2311,17 @@ module_param_cb(events_dfl_poll_msecs, &disk_events_dfl_poll_msecs_param_ops,
/*
* disk_{alloc|add|del|release}_events - initialize and destroy disk_events.
*/
-static void disk_alloc_events(struct gendisk *disk)
+static int disk_alloc_events(struct gendisk *disk)
{
struct disk_events *ev;
if (!disk->fops->check_events || !disk->events)
- return;
+ return 0;
ev = kzalloc(sizeof(*ev), GFP_KERNEL);
if (!ev) {
pr_warn("%s: failed to initialize events\n", disk->disk_name);
- return;
+ return -ENOMEM;
}
INIT_LIST_HEAD(&ev->node);
@@ -2333,6 +2333,7 @@ static void disk_alloc_events(struct gendisk *disk)
INIT_DELAYED_WORK(&ev->dwork, disk_events_workfn);
disk->ev = ev;
+ return 0;
}
static void disk_add_events(struct gendisk *disk)
From patchwork Wed Jan 26 08:35:31 2022
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Yu Kuai <yukuai3(a)huawei.com>
X-Patchwork-Id: 152664
Return-Path: <yukuai3(a)huawei.com>
Received: from dggems706-chm.china.huawei.com (10.3.19.183) by
dggems702-chm.china.huawei.com (10.3.19.179) with Microsoft SMTP Server
(version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
15.1.2308.21 via Mailbox Transport; Wed, 26 Jan 2022 16:24:57 +0800
Received: from kwepemm600009.china.huawei.com (7.193.23.164) by
dggems706-chm.china.huawei.com (10.3.19.183) with Microsoft SMTP Server
(version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
15.1.2308.21; Wed, 26 Jan 2022 16:24:57 +0800
Received: from huawei.com (10.175.127.227) by kwepemm600009.china.huawei.com
(7.193.23.164) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Wed, 26 Jan
2022 16:24:55 +0800
From: Yu Kuai <yukuai3(a)huawei.com>
To: <zhengzengkai(a)huawei.com>, <xiexiuqi(a)huawei.com>, <patchwork(a)huawei.com>
CC: <yukuai3(a)huawei.com>, <yi.zhang(a)huawei.com>, <houtao1(a)huawei.com>,
<chenxiaosong2(a)huawei.com>, <chengzhihao1(a)huawei.com>,
<libaokun1(a)huawei.com>, <luomeng12(a)huawei.com>, <yanaijie(a)huawei.com>,
<yangerkun(a)huawei.com>, <yebin10(a)huawei.com>, <yuyufen(a)huawei.com>,
<zhangxiaoxu5(a)huawei.com>, <zhengbin13(a)huawei.com>, <koulihong(a)huawei.com>,
<qiulaibin(a)huawei.com>, <zhengliang6(a)huawei.com>
Subject: [PATCH OLK-5.10 09/12] block: refactor device number setup in
__device_add_disk
Date: Wed, 26 Jan 2022 16:35:31 +0800
Message-ID: <20220126083534.4016012-10-yukuai3(a)huawei.com>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <20220126083534.4016012-1-yukuai3(a)huawei.com>
References: <20220126083534.4016012-1-yukuai3(a)huawei.com>
Content-Type: text/plain
X-MS-Exchange-Organization-Network-Message-Id:
d9a6c01c-83ab-4afd-0792-08d9e0a55611
X-MS-Exchange-Organization-AuthSource: kwepemm600009.china.huawei.com
X-MS-Exchange-Organization-AuthAs: Internal
X-MS-Exchange-Organization-AuthMechanism: 07
X-Originating-IP: [10.175.127.227]
X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To
kwepemm600009.china.huawei.com (7.193.23.164)
X-MS-Exchange-Transport-EndToEndLatency: 00:00:01.8228257
X-MS-Exchange-Processed-By-BccFoldering: 15.01.2308.021
MIME-Version: 1.0
mainline inclusion
from mainline-v5.14-rc1
commit 7c3f828b522b07adb341b08fde1660685c5ba3eb
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4SA9G
---------------------------
Untangle the mess around blk_alloc_devt by moving the check for
the used allocation scheme into the callers.
Signed-off-by: Christoph Hellwig <hch(a)lst.de>
Reviewed-by: Hannes Reinecke <hare(a)suse.de>
Reviewed-by: Luis Chamberlain <mcgrof(a)kernel.org>
Reviewed-by: Ulf Hansson <ulf.hansson(a)linaro.org>
Link: https://lore.kernel.org/r/20210521055116.1053587-2-hch@lst.de
Signed-off-by: Jens Axboe <axboe(a)kernel.dk>
Signed-off-by: Yu Kuai <yukuai3(a)huawei.com>
---
block/blk.h | 4 +-
block/genhd.c | 89 +++++++++++++----------------------------
block/partitions/core.c | 16 ++++++--
3 files changed, 42 insertions(+), 67 deletions(-)
diff --git a/block/blk.h b/block/blk.h
index 80bb41a43120..88b00aa6e1c6 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -354,8 +354,8 @@ static inline void blk_queue_free_zone_bitmaps(struct request_queue *q) {}
struct hd_struct *disk_map_sector_rcu(struct gendisk *disk, sector_t sector);
-int blk_alloc_devt(struct hd_struct *part, dev_t *devt);
-void blk_free_devt(dev_t devt);
+int blk_alloc_ext_minor(struct hd_struct *part);
+void blk_free_ext_minor(unsigned int minor);
void blk_invalidate_devt(dev_t devt);
char *disk_name(struct gendisk *hd, int partno, char *buf);
#define ADDPART_FLAG_NONE 0
diff --git a/block/genhd.c b/block/genhd.c
index ec1e2fe27249..019641280df3 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -557,31 +557,10 @@ static int blk_mangle_minor(int minor)
return minor;
}
-/**
- * blk_alloc_devt - allocate a dev_t for a partition
- * @part: partition to allocate dev_t for
- * @devt: out parameter for resulting dev_t
- *
- * Allocate a dev_t for block device.
- *
- * RETURNS:
- * 0 on success, allocated dev_t is returned in *@devt. -errno on
- * failure.
- *
- * CONTEXT:
- * Might sleep.
- */
-int blk_alloc_devt(struct hd_struct *part, dev_t *devt)
+int blk_alloc_ext_minor(struct hd_struct *part)
{
- struct gendisk *disk = part_to_disk(part);
int idx;
- /* in consecutive minor range? */
- if (part->partno < disk->minors) {
- *devt = MKDEV(disk->major, disk->first_minor + part->partno);
- return 0;
- }
-
/* allocate ext devt */
idr_preload(GFP_KERNEL);
@@ -590,32 +569,20 @@ int blk_alloc_devt(struct hd_struct *part, dev_t *devt)
spin_unlock_bh(&ext_devt_lock);
idr_preload_end();
- if (idx < 0)
- return idx == -ENOSPC ? -EBUSY : idx;
+ if (idx < 0) {
+ if (idx == -ENOSPC)
+ return -EBUSY;
+ return idx;
+ }
- *devt = MKDEV(BLOCK_EXT_MAJOR, blk_mangle_minor(idx));
- return 0;
+ return blk_mangle_minor(idx);
}
-/**
- * blk_free_devt - free a dev_t
- * @devt: dev_t to free
- *
- * Free @devt which was allocated using blk_alloc_devt().
- *
- * CONTEXT:
- * Might sleep.
- */
-void blk_free_devt(dev_t devt)
+void blk_free_ext_minor(unsigned int minor)
{
- if (devt == MKDEV(0, 0))
- return;
-
- if (MAJOR(devt) == BLOCK_EXT_MAJOR) {
- spin_lock_bh(&ext_devt_lock);
- idr_remove(&ext_devt_idr, blk_mangle_minor(MINOR(devt)));
- spin_unlock_bh(&ext_devt_lock);
- }
+ spin_lock_bh(&ext_devt_lock);
+ idr_remove(&ext_devt_idr, blk_mangle_minor(minor));
+ spin_unlock_bh(&ext_devt_lock);
}
/*
@@ -719,7 +686,6 @@ static void __device_add_disk(struct device *parent, struct gendisk *disk,
struct device *ddev = disk_to_dev(disk);
struct disk_part_iter piter;
struct hd_struct *part;
- dev_t devt;
int ret;
/*
@@ -731,26 +697,25 @@ static void __device_add_disk(struct device *parent, struct gendisk *disk,
if (register_queue)
elevator_init_mq(disk->queue);
- /* minors == 0 indicates to use ext devt from part0 and should
- * be accompanied with EXT_DEVT flag. Make sure all
- * parameters make sense.
- */
- WARN_ON(disk->minors && !(disk->major || disk->first_minor));
- WARN_ON(!disk->minors &&
- !(disk->flags & (GENHD_FL_EXT_DEVT | GENHD_FL_HIDDEN)));
+ if (disk->major) {
+ WARN_ON(!disk->minors);
+ } else {
+ WARN_ON(disk->minors);
+ WARN_ON(!(disk->flags & (GENHD_FL_EXT_DEVT | GENHD_FL_HIDDEN)));
- ret = blk_alloc_devt(&disk->part0, &devt);
- if (ret) {
- WARN_ON(1);
- return;
+ ret = blk_alloc_ext_minor(&disk->part0);
+ if (ret < 0) {
+ WARN_ON(1);
+ return;
+ }
+ disk->major = BLOCK_EXT_MAJOR;
+ disk->first_minor = MINOR(ret);
}
- disk->major = MAJOR(devt);
- disk->first_minor = MINOR(devt);
disk_alloc_events(disk);
if (!(disk->flags & GENHD_FL_HIDDEN))
- ddev->devt = devt;
+ ddev->devt = MKDEV(disk->major, disk->first_minor);
/* delay uevents, until we scanned partition table */
dev_set_uevent_suppress(ddev, 1);
@@ -792,7 +757,8 @@ static void __device_add_disk(struct device *parent, struct gendisk *disk,
} else {
struct backing_dev_info *bdi = disk->queue->backing_dev_info;
- ret = bdi_register(bdi, "%u:%u", MAJOR(devt), MINOR(devt));
+ ret = bdi_register(bdi, "%u:%u",
+ disk->major, disk->first_minor);
WARN_ON(ret);
bdi_set_owner(bdi, ddev);
blk_register_region(disk_devt(disk), disk->minors, NULL,
@@ -1554,7 +1520,8 @@ static void disk_release(struct device *dev)
might_sleep();
- blk_free_devt(dev->devt);
+ if (MAJOR(dev->devt) == BLOCK_EXT_MAJOR)
+ blk_free_ext_minor(MINOR(dev->devt));
disk_release_events(disk);
kfree(disk->random);
disk_replace_part_tbl(disk, NULL);
diff --git a/block/partitions/core.c b/block/partitions/core.c
index 569b0ca9f6e1..68d75acc269a 100644
--- a/block/partitions/core.c
+++ b/block/partitions/core.c
@@ -258,7 +258,9 @@ static const struct attribute_group *part_attr_groups[] = {
static void part_release(struct device *dev)
{
struct hd_struct *p = dev_to_part(dev);
- blk_free_devt(dev->devt);
+
+ if (MAJOR(dev->devt) == BLOCK_EXT_MAJOR)
+ blk_free_ext_minor(MINOR(dev->devt));
hd_free_part(p);
kfree(p);
}
@@ -439,9 +441,15 @@ static struct hd_struct *add_partition(struct gendisk *disk, int partno,
pdev->type = &part_type;
pdev->parent = ddev;
- err = blk_alloc_devt(p, &devt);
- if (err)
- goto out_free_info;
+ /* in consecutive minor range? */
+ if (partno < disk->minors) {
+ devt = MKDEV(disk->major, disk->first_minor + partno);
+ } else {
+ err = blk_alloc_ext_minor(p);
+ if (err < 0)
+ goto out_free_info;
+ devt = MKDEV(BLOCK_EXT_MAJOR, err);
+ }
pdev->devt = devt;
/* delay uevent until 'holders' subdir is created */
From patchwork Wed Jan 26 08:35:32 2022
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Yu Kuai <yukuai3(a)huawei.com>
X-Patchwork-Id: 152665
Return-Path: <yukuai3(a)huawei.com>
Received: from dggems705-chm.china.huawei.com (10.3.19.182) by
dggems702-chm.china.huawei.com (10.3.19.179) with Microsoft SMTP Server
(version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
15.1.2308.21 via Mailbox Transport; Wed, 26 Jan 2022 16:24:58 +0800
Received: from kwepemm600009.china.huawei.com (7.193.23.164) by
dggems705-chm.china.huawei.com (10.3.19.182) with Microsoft SMTP Server
(version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
15.1.2308.21; Wed, 26 Jan 2022 16:24:58 +0800
Received: from huawei.com (10.175.127.227) by kwepemm600009.china.huawei.com
(7.193.23.164) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Wed, 26 Jan
2022 16:24:56 +0800
From: Yu Kuai <yukuai3(a)huawei.com>
To: <zhengzengkai(a)huawei.com>, <xiexiuqi(a)huawei.com>, <patchwork(a)huawei.com>
CC: <yukuai3(a)huawei.com>, <yi.zhang(a)huawei.com>, <houtao1(a)huawei.com>,
<chenxiaosong2(a)huawei.com>, <chengzhihao1(a)huawei.com>,
<libaokun1(a)huawei.com>, <luomeng12(a)huawei.com>, <yanaijie(a)huawei.com>,
<yangerkun(a)huawei.com>, <yebin10(a)huawei.com>, <yuyufen(a)huawei.com>,
<zhangxiaoxu5(a)huawei.com>, <zhengbin13(a)huawei.com>, <koulihong(a)huawei.com>,
<qiulaibin(a)huawei.com>, <zhengliang6(a)huawei.com>
Subject: [PATCH OLK-5.10 10/12] block: automatically enable GENHD_FL_EXT_DEVT
Date: Wed, 26 Jan 2022 16:35:32 +0800
Message-ID: <20220126083534.4016012-11-yukuai3(a)huawei.com>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <20220126083534.4016012-1-yukuai3(a)huawei.com>
References: <20220126083534.4016012-1-yukuai3(a)huawei.com>
Content-Type: text/plain
X-MS-Exchange-Organization-Network-Message-Id:
78c33535-647d-4416-5833-08d9e0a556da
X-MS-Exchange-Organization-AuthSource: kwepemm600009.china.huawei.com
X-MS-Exchange-Organization-AuthAs: Internal
X-MS-Exchange-Organization-AuthMechanism: 07
X-Originating-IP: [10.175.127.227]
X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To
kwepemm600009.china.huawei.com (7.193.23.164)
X-MS-Exchange-Transport-EndToEndLatency: 00:00:01.8541754
X-MS-Exchange-Processed-By-BccFoldering: 15.01.2308.021
MIME-Version: 1.0
From: Christoph Hellwig <hch(a)lst.de>
mainline inclusion
from mainline-v5.14-rc1
commit 0d1feb72ffd8578f6f167ca15b2096c276c1f6df
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4SA9G
---------------------------
Automatically set the GENHD_FL_EXT_DEVT flag for all disks allocated
without an explicit number of minors. This is what all new block
drivers should do, so make sure it is the default without boilerplate
code.
Signed-off-by: Christoph Hellwig <hch(a)lst.de>
Reviewed-by: Hannes Reinecke <hare(a)suse.de>
Reviewed-by: Luis Chamberlain <mcgrof(a)kernel.org>
Reviewed-by: Ulf Hansson <ulf.hansson(a)linaro.org>
Link: https://lore.kernel.org/r/20210521055116.1053587-4-hch@lst.de
Signed-off-by: Jens Axboe <axboe(a)kernel.dk>
Signed-off-by: Yu Kuai <yukuai3(a)huawei.com>
---
block/genhd.c | 2 +-
drivers/block/brd.c | 1 -
drivers/block/loop.c | 1 -
drivers/block/null_blk_main.c | 2 +-
drivers/block/rbd.c | 2 --
drivers/block/virtio_blk.c | 1 -
drivers/ide/ide-gd.c | 1 -
drivers/lightnvm/core.c | 1 -
drivers/md/md.c | 1 -
drivers/memstick/core/ms_block.c | 1 -
drivers/mmc/core/block.c | 1 -
drivers/nvdimm/blk.c | 1 -
drivers/nvdimm/btt.c | 1 -
drivers/nvdimm/pmem.c | 1 -
drivers/nvme/host/core.c | 2 +-
drivers/nvme/host/multipath.c | 1 -
drivers/scsi/sd.c | 1 -
17 files changed, 3 insertions(+), 18 deletions(-)
diff --git a/block/genhd.c b/block/genhd.c
index 019641280df3..c35bceed6870 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -701,7 +701,6 @@ static void __device_add_disk(struct device *parent, struct gendisk *disk,
WARN_ON(!disk->minors);
} else {
WARN_ON(disk->minors);
- WARN_ON(!(disk->flags & (GENHD_FL_EXT_DEVT | GENHD_FL_HIDDEN)));
ret = blk_alloc_ext_minor(&disk->part0);
if (ret < 0) {
@@ -710,6 +709,7 @@ static void __device_add_disk(struct device *parent, struct gendisk *disk,
}
disk->major = BLOCK_EXT_MAJOR;
disk->first_minor = MINOR(ret);
+ disk->flags |= GENHD_FL_EXT_DEVT;
}
disk_alloc_events(disk);
diff --git a/drivers/block/brd.c b/drivers/block/brd.c
index 085d1ff2bc03..395195edd5d7 100644
--- a/drivers/block/brd.c
+++ b/drivers/block/brd.c
@@ -411,7 +411,6 @@ static struct brd_device *brd_alloc(int i)
disk->first_minor = i * max_part;
disk->fops = &brd_fops;
disk->private_data = brd;
- disk->flags = GENHD_FL_EXT_DEVT;
strlcpy(disk->disk_name, buf, DISK_NAME_LEN);
set_capacity(disk, rd_size * 2);
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index e354faf7c9e6..b761afd294a2 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -2154,7 +2154,6 @@ static int loop_add(struct loop_device **l, int i)
*/
if (!part_shift)
disk->flags |= GENHD_FL_NO_PART_SCAN;
- disk->flags |= GENHD_FL_EXT_DEVT;
atomic_set(&lo->lo_refcnt, 0);
lo->lo_number = i;
spin_lock_init(&lo->lo_lock);
diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c
index bb3686c3869d..4279db5bef59 100644
--- a/drivers/block/null_blk_main.c
+++ b/drivers/block/null_blk_main.c
@@ -1692,7 +1692,7 @@ static int null_gendisk_register(struct nullb *nullb)
return -ENOMEM;
set_capacity(disk, size);
- disk->flags |= GENHD_FL_EXT_DEVT | GENHD_FL_SUPPRESS_PARTITION_INFO;
+ disk->flags |= GENHD_FL_SUPPRESS_PARTITION_INFO;
disk->major = null_major;
disk->first_minor = nullb->index;
if (queue_is_mq(nullb->q))
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 340b1df365f7..7249448b2a51 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -4973,8 +4973,6 @@ static int rbd_init_disk(struct rbd_device *rbd_dev)
rbd_dev->dev_id);
disk->major = rbd_dev->major;
disk->first_minor = rbd_dev->minor;
- if (single_major)
- disk->flags |= GENHD_FL_EXT_DEVT;
disk->fops = &rbd_bd_ops;
disk->private_data = rbd_dev;
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 42acf9587ef3..eba1d6e06ca2 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -794,7 +794,6 @@ static int virtblk_probe(struct virtio_device *vdev)
vblk->disk->first_minor = index_to_minor(index);
vblk->disk->private_data = vblk;
vblk->disk->fops = &virtblk_fops;
- vblk->disk->flags |= GENHD_FL_EXT_DEVT;
vblk->index = index;
/* configure queue flush support */
diff --git a/drivers/ide/ide-gd.c b/drivers/ide/ide-gd.c
index e2b6c82586ce..1c19f6830704 100644
--- a/drivers/ide/ide-gd.c
+++ b/drivers/ide/ide-gd.c
@@ -395,7 +395,6 @@ static int ide_gd_probe(ide_drive_t *drive)
set_capacity(g, ide_gd_capacity(drive));
g->minors = IDE_DISK_MINORS;
- g->flags |= GENHD_FL_EXT_DEVT;
if (drive->dev_flags & IDE_DFLAG_REMOVABLE)
g->flags = GENHD_FL_REMOVABLE;
g->fops = &ide_gd_ops;
diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
index 28ddcaa5358b..8903b7b57e61 100644
--- a/drivers/lightnvm/core.c
+++ b/drivers/lightnvm/core.c
@@ -383,7 +383,6 @@ static int nvm_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create)
}
strlcpy(tdisk->disk_name, create->tgtname, sizeof(tdisk->disk_name));
- tdisk->flags = GENHD_FL_EXT_DEVT;
tdisk->major = 0;
tdisk->first_minor = 0;
tdisk->fops = tt->bops;
diff --git a/drivers/md/md.c b/drivers/md/md.c
index a299fda5b0e9..1cc26fab10b1 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -5721,7 +5721,6 @@ static int md_alloc(dev_t dev, char *name)
* 'mdp' device redundant, but we can't really
* remove it now.
*/
- disk->flags |= GENHD_FL_EXT_DEVT;
disk->events |= DISK_EVENT_MEDIA_CHANGE;
mddev->gendisk = disk;
add_disk(disk);
diff --git a/drivers/memstick/core/ms_block.c b/drivers/memstick/core/ms_block.c
index bc1f484f50f1..0ca990f7ca3e 100644
--- a/drivers/memstick/core/ms_block.c
+++ b/drivers/memstick/core/ms_block.c
@@ -2136,7 +2136,6 @@ static int msb_init_disk(struct memstick_dev *card)
msb->disk->fops = &msb_bdops;
msb->disk->private_data = msb;
msb->disk->queue = msb->queue;
- msb->disk->flags |= GENHD_FL_EXT_DEVT;
capacity = msb->pages_in_block * msb->logical_block_count;
capacity *= (msb->page_size / 512);
diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index 94caee49da99..78a491ddcbf6 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -2347,7 +2347,6 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,
md->disk->queue = md->queue.queue;
md->parent = parent;
set_disk_ro(md->disk, md->read_only || default_ro);
- md->disk->flags = GENHD_FL_EXT_DEVT;
if (area_type & (MMC_BLK_DATA_AREA_RPMB | MMC_BLK_DATA_AREA_BOOT))
md->disk->flags |= GENHD_FL_NO_PART_SCAN
| GENHD_FL_SUPPRESS_PARTITION_INFO;
diff --git a/drivers/nvdimm/blk.c b/drivers/nvdimm/blk.c
index 22e5617b2cea..f1295f6896c9 100644
--- a/drivers/nvdimm/blk.c
+++ b/drivers/nvdimm/blk.c
@@ -267,7 +267,6 @@ static int nsblk_attach_disk(struct nd_namespace_blk *nsblk)
disk->first_minor = 0;
disk->fops = &nd_blk_fops;
disk->queue = q;
- disk->flags = GENHD_FL_EXT_DEVT;
disk->private_data = nsblk;
nvdimm_namespace_disk_name(&nsblk->common, disk->disk_name);
diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c
index 12ff6f8784ac..42d79a9a404f 100644
--- a/drivers/nvdimm/btt.c
+++ b/drivers/nvdimm/btt.c
@@ -1536,7 +1536,6 @@ static int btt_blk_init(struct btt *btt)
btt->btt_disk->fops = &btt_fops;
btt->btt_disk->private_data = btt;
btt->btt_disk->queue = btt->btt_queue;
- btt->btt_disk->flags = GENHD_FL_EXT_DEVT;
blk_queue_logical_block_size(btt->btt_queue, btt->sector_size);
blk_queue_max_hw_sectors(btt->btt_queue, UINT_MAX);
diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
index d5dd79b59b16..ca2a1967c070 100644
--- a/drivers/nvdimm/pmem.c
+++ b/drivers/nvdimm/pmem.c
@@ -476,7 +476,6 @@ static int pmem_attach_disk(struct device *dev,
disk->fops = &pmem_fops;
disk->queue = q;
- disk->flags = GENHD_FL_EXT_DEVT;
disk->private_data = pmem;
nvdimm_namespace_disk_name(ndns, disk->disk_name);
set_capacity(disk, (pmem->size - pmem->pfn_pad - pmem->data_offset)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 9ccf44592fe4..24d59b73ac3e 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -3825,7 +3825,7 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid,
struct gendisk *disk;
struct nvme_id_ns *id;
char disk_name[DISK_NAME_LEN];
- int node = ctrl->numa_node, flags = GENHD_FL_EXT_DEVT, ret;
+ int node = ctrl->numa_node, flags = 0, ret;
if (nvme_identify_ns(ctrl, nsid, ids, &id))
return;
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index 18a756444d5a..95a5222b3642 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -392,7 +392,6 @@ int nvme_mpath_alloc_disk(struct nvme_ctrl *ctrl, struct nvme_ns_head *head)
head->disk->fops = &nvme_ns_head_ops;
head->disk->private_data = head;
head->disk->queue = q;
- head->disk->flags = GENHD_FL_EXT_DEVT;
sprintf(head->disk->disk_name, "nvme%dn%d",
ctrl->subsys->instance, head->instance);
return 0;
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 3fc184e9702f..db7166fd05e1 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -3479,7 +3479,6 @@ static int sd_probe(struct device *dev)
sd_revalidate_disk(gd);
- gd->flags = GENHD_FL_EXT_DEVT;
if (sdp->removable) {
gd->flags |= GENHD_FL_REMOVABLE;
gd->events |= DISK_EVENT_MEDIA_CHANGE;
From patchwork Wed Jan 26 08:35:33 2022
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Yu Kuai <yukuai3(a)huawei.com>
X-Patchwork-Id: 152666
Return-Path: <yukuai3(a)huawei.com>
Received: from dggems701-chm.china.huawei.com (10.3.19.178) by
dggems702-chm.china.huawei.com (10.3.19.179) with Microsoft SMTP Server
(version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
15.1.2308.21 via Mailbox Transport; Wed, 26 Jan 2022 16:25:00 +0800
Received: from kwepemm600009.china.huawei.com (7.193.23.164) by
dggems701-chm.china.huawei.com (10.3.19.178) with Microsoft SMTP Server
(version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
15.1.2308.21; Wed, 26 Jan 2022 16:24:59 +0800
Received: from huawei.com (10.175.127.227) by kwepemm600009.china.huawei.com
(7.193.23.164) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Wed, 26 Jan
2022 16:24:58 +0800
From: Yu Kuai <yukuai3(a)huawei.com>
To: <zhengzengkai(a)huawei.com>, <xiexiuqi(a)huawei.com>, <patchwork(a)huawei.com>
CC: <yukuai3(a)huawei.com>, <yi.zhang(a)huawei.com>, <houtao1(a)huawei.com>,
<chenxiaosong2(a)huawei.com>, <chengzhihao1(a)huawei.com>,
<libaokun1(a)huawei.com>, <luomeng12(a)huawei.com>, <yanaijie(a)huawei.com>,
<yangerkun(a)huawei.com>, <yebin10(a)huawei.com>, <yuyufen(a)huawei.com>,
<zhangxiaoxu5(a)huawei.com>, <zhengbin13(a)huawei.com>, <koulihong(a)huawei.com>,
<qiulaibin(a)huawei.com>, <zhengliang6(a)huawei.com>
Subject: [PATCH OLK-5.10 11/12] block: add error handling for device_add_disk
/ add_disk
Date: Wed, 26 Jan 2022 16:35:33 +0800
Message-ID: <20220126083534.4016012-12-yukuai3(a)huawei.com>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <20220126083534.4016012-1-yukuai3(a)huawei.com>
References: <20220126083534.4016012-1-yukuai3(a)huawei.com>
Content-Type: text/plain
X-MS-Exchange-Organization-Network-Message-Id:
af00f8da-255b-48f7-afb7-08d9e0a557a7
X-MS-Exchange-Organization-AuthSource: kwepemm600009.china.huawei.com
X-MS-Exchange-Organization-AuthAs: Internal
X-MS-Exchange-Organization-AuthMechanism: 07
X-Originating-IP: [10.175.127.227]
X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To
kwepemm600009.china.huawei.com (7.193.23.164)
X-MS-Exchange-Transport-EndToEndLatency: 00:00:01.7770389
X-MS-Exchange-Processed-By-BccFoldering: 15.01.2308.021
MIME-Version: 1.0
hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4SA9G
---------------------------
Properly unwind on errors in device_add_disk. This is the initial work
as drivers are not converted yet, which will follow in separate patches.
Signed-off-by: Yu Kuai <yukuai3(a)huawei.com>
---
block/genhd.c | 91 +++++++++++++++++++++++++++++++++++----------------
1 file changed, 63 insertions(+), 28 deletions(-)
diff --git a/block/genhd.c b/block/genhd.c
index c35bceed6870..371fdd2e0786 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -676,10 +676,8 @@ static void disk_scan_partitions(struct gendisk *disk)
*
* This function registers the partitioning information in @disk
* with the kernel.
- *
- * FIXME: error handling
*/
-static void __device_add_disk(struct device *parent, struct gendisk *disk,
+static int __device_add_disk(struct device *parent, struct gendisk *disk,
const struct attribute_group **groups,
bool register_queue)
{
@@ -698,22 +696,20 @@ static void __device_add_disk(struct device *parent, struct gendisk *disk,
elevator_init_mq(disk->queue);
if (disk->major) {
- WARN_ON(!disk->minors);
+ if (WARN_ON(!disk->minors))
+ return -EINVAL;
} else {
- WARN_ON(disk->minors);
+ if (WARN_ON(disk->minors))
+ return -EINVAL;
ret = blk_alloc_ext_minor(&disk->part0);
- if (ret < 0) {
- WARN_ON(1);
- return;
- }
+ if (ret < 0)
+ return ret;
disk->major = BLOCK_EXT_MAJOR;
disk->first_minor = MINOR(ret);
disk->flags |= GENHD_FL_EXT_DEVT;
}
- disk_alloc_events(disk);
-
if (!(disk->flags & GENHD_FL_HIDDEN))
ddev->devt = MKDEV(disk->major, disk->first_minor);
@@ -724,15 +720,19 @@ static void __device_add_disk(struct device *parent, struct gendisk *disk,
ddev->groups = groups;
dev_set_name(ddev, "%s", disk->disk_name);
- if (device_add(ddev))
- return;
+ ret = device_add(ddev);
+ if (ret)
+ goto out_free_ext_minor;
+
+ ret = disk_alloc_events(disk);
+ if (ret)
+ goto out_device_del;
+
if (!sysfs_deprecated) {
ret = sysfs_create_link(block_depr, &ddev->kobj,
kobject_name(&ddev->kobj));
- if (ret) {
- device_del(ddev);
- return;
- }
+ if (ret)
+ goto out_device_del;
}
/*
@@ -742,10 +742,20 @@ static void __device_add_disk(struct device *parent, struct gendisk *disk,
*/
pm_runtime_set_memalloc_noio(ddev, true);
- blk_integrity_add(disk);
+ ret = blk_integrity_add(disk);
+ if (ret)
+ goto out_del_block_link;
disk->part0.holder_dir = kobject_create_and_add("holders", &ddev->kobj);
+ if (!disk->part0.holder_dir) {
+ ret = -ENOMEM;
+ goto out_del_integrity;
+ }
disk->slave_dir = kobject_create_and_add("slaves", &ddev->kobj);
+ if (!disk->slave_dir) {
+ ret = -ENOMEM;
+ goto out_put_holder_dir;
+ }
if (disk->flags & GENHD_FL_HIDDEN) {
/*
@@ -759,17 +769,17 @@ static void __device_add_disk(struct device *parent, struct gendisk *disk,
ret = bdi_register(bdi, "%u:%u",
disk->major, disk->first_minor);
- WARN_ON(ret);
+ if (ret)
+ goto out_put_slave_dir;
bdi_set_owner(bdi, ddev);
blk_register_region(disk_devt(disk), disk->minors, NULL,
exact_match, exact_lock, disk);
- if (disk->queue->backing_dev_info->dev) {
- ret = sysfs_create_link(&ddev->kobj,
- &disk->queue->backing_dev_info->dev->kobj,
- "bdi");
- WARN_ON(ret);
- }
+ ret = sysfs_create_link(&ddev->kobj,
+ &disk->queue->backing_dev_info->dev->kobj,
+ "bdi");
+ if (ret)
+ goto out_unregister_bdi;
disk_scan_partitions(disk);
@@ -784,8 +794,11 @@ static void __device_add_disk(struct device *parent, struct gendisk *disk,
disk_part_iter_exit(&piter);
}
- if (register_queue)
- blk_register_queue(disk);
+ if (register_queue) {
+ ret = blk_register_queue(disk);
+ if (ret)
+ goto out_del_bdi_link;
+ }
/*
* Take an extra ref on queue which will be put on disk_release()
@@ -794,8 +807,30 @@ static void __device_add_disk(struct device *parent, struct gendisk *disk,
WARN_ON_ONCE(!blk_get_queue(disk->queue));
disk_add_events(disk);
-
disk->flags |= GENHD_FL_UP;
+ return 0;
+
+out_del_bdi_link:
+ if (!(disk->flags & GENHD_FL_HIDDEN))
+ sysfs_remove_link(&ddev->kobj, "bdi");
+out_unregister_bdi:
+ if (!(disk->flags & GENHD_FL_HIDDEN))
+ bdi_unregister(disk->queue->backing_dev_info);
+out_put_slave_dir:
+ kobject_put(disk->slave_dir);
+out_put_holder_dir:
+ kobject_put(disk->part0.holder_dir);
+out_del_integrity:
+ blk_integrity_del(disk);
+out_del_block_link:
+ if (!sysfs_deprecated)
+ sysfs_remove_link(block_depr, dev_name(ddev));
+out_device_del:
+ device_del(ddev);
+out_free_ext_minor:
+ if (disk->major == BLOCK_EXT_MAJOR)
+ blk_free_ext_minor(disk->first_minor);
+ return WARN_ON_ONCE(ret); /* keep until all callers handle errors */
}
void device_add_disk(struct device *parent, struct gendisk *disk,
From patchwork Wed Jan 26 08:35:34 2022
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Yu Kuai <yukuai3(a)huawei.com>
X-Patchwork-Id: 152667
Return-Path: <yukuai3(a)huawei.com>
Received: from dggems702-chm.china.huawei.com (10.3.19.179) by
dggems702-chm.china.huawei.com (10.3.19.179) with Microsoft SMTP Server
(version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
15.1.2308.21 via Mailbox Transport; Wed, 26 Jan 2022 16:25:01 +0800
Received: from kwepemm600009.china.huawei.com (7.193.23.164) by
dggems702-chm.china.huawei.com (10.3.19.179) with Microsoft SMTP Server
(version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
15.1.2308.21; Wed, 26 Jan 2022 16:25:01 +0800
Received: from huawei.com (10.175.127.227) by kwepemm600009.china.huawei.com
(7.193.23.164) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Wed, 26 Jan
2022 16:24:59 +0800
From: Yu Kuai <yukuai3(a)huawei.com>
To: <zhengzengkai(a)huawei.com>, <xiexiuqi(a)huawei.com>, <patchwork(a)huawei.com>
CC: <yukuai3(a)huawei.com>, <yi.zhang(a)huawei.com>, <houtao1(a)huawei.com>,
<chenxiaosong2(a)huawei.com>, <chengzhihao1(a)huawei.com>,
<libaokun1(a)huawei.com>, <luomeng12(a)huawei.com>, <yanaijie(a)huawei.com>,
<yangerkun(a)huawei.com>, <yebin10(a)huawei.com>, <yuyufen(a)huawei.com>,
<zhangxiaoxu5(a)huawei.com>, <zhengbin13(a)huawei.com>, <koulihong(a)huawei.com>,
<qiulaibin(a)huawei.com>, <zhengliang6(a)huawei.com>
Subject: [PATCH OLK-5.10 12/12] sd: don't mess with SD_MINORS for
CONFIG_DEBUG_BLOCK_EXT_DEVT
Date: Wed, 26 Jan 2022 16:35:34 +0800
Message-ID: <20220126083534.4016012-13-yukuai3(a)huawei.com>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <20220126083534.4016012-1-yukuai3(a)huawei.com>
References: <20220126083534.4016012-1-yukuai3(a)huawei.com>
Content-Type: text/plain
X-MS-Exchange-Organization-Network-Message-Id:
a409ac94-39e4-47fd-25f8-08d9e0a55871
X-MS-Exchange-Organization-AuthSource: kwepemm600009.china.huawei.com
X-MS-Exchange-Organization-AuthAs: Internal
X-MS-Exchange-Organization-AuthMechanism: 07
X-Originating-IP: [10.175.127.227]
X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To
kwepemm600009.china.huawei.com (7.193.23.164)
X-MS-Exchange-Transport-EndToEndLatency: 00:00:01.7893204
X-MS-Exchange-Processed-By-BccFoldering: 15.01.2308.021
MIME-Version: 1.0
From: Christoph Hellwig <hch(a)lst.de>
mainline inclusion
from mainline-v5.14-rc2
commit 7fef2edf7cc753b51f7ccc74993971b0a9c81eca
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4SA9G
---------------------------
No need to give up the original sd minor even with this option,
and if we did we'd also need to fix the number of minors for
this configuration to actually work.
Fixes: 7c3f828b522b0 ("block: refactor device number setup in __device_add_disk")
Reported-by: Guenter Roeck <linux(a)roeck-us.net>
Signed-off-by: Christoph Hellwig <hch(a)lst.de>
Tested-by: Guenter Roeck <linux(a)roeck-us.net>
Signed-off-by: Linus Torvalds <torvalds(a)linux-foundation.org>
Signed-off-by: Yu Kuai <yukuai3(a)huawei.com>
---
drivers/scsi/sd.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index db7166fd05e1..2dfa5a34b048 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -98,11 +98,7 @@ MODULE_ALIAS_SCSI_DEVICE(TYPE_MOD);
MODULE_ALIAS_SCSI_DEVICE(TYPE_RBC);
MODULE_ALIAS_SCSI_DEVICE(TYPE_ZBC);
-#if !defined(CONFIG_DEBUG_BLOCK_EXT_DEVT)
#define SD_MINORS 16
-#else
-#define SD_MINORS 0
-#endif
static void sd_config_discard(struct scsi_disk *, unsigned int);
static void sd_config_write_same(struct scsi_disk *);
1
0

[PATCH openEuler-5.10] lib/iov_iter: initialize "flags" in new pipe_buffer
by Zheng Zengkai 08 Mar '22
by Zheng Zengkai 08 Mar '22
08 Mar '22
From: Max Kellermann <max.kellermann(a)ionos.com>
mainline inclusion
from mainline-v5.17-rc6
commit 9d2231c5d74e13b2a0546fee6737ee4446017903
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4WUKP?from=project-issue
CVE: CVE-2022-0847
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/l…
--------------------------------
The functions copy_page_to_iter_pipe() and push_pipe() can both
allocate a new pipe_buffer, but the "flags" member initializer is
missing.
Fixes: 241699cd72a8 ("new iov_iter flavour: pipe-backed")
To: Alexander Viro <viro(a)zeniv.linux.org.uk>
To: linux-fsdevel(a)vger.kernel.org
To: linux-kernel(a)vger.kernel.org
Cc: stable(a)vger.kernel.org
Signed-off-by: Max Kellermann <max.kellermann(a)ionos.com>
Signed-off-by: Al Viro <viro(a)zeniv.linux.org.uk>
Signed-off-by: Zhihao Cheng <chengzhihao1(a)huawei.com>
Reviewed-by: Zhang Yi <yi.zhang(a)huawei.com>
Signed-off-by: Zheng Zengkai <zhengzengkai(a)huawei.com>
---
lib/iov_iter.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index b364231b5fc8..1b0a349fbcd9 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -407,6 +407,7 @@ static size_t copy_page_to_iter_pipe(struct page *page, size_t offset, size_t by
return 0;
buf->ops = &page_cache_pipe_buf_ops;
+ buf->flags = 0;
get_page(page);
buf->page = page;
buf->offset = offset;
@@ -543,6 +544,7 @@ static size_t push_pipe(struct iov_iter *i, size_t size,
break;
buf->ops = &default_pipe_buf_ops;
+ buf->flags = 0;
buf->page = page;
buf->offset = 0;
buf->len = min_t(ssize_t, left, PAGE_SIZE);
--
2.20.1
1
0

[PATCH openEuler-1.0-LTS] hugetlbfs: fix a truncation issue in hugepages parameter
by Yang Yingliang 08 Mar '22
by Yang Yingliang 08 Mar '22
08 Mar '22
From: Liu Yuntao <liuyuntao10(a)huawei.com>
mainline inclusion
from mainline-v5.17-rc6
commit e79ce9832316e09529b212a21278d68240ccbf1f
category: bugfix
bugzilla: 186043
CVE: NA
-------------------------------------------------
When we specify a large number for node in hugepages parameter, it may
be parsed to another number due to truncation in this statement:
node = tmp;
For example, add following parameter in command line:
hugepagesz=1G hugepages=4294967297:5
and kernel will allocate 5 hugepages for node 1 instead of ignoring it.
I move the validation check earlier to fix this issue, and slightly
simplifies the condition here.
Link: https://lkml.kernel.org/r/20220209134018.8242-1-liuyuntao10@huawei.com
Fixes: b5389086ad7be0 ("hugetlbfs: extend the definition of hugepages parameter to support node allocation")
Signed-off-by: Liu Yuntao <liuyuntao10(a)huawei.com>
Reviewed-by: Mike Kravetz <mike.kravetz(a)oracle.com>
Cc: <stable(a)vger.kernel.org>
Signed-off-by: Andrew Morton <akpm(a)linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds(a)linux-foundation.org>
Signed-off-by: Liu Shixin <liushixin2(a)huawei.com>
Reviewed-by: Kefeng Wang <wangkefeng.wang(a)huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang(a)huawei.com>
---
mm/hugetlb.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index f7e41390f3d8b..68cec97bbd066 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -3151,10 +3151,10 @@ static int __init hugetlb_nrpages_setup(char *s)
pr_warn("HugeTLB: architecture can't support node specific alloc, ignoring!\n");
return 0;
}
+ if (tmp >= nr_online_nodes)
+ goto invalid;
node = tmp;
p += count + 1;
- if (node < 0 || node >= nr_online_nodes)
- goto invalid;
/* Parse hugepages */
if (sscanf(p, "%lu%n", &tmp, &count) != 1)
goto invalid;
--
2.25.1
1
0