From: Demi Marie Obenour <demi@invisiblethingslab.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: "Demi Marie Obenour" <demi@invisiblethingslab.com>,
"Marek Marczykowski-Górecki" <marmarek@invisiblethingslab.com>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [RFC PATCH 4/7] Increment diskseq when releasing a loop device
Date: Wed, 25 Jan 2023 22:33:56 -0500 [thread overview]
Message-ID: <20230126033358.1880-5-demi@invisiblethingslab.com> (raw)
In-Reply-To: <20230126033358.1880-1-demi@invisiblethingslab.com>
This ensures that userspace is aware that the device may now point to
something else.
Signed-off-by: Demi Marie Obenour <demi@invisiblethingslab.com>
---
block/genhd.c | 1 +
drivers/block/loop.c | 6 ++++++
2 files changed, 7 insertions(+)
diff --git a/block/genhd.c b/block/genhd.c
index 23cf83b3331cdea5c916fbf01cb5b92aeb2f7cf8..5bf7664273c66d04b40730434f17f7b65fbfe101 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -1490,3 +1490,4 @@ void inc_diskseq(struct gendisk *disk)
{
disk->diskseq = atomic64_inc_return(&diskseq);
}
+EXPORT_SYMBOL(inc_diskseq);
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 1518a6423279bc890221e8184a8f2e420cb16715..f862b0ab1dce43b3617b1381be8e2de3aab828b1 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -1205,6 +1205,12 @@ static void __loop_clr_fd(struct loop_device *lo, bool release)
if (!part_shift)
set_bit(GD_SUPPRESS_PART_SCAN, &lo->lo_disk->state);
mutex_lock(&lo->lo_mutex);
+
+ /*
+ * Increment the disk sequence number, so that userspace knows this
+ * device now points to something else.
+ */
+ inc_diskseq(lo->lo_disk);
lo->lo_state = Lo_unbound;
mutex_unlock(&lo->lo_mutex);
--
Sincerely,
Demi Marie Obenour (she/her/hers)
Invisible Things Lab
next prev parent reply other threads:[~2023-01-26 3:34 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-26 3:33 [RFC PATCH 0/7] Allow race-free block device handling Demi Marie Obenour
2023-01-26 3:33 ` [RFC PATCH 1/7] block: Support creating a struct file from a block device Demi Marie Obenour
2023-01-30 8:08 ` Christoph Hellwig
2023-01-30 19:22 ` Demi Marie Obenour
2023-01-31 8:53 ` Christoph Hellwig
2023-01-31 16:27 ` Demi Marie Obenour
2023-02-01 7:45 ` Christoph Hellwig
2023-02-01 16:18 ` Demi Marie Obenour
2023-02-02 8:49 ` Ming Lei
2023-02-02 17:24 ` Demi Marie Obenour
2023-01-26 3:33 ` [RFC PATCH 2/7] Allow userspace to get an FD to a newly-created DM device Demi Marie Obenour
2023-01-26 3:33 ` [RFC PATCH 3/7] Implement diskseq checks in blkback Demi Marie Obenour
2023-01-26 3:33 ` Demi Marie Obenour [this message]
2023-01-30 8:09 ` [RFC PATCH 4/7] Increment diskseq when releasing a loop device Christoph Hellwig
2023-01-26 3:33 ` [RFC PATCH 6/7] Minor blkback cleanups Demi Marie Obenour
2023-01-26 3:33 ` [RFC PATCH 7/7] xen/blkback: Inform userspace that device has been opened Demi Marie Obenour
2023-02-02 16:50 ` [RFC PATCH 0/7] Allow race-free block device handling Mike Snitzer
2023-02-02 18:41 ` Demi Marie Obenour
2023-02-02 19:56 ` Mike Snitzer
2023-02-02 20:57 ` Demi Marie Obenour
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=20230126033358.1880-5-demi@invisiblethingslab.com \
--to=demi@invisiblethingslab.com \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marmarek@invisiblethingslab.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).