All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hou Tao <houtao@huaweicloud.com>
To: linux-cachefs@redhat.com
Cc: Jeff Layton <jlayton@kernel.org>,
	linux-kernel@vger.kernel.org, David Howells <dhowells@redhat.com>,
	houtao1@huawei.com, linux-fsdevel@vger.kernel.org,
	linux-erofs@lists.ozlabs.org
Subject: [PATCH v3 2/2] fscache: Use clear_and_wake_up_bit() in fscache_create_volume_work()
Date: Fri, 13 Jan 2023 19:52:11 +0800	[thread overview]
Message-ID: <20230113115211.2895845-3-houtao@huaweicloud.com> (raw)
In-Reply-To: <20230113115211.2895845-1-houtao@huaweicloud.com>

From: Hou Tao <houtao1@huawei.com>

fscache_create_volume_work() uses wake_up_bit() to wake up the processes
which are waiting for the completion of volume creation. According to
comments in wake_up_bit() and waitqueue_active(), an extra smp_mb() is
needed to guarantee the memory order between FSCACHE_VOLUME_CREATING
flag and waitqueue_active() before invoking wake_up_bit().

Fixing it by using clear_and_wake_up_bit() to add the missing memory
barrier.

Reviewed-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Signed-off-by: Hou Tao <houtao1@huawei.com>
---
 fs/fscache/volume.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/fscache/volume.c b/fs/fscache/volume.c
index 903af9d85f8b..cdf991bdd9de 100644
--- a/fs/fscache/volume.c
+++ b/fs/fscache/volume.c
@@ -280,8 +280,7 @@ static void fscache_create_volume_work(struct work_struct *work)
 	fscache_end_cache_access(volume->cache,
 				 fscache_access_acquire_volume_end);
 
-	clear_bit_unlock(FSCACHE_VOLUME_CREATING, &volume->flags);
-	wake_up_bit(&volume->flags, FSCACHE_VOLUME_CREATING);
+	clear_and_wake_up_bit(FSCACHE_VOLUME_CREATING, &volume->flags);
 	fscache_put_volume(volume, fscache_volume_put_create_work);
 }
 
-- 
2.29.2


WARNING: multiple messages have this Message-ID (diff)
From: Hou Tao <houtao@huaweicloud.com>
To: linux-cachefs@redhat.com
Cc: David Howells <dhowells@redhat.com>,
	Jeff Layton <jlayton@kernel.org>,
	linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Jingbo Xu <jefflexu@linux.alibaba.com>,
	houtao1@huawei.com
Subject: [PATCH v3 2/2] fscache: Use clear_and_wake_up_bit() in fscache_create_volume_work()
Date: Fri, 13 Jan 2023 19:52:11 +0800	[thread overview]
Message-ID: <20230113115211.2895845-3-houtao@huaweicloud.com> (raw)
In-Reply-To: <20230113115211.2895845-1-houtao@huaweicloud.com>

From: Hou Tao <houtao1@huawei.com>

fscache_create_volume_work() uses wake_up_bit() to wake up the processes
which are waiting for the completion of volume creation. According to
comments in wake_up_bit() and waitqueue_active(), an extra smp_mb() is
needed to guarantee the memory order between FSCACHE_VOLUME_CREATING
flag and waitqueue_active() before invoking wake_up_bit().

Fixing it by using clear_and_wake_up_bit() to add the missing memory
barrier.

Reviewed-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Signed-off-by: Hou Tao <houtao1@huawei.com>
---
 fs/fscache/volume.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/fscache/volume.c b/fs/fscache/volume.c
index 903af9d85f8b..cdf991bdd9de 100644
--- a/fs/fscache/volume.c
+++ b/fs/fscache/volume.c
@@ -280,8 +280,7 @@ static void fscache_create_volume_work(struct work_struct *work)
 	fscache_end_cache_access(volume->cache,
 				 fscache_access_acquire_volume_end);
 
-	clear_bit_unlock(FSCACHE_VOLUME_CREATING, &volume->flags);
-	wake_up_bit(&volume->flags, FSCACHE_VOLUME_CREATING);
+	clear_and_wake_up_bit(FSCACHE_VOLUME_CREATING, &volume->flags);
 	fscache_put_volume(volume, fscache_volume_put_create_work);
 }
 
-- 
2.29.2


  parent reply	other threads:[~2023-01-13 11:24 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-13 11:52 [PATCH v3 0/2] Fixes for fscache volume operations Hou Tao
2023-01-13 11:52 ` Hou Tao
2023-01-13 11:52 ` [PATCH v3 1/2] fscache: Use wait_on_bit() to wait for the freeing of relinquished volume Hou Tao
2023-01-13 11:52   ` Hou Tao
2023-01-13 15:27   ` Jeff Layton
2023-01-13 15:27     ` Jeff Layton
2023-01-13 11:52 ` Hou Tao [this message]
2023-01-13 11:52   ` [PATCH v3 2/2] fscache: Use clear_and_wake_up_bit() in fscache_create_volume_work() Hou Tao
2023-01-13 15:28   ` Jeff Layton
2023-01-13 15:28     ` Jeff Layton
2023-01-30 10:56 ` [PATCH v3 0/2] Fixes for fscache volume operations Hou Tao
2023-01-30 10:56   ` Hou Tao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230113115211.2895845-3-houtao@huaweicloud.com \
    --to=houtao@huaweicloud.com \
    --cc=dhowells@redhat.com \
    --cc=houtao1@huawei.com \
    --cc=jlayton@kernel.org \
    --cc=linux-cachefs@redhat.com \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.