f2fs: quota: fix potential deadlock
Subsystems (5)
Sasha Levin
maintainerPATCH 1/7 f2fs: quota: fix potential deadlock
From: Chao Yu <[email protected]>
[ Upstream commit a5c0042200b28fff3bde6fa128ddeaef97990f8d ]
As Yi Zhuang reported in bugzilla:
https://bugzilla.kernel.org/show_bug.cgi?id=214299
There is potential deadlock during quota data flush as below:
Thread A: Thread B:f2fs_dquot_acquiredown_read(&sbi->quota_sem)
f2fs_write_checkpoint block_operations f2fs_look_all down_write(&sbi->cp_rwsem)
f2fs_quota_writef2fs_write_begin__do_map_lockf2fs_lock_opdown_read(&sbi->cp_rwsem)
__need_flush_qutoa down_write(&sbi->quota_sem)
This patch changes block_operations() to use trylock, if it fails, it means there is potential quota data updater, in this condition, let's flush quota data first and then trylock again to check dirty status of quota data.
The side effect is: in heavy race condition (e.g. multi quota data upaters vs quota data flusher), it may decrease the probability of synchronizing quota data successfully in checkpoint() due to limited retry time of quota flush.
--- fs/f2fs/checkpoint.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/checkpoint.c +2 -1
@@ -1162,7 +1162,8 @@ static bool __need_flush_quota(struct f2fs_sb_info *sbi)if (!is_journalled_quota (sbi))return false; -down_write (&sbi->quota_sem); +if (!down_write_trylock (&sbi->quota_sem)) +return true;if (is_sbi_flag_set (sbi,SBI_QUOTA_SKIP_FLUSH )) { ret = false; }else if (is_sbi_flag_set (sbi,SBI_QUOTA_NEED_REPAIR )) {
Signature · 8 lines
2.33.0 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Sasha Levin
maintainerPATCH 2/7 f2fs: set SBI_NEED_FSCK flag when inconsistent node block found
From: Weichao Guo <[email protected]>
[ Upstream commit 6663b138ded1a59e630c9e605e42aa7fde490cdc ]
Inconsistent node block will cause a file fail to open or read, which could make the user process crashes or stucks. Let's mark SBI_NEED_FSCK flag to trigger a fix at next fsck time. After unlinking the corrupted file, the user process could regenerate a new one and work correctly.
--- fs/f2fs/node.c | 1 + 1 file changed, 1 insertion(+)
fs/f2fs/node.c +1 -0
@@ -1443,6 +1443,7 @@ static struct page *__get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid, nid,nid_of_node (page),ino_of_node (page),ofs_of_node (page),cpver_of_node (page), next_blkaddr_of_node(page)); +set_sbi_flag (sbi,SBI_NEED_FSCK ); err = -EINVAL ; out_err:ClearPageUptodate (page);
Signature · 8 lines
2.33.0 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Sasha Levin
maintainerPATCH 3/7 riscv: dts: microchip: fix board compatible
In reply to Sasha LevinFrom: Krzysztof Kozlowski <[email protected]>
[ Upstream commit fd86dd2a5dc5ff1044423c19fef3907862f591c4 ]
According to bindings, the compatible must include microchip,mpfs. This fixes dtbs_check warning:
arch/riscv/boot/dts/microchip/microchip-mpfs-icicle-kit.dt.yaml: /: compatible: ['microchip,mpfs-icicle-kit'] is too short
--- arch/riscv/boot/dts/microchip/microchip-mpfs-icicle-kit.dts | 2 +- arch/riscv/boot/dts/microchip/microchip-mpfs.dtsi | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
arch/riscv/boot/dts/microchip/microchip-mpfs-icicle-kit.dts +1 -1
@@ -12,7 +12,7 @@ / { #address-cells = <2>; #size-cells = <2>; model = "Microchip PolarFire-SoC Icicle Kit"; - compatible = "microchip,mpfs-icicle-kit"; + compatible = "microchip,mpfs-icicle-kit", "microchip,mpfs"; aliases { ethernet0 = &emac1;
arch/riscv/boot/dts/microchip/microchip-mpfs.dtsi +2 -2
@@ -6,8 +6,8 @@ / { #address-cells = <2>; #size-cells = <2>; - model = "Microchip MPFS Icicle Kit"; - compatible = "microchip,mpfs-icicle-kit"; + model = "Microchip PolarFire SoC"; + compatible = "microchip,mpfs"; chosen { };
Signature · 7 lines
2.33.0 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
Sasha Levin
maintainerPATCH 4/7 riscv: dts: microchip: drop duplicated MMC/SDHC node
In reply to Sasha LevinFrom: Krzysztof Kozlowski <[email protected]>
[ Upstream commit 42a57a47bb0c0f531321a7001972a3ca121409bd ]
Devicetree source is a description of hardware and hardware has only one block @20008000 which can be configured either as eMMC or SDHC. Having two node for different modes is an obscure, unusual and confusing way to configure it. Instead the board file is supposed to customize the block to its needs, e.g. to SDHC mode.
This fixes dtbs_check warning:
arch/riscv/boot/dts/microchip/microchip-mpfs-icicle-kit.dt.yaml: sdhc@20008000: $nodename:0: 'sdhc@20008000' does not match '^mmc(@.*)?$'
--- .../microchip/microchip-mpfs-icicle-kit.dts | 11 ++++++- .../boot/dts/microchip/microchip-mpfs.dtsi | 29 ++----------------- 2 files changed, 12 insertions(+), 28 deletions(-)
arch/riscv/boot/dts/microchip/microchip-mpfs-icicle-kit.dts +10 -1
@@ -56,8 +56,17 @@ &serial3 { status = "okay"; }; -&sdcard { +&mmc { status = "okay"; + + bus-width = <4>; + disable-wp; + cap-sd-highspeed; + card-detect-delay = <200>; + sd-uhs-sdr12; + sd-uhs-sdr25; + sd-uhs-sdr50; + sd-uhs-sdr104; }; &emac0 {
arch/riscv/boot/dts/microchip/microchip-mpfs.dtsi +2 -27
@@ -262,39 +262,14 @@ serial3: serial@20104000 { status = "disabled"; }; - emmc: mmc@20008000 { + /* Common node entry for emmc/sd */ + mmc: mmc@20008000 { compatible = "cdns,sd4hc"; reg = <0x0 0x20008000 0x0 0x1000>; interrupt-parent = <&plic>; interrupts = <88 89>; pinctrl-names = "default"; clocks = <&clkcfg 6>; - bus-width = <4>; - cap-mmc-highspeed; - mmc-ddr-3_3v; - max-frequency = <200000000>; - non-removable; - no-sd; - no-sdio; - voltage-ranges = <3300 3300>; - status = "disabled"; - }; - - sdcard: sdhc@20008000 { - compatible = "cdns,sd4hc"; - reg = <0x0 0x20008000 0x0 0x1000>; - interrupt-parent = <&plic>; - interrupts = <88>; - pinctrl-names = "default"; - clocks = <&clkcfg 6>; - bus-width = <4>; - disable-wp; - cap-sd-highspeed; - card-detect-delay = <200>; - sd-uhs-sdr12; - sd-uhs-sdr25; - sd-uhs-sdr50; - sd-uhs-sdr104; max-frequency = <200000000>; status = "disabled"; };
Signature · 7 lines
2.33.0 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
Sasha Levin
maintainerPATCH 5/7 cifs: nosharesock should not share socket with future sessions
In reply to Sasha LevinFrom: Shyam Prasad N <[email protected]>
[ Upstream commit c9f1c19cf7c50949885fa5afdb2cb242d61a7fac ]
Today, when a new mount is done with nosharesock, we ensure that we don't select an existing matching session. However, we don't mark the connection as nosharesock, which means that those could be shared with future sessions.
Fixed it with this commit. Also printing this info in DebugData.
--- fs/cifs/cifs_debug.c | 2 ++ fs/cifs/cifsglob.h | 1 + fs/cifs/connect.c | 8 +++++++- 3 files changed, 10 insertions(+), 1 deletion(-)
fs/cifs/cifs_debug.c +2 -0
@@ -358,6 +358,8 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v)seq_printf (m," signed" );if (server->posix_ext_supported)seq_printf (m," posix" ); +if (server->nosharesock) +seq_printf (m," nosharesock" );if (server->rdma)seq_printf (m,"\nRDMA " );
fs/cifs/cifsglob.h +1 -0
@@ -592,6 +592,7 @@ struct TCP_Server_Info {struct list_head pending_mid_q;bool noblocksnd;/* use blocking sendmsg */ bool noautotune;/* do not autotune send buf sizes */ +bool nosharesock;bool tcp_nodelay;unsigned int credits;/* send no more requests at once */ unsigned int max_credits;/* can override large 32000 default at mnt */
fs/cifs/connect.c +7 -1
@@ -1217,7 +1217,13 @@ static int match_server(struct TCP_Server_Info *server, struct smb3_fs_context * {struct sockaddr *addr = (struct sockaddr *)&ctx->dstaddr; -if (ctx->nosharesock) +if (ctx->nosharesock) { + server->nosharesock = true; +return 0 ; + } + +/* this server does not share socket */ +if (server->nosharesock)return 0 ;/* If multidialect negotiation see if existing sessions match one */
Signature · 1 line
2.33.0
Sasha Levin
maintainerPATCH 6/7 ceph: properly handle statfs on multifs setups
In reply to Sasha LevinFrom: Jeff Layton <[email protected]>
[ Upstream commit 8cfc0c7ed34f7929ce7e5d7c6eecf4d01ba89a84 ]
ceph_statfs currently stuffs the cluster fsid into the f_fsid field. This was fine when we only had a single filesystem per cluster, but now that we have multiples we need to use something that will vary between them.
Change ceph_statfs to xor each 32-bit chunk of the fsid (aka cluster id) into the lower bits of the statfs->f_fsid. Change the lower bits to hold the fscid (filesystem ID within the cluster).
That should give us a value that is guaranteed to be unique between filesystems within a cluster, and should minimize the chance of collisions between mounts of different clusters.
URL: https://tracker.ceph.com/issues/52812
--- fs/ceph/super.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
fs/ceph/super.c +6 -5
@@ -52,8 +52,7 @@ static int ceph_statfs(struct dentry *dentry, struct kstatfs *buf)struct ceph_fs_client *fsc =ceph_inode_to_client (d_inode (dentry));struct ceph_mon_client *monc = &fsc->client->monc;struct ceph_statfs st; -u64 fsid; -int err; +int i, err;u64 data_pool;if (fsc->mdsc->mdsmap->m_num_data_pg_pools ==1 ) {
@@ -99,12 +98,14 @@ static int ceph_statfs(struct dentry *dentry, struct kstatfs *buf) buf->f_namelen =NAME_MAX ;/* Must convert the fsid, for consistent values across arches */ + buf->f_fsid.val[0 ] =0 ;mutex_lock (&monc->mutex); - fsid =le64_to_cpu (*(__le64 *)(&monc->monmap->fsid)) ^ -le64_to_cpu (*((__le64 *)&monc->monmap->fsid +1 )); +for (i =0 ; i <sizeof (monc->monmap->fsid) /sizeof (__le32) ; ++i) + buf->f_fsid.val[0 ] ^=le32_to_cpu (((__le32 *)&monc->monmap->fsid)[i]);mutex_unlock (&monc->mutex); - buf->f_fsid =u64_to_fsid (fsid); +/* fold the fs_cluster_id into the upper bits */ + buf->f_fsid.val[1 ] = monc->fs_cluster_id;return 0 ; }
Signature · 1 line
2.33.0
Sasha Levin
maintainerPATCH 7/7 virtio-mem: support VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE
In reply to Sasha LevinFrom: David Hildenbrand <[email protected]>
[ Upstream commit 61082ad6a6e1f999eef7e7e90046486c87933b1e ]
The initial virtio-mem spec states that while unplugged memory should not be read, the device still has to allow for reading unplugged memory inside the usable region. The primary motivation for this default handling was to simplify bringup of virtio-mem, because there were corner cases where Linux might have accidentially read unplugged memory inside added Linux memory blocks.
In the meantime, we:
1. Removed /dev/kmem in commit bbcd53c96071 ("drivers/char: remove /dev/kmem for good")
2. Disallowed access to virtio-mem device memory via /dev/mem in commit 2128f4e21aa2 ("virtio-mem: disallow mapping virtio-mem memory via /dev/mem")
3. Sanitized access to virtio-mem device memory via /proc/kcore in commit 0daa322b8ff9 ("fs/proc/kcore: don't read offline sections, logically offline pages and hwpoisoned pages")
4. Sanitized access to virtio-mem device memory via /proc/vmcore in commit ce2814622e84 ("virtio-mem: kdump mode to sanitize /proc/vmcore access")
"Accidential" access to unplugged memory is no longer possible; we can support the new VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE feature that will be required by some hypervisors implementing virtio-mem in the near future.
--- drivers/virtio/virtio_mem.c | 1 + include/uapi/linux/virtio_mem.h | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-)
drivers/virtio/virtio_mem.c +1 -0
@@ -2758,6 +2758,7 @@ static unsigned int virtio_mem_features[] = { #if defined(CONFIG_NUMA) && defined(CONFIG_ACPI_NUMA) VIRTIO_MEM_F_ACPI_PXM, #endif + VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE, }; static const struct virtio_device_id virtio_mem_id_table[] = {
include/uapi/linux/virtio_mem.h +6 -3
@@ -68,9 +68,10 @@* explicitly triggered (VIRTIO_MEM_REQ_UNPLUG). * * There are no guarantees what will happen if unplugged memory is -* read/written. Such memory should, in general, not be touched. E.g., -* even writing might succeed, but the values will simply be discarded at -* random points in time. +* read/written. In general, unplugged memory should not be touched, because +* the resulting action is undefined. There is one exception: without +* VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE, unplugged memory inside the usable +* region can be read, to simplify creation of memory dumps. * * It can happen that the device cannot process a request, because it is * busy. The device driver has to retry later.
@@ -87,6 +88,8 @@/* node_id is an ACPI PXM and is valid */ #define VIRTIO_MEM_F_ACPI_PXM 0 +/* unplugged memory must not be accessed */ +#define VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE 1/* --- virtio-mem: guest -> host requests --- */
Signature · 6 lines
2.33.0 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH AUTOSEL 5.15 7/7] virtio-mem: support VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE
Quoted 75 lines · Sasha Levin
From: David Hildenbrand <[email protected]>
[ Upstream commit
61082ad6a6e1f999eef7e7e90046486c87933b1e]The initial virtio-mem spec states that while unplugged memory should not be read, the device still has to allow for reading unplugged memory inside the usable region. The primary motivation for this default handling was to simplify bringup of virtio-mem, because there were corner cases where Linux might have accidentially read unplugged memory inside added Linux memory blocks.
In the meantime, we:
1. Removed/dev/kmemin commitbbcd53c96071("drivers/char: remove/dev/kmemfor good")
2. Disallowed access to virtio-mem device memory via/dev/memin commit2128f4e21aa2("virtio-mem: disallow mapping virtio-mem memory via/dev/mem")
3. Sanitized access to virtio-mem device memory via/proc/kcorein commit0daa322b8ff9("fs/proc/kcore: don't read offline sections, logically offline pages and hwpoisoned pages")
4. Sanitized access to virtio-mem device memory via/proc/vmcorein commitce2814622e84("virtio-mem: kdump mode to sanitize/proc/vmcoreaccess")"Accidential" access to unplugged memory is no longer possible; we can support the new
VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLEfeature that will be required by some hypervisors implementing virtio-mem in the near future.Cc "Michael S. Tsirkin" <[email protected]>Cc Jason Wang <[email protected]>Cc Marek Kedzierski <[email protected]>Cc Hui Zhu <[email protected]>Cc Sebastien Boeuf <[email protected]>Cc Pankaj Gupta <[email protected]>Cc Wei Yang <[email protected]>Signed-off-by David Hildenbrand <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- drivers/virtio/virtio_mem.c | 1 + include/uapi/linux/virtio_mem.h | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-)drivers/virtio/virtio_mem.c +1
-0@@ -2758,6 +2758,7 @@ static unsigned int virtio_mem_features[] = { #if defined(CONFIG_NUMA) && defined(CONFIG_ACPI_NUMA) VIRTIO_MEM_F_ACPI_PXM, #endif + VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE, }; static const struct virtio_device_id virtio_mem_id_table[] = {include/uapi/linux/virtio_mem.h +4
-3@@ -68,9 +68,10 @@* explicitly triggered (VIRTIO_MEM_REQ_UNPLUG). * * There are no guarantees what will happen if unplugged memory is -* read/written. Such memory should, in general, not be touched. E.g., -* even writing might succeed, but the values will simply be discarded at -* random points in time. +* read/written. In general, unplugged memory should not be touched, because +* the resulting action is undefined. There is one exception: without +* VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE, unplugged memory inside the usable +* region can be read, to simplify creation of memory dumps. * * It can happen that the device cannot process a request, because it is * busy. The device driver has to retry later.
include/uapi/linux/virtio_mem.h line 95
Quoted 8 lines
include/uapi/linux/virtio_mem.h +2
-0@@ -87,6 +88,8 @@/* node_id is an ACPI PXM and is valid */ #define VIRTIO_MEM_F_ACPI_PXM 0 +/* unplugged memory must not be accessed */ +#define VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE 1/* --- virtio-mem: guest -> host requests --- */
As 2. and 4. are part of v5.16-rc1 but not v5.15-stable
Signature · 8 lines
Thanks, David / dhildenb _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Sasha Levin
maintainerRe: [PATCH AUTOSEL 5.15 7/7] virtio-mem: support VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE
Quoted 82 lines · David Hildenbrand
Quoted 81 lines · Sasha Levin
From: David Hildenbrand <[email protected]>
[ Upstream commit
61082ad6a6e1f999eef7e7e90046486c87933b1e]The initial virtio-mem spec states that while unplugged memory should not be read, the device still has to allow for reading unplugged memory inside the usable region. The primary motivation for this default handling was to simplify bringup of virtio-mem, because there were corner cases where Linux might have accidentially read unplugged memory inside added Linux memory blocks.
In the meantime, we:
1. Removed/dev/kmemin commitbbcd53c96071("drivers/char: remove/dev/kmemfor good")
2. Disallowed access to virtio-mem device memory via/dev/memin commit2128f4e21aa2("virtio-mem: disallow mapping virtio-mem memory via/dev/mem")
3. Sanitized access to virtio-mem device memory via/proc/kcorein commit0daa322b8ff9("fs/proc/kcore: don't read offline sections, logically offline pages and hwpoisoned pages")
4. Sanitized access to virtio-mem device memory via/proc/vmcorein commitce2814622e84("virtio-mem: kdump mode to sanitize/proc/vmcoreaccess")"Accidential" access to unplugged memory is no longer possible; we can support the new
VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLEfeature that will be required by some hypervisors implementing virtio-mem in the near future.Cc "Michael S. Tsirkin" <[email protected]>Cc Jason Wang <[email protected]>Cc Marek Kedzierski <[email protected]>Cc Hui Zhu <[email protected]>Cc Sebastien Boeuf <[email protected]>Cc Pankaj Gupta <[email protected]>Cc Wei Yang <[email protected]>Signed-off-by David Hildenbrand <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- drivers/virtio/virtio_mem.c | 1 + include/uapi/linux/virtio_mem.h | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-)drivers/virtio/virtio_mem.c +1
-0@@ -2758,6 +2758,7 @@ static unsigned int virtio_mem_features[] = { #if defined(CONFIG_NUMA) && defined(CONFIG_ACPI_NUMA) VIRTIO_MEM_F_ACPI_PXM, #endif + VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE, }; static const struct virtio_device_id virtio_mem_id_table[] = {include/uapi/linux/virtio_mem.h +6
-3@@ -68,9 +68,10 @@* explicitly triggered (VIRTIO_MEM_REQ_UNPLUG). * * There are no guarantees what will happen if unplugged memory is -* read/written. Such memory should, in general, not be touched. E.g., -* even writing might succeed, but the values will simply be discarded at -* random points in time. +* read/written. In general, unplugged memory should not be touched, because +* the resulting action is undefined. There is one exception: without +* VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE, unplugged memory inside the usable +* region can be read, to simplify creation of memory dumps. * * It can happen that the device cannot process a request, because it is * busy. The device driver has to retry later. @@ -87,6 +88,8 @@/* node_id is an ACPI PXM and is valid */ #define VIRTIO_MEM_F_ACPI_PXM 0 +/* unplugged memory must not be accessed */ +#define VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE 1
Quoted 6 lines
include/uapi/linux/virtio_mem.h line 95
Quoted 2 lines
include/uapi/linux/virtio_mem.h +0
-0/* --- virtio-mem: guest -> host requests --- */ As 2. and 4. are part of v5.16-rc1 but not v5.15-stable
Nacked-by David Hildenbrand <[email protected]>
I'll drop them, thanks!
Signature · 6 lines
Thanks, Sasha _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization