fuse: remove unneeded lock which protecting update of congestion_threshold
authorKemeng Shi <shikemeng@huaweicloud.com>
Sat, 7 Oct 2023 15:39:56 +0000 (23:39 +0800)
committerMiklos Szeredi <mszeredi@redhat.com>
Wed, 6 Mar 2024 10:07:51 +0000 (11:07 +0100)
Commit 670d21c6e17f6 ("fuse: remove reliance on bdi congestion") change how
congestion_threshold is used and lock in
fuse_conn_congestion_threshold_write is not needed anymore.
1. Access to supe_block is removed along with removing of bdi congestion.
Then down_read(&fc->killsb) which protecting access to super_block is no
needed.
2. Compare num_background and congestion_threshold without holding
bg_lock. Then there is no need to hold bg_lock to update
congestion_threshold.

Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
fs/fuse/control.c

index 284a3500646296dab9a4dd8883159c8a24b9f82f..97ac994ff78f1daca5b8cc25ef2f5bb7210577db 100644 (file)
@@ -174,11 +174,7 @@ static ssize_t fuse_conn_congestion_threshold_write(struct file *file,
        if (!fc)
                goto out;
 
-       down_read(&fc->killsb);
-       spin_lock(&fc->bg_lock);
-       fc->congestion_threshold = val;
-       spin_unlock(&fc->bg_lock);
-       up_read(&fc->killsb);
+       WRITE_ONCE(fc->congestion_threshold, val);
        fuse_conn_put(fc);
 out:
        return ret;