Hello,
this patch series implements the idea of blkdev_get_by_*() calls returning
bdev_handle which is then passed to blkdev_put() [1]. This makes the get
and put calls for bdevs more obviously matching and allows us to propagate
context from get to put without having to modify all the users (again!).
In particular I need to propagate used open flags to blkdev_put() to be able
count writeable opens and add support for blocking writes to mounted block
devices. I'll send that series separately.
The series is based on Linus' tree as of yesterday + two bcache fixes which are
in the block tree. Patches have passed some basic testing, I plan to test more
users once we agree this is the right way to go.
Honza
[1] https://lore.kernel.org/all/[email protected]
CC: Alasdair Kergon <[email protected]>
CC: Andrew Morton <[email protected]>
CC: Anna Schumaker <[email protected]>
CC: Chao Yu <[email protected]>
CC: Christian Borntraeger <[email protected]>
CC: Coly Li <[email protected]
CC: "Darrick J. Wong" <[email protected]>
CC: Dave Kleikamp <[email protected]>
CC: David Sterba <[email protected]>
CC: [email protected]
CC: [email protected]
CC: Gao Xiang <[email protected]>
CC: Jack Wang <[email protected]>
CC: Jaegeuk Kim <[email protected]>
CC: [email protected]
CC: Joern Engel <[email protected]>
CC: Joseph Qi <[email protected]>
CC: Kent Overstreet <[email protected]>
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: <[email protected]>
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: "Md. Haris Iqbal" <[email protected]>
CC: Mike Snitzer <[email protected]>
CC: Minchan Kim <[email protected]>
CC: [email protected]
CC: [email protected]
CC: Sergey Senozhatsky <[email protected]>
CC: Song Liu <[email protected]>
CC: Sven Schnelle <[email protected]>
CC: [email protected]
CC: Ted Tso <[email protected]>
CC: Trond Myklebust <[email protected]>
CC: [email protected]
Create struct bdev_handle that contains all parameters that need to be
passed to blkdev_put() and provide blkdev_get_handle_* functions that
return this structure instead of plain bdev pointer. This will
eventually allow us to pass one more argument to blkdev_put() without
too much hassle.
CC: Alasdair Kergon <[email protected]>
CC: Andrew Morton <[email protected]>
CC: Anna Schumaker <[email protected]>
CC: Chao Yu <[email protected]>
CC: Christian Borntraeger <[email protected]>
CC: Coly Li <[email protected]
CC: "Darrick J. Wong" <[email protected]>
CC: Dave Kleikamp <[email protected]>
CC: David Sterba <[email protected]>
CC: [email protected]
CC: [email protected]
CC: Gao Xiang <[email protected]>
CC: Jack Wang <[email protected]>
CC: Jaegeuk Kim <[email protected]>
CC: [email protected]
CC: Joern Engel <[email protected]>
CC: Joseph Qi <[email protected]>
CC: Kent Overstreet <[email protected]>
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: <[email protected]>
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: "Md. Haris Iqbal" <[email protected]>
CC: Mike Snitzer <[email protected]>
CC: Minchan Kim <[email protected]>
CC: [email protected]
CC: [email protected]
CC: Sergey Senozhatsky <[email protected]>
CC: Song Liu <[email protected]>
CC: Sven Schnelle <[email protected]>
CC: [email protected]
CC: Ted Tso <[email protected]>
CC: Trond Myklebust <[email protected]>
CC: [email protected]
Signed-off-by: Jan Kara <[email protected]>
---
block/bdev.c | 47 ++++++++++++++++++++++++++++++++++++++++++
include/linux/blkdev.h | 10 +++++++++
2 files changed, 57 insertions(+)
diff --git a/block/bdev.c b/block/bdev.c
index 979e28a46b98..c75de5cac2bc 100644
--- a/block/bdev.c
+++ b/block/bdev.c
@@ -846,6 +846,24 @@ struct block_device *blkdev_get_by_dev(dev_t dev, blk_mode_t mode, void *holder,
}
EXPORT_SYMBOL(blkdev_get_by_dev);
+struct bdev_handle *blkdev_get_handle_by_dev(dev_t dev, blk_mode_t mode,
+ void *holder, const struct blk_holder_ops *hops)
+{
+ struct bdev_handle *handle = kmalloc(sizeof(struct bdev_handle),
+ GFP_KERNEL);
+ struct block_device *bdev;
+
+ if (!handle)
+ return ERR_PTR(-ENOMEM);
+ bdev = blkdev_get_by_dev(dev, mode, holder, hops);
+ if (IS_ERR(bdev))
+ return ERR_CAST(bdev);
+ handle->bdev = bdev;
+ handle->holder = holder;
+ return handle;
+}
+EXPORT_SYMBOL(blkdev_get_handle_by_dev);
+
/**
* blkdev_get_by_path - open a block device by name
* @path: path to the block device to open
@@ -884,6 +902,28 @@ struct block_device *blkdev_get_by_path(const char *path, blk_mode_t mode,
}
EXPORT_SYMBOL(blkdev_get_by_path);
+struct bdev_handle *blkdev_get_handle_by_path(const char *path, blk_mode_t mode,
+ void *holder, const struct blk_holder_ops *hops)
+{
+ struct bdev_handle *handle;
+ dev_t dev;
+ int error;
+
+ error = lookup_bdev(path, &dev);
+ if (error)
+ return ERR_PTR(error);
+
+ handle = blkdev_get_handle_by_dev(dev, mode, holder, hops);
+ if (!IS_ERR(handle) && (mode & BLK_OPEN_WRITE) &&
+ bdev_read_only(handle->bdev)) {
+ blkdev_handle_put(handle);
+ return ERR_PTR(-EACCES);
+ }
+
+ return handle;
+}
+EXPORT_SYMBOL(blkdev_get_handle_by_path);
+
void blkdev_put(struct block_device *bdev, void *holder)
{
struct gendisk *disk = bdev->bd_disk;
@@ -920,6 +960,13 @@ void blkdev_put(struct block_device *bdev, void *holder)
}
EXPORT_SYMBOL(blkdev_put);
+void blkdev_handle_put(struct bdev_handle *handle)
+{
+ blkdev_put(handle->bdev, handle->holder);
+ kfree(handle);
+}
+EXPORT_SYMBOL(blkdev_handle_put);
+
/**
* lookup_bdev() - Look up a struct block_device by name.
* @pathname: Name of the block device in the filesystem.
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index ed44a997f629..a910e9997ddd 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1471,14 +1471,24 @@ struct blk_holder_ops {
#define sb_open_mode(flags) \
(BLK_OPEN_READ | (((flags) & SB_RDONLY) ? 0 : BLK_OPEN_WRITE))
+struct bdev_handle {
+ struct block_device *bdev;
+ void *holder;
+};
+
struct block_device *blkdev_get_by_dev(dev_t dev, blk_mode_t mode, void *holder,
const struct blk_holder_ops *hops);
struct block_device *blkdev_get_by_path(const char *path, blk_mode_t mode,
void *holder, const struct blk_holder_ops *hops);
+struct bdev_handle *blkdev_get_handle_by_dev(dev_t dev, blk_mode_t mode,
+ void *holder, const struct blk_holder_ops *hops);
+struct bdev_handle *blkdev_get_handle_by_path(const char *path, blk_mode_t mode,
+ void *holder, const struct blk_holder_ops *hops);
int bd_prepare_to_claim(struct block_device *bdev, void *holder,
const struct blk_holder_ops *hops);
void bd_abort_claiming(struct block_device *bdev, void *holder);
void blkdev_put(struct block_device *bdev, void *holder);
+void blkdev_handle_put(struct bdev_handle *handle);
/* just for blk-cgroup, don't use elsewhere */
struct block_device *blkdev_get_no_open(dev_t dev);
--
2.35.3
Convert ext4 to use blkdev_get_handle_by_dev() and pass the handle
around.
CC: <[email protected]>
CC: Ted Tso <[email protected]>
Signed-off-by: Jan Kara <[email protected]>
---
fs/ext4/ext4.h | 2 +-
fs/ext4/fsmap.c | 9 +++++----
fs/ext4/super.c | 40 ++++++++++++++++++++--------------------
3 files changed, 26 insertions(+), 25 deletions(-)
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 0a2d55faa095..72bad004841b 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -1535,7 +1535,7 @@ struct ext4_sb_info {
unsigned long s_commit_interval;
u32 s_max_batch_time;
u32 s_min_batch_time;
- struct block_device *s_journal_bdev;
+ struct bdev_handle *s_journal_bdev_handle;
#ifdef CONFIG_QUOTA
/* Names of quota files with journalled quota */
char __rcu *s_qf_names[EXT4_MAXQUOTAS];
diff --git a/fs/ext4/fsmap.c b/fs/ext4/fsmap.c
index cdf9bfe10137..11e6f33677a2 100644
--- a/fs/ext4/fsmap.c
+++ b/fs/ext4/fsmap.c
@@ -576,8 +576,9 @@ static bool ext4_getfsmap_is_valid_device(struct super_block *sb,
if (fm->fmr_device == 0 || fm->fmr_device == UINT_MAX ||
fm->fmr_device == new_encode_dev(sb->s_bdev->bd_dev))
return true;
- if (EXT4_SB(sb)->s_journal_bdev &&
- fm->fmr_device == new_encode_dev(EXT4_SB(sb)->s_journal_bdev->bd_dev))
+ if (EXT4_SB(sb)->s_journal_bdev_handle &&
+ fm->fmr_device ==
+ new_encode_dev(EXT4_SB(sb)->s_journal_bdev_handle->bdev->bd_dev))
return true;
return false;
}
@@ -647,9 +648,9 @@ int ext4_getfsmap(struct super_block *sb, struct ext4_fsmap_head *head,
memset(handlers, 0, sizeof(handlers));
handlers[0].gfd_dev = new_encode_dev(sb->s_bdev->bd_dev);
handlers[0].gfd_fn = ext4_getfsmap_datadev;
- if (EXT4_SB(sb)->s_journal_bdev) {
+ if (EXT4_SB(sb)->s_journal_bdev_handle) {
handlers[1].gfd_dev = new_encode_dev(
- EXT4_SB(sb)->s_journal_bdev->bd_dev);
+ EXT4_SB(sb)->s_journal_bdev_handle->bdev->bd_dev);
handlers[1].gfd_fn = ext4_getfsmap_logdev;
}
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index c94ebf704616..a3b982d6abf1 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1108,20 +1108,20 @@ static const struct blk_holder_ops ext4_holder_ops = {
/*
* Open the external journal device
*/
-static struct block_device *ext4_blkdev_get(dev_t dev, struct super_block *sb)
+static struct bdev_handle *ext4_blkdev_get(dev_t dev, struct super_block *sb)
{
- struct block_device *bdev;
+ struct bdev_handle *handle;
- bdev = blkdev_get_by_dev(dev, BLK_OPEN_READ | BLK_OPEN_WRITE, sb,
- &ext4_holder_ops);
- if (IS_ERR(bdev))
+ handle = blkdev_get_handle_by_dev(dev, BLK_OPEN_READ | BLK_OPEN_WRITE,
+ sb, &ext4_holder_ops);
+ if (IS_ERR(handle))
goto fail;
- return bdev;
+ return handle;
fail:
ext4_msg(sb, KERN_ERR,
"failed to open journal device unknown-block(%u,%u) %ld",
- MAJOR(dev), MINOR(dev), PTR_ERR(bdev));
+ MAJOR(dev), MINOR(dev), PTR_ERR(handle));
return NULL;
}
@@ -1130,17 +1130,15 @@ static struct block_device *ext4_blkdev_get(dev_t dev, struct super_block *sb)
*/
static void ext4_blkdev_remove(struct ext4_sb_info *sbi)
{
- struct block_device *bdev;
- bdev = sbi->s_journal_bdev;
- if (bdev) {
+ if (sbi->s_journal_bdev_handle) {
/*
* Invalidate the journal device's buffers. We don't want them
* floating about in memory - the physical journal device may
* hotswapped, and it breaks the `ro-after' testing code.
*/
- invalidate_bdev(bdev);
- blkdev_put(bdev, sbi->s_sb);
- sbi->s_journal_bdev = NULL;
+ invalidate_bdev(sbi->s_journal_bdev_handle->bdev);
+ blkdev_handle_put(sbi->s_journal_bdev_handle);
+ sbi->s_journal_bdev_handle = NULL;
}
}
@@ -1338,8 +1336,8 @@ static void ext4_put_super(struct super_block *sb)
sync_blockdev(sb->s_bdev);
invalidate_bdev(sb->s_bdev);
- if (sbi->s_journal_bdev) {
- sync_blockdev(sbi->s_journal_bdev);
+ if (sbi->s_journal_bdev_handle) {
+ sync_blockdev(sbi->s_journal_bdev_handle->bdev);
ext4_blkdev_remove(sbi);
}
@@ -4227,7 +4225,7 @@ int ext4_calculate_overhead(struct super_block *sb)
* Add the internal journal blocks whether the journal has been
* loaded or not
*/
- if (sbi->s_journal && !sbi->s_journal_bdev)
+ if (sbi->s_journal && !sbi->s_journal_bdev_handle)
overhead += EXT4_NUM_B2C(sbi, sbi->s_journal->j_total_len);
else if (ext4_has_feature_journal(sb) && !sbi->s_journal && j_inum) {
/* j_inum for internal journal is non-zero */
@@ -5850,14 +5848,16 @@ static journal_t *ext4_get_dev_journal(struct super_block *sb,
unsigned long offset;
struct ext4_super_block *es;
struct block_device *bdev;
+ struct bdev_handle *bdev_handle;
if (WARN_ON_ONCE(!ext4_has_feature_journal(sb)))
return NULL;
- bdev = ext4_blkdev_get(j_dev, sb);
- if (bdev == NULL)
+ bdev_handle = ext4_blkdev_get(j_dev, sb);
+ if (!bdev_handle)
return NULL;
+ bdev = bdev_handle->bdev;
blocksize = sb->s_blocksize;
hblock = bdev_logical_block_size(bdev);
if (blocksize < hblock) {
@@ -5921,14 +5921,14 @@ static journal_t *ext4_get_dev_journal(struct super_block *sb,
be32_to_cpu(journal->j_superblock->s_nr_users));
goto out_journal;
}
- EXT4_SB(sb)->s_journal_bdev = bdev;
+ EXT4_SB(sb)->s_journal_bdev_handle = bdev_handle;
ext4_init_journal_params(sb, journal);
return journal;
out_journal:
jbd2_journal_destroy(journal);
out_bdev:
- blkdev_put(bdev, sb);
+ blkdev_handle_put(bdev_handle);
return NULL;
}
--
2.35.3
On Tue, Jul 04, 2023 at 02:21:28PM +0200, Jan Kara wrote:
> +struct bdev_handle *blkdev_get_handle_by_dev(dev_t dev, blk_mode_t mode,
> + void *holder, const struct blk_holder_ops *hops)
> +{
> + struct bdev_handle *handle = kmalloc(sizeof(struct bdev_handle),
> + GFP_KERNEL);
> + struct block_device *bdev;
> +
> + if (!handle)
> + return ERR_PTR(-ENOMEM);
> + bdev = blkdev_get_by_dev(dev, mode, holder, hops);
> + if (IS_ERR(bdev))
> + return ERR_CAST(bdev);
Would we be better off with a handle->error (and a NULL return from this
function means "we couldn't allocate a handle")? I have no objection
to what you've done here, just wondering if it might end up nicer for
the users.
On Tue 04-07-23 13:43:51, Matthew Wilcox wrote:
> On Tue, Jul 04, 2023 at 02:21:28PM +0200, Jan Kara wrote:
> > +struct bdev_handle *blkdev_get_handle_by_dev(dev_t dev, blk_mode_t mode,
> > + void *holder, const struct blk_holder_ops *hops)
> > +{
> > + struct bdev_handle *handle = kmalloc(sizeof(struct bdev_handle),
> > + GFP_KERNEL);
> > + struct block_device *bdev;
> > +
> > + if (!handle)
> > + return ERR_PTR(-ENOMEM);
> > + bdev = blkdev_get_by_dev(dev, mode, holder, hops);
> > + if (IS_ERR(bdev))
> > + return ERR_CAST(bdev);
>
> Would we be better off with a handle->error (and a NULL return from this
> function means "we couldn't allocate a handle")? I have no objection
> to what you've done here, just wondering if it might end up nicer for
> the users.
Hum, I've checked a couple of users and it seems it would be more
complicated for the users to handle this convention than the one I've
chosen. And that one is also pretty standard so I think by the principle of
least surprise it is also better.
Honza
>
--
Jan Kara <[email protected]>
SUSE Labs, CR
On 7/4/23 05:21, Jan Kara wrote:
> +struct bdev_handle {
> + struct block_device *bdev;
> + void *holder;
> +};
Please explain in the patch description why a holder pointer is
introduced in struct bdev_handle and how it relates to the bd_holder
pointer in struct block_device. Is one of the purposes of this patch
series perhaps to add support for multiple holders per block device?
Thanks,
Bart.
On Tue 04-07-23 10:28:36, Keith Busch wrote:
> On Tue, Jul 04, 2023 at 02:21:28PM +0200, Jan Kara wrote:
> > +struct bdev_handle *blkdev_get_handle_by_dev(dev_t dev, blk_mode_t mode,
> > + void *holder, const struct blk_holder_ops *hops)
> > +{
> > + struct bdev_handle *handle = kmalloc(sizeof(struct bdev_handle),
> > + GFP_KERNEL);
>
> I believe 'sizeof(*handle)' is the preferred style.
OK.
> > + struct block_device *bdev;
> > +
> > + if (!handle)
> > + return ERR_PTR(-ENOMEM);
> > + bdev = blkdev_get_by_dev(dev, mode, holder, hops);
> > + if (IS_ERR(bdev))
> > + return ERR_CAST(bdev);
>
> Need a 'kfree(handle)' before the error return. Or would it be simpler
> to get the bdev first so you can check the mode settings against a
> read-only bdev prior to the kmalloc?
Yeah. Good point with kfree(). I'm not sure calling blkdev_get_by_dev()
first will be "simpler" - then we need blkdev_put() in case of kmalloc()
failure. Thanks for review!
Honza
--
Jan Kara <[email protected]>
SUSE Labs, CR
On 7/4/23 09:14, Matthew Wilcox wrote:
> On Tue, Jul 04, 2023 at 07:06:26AM -0700, Bart Van Assche wrote:
>> On 7/4/23 05:21, Jan Kara wrote:
>>> +struct bdev_handle {
>>> + struct block_device *bdev;
>>> + void *holder;
>>> +};
>>
>> Please explain in the patch description why a holder pointer is introduced
>> in struct bdev_handle and how it relates to the bd_holder pointer in struct
>> block_device. Is one of the purposes of this patch series perhaps to add
>> support for multiple holders per block device?
>
> That is all in patch 0/32. Why repeat it?
This cover letter: https://lore.kernel.org/linux-block/[email protected]/T/#t?
The word "holder" doesn't even occur in that cover letter so how could the
answer to my question be present in the cover letter?
Bart.
On Tue, Jul 04, 2023 at 02:21:27PM +0200, Jan Kara wrote:
> Hello,
>
> this patch series implements the idea of blkdev_get_by_*() calls returning
> bdev_handle which is then passed to blkdev_put() [1]. This makes the get
> and put calls for bdevs more obviously matching and allows us to propagate
> context from get to put without having to modify all the users (again!).
> In particular I need to propagate used open flags to blkdev_put() to be able
> count writeable opens and add support for blocking writes to mounted block
> devices. I'll send that series separately.
>
> The series is based on Linus' tree as of yesterday + two bcache fixes which are
> in the block tree. Patches have passed some basic testing, I plan to test more
> users once we agree this is the right way to go.
Can you post a link to a git branch for this and the follow up series?
Especially with a fairly unstable base it's kinda hard to look at the
result otherwise.
On Tue, Jul 04, 2023 at 02:21:28PM +0200, Jan Kara wrote:
> Create struct bdev_handle that contains all parameters that need to be
> passed to blkdev_put() and provide blkdev_get_handle_* functions that
> return this structure instead of plain bdev pointer. This will
> eventually allow us to pass one more argument to blkdev_put() without
> too much hassle.
Can we use the opportunity to come up with better names? blkdev_get_*
was always a rather horrible naming convention for something that
ends up calling into ->open.
What about:
struct bdev_handle *bdev_open_by_dev(dev_t dev, blk_mode_t mode, void *holder,
const struct blk_holder_ops *hops);
struct bdev_handle *bdev_open_by_path(dev_t dev, blk_mode_t mode,
void *holder, const struct blk_holder_ops *hops);
void bdev_release(struct bdev_handle *handle);
?
On Thu, Jul 06, 2023 at 06:14:33PM +0200, Jan Kara wrote:
> > struct bdev_handle *bdev_open_by_path(dev_t dev, blk_mode_t mode,
> > void *holder, const struct blk_holder_ops *hops);
> > void bdev_release(struct bdev_handle *handle);
>
> I'd maybe use bdev_close() instead of bdev_release() but otherwise I like
> the new naming.
We're using release everywhese else, but if Jens is fine with that I
can live with close.
On Fri 07-07-23 04:28:41, Christoph Hellwig wrote:
> On Thu, Jul 06, 2023 at 06:14:33PM +0200, Jan Kara wrote:
> > > struct bdev_handle *bdev_open_by_path(dev_t dev, blk_mode_t mode,
> > > void *holder, const struct blk_holder_ops *hops);
> > > void bdev_release(struct bdev_handle *handle);
> >
> > I'd maybe use bdev_close() instead of bdev_release() but otherwise I like
> > the new naming.
>
> We're using release everywhese else, but if Jens is fine with that I
> can live with close.
Dunno, to me words pair like open-close, get-put, acquire-release.
Furthermore e.g. ->release() (and thus blkdev_release()) is called only
when the last file reference is dropped, not when each reference is
dropped, so that's why bdev_release() seems a bit confusing to me.
Honza
--
Jan Kara <[email protected]>
SUSE Labs, CR
On Thu, Jul 6, 2023 at 5:38 PM Christoph Hellwig <[email protected]> wrote:
>
> On Tue, Jul 04, 2023 at 02:21:28PM +0200, Jan Kara wrote:
> > Create struct bdev_handle that contains all parameters that need to be
> > passed to blkdev_put() and provide blkdev_get_handle_* functions that
> > return this structure instead of plain bdev pointer. This will
> > eventually allow us to pass one more argument to blkdev_put() without
> > too much hassle.
>
> Can we use the opportunity to come up with better names? blkdev_get_*
> was always a rather horrible naming convention for something that
> ends up calling into ->open.
>
> What about:
>
> struct bdev_handle *bdev_open_by_dev(dev_t dev, blk_mode_t mode, void *holder,
> const struct blk_holder_ops *hops);
> struct bdev_handle *bdev_open_by_path(dev_t dev, blk_mode_t mode,
> void *holder, const struct blk_holder_ops *hops);
> void bdev_release(struct bdev_handle *handle);
+1 to this.
Also, if we are removing "handle" from the function, should the name
of the structure it returns also change? Would something like bdev_ctx
be better?
(Apologies for the previous non-plaintext email)
>
> ?
On Wed 12-07-23 18:06:35, Haris Iqbal wrote:
> On Thu, Jul 6, 2023 at 5:38 PM Christoph Hellwig <[email protected]> wrote:
> >
> > On Tue, Jul 04, 2023 at 02:21:28PM +0200, Jan Kara wrote:
> > > Create struct bdev_handle that contains all parameters that need to be
> > > passed to blkdev_put() and provide blkdev_get_handle_* functions that
> > > return this structure instead of plain bdev pointer. This will
> > > eventually allow us to pass one more argument to blkdev_put() without
> > > too much hassle.
> >
> > Can we use the opportunity to come up with better names? blkdev_get_*
> > was always a rather horrible naming convention for something that
> > ends up calling into ->open.
> >
> > What about:
> >
> > struct bdev_handle *bdev_open_by_dev(dev_t dev, blk_mode_t mode, void *holder,
> > const struct blk_holder_ops *hops);
> > struct bdev_handle *bdev_open_by_path(dev_t dev, blk_mode_t mode,
> > void *holder, const struct blk_holder_ops *hops);
> > void bdev_release(struct bdev_handle *handle);
>
> +1 to this.
> Also, if we are removing "handle" from the function, should the name
> of the structure it returns also change? Would something like bdev_ctx
> be better?
I think the bdev_handle name is fine for the struct. After all it is
equivalent of an open handle for the block device so IMHO bdev_handle
captures that better than bdev_ctx.
Honza
--
Jan Kara <[email protected]>
SUSE Labs, CR