Re: [PATCH 07/27] quota: port to const mnt_idmap
From: Jan Kara
Date: Wed Sep 02 2026 - 10:48:30 EST
On Tue 01-09-26 14:14:32, Christian Brauner wrote:
> Convert to const struct mnt_idmap.
>
> A mount's idmapping is immutable. The only thing that is allowed to be
> modified afterwards is the reference count and that is hidden behind
> mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
> from the idmapping. This is the same model that struct cred uses and the
> idmapping is also rather sensitive.
>
> So make the idmap argument const wherever we can. The conversion is done
> from the bottom up so callers can continue to pass a non-const pointer
> to a const parameter until the conversion is finished.
>
> No functional changes.
>
> Signed-off-by: Christian Brauner (Amutable) <brauner@xxxxxxxxxx>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@xxxxxxx>
Honza
> ---
> fs/quota/dquot.c | 2 +-
> include/linux/quotaops.h | 6 +++---
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
> index 204afc5e984b..c5e9c4e24d68 100644
> --- a/fs/quota/dquot.c
> +++ b/fs/quota/dquot.c
> @@ -2079,7 +2079,7 @@ EXPORT_SYMBOL(__dquot_transfer);
> /* Wrapper for transferring ownership of an inode for uid/gid only
> * Called from FSXXX_setattr()
> */
> -int dquot_transfer(struct mnt_idmap *idmap, struct inode *inode,
> +int dquot_transfer(const struct mnt_idmap *idmap, struct inode *inode,
> struct iattr *iattr)
> {
> struct dquot *transfer_to[MAXQUOTAS] = {};
> diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h
> index f9c0f9d7c9d9..0c64ca674e77 100644
> --- a/include/linux/quotaops.h
> +++ b/include/linux/quotaops.h
> @@ -20,7 +20,7 @@ static inline struct quota_info *sb_dqopt(struct super_block *sb)
> }
>
> /* i_rwsem must being held */
> -static inline bool is_quota_modification(struct mnt_idmap *idmap,
> +static inline bool is_quota_modification(const struct mnt_idmap *idmap,
> struct inode *inode, struct iattr *ia)
> {
> return ((ia->ia_valid & ATTR_SIZE) ||
> @@ -109,7 +109,7 @@ int dquot_set_dqblk(struct super_block *sb, struct kqid id,
> struct qc_dqblk *di);
>
> int __dquot_transfer(struct inode *inode, struct dquot **transfer_to);
> -int dquot_transfer(struct mnt_idmap *idmap, struct inode *inode,
> +int dquot_transfer(const struct mnt_idmap *idmap, struct inode *inode,
> struct iattr *iattr);
>
> static inline struct mem_dqinfo *sb_dqinfo(struct super_block *sb, int type)
> @@ -229,7 +229,7 @@ static inline void dquot_free_inode(struct inode *inode)
> {
> }
>
> -static inline int dquot_transfer(struct mnt_idmap *idmap,
> +static inline int dquot_transfer(const struct mnt_idmap *idmap,
> struct inode *inode, struct iattr *iattr)
> {
> return 0;
>
> --
> 2.53.0
>
--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR