Re: [f2fs-dev] [PATCH v5 4/5] sd: limit to use write life hints

2024-09-18 Thread Christoph Hellwig
On Wed, Sep 18, 2024 at 01:42:51PM +0530, Kanchan Joshi wrote:
> Would you prefer a new queue attribute (say nr_streams) that tells that?

No.  For one because using the same file descriptors as the one used
to set the hind actually makes it usable - finding the block device
does not.  And second as told about half a dozend time for this scheme
to actually work on a regular file the file system actually needs the
arbiter, as it can work on top of multiple block devices, consumes
streams, might export streams even if the underlying devices don't and
so on.


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH v5 4/5] sd: limit to use write life hints

2024-09-17 Thread Christoph Hellwig
> > If the device (or file system, which really needs to be in control
> > for actual files vs just block devices) does not support all 256
> > we need to reduce them to less than that.  The kernel can help with
> > that a bit if the streams have meanings (collapsing temperature levels
> > that are close), but not at all if they don't have meanings. 
> 
> Current patch (nvme) does what you mentioned above.
> Pasting the fragment that maps potentially large placement-hints to the 
> last valid placement-id.
> 
> +static inline void nvme_assign_placement_id(struct nvme_ns *ns,
> + struct request *req,
> + struct nvme_command *cmd)
> +{
> + u8 h = umin(ns->head->nr_plids - 1,
> + WRITE_PLACEMENT_HINT(req->write_hint));
> +
> + cmd->rw.control |= cpu_to_le16(NVME_RW_DTYPE_DPLCMT);
> + cmd->rw.dsmgmt |= cpu_to_le32(ns->head->plids[h] << 16);
> +}
> 
> But this was just an implementation choice (and not a failure avoidance 
> fallback).

And it completely fucks thing up as I said.  If I have an application
that wants to separate streams I need to know how many stream I
have available, and not fold all higher numbers into the last one
available.


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH v5 4/5] sd: limit to use write life hints

2024-09-16 Thread Christoph Hellwig
On Mon, Sep 16, 2024 at 07:19:21PM +0530, Kanchan Joshi wrote:
> > Maybe part of the problem is that the API is very confusing.  A smal
> > part of that is of course that the existing temperature hints already
> > have some issues, but this seems to be taking them make it significantly
> > worse.
> 
> Can you explain what part is confusing. This is a simple API that takes 
> type/value pair. Two types (and respective values) are clearly defined 
> currently, and more can be added in future.

I though I outlined that below.

> > But if we increase this to a variable number of hints that don't have
> > any meaning (and even if that is just the rough order of the temperature
> > hints assigned to them), that doesn't really work.  We'll need an API
> > to check if these stream hints are supported and how many of them,
> > otherwise the applications can't make any sensible use of them.
> 
> - Since writes are backward compatible, nothing bad happens if the 
> passed placement-hint value is not supported. Maybe desired outcome (in 
> terms of WAF reduction) may not come but that's not a kernel problem 
> anyway. It's rather about how well application is segregating and how 
> well device is doing its job.

What do you mean with "writes are backward compatible" ?

> - Device is perfectly happy to work with numbers (0 to 256 in current 
> spec) to produce some value (i.e., WAF reduction). Any extra 
> semantics/abstraction on these numbers only adds to the work without 
> increasing that value. If any application needs that, it's free to 
> attach any meaning/semantics to these numbers.

If the device (or file system, which really needs to be in control
for actual files vs just block devices) does not support all 256
we need to reduce them to less than that.  The kernel can help with
that a bit if the streams have meanings (collapsing temperature levels
that are close), but not at all if they don't have meanings.  The
application can and thus needs to know the number of separate
streams available.



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH v5 4/5] sd: limit to use write life hints

2024-09-13 Thread Christoph Hellwig
On Thu, Sep 12, 2024 at 10:01:00PM +0530, Kanchan Joshi wrote:
> Please see the response in patch #1. My worries were:
> (a) adding a new field and propagating it across the stack will cause 
> code duplication.
> (b) to add a new field we need to carve space within inode, bio and 
> request.
> We had a hole in request, but it is set to vanish after ongoing 
> integrity refactoring patch of Keith [1]. For inode also, there is no 
> liberty at this point [2].
> 
> I think current multiplexing approach is similar to ioprio where 
> multiple io priority classes/values are expressed within an int type. 
> And few kernel components choose to interpret certain ioprio values at will.
> 
> And all this is still in-kernel details. Which can be changed if/when 
> other factors start helping.

Maybe part of the problem is that the API is very confusing.  A smal
part of that is of course that the existing temperature hints already
have some issues, but this seems to be taking them make it significantly
worse.

Note: this tries to include highlevel comments from the discussion of
the previous patches instead of splitting them over multiple threads.

F_{S,G}ET_RW_HINT works on arbitrary file descriptors with absolutely no
check for support by the device or file system and not check for the
file type.  That's not exactly good API design, but not really a major
because they are clearly designed as hints with a fixed number of
values, allowing the implementation to map them if not enough are
supported.

But if we increase this to a variable number of hints that don't have
any meaning (and even if that is just the rough order of the temperature
hints assigned to them), that doesn't really work.  We'll need an API
to check if these stream hints are supported and how many of them,
otherwise the applications can't make any sensible use of them.

If these aren't just stream hints of the file system but you actually
want them as an abstract API for FDP you'll also need to actually
expose even more information like the reclaim unit size, but let's
ignore that for this part of the discssion.

Back the the API: the existing lifetime hints have basically three
layers:

 1) syscall ABI
 2) the hint stored in the inode
 3) the hint passed in the bio

1) is very much fixed for the temperature API, we just need to think if
   we want to support it at the same time as a more general hints API.
   Or if we can map one into another.  Or if we can't support them at
   the same time how that is communicated.

For 2) and 3) we can use an actual union if we decide to not support
both at the same time, keyed off a flag outside the field, but if not
we simply need space for both.


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH] f2fs: fix to don't set SB_RDONLY in f2fs_handle_critical_error()

2024-09-12 Thread Christoph Hellwig
Another problem is that it sets SB_RDONLY instead of an internal
shutdown flag. But that can be solved later.



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH v5 2/5] fcntl: rename rw_hint_* to rw_lifetime_hint_*

2024-09-12 Thread Christoph Hellwig
On Tue, Sep 10, 2024 at 08:31:57PM +0530, Kanchan Joshi wrote:
> F_GET/SET_RW_HINT fcntl handlers query/set write life hints.
> Rename the handlers/helpers to be explicit that write life hints are
> being handled.
> 
> This is in preparation to introduce a new interface that supports more
> than one type of write hint.

Wouldn't it make more sense to stick with the name as exposed in the
uapi?  The same minda applies to the previous patch - in fact IFF we
decide to do the rename I'd probably expect both parts to go together.



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH v5 4/5] sd: limit to use write life hints

2024-09-12 Thread Christoph Hellwig
On Tue, Sep 10, 2024 at 08:31:59PM +0530, Kanchan Joshi wrote:
> From: Nitesh Shetty 
> 
> The incoming hint value maybe either lifetime hint or placement hint.

.. may either be .. ?

> Make SCSI interpret only temperature-based write lifetime hints.
> 
> Signed-off-by: Nitesh Shetty 
> Signed-off-by: Kanchan Joshi 
> ---
>  drivers/scsi/sd.c | 7 ---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index dad3991397cf..82bd4b07314e 100644
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -1191,8 +1191,8 @@ static u8 sd_group_number(struct scsi_cmnd *cmd)
>   if (!sdkp->rscs)
>   return 0;
>  
> - return min3((u32)rq->write_hint, (u32)sdkp->permanent_stream_count,
> - 0x3fu);
> + return min3((u32)WRITE_LIFETIME_HINT(rq->write_hint),

No fan of the screaming WRITE_LIFETIME_HINT.Or the fact that multiple
things are multiplexed into the single rq->write_hint field to
start with.

This code could also use a bit of documentation already in the existing
version, but even more so now.



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH v5 3/5] fcntl: add F_{SET/GET}_RW_HINT_EX

2024-09-12 Thread Christoph Hellwig
On Tue, Sep 10, 2024 at 08:31:58PM +0530, Kanchan Joshi wrote:
> This is similar to existing F_{SET/GET}_RW_HINT but more
> generic/extensible.
> 
> F_SET/GET_RW_HINT_EX take a pointer to a struct rw_hint_ex as argument:
> 
> struct rw_hint_ex {
> __u8type;
> __u8pad[7];
> __u64   val;
> };
> 
> With F_SET_RW_HINT_EX, the user passes the hint type and its value.
> Hint type can be either lifetime hint (TYPE_RW_LIFETIME_HINT) or
> placement hint (TYPE_RW_PLACEMENT_HINT). The interface allows to add
> more hint add more hint types in future.

What is the point of multiplexing these into a single call vs having
one fcntl for each?  It's not like the code points are a super
limited resource.

And the _EX name isn't exactly descriptive either and screams of horrible
Windows APIs :)

> + WRITE_ONCE(inode->i_write_hint, hint);
> + if (file->f_mapping->host != inode)
> + WRITE_ONCE(file->f_mapping->host->i_write_hint, hint);

This doesn't work.  You need a file system method for this so that
the file system can intercept it, instead of storing it in completely
arbitrary inodes without any kind of checking for support or intercetion
point.

> --- a/include/linux/rw_hint.h
> +++ b/include/linux/rw_hint.h
> @@ -21,4 +21,17 @@ enum rw_lifetime_hint {
>  static_assert(sizeof(enum rw_lifetime_hint) == 1);
>  #endif
>  
> +#define WRITE_HINT_TYPE_BIT  BIT(7)
> +#define WRITE_HINT_VAL_MASK  (WRITE_HINT_TYPE_BIT - 1)
> +#define WRITE_HINT_TYPE(h)   (((h) & WRITE_HINT_TYPE_BIT) ? \
> + TYPE_RW_PLACEMENT_HINT : TYPE_RW_LIFETIME_HINT)
> +#define WRITE_HINT_VAL(h)((h) & WRITE_HINT_VAL_MASK)
> +
> +#define WRITE_PLACEMENT_HINT(h)  (((h) & WRITE_HINT_TYPE_BIT) ? \
> +  WRITE_HINT_VAL(h) : 0)
> +#define WRITE_LIFETIME_HINT(h)   (((h) & WRITE_HINT_TYPE_BIT) ? \
> +  0 : WRITE_HINT_VAL(h))
> +
> +#define PLACEMENT_HINT_TYPE  WRITE_HINT_TYPE_BIT
> +#define MAX_PLACEMENT_HINT_VAL   (WRITE_HINT_VAL_MASK - 1)

That's a whole lot of undocumented macros.  Please turn these into proper
inline functions and write documentation for them.



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH v5 1/5] fs, block: refactor enum rw_hint

2024-09-12 Thread Christoph Hellwig
On Tue, Sep 10, 2024 at 08:31:56PM +0530, Kanchan Joshi wrote:
> Rename enum rw_hint to rw_lifetime_hint.
> Change i_write_hint (in inode), bi_write_hint(in bio), and write_hint
> (in request) to use u8 data-type rather than this enum.
> 
> This is in preparation to introduce a new write hint type.

The rationale seems a bit sparse.  Why is it renamed?  Because the
name fits better, because you need the same for something else?

>  static void submit_bh_wbc(blk_opf_t opf, struct buffer_head *bh,
> -   enum rw_hint hint, struct writeback_control *wbc);
> +   u8 hint, struct writeback_control *wbc);

And moving from the enum to an plain integer seems like a bit of a
retrograde step.



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH v2] f2fs: check discard support for conventional zones

2024-08-15 Thread Christoph Hellwig
Looks good:

Reviewed-by: Christoph Hellwig 



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH 1/4] module: Add module_subinit{_noexit} and module_subeixt helper macros

2024-07-29 Thread Christoph Hellwig
On Sun, Jul 28, 2024 at 10:44:12PM -0400, Theodore Ts'o wrote:
> >
> > Personally, I prefer the implementation of method two.
> 
> But there's also method zero --- keep things the way they are, and
> don't try to add a new astraction.
> 
> Advantage:
> 
>  -- Code has worked for decades, so it is very well tested
>  -- Very easy to understand and maintain
> 
> Disadvantage
> 
>  --- A few extra lines of C code.
> 
> which we need to weigh against the other choices.

I think option zero is the right option for you and David and anyone
scared of link order issues.

But I know for XFS or the nvme code having multiple initcalls per
module would be extremely helpfu.  I don't really want to drag Youling
into implementing something he is not behind, but I plan to try that
out myself once I find a little time.



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH 1/4] module: Add module_subinit{_noexit} and module_subeixt helper macros

2024-07-26 Thread Christoph Hellwig
On Fri, Jul 26, 2024 at 01:58:00PM -0400, Theodore Ts'o wrote:
> Yeah, that's my reaction as well.  This only saves 50 lines of code in
> ext4, and that includes unrelated changes such as getting rid of "int
> i" and putting the declaration into the for loop --- "for (int i =
> ...").  Sure, that saves two lines of code, but yay?
> 
> If the ordering how the functions gets called is based on the magic
> ordering in the Makefile, I'm not sure this actually makes the code
> clearer, more robust, and easier to maintain for the long term.

So you two object to kernel initcalls for the same reason and would
rather go back to calling everything explicitly?



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH 1/4] module: Add module_subinit{_noexit} and module_subeixt helper macros

2024-07-26 Thread Christoph Hellwig
On Fri, Jul 26, 2024 at 04:54:59PM +0800, Youling Tang wrote:
> Based on this patch, we may need to do these things with this
>
>
> 1. Change the order of *.o in the Makefile (the same order as before the
> change)

While we'll need to be careful, we don't need to match the exact
order.  Most of the calls simply create slab caches / mempools and
similar things and the order for those does not matter at all.

Of course the register_filesytem calls need to be last, and sysfs
registration probably should be second to last, but for the vast
amount of calls the order does not matter as long as it is unwound
in reverse order.

> 2. We need to define module_subinit through the ifdef MODULE
> distinction,

Yes.

> When one of the subinit runs in a module fails, it is difficult
> to rollback execution of subexit.

By having both section in the same order, you an just walk the
exit section backwards from the offset that failed.  Of course that
only matters for the modular case as normal initcalls don't get
unwound when built-in either.

> 4. The order in which subinit is called is not intuitively known
> (although it can be found in the Makefile).

Link order through make file is already a well known concept due to
it mattering for built-in code.



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH 1/4] module: Add module_subinit{_noexit} and module_subeixt helper macros

2024-07-25 Thread Christoph Hellwig
On Thu, Jul 25, 2024 at 07:14:14PM +0200, Goffredo Baroncelli wrote:
> Instead of relying to the "expected" order of the compiler/linker,
> why doesn't manage the chain explicitly ? Something like:

Because that doesn't actually solve anything over simple direct calls
as you still need the symbols to be global?

As an example here is a very hacky patch that just compiles with unused
variable warnings and doesn't work at all to show how the distributed
module_subinit would improve ext4, the file system with the least
subinit calls of the three converted in the series, and without any
extra cleanups like removing now unneded includes or moving more stuff
into subinits if they can remain entirely static that way:

 11 files changed, 61 insertions(+), 114 deletions(-)

diff --git a/fs/ext4/block_validity.c b/fs/ext4/block_validity.c
index 87ee3a17bd29c9..87f0ccd06fc069 100644
--- a/fs/ext4/block_validity.c
+++ b/fs/ext4/block_validity.c
@@ -29,7 +29,7 @@ struct ext4_system_zone {
 
 static struct kmem_cache *ext4_system_zone_cachep;
 
-int __init ext4_init_system_zone(void)
+static int __init ext4_init_system_zone(void)
 {
ext4_system_zone_cachep = KMEM_CACHE(ext4_system_zone, 0);
if (ext4_system_zone_cachep == NULL)
@@ -37,11 +37,12 @@ int __init ext4_init_system_zone(void)
return 0;
 }
 
-void ext4_exit_system_zone(void)
+static void ext4_exit_system_zone(void)
 {
rcu_barrier();
kmem_cache_destroy(ext4_system_zone_cachep);
 }
+module_subinit(ext4_init_system_zone, ext4_exit_system_zone);
 
 static inline int can_merge(struct ext4_system_zone *entry1,
 struct ext4_system_zone *entry2)
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 08acd152261ed8..db81f18cdc3266 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -2915,8 +2915,6 @@ void ext4_fc_del(struct inode *inode);
 bool ext4_fc_replay_check_excluded(struct super_block *sb, ext4_fsblk_t block);
 void ext4_fc_replay_cleanup(struct super_block *sb);
 int ext4_fc_commit(journal_t *journal, tid_t commit_tid);
-int __init ext4_fc_init_dentry_cache(void);
-void ext4_fc_destroy_dentry_cache(void);
 int ext4_fc_record_regions(struct super_block *sb, int ino,
   ext4_lblk_t lblk, ext4_fsblk_t pblk,
   int len, int replay);
@@ -2930,8 +2928,6 @@ extern void ext4_mb_release(struct super_block *);
 extern ext4_fsblk_t ext4_mb_new_blocks(handle_t *,
struct ext4_allocation_request *, int *);
 extern void ext4_discard_preallocations(struct inode *);
-extern int __init ext4_init_mballoc(void);
-extern void ext4_exit_mballoc(void);
 extern ext4_group_t ext4_mb_prefetch(struct super_block *sb,
 ext4_group_t group,
 unsigned int nr, int *cnt);
@@ -3651,8 +3647,6 @@ static inline void ext4_set_de_type(struct super_block 
*sb,
 /* readpages.c */
 extern int ext4_mpage_readpages(struct inode *inode,
struct readahead_control *rac, struct folio *folio);
-extern int __init ext4_init_post_read_processing(void);
-extern void ext4_exit_post_read_processing(void);
 
 /* symlink.c */
 extern const struct inode_operations ext4_encrypted_symlink_inode_operations;
@@ -3663,14 +3657,10 @@ extern const struct inode_operations 
ext4_fast_symlink_inode_operations;
 extern void ext4_notify_error_sysfs(struct ext4_sb_info *sbi);
 extern int ext4_register_sysfs(struct super_block *sb);
 extern void ext4_unregister_sysfs(struct super_block *sb);
-extern int __init ext4_init_sysfs(void);
-extern void ext4_exit_sysfs(void);
 
 /* block_validity */
 extern void ext4_release_system_zone(struct super_block *sb);
 extern int ext4_setup_system_zone(struct super_block *sb);
-extern int __init ext4_init_system_zone(void);
-extern void ext4_exit_system_zone(void);
 extern int ext4_inode_block_valid(struct inode *inode,
  ext4_fsblk_t start_blk,
  unsigned int count);
@@ -3750,8 +3740,6 @@ extern int ext4_move_extents(struct file *o_filp, struct 
file *d_filp,
 __u64 len, __u64 *moved_len);
 
 /* page-io.c */
-extern int __init ext4_init_pageio(void);
-extern void ext4_exit_pageio(void);
 extern ext4_io_end_t *ext4_init_io_end(struct inode *inode, gfp_t flags);
 extern ext4_io_end_t *ext4_get_io_end(ext4_io_end_t *io_end);
 extern int ext4_put_io_end(ext4_io_end_t *io_end);
diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c
index 17dcf13adde275..d381ec88441ffd 100644
--- a/fs/ext4/extents_status.c
+++ b/fs/ext4/extents_status.c
@@ -156,19 +156,6 @@ static int __revise_pending(struct inode *inode, 
ext4_lblk_t lblk,
ext4_lblk_t len,
struct pending_reservation **prealloc);
 
-int __init ext4_init_es(void)
-{
-   ext4_es_cachep = KMEM_CACHE(extent_status, SLAB_RECLAIM_ACCOUNT);
-   if (ext4_es_cachep == NULL)
-

Re: [f2fs-dev] [PATCH 1/4] module: Add module_subinit{_noexit} and module_subeixt helper macros

2024-07-25 Thread Christoph Hellwig
On Thu, Jul 25, 2024 at 05:30:58PM +0200, Arnd Bergmann wrote:
> Now I think we could just make the module_init() macro
> do the same thing as a built-in initcall() and put
> an entry in a special section, to let you have multiple
> entry points in a loadable module.
> 
> There are still at least two problems though:
> 
> - while link order is defined between files in a module,
>   I don't think there is any guarantee for the order between
>   two initcalls of the same level within a single file.

I think the sanest answer is to only allow one per file.  If you
are in the same file anyway calling one function from the other
is not a big burden.  It really is when they are spread over files
when it is annoying, and the three examples show that pretty
clearly.

> - For built-in code we don't have to worry about matching
>   the order of the exit calls since they don't exist there.
>   As I understand, the interesting part of this patch
>   series is about making sure the order matches between
>   init and exit, so there still needs to be a way to
>   express a pair of such calls.

That's why you want a single macro to define the init and exit
callbacks, so that the order can be matched up and so that
error unwinding can use the relative position easily.


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH 1/4] module: Add module_subinit{_noexit} and module_subeixt helper macros

2024-07-25 Thread Christoph Hellwig
On Thu, Jul 25, 2024 at 11:01:33AM +0800, Youling Tang wrote:
> - It doesn't feel good to have only one subinit/exit in a file.
>   Assuming that there is only one file in each file, how do we
>   ensure that the files are linked in order?(Is it sorted by *.o
>   in the Makefile?)

Yes, link order already matterns for initialization order for built-in
code, so this is a well known concept.

> - Even if the order of each init is linked correctly, then the
>   runtime will be iterated through the .subinitcall.init section,
>   which executes each initfn in sequence (similar to do_initcalls),
>   which means that no other code can be inserted between each subinit.

I don't understand this comment.  What do you mean with no other
code could be inserted?

> If module_subinit is called in module_init, other code can be inserted
> between subinit, similar to the following:
> 
> ```
> static int __init init_example(void)
> {
>     module_subinit(inita, exita);
> 
>     otherthing...
> 
>     module_subinit(initb, exitb);
> 
>     return 0;
> }

Yikes.  That's really not the point of having init calls, but just
really, really convoluted control flow.

> module_init(init_example);
> ```
> 
> IMHO, module_subinit() might be better called in module_init().

I strongly disagree.



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH 1/4] module: Add module_subinit{_noexit} and module_subeixt helper macros

2024-07-24 Thread Christoph Hellwig
On Wed, Jul 24, 2024 at 09:57:05AM +0800, Youling Tang wrote:
> module_init(initfn)/module_exit(exitfn) has two definitions (via MODULE):
> - buindin: uses do_initcalls() to iterate over the contents of the specified
>   section and executes all initfn functions in the section in the order in
>   which they are stored (exitfn is not required).
> 
> - ko: run do_init_module(mod)->do_one_initcall(mod->init) to execute initfn
>   of the specified module.
> 
> If we change module_subinit to something like this, not called in
> module_init,

> Not only do we want to ensure that exit is executed in reverse order of
> init, but we also want to ensure the order of init.

Yes.

> This does not guarantee the order in which init will be executed (although
> the init/exit order will remain the same)

Hmm, so the normal built-in initcalls depend on the link order, but when
they are in the same file, the compiler can reorder them before we even
get to the linker.

I wonder what a good syntax would be to still avoid the boilerplate
code.  We'd probably need one macro to actually define the init/exit
table in a single statement so that it can't be reordered, but that
would lose the ability to actually declare the module subinit/exit
handlers in multiple files, which really is the biggest win of this
scheme as it allows to keep the functions static instead of exposing
them to other compilation units.

And in fact even in your three converted file systems, most
subinit/exit handler are in separate files, so maybe instead
enforcing that there is just one per file and slightly refactoring
the code so that this is the case might be the best option?


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH 1/4] module: Add module_subinit{_noexit} and module_subeixt helper macros

2024-07-23 Thread Christoph Hellwig
On Tue, Jul 23, 2024 at 04:32:36PM +0800, Youling Tang wrote:
> Providing module_subinit{_noexit} and module_subeixt helps macros ensure
> that modules init/exit match their order, while also simplifying the code.
> 
> The three macros are defined as follows:
> - module_subinit(initfn, exitfn,rollback)
> - module_subinit_noexit(initfn, rollback)
> - module_subexit(rollback)
> 
> `initfn` is the initialization function and `exitfn` is the corresponding
> exit function.

I find the interface a little confusing.  What I would have expected
is to:

 - have the module_subinit call at file scope instead of in the
   module_init helper, similar to module_init/module_exit
 - thus keep the rollback state explicitly in the module structure or
   similar so that the driver itself doesn't need to care about at
   all, and thus remove the need for the module_subexit call.



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH 0/3] Add {init, exit}_sequence_fs() helper function

2024-07-23 Thread Christoph Hellwig
On Tue, Jul 23, 2024 at 04:44:14PM +0800, Youling Tang wrote:
> Thanks for your suggestion,  I re-implemented it using section mode,
> and the new patch set [1] has been sent.

Nice!  I'll review it.



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH 0/3] Add {init, exit}_sequence_fs() helper function

2024-07-11 Thread Christoph Hellwig
Can we please stop this boilerplate code an instead our __init/__exit
sections to supper multiple entires per module.  This should be mostly
trivial, except that we'd probably want a single macro that has the
init and exit calls so that the order in the section is the same and
the unroll on failure can walk back form the given offset. e.g.
something like:

module_subinit(foo_bar_init, foo_bar_exit);
module_subinit(foo_bar2_init, foo_bar2_exit);




___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH 3/5] block: remove support for the host aware zone model

2023-12-18 Thread Christoph Hellwig
On Mon, Dec 18, 2023 at 06:48:43PM +0900, Damien Le Moal wrote:
> > -   if (devip->zmodel == BLK_ZONED_HA)
> > -   arr[4] = 1 << 4;/* zoned field = 01b */
> 
> I think we should keep everything related to HA in scsi debug as that is an 
> easy
> way to test the block layer and scsi. no ?

Yes.


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 2/5] virtio_blk: remove the broken zone revalidation support

2023-12-17 Thread Christoph Hellwig
virtblk_revalidate_zones is called unconditionally from
virtblk_config_changed_work from the virtio config_changed callback.

virtblk_revalidate_zones is a bit odd in that it re-clears the zoned
state for host aware or non-zoned devices, which isn't needed unless the
zoned mode changed - but a zone mode change to a host managed model isn't
handled at all, and virtio_blk also doesn't handle any other config
change except for a capacity change is handled (and even if it was
the upper layers above virtio_blk wouldn't handle it very well).

But even the useful case of a size change that would add or remove
zones isn't handled properly as blk_revalidate_disk_zones expects the
device capacity to cover all zones, but the capacity is only updated
after virtblk_revalidate_zones.

As this code appears to be entirely untested and is getting in the way
remove it for now, but it can be readded in a fixed version with
proper test coverage if needed.

Fixes: 95bfec41bd3d ("virtio-blk: add support for zoned block devices")
Fixes: f1ba4e674feb ("virtio-blk: fix to match virtio spec")
Signed-off-by: Christoph Hellwig 
---
 drivers/block/virtio_blk.c | 26 --
 1 file changed, 26 deletions(-)

diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index aeead732a24dc9..a28f1687066bb4 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -722,27 +722,6 @@ static int virtblk_report_zones(struct gendisk *disk, 
sector_t sector,
return ret;
 }
 
-static void virtblk_revalidate_zones(struct virtio_blk *vblk)
-{
-   u8 model;
-
-   virtio_cread(vblk->vdev, struct virtio_blk_config,
-zoned.model, &model);
-   switch (model) {
-   default:
-   dev_err(&vblk->vdev->dev, "unknown zone model %d\n", model);
-   fallthrough;
-   case VIRTIO_BLK_Z_NONE:
-   case VIRTIO_BLK_Z_HA:
-   disk_set_zoned(vblk->disk, BLK_ZONED_NONE);
-   return;
-   case VIRTIO_BLK_Z_HM:
-   WARN_ON_ONCE(!vblk->zone_sectors);
-   if (!blk_revalidate_disk_zones(vblk->disk, NULL))
-   set_capacity_and_notify(vblk->disk, 0);
-   }
-}
-
 static int virtblk_probe_zoned_device(struct virtio_device *vdev,
   struct virtio_blk *vblk,
   struct request_queue *q)
@@ -823,10 +802,6 @@ static int virtblk_probe_zoned_device(struct virtio_device 
*vdev,
  */
 #define virtblk_report_zones   NULL
 
-static inline void virtblk_revalidate_zones(struct virtio_blk *vblk)
-{
-}
-
 static inline int virtblk_probe_zoned_device(struct virtio_device *vdev,
struct virtio_blk *vblk, struct request_queue *q)
 {
@@ -982,7 +957,6 @@ static void virtblk_config_changed_work(struct work_struct 
*work)
struct virtio_blk *vblk =
container_of(work, struct virtio_blk, config_work);
 
-   virtblk_revalidate_zones(vblk);
virtblk_update_capacity(vblk, true);
 }
 
-- 
2.39.2



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 3/5] block: remove support for the host aware zone model

2023-12-17 Thread Christoph Hellwig
When zones were first added the SCSI and ATA specs, two different
models were supported (in addition to the drive managed one that
is invisible to the host):

 - host managed where non-conventional zones there is strict requirement
   to write at the write pointer, or else an error is returned
 - host aware where a write point is maintained if writes always happen
   at it, otherwise it is left in an under-defined state and the
   sequential write preferred zones behave like conventional zones
   (probably very badly performing ones, though)

Not surprisingly this lukewarm model didn't prove to be very useful and
was finally removed from the ZBC and SBC specs (NVMe never implemented
it).  Due to to the easily disappearing write pointer host software
could never rely on the write pointer to actually be useful for say
recovery.

Fortunately only a few HDD prototypes shipped using this model which
never made it to mass production.  Drop the support before it is too
late.  Note that any such host aware prototype HDD can still be used
with Linux as we'll now treat it as a conventional HDD.

Signed-off-by: Christoph Hellwig 
---
 block/blk-settings.c   | 67 +-
 block/blk-sysfs.c  |  9 +
 block/partitions/core.c| 12 +-
 drivers/block/null_blk/zoned.c |  2 +-
 drivers/block/ublk_drv.c   |  2 +-
 drivers/block/virtio_blk.c |  2 +-
 drivers/md/dm-kcopyd.c |  2 +-
 drivers/md/dm-table.c  | 45 ++-
 drivers/md/dm-zoned-metadata.c |  7 ++--
 drivers/md/dm-zoned-target.c   |  4 +-
 drivers/nvme/host/zns.c|  2 +-
 drivers/scsi/scsi_debug.c  | 27 +++---
 drivers/scsi/sd.c  | 45 ++-
 drivers/scsi/sd_zbc.c  | 16 +---
 fs/btrfs/zoned.c   | 23 ++--
 fs/btrfs/zoned.h   |  2 +-
 fs/f2fs/data.c |  2 +-
 fs/f2fs/super.c| 17 -
 include/linux/blkdev.h | 37 ++-
 19 files changed, 92 insertions(+), 231 deletions(-)

diff --git a/block/blk-settings.c b/block/blk-settings.c
index 09e3a4d5e4d20f..50e9efb59f67fd 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -56,7 +56,7 @@ void blk_set_default_limits(struct queue_limits *lim)
lim->alignment_offset = 0;
lim->io_opt = 0;
lim->misaligned = 0;
-   lim->zoned = BLK_ZONED_NONE;
+   lim->zoned = false;
lim->zone_write_granularity = 0;
lim->dma_alignment = 511;
 }
@@ -880,79 +880,30 @@ bool blk_queue_can_use_dma_map_merging(struct 
request_queue *q,
 }
 EXPORT_SYMBOL_GPL(blk_queue_can_use_dma_map_merging);
 
-static bool disk_has_partitions(struct gendisk *disk)
-{
-   unsigned long idx;
-   struct block_device *part;
-   bool ret = false;
-
-   rcu_read_lock();
-   xa_for_each(&disk->part_tbl, idx, part) {
-   if (bdev_is_partition(part)) {
-   ret = true;
-   break;
-   }
-   }
-   rcu_read_unlock();
-
-   return ret;
-}
-
 /**
  * disk_set_zoned - configure the zoned model for a disk
  * @disk:  the gendisk of the queue to configure
- * @model: the zoned model to set
- *
- * Set the zoned model of @disk to @model.
+ * @zoned: zoned or not.
  *
- * When @model is BLK_ZONED_HM (host managed), this should be called only
- * if zoned block device support is enabled (CONFIG_BLK_DEV_ZONED option).
- * If @model specifies BLK_ZONED_HA (host aware), the effective model used
- * depends on CONFIG_BLK_DEV_ZONED settings and on the existence of partitions
- * on the disk.
+ * When @zoned is %true, this should be called only if zoned block device
+ * support is enabled (CONFIG_BLK_DEV_ZONED option).
  */
-void disk_set_zoned(struct gendisk *disk, enum blk_zoned_model model)
+void disk_set_zoned(struct gendisk *disk, bool zoned)
 {
struct request_queue *q = disk->queue;
-   unsigned int old_model = q->limits.zoned;
 
-   switch (model) {
-   case BLK_ZONED_HM:
-   /*
-* Host managed devices are supported only if
-* CONFIG_BLK_DEV_ZONED is enabled.
-*/
+   if (zoned) {
WARN_ON_ONCE(!IS_ENABLED(CONFIG_BLK_DEV_ZONED));
-   break;
-   case BLK_ZONED_HA:
-   /*
-* Host aware devices can be treated either as regular block
-* devices (similar to drive managed devices) or as zoned block
-* devices to take advantage of the zone command set, similarly
-* to host managed devices. We try the latter if there are no
-* partitions and zoned block device support is enabled, else
-* we do nothing special as far as the block layer is concerned.
-*/
-   if (!IS_ENABLED(CONFIG_BLK_DEV_ZONED) ||

[f2fs-dev] remove support for the host aware zoned model

2023-12-17 Thread Christoph Hellwig
Hi all,

hen zones were first added the SCSI and ATA specs, two different
models were supported (in addition to the drive managed one that
is invisible to the host):

 - host managed where non-conventional zones there is strict requirement
   to write at the write pointer, or else an error is returned
 - host aware where a write point is maintained if writes always happen
   at it, otherwise it is left in an under-defined state and the
   sequential write preferred zones behave like conventional zones
   (probably very badly performing ones, though)

Not surprisingly this lukewarm model didn't prove to be very useful and
was finally removed from the ZBC and SBC specs (NVMe never implemented
it).  Due to to the easily disappearing write pointer host software
could never rely on the write pointer to actually be useful for say
recovery.

Fortunately only a few HDD prototypes shipped using this model which
never made it to mass production.  Drop the support before it is too
late.  Note that any such host aware prototype HDD can still be used
with Linux as we'll now treat it as a conventional HDD.

Diffstat:
 block/blk-settings.c   |   83 +
 block/blk-sysfs.c  |9 
 block/blk-zoned.c  |3 -
 block/blk.h|2 
 block/partitions/core.c|   12 -
 drivers/block/null_blk/zoned.c |2 
 drivers/block/ublk_drv.c   |2 
 drivers/block/virtio_blk.c |   78 +++---
 drivers/md/dm-kcopyd.c |2 
 drivers/md/dm-table.c  |   45 +-
 drivers/md/dm-zoned-metadata.c |7 +--
 drivers/md/dm-zoned-target.c   |4 -
 drivers/nvme/host/zns.c|2 
 drivers/scsi/scsi_debug.c  |   27 ++---
 drivers/scsi/sd.c  |   50 +++-
 drivers/scsi/sd_zbc.c  |   16 ---
 fs/btrfs/zoned.c   |   23 +--
 fs/btrfs/zoned.h   |2 
 fs/f2fs/data.c |2 
 fs/f2fs/super.c|   17 +++-
 include/linux/blkdev.h |   38 +-
 21 files changed, 124 insertions(+), 302 deletions(-)


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 5/5] sd: only call disk_clear_zoned when needed

2023-12-17 Thread Christoph Hellwig
disk_clear_zoned only needs to be called when a device reported zone
managed mode first and we clear it.  Add a check so that disk_clear_zoned
isn't called on devices that were never zoned.

This avoids a fairly expensive queue freezing when revalidating
conventional devices.

Signed-off-by: Christoph Hellwig 
---
 drivers/scsi/sd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index dbed075cdb981a..8c8ac5cd1833b4 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -3149,7 +3149,7 @@ static void sd_read_block_characteristics(struct 
scsi_disk *sdkp)
 * the device physical block size.
 */
blk_queue_zone_write_granularity(q, sdkp->physical_block_size);
-   } else {
+   } else if (blk_queue_is_zoned(q)) {
/*
 * Anything else.  This includes host-aware device that we treat
 * as conventional.
-- 
2.39.2



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 1/5] virtio_blk: cleanup zoned device probing

2023-12-17 Thread Christoph Hellwig
Move reading and checking the zoned model from virtblk_probe_zoned_device
into the caller, leaving only the code to perform the actual setup for
host managed zoned devices in virtblk_probe_zoned_device.

This allows to share the model reading and sharing between builds with
and without CONFIG_BLK_DEV_ZONED, and improve it for the
!CONFIG_BLK_DEV_ZONED case.

Signed-off-by: Christoph Hellwig 
---
 drivers/block/virtio_blk.c | 50 +-
 1 file changed, 22 insertions(+), 28 deletions(-)

diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index d53d6aa8ee69a4..aeead732a24dc9 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -748,22 +748,6 @@ static int virtblk_probe_zoned_device(struct virtio_device 
*vdev,
   struct request_queue *q)
 {
u32 v, wg;
-   u8 model;
-
-   virtio_cread(vdev, struct virtio_blk_config,
-zoned.model, &model);
-
-   switch (model) {
-   case VIRTIO_BLK_Z_NONE:
-   case VIRTIO_BLK_Z_HA:
-   /* Present the host-aware device as non-zoned */
-   return 0;
-   case VIRTIO_BLK_Z_HM:
-   break;
-   default:
-   dev_err(&vdev->dev, "unsupported zone model %d\n", model);
-   return -EINVAL;
-   }
 
dev_dbg(&vdev->dev, "probing host-managed zoned device\n");
 
@@ -846,16 +830,9 @@ static inline void virtblk_revalidate_zones(struct 
virtio_blk *vblk)
 static inline int virtblk_probe_zoned_device(struct virtio_device *vdev,
struct virtio_blk *vblk, struct request_queue *q)
 {
-   u8 model;
-
-   virtio_cread(vdev, struct virtio_blk_config, zoned.model, &model);
-   if (model == VIRTIO_BLK_Z_HM) {
-   dev_err(&vdev->dev,
-   "virtio_blk: zoned devices are not supported");
-   return -EOPNOTSUPP;
-   }
-
-   return 0;
+   dev_err(&vdev->dev,
+   "virtio_blk: zoned devices are not supported");
+   return -EOPNOTSUPP;
 }
 #endif /* CONFIG_BLK_DEV_ZONED */
 
@@ -1570,9 +1547,26 @@ static int virtblk_probe(struct virtio_device *vdev)
 * placed after the virtio_device_ready() call above.
 */
if (virtio_has_feature(vdev, VIRTIO_BLK_F_ZONED)) {
-   err = virtblk_probe_zoned_device(vdev, vblk, q);
-   if (err)
+   u8 model;
+
+   virtio_cread(vdev, struct virtio_blk_config, zoned.model,
+   &model);
+   switch (model) {
+   case VIRTIO_BLK_Z_NONE:
+   case VIRTIO_BLK_Z_HA:
+   /* Present the host-aware device as non-zoned */
+   break;
+   case VIRTIO_BLK_Z_HM:
+   err = virtblk_probe_zoned_device(vdev, vblk, q);
+   if (err)
+   goto out_cleanup_disk;
+   break;
+   default:
+   dev_err(&vdev->dev, "unsupported zone model %d\n",
+   model);
+   err = -EINVAL;
goto out_cleanup_disk;
+   }
}
 
err = device_add_disk(&vdev->dev, vblk->disk, virtblk_attr_groups);
-- 
2.39.2



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 4/5] block: simplify disk_set_zoned

2023-12-17 Thread Christoph Hellwig
Only use disk_set_zoned to actually enable zoned device support.
For clearing it, call disk_clear_zoned, which is renamed from
disk_clear_zone_settings and now directly clears the zoned flag as
well.

Signed-off-by: Christoph Hellwig 
---
 block/blk-settings.c   | 32 +++-
 block/blk-zoned.c  |  3 ++-
 block/blk.h|  2 --
 drivers/block/null_blk/zoned.c |  2 +-
 drivers/block/ublk_drv.c   |  2 +-
 drivers/block/virtio_blk.c |  2 +-
 drivers/nvme/host/zns.c|  2 +-
 drivers/scsi/sd.c  |  7 +--
 include/linux/blkdev.h |  3 ++-
 9 files changed, 24 insertions(+), 31 deletions(-)

diff --git a/block/blk-settings.c b/block/blk-settings.c
index 50e9efb59f67fd..bb94a3d471f4fb 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -881,31 +881,21 @@ bool blk_queue_can_use_dma_map_merging(struct 
request_queue *q,
 EXPORT_SYMBOL_GPL(blk_queue_can_use_dma_map_merging);
 
 /**
- * disk_set_zoned - configure the zoned model for a disk
- * @disk:  the gendisk of the queue to configure
- * @zoned: zoned or not.
- *
- * When @zoned is %true, this should be called only if zoned block device
- * support is enabled (CONFIG_BLK_DEV_ZONED option).
+ * disk_set_zoned - inidicate a zoned device
+ * @disk:  gendisk to configure
  */
-void disk_set_zoned(struct gendisk *disk, bool zoned)
+void disk_set_zoned(struct gendisk *disk)
 {
struct request_queue *q = disk->queue;
 
-   if (zoned) {
-   WARN_ON_ONCE(!IS_ENABLED(CONFIG_BLK_DEV_ZONED));
-
-   /*
-* Set the zone write granularity to the device logical block
-* size by default. The driver can change this value if needed.
-*/
-   q->limits.zoned = true;
-   blk_queue_zone_write_granularity(q,
-   queue_logical_block_size(q));
-   } else if (q->limits.zoned) {
-   q->limits.zoned = false;
-   disk_clear_zone_settings(disk);
-   }
+   WARN_ON_ONCE(!IS_ENABLED(CONFIG_BLK_DEV_ZONED));
+
+   /*
+* Set the zone write granularity to the device logical block
+* size by default. The driver can change this value if needed.
+*/
+   q->limits.zoned = true;
+   blk_queue_zone_write_granularity(q, queue_logical_block_size(q));
 }
 EXPORT_SYMBOL_GPL(disk_set_zoned);
 
diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 619ee41a51cc8c..580a58e53efd77 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -616,12 +616,13 @@ int blk_revalidate_disk_zones(struct gendisk *disk,
 }
 EXPORT_SYMBOL_GPL(blk_revalidate_disk_zones);
 
-void disk_clear_zone_settings(struct gendisk *disk)
+void disk_clear_zoned(struct gendisk *disk)
 {
struct request_queue *q = disk->queue;
 
blk_mq_freeze_queue(q);
 
+   q->limits.zoned = false;
disk_free_zone_bitmaps(disk);
blk_queue_flag_clear(QUEUE_FLAG_ZONE_RESETALL, q);
q->required_elevator_features &= ~ELEVATOR_F_ZBD_SEQ_WRITE;
diff --git a/block/blk.h b/block/blk.h
index 08a358bc0919e2..1ef920f72e0f87 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -395,14 +395,12 @@ static inline struct bio *blk_queue_bounce(struct bio 
*bio,
 
 #ifdef CONFIG_BLK_DEV_ZONED
 void disk_free_zone_bitmaps(struct gendisk *disk);
-void disk_clear_zone_settings(struct gendisk *disk);
 int blkdev_report_zones_ioctl(struct block_device *bdev, unsigned int cmd,
unsigned long arg);
 int blkdev_zone_mgmt_ioctl(struct block_device *bdev, blk_mode_t mode,
unsigned int cmd, unsigned long arg);
 #else /* CONFIG_BLK_DEV_ZONED */
 static inline void disk_free_zone_bitmaps(struct gendisk *disk) {}
-static inline void disk_clear_zone_settings(struct gendisk *disk) {}
 static inline int blkdev_report_zones_ioctl(struct block_device *bdev,
unsigned int cmd, unsigned long arg)
 {
diff --git a/drivers/block/null_blk/zoned.c b/drivers/block/null_blk/zoned.c
index 369eb1e78bb579..6f5e0994862eae 100644
--- a/drivers/block/null_blk/zoned.c
+++ b/drivers/block/null_blk/zoned.c
@@ -159,7 +159,7 @@ int null_register_zoned_dev(struct nullb *nullb)
struct nullb_device *dev = nullb->dev;
struct request_queue *q = nullb->q;
 
-   disk_set_zoned(nullb->disk, true);
+   disk_set_zoned(nullb->disk);
blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q);
blk_queue_required_elevator_features(q, ELEVATOR_F_ZBD_SEQ_WRITE);
blk_queue_chunk_sectors(q, dev->zone_size_sects);
diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
index 24fb95f19d5284..d50d69b2c023de 100644
--- a/drivers/block/ublk_drv.c
+++ b/drivers/block/ublk_drv.c
@@ -250,7 +250,7 @@ static int ublk_dev_param_zoned_apply(struct ublk_device 
*ub)
 {
const struct ublk_param_zoned *p = &ub->params

Re: [f2fs-dev] [PATCH 1/3] btrfs: call btrfs_close_devices from ->kill_sb

2023-12-15 Thread Christoph Hellwig
On Fri, Dec 15, 2023 at 04:45:50PM -0500, Josef Bacik wrote:
> I ran it through, you broke a test that isn't upstream yet to test the old 
> mount
> api double mount thing that I have a test for
> 
> https://github.com/btrfs/fstests/commit/2796723e77adb0f9da1059acf13fc402467f7ac4
> 
> In this case we end up leaking a reference on the fs_devices.  If you add this
> fixup to "btrfs: call btrfs_close_devices from ->kill_sb" it fixes that 
> failure.
> I'm re-running with that fixup applied, but I assume the rest is fine.  
> Thanks,

Is "this fixup" referring to a patch that was supposed to be attached
but is't? :)


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH 3/3] fs: move fscrypt keyring destruction to after ->put_super

2023-12-13 Thread Christoph Hellwig
Looks good:

Reviewed-by: Christoph Hellwig 


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH 1/3] btrfs: call btrfs_close_devices from ->kill_sb

2023-12-13 Thread Christoph Hellwig
On Tue, Dec 12, 2023 at 08:00:16PM -0800, Eric Biggers wrote:
> From: Christoph Hellwig 
> 
> blkdev_put must not be called under sb->s_umount to avoid a lock order
> reversal with disk->open_mutex once call backs from block devices to
> the file system using the holder ops are supported.  Move the call
> to btrfs_close_devices into btrfs_free_fs_info so that it is closed
> from ->kill_sb (which is also called from the mount failure handling
> path unlike ->put_super) as well as when an fs_info is freed because
> an existing superblock already exists.

Thanks, this looks roughly the same to what I have locally.

I did in fact forward port everything missing from the get_super
series yesterday, but on my test setup btrfs/142 hangs even in the
baseline setup.  I went back to Linux before giving up for now.

Josef, any chane you could throw this branch:

git://git.infradead.org/users/hch/misc.git btrfs-holder

into your CI setup and see if it sticks?  Except for the trivial last
three patches this is basically what you reviewed already, although
there was some heavy rebasing due to the mount API converison.



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH 03/12] filemap: update ki_pos in generic_perform_write

2023-09-13 Thread Christoph Hellwig
> direct_write_fallback(): on error revert the ->ki_pos update from buffered 
> write

Al, Christian: can you send this fix on top Linus?



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH v2 0/29] block: Make blkdev_get_by_*() return handle

2023-08-28 Thread Christoph Hellwig
On Sat, Aug 26, 2023 at 03:28:52AM +0100, Al Viro wrote:
> I mean, look at claim_swapfile() for example:
> p->bdev = blkdev_get_by_dev(inode->i_rdev,
>FMODE_READ | FMODE_WRITE | FMODE_EXCL, p);
> if (IS_ERR(p->bdev)) {
> error = PTR_ERR(p->bdev);
> p->bdev = NULL;
> return error;
> }
> p->old_block_size = block_size(p->bdev);
> error = set_blocksize(p->bdev, PAGE_SIZE);
> if (error < 0)
> return error;
> we already have the file opened, and we keep it opened all the way until
> the swapoff(2); here we have noticed that it's a block device and we
>   * open the fucker again (by device number), this time claiming
> it with our swap_info_struct as holder, to be closed at swapoff(2) time
> (just before we close the file)

Note that some drivers look at FMODE_EXCL/BLK_OPEN_EXCL in ->open.
These are probably bogus and maybe we want to kill them, but that will
need an audit first.

> BTW, what happens if two threads call ioctl(fd, BLKBSZSET, &n)
> for the same descriptor that happens to have been opened O_EXCL?
> Without O_EXCL they would've been unable to claim the sucker at the same
> time - the holder we are using is the address of a function argument,
> i.e. something that points to kernel stack of the caller.  Those would
> conflict and we either get set_blocksize() calls fully serialized, or
> one of the callers would eat -EBUSY.  Not so in "opened with O_EXCL"
> case - they can very well overlap and IIRC set_blocksize() does *not*
> expect that kind of crap...  It's all under CAP_SYS_ADMIN, so it's not
> as if it was a meaningful security hole anyway, but it does look fishy.

The user get to keep the pieces..  BLKBSZSET is kinda bogus anyway
as the soft blocksize only matters for buffer_head-like I/O, and
there only for file systems.  Not idea why anyone would set it manually.


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH v2 0/29] block: Make blkdev_get_by_*() return handle

2023-08-28 Thread Christoph Hellwig
On Fri, Aug 25, 2023 at 03:47:56PM +0200, Jan Kara wrote:
> I can see the appeal of not having to introduce the new bdev_handle type
> and just using struct file which unifies in-kernel and userspace block
> device opens. But I can see downsides too - the last fput() happening from
> task work makes me a bit nervous whether it will not break something
> somewhere with exclusive bdev opens. Getting from struct file to bdev is
> somewhat harder but I guess a helper like F_BDEV() would solve that just
> fine.
> 
> So besides my last fput() worry about I think this could work and would be
> probably a bit nicer than what I have. But before going and redoing the whole
> series let me gather some more feedback so that we don't go back and forth.
> Christoph, Christian, Jens, any opinion?

I did think about the file a bit.  The fact that we'd need something
like an anon_file for the by_dev open was always a huge turn off for
me, but maybe my concern is overblown.  Having a struct file would
actually be really useful for a bunch of users.



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH 03/12] filemap: update ki_pos in generic_perform_write

2023-08-28 Thread Christoph Hellwig
On Mon, Aug 28, 2023 at 02:56:15PM +0100, Al Viro wrote:
> The first failure exit does not need any work - the caller had not bumped
> ->ki_pos; the second one (after that 'if (err < 0) {' line) does and that's
> where the patch upthread adds iocb->ki_pos -= buffered_written.
> 
> Or am I completely misparsing what you've written?

No, I misread the patch.  Looks good:

Acked-by: Christoph Hellwig 


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH 03/12] filemap: update ki_pos in generic_perform_write

2023-08-28 Thread Christoph Hellwig
On Sun, Aug 27, 2023 at 10:45:18PM +0100, Al Viro wrote:
> IOW, I suspect that the right thing to do would be something along the lines
> of

The idea looks sensible to me, but we'll also need to do it for the
filemap_write_and_wait_range failure case.



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH 03/12] filemap: update ki_pos in generic_perform_write

2023-08-28 Thread Christoph Hellwig
On Sun, Aug 27, 2023 at 08:41:22PM +0100, Al Viro wrote:
> That part is somewhat fishy - there's a case where you return a positive value
> and advance ->ki_pos by more than that amount.  I really wonder if all callers
> of ->write_iter() are OK with that.  Consider e.g. this:

This should not exist in the latest version merged by Jens.  Can you
check if you still  see issues in the version in the block tree or
linux-next.

> Suppose ->write_iter() ends up doing returning a positive value smaller than
> the increment of kiocb.ki_pos.  What do we get?  ret is positive, so
> kiocb.ki_pos gets copied into *ppos, which is ksys_write's pos and there
> we copy it into file->f_pos.
> 
> Is it really OK to have write() return 4096 and advance the file position
> by 16K?  AFAICS, userland wouldn't get any indication of something
> odd going on - just a short write to a regular file, with followup write
> of remaining 12K getting quietly written in the range 16K..28K.
> 
> I don't remember what POSIX says about that, but it would qualify as
> nasty surprise for any userland program - sure, one can check fsync()
> results before closing the sucker and see if everything looks fine,
> but the way it's usually discussed could easily lead to assumption that
> (synchronous) O_DIRECT writes would not be affected by anything of that
> sort.

ki_pos should always be updated by the write return value.  Everything
else is a bug.


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH 01/30] block: also call ->open for incremental partition opens

2023-08-28 Thread Christoph Hellwig
On Fri, Aug 25, 2023 at 03:44:57AM +0100, Al Viro wrote:
> That got me curious about the ->bd_openers - do we need it atomic?
> Most of the users (and all places that do modifications) are
> under ->open_mutex; the only exceptions are
>   * early sync logics in blkdev_put(); it's explicitly racy -
> see the comment there.
>   * callers of disk_openers() in loop and nbd (the ones in
> zram are under ->open_mutex).  There's driver-private exclusion
> around those, but in any case - READ_ONCE() is no worse than
> atomic_read() in those cases.
> 
> Is there something subtle I'm missing here?

No.  When I had to add unlocked readers I did the READ_ONCE initially,
but reviewers though the atomic_t would be better.  I didn't really feel
like arguing so went with this version.


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH v2 0/29] block: Make blkdev_get_by_*() return handle

2023-08-11 Thread Christoph Hellwig
Except for a mostly cosmetic nitpick this looks good to me:

Acked-by: Christoph Hellwig 

That's not eactly the deep review I'd like to do, but as I'm about to
head out for vacation that's probably as good as it gets.


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH 06/12] fs: use the super_block as holder when mounting file systems

2023-08-05 Thread Christoph Hellwig
On Thu, Aug 03, 2023 at 03:33:30PM +0200, Jan Kara wrote:
> As a side note, after this patch we can also remove bdev->bd_super and
> transition the two real users (mark_buffer_write_io_error() and two places
> in ocfs2) to use bd_holder. Ext4 also uses bd_super but there it is really
> pointless as we have the superblock directly available in that function
> anyway.

I actually have a series to kill bd_super, but it uses b_assoc_map
as the replacement, as nothing in buffer.c should poke into the holder
and the buffer_head codes uses b_assoc_map a lot anyway.  Let me rebase
it and send it out.


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH 11/12] xfs: drop s_umount over opening the log and RT devices

2023-08-05 Thread Christoph Hellwig
On Wed, Aug 02, 2023 at 09:32:19AM -0700, Darrick J. Wong wrote:
> > +   /* see get_tree_bdev why this is needed and safe */
> 
> Which part of get_tree_bdev?  Is it this?
> 
>   /*
>* s_umount nests inside open_mutex during
>* __invalidate_device().  blkdev_put() acquires
>* open_mutex and can't be called under s_umount.  Drop
>* s_umount temporarily.  This is safe as we're
>* holding an active reference.
>*/
>   up_write(&s->s_umount);
>   blkdev_put(bdev, fc->fs_type);
>   down_write(&s->s_umount);

Yes.  With the refactoring earlier in the series get_tree_bdev should
be trivial enough to not need a more specific reference.  If you
think there's a better way to refer to it I can update the comment,
though.

> > mp->m_logdev_targp = mp->m_ddev_targp;
> > }
> >  
> > -   return 0;
> > +   error = 0;
> > +out_unlock:
> > +   down_write(&sb->s_umount);
> 
> Isn't down_write taking s_umount?  I think the label should be
> out_relock or something less misleading.

Agreed.  Christian, can you just change this in your branch, or should
I send an incremental patch?



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 12/12] xfs use fs_holder_ops for the log and RT devices

2023-08-02 Thread Christoph Hellwig
Use the generic fs_holder_ops to shut down the file system when the
log or RT device goes away instead of duplicating the logic.

Signed-off-by: Christoph Hellwig 
---
 fs/xfs/xfs_super.c | 17 +++--
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index d5042419ed9997..338eba71ff8667 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -377,17 +377,6 @@ xfs_setup_dax_always(
return 0;
 }
 
-static void
-xfs_bdev_mark_dead(
-   struct block_device *bdev)
-{
-   xfs_force_shutdown(bdev->bd_holder, SHUTDOWN_DEVICE_REMOVED);
-}
-
-static const struct blk_holder_ops xfs_holder_ops = {
-   .mark_dead  = xfs_bdev_mark_dead,
-};
-
 STATIC int
 xfs_blkdev_get(
xfs_mount_t *mp,
@@ -396,8 +385,8 @@ xfs_blkdev_get(
 {
int error = 0;
 
-   *bdevp = blkdev_get_by_path(name, BLK_OPEN_READ | BLK_OPEN_WRITE, mp,
-   &xfs_holder_ops);
+   *bdevp = blkdev_get_by_path(name, BLK_OPEN_READ | BLK_OPEN_WRITE,
+   mp->m_super, &fs_holder_ops);
if (IS_ERR(*bdevp)) {
error = PTR_ERR(*bdevp);
xfs_warn(mp, "Invalid device [%s], error=%d", name, error);
@@ -412,7 +401,7 @@ xfs_blkdev_put(
struct block_device *bdev)
 {
if (bdev)
-   blkdev_put(bdev, mp);
+   blkdev_put(bdev, mp->m_super);
 }
 
 STATIC void
-- 
2.39.2



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 10/12] ext4: use fs_holder_ops for the log device

2023-08-02 Thread Christoph Hellwig
Use the generic fs_holder_ops to shut down the file system when the
log device goes away instead of duplicating the logic.

Signed-off-by: Christoph Hellwig 
---
 fs/ext4/super.c | 11 +--
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 2ccb19d345c6dd..063832e2d12a8e 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1096,15 +1096,6 @@ void ext4_update_dynamic_rev(struct super_block *sb)
 */
 }
 
-static void ext4_bdev_mark_dead(struct block_device *bdev)
-{
-   ext4_force_shutdown(bdev->bd_holder, EXT4_GOING_FLAGS_NOLOGFLUSH);
-}
-
-static const struct blk_holder_ops ext4_holder_ops = {
-   .mark_dead  = ext4_bdev_mark_dead,
-};
-
 /*
  * Open the external journal device
  */
@@ -1113,7 +1104,7 @@ static struct block_device *ext4_blkdev_get(dev_t dev, 
struct super_block *sb)
struct block_device *bdev;
 
bdev = blkdev_get_by_dev(dev, BLK_OPEN_READ | BLK_OPEN_WRITE, sb,
-&ext4_holder_ops);
+&fs_holder_ops);
if (IS_ERR(bdev))
goto fail;
return bdev;
-- 
2.39.2



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 04/12] btrfs: open block devices after superblock creation

2023-08-02 Thread Christoph Hellwig
Currently btrfs_mount_root opens the block devices before committing to
allocating a super block. That creates problems for restricting the
number of writers to a device, and also leads to a unusual and not very
helpful holder (the fs_type).

Reorganize the code to first look whether the superblock for a
particular fsid does already exist and open the block devices only if it
doesn't, mirror the recent changes to the VFS mount helpers.

Signed-off-by: Christoph Hellwig 
---
 fs/btrfs/super.c   | 51 ++
 fs/btrfs/volumes.c |  4 ++--
 2 files changed, 26 insertions(+), 29 deletions(-)

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index b318bddefd5236..5980b5dcc6b163 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -1434,10 +1434,8 @@ static struct dentry *mount_subvol(const char 
*subvol_name, u64 subvol_objectid,
 static struct dentry *btrfs_mount_root(struct file_system_type *fs_type,
int flags, const char *device_name, void *data)
 {
-   struct block_device *bdev = NULL;
struct super_block *s;
struct btrfs_device *device = NULL;
-   struct btrfs_fs_devices *fs_devices = NULL;
struct btrfs_fs_info *fs_info = NULL;
void *new_sec_opts = NULL;
int error = 0;
@@ -1483,35 +1481,36 @@ static struct dentry *btrfs_mount_root(struct 
file_system_type *fs_type,
error = PTR_ERR(device);
goto error_fs_info;
}
-
-   fs_devices = device->fs_devices;
-   fs_info->fs_devices = fs_devices;
-
-   error = btrfs_open_devices(fs_devices, sb_open_mode(flags), fs_type);
+   fs_info->fs_devices = device->fs_devices;
mutex_unlock(&uuid_mutex);
-   if (error)
-   goto error_fs_info;
-
-   if (!(flags & SB_RDONLY) && fs_devices->rw_devices == 0) {
-   error = -EACCES;
-   goto error_close_devices;
-   }
 
-   bdev = fs_devices->latest_dev->bdev;
s = sget(fs_type, btrfs_test_super, btrfs_set_super, flags | SB_NOSEC,
 fs_info);
if (IS_ERR(s)) {
error = PTR_ERR(s);
-   goto error_close_devices;
+   goto error_fs_info;
}
 
if (s->s_root) {
-   btrfs_close_devices(fs_devices);
btrfs_free_fs_info(fs_info);
if ((flags ^ s->s_flags) & SB_RDONLY)
error = -EBUSY;
} else {
-   snprintf(s->s_id, sizeof(s->s_id), "%pg", bdev);
+   struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
+
+   error = btrfs_open_devices(fs_devices, sb_open_mode(flags),
+  fs_type);
+   if (error)
+   goto out_deactivate;
+
+   if (!(flags & SB_RDONLY) && fs_devices->rw_devices == 0) {
+   error = -EACCES;
+   btrfs_close_devices(fs_info->fs_devices);
+   goto out_deactivate;
+   }
+
+   snprintf(s->s_id, sizeof(s->s_id), "%pg",
+fs_devices->latest_dev->bdev);
shrinker_debugfs_rename(&s->s_shrink, "sb-%s:%s", fs_type->name,
s->s_id);
btrfs_sb(s)->bdev_holder = fs_type;
@@ -1519,21 +1518,19 @@ static struct dentry *btrfs_mount_root(struct 
file_system_type *fs_type,
}
if (!error)
error = security_sb_set_mnt_opts(s, new_sec_opts, 0, NULL);
+   if (error)
+   goto out_deactivate;
security_free_mnt_opts(&new_sec_opts);
-   if (error) {
-   deactivate_locked_super(s);
-   return ERR_PTR(error);
-   }
-
return dget(s->s_root);
 
-error_close_devices:
-   btrfs_close_devices(fs_devices);
-error_fs_info:
-   btrfs_free_fs_info(fs_info);
+out_deactivate:
+   deactivate_locked_super(s);
 error_sec_opts:
security_free_mnt_opts(&new_sec_opts);
return ERR_PTR(error);
+error_fs_info:
+   btrfs_free_fs_info(fs_info);
+   goto error_sec_opts;
 }
 
 /*
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 8246578c70f55b..88e9daae5e74ed 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1269,7 +1269,6 @@ int btrfs_open_devices(struct btrfs_fs_devices 
*fs_devices,
 {
int ret;
 
-   lockdep_assert_held(&uuid_mutex);
/*
 * The device_list_mutex cannot be taken here in case opening the
 * underlying device takes further locks like open_mutex.
@@ -1277,7 +1276,7 @@ int btrfs_open_devices(struct btrfs_fs_devices 
*fs_devices,
 * We also don't need the lock here as this is called during mount and
 * exclusion is provided by uuid_mutex
 */

[f2fs-dev] [PATCH 07/12] fs: stop using get_super in fs_mark_dead

2023-08-02 Thread Christoph Hellwig
fs_mark_dead currently uses get_super to find the superblock for the
block device that is going away.  This means it is limited to the
main device stored in sb->s_dev, leading to a lot of code duplication
for file systems that can use multiple block devices.

Now that the holder for all block devices used by file systems is set
to the super_block, we can instead look at that holder and then check
if the file system is born and active, so do that instead.

Signed-off-by: Christoph Hellwig 
---
 fs/super.c | 30 ++
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/fs/super.c b/fs/super.c
index 09b65ee1a8b737..0cda4af0a7e16c 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -1209,17 +1209,39 @@ int get_tree_keyed(struct fs_context *fc,
 EXPORT_SYMBOL(get_tree_keyed);
 
 #ifdef CONFIG_BLOCK
+/*
+ * Lock a super block that the callers holds a reference to.
+ *
+ * The caller needs to ensure that the super_block isn't being freed while
+ * calling this function, e.g. by holding a lock over the call to this function
+ * and the place that clears the pointer to the superblock used by this 
function
+ * before freeing the superblock.
+ */
+static bool lock_active_super(struct super_block *sb)
+{
+   down_read(&sb->s_umount);
+   if (!sb->s_root ||
+   (sb->s_flags & (SB_ACTIVE | SB_BORN)) != (SB_ACTIVE | SB_BORN)) {
+   up_read(&sb->s_umount);
+   return false;
+   }
+   return true;
+}
+
 static void fs_mark_dead(struct block_device *bdev)
 {
-   struct super_block *sb;
+   struct super_block *sb = bdev->bd_holder;
 
-   sb = get_super(bdev);
-   if (!sb)
+   /* bd_holder_lock ensures that the sb isn't freed */
+   lockdep_assert_held(&bdev->bd_holder_lock);
+
+   if (!lock_active_super(sb))
return;
 
if (sb->s_op->shutdown)
sb->s_op->shutdown(sb);
-   drop_super(sb);
+
+   up_read(&sb->s_umount);
 }
 
 static const struct blk_holder_ops fs_holder_ops = {
-- 
2.39.2



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 11/12] xfs: drop s_umount over opening the log and RT devices

2023-08-02 Thread Christoph Hellwig
Just like get_tree_bdev needs to drop s_umount when opening the main
device, we need to do the same for the xfs log and RT devices to avoid a
potential lock order reversal with s_unmount for the mark_dead path.

It might be preferable to just drop s_umount over ->fill_super entirely,
but that will require a fairly massive audit first, so we'll do the easy
version here first.

Signed-off-by: Christoph Hellwig 
---
 fs/xfs/xfs_super.c | 15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 8185102431301d..d5042419ed9997 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -448,17 +448,21 @@ STATIC int
 xfs_open_devices(
struct xfs_mount*mp)
 {
-   struct block_device *ddev = mp->m_super->s_bdev;
+   struct super_block  *sb = mp->m_super;
+   struct block_device *ddev = sb->s_bdev;
struct block_device *logdev = NULL, *rtdev = NULL;
int error;
 
+   /* see get_tree_bdev why this is needed and safe */
+   up_write(&sb->s_umount);
+
/*
 * Open real time and log devices - order is important.
 */
if (mp->m_logname) {
error = xfs_blkdev_get(mp, mp->m_logname, &logdev);
if (error)
-   return error;
+   goto out_unlock;
}
 
if (mp->m_rtname) {
@@ -496,7 +500,10 @@ xfs_open_devices(
mp->m_logdev_targp = mp->m_ddev_targp;
}
 
-   return 0;
+   error = 0;
+out_unlock:
+   down_write(&sb->s_umount);
+   return error;
 
  out_free_rtdev_targ:
if (mp->m_rtdev_targp)
@@ -508,7 +515,7 @@ xfs_open_devices(
  out_close_logdev:
if (logdev && logdev != ddev)
xfs_blkdev_put(mp, logdev);
-   return error;
+   goto out_unlock;
 }
 
 /*
-- 
2.39.2



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] more blkdev_get and holder work

2023-08-02 Thread Christoph Hellwig
Hi all,

this series sits on top of the vfs.super branch in the VFS tree and does a
few closely related things:

  1) it also converts nilfs2 and btrfs to the new scheme where the file system
 only opens the block devices after we know that a new super_block was
 allocated.
  2) it then makes sure that for all file system openers the super_block is
 stored in bd_holder, and makes use of that fact in the mark_dead method
 so that it doesn't have to fall get_super and thus can also work on
 block devices that sb->s_bdev doesn't point to
  3) it then drops the fs-specific holder ops in ext4 and xfs and uses the
 generic fs_holder_ops there

A git tree is available here:

git://git.infradead.org/users/hch/misc.git fs-holder-rework

Gitweb:


http://git.infradead.org/users/hch/misc.git/shortlog/refs/heads/fs-holder-rework

Diffstat:
 fs/btrfs/super.c   |   67 -
 fs/btrfs/volumes.c |8 ++--
 fs/btrfs/volumes.h |2 -
 fs/ext4/super.c|   18 +++---
 fs/f2fs/super.c|7 +--
 fs/nilfs2/super.c  |   81 -
 fs/super.c |   44 ++--
 fs/xfs/xfs_super.c |   32 +++--
 include/linux/blkdev.h |2 +
 include/linux/fs_context.h |2 +
 10 files changed, 126 insertions(+), 137 deletions(-)


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 08/12] fs: export fs_holder_ops

2023-08-02 Thread Christoph Hellwig
Export fs_holder_ops so that file systems that open additional block
devices can use it as well.

Signed-off-by: Christoph Hellwig 
---
 fs/super.c | 3 ++-
 include/linux/blkdev.h | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/super.c b/fs/super.c
index 0cda4af0a7e16c..dac05f96ab9ac8 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -1244,9 +1244,10 @@ static void fs_mark_dead(struct block_device *bdev)
up_read(&sb->s_umount);
 }
 
-static const struct blk_holder_ops fs_holder_ops = {
+const struct blk_holder_ops fs_holder_ops = {
.mark_dead  = fs_mark_dead,
 };
+EXPORT_SYMBOL_GPL(fs_holder_ops);
 
 static int set_bdev_super(struct super_block *s, void *data)
 {
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index ed44a997f629f5..83262702eea71a 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1464,6 +1464,8 @@ struct blk_holder_ops {
void (*mark_dead)(struct block_device *bdev);
 };
 
+extern const struct blk_holder_ops fs_holder_ops;
+
 /*
  * Return the correct open flags for blkdev_get_by_* for super block flags
  * as stored in sb->s_flags.
-- 
2.39.2



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 01/12] fs: export setup_bdev_super

2023-08-02 Thread Christoph Hellwig
We'll want to use setup_bdev_super instead of duplicating it in nilfs2.

Signed-off-by: Christoph Hellwig 
---
 fs/super.c | 3 ++-
 include/linux/fs_context.h | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/super.c b/fs/super.c
index 3ef39df5bec506..6aaa275fa8630d 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -1243,7 +1243,7 @@ static int test_bdev_super_fc(struct super_block *s, 
struct fs_context *fc)
s->s_dev == *(dev_t *)fc->sget_key;
 }
 
-static int setup_bdev_super(struct super_block *sb, int sb_flags,
+int setup_bdev_super(struct super_block *sb, int sb_flags,
struct fs_context *fc)
 {
blk_mode_t mode = sb_open_mode(sb_flags);
@@ -1295,6 +1295,7 @@ static int setup_bdev_super(struct super_block *sb, int 
sb_flags,
sb_set_blocksize(sb, block_size(bdev));
return 0;
 }
+EXPORT_SYMBOL_GPL(setup_bdev_super);
 
 /**
  * get_tree_bdev - Get a superblock based on a single block device
diff --git a/include/linux/fs_context.h b/include/linux/fs_context.h
index ff6341e09925bc..58ef8433a94b8c 100644
--- a/include/linux/fs_context.h
+++ b/include/linux/fs_context.h
@@ -158,6 +158,8 @@ extern int get_tree_keyed(struct fs_context *fc,
   struct fs_context *fc),
 void *key);
 
+int setup_bdev_super(struct super_block *sb, int sb_flags,
+   struct fs_context *fc);
 extern int get_tree_bdev(struct fs_context *fc,
   int (*fill_super)(struct super_block *sb,
 struct fs_context *fc));
-- 
2.39.2



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 09/12] ext4: drop s_umount over opening the log device

2023-08-02 Thread Christoph Hellwig
Just like get_tree_bdev needs to drop s_umount when opening the main
device, we need to do the same for the ext4 log device to avoid a
potential lock order reversal with s_unmount for the mark_dead path.

It might be preferable to just drop s_umount over ->fill_super entirely,
but that will require a fairly massive audit first, so we'll do the easy
version here first.

Signed-off-by: Christoph Hellwig 
---
 fs/ext4/super.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 193d665813b611..2ccb19d345c6dd 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -5854,7 +5854,10 @@ static journal_t *ext4_get_dev_journal(struct 
super_block *sb,
if (WARN_ON_ONCE(!ext4_has_feature_journal(sb)))
return NULL;
 
+   /* see get_tree_bdev why this is needed and safe */
+   up_write(&sb->s_umount);
bdev = ext4_blkdev_get(j_dev, sb);
+   down_write(&sb->s_umount);
if (bdev == NULL)
return NULL;
 
-- 
2.39.2



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 06/12] fs: use the super_block as holder when mounting file systems

2023-08-02 Thread Christoph Hellwig
The file system type is not a very useful holder as it doesn't allow us
to go back to the actual file system instance.  Pass the super_block instead
which is useful when passed back to the file system driver.

Signed-off-by: Christoph Hellwig 
---
 fs/btrfs/super.c | 7 ++-
 fs/f2fs/super.c  | 7 +++
 fs/super.c   | 8 
 3 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 5980b5dcc6b163..8a47c7f2690880 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -69,8 +69,6 @@ static const struct super_operations btrfs_super_ops;
  * requested by subvol=/path. That way the callchain is straightforward and we
  * don't have to play tricks with the mount options and recursive calls to
  * btrfs_mount.
- *
- * The new btrfs_root_fs_type also servers as a tag for the bdev_holder.
  */
 static struct file_system_type btrfs_fs_type;
 static struct file_system_type btrfs_root_fs_type;
@@ -1498,8 +1496,7 @@ static struct dentry *btrfs_mount_root(struct 
file_system_type *fs_type,
} else {
struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
 
-   error = btrfs_open_devices(fs_devices, sb_open_mode(flags),
-  fs_type);
+   error = btrfs_open_devices(fs_devices, sb_open_mode(flags), s);
if (error)
goto out_deactivate;
 
@@ -1513,7 +1510,7 @@ static struct dentry *btrfs_mount_root(struct 
file_system_type *fs_type,
 fs_devices->latest_dev->bdev);
shrinker_debugfs_rename(&s->s_shrink, "sb-%s:%s", fs_type->name,
s->s_id);
-   btrfs_sb(s)->bdev_holder = fs_type;
+   fs_info->bdev_holder = s;
error = btrfs_fill_super(s, fs_devices, data);
}
if (!error)
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index ca31163da00a55..05c90fdb7a6cca 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -1561,7 +1561,7 @@ static void destroy_device_list(struct f2fs_sb_info *sbi)
int i;
 
for (i = 0; i < sbi->s_ndevs; i++) {
-   blkdev_put(FDEV(i).bdev, sbi->sb->s_type);
+   blkdev_put(FDEV(i).bdev, sbi->sb);
 #ifdef CONFIG_BLK_DEV_ZONED
kvfree(FDEV(i).blkz_seq);
 #endif
@@ -4198,7 +4198,7 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi)
/* Single zoned block device mount */
FDEV(0).bdev =
blkdev_get_by_dev(sbi->sb->s_bdev->bd_dev, mode,
- sbi->sb->s_type, NULL);
+ sbi->sb, NULL);
} else {
/* Multi-device mount */
memcpy(FDEV(i).path, RDEV(i).path, MAX_PATH_LEN);
@@ -4217,8 +4217,7 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi)
sbi->log_blocks_per_seg) - 1;
}
FDEV(i).bdev = blkdev_get_by_path(FDEV(i).path, mode,
- sbi->sb->s_type,
- NULL);
+ sbi->sb, NULL);
}
if (IS_ERR(FDEV(i).bdev))
return PTR_ERR(FDEV(i).bdev);
diff --git a/fs/super.c b/fs/super.c
index 6aaa275fa8630d..09b65ee1a8b737 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -1249,7 +1249,7 @@ int setup_bdev_super(struct super_block *sb, int sb_flags,
blk_mode_t mode = sb_open_mode(sb_flags);
struct block_device *bdev;
 
-   bdev = blkdev_get_by_dev(sb->s_dev, mode, sb->s_type, &fs_holder_ops);
+   bdev = blkdev_get_by_dev(sb->s_dev, mode, sb, &fs_holder_ops);
if (IS_ERR(bdev)) {
if (fc)
errorf(fc, "%s: Can't open blockdev", fc->source);
@@ -1262,7 +1262,7 @@ int setup_bdev_super(struct super_block *sb, int sb_flags,
 * writable from userspace even for a read-only block device.
 */
if ((mode & BLK_OPEN_WRITE) && bdev_read_only(bdev)) {
-   blkdev_put(bdev, sb->s_type);
+   blkdev_put(bdev, sb);
return -EACCES;
}
 
@@ -1278,7 +1278,7 @@ int setup_bdev_super(struct super_block *sb, int sb_flags,
mutex_unlock(&bdev->bd_fsfreeze_mutex);
if (fc)
warnf(fc, "%pg: Can't mount, blockdev is frozen", bdev);
-   blkdev_put(bdev, sb->s_type);
+   blkdev_put(bdev, sb);
return -EBUSY;
}
spin_lock(&sb_lock);
@@ -1418,7 +1418,7 @@ v

[f2fs-dev] [PATCH 02/12] nilfs2: use setup_bdev_super to de-duplicate the mount code

2023-08-02 Thread Christoph Hellwig
Use the generic setup_bdev_super helper to open the main block device
and do various bits of superblock setup instead of duplicating the
logic.  This includes moving to the new scheme implemented in common
code that only opens the block device after the superblock has allocated.

It does not yet convert nilfs2 to the new mount API, but doing so will
become a bit simpler after this first step.

Signed-off-by: Christoph Hellwig 
---
 fs/nilfs2/super.c | 81 ++-
 1 file changed, 30 insertions(+), 51 deletions(-)

diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
index 0ef8c71bde8e5f..a5d1fa4e7552f6 100644
--- a/fs/nilfs2/super.c
+++ b/fs/nilfs2/super.c
@@ -35,6 +35,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "nilfs.h"
 #include "export.h"
 #include "mdt.h"
@@ -1216,7 +1217,6 @@ static int nilfs_remount(struct super_block *sb, int 
*flags, char *data)
 }
 
 struct nilfs_super_data {
-   struct block_device *bdev;
__u64 cno;
int flags;
 };
@@ -1283,64 +1283,49 @@ static int nilfs_identify(char *data, struct 
nilfs_super_data *sd)
 
 static int nilfs_set_bdev_super(struct super_block *s, void *data)
 {
-   s->s_bdev = data;
-   s->s_dev = s->s_bdev->bd_dev;
+   s->s_dev = *(dev_t *)data;
return 0;
 }
 
 static int nilfs_test_bdev_super(struct super_block *s, void *data)
 {
-   return (void *)s->s_bdev == data;
+   return !(s->s_iflags & SB_I_RETIRED) && s->s_dev == *(dev_t *)data;
 }
 
 static struct dentry *
 nilfs_mount(struct file_system_type *fs_type, int flags,
 const char *dev_name, void *data)
 {
-   struct nilfs_super_data sd;
+   struct nilfs_super_data sd = { .flags = flags };
struct super_block *s;
-   struct dentry *root_dentry;
-   int err, s_new = false;
+   dev_t dev;
+   int err;
 
-   sd.bdev = blkdev_get_by_path(dev_name, sb_open_mode(flags), fs_type,
-NULL);
-   if (IS_ERR(sd.bdev))
-   return ERR_CAST(sd.bdev);
+   if (nilfs_identify(data, &sd))
+   return ERR_PTR(-EINVAL);
 
-   sd.cno = 0;
-   sd.flags = flags;
-   if (nilfs_identify((char *)data, &sd)) {
-   err = -EINVAL;
-   goto failed;
-   }
+   err = lookup_bdev(dev_name, &dev);
+   if (err)
+   return ERR_PTR(err);
 
-   /*
-* once the super is inserted into the list by sget, s_umount
-* will protect the lockfs code from trying to start a snapshot
-* while we are mounting
-*/
-   mutex_lock(&sd.bdev->bd_fsfreeze_mutex);
-   if (sd.bdev->bd_fsfreeze_count > 0) {
-   mutex_unlock(&sd.bdev->bd_fsfreeze_mutex);
-   err = -EBUSY;
-   goto failed;
-   }
s = sget(fs_type, nilfs_test_bdev_super, nilfs_set_bdev_super, flags,
-sd.bdev);
-   mutex_unlock(&sd.bdev->bd_fsfreeze_mutex);
-   if (IS_ERR(s)) {
-   err = PTR_ERR(s);
-   goto failed;
-   }
+&dev);
+   if (IS_ERR(s))
+   return ERR_CAST(s);
 
if (!s->s_root) {
-   s_new = true;
-
-   /* New superblock instance created */
-   snprintf(s->s_id, sizeof(s->s_id), "%pg", sd.bdev);
-   sb_set_blocksize(s, block_size(sd.bdev));
-
-   err = nilfs_fill_super(s, data, flags & SB_SILENT ? 1 : 0);
+   /*
+* We drop s_umount here because we need to open the bdev and
+* bdev->open_mutex ranks above s_umount (blkdev_put() ->
+* __invalidate_device()). It is safe because we have active sb
+* reference and SB_BORN is not set yet.
+*/
+   up_write(&s->s_umount);
+   err = setup_bdev_super(s, flags, NULL);
+   down_write(&s->s_umount);
+   if (!err)
+   err = nilfs_fill_super(s, data,
+  flags & SB_SILENT ? 1 : 0);
if (err)
goto failed_super;
 
@@ -1366,24 +1351,18 @@ nilfs_mount(struct file_system_type *fs_type, int flags,
}
 
if (sd.cno) {
+   struct dentry *root_dentry;
+
err = nilfs_attach_snapshot(s, sd.cno, &root_dentry);
if (err)
goto failed_super;
-   } else {
-   root_dentry = dget(s->s_root);
+   return root_dentry;
}
 
-   if (!s_new)
-   blkdev_put(sd.bdev, fs_type);
-
-   return root_dentry;
+   return dget(s->s_root);
 
  failed_super:
deactivate_locked_super(s);
-
- failed:
-   if (!s_new)
-   blkdev

[f2fs-dev] [PATCH 03/12] btrfs: always open the device read-only in btrfs_scan_one_device

2023-08-02 Thread Christoph Hellwig
btrfs_scan_one_device opens the block device only to read the super
block.  Instead of passing a blk_mode_t argument to sometimes open
it for writing, just hard code BLK_OPEN_READ as it will never write
to the device or hand the block_device out to someone else.

Signed-off-by: Christoph Hellwig 
---
 fs/btrfs/super.c   | 15 +++
 fs/btrfs/volumes.c |  4 ++--
 fs/btrfs/volumes.h |  2 +-
 3 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index f1dd172d8d5bd7..b318bddefd5236 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -849,7 +849,7 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char 
*options,
  * All other options will be parsed on much later in the mount process and
  * only when we need to allocate a new super block.
  */
-static int btrfs_parse_device_options(const char *options, blk_mode_t flags)
+static int btrfs_parse_device_options(const char *options)
 {
substring_t args[MAX_OPT_ARGS];
char *device_name, *opts, *orig, *p;
@@ -883,7 +883,7 @@ static int btrfs_parse_device_options(const char *options, 
blk_mode_t flags)
error = -ENOMEM;
goto out;
}
-   device = btrfs_scan_one_device(device_name, flags);
+   device = btrfs_scan_one_device(device_name);
kfree(device_name);
if (IS_ERR(device)) {
error = PTR_ERR(device);
@@ -1440,7 +1440,6 @@ static struct dentry *btrfs_mount_root(struct 
file_system_type *fs_type,
struct btrfs_fs_devices *fs_devices = NULL;
struct btrfs_fs_info *fs_info = NULL;
void *new_sec_opts = NULL;
-   blk_mode_t mode = sb_open_mode(flags);
int error = 0;
 
if (data) {
@@ -1472,13 +1471,13 @@ static struct dentry *btrfs_mount_root(struct 
file_system_type *fs_type,
}
 
mutex_lock(&uuid_mutex);
-   error = btrfs_parse_device_options(data, mode);
+   error = btrfs_parse_device_options(data);
if (error) {
mutex_unlock(&uuid_mutex);
goto error_fs_info;
}
 
-   device = btrfs_scan_one_device(device_name, mode);
+   device = btrfs_scan_one_device(device_name);
if (IS_ERR(device)) {
mutex_unlock(&uuid_mutex);
error = PTR_ERR(device);
@@ -1488,7 +1487,7 @@ static struct dentry *btrfs_mount_root(struct 
file_system_type *fs_type,
fs_devices = device->fs_devices;
fs_info->fs_devices = fs_devices;
 
-   error = btrfs_open_devices(fs_devices, mode, fs_type);
+   error = btrfs_open_devices(fs_devices, sb_open_mode(flags), fs_type);
mutex_unlock(&uuid_mutex);
if (error)
goto error_fs_info;
@@ -2190,7 +2189,7 @@ static long btrfs_control_ioctl(struct file *file, 
unsigned int cmd,
switch (cmd) {
case BTRFS_IOC_SCAN_DEV:
mutex_lock(&uuid_mutex);
-   device = btrfs_scan_one_device(vol->name, BLK_OPEN_READ);
+   device = btrfs_scan_one_device(vol->name);
ret = PTR_ERR_OR_ZERO(device);
mutex_unlock(&uuid_mutex);
break;
@@ -2204,7 +2203,7 @@ static long btrfs_control_ioctl(struct file *file, 
unsigned int cmd,
break;
case BTRFS_IOC_DEVICES_READY:
mutex_lock(&uuid_mutex);
-   device = btrfs_scan_one_device(vol->name, BLK_OPEN_READ);
+   device = btrfs_scan_one_device(vol->name);
if (IS_ERR(device)) {
mutex_unlock(&uuid_mutex);
ret = PTR_ERR(device);
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 73f9ea7672dbda..8246578c70f55b 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1356,7 +1356,7 @@ int btrfs_forget_devices(dev_t devt)
  * and we are not allowed to call set_blocksize during the scan. The superblock
  * is read via pagecache
  */
-struct btrfs_device *btrfs_scan_one_device(const char *path, blk_mode_t flags)
+struct btrfs_device *btrfs_scan_one_device(const char *path)
 {
struct btrfs_super_block *disk_super;
bool new_device_added = false;
@@ -1384,7 +1384,7 @@ struct btrfs_device *btrfs_scan_one_device(const char 
*path, blk_mode_t flags)
 * values temporarily, as the device paths of the fsid are the only
 * required information for assembling the volume.
 */
-   bdev = blkdev_get_by_path(path, flags, NULL, NULL);
+   bdev = blkdev_get_by_path(path, BLK_OPEN_READ, NULL, NULL);
if (IS_ERR(bdev))
return ERR_CAST(bdev);
 
diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
index b8c51f16ba867f..824161c6dd063e 100644
--- a/fs/btrfs/volumes.h
+++ b/fs/btrfs/volumes.h
@@ -611,7 +611,7 @@ struct btrfs_block_gr

[f2fs-dev] [PATCH 05/12] ext4: make the IS_EXT2_SB/IS_EXT3_SB checks more robust

2023-08-02 Thread Christoph Hellwig
Check for sb->s_type which is the right place to look at the file system
type, not the holder, which is just an implementation detail in the VFS
helpers.

Signed-off-by: Christoph Hellwig 
---
 fs/ext4/super.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index c94ebf704616e5..193d665813b611 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -140,7 +140,7 @@ static struct file_system_type ext2_fs_type = {
 };
 MODULE_ALIAS_FS("ext2");
 MODULE_ALIAS("ext2");
-#define IS_EXT2_SB(sb) ((sb)->s_bdev->bd_holder == &ext2_fs_type)
+#define IS_EXT2_SB(sb) ((sb)->s_type == &ext2_fs_type)
 #else
 #define IS_EXT2_SB(sb) (0)
 #endif
@@ -156,7 +156,7 @@ static struct file_system_type ext3_fs_type = {
 };
 MODULE_ALIAS_FS("ext3");
 MODULE_ALIAS("ext3");
-#define IS_EXT3_SB(sb) ((sb)->s_bdev->bd_holder == &ext3_fs_type)
+#define IS_EXT3_SB(sb) ((sb)->s_type == &ext3_fs_type)
 
 
 static inline void __ext4_read_bh(struct buffer_head *bh, blk_opf_t op_flags,
-- 
2.39.2



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH 01/32] block: Provide blkdev_get_handle_* functions

2023-07-31 Thread Christoph Hellwig
On Mon, Jul 31, 2023 at 12:50:34PM +0200, Jan Kara wrote:
> 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.

Agreed.


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH 16/17] block: use iomap for writes to block devices

2023-07-20 Thread Christoph Hellwig
On Wed, May 24, 2023 at 02:33:13PM +0100, Matthew Wilcox wrote:
> As you can see, do_page_cache_ra() does limit readahead to i_size.
> Is ractl->mapping->host the correct way to find the inode?  I always
> get confused.

As far as I can tell it is the right inode, the indirection through
file->f_mapping ensures it actually points to the backing inode.


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH 16/17] block: use iomap for writes to block devices

2023-07-20 Thread Christoph Hellwig
On Fri, May 19, 2023 at 04:22:01PM +0200, Hannes Reinecke wrote:
> I'm hitting this during booting:
> [5.016324]  
> [5.030256]  iomap_iter+0x11a/0x350
> [5.030264]  iomap_readahead+0x1eb/0x2c0
> [5.030272]  read_pages+0x5d/0x220
> [5.030279]  page_cache_ra_unbounded+0x131/0x180
> [5.030284]  filemap_get_pages+0xff/0x5a0
> [5.030292]  filemap_read+0xca/0x320
> [5.030296]  ? aa_file_perm+0x126/0x500
> [5.040216]  ? touch_atime+0xc8/0x150
> [5.040224]  blkdev_read_iter+0xb0/0x150
> [5.040228]  vfs_read+0x226/0x2d0
> [5.040234]  ksys_read+0xa5/0xe0
> [5.040238]  do_syscall_64+0x5b/0x80
>
> Maybe we should consider this patch:

As willy said this should be taken care of by the i_size check.
Did you run with just this patch set or some of the large block
size experiments on top which might change the variables?

I'll repost the series today without any chances in the area, and
if you can reproduce it with just that series we need to root
cause it, so please send your kernel and VM config along for the
next report.


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [bug report] f2fs mount failure on zoned block devices

2023-07-13 Thread Christoph Hellwig
Take a look at the "f2fs: don't reopen the main block device in
f2fs_scan_devices" thread on the block list.  The first version of patch
still had issues, but there is an updated on deeper in the thread.



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH] f2fs: don't reopen the main block device in f2fs_scan_devices

2023-07-10 Thread Christoph Hellwig
On Tue, Jul 11, 2023 at 08:19:50AM +0200, Hannes Reinecke wrote:
>>  for (i = 0; i < sbi->s_ndevs; i++) {
>> -blkdev_put(FDEV(i).bdev, sbi->sb->s_type);
>> +if (i > 0)
>> +blkdev_put(FDEV(i).bdev, sbi->sb->s_type);
> You could have started the loop at '1', and avoid the curious 'if' clause 

That's what the previous version did, which caused a NULL pointer
dereference discussed in this thread, as well as a compile error for
non-zoned builds..



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH] f2fs: don't reopen the main block device in f2fs_scan_devices

2023-07-10 Thread Christoph Hellwig
I think that's because it doesn't look at sbi->s_ndevs in
destroy_device_list.  Let's try the variant below, which also fixes
the buildbot warning for non-zoned configfs:

---
>From 645d8dceaa97b6ee73be067495b111b15b187498 Mon Sep 17 00:00:00 2001
From: Christoph Hellwig 
Date: Fri, 7 Jul 2023 10:31:49 +0200
Subject: f2fs: don't reopen the main block device in f2fs_scan_devices

f2fs_scan_devices reopens the main device since the very beginning, which
has always been useless, and also means that we don't pass the right
holder for the reopen, which now leads to a warning as the core super.c
holder ops aren't passed in for the reopen.

Fixes: 3c62be17d4f5 ("f2fs: support multiple devices")
Fixes: 0718afd47f70 ("block: introduce holder ops")
Signed-off-by: Christoph Hellwig 
---
 block/blk-flush.c |  2 +-
 fs/f2fs/super.c   | 20 
 2 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index ca31163da00a55..30883beb750a59 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -1561,7 +1561,8 @@ static void destroy_device_list(struct f2fs_sb_info *sbi)
int i;
 
for (i = 0; i < sbi->s_ndevs; i++) {
-   blkdev_put(FDEV(i).bdev, sbi->sb->s_type);
+   if (i > 0)
+   blkdev_put(FDEV(i).bdev, sbi->sb->s_type);
 #ifdef CONFIG_BLK_DEV_ZONED
kvfree(FDEV(i).blkz_seq);
 #endif
@@ -4190,16 +4191,12 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi)
sbi->aligned_blksize = true;
 
for (i = 0; i < max_devices; i++) {
-
-   if (i > 0 && !RDEV(i).path[0])
+   if (i == 0)
+   FDEV(0).bdev = sbi->sb->s_bdev;
+   else if (!RDEV(i).path[0])
break;
 
-   if (max_devices == 1) {
-   /* Single zoned block device mount */
-   FDEV(0).bdev =
-   blkdev_get_by_dev(sbi->sb->s_bdev->bd_dev, mode,
- sbi->sb->s_type, NULL);
-   } else {
+   if (max_devices > 1) {
/* Multi-device mount */
memcpy(FDEV(i).path, RDEV(i).path, MAX_PATH_LEN);
FDEV(i).total_segments =
@@ -4215,10 +4212,9 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi)
FDEV(i).end_blk = FDEV(i).start_blk +
(FDEV(i).total_segments <<
sbi->log_blocks_per_seg) - 1;
+   FDEV(i).bdev = blkdev_get_by_path(FDEV(i).path,
+   mode, sbi->sb->s_type, NULL);
}
-   FDEV(i).bdev = blkdev_get_by_path(FDEV(i).path, mode,
- sbi->sb->s_type,
- NULL);
}
if (IS_ERR(FDEV(i).bdev))
return PTR_ERR(FDEV(i).bdev);
-- 
2.39.2



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH 01/32] block: Provide blkdev_get_handle_* functions

2023-07-07 Thread Christoph Hellwig
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.


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH] f2fs: don't reopen the main block device in f2fs_scan_devices

2023-07-07 Thread Christoph Hellwig
f2fs_scan_devices reopens the main device since the very beginning, which
has always been useless, and also means that we don't pass the right
holder for the reopen, which now leads to a warning as the core super.c
holder ops aren't passed in for the reopen.

Fixes: 3c62be17d4f5 ("f2fs: support multiple devices")
Fixes: 0718afd47f70 ("block: introduce holder ops")
Signed-off-by: Christoph Hellwig 
---
 fs/f2fs/super.c | 20 
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index ca31163da00a55..8d11d4a5ec331d 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -1560,7 +1560,8 @@ static void destroy_device_list(struct f2fs_sb_info *sbi)
 {
int i;
 
-   for (i = 0; i < sbi->s_ndevs; i++) {
+   kvfree(FDEV(0).blkz_seq);
+   for (i = 1; i < sbi->s_ndevs; i++) {
blkdev_put(FDEV(i).bdev, sbi->sb->s_type);
 #ifdef CONFIG_BLK_DEV_ZONED
kvfree(FDEV(i).blkz_seq);
@@ -4190,16 +4191,12 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi)
sbi->aligned_blksize = true;
 
for (i = 0; i < max_devices; i++) {
-
-   if (i > 0 && !RDEV(i).path[0])
+   if (i == 0)
+   FDEV(0).bdev = sbi->sb->s_bdev;
+   else if (!RDEV(i).path[0])
break;
 
-   if (max_devices == 1) {
-   /* Single zoned block device mount */
-   FDEV(0).bdev =
-   blkdev_get_by_dev(sbi->sb->s_bdev->bd_dev, mode,
- sbi->sb->s_type, NULL);
-   } else {
+   if (max_devices > 1) {
/* Multi-device mount */
memcpy(FDEV(i).path, RDEV(i).path, MAX_PATH_LEN);
FDEV(i).total_segments =
@@ -4215,10 +4212,9 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi)
FDEV(i).end_blk = FDEV(i).start_blk +
(FDEV(i).total_segments <<
sbi->log_blocks_per_seg) - 1;
+   FDEV(i).bdev = blkdev_get_by_path(FDEV(i).path,
+   mode, sbi->sb->s_type, NULL);
}
-   FDEV(i).bdev = blkdev_get_by_path(FDEV(i).path, mode,
- sbi->sb->s_type,
- NULL);
}
if (IS_ERR(FDEV(i).bdev))
return PTR_ERR(FDEV(i).bdev);
-- 
2.39.2



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH 01/32] block: Provide blkdev_get_handle_* functions

2023-07-06 Thread Christoph Hellwig
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);

?


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH RFC 0/32] block: Make blkdev_get_by_*() return handle

2023-07-06 Thread Christoph Hellwig
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.


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH] f2fs: set FMODE_CAN_ODIRECT instead of a dummy direct_IO method

2023-06-11 Thread Christoph Hellwig
Since commit a2ad63daa88b ("VFS: add FMODE_CAN_ODIRECT file flag") file
systems can just set the FMODE_CAN_ODIRECT flag at open time instead of
wiring up a dummy direct_IO method to indicate support for direct I/O.

Do that for f2fs so that noop_direct_IO can eventually be removed.

Signed-off-by: Christoph Hellwig 
---
 fs/f2fs/data.c | 1 -
 fs/f2fs/file.c | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 7165b1202f539c..5e90416f64daa1 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -4067,7 +4067,6 @@ const struct address_space_operations f2fs_dblock_aops = {
.migrate_folio  = filemap_migrate_folio,
.invalidate_folio = f2fs_invalidate_folio,
.release_folio  = f2fs_release_folio,
-   .direct_IO  = noop_direct_IO,
.bmap   = f2fs_bmap,
.swap_activate  = f2fs_swap_activate,
.swap_deactivate = f2fs_swap_deactivate,
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 5ac53d2627d20d..ca809e366cb79f 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -547,6 +547,7 @@ static int f2fs_file_open(struct inode *inode, struct file 
*filp)
return err;
 
filp->f_mode |= FMODE_NOWAIT;
+   filp->f_mode |= FMODE_CAN_ODIRECT;
 
return dquot_file_open(inode, filp);
 }
-- 
2.39.2



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 22/30] mtd: block: use a simple bool to track open for write

2023-06-08 Thread Christoph Hellwig
Instead of propagating the fmode_t, just use a bool to track if a mtd
block device was opened for writing.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Hannes Reinecke 
Acked-by: Christian Brauner 
Acked-by: Richard Weinberger 
---
 drivers/mtd/mtd_blkdevs.c| 2 +-
 drivers/mtd/mtdblock.c   | 2 +-
 include/linux/mtd/blktrans.h | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
index f0bb09fde95e3a..bd0b7545364349 100644
--- a/drivers/mtd/mtd_blkdevs.c
+++ b/drivers/mtd/mtd_blkdevs.c
@@ -208,7 +208,7 @@ static int blktrans_open(struct gendisk *disk, fmode_t mode)
ret = __get_mtd_device(dev->mtd);
if (ret)
goto error_release;
-   dev->file_mode = mode;
+   dev->writable = mode & FMODE_WRITE;
 
 unlock:
dev->open++;
diff --git a/drivers/mtd/mtdblock.c b/drivers/mtd/mtdblock.c
index a0a1194dc1d902..fa476fb4dffb6c 100644
--- a/drivers/mtd/mtdblock.c
+++ b/drivers/mtd/mtdblock.c
@@ -294,7 +294,7 @@ static void mtdblock_release(struct mtd_blktrans_dev *mbd)
 * It was the last usage. Free the cache, but only sync if
 * opened for writing.
 */
-   if (mbd->file_mode & FMODE_WRITE)
+   if (mbd->writable)
mtd_sync(mbd->mtd);
vfree(mtdblk->cache_data);
}
diff --git a/include/linux/mtd/blktrans.h b/include/linux/mtd/blktrans.h
index 15cc9b95e32b52..6e471436bba556 100644
--- a/include/linux/mtd/blktrans.h
+++ b/include/linux/mtd/blktrans.h
@@ -34,7 +34,7 @@ struct mtd_blktrans_dev {
struct blk_mq_tag_set *tag_set;
spinlock_t queue_lock;
void *priv;
-   fmode_t file_mode;
+   bool writable;
 };
 
 struct mtd_blktrans_ops {
-- 
2.39.2



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 27/30] block: replace fmode_t with a block-specific type for block open flags

2023-06-08 Thread Christoph Hellwig
The only overlap between the block open flags mapped into the fmode_t and
other uses of fmode_t are FMODE_READ and FMODE_WRITE.  Define a new
blk_mode_t instead for use in blkdev_get_by_{dev,path}, ->open and
->ioctl and stop abusing fmode_t.

Signed-off-by: Christoph Hellwig 
Acked-by: Jack Wang   [rnbd]
---
 arch/um/drivers/ubd_kern.c  |  8 +++---
 arch/xtensa/platforms/iss/simdisk.c |  2 +-
 block/bdev.c| 32 +++---
 block/blk-zoned.c   |  8 +++---
 block/blk.h | 11 
 block/fops.c| 32 +-
 block/genhd.c   |  8 +++---
 block/ioctl.c   | 42 +
 drivers/block/amiflop.c | 12 -
 drivers/block/aoe/aoeblk.c  |  4 +--
 drivers/block/ataflop.c | 25 +
 drivers/block/drbd/drbd_main.c  |  7 ++---
 drivers/block/drbd/drbd_nl.c|  2 +-
 drivers/block/floppy.c  | 28 +--
 drivers/block/loop.c| 22 +++
 drivers/block/mtip32xx/mtip32xx.c   |  4 +--
 drivers/block/nbd.c |  4 +--
 drivers/block/pktcdvd.c | 17 ++--
 drivers/block/rbd.c |  2 +-
 drivers/block/rnbd/rnbd-clt.c   |  4 +--
 drivers/block/rnbd/rnbd-srv.c   |  4 +--
 drivers/block/sunvdc.c  |  2 +-
 drivers/block/swim.c| 16 +--
 drivers/block/swim3.c   | 24 -
 drivers/block/ublk_drv.c|  2 +-
 drivers/block/xen-blkback/xenbus.c  |  2 +-
 drivers/block/xen-blkfront.c|  2 +-
 drivers/block/z2ram.c   |  2 +-
 drivers/block/zram/zram_drv.c   |  6 ++---
 drivers/cdrom/cdrom.c   |  6 ++---
 drivers/cdrom/gdrom.c   |  4 +--
 drivers/md/bcache/bcache.h  |  2 +-
 drivers/md/bcache/request.c |  4 +--
 drivers/md/bcache/super.c   |  6 ++---
 drivers/md/dm-cache-target.c| 12 -
 drivers/md/dm-clone-target.c| 10 +++
 drivers/md/dm-core.h|  7 +++--
 drivers/md/dm-era-target.c  |  6 +++--
 drivers/md/dm-ioctl.c   | 10 +++
 drivers/md/dm-snap.c|  4 +--
 drivers/md/dm-table.c   | 11 
 drivers/md/dm-thin.c|  9 ---
 drivers/md/dm-verity-fec.c  |  2 +-
 drivers/md/dm-verity-target.c   |  6 ++---
 drivers/md/dm.c | 10 +++
 drivers/md/dm.h |  2 +-
 drivers/md/md.c |  8 +++---
 drivers/mmc/core/block.c|  8 +++---
 drivers/mtd/devices/block2mtd.c |  4 +--
 drivers/mtd/mtd_blkdevs.c   |  4 +--
 drivers/mtd/ubi/block.c |  5 ++--
 drivers/nvme/host/core.c|  2 +-
 drivers/nvme/host/ioctl.c   |  8 +++---
 drivers/nvme/host/multipath.c   |  2 +-
 drivers/nvme/host/nvme.h|  4 +--
 drivers/nvme/target/io-cmd-bdev.c   |  2 +-
 drivers/s390/block/dasd.c   |  6 ++---
 drivers/s390/block/dasd_genhd.c |  3 ++-
 drivers/s390/block/dasd_int.h   |  3 ++-
 drivers/s390/block/dasd_ioctl.c |  2 +-
 drivers/s390/block/dcssblk.c|  4 +--
 drivers/scsi/sd.c   | 19 ++---
 drivers/scsi/sr.c   | 10 +++
 drivers/target/target_core_iblock.c |  5 ++--
 drivers/target/target_core_pscsi.c  |  4 +--
 fs/btrfs/dev-replace.c  |  2 +-
 fs/btrfs/super.c|  8 +++---
 fs/btrfs/volumes.c  | 16 +--
 fs/btrfs/volumes.h  |  4 +--
 fs/erofs/super.c|  2 +-
 fs/ext4/super.c |  2 +-
 fs/f2fs/super.c |  2 +-
 fs/jfs/jfs_logmgr.c |  2 +-
 fs/nfs/blocklayout/dev.c|  5 ++--
 fs/ocfs2/cluster/heartbeat.c|  3 ++-
 fs/reiserfs/journal.c   |  4 +--
 fs/xfs/xfs_super.c  |  2 +-
 include/linux/blkdev.h  | 30 -
 include/linux/cdrom.h   |  3 ++-
 include/linux/device-mapper.h   |  8 +++---
 kernel/power/swap.c |  6 ++---
 mm/swapfile.c   |  2 +-
 82 files changed, 334 insertions(+), 315 deletions(-)

diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index 20c1a16199c503..50206feac577d5 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -108,9 +108,9 @@ static inline void ubd_set_bit(__u64 bit, unsigned char 
*data)
 static DEFINE_MUTEX(ubd_lock);
 static DEFINE_MUTEX(ubd_mutex); /* replaces BKL, might not be needed */
 
-static int ubd_open(struct gendisk *disk, fmode_t mode);
+static int ubd_open(struct gendisk *disk, blk_mode_t mode);
 static void ubd_release(struct gendisk *disk);
-static int ubd_ioctl(struct block_device *bdev, fmode_t mode,
+

[f2fs-dev] [PATCH 30/30] fs: remove the now unused FMODE_* flags

2023-06-08 Thread Christoph Hellwig
FMODE_NDELAY, FMODE_EXCL and FMODE_WRITE_IOCTL were only used for
block internal purposed and are now entirely unused, so remove them.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Hannes Reinecke 
Reviewed-by: Christian Brauner 
---
 include/linux/fs.h | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index ad1d2c9afb3fa4..8045c7ef4000c2 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -119,13 +119,6 @@ typedef int (dio_iodone_t)(struct kiocb *iocb, loff_t 
offset,
 #define FMODE_PWRITE   ((__force fmode_t)0x10)
 /* File is opened for execution with sys_execve / sys_uselib */
 #define FMODE_EXEC ((__force fmode_t)0x20)
-/* File is opened with O_NDELAY (only set for block devices) */
-#define FMODE_NDELAY   ((__force fmode_t)0x40)
-/* File is opened with O_EXCL (only set for block devices) */
-#define FMODE_EXCL ((__force fmode_t)0x80)
-/* File is opened using open(.., 3, ..) and is writeable only for ioctls
-   (specialy hack for floppy.c) */
-#define FMODE_WRITE_IOCTL  ((__force fmode_t)0x100)
 /* 32bit hashes as llseek() offset (for directories) */
 #define FMODE_32BITHASH ((__force fmode_t)0x200)
 /* 64bit hashes as llseek() offset (for directories) */
-- 
2.39.2



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 29/30] block: store the holder in file->private_data

2023-06-08 Thread Christoph Hellwig
Store the file struct used as the holder in file->private_data as an
indicator that this file descriptor was opened exclusively to  remove
the last use of FMODE_EXCL.

Signed-off-by: Christoph Hellwig 
---
 block/fops.c | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/block/fops.c b/block/fops.c
index 0d714d050a462c..9871bd6052b416 100644
--- a/block/fops.c
+++ b/block/fops.c
@@ -478,7 +478,7 @@ blk_mode_t file_to_blk_mode(struct file *file)
mode |= BLK_OPEN_READ;
if (file->f_mode & FMODE_WRITE)
mode |= BLK_OPEN_WRITE;
-   if (file->f_mode & FMODE_EXCL)
+   if (file->private_data)
mode |= BLK_OPEN_EXCL;
if (file->f_flags & O_NDELAY)
mode |= BLK_OPEN_NDELAY;
@@ -507,12 +507,15 @@ static int blkdev_open(struct inode *inode, struct file 
*filp)
filp->f_flags |= O_LARGEFILE;
filp->f_mode |= FMODE_NOWAIT | FMODE_BUF_RASYNC;
 
+   /*
+* Use the file private data to store the holder for exclusive openes.
+* file_to_blk_mode relies on it being present to set BLK_OPEN_EXCL.
+*/
if (filp->f_flags & O_EXCL)
-   filp->f_mode |= FMODE_EXCL;
+   filp->private_data = filp;
 
bdev = blkdev_get_by_dev(inode->i_rdev, file_to_blk_mode(filp),
-(filp->f_mode & FMODE_EXCL) ? filp : NULL,
-NULL);
+filp->private_data, NULL);
if (IS_ERR(bdev))
return PTR_ERR(bdev);
 
@@ -523,8 +526,7 @@ static int blkdev_open(struct inode *inode, struct file 
*filp)
 
 static int blkdev_release(struct inode *inode, struct file *filp)
 {
-   blkdev_put(I_BDEV(filp->f_mapping->host),
-  (filp->f_mode & FMODE_EXCL) ? filp : NULL);
+   blkdev_put(I_BDEV(filp->f_mapping->host), filp->private_data);
return 0;
 }
 
-- 
2.39.2



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 28/30] block: always use I_BDEV on file->f_mapping->host to find the bdev

2023-06-08 Thread Christoph Hellwig
Always use I_BDEV(file->f_mapping->host) to find the bdev for a file to
free up file->private_data for other uses.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Hannes Reinecke 
Acked-by: Christian Brauner 
---
 block/fops.c | 18 --
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/block/fops.c b/block/fops.c
index 086612103b9dd9..0d714d050a462c 100644
--- a/block/fops.c
+++ b/block/fops.c
@@ -54,7 +54,7 @@ static bool blkdev_dio_unaligned(struct block_device *bdev, 
loff_t pos,
 static ssize_t __blkdev_direct_IO_simple(struct kiocb *iocb,
struct iov_iter *iter, unsigned int nr_pages)
 {
-   struct block_device *bdev = iocb->ki_filp->private_data;
+   struct block_device *bdev = I_BDEV(iocb->ki_filp->f_mapping->host);
struct bio_vec inline_vecs[DIO_INLINE_BIO_VECS], *vecs;
loff_t pos = iocb->ki_pos;
bool should_dirty = false;
@@ -170,7 +170,7 @@ static void blkdev_bio_end_io(struct bio *bio)
 static ssize_t __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter,
unsigned int nr_pages)
 {
-   struct block_device *bdev = iocb->ki_filp->private_data;
+   struct block_device *bdev = I_BDEV(iocb->ki_filp->f_mapping->host);
struct blk_plug plug;
struct blkdev_dio *dio;
struct bio *bio;
@@ -310,7 +310,7 @@ static ssize_t __blkdev_direct_IO_async(struct kiocb *iocb,
struct iov_iter *iter,
unsigned int nr_pages)
 {
-   struct block_device *bdev = iocb->ki_filp->private_data;
+   struct block_device *bdev = I_BDEV(iocb->ki_filp->f_mapping->host);
bool is_read = iov_iter_rw(iter) == READ;
blk_opf_t opf = is_read ? REQ_OP_READ : dio_bio_write_op(iocb);
struct blkdev_dio *dio;
@@ -451,7 +451,7 @@ static loff_t blkdev_llseek(struct file *file, loff_t 
offset, int whence)
 static int blkdev_fsync(struct file *filp, loff_t start, loff_t end,
int datasync)
 {
-   struct block_device *bdev = filp->private_data;
+   struct block_device *bdev = I_BDEV(filp->f_mapping->host);
int error;
 
error = file_write_and_wait_range(filp, start, end);
@@ -516,7 +516,6 @@ static int blkdev_open(struct inode *inode, struct file 
*filp)
if (IS_ERR(bdev))
return PTR_ERR(bdev);
 
-   filp->private_data = bdev;
filp->f_mapping = bdev->bd_inode->i_mapping;
filp->f_wb_err = filemap_sample_wb_err(filp->f_mapping);
return 0;
@@ -524,9 +523,8 @@ static int blkdev_open(struct inode *inode, struct file 
*filp)
 
 static int blkdev_release(struct inode *inode, struct file *filp)
 {
-   struct block_device *bdev = filp->private_data;
-
-   blkdev_put(bdev, (filp->f_mode & FMODE_EXCL) ? filp : NULL);
+   blkdev_put(I_BDEV(filp->f_mapping->host),
+  (filp->f_mode & FMODE_EXCL) ? filp : NULL);
return 0;
 }
 
@@ -539,7 +537,7 @@ static int blkdev_release(struct inode *inode, struct file 
*filp)
  */
 static ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from)
 {
-   struct block_device *bdev = iocb->ki_filp->private_data;
+   struct block_device *bdev = I_BDEV(iocb->ki_filp->f_mapping->host);
struct inode *bd_inode = bdev->bd_inode;
loff_t size = bdev_nr_bytes(bdev);
size_t shorted = 0;
@@ -575,7 +573,7 @@ static ssize_t blkdev_write_iter(struct kiocb *iocb, struct 
iov_iter *from)
 
 static ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to)
 {
-   struct block_device *bdev = iocb->ki_filp->private_data;
+   struct block_device *bdev = I_BDEV(iocb->ki_filp->f_mapping->host);
loff_t size = bdev_nr_bytes(bdev);
loff_t pos = iocb->ki_pos;
size_t shorted = 0;
-- 
2.39.2



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 25/30] block: move a few internal definitions out of blkdev.h

2023-06-08 Thread Christoph Hellwig
All these helpers are only used in core block code, so move them out of
the public header.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Hannes Reinecke 
Acked-by: Christian Brauner 
---
 block/blk.h| 23 +--
 include/linux/blkdev.h | 27 ---
 2 files changed, 21 insertions(+), 29 deletions(-)

diff --git a/block/blk.h b/block/blk.h
index 9582fcd0df4123..6910220aa030f1 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -394,10 +394,27 @@ static inline struct bio *blk_queue_bounce(struct bio 
*bio,
 #ifdef CONFIG_BLK_DEV_ZONED
 void disk_free_zone_bitmaps(struct gendisk *disk);
 void disk_clear_zone_settings(struct gendisk *disk);
-#else
+int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode,
+   unsigned int cmd, unsigned long arg);
+int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode,
+   unsigned int cmd, unsigned long arg);
+#else /* CONFIG_BLK_DEV_ZONED */
 static inline void disk_free_zone_bitmaps(struct gendisk *disk) {}
 static inline void disk_clear_zone_settings(struct gendisk *disk) {}
-#endif
+static inline int blkdev_report_zones_ioctl(struct block_device *bdev,
+   fmode_t mode, unsigned int cmd, unsigned long arg)
+{
+   return -ENOTTY;
+}
+static inline int blkdev_zone_mgmt_ioctl(struct block_device *bdev,
+   fmode_t mode, unsigned int cmd, unsigned long arg)
+{
+   return -ENOTTY;
+}
+#endif /* CONFIG_BLK_DEV_ZONED */
+
+struct block_device *bdev_alloc(struct gendisk *disk, u8 partno);
+void bdev_add(struct block_device *bdev, dev_t dev);
 
 int blk_alloc_ext_minor(void);
 void blk_free_ext_minor(unsigned int minor);
@@ -449,6 +466,8 @@ extern struct device_attribute dev_attr_events_poll_msecs;
 
 extern struct attribute_group blk_trace_attr_group;
 
+int truncate_bdev_range(struct block_device *bdev, fmode_t mode, loff_t lstart,
+   loff_t lend);
 long blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg);
 long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg);
 
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 97803603902076..6b65623e447c02 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -318,7 +318,6 @@ typedef int (*report_zones_cb)(struct blk_zone *zone, 
unsigned int idx,
 void disk_set_zoned(struct gendisk *disk, enum blk_zoned_model model);
 
 #ifdef CONFIG_BLK_DEV_ZONED
-
 #define BLK_ALL_ZONES  ((unsigned int)-1)
 int blkdev_report_zones(struct block_device *bdev, sector_t sector,
unsigned int nr_zones, report_zones_cb cb, void *data);
@@ -328,33 +327,11 @@ extern int blkdev_zone_mgmt(struct block_device *bdev, 
enum req_op op,
gfp_t gfp_mask);
 int blk_revalidate_disk_zones(struct gendisk *disk,
  void (*update_driver_data)(struct gendisk *disk));
-
-extern int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode,
-unsigned int cmd, unsigned long arg);
-extern int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode,
- unsigned int cmd, unsigned long arg);
-
 #else /* CONFIG_BLK_DEV_ZONED */
-
 static inline unsigned int bdev_nr_zones(struct block_device *bdev)
 {
return 0;
 }
-
-static inline int blkdev_report_zones_ioctl(struct block_device *bdev,
-   fmode_t mode, unsigned int cmd,
-   unsigned long arg)
-{
-   return -ENOTTY;
-}
-
-static inline int blkdev_zone_mgmt_ioctl(struct block_device *bdev,
-fmode_t mode, unsigned int cmd,
-unsigned long arg)
-{
-   return -ENOTTY;
-}
-
 #endif /* CONFIG_BLK_DEV_ZONED */
 
 /*
@@ -1493,11 +1470,7 @@ void blkdev_put(struct block_device *bdev, void *holder);
 struct block_device *blkdev_get_no_open(dev_t dev);
 void blkdev_put_no_open(struct block_device *bdev);
 
-struct block_device *bdev_alloc(struct gendisk *disk, u8 partno);
-void bdev_add(struct block_device *bdev, dev_t dev);
 struct block_device *I_BDEV(struct inode *inode);
-int truncate_bdev_range(struct block_device *bdev, fmode_t mode, loff_t lstart,
-   loff_t lend);
 
 #ifdef CONFIG_BLOCK
 void invalidate_bdev(struct block_device *bdev);
-- 
2.39.2



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 24/30] ubd: remove commented out code in ubd_open

2023-06-08 Thread Christoph Hellwig
This code has been dead forever, make sure it doesn't show up in code
searches.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Hannes Reinecke 
Acked-by: Christian Brauner 
Acked-by: Richard Weinberger 
---
 arch/um/drivers/ubd_kern.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index 8b79554968addb..20c1a16199c503 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -1170,13 +1170,6 @@ static int ubd_open(struct gendisk *disk, fmode_t mode)
}
ubd_dev->count++;
set_disk_ro(disk, !ubd_dev->openflags.w);
-
-   /* This should no more be needed. And it didn't work anyway to exclude
-* read-write remounting of filesystems.*/
-   /*if((mode & FMODE_WRITE) && !ubd_dev->openflags.w){
-   if(--ubd_dev->count == 0) ubd_close_dev(ubd_dev);
-   err = -EROFS;
-   }*/
 out:
mutex_unlock(&ubd_mutex);
return err;
-- 
2.39.2



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 21/30] nvme: replace the fmode_t argument to the nvme ioctl handlers with a simple bool

2023-06-08 Thread Christoph Hellwig
Instead of passing a fmode_t and only checking it fo0r FMODE_WRITE, pass
a bool open_for_write to prepare for callers that won't have the fmode_t.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Hannes Reinecke 
Acked-by: Christian Brauner 
---
 drivers/nvme/host/ioctl.c | 62 +--
 1 file changed, 34 insertions(+), 28 deletions(-)

diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c
index 81c5c9e3847747..8bf09047348ee9 100644
--- a/drivers/nvme/host/ioctl.c
+++ b/drivers/nvme/host/ioctl.c
@@ -14,7 +14,7 @@ enum {
 };
 
 static bool nvme_cmd_allowed(struct nvme_ns *ns, struct nvme_command *c,
-   unsigned int flags, fmode_t mode)
+   unsigned int flags, bool open_for_write)
 {
u32 effects;
 
@@ -80,7 +80,7 @@ static bool nvme_cmd_allowed(struct nvme_ns *ns, struct 
nvme_command *c,
 * writing.
 */
if (nvme_is_write(c) || (effects & NVME_CMD_EFFECTS_LBCC))
-   return mode & FMODE_WRITE;
+   return open_for_write;
return true;
 }
 
@@ -337,7 +337,7 @@ static bool nvme_validate_passthru_nsid(struct nvme_ctrl 
*ctrl,
 
 static int nvme_user_cmd(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
struct nvme_passthru_cmd __user *ucmd, unsigned int flags,
-   fmode_t mode)
+   bool open_for_write)
 {
struct nvme_passthru_cmd cmd;
struct nvme_command c;
@@ -365,7 +365,7 @@ static int nvme_user_cmd(struct nvme_ctrl *ctrl, struct 
nvme_ns *ns,
c.common.cdw14 = cpu_to_le32(cmd.cdw14);
c.common.cdw15 = cpu_to_le32(cmd.cdw15);
 
-   if (!nvme_cmd_allowed(ns, &c, 0, mode))
+   if (!nvme_cmd_allowed(ns, &c, 0, open_for_write))
return -EACCES;
 
if (cmd.timeout_ms)
@@ -385,7 +385,7 @@ static int nvme_user_cmd(struct nvme_ctrl *ctrl, struct 
nvme_ns *ns,
 
 static int nvme_user_cmd64(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
struct nvme_passthru_cmd64 __user *ucmd, unsigned int flags,
-   fmode_t mode)
+   bool open_for_write)
 {
struct nvme_passthru_cmd64 cmd;
struct nvme_command c;
@@ -412,7 +412,7 @@ static int nvme_user_cmd64(struct nvme_ctrl *ctrl, struct 
nvme_ns *ns,
c.common.cdw14 = cpu_to_le32(cmd.cdw14);
c.common.cdw15 = cpu_to_le32(cmd.cdw15);
 
-   if (!nvme_cmd_allowed(ns, &c, flags, mode))
+   if (!nvme_cmd_allowed(ns, &c, flags, open_for_write))
return -EACCES;
 
if (cmd.timeout_ms)
@@ -583,7 +583,7 @@ static int nvme_uring_cmd_io(struct nvme_ctrl *ctrl, struct 
nvme_ns *ns,
c.common.cdw14 = cpu_to_le32(READ_ONCE(cmd->cdw14));
c.common.cdw15 = cpu_to_le32(READ_ONCE(cmd->cdw15));
 
-   if (!nvme_cmd_allowed(ns, &c, 0, ioucmd->file->f_mode))
+   if (!nvme_cmd_allowed(ns, &c, 0, ioucmd->file->f_mode & FMODE_WRITE))
return -EACCES;
 
d.metadata = READ_ONCE(cmd->metadata);
@@ -649,13 +649,13 @@ static bool is_ctrl_ioctl(unsigned int cmd)
 }
 
 static int nvme_ctrl_ioctl(struct nvme_ctrl *ctrl, unsigned int cmd,
-   void __user *argp, fmode_t mode)
+   void __user *argp, bool open_for_write)
 {
switch (cmd) {
case NVME_IOCTL_ADMIN_CMD:
-   return nvme_user_cmd(ctrl, NULL, argp, 0, mode);
+   return nvme_user_cmd(ctrl, NULL, argp, 0, open_for_write);
case NVME_IOCTL_ADMIN64_CMD:
-   return nvme_user_cmd64(ctrl, NULL, argp, 0, mode);
+   return nvme_user_cmd64(ctrl, NULL, argp, 0, open_for_write);
default:
return sed_ioctl(ctrl->opal_dev, cmd, argp);
}
@@ -680,14 +680,14 @@ struct nvme_user_io32 {
 #endif /* COMPAT_FOR_U64_ALIGNMENT */
 
 static int nvme_ns_ioctl(struct nvme_ns *ns, unsigned int cmd,
-   void __user *argp, unsigned int flags, fmode_t mode)
+   void __user *argp, unsigned int flags, bool open_for_write)
 {
switch (cmd) {
case NVME_IOCTL_ID:
force_successful_syscall_return();
return ns->head->ns_id;
case NVME_IOCTL_IO_CMD:
-   return nvme_user_cmd(ns->ctrl, ns, argp, flags, mode);
+   return nvme_user_cmd(ns->ctrl, ns, argp, flags, open_for_write);
/*
 * struct nvme_user_io can have different padding on some 32-bit ABIs.
 * Just accept the compat version as all fields that are used are the
@@ -702,7 +702,8 @@ static int nvme_ns_ioctl(struct nvme_ns *ns, unsigned int 
cmd,
flags |= NVME_IOCTL_VEC;
fallthrough;
case NVME_IOCTL_IO64_CMD:
-   return nvme_user_cmd64(ns->ctrl, ns, argp, flags, mode);
+   return nvme_user_cmd64(ns->ctrl, ns, argp, flags,
+  open_for_write);
default:

[f2fs-dev] [PATCH 26/30] block: remove unused fmode_t arguments from ioctl handlers

2023-06-08 Thread Christoph Hellwig
A few ioctl handlers have fmode_t arguments that are entirely unused,
remove them.

Signed-off-by: Christoph Hellwig 
Acked-by: Christian Brauner 
Reviewed-by: Hannes Reinecke 
---
 block/blk-zoned.c |  4 ++--
 block/blk.h   |  6 +++---
 block/ioctl.c | 14 +++---
 3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 096b6b47561f83..02cc2c629ac9be 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -323,8 +323,8 @@ static int blkdev_copy_zone_to_user(struct blk_zone *zone, 
unsigned int idx,
  * BLKREPORTZONE ioctl processing.
  * Called from blkdev_ioctl.
  */
-int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode,
- unsigned int cmd, unsigned long arg)
+int blkdev_report_zones_ioctl(struct block_device *bdev, unsigned int cmd,
+   unsigned long arg)
 {
void __user *argp = (void __user *)arg;
struct zone_report_args args;
diff --git a/block/blk.h b/block/blk.h
index 6910220aa030f1..e28d5d67d31a28 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -394,15 +394,15 @@ static inline struct bio *blk_queue_bounce(struct bio 
*bio,
 #ifdef CONFIG_BLK_DEV_ZONED
 void disk_free_zone_bitmaps(struct gendisk *disk);
 void disk_clear_zone_settings(struct gendisk *disk);
-int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode,
-   unsigned int cmd, unsigned long arg);
+int blkdev_report_zones_ioctl(struct block_device *bdev, unsigned int cmd,
+   unsigned long arg);
 int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode,
unsigned int cmd, unsigned long arg);
 #else /* CONFIG_BLK_DEV_ZONED */
 static inline void disk_free_zone_bitmaps(struct gendisk *disk) {}
 static inline void disk_clear_zone_settings(struct gendisk *disk) {}
 static inline int blkdev_report_zones_ioctl(struct block_device *bdev,
-   fmode_t mode, unsigned int cmd, unsigned long arg)
+   unsigned int cmd, unsigned long arg)
 {
return -ENOTTY;
 }
diff --git a/block/ioctl.c b/block/ioctl.c
index b39bd5b41ee492..3a10c34b8ef6d3 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -344,8 +344,8 @@ static int blkdev_pr_clear(struct block_device *bdev,
return ops->pr_clear(bdev, c.key);
 }
 
-static int blkdev_flushbuf(struct block_device *bdev, fmode_t mode,
-   unsigned cmd, unsigned long arg)
+static int blkdev_flushbuf(struct block_device *bdev, unsigned cmd,
+   unsigned long arg)
 {
if (!capable(CAP_SYS_ADMIN))
return -EACCES;
@@ -354,8 +354,8 @@ static int blkdev_flushbuf(struct block_device *bdev, 
fmode_t mode,
return 0;
 }
 
-static int blkdev_roset(struct block_device *bdev, fmode_t mode,
-   unsigned cmd, unsigned long arg)
+static int blkdev_roset(struct block_device *bdev, unsigned cmd,
+   unsigned long arg)
 {
int ret, n;
 
@@ -475,9 +475,9 @@ static int blkdev_common_ioctl(struct block_device *bdev, 
fmode_t mode,
 
switch (cmd) {
case BLKFLSBUF:
-   return blkdev_flushbuf(bdev, mode, cmd, arg);
+   return blkdev_flushbuf(bdev, cmd, arg);
case BLKROSET:
-   return blkdev_roset(bdev, mode, cmd, arg);
+   return blkdev_roset(bdev, cmd, arg);
case BLKDISCARD:
return blk_ioctl_discard(bdev, mode, arg);
case BLKSECDISCARD:
@@ -487,7 +487,7 @@ static int blkdev_common_ioctl(struct block_device *bdev, 
fmode_t mode,
case BLKGETDISKSEQ:
return put_u64(argp, bdev->bd_disk->diskseq);
case BLKREPORTZONE:
-   return blkdev_report_zones_ioctl(bdev, mode, cmd, arg);
+   return blkdev_report_zones_ioctl(bdev, cmd, arg);
case BLKRESETZONE:
case BLKOPENZONE:
case BLKCLOSEZONE:
-- 
2.39.2



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 13/30] rnbd-srv: don't pass a holder for non-exclusive blkdev_get_by_path

2023-06-08 Thread Christoph Hellwig
Passing a holder to blkdev_get_by_path when FMODE_EXCL isn't set doesn't
make sense, so pass NULL instead.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Hannes Reinecke 
Acked-by: Christian Brauner 
Acked-by: Jack Wang 
---
 drivers/block/rnbd/rnbd-srv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/rnbd/rnbd-srv.c b/drivers/block/rnbd/rnbd-srv.c
index cec22bbae2f9a5..ce505e552f4d50 100644
--- a/drivers/block/rnbd/rnbd-srv.c
+++ b/drivers/block/rnbd/rnbd-srv.c
@@ -719,7 +719,7 @@ static int process_msg_open(struct rnbd_srv_session 
*srv_sess,
goto reject;
}
 
-   bdev = blkdev_get_by_path(full_path, open_flags, THIS_MODULE, NULL);
+   bdev = blkdev_get_by_path(full_path, open_flags, NULL, NULL);
if (IS_ERR(bdev)) {
ret = PTR_ERR(bdev);
pr_err("Opening device '%s' on session %s failed, failed to 
open the block device, err: %d\n",
-- 
2.39.2



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 17/30] fs: remove sb->s_mode

2023-06-08 Thread Christoph Hellwig
There is no real need to store the open mode in the super_block now.
It is only used by f2fs, which can easily recalculate it.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Hannes Reinecke 
Acked-by: Christian Brauner 
---
 fs/f2fs/super.c| 10 ++
 fs/nilfs2/super.c  |  1 -
 fs/super.c |  2 --
 include/linux/fs.h |  1 -
 4 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index a5adb1d316e331..5a764fecd1c7ef 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -3993,6 +3993,7 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi)
struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi);
unsigned int max_devices = MAX_DEVICES;
unsigned int logical_blksize;
+   fmode_t mode = sb_open_mode(sbi->sb->s_flags);
int i;
 
/* Initialize single device information */
@@ -4024,8 +4025,8 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi)
if (max_devices == 1) {
/* Single zoned block device mount */
FDEV(0).bdev =
-   blkdev_get_by_dev(sbi->sb->s_bdev->bd_dev,
-   sbi->sb->s_mode, sbi->sb->s_type, NULL);
+   blkdev_get_by_dev(sbi->sb->s_bdev->bd_dev, mode,
+ sbi->sb->s_type, NULL);
} else {
/* Multi-device mount */
memcpy(FDEV(i).path, RDEV(i).path, MAX_PATH_LEN);
@@ -4043,8 +4044,9 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi)
(FDEV(i).total_segments <<
sbi->log_blocks_per_seg) - 1;
}
-   FDEV(i).bdev = blkdev_get_by_path(FDEV(i).path,
-   sbi->sb->s_mode, sbi->sb->s_type, NULL);
+   FDEV(i).bdev = blkdev_get_by_path(FDEV(i).path, mode,
+ sbi->sb->s_type,
+ NULL);
}
if (IS_ERR(FDEV(i).bdev))
return PTR_ERR(FDEV(i).bdev);
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
index a41fd84d4e28ab..15a5a1099427d8 100644
--- a/fs/nilfs2/super.c
+++ b/fs/nilfs2/super.c
@@ -1316,7 +1316,6 @@ nilfs_mount(struct file_system_type *fs_type, int flags,
s_new = true;
 
/* New superblock instance created */
-   s->s_mode = mode;
snprintf(s->s_id, sizeof(s->s_id), "%pg", sd.bdev);
sb_set_blocksize(s, block_size(sd.bdev));
 
diff --git a/fs/super.c b/fs/super.c
index dc7f328398339d..86f40f8981989d 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -1308,7 +1308,6 @@ int get_tree_bdev(struct fs_context *fc,
blkdev_put(bdev, fc->fs_type);
down_write(&s->s_umount);
} else {
-   s->s_mode = mode;
snprintf(s->s_id, sizeof(s->s_id), "%pg", bdev);
shrinker_debugfs_rename(&s->s_shrink, "sb-%s:%s",
fc->fs_type->name, s->s_id);
@@ -1382,7 +1381,6 @@ struct dentry *mount_bdev(struct file_system_type 
*fs_type,
blkdev_put(bdev, fs_type);
down_write(&s->s_umount);
} else {
-   s->s_mode = mode;
snprintf(s->s_id, sizeof(s->s_id), "%pg", bdev);
shrinker_debugfs_rename(&s->s_shrink, "sb-%s:%s",
fs_type->name, s->s_id);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 7b2053649820cc..ad1d2c9afb3fa4 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1215,7 +1215,6 @@ struct super_block {
uuid_t  s_uuid; /* UUID */
 
unsigned ints_max_links;
-   fmode_t s_mode;
 
/*
 * The next field is for VFS *only*. No filesystems have any business
-- 
2.39.2



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 20/30] scsi: replace the fmode_t argument to ->sg_io_fn with a simple bool

2023-06-08 Thread Christoph Hellwig
Instead of passing a fmode_t and only checking it for FMODE_WRITE, pass
a bool open_for_write to prepare for callers that won't have the fmode_t.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Martin K. Petersen 
Reviewed-by: Hannes Reinecke 
Acked-by: Christian Brauner 
---
 block/bsg-lib.c | 2 +-
 block/bsg.c | 8 +---
 drivers/scsi/scsi_bsg.c | 4 ++--
 include/linux/bsg.h | 2 +-
 4 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/block/bsg-lib.c b/block/bsg-lib.c
index 435c32373cd68f..b3acdbdb6e7ea8 100644
--- a/block/bsg-lib.c
+++ b/block/bsg-lib.c
@@ -26,7 +26,7 @@ struct bsg_set {
 };
 
 static int bsg_transport_sg_io_fn(struct request_queue *q, struct sg_io_v4 
*hdr,
-   fmode_t mode, unsigned int timeout)
+   bool open_for_write, unsigned int timeout)
 {
struct bsg_job *job;
struct request *rq;
diff --git a/block/bsg.c b/block/bsg.c
index 7eca43f33d7ff8..bec4027842b31e 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -54,7 +54,8 @@ static unsigned int bsg_timeout(struct bsg_device *bd, struct 
sg_io_v4 *hdr)
return max_t(unsigned int, timeout, BLK_MIN_SG_TIMEOUT);
 }
 
-static int bsg_sg_io(struct bsg_device *bd, fmode_t mode, void __user *uarg)
+static int bsg_sg_io(struct bsg_device *bd, bool open_for_write,
+void __user *uarg)
 {
struct sg_io_v4 hdr;
int ret;
@@ -63,7 +64,8 @@ static int bsg_sg_io(struct bsg_device *bd, fmode_t mode, 
void __user *uarg)
return -EFAULT;
if (hdr.guard != 'Q')
return -EINVAL;
-   ret = bd->sg_io_fn(bd->queue, &hdr, mode, bsg_timeout(bd, &hdr));
+   ret = bd->sg_io_fn(bd->queue, &hdr, open_for_write,
+  bsg_timeout(bd, &hdr));
if (!ret && copy_to_user(uarg, &hdr, sizeof(hdr)))
return -EFAULT;
return ret;
@@ -146,7 +148,7 @@ static long bsg_ioctl(struct file *file, unsigned int cmd, 
unsigned long arg)
case SG_EMULATED_HOST:
return put_user(1, intp);
case SG_IO:
-   return bsg_sg_io(bd, file->f_mode, uarg);
+   return bsg_sg_io(bd, file->f_mode & FMODE_WRITE, uarg);
case SCSI_IOCTL_SEND_COMMAND:
pr_warn_ratelimited("%s: calling unsupported 
SCSI_IOCTL_SEND_COMMAND\n",
current->comm);
diff --git a/drivers/scsi/scsi_bsg.c b/drivers/scsi/scsi_bsg.c
index 12431f35f861e1..a9a9ec086a7e3f 100644
--- a/drivers/scsi/scsi_bsg.c
+++ b/drivers/scsi/scsi_bsg.c
@@ -10,7 +10,7 @@
 #define uptr64(val) ((void __user *)(uintptr_t)(val))
 
 static int scsi_bsg_sg_io_fn(struct request_queue *q, struct sg_io_v4 *hdr,
-   fmode_t mode, unsigned int timeout)
+   bool open_for_write, unsigned int timeout)
 {
struct scsi_cmnd *scmd;
struct request *rq;
@@ -42,7 +42,7 @@ static int scsi_bsg_sg_io_fn(struct request_queue *q, struct 
sg_io_v4 *hdr,
if (copy_from_user(scmd->cmnd, uptr64(hdr->request), scmd->cmd_len))
goto out_put_request;
ret = -EPERM;
-   if (!scsi_cmd_allowed(scmd->cmnd, mode & FMODE_WRITE))
+   if (!scsi_cmd_allowed(scmd->cmnd, open_for_write))
goto out_put_request;
 
ret = 0;
diff --git a/include/linux/bsg.h b/include/linux/bsg.h
index 1ac81c809da9b3..ee2df73edf83f8 100644
--- a/include/linux/bsg.h
+++ b/include/linux/bsg.h
@@ -9,7 +9,7 @@ struct device;
 struct request_queue;
 
 typedef int (bsg_sg_io_fn)(struct request_queue *, struct sg_io_v4 *hdr,
-   fmode_t mode, unsigned int timeout);
+   bool open_for_write, unsigned int timeout);
 
 struct bsg_device *bsg_register_queue(struct request_queue *q,
struct device *parent, const char *name,
-- 
2.39.2



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 23/30] rnbd-srv: replace sess->open_flags with a "bool readonly"

2023-06-08 Thread Christoph Hellwig
Stop passing the fmode_t around and just use a simple bool to track if
an export is read-only.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Hannes Reinecke 
Acked-by: Christian Brauner 
Acked-by: Jack Wang 
---
 drivers/block/rnbd/rnbd-srv-sysfs.c |  3 +--
 drivers/block/rnbd/rnbd-srv.c   | 15 +++
 drivers/block/rnbd/rnbd-srv.h   |  2 +-
 3 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/block/rnbd/rnbd-srv-sysfs.c 
b/drivers/block/rnbd/rnbd-srv-sysfs.c
index d5d9267e1fa5e4..ebd95771c85ec7 100644
--- a/drivers/block/rnbd/rnbd-srv-sysfs.c
+++ b/drivers/block/rnbd/rnbd-srv-sysfs.c
@@ -88,8 +88,7 @@ static ssize_t read_only_show(struct kobject *kobj, struct 
kobj_attribute *attr,
 
sess_dev = container_of(kobj, struct rnbd_srv_sess_dev, kobj);
 
-   return sysfs_emit(page, "%d\n",
- !(sess_dev->open_flags & FMODE_WRITE));
+   return sysfs_emit(page, "%d\n", sess_dev->readonly);
 }
 
 static struct kobj_attribute rnbd_srv_dev_session_ro_attr =
diff --git a/drivers/block/rnbd/rnbd-srv.c b/drivers/block/rnbd/rnbd-srv.c
index 29d560472d05ba..b680071342b898 100644
--- a/drivers/block/rnbd/rnbd-srv.c
+++ b/drivers/block/rnbd/rnbd-srv.c
@@ -222,7 +222,7 @@ void rnbd_destroy_sess_dev(struct rnbd_srv_sess_dev 
*sess_dev, bool keep_id)
blkdev_put(sess_dev->bdev, NULL);
mutex_lock(&sess_dev->dev->lock);
list_del(&sess_dev->dev_list);
-   if (sess_dev->open_flags & FMODE_WRITE)
+   if (!sess_dev->readonly)
sess_dev->dev->open_write_cnt--;
mutex_unlock(&sess_dev->dev->lock);
 
@@ -561,7 +561,7 @@ static void rnbd_srv_fill_msg_open_rsp(struct 
rnbd_msg_open_rsp *rsp,
 static struct rnbd_srv_sess_dev *
 rnbd_srv_create_set_sess_dev(struct rnbd_srv_session *srv_sess,
  const struct rnbd_msg_open *open_msg,
- struct block_device *bdev, fmode_t open_flags,
+ struct block_device *bdev, bool readonly,
  struct rnbd_srv_dev *srv_dev)
 {
struct rnbd_srv_sess_dev *sdev = rnbd_sess_dev_alloc(srv_sess);
@@ -576,7 +576,7 @@ rnbd_srv_create_set_sess_dev(struct rnbd_srv_session 
*srv_sess,
sdev->bdev  = bdev;
sdev->sess  = srv_sess;
sdev->dev   = srv_dev;
-   sdev->open_flags= open_flags;
+   sdev->readonly  = readonly;
sdev->access_mode   = open_msg->access_mode;
 
return sdev;
@@ -681,13 +681,12 @@ static int process_msg_open(struct rnbd_srv_session 
*srv_sess,
struct rnbd_srv_sess_dev *srv_sess_dev;
const struct rnbd_msg_open *open_msg = msg;
struct block_device *bdev;
-   fmode_t open_flags;
+   fmode_t open_flags = FMODE_READ;
char *full_path;
struct rnbd_msg_open_rsp *rsp = data;
 
trace_process_msg_open(srv_sess, open_msg);
 
-   open_flags = FMODE_READ;
if (open_msg->access_mode != RNBD_ACCESS_RO)
open_flags |= FMODE_WRITE;
 
@@ -736,9 +735,9 @@ static int process_msg_open(struct rnbd_srv_session 
*srv_sess,
goto blkdev_put;
}
 
-   srv_sess_dev = rnbd_srv_create_set_sess_dev(srv_sess, open_msg,
-bdev, open_flags,
-srv_dev);
+   srv_sess_dev = rnbd_srv_create_set_sess_dev(srv_sess, open_msg, bdev,
+   open_msg->access_mode == RNBD_ACCESS_RO,
+   srv_dev);
if (IS_ERR(srv_sess_dev)) {
pr_err("Opening device '%s' on session %s failed, creating 
sess_dev failed, err: %ld\n",
   full_path, srv_sess->sessname, PTR_ERR(srv_sess_dev));
diff --git a/drivers/block/rnbd/rnbd-srv.h b/drivers/block/rnbd/rnbd-srv.h
index f5962fd31d62e4..76077a9db3dd55 100644
--- a/drivers/block/rnbd/rnbd-srv.h
+++ b/drivers/block/rnbd/rnbd-srv.h
@@ -52,7 +52,7 @@ struct rnbd_srv_sess_dev {
struct kobject  kobj;
u32 device_id;
boolkeep_id;
-   fmode_t open_flags;
+   boolreadonly;
struct kref kref;
struct completion   *destroy_comp;
charpathname[NAME_MAX];
-- 
2.39.2



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 18/30] scsi: replace the fmode_t argument to scsi_cmd_allowed with a simple bool

2023-06-08 Thread Christoph Hellwig
Instead of passing a fmode_t and only checking it for FMODE_WRITE, pass
a bool open_for_write to prepare for callers that won't have the fmode_t.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Martin K. Petersen 
Reviewed-by: Hannes Reinecke 
Acked-by: Christian Brauner 
---
 drivers/scsi/scsi_bsg.c   | 2 +-
 drivers/scsi/scsi_ioctl.c | 8 
 drivers/scsi/sg.c | 2 +-
 include/scsi/scsi_ioctl.h | 2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/scsi_bsg.c b/drivers/scsi/scsi_bsg.c
index 96ee35256a168f..12431f35f861e1 100644
--- a/drivers/scsi/scsi_bsg.c
+++ b/drivers/scsi/scsi_bsg.c
@@ -42,7 +42,7 @@ static int scsi_bsg_sg_io_fn(struct request_queue *q, struct 
sg_io_v4 *hdr,
if (copy_from_user(scmd->cmnd, uptr64(hdr->request), scmd->cmd_len))
goto out_put_request;
ret = -EPERM;
-   if (!scsi_cmd_allowed(scmd->cmnd, mode))
+   if (!scsi_cmd_allowed(scmd->cmnd, mode & FMODE_WRITE))
goto out_put_request;
 
ret = 0;
diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c
index e3b31d32b6a92e..dda5468ca97f90 100644
--- a/drivers/scsi/scsi_ioctl.c
+++ b/drivers/scsi/scsi_ioctl.c
@@ -248,7 +248,7 @@ static int scsi_send_start_stop(struct scsi_device *sdev, 
int data)
  * Only a subset of commands are allowed for unprivileged users. Commands used
  * to format the media, update the firmware, etc. are not permitted.
  */
-bool scsi_cmd_allowed(unsigned char *cmd, fmode_t mode)
+bool scsi_cmd_allowed(unsigned char *cmd, bool open_for_write)
 {
/* root can do any command. */
if (capable(CAP_SYS_RAWIO))
@@ -338,7 +338,7 @@ bool scsi_cmd_allowed(unsigned char *cmd, fmode_t mode)
case GPCMD_SET_READ_AHEAD:
/* ZBC */
case ZBC_OUT:
-   return (mode & FMODE_WRITE);
+   return open_for_write;
default:
return false;
}
@@ -354,7 +354,7 @@ static int scsi_fill_sghdr_rq(struct scsi_device *sdev, 
struct request *rq,
return -EMSGSIZE;
if (copy_from_user(scmd->cmnd, hdr->cmdp, hdr->cmd_len))
return -EFAULT;
-   if (!scsi_cmd_allowed(scmd->cmnd, mode))
+   if (!scsi_cmd_allowed(scmd->cmnd, mode & FMODE_WRITE))
return -EPERM;
scmd->cmd_len = hdr->cmd_len;
 
@@ -554,7 +554,7 @@ static int sg_scsi_ioctl(struct request_queue *q, fmode_t 
mode,
goto error;
 
err = -EPERM;
-   if (!scsi_cmd_allowed(scmd->cmnd, mode))
+   if (!scsi_cmd_allowed(scmd->cmnd, mode & FMODE_WRITE))
goto error;
 
/* default.  possible overridden later */
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 037f8c98a6d364..e49ea693d0b656 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -237,7 +237,7 @@ static int sg_allow_access(struct file *filp, unsigned char 
*cmd)
 
if (sfp->parentdp->device->type == TYPE_SCANNER)
return 0;
-   if (!scsi_cmd_allowed(cmd, filp->f_mode))
+   if (!scsi_cmd_allowed(cmd, filp->f_mode & FMODE_WRITE))
return -EPERM;
return 0;
 }
diff --git a/include/scsi/scsi_ioctl.h b/include/scsi/scsi_ioctl.h
index beac64e38b8746..914201a8cb947c 100644
--- a/include/scsi/scsi_ioctl.h
+++ b/include/scsi/scsi_ioctl.h
@@ -49,7 +49,7 @@ int scsi_ioctl(struct scsi_device *sdev, fmode_t mode, int 
cmd,
void __user *arg);
 int get_sg_io_hdr(struct sg_io_hdr *hdr, const void __user *argp);
 int put_sg_io_hdr(const struct sg_io_hdr *hdr, void __user *argp);
-bool scsi_cmd_allowed(unsigned char *cmd, fmode_t mode);
+bool scsi_cmd_allowed(unsigned char *cmd, bool open_for_write);
 
 #endif /* __KERNEL__ */
 #endif /* _SCSI_IOCTL_H */
-- 
2.39.2



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 19/30] scsi: replace the fmode_t argument to scsi_ioctl with a simple bool

2023-06-08 Thread Christoph Hellwig
Instead of passing a fmode_t and only checking it for FMODE_WRITE, pass
a bool open_for_write to prepare for callers that won't have the fmode_t.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Martin K. Petersen 
Reviewed-by: Hannes Reinecke 
Acked-by: Christian Brauner 
---
 drivers/scsi/ch.c |  3 ++-
 drivers/scsi/scsi_ioctl.c | 34 +-
 drivers/scsi/sd.c |  2 +-
 drivers/scsi/sg.c |  5 +++--
 drivers/scsi/sr.c |  2 +-
 drivers/scsi/st.c |  2 +-
 include/scsi/scsi_ioctl.h |  2 +-
 7 files changed, 26 insertions(+), 24 deletions(-)

diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c
index ac648bb8f7e7f4..cb0a399be1ccee 100644
--- a/drivers/scsi/ch.c
+++ b/drivers/scsi/ch.c
@@ -877,7 +877,8 @@ static long ch_ioctl(struct file *file,
}
 
default:
-   return scsi_ioctl(ch->device, file->f_mode, cmd, argp);
+   return scsi_ioctl(ch->device, file->f_mode & FMODE_WRITE, cmd,
+ argp);
 
}
 }
diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c
index dda5468ca97f90..6f6c5973c3ea95 100644
--- a/drivers/scsi/scsi_ioctl.c
+++ b/drivers/scsi/scsi_ioctl.c
@@ -346,7 +346,7 @@ bool scsi_cmd_allowed(unsigned char *cmd, bool 
open_for_write)
 EXPORT_SYMBOL(scsi_cmd_allowed);
 
 static int scsi_fill_sghdr_rq(struct scsi_device *sdev, struct request *rq,
-   struct sg_io_hdr *hdr, fmode_t mode)
+   struct sg_io_hdr *hdr, bool open_for_write)
 {
struct scsi_cmnd *scmd = blk_mq_rq_to_pdu(rq);
 
@@ -354,7 +354,7 @@ static int scsi_fill_sghdr_rq(struct scsi_device *sdev, 
struct request *rq,
return -EMSGSIZE;
if (copy_from_user(scmd->cmnd, hdr->cmdp, hdr->cmd_len))
return -EFAULT;
-   if (!scsi_cmd_allowed(scmd->cmnd, mode & FMODE_WRITE))
+   if (!scsi_cmd_allowed(scmd->cmnd, open_for_write))
return -EPERM;
scmd->cmd_len = hdr->cmd_len;
 
@@ -407,7 +407,8 @@ static int scsi_complete_sghdr_rq(struct request *rq, 
struct sg_io_hdr *hdr,
return ret;
 }
 
-static int sg_io(struct scsi_device *sdev, struct sg_io_hdr *hdr, fmode_t mode)
+static int sg_io(struct scsi_device *sdev, struct sg_io_hdr *hdr,
+   bool open_for_write)
 {
unsigned long start_time;
ssize_t ret = 0;
@@ -448,7 +449,7 @@ static int sg_io(struct scsi_device *sdev, struct sg_io_hdr 
*hdr, fmode_t mode)
goto out_put_request;
}
 
-   ret = scsi_fill_sghdr_rq(sdev, rq, hdr, mode);
+   ret = scsi_fill_sghdr_rq(sdev, rq, hdr, open_for_write);
if (ret < 0)
goto out_put_request;
 
@@ -477,8 +478,7 @@ static int sg_io(struct scsi_device *sdev, struct sg_io_hdr 
*hdr, fmode_t mode)
 /**
  * sg_scsi_ioctl  --  handle deprecated SCSI_IOCTL_SEND_COMMAND ioctl
  * @q: request queue to send scsi commands down
- * @mode:  mode used to open the file through which the ioctl has been
- * submitted
+ * @open_for_write: is the file / block device opened for writing?
  * @sic:   userspace structure describing the command to perform
  *
  * Send down the scsi command described by @sic to the device below
@@ -501,7 +501,7 @@ static int sg_io(struct scsi_device *sdev, struct sg_io_hdr 
*hdr, fmode_t mode)
  *  Positive numbers returned are the compacted SCSI error codes (4
  *  bytes in one int) where the lowest byte is the SCSI status.
  */
-static int sg_scsi_ioctl(struct request_queue *q, fmode_t mode,
+static int sg_scsi_ioctl(struct request_queue *q, bool open_for_write,
struct scsi_ioctl_command __user *sic)
 {
struct request *rq;
@@ -554,7 +554,7 @@ static int sg_scsi_ioctl(struct request_queue *q, fmode_t 
mode,
goto error;
 
err = -EPERM;
-   if (!scsi_cmd_allowed(scmd->cmnd, mode & FMODE_WRITE))
+   if (!scsi_cmd_allowed(scmd->cmnd, open_for_write))
goto error;
 
/* default.  possible overridden later */
@@ -776,7 +776,7 @@ static int scsi_put_cdrom_generic_arg(const struct 
cdrom_generic_command *cgc,
return 0;
 }
 
-static int scsi_cdrom_send_packet(struct scsi_device *sdev, fmode_t mode,
+static int scsi_cdrom_send_packet(struct scsi_device *sdev, bool 
open_for_write,
void __user *arg)
 {
struct cdrom_generic_command cgc;
@@ -817,7 +817,7 @@ static int scsi_cdrom_send_packet(struct scsi_device *sdev, 
fmode_t mode,
hdr.cmdp = ((struct cdrom_generic_command __user *) arg)->cmd;
hdr.cmd_len = sizeof(cgc.cmd);
 
-   err = sg_io(sdev, &hdr, mode);
+   err = sg_io(sdev, &hdr, open_for_write);
if (err == -EFAULT)
return -EFAULT;
 
@@ -832,7 +832,7 @@ static int scsi_cdrom_send_packet(struct scsi_device *sdev, 
fmode_t mode,
return err;
 }
 
-static in

[f2fs-dev] [PATCH 15/30] block: use the holder as indication for exclusive opens

2023-06-08 Thread Christoph Hellwig
The current interface for exclusive opens is rather confusing as it
requires both the FMODE_EXCL flag and a holder.  Remove the need to pass
FMODE_EXCL and just key off the exclusive open off a non-NULL holder.

For blkdev_put this requires adding the holder argument, which provides
better debug checking that only the holder actually releases the hold,
but at the same time allows removing the now superfluous mode argument.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Hannes Reinecke 
Acked-by: Christian Brauner 
Acked-by: David Sterba[btrfs]
Acked-by: Jack Wang   [rnbd]
---
 block/bdev.c| 37 
 block/fops.c|  6 +++--
 block/genhd.c   |  5 ++--
 block/ioctl.c   |  5 ++--
 drivers/block/drbd/drbd_nl.c| 23 ++---
 drivers/block/pktcdvd.c | 13 +-
 drivers/block/rnbd/rnbd-srv.c   |  4 +--
 drivers/block/xen-blkback/xenbus.c  |  2 +-
 drivers/block/zram/zram_drv.c   |  8 +++---
 drivers/md/bcache/super.c   | 15 ++--
 drivers/md/dm.c |  6 ++---
 drivers/md/md.c | 38 +++--
 drivers/mtd/devices/block2mtd.c |  4 +--
 drivers/nvme/target/io-cmd-bdev.c   |  2 +-
 drivers/s390/block/dasd_genhd.c |  2 +-
 drivers/target/target_core_iblock.c |  6 ++---
 drivers/target/target_core_pscsi.c  |  8 +++---
 fs/btrfs/dev-replace.c  |  6 ++---
 fs/btrfs/ioctl.c| 12 -
 fs/btrfs/volumes.c  | 28 ++---
 fs/btrfs/volumes.h  |  6 ++---
 fs/erofs/super.c|  7 +++---
 fs/ext4/super.c | 11 +++--
 fs/f2fs/super.c |  2 +-
 fs/jfs/jfs_logmgr.c |  6 ++---
 fs/nfs/blocklayout/dev.c|  4 +--
 fs/nilfs2/super.c   |  6 ++---
 fs/ocfs2/cluster/heartbeat.c|  4 +--
 fs/reiserfs/journal.c   | 19 +++
 fs/reiserfs/reiserfs.h  |  1 -
 fs/super.c  | 20 +++
 fs/xfs/xfs_super.c  | 15 ++--
 include/linux/blkdev.h  |  2 +-
 kernel/power/hibernate.c| 12 +++--
 kernel/power/power.h|  2 +-
 kernel/power/swap.c | 21 +++-
 mm/swapfile.c   |  7 +++---
 37 files changed, 183 insertions(+), 192 deletions(-)

diff --git a/block/bdev.c b/block/bdev.c
index 2c6888ceb3784a..db63e5bcc46ffa 100644
--- a/block/bdev.c
+++ b/block/bdev.c
@@ -604,7 +604,7 @@ void bd_abort_claiming(struct block_device *bdev, void 
*holder)
 }
 EXPORT_SYMBOL(bd_abort_claiming);
 
-static void bd_end_claim(struct block_device *bdev)
+static void bd_end_claim(struct block_device *bdev, void *holder)
 {
struct block_device *whole = bdev_whole(bdev);
bool unblock = false;
@@ -614,6 +614,7 @@ static void bd_end_claim(struct block_device *bdev)
 * bdev_lock.  open_mutex is used to synchronize disk_holder unlinking.
 */
mutex_lock(&bdev_lock);
+   WARN_ON_ONCE(bdev->bd_holder != holder);
WARN_ON_ONCE(--bdev->bd_holders < 0);
WARN_ON_ONCE(--whole->bd_holders < 0);
if (!bdev->bd_holders) {
@@ -750,10 +751,9 @@ void blkdev_put_no_open(struct block_device *bdev)
  * @holder: exclusive holder identifier
  * @hops: holder operations
  *
- * Open the block device described by device number @dev. If @mode includes
- * %FMODE_EXCL, the block device is opened with exclusive access.  Specifying
- * %FMODE_EXCL with a %NULL @holder is invalid.  Exclusive opens may nest for
- * the same @holder.
+ * Open the block device described by device number @dev. If @holder is not
+ * %NULL, the block device is opened with exclusive access.  Exclusive opens 
may
+ * nest for the same @holder.
  *
  * Use this interface ONLY if you really do not have anything better - i.e. 
when
  * you are behind a truly sucky interface and all you are given is a device
@@ -785,10 +785,16 @@ struct block_device *blkdev_get_by_dev(dev_t dev, fmode_t 
mode, void *holder,
return ERR_PTR(-ENXIO);
disk = bdev->bd_disk;
 
-   if (mode & FMODE_EXCL) {
+   if (holder) {
+   mode |= FMODE_EXCL;
ret = bd_prepare_to_claim(bdev, holder, hops);
if (ret)
goto put_blkdev;
+   } else {
+   if (WARN_ON_ONCE(mode & FMODE_EXCL)) {
+   ret = -EIO;
+   goto put_blkdev;
+   }
}
 
disk_block_events(disk);
@@ -805,7 +811,7 @@ struct block_device *blkdev_get_by_dev(dev_t dev, fmode_t 
mode, void *holder,
ret = blkdev_get_whole(bdev, mode);
if (ret)
goto put_module;
-   if (mode &

[f2fs-dev] [PATCH 11/30] swsusp: don't pass a stack address to blkdev_get_by_path

2023-06-08 Thread Christoph Hellwig
holder is just an on-stack pointer that can easily be reused by other calls,
replace it with a static variable that doesn't change.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Hannes Reinecke 
---
 kernel/power/swap.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/kernel/power/swap.c b/kernel/power/swap.c
index 81aec3b2c60510..b03ff1a33c7f68 100644
--- a/kernel/power/swap.c
+++ b/kernel/power/swap.c
@@ -1510,6 +1510,8 @@ int swsusp_read(unsigned int *flags_p)
return error;
 }
 
+static void *swsusp_holder;
+
 /**
  *  swsusp_check - Check for swsusp signature in the resume device
  */
@@ -1517,14 +1519,13 @@ int swsusp_read(unsigned int *flags_p)
 int swsusp_check(bool snapshot_test)
 {
int error;
-   void *holder;
fmode_t mode = FMODE_READ;
 
if (snapshot_test)
mode |= FMODE_EXCL;
 
hib_resume_bdev = blkdev_get_by_dev(swsusp_resume_device,
-   mode, &holder, NULL);
+   mode, &swsusp_holder, NULL);
if (!IS_ERR(hib_resume_bdev)) {
set_blocksize(hib_resume_bdev, PAGE_SIZE);
clear_page(swsusp_header);
-- 
2.39.2



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 05/30] cdrom: track if a cdrom_device_info was opened for data

2023-06-08 Thread Christoph Hellwig
Set a flag when a cdrom_device_info is opened for writing, instead of
trying to figure out this at release time.  This will allow to eventually
remove the mode argument to the ->release block_device_operation as
nothing but the CDROM drivers uses that argument.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Phillip Potter 
Acked-by: Christian Brauner 
---
 drivers/cdrom/cdrom.c | 12 +---
 include/linux/cdrom.h |  1 +
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
index 08abf1ffede002..adebac1bd210d9 100644
--- a/drivers/cdrom/cdrom.c
+++ b/drivers/cdrom/cdrom.c
@@ -1172,6 +1172,7 @@ int cdrom_open(struct cdrom_device_info *cdi, fmode_t 
mode)
ret = 0;
cdi->media_written = 0;
}
+   cdi->opened_for_data = true;
}
 
if (ret)
@@ -1252,7 +1253,6 @@ static int check_for_audio_disc(struct cdrom_device_info 
*cdi,
 void cdrom_release(struct cdrom_device_info *cdi, fmode_t mode)
 {
const struct cdrom_device_ops *cdo = cdi->ops;
-   int opened_for_data;
 
cd_dbg(CD_CLOSE, "entering cdrom_release\n");
 
@@ -1270,14 +1270,12 @@ void cdrom_release(struct cdrom_device_info *cdi, 
fmode_t mode)
}
}
 
-   opened_for_data = !(cdi->options & CDO_USE_FFLAGS) ||
-   !(mode & FMODE_NDELAY);
-
cdo->release(cdi);
-   if (cdi->use_count == 0) {  /* last process that closes dev*/
-   if (opened_for_data &&
-   cdi->options & CDO_AUTO_EJECT && CDROM_CAN(CDC_OPEN_TRAY))
+
+   if (cdi->use_count == 0 && cdi->opened_for_data) {
+   if (cdi->options & CDO_AUTO_EJECT && CDROM_CAN(CDC_OPEN_TRAY))
cdo->tray_move(cdi, 1);
+   cdi->opened_for_data = false;
}
 }
 EXPORT_SYMBOL(cdrom_release);
diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
index 0a5db0b0c958a1..adcc9f2beb2653 100644
--- a/include/linux/cdrom.h
+++ b/include/linux/cdrom.h
@@ -63,6 +63,7 @@ struct cdrom_device_info {
unsigned short mmc3_profile;/* current MMC3 profile */
int (*exit)(struct cdrom_device_info *);
int mrw_mode_page;
+   bool opened_for_data;
__s64 last_media_change_ms;
 };
 
-- 
2.39.2



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 16/30] block: add a sb_open_mode helper

2023-06-08 Thread Christoph Hellwig
Add a helper to return the open flags for blkdev_get_by* for passed in
super block flags instead of open coding the logic in many places.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Hannes Reinecke 
Acked-by: Christian Brauner 
---
 fs/btrfs/super.c   |  5 +
 fs/nilfs2/super.c  |  7 ++-
 fs/super.c | 15 ---
 include/linux/blkdev.h |  7 +++
 4 files changed, 14 insertions(+), 20 deletions(-)

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 1a2ee9407f5414..fd02b92e39106a 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -1440,12 +1440,9 @@ static struct dentry *btrfs_mount_root(struct 
file_system_type *fs_type,
struct btrfs_fs_devices *fs_devices = NULL;
struct btrfs_fs_info *fs_info = NULL;
void *new_sec_opts = NULL;
-   fmode_t mode = FMODE_READ;
+   fmode_t mode = sb_open_mode(flags);
int error = 0;
 
-   if (!(flags & SB_RDONLY))
-   mode |= FMODE_WRITE;
-
if (data) {
error = security_sb_eat_lsm_opts(data, &new_sec_opts);
if (error)
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
index 61d5e79a5e81df..a41fd84d4e28ab 100644
--- a/fs/nilfs2/super.c
+++ b/fs/nilfs2/super.c
@@ -1278,14 +1278,11 @@ nilfs_mount(struct file_system_type *fs_type, int flags,
 {
struct nilfs_super_data sd;
struct super_block *s;
-   fmode_t mode = FMODE_READ;
struct dentry *root_dentry;
int err, s_new = false;
 
-   if (!(flags & SB_RDONLY))
-   mode |= FMODE_WRITE;
-
-   sd.bdev = blkdev_get_by_path(dev_name, mode, fs_type, NULL);
+   sd.bdev = blkdev_get_by_path(dev_name, sb_open_mode(flags), fs_type,
+NULL);
if (IS_ERR(sd.bdev))
return ERR_CAST(sd.bdev);
 
diff --git a/fs/super.c b/fs/super.c
index 8563794a8bc462..dc7f328398339d 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -1255,17 +1255,13 @@ int get_tree_bdev(struct fs_context *fc,
 {
struct block_device *bdev;
struct super_block *s;
-   fmode_t mode = FMODE_READ;
int error = 0;
 
-   if (!(fc->sb_flags & SB_RDONLY))
-   mode |= FMODE_WRITE;
-
if (!fc->source)
return invalf(fc, "No source specified");
 
-   bdev = blkdev_get_by_path(fc->source, mode, fc->fs_type,
- &fs_holder_ops);
+   bdev = blkdev_get_by_path(fc->source, sb_open_mode(fc->sb_flags),
+ fc->fs_type, &fs_holder_ops);
if (IS_ERR(bdev)) {
errorf(fc, "%s: Can't open blockdev", fc->source);
return PTR_ERR(bdev);
@@ -1344,13 +1340,10 @@ struct dentry *mount_bdev(struct file_system_type 
*fs_type,
 {
struct block_device *bdev;
struct super_block *s;
-   fmode_t mode = FMODE_READ;
int error = 0;
 
-   if (!(flags & SB_RDONLY))
-   mode |= FMODE_WRITE;
-
-   bdev = blkdev_get_by_path(dev_name, mode, fs_type, &fs_holder_ops);
+   bdev = blkdev_get_by_path(dev_name, sb_open_mode(flags), fs_type,
+ &fs_holder_ops);
if (IS_ERR(bdev))
return ERR_CAST(bdev);
 
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index d5b99796f12c11..97803603902076 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1473,6 +1473,13 @@ struct blk_holder_ops {
void (*mark_dead)(struct block_device *bdev);
 };
 
+/*
+ * Return the correct open flags for blkdev_get_by_* for super block flags
+ * as stored in sb->s_flags.
+ */
+#define sb_open_mode(flags) \
+   (FMODE_READ | (((flags) & SB_RDONLY) ? 0 : FMODE_WRITE))
+
 struct block_device *blkdev_get_by_dev(dev_t dev, fmode_t mode, void *holder,
const struct blk_holder_ops *hops);
 struct block_device *blkdev_get_by_path(const char *path, fmode_t mode,
-- 
2.39.2



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 06/30] cdrom: remove the unused mode argument to cdrom_release

2023-06-08 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig 
Reviewed-by: Phillip Potter 
Reviewed-by: Hannes Reinecke 
Acked-by: Christian Brauner 
---
 drivers/cdrom/cdrom.c | 2 +-
 drivers/cdrom/gdrom.c | 2 +-
 drivers/scsi/sr.c | 2 +-
 include/linux/cdrom.h | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
index adebac1bd210d9..998b03fe976e22 100644
--- a/drivers/cdrom/cdrom.c
+++ b/drivers/cdrom/cdrom.c
@@ -1250,7 +1250,7 @@ static int check_for_audio_disc(struct cdrom_device_info 
*cdi,
return 0;
 }
 
-void cdrom_release(struct cdrom_device_info *cdi, fmode_t mode)
+void cdrom_release(struct cdrom_device_info *cdi)
 {
const struct cdrom_device_ops *cdo = cdi->ops;
 
diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
index 14922403983e9e..a401dc4218a998 100644
--- a/drivers/cdrom/gdrom.c
+++ b/drivers/cdrom/gdrom.c
@@ -481,7 +481,7 @@ static int gdrom_bdops_open(struct block_device *bdev, 
fmode_t mode)
bdev_check_media_change(bdev);
 
mutex_lock(&gdrom_mutex);
-   ret = cdrom_open(gd.cd_info, mode);
+   ret = cdrom_open(gd.cd_info);
mutex_unlock(&gdrom_mutex);
return ret;
 }
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index 444c7efc14cba7..6d33120ee5ba85 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -512,7 +512,7 @@ static void sr_block_release(struct gendisk *disk, fmode_t 
mode)
struct scsi_cd *cd = scsi_cd(disk);
 
mutex_lock(&cd->lock);
-   cdrom_release(&cd->cdi, mode);
+   cdrom_release(&cd->cdi);
mutex_unlock(&cd->lock);
 
scsi_device_put(cd->device);
diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
index adcc9f2beb2653..3c253b29f4aafc 100644
--- a/include/linux/cdrom.h
+++ b/include/linux/cdrom.h
@@ -102,7 +102,7 @@ int cdrom_read_tocentry(struct cdrom_device_info *cdi,
 
 /* the general block_device operations structure: */
 int cdrom_open(struct cdrom_device_info *cdi, fmode_t mode);
-extern void cdrom_release(struct cdrom_device_info *cdi, fmode_t mode);
+void cdrom_release(struct cdrom_device_info *cdi);
 int cdrom_ioctl(struct cdrom_device_info *cdi, struct block_device *bdev,
unsigned int cmd, unsigned long arg);
 extern unsigned int cdrom_check_events(struct cdrom_device_info *cdi,
-- 
2.39.2



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 14/30] btrfs: don't pass a holder for non-exclusive blkdev_get_by_path

2023-06-08 Thread Christoph Hellwig
Passing a holder to blkdev_get_by_path when FMODE_EXCL isn't set doesn't
make sense, so pass NULL instead and remove the holder argument from the
call chains the only end up in non-FMODE_EXCL blkdev_get_by_path calls.

Exclusive mode for device scanning is not used since commit 50d281fc434c
("btrfs: scan device in non-exclusive mode")".

Signed-off-by: Christoph Hellwig 
Reviewed-by: Hannes Reinecke 
Acked-by: Christian Brauner 
Acked-by: David Sterba 
---
 fs/btrfs/super.c   | 16 ++--
 fs/btrfs/volumes.c | 17 -
 fs/btrfs/volumes.h |  3 +--
 3 files changed, 15 insertions(+), 21 deletions(-)

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index ec18e22106023b..1a2ee9407f5414 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -849,8 +849,7 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char 
*options,
  * All other options will be parsed on much later in the mount process and
  * only when we need to allocate a new super block.
  */
-static int btrfs_parse_device_options(const char *options, fmode_t flags,
- void *holder)
+static int btrfs_parse_device_options(const char *options, fmode_t flags)
 {
substring_t args[MAX_OPT_ARGS];
char *device_name, *opts, *orig, *p;
@@ -884,8 +883,7 @@ static int btrfs_parse_device_options(const char *options, 
fmode_t flags,
error = -ENOMEM;
goto out;
}
-   device = btrfs_scan_one_device(device_name, flags,
-   holder);
+   device = btrfs_scan_one_device(device_name, flags);
kfree(device_name);
if (IS_ERR(device)) {
error = PTR_ERR(device);
@@ -1477,13 +1475,13 @@ static struct dentry *btrfs_mount_root(struct 
file_system_type *fs_type,
}
 
mutex_lock(&uuid_mutex);
-   error = btrfs_parse_device_options(data, mode, fs_type);
+   error = btrfs_parse_device_options(data, mode);
if (error) {
mutex_unlock(&uuid_mutex);
goto error_fs_info;
}
 
-   device = btrfs_scan_one_device(device_name, mode, fs_type);
+   device = btrfs_scan_one_device(device_name, mode);
if (IS_ERR(device)) {
mutex_unlock(&uuid_mutex);
error = PTR_ERR(device);
@@ -2190,8 +2188,7 @@ static long btrfs_control_ioctl(struct file *file, 
unsigned int cmd,
switch (cmd) {
case BTRFS_IOC_SCAN_DEV:
mutex_lock(&uuid_mutex);
-   device = btrfs_scan_one_device(vol->name, FMODE_READ,
-  &btrfs_root_fs_type);
+   device = btrfs_scan_one_device(vol->name, FMODE_READ);
ret = PTR_ERR_OR_ZERO(device);
mutex_unlock(&uuid_mutex);
break;
@@ -2205,8 +2202,7 @@ static long btrfs_control_ioctl(struct file *file, 
unsigned int cmd,
break;
case BTRFS_IOC_DEVICES_READY:
mutex_lock(&uuid_mutex);
-   device = btrfs_scan_one_device(vol->name, FMODE_READ,
-  &btrfs_root_fs_type);
+   device = btrfs_scan_one_device(vol->name, FMODE_READ);
if (IS_ERR(device)) {
mutex_unlock(&uuid_mutex);
ret = PTR_ERR(device);
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 784ccc8f6c69c1..035868cee3ddc3 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1348,8 +1348,7 @@ int btrfs_forget_devices(dev_t devt)
  * and we are not allowed to call set_blocksize during the scan. The superblock
  * is read via pagecache
  */
-struct btrfs_device *btrfs_scan_one_device(const char *path, fmode_t flags,
-  void *holder)
+struct btrfs_device *btrfs_scan_one_device(const char *path, fmode_t flags)
 {
struct btrfs_super_block *disk_super;
bool new_device_added = false;
@@ -1368,16 +1367,16 @@ struct btrfs_device *btrfs_scan_one_device(const char 
*path, fmode_t flags,
 */
 
/*
-* Avoid using flag |= FMODE_EXCL here, as the systemd-udev may
-* initiate the device scan which may race with the user's mount
-* or mkfs command, resulting in failure.
-* Since the device scan is solely for reading purposes, there is
-* no need for FMODE_EXCL. Additionally, the devices are read again
+* Avoid an exclusive open here, as the systemd-udev may initiate the
+* device scan which may race with the user's mount or mkfs command,
+* resulting in failure.
+* Since the device scan is solely for reading purposes, there is no
+* need for an exclusive open. Additionally, t

[f2fs-dev] [PATCH 12/30] bcache: don't pass a stack address to blkdev_get_by_path

2023-06-08 Thread Christoph Hellwig
sb is just an on-stack pointer that can easily be reused by other calls.
Switch to use the bcache-wide bcache_kobj instead as there is no need to
claim per-bcache device anyway.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Hannes Reinecke 
---
 drivers/md/bcache/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 94b91c45c9e2a9..4a2aed047aec12 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -2560,7 +2560,7 @@ static ssize_t register_bcache(struct kobject *k, struct 
kobj_attribute *attr,
err = "failed to open device";
bdev = blkdev_get_by_path(strim(path),
  FMODE_READ|FMODE_WRITE|FMODE_EXCL,
- sb, NULL);
+ bcache_kobj, NULL);
if (IS_ERR(bdev)) {
if (bdev == ERR_PTR(-EBUSY)) {
dev_t dev;
-- 
2.39.2



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] decouple block open flags from fmode_t v2

2023-06-08 Thread Christoph Hellwig
Hi all,

this series adds a new blk_mode_t for block open flags instead of abusing
fmode_t.  The block open flags work very different from the normal use of
fmode_t and only share the basic READ/WRITE flags with it.  None of the
other normal FMODE_* flags is used, but instead there are three
block-specific ones not used by anyone else, which can now be removed.

Note that I've only CCed maintainers and lists for drivers and file systems
that have non-trivial changes, as otherwise the series would spam literally
everyone in the block and file system world.

A git tree is available here:

git://git.infradead.org/users/hch/block.git blk-open-release

Gitweb:


http://git.infradead.org/users/hch/block.git/shortlog/refs/heads/blk-open-release

Changes since v1:
 - drop "block: share code between disk_check_media_change and
   disk_force_media_change" for now as it conflicts with a fix in
   disk_force_media_change
 - add a few missing fmode_t -> blk_mode_t conversions
 - move the opened_for_data memeber in struct cdrom_device_info to a
   place that creates less padding
 - better document the magic floppy O_ACCMODE == O_WRONLY | O_RDWR case
 - better document the new usage of file->private_data for block devices
 - improve a few commit messages

Diffstat:
 arch/um/drivers/ubd_kern.c  |   20 ++-
 arch/xtensa/platforms/iss/simdisk.c |6 +-
 block/bdev.c|   99 ++--
 block/blk-zoned.c   |   12 ++--
 block/blk.h |   26 -
 block/bsg-lib.c |2 
 block/bsg.c |8 +-
 block/disk-events.c |   18 +++---
 block/fops.c|   60 ++---
 block/genhd.c   |   13 ++--
 block/ioctl.c   |   61 +++---
 drivers/block/amiflop.c |   20 +++
 drivers/block/aoe/aoeblk.c  |8 +-
 drivers/block/ataflop.c |   43 +++
 drivers/block/drbd/drbd_main.c  |   13 ++--
 drivers/block/drbd/drbd_nl.c|   23 +---
 drivers/block/floppy.c  |   72 +-
 drivers/block/loop.c|   24 
 drivers/block/mtip32xx/mtip32xx.c   |4 -
 drivers/block/nbd.c |   12 ++--
 drivers/block/pktcdvd.c |   36 ++---
 drivers/block/rbd.c |6 +-
 drivers/block/rnbd/rnbd-clt.c   |8 +-
 drivers/block/rnbd/rnbd-srv-sysfs.c |3 -
 drivers/block/rnbd/rnbd-srv.c   |   23 
 drivers/block/rnbd/rnbd-srv.h   |2 
 drivers/block/sunvdc.c  |2 
 drivers/block/swim.c|   24 
 drivers/block/swim3.c   |   33 +---
 drivers/block/ublk_drv.c|4 -
 drivers/block/xen-blkback/xenbus.c  |4 -
 drivers/block/xen-blkfront.c|2 
 drivers/block/z2ram.c   |8 +-
 drivers/block/zram/zram_drv.c   |   21 +++
 drivers/cdrom/cdrom.c   |   38 +++--
 drivers/cdrom/gdrom.c   |   12 ++--
 drivers/md/bcache/bcache.h  |2 
 drivers/md/bcache/request.c |4 -
 drivers/md/bcache/super.c   |   25 -
 drivers/md/dm-cache-target.c|   12 ++--
 drivers/md/dm-clone-target.c|   10 +--
 drivers/md/dm-core.h|7 +-
 drivers/md/dm-era-target.c  |6 +-
 drivers/md/dm-ioctl.c   |   10 +--
 drivers/md/dm-snap.c|4 -
 drivers/md/dm-table.c   |   11 ++--
 drivers/md/dm-thin.c|9 +--
 drivers/md/dm-verity-fec.c  |2 
 drivers/md/dm-verity-target.c   |6 +-
 drivers/md/dm.c |   20 +++
 drivers/md/dm.h |2 
 drivers/md/md.c |   50 +-
 drivers/mmc/core/block.c|   12 ++--
 drivers/mtd/devices/block2mtd.c |6 +-
 drivers/mtd/mtd_blkdevs.c   |8 +-
 drivers/mtd/mtdblock.c  |2 
 drivers/mtd/ubi/block.c |9 +--
 drivers/nvme/host/core.c|6 +-
 drivers/nvme/host/ioctl.c   |   66 +---
 drivers/nvme/host/multipath.c   |6 +-
 drivers/nvme/host/nvme.h|4 -
 drivers/nvme/target/io-cmd-bdev.c   |4 -
 drivers/s390/block/dasd.c   |   10 +--
 drivers/s390/block/dasd_genhd.c |5 +
 drivers/s390/block/dasd_int.h   |3 -
 drivers/s390/block/dasd_ioctl.c |2 
 drivers/s390/block/dcssblk.c|   11 +---
 drivers/scsi/ch.c   |3 -
 drivers/scsi/scsi_bsg.c |4 -
 drivers/scsi/scsi_ioctl.c   |   38 ++---
 drivers/scsi/sd.c   |   39 ++
 drivers/scsi/sg.c   |7 +-
 drivers/scsi/sr.c   |   22 
 drivers/scsi/st.c   

[f2fs-dev] [PATCH 03/30] cdrom: remove the unused mode argument to cdrom_ioctl

2023-06-08 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig 
Reviewed-by: Phillip Potter 
Reviewed-by: Hannes Reinecke 
Acked-by: Christian Brauner 
---
 drivers/cdrom/cdrom.c | 2 +-
 drivers/cdrom/gdrom.c | 2 +-
 drivers/scsi/sr.c | 2 +-
 include/linux/cdrom.h | 4 ++--
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
index e3eab319cb0474..245e5bbb05d41c 100644
--- a/drivers/cdrom/cdrom.c
+++ b/drivers/cdrom/cdrom.c
@@ -3336,7 +3336,7 @@ static int mmc_ioctl(struct cdrom_device_info *cdi, 
unsigned int cmd,
  * ATAPI / SCSI specific code now mainly resides in mmc_ioctl().
  */
 int cdrom_ioctl(struct cdrom_device_info *cdi, struct block_device *bdev,
-   fmode_t mode, unsigned int cmd, unsigned long arg)
+   unsigned int cmd, unsigned long arg)
 {
void __user *argp = (void __user *)arg;
int ret;
diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
index eaa2d5a90bc82f..14922403983e9e 100644
--- a/drivers/cdrom/gdrom.c
+++ b/drivers/cdrom/gdrom.c
@@ -505,7 +505,7 @@ static int gdrom_bdops_ioctl(struct block_device *bdev, 
fmode_t mode,
int ret;
 
mutex_lock(&gdrom_mutex);
-   ret = cdrom_ioctl(gd.cd_info, bdev, mode, cmd, arg);
+   ret = cdrom_ioctl(gd.cd_info, bdev, cmd, arg);
mutex_unlock(&gdrom_mutex);
 
return ret;
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index 61b83880e395a4..444c7efc14cba7 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -539,7 +539,7 @@ static int sr_block_ioctl(struct block_device *bdev, 
fmode_t mode, unsigned cmd,
scsi_autopm_get_device(sdev);
 
if (cmd != CDROMCLOSETRAY && cmd != CDROMEJECT) {
-   ret = cdrom_ioctl(&cd->cdi, bdev, mode, cmd, arg);
+   ret = cdrom_ioctl(&cd->cdi, bdev, cmd, arg);
if (ret != -ENOSYS)
goto put;
}
diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
index cc5717cb0fa8a8..4aea8c82d16971 100644
--- a/include/linux/cdrom.h
+++ b/include/linux/cdrom.h
@@ -103,8 +103,8 @@ int cdrom_read_tocentry(struct cdrom_device_info *cdi,
 /* the general block_device operations structure: */
 int cdrom_open(struct cdrom_device_info *cdi, fmode_t mode);
 extern void cdrom_release(struct cdrom_device_info *cdi, fmode_t mode);
-extern int cdrom_ioctl(struct cdrom_device_info *cdi, struct block_device 
*bdev,
-  fmode_t mode, unsigned int cmd, unsigned long arg);
+int cdrom_ioctl(struct cdrom_device_info *cdi, struct block_device *bdev,
+   unsigned int cmd, unsigned long arg);
 extern unsigned int cdrom_check_events(struct cdrom_device_info *cdi,
   unsigned int clearing);
 
-- 
2.39.2



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 09/30] block: remove the unused mode argument to ->release

2023-06-08 Thread Christoph Hellwig
The mode argument to the ->release block_device_operation is never used,
so remove it.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Hannes Reinecke 
Acked-by: Christian Brauner 
Acked-by: Jack Wang   [rnbd]
---
 arch/um/drivers/ubd_kern.c  |  4 ++--
 arch/xtensa/platforms/iss/simdisk.c |  2 +-
 block/bdev.c| 14 +++---
 drivers/block/amiflop.c |  2 +-
 drivers/block/aoe/aoeblk.c  |  2 +-
 drivers/block/ataflop.c |  4 ++--
 drivers/block/drbd/drbd_main.c  |  4 ++--
 drivers/block/floppy.c  |  2 +-
 drivers/block/loop.c|  2 +-
 drivers/block/nbd.c |  2 +-
 drivers/block/pktcdvd.c |  4 ++--
 drivers/block/rbd.c |  2 +-
 drivers/block/rnbd/rnbd-clt.c   |  2 +-
 drivers/block/swim.c|  2 +-
 drivers/block/swim3.c   |  3 +--
 drivers/block/z2ram.c   |  2 +-
 drivers/cdrom/gdrom.c   |  2 +-
 drivers/md/bcache/super.c   |  2 +-
 drivers/md/dm.c |  2 +-
 drivers/md/md.c |  2 +-
 drivers/mmc/core/block.c|  2 +-
 drivers/mtd/mtd_blkdevs.c   |  2 +-
 drivers/mtd/ubi/block.c |  2 +-
 drivers/nvme/host/core.c|  2 +-
 drivers/nvme/host/multipath.c   |  2 +-
 drivers/s390/block/dasd.c   |  2 +-
 drivers/s390/block/dcssblk.c|  4 ++--
 drivers/scsi/sd.c   |  3 +--
 drivers/scsi/sr.c   |  2 +-
 include/linux/blkdev.h  |  2 +-
 30 files changed, 41 insertions(+), 43 deletions(-)

diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index 6b831f82881bc4..8b79554968addb 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -109,7 +109,7 @@ static DEFINE_MUTEX(ubd_lock);
 static DEFINE_MUTEX(ubd_mutex); /* replaces BKL, might not be needed */
 
 static int ubd_open(struct gendisk *disk, fmode_t mode);
-static void ubd_release(struct gendisk *disk, fmode_t mode);
+static void ubd_release(struct gendisk *disk);
 static int ubd_ioctl(struct block_device *bdev, fmode_t mode,
 unsigned int cmd, unsigned long arg);
 static int ubd_getgeo(struct block_device *bdev, struct hd_geometry *geo);
@@ -1182,7 +1182,7 @@ static int ubd_open(struct gendisk *disk, fmode_t mode)
return err;
 }
 
-static void ubd_release(struct gendisk *disk, fmode_t mode)
+static void ubd_release(struct gendisk *disk)
 {
struct ubd *ubd_dev = disk->private_data;
 
diff --git a/arch/xtensa/platforms/iss/simdisk.c 
b/arch/xtensa/platforms/iss/simdisk.c
index 38f95f79a1270c..2ad9da3de0d90f 100644
--- a/arch/xtensa/platforms/iss/simdisk.c
+++ b/arch/xtensa/platforms/iss/simdisk.c
@@ -130,7 +130,7 @@ static int simdisk_open(struct gendisk *disk, fmode_t mode)
return 0;
 }
 
-static void simdisk_release(struct gendisk *disk, fmode_t mode)
+static void simdisk_release(struct gendisk *disk)
 {
struct simdisk *dev = disk->private_data;
spin_lock(&dev->lock);
diff --git a/block/bdev.c b/block/bdev.c
index 8a5fded303d4ed..2c6888ceb3784a 100644
--- a/block/bdev.c
+++ b/block/bdev.c
@@ -670,12 +670,12 @@ static int blkdev_get_whole(struct block_device *bdev, 
fmode_t mode)
return 0;
 }
 
-static void blkdev_put_whole(struct block_device *bdev, fmode_t mode)
+static void blkdev_put_whole(struct block_device *bdev)
 {
if (atomic_dec_and_test(&bdev->bd_openers))
blkdev_flush_mapping(bdev);
if (bdev->bd_disk->fops->release)
-   bdev->bd_disk->fops->release(bdev->bd_disk, mode);
+   bdev->bd_disk->fops->release(bdev->bd_disk);
 }
 
 static int blkdev_get_part(struct block_device *part, fmode_t mode)
@@ -699,11 +699,11 @@ static int blkdev_get_part(struct block_device *part, 
fmode_t mode)
return 0;
 
 out_blkdev_put:
-   blkdev_put_whole(bdev_whole(part), mode);
+   blkdev_put_whole(bdev_whole(part));
return ret;
 }
 
-static void blkdev_put_part(struct block_device *part, fmode_t mode)
+static void blkdev_put_part(struct block_device *part)
 {
struct block_device *whole = bdev_whole(part);
 
@@ -711,7 +711,7 @@ static void blkdev_put_part(struct block_device *part, 
fmode_t mode)
blkdev_flush_mapping(part);
whole->bd_disk->open_partitions--;
}
-   blkdev_put_whole(whole, mode);
+   blkdev_put_whole(whole);
 }
 
 struct block_device *blkdev_get_no_open(dev_t dev)
@@ -903,9 +903,9 @@ void blkdev_put(struct block_device *bdev, fmode_t mode)
disk_flush_events(disk, DISK_EVENT_MEDIA_CHANGE);
 
if (bdev_is_partition(bdev))
-   blkdev_put_part(bdev, mode);
+   blkdev_put_part(bdev);
else
-   blkdev_put_whole(bdev, mode);
+   

[f2fs-dev] [PATCH 08/30] block: pass a gendisk to ->open

2023-06-08 Thread Christoph Hellwig
->open is only called on the whole device.  Make that explicit by
passing a gendisk instead of the block_device.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Hannes Reinecke 
Acked-by: Christian Brauner 
Acked-by: Jack Wang   [rnbd]
---
 arch/um/drivers/ubd_kern.c  |  5 ++---
 arch/xtensa/platforms/iss/simdisk.c |  4 ++--
 block/bdev.c|  2 +-
 drivers/block/amiflop.c |  8 
 drivers/block/aoe/aoeblk.c  |  4 ++--
 drivers/block/ataflop.c | 16 +++
 drivers/block/drbd/drbd_main.c  |  6 +++---
 drivers/block/floppy.c  | 30 +++--
 drivers/block/nbd.c |  8 
 drivers/block/pktcdvd.c |  6 +++---
 drivers/block/rbd.c |  4 ++--
 drivers/block/rnbd/rnbd-clt.c   |  4 ++--
 drivers/block/swim.c| 10 +-
 drivers/block/swim3.c   | 10 +-
 drivers/block/ublk_drv.c|  4 ++--
 drivers/block/z2ram.c   |  6 ++
 drivers/block/zram/zram_drv.c   | 13 +
 drivers/cdrom/gdrom.c   |  4 ++--
 drivers/md/bcache/super.c   |  4 ++--
 drivers/md/dm.c |  4 ++--
 drivers/md/md.c |  6 +++---
 drivers/mmc/core/block.c|  4 ++--
 drivers/mtd/mtd_blkdevs.c   |  4 ++--
 drivers/mtd/ubi/block.c |  4 ++--
 drivers/nvme/host/core.c|  4 ++--
 drivers/nvme/host/multipath.c   |  4 ++--
 drivers/s390/block/dasd.c   |  4 ++--
 drivers/s390/block/dcssblk.c|  7 +++
 drivers/scsi/sd.c   | 12 ++--
 drivers/scsi/sr.c   |  6 +++---
 include/linux/blkdev.h  |  2 +-
 31 files changed, 102 insertions(+), 107 deletions(-)

diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index f4c1e6e97ad520..6b831f82881bc4 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -108,7 +108,7 @@ static inline void ubd_set_bit(__u64 bit, unsigned char 
*data)
 static DEFINE_MUTEX(ubd_lock);
 static DEFINE_MUTEX(ubd_mutex); /* replaces BKL, might not be needed */
 
-static int ubd_open(struct block_device *bdev, fmode_t mode);
+static int ubd_open(struct gendisk *disk, fmode_t mode);
 static void ubd_release(struct gendisk *disk, fmode_t mode);
 static int ubd_ioctl(struct block_device *bdev, fmode_t mode,
 unsigned int cmd, unsigned long arg);
@@ -1154,9 +1154,8 @@ static int __init ubd_driver_init(void){
 
 device_initcall(ubd_driver_init);
 
-static int ubd_open(struct block_device *bdev, fmode_t mode)
+static int ubd_open(struct gendisk *disk, fmode_t mode)
 {
-   struct gendisk *disk = bdev->bd_disk;
struct ubd *ubd_dev = disk->private_data;
int err = 0;
 
diff --git a/arch/xtensa/platforms/iss/simdisk.c 
b/arch/xtensa/platforms/iss/simdisk.c
index f50caaa1c2496e..38f95f79a1270c 100644
--- a/arch/xtensa/platforms/iss/simdisk.c
+++ b/arch/xtensa/platforms/iss/simdisk.c
@@ -120,9 +120,9 @@ static void simdisk_submit_bio(struct bio *bio)
bio_endio(bio);
 }
 
-static int simdisk_open(struct block_device *bdev, fmode_t mode)
+static int simdisk_open(struct gendisk *disk, fmode_t mode)
 {
-   struct simdisk *dev = bdev->bd_disk->private_data;
+   struct simdisk *dev = disk->private_data;
 
spin_lock(&dev->lock);
++dev->users;
diff --git a/block/bdev.c b/block/bdev.c
index 981f6135795138..8a5fded303d4ed 100644
--- a/block/bdev.c
+++ b/block/bdev.c
@@ -652,7 +652,7 @@ static int blkdev_get_whole(struct block_device *bdev, 
fmode_t mode)
int ret;
 
if (disk->fops->open) {
-   ret = disk->fops->open(bdev, mode);
+   ret = disk->fops->open(disk, mode);
if (ret) {
/* avoid ghost partitions on a removed medium */
if (ret == -ENOMEDIUM &&
diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c
index 6de12b311749a1..0cf2e58294be68 100644
--- a/drivers/block/amiflop.c
+++ b/drivers/block/amiflop.c
@@ -1654,10 +1654,10 @@ static void fd_probe(int dev)
  * /dev/PS0 etc), and disallows simultaneous access to the same
  * drive with different device numbers.
  */
-static int floppy_open(struct block_device *bdev, fmode_t mode)
+static int floppy_open(struct gendisk *disk, fmode_t mode)
 {
-   int drive = MINOR(bdev->bd_dev) & 3;
-   int system =  (MINOR(bdev->bd_dev) & 4) >> 2;
+   int drive = disk->first_minor & 3;
+   int system = (disk->first_minor & 4) >> 2;
int old_dev;
unsigned long flags;
 
@@ -1675,7 +1675,7 @@ static int floppy_open(struct block_device *bdev, fmode_t 
mode)
}
 
if (mode & (FMODE_READ|FMODE_WRITE)) {
-   disk_check_media_change(bde

[f2fs-dev] [PATCH 10/30] block: rename blkdev_close to blkdev_release

2023-06-08 Thread Christoph Hellwig
Make the function name match the method name.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Hannes Reinecke 
Acked-by: Christian Brauner 
---
 block/fops.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/block/fops.c b/block/fops.c
index 6a3087b750a6cd..26af2b39c758e1 100644
--- a/block/fops.c
+++ b/block/fops.c
@@ -500,7 +500,7 @@ static int blkdev_open(struct inode *inode, struct file 
*filp)
return 0;
 }
 
-static int blkdev_close(struct inode *inode, struct file *filp)
+static int blkdev_release(struct inode *inode, struct file *filp)
 {
struct block_device *bdev = filp->private_data;
 
@@ -677,7 +677,7 @@ static long blkdev_fallocate(struct file *file, int mode, 
loff_t start,
 
 const struct file_operations def_blk_fops = {
.open   = blkdev_open,
-   .release= blkdev_close,
+   .release= blkdev_release,
.llseek = blkdev_llseek,
.read_iter  = blkdev_read_iter,
.write_iter = blkdev_write_iter,
-- 
2.39.2



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 07/30] block: pass a gendisk on bdev_check_media_change

2023-06-08 Thread Christoph Hellwig
bdev_check_media_change should only ever be called for the whole device.
Pass a gendisk to make that explicit and rename the function to
disk_check_media_change.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Hannes Reinecke 
Acked-by: Christian Brauner 
---
 block/disk-events.c | 18 +-
 drivers/block/amiflop.c |  2 +-
 drivers/block/ataflop.c |  6 +++---
 drivers/block/floppy.c  | 16 
 drivers/block/swim.c|  2 +-
 drivers/block/swim3.c   |  2 +-
 drivers/cdrom/gdrom.c   |  2 +-
 drivers/md/md.c |  2 +-
 drivers/scsi/sd.c   |  9 -
 drivers/scsi/sr.c   |  2 +-
 include/linux/blkdev.h  |  2 +-
 11 files changed, 31 insertions(+), 32 deletions(-)

diff --git a/block/disk-events.c b/block/disk-events.c
index aee25a7e1ab7de..8b1b63225738f8 100644
--- a/block/disk-events.c
+++ b/block/disk-events.c
@@ -263,31 +263,31 @@ static unsigned int disk_clear_events(struct gendisk 
*disk, unsigned int mask)
 }
 
 /**
- * bdev_check_media_change - check if a removable media has been changed
- * @bdev: block device to check
+ * disk_check_media_change - check if a removable media has been changed
+ * @disk: gendisk to check
  *
  * Check whether a removable media has been changed, and attempt to free all
  * dentries and inodes and invalidates all block device page cache entries in
  * that case.
  *
- * Returns %true if the block device changed, or %false if not.
+ * Returns %true if the media has changed, or %false if not.
  */
-bool bdev_check_media_change(struct block_device *bdev)
+bool disk_check_media_change(struct gendisk *disk)
 {
unsigned int events;
 
-   events = disk_clear_events(bdev->bd_disk, DISK_EVENT_MEDIA_CHANGE |
+   events = disk_clear_events(disk, DISK_EVENT_MEDIA_CHANGE |
   DISK_EVENT_EJECT_REQUEST);
if (!(events & DISK_EVENT_MEDIA_CHANGE))
return false;
 
-   if (__invalidate_device(bdev, true))
+   if (__invalidate_device(disk->part0, true))
pr_warn("VFS: busy inodes on changed media %s\n",
-   bdev->bd_disk->disk_name);
-   set_bit(GD_NEED_PART_SCAN, &bdev->bd_disk->state);
+   disk->disk_name);
+   set_bit(GD_NEED_PART_SCAN, &disk->state);
return true;
 }
-EXPORT_SYMBOL(bdev_check_media_change);
+EXPORT_SYMBOL(disk_check_media_change);
 
 /**
  * disk_force_media_change - force a media change event
diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c
index 4c8b2ba579ee6d..6de12b311749a1 100644
--- a/drivers/block/amiflop.c
+++ b/drivers/block/amiflop.c
@@ -1675,7 +1675,7 @@ static int floppy_open(struct block_device *bdev, fmode_t 
mode)
}
 
if (mode & (FMODE_READ|FMODE_WRITE)) {
-   bdev_check_media_change(bdev);
+   disk_check_media_change(bdev->bd_disk);
if (mode & FMODE_WRITE) {
int wrprot;
 
diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c
index 9deb4df6bdb8b2..da481ddbca90db 100644
--- a/drivers/block/ataflop.c
+++ b/drivers/block/ataflop.c
@@ -1760,8 +1760,8 @@ static int fd_locked_ioctl(struct block_device *bdev, 
fmode_t mode,
/* invalidate the buffer track to force a reread */
BufferDrive = -1;
set_bit(drive, &fake_change);
-   if (bdev_check_media_change(bdev))
-   floppy_revalidate(bdev->bd_disk);
+   if (disk_check_media_change(disk))
+   floppy_revalidate(disk);
return 0;
default:
return -EINVAL;
@@ -1938,7 +1938,7 @@ static int floppy_open(struct block_device *bdev, fmode_t 
mode)
return 0;
 
if (mode & (FMODE_READ|FMODE_WRITE)) {
-   if (bdev_check_media_change(bdev))
+   if (disk_check_media_change(bdev->bd_disk))
floppy_revalidate(bdev->bd_disk);
if (mode & FMODE_WRITE) {
if (p->wpstat) {
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 28ec6b442e9c58..3accafcbc95c85 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -3210,13 +3210,13 @@ static int floppy_raw_cmd_ioctl(int type, int drive, 
int cmd,
 
 #endif
 
-static int invalidate_drive(struct block_device *bdev)
+static int invalidate_drive(struct gendisk *disk)
 {
/* invalidate the buffer track to force a reread */
-   set_bit((long)bdev->bd_disk->private_data, &fake_change);
+   set_bit((long)disk->private_data, &fake_change);
process_fd_request();
-   if (bdev_check_media_change(bdev))
-   floppy_revalidate(bdev->bd_disk);
+   if (disk_check_media_change(disk))
+   floppy_revalidate(disk);
return 0;
 }
 
@@ -3287,7 +3287,7 @@ static int set_geometr

[f2fs-dev] [PATCH 02/30] cdrom: remove the unused bdev argument to cdrom_open

2023-06-08 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig 
Reviewed-by: Phillip Potter 
Reviewed-by: Hannes Reinecke 
Acked-by: Christian Brauner 
---
 drivers/cdrom/cdrom.c | 3 +--
 drivers/cdrom/gdrom.c | 2 +-
 drivers/scsi/sr.c | 2 +-
 include/linux/cdrom.h | 3 +--
 4 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
index 416f723a2dbb33..e3eab319cb0474 100644
--- a/drivers/cdrom/cdrom.c
+++ b/drivers/cdrom/cdrom.c
@@ -1155,8 +1155,7 @@ int open_for_data(struct cdrom_device_info *cdi)
  * is in their own interest: device control becomes a lot easier
  * this way.
  */
-int cdrom_open(struct cdrom_device_info *cdi, struct block_device *bdev,
-  fmode_t mode)
+int cdrom_open(struct cdrom_device_info *cdi, fmode_t mode)
 {
int ret;
 
diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
index ceded5772aac6d..eaa2d5a90bc82f 100644
--- a/drivers/cdrom/gdrom.c
+++ b/drivers/cdrom/gdrom.c
@@ -481,7 +481,7 @@ static int gdrom_bdops_open(struct block_device *bdev, 
fmode_t mode)
bdev_check_media_change(bdev);
 
mutex_lock(&gdrom_mutex);
-   ret = cdrom_open(gd.cd_info, bdev, mode);
+   ret = cdrom_open(gd.cd_info, mode);
mutex_unlock(&gdrom_mutex);
return ret;
 }
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index 12869e6d4ebda8..61b83880e395a4 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -498,7 +498,7 @@ static int sr_block_open(struct block_device *bdev, fmode_t 
mode)
sr_revalidate_disk(cd);
 
mutex_lock(&cd->lock);
-   ret = cdrom_open(&cd->cdi, bdev, mode);
+   ret = cdrom_open(&cd->cdi, mode);
mutex_unlock(&cd->lock);
 
scsi_autopm_put_device(sdev);
diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
index 67caa909e3e615..cc5717cb0fa8a8 100644
--- a/include/linux/cdrom.h
+++ b/include/linux/cdrom.h
@@ -101,8 +101,7 @@ int cdrom_read_tocentry(struct cdrom_device_info *cdi,
struct cdrom_tocentry *entry);
 
 /* the general block_device operations structure: */
-extern int cdrom_open(struct cdrom_device_info *cdi, struct block_device *bdev,
-   fmode_t mode);
+int cdrom_open(struct cdrom_device_info *cdi, fmode_t mode);
 extern void cdrom_release(struct cdrom_device_info *cdi, fmode_t mode);
 extern int cdrom_ioctl(struct cdrom_device_info *cdi, struct block_device 
*bdev,
   fmode_t mode, unsigned int cmd, unsigned long arg);
-- 
2.39.2



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 04/30] cdrom: remove the unused cdrom_close_write release code

2023-06-08 Thread Christoph Hellwig
cdrom_close_write is empty, and the for_data flag it is keyed off is
never set.  Remove all this clutter.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Phillip Potter 
Reviewed-by: Hannes Reinecke 
Acked-by: Christian Brauner 
---
 drivers/cdrom/cdrom.c | 15 ---
 include/linux/cdrom.h |  1 -
 2 files changed, 16 deletions(-)

diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
index 245e5bbb05d41c..08abf1ffede002 100644
--- a/drivers/cdrom/cdrom.c
+++ b/drivers/cdrom/cdrom.c
@@ -978,15 +978,6 @@ static void cdrom_dvd_rw_close_write(struct 
cdrom_device_info *cdi)
cdi->media_written = 0;
 }
 
-static int cdrom_close_write(struct cdrom_device_info *cdi)
-{
-#if 0
-   return cdrom_flush_cache(cdi);
-#else
-   return 0;
-#endif
-}
-
 /* badly broken, I know. Is due for a fixup anytime. */
 static void cdrom_count_tracks(struct cdrom_device_info *cdi, tracktype 
*tracks)
 {
@@ -1282,12 +1273,6 @@ void cdrom_release(struct cdrom_device_info *cdi, 
fmode_t mode)
opened_for_data = !(cdi->options & CDO_USE_FFLAGS) ||
!(mode & FMODE_NDELAY);
 
-   /*
-* flush cache on last write release
-*/
-   if (CDROM_CAN(CDC_RAM) && !cdi->use_count && cdi->for_data)
-   cdrom_close_write(cdi);
-
cdo->release(cdi);
if (cdi->use_count == 0) {  /* last process that closes dev*/
if (opened_for_data &&
diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
index 4aea8c82d16971..0a5db0b0c958a1 100644
--- a/include/linux/cdrom.h
+++ b/include/linux/cdrom.h
@@ -61,7 +61,6 @@ struct cdrom_device_info {
__u8 last_sense;
__u8 media_written; /* dirty flag, DVD+RW bookkeeping */
unsigned short mmc3_profile;/* current MMC3 profile */
-   int for_data;
int (*exit)(struct cdrom_device_info *);
int mrw_mode_page;
__s64 last_media_change_ms;
-- 
2.39.2



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH 01/30] block: also call ->open for incremental partition opens

2023-06-08 Thread Christoph Hellwig
For whole devices ->open is called for each open, but for partitions it
is only called on the first open of a partition, e.g.:

  open("/dev/vdb", ...)
  open("/dev/vdb", ...)
- 2 call to ->open

  open("/dev/vdb1", ...)
  open("/dev/vdb", ...)
- 2 call to ->open

  open("/dev/vdb", ...)
  open("/dev/vdb", ...)
- just open call to ->open

This is problematic as various block drivers look at open flags and
might not do all the required setup if the earlier open was with an
odd flag like O_NDELAY or the magic 3 ioctl-only open mode.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Phillip Potter 
Reviewed-by: Hannes Reinecke 
Acked-by: Christian Brauner 
---
 block/bdev.c | 18 --
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/block/bdev.c b/block/bdev.c
index 5c46ff10770638..981f6135795138 100644
--- a/block/bdev.c
+++ b/block/bdev.c
@@ -683,9 +683,6 @@ static int blkdev_get_part(struct block_device *part, 
fmode_t mode)
struct gendisk *disk = part->bd_disk;
int ret;
 
-   if (atomic_read(&part->bd_openers))
-   goto done;
-
ret = blkdev_get_whole(bdev_whole(part), mode);
if (ret)
return ret;
@@ -694,9 +691,10 @@ static int blkdev_get_part(struct block_device *part, 
fmode_t mode)
if (!bdev_nr_sectors(part))
goto out_blkdev_put;
 
-   disk->open_partitions++;
-   set_init_blocksize(part);
-done:
+   if (!atomic_read(&part->bd_openers)) {
+   disk->open_partitions++;
+   set_init_blocksize(part);
+   }
atomic_inc(&part->bd_openers);
return 0;
 
@@ -709,10 +707,10 @@ static void blkdev_put_part(struct block_device *part, 
fmode_t mode)
 {
struct block_device *whole = bdev_whole(part);
 
-   if (!atomic_dec_and_test(&part->bd_openers))
-   return;
-   blkdev_flush_mapping(part);
-   whole->bd_disk->open_partitions--;
+   if (atomic_dec_and_test(&part->bd_openers)) {
+   blkdev_flush_mapping(part);
+   whole->bd_disk->open_partitions--;
+   }
blkdev_put_whole(whole, mode);
 }
 
-- 
2.39.2



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH 06/31] cdrom: remove the unused mode argument to cdrom_release

2023-06-08 Thread Christoph Hellwig
On Thu, Jun 08, 2023 at 09:47:27AM +0100, Phillip Potter wrote:
> Yes indeed - I was under the impression it was appropriate for a
> maintainer to signal their approval of a patch to maintained code using
> a Signed-off-by tag due to their involvement in the submission process?
> Apologies if I've got this wrong, happy to send Reviewed-bys by all
> means.

Signed-off-by is for the chain that the patches pass through.  You add
it when you apply or forward the patch.  Just give me a Reviewed-by
tag and say it shold apply to patches 1 to 6 and I'll add it.


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH 06/31] cdrom: remove the unused mode argument to cdrom_release

2023-06-08 Thread Christoph Hellwig
On Wed, Jun 07, 2023 at 12:00:57AM +0100, Phillip Potter wrote:
> Looks good, thanks.
> 
> Signed-off-by: Phillip Potter 

Hmm, these signoffs don't really make sense here.  Were they intended
as Reviewed-bys?



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH 08/31] block: share code between disk_check_media_change and disk_force_media_change

2023-06-07 Thread Christoph Hellwig
On Wed, Jun 07, 2023 at 02:19:00PM +0200, Hannes Reinecke wrote:
>> -return true;
>> +return __disk_check_media_change(disk,
>> +disk_clear_events(disk, DISK_EVENT_MEDIA_CHANGE |
>> +DISK_EVENT_EJECT_REQUEST));
>
> Can you move the call to disk_clear_events() out of the call to 
> __disk_check_media_change()?
> I find this pattern hard to read.

I suspect you've not done enough functional programming in your youth :)


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH 05/31] cdrom: track if a cdrom_device_info was opened for data

2023-06-07 Thread Christoph Hellwig
On Wed, Jun 07, 2023 at 02:13:33PM +0200, Hannes Reinecke wrote:
>> +++ b/include/linux/cdrom.h
>> @@ -64,6 +64,7 @@ struct cdrom_device_info {
>>  int (*exit)(struct cdrom_device_info *);
>>  int mrw_mode_page;
>>  __s64 last_media_change_ms;
>> +bool opened_for_data;
>>   };
>> struct cdrom_device_ops {
>
> Do we care about alignment here?
> integer followed by a 64 bit value followed by a bool seems
> like an automatic padding to me ...

I don't think the structure matter much here, but placing it before
last_media_change_ms still seems better.  I'll change it.



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH 30/31] block: store the holder in file->private_data

2023-06-07 Thread Christoph Hellwig
On Wed, Jun 07, 2023 at 11:24:55AM +0200, Christian Brauner wrote:
> On Tue, Jun 06, 2023 at 09:39:49AM +0200, Christoph Hellwig wrote:
> > Store the file struct used as the holder in file->private_data as an
> > indicator that this file descriptor was opened exclusively to  remove
> > the last use of FMODE_EXCL.
> > 
> > Signed-off-by: Christoph Hellwig 
> > ---
> 
> Feels a bit odd to store the object itself but anyway,
> Acked-by: Christian Brauner 

We could literally store anything we want.  The only reason I picked the
file is because: a) we have it around and b) that allows passing it
to blkdev_put without a branch in blkdev_release.

If you prefer something else I can change it.


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


  1   2   3   4   5   6   7   8   >