From: Simon Glass <simon.glass@canonical.com>
Extend linux/quotaops.h with additional quota stubs needed by ext4l:
- dquot_alloc_block_nofail, dquot_alloc_block, dquot_free_block
- dquot_claim_block, dquot_reclaim_block, dquot_reserve_block
- dquot_release_reservation_block, dquot_initialize_needed
- dquot_alloc_space_nodirty, dquot_free_space_nodirty
- is_quota_modification, dquot_writeback_dquots
- sb_any_quota_suspended
The block allocation macros update inode->i_blocks to track allocated
blocks without actual quota enforcement.
Update ext4_uboot.h to use linux/quotaops.h and remove the function
implementations from stub.c since they are now macros.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---
fs/ext4l/ext4_uboot.h | 35 +++++--------------------
fs/ext4l/stub.c | 30 +--------------------
include/linux/quotaops.h | 56 +++++++++++++++++++++++++++++++++-------
3 files changed, 54 insertions(+), 67 deletions(-)
@@ -239,13 +239,8 @@ struct buffer_head *sb_getblk(struct super_block *sb, sector_t block);
/* Group permission - stub */
#define in_group_p(gid) (0)
-/* Quota operations - stubs */
-#define dquot_alloc_block_nofail(inode, nr) \
- ({ (inode)->i_blocks += (nr) << ((inode)->i_blkbits - 9); 0; })
-#define dquot_initialize(inode) ({ (void)(inode); 0; })
-#define dquot_free_inode(inode) do { (void)(inode); } while (0)
-#define dquot_alloc_inode(inode) ({ (void)(inode); 0; })
-#define dquot_drop(inode) do { (void)(inode); } while (0)
+/* Quota operations - use linux/quotaops.h */
+#include <linux/quotaops.h>
/* icount - inode reference count */
#define icount_read(inode) (1)
@@ -818,8 +813,7 @@ static inline unsigned long memweight(const void *ptr, size_t bytes)
/* in_range - use linux/minmax.h */
#include <linux/minmax.h>
-/* Quota stub */
-#define dquot_reclaim_block(i, n) do { } while (0)
+/* dquot_reclaim_block is in linux/quotaops.h */
/* fiemap stubs are now in linux/fiemap.h */
@@ -923,8 +917,7 @@ void mapping_clear_folio_cache(struct address_space *mapping);
/* fsverity_file_open is in linux/fsverity.h */
#include <linux/fsverity.h>
-/* Quota file open - stub */
-#define dquot_file_open(i, f) ({ (void)(i); (void)(f); 0; })
+/* dquot_file_open is in linux/quotaops.h */
/* Inode I/O list management */
#define inode_io_list_del(inode) do { } while (0)
@@ -934,13 +927,7 @@ void mapping_clear_folio_cache(struct address_space *mapping);
/* Folio operations and writeback stubs are in linux/pagemap.h */
#define folio_batch_release(fb) do { } while (0)
-/* Quota stubs - additional */
-#define dquot_claim_block(i, n) ({ (void)(i); (void)(n); 0; })
-#define dquot_reserve_block(i, n) ({ (void)(i); (void)(n); 0; })
-#define dquot_release_reservation_block(i, n) do { } while (0)
-#define dquot_initialize_needed(i) (0)
-#define dquot_transfer(m, i, a) ({ (void)(m); (void)(i); (void)(a); 0; })
-#define is_quota_modification(m, i, a) ({ (void)(m); (void)(i); (void)(a); 0; })
+/* Quota stubs are in linux/quotaops.h */
/* percpu_counter_sub is in linux/percpu_counter.h */
@@ -1455,12 +1442,7 @@ void *bdev_file_open_by_dev(dev_t dev, int flags, void *holder,
/* Filesystem sync - declaration for stub.c */
int sync_filesystem(void *sb);
-/* Quota - declarations for stub.c */
-#define dquot_suspend(sb, type) ({ (void)(sb); (void)(type); 0; })
-int dquot_alloc_space_nodirty(struct inode *inode, loff_t size);
-void dquot_free_space_nodirty(struct inode *inode, loff_t size);
-int dquot_alloc_block(struct inode *inode, loff_t nr);
-void dquot_free_block(struct inode *inode, loff_t nr);
+/* Quota operations are in linux/quotaops.h */
/* Block device file operations - stubs */
#define set_blocksize(f, size) ({ (void)(f); (void)(size); 0; })
@@ -1468,10 +1450,7 @@ struct buffer_head *__bread(struct block_device *bdev, sector_t block, unsigned
/* flush_workqueue is now in linux/workqueue.h */
-/* Quota stubs for super.c */
-#define dquot_writeback_dquots(sb, type) do { (void)(sb); (void)(type); } while (0)
-#define dquot_resume(sb, type) do { (void)(sb); (void)(type); } while (0)
-#define sb_any_quota_suspended(sb) ({ (void)(sb); 0; })
+/* Quota stubs for super.c are in linux/quotaops.h */
/*
* Stubs for mballoc.c
@@ -620,35 +620,7 @@ long ext4_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
/* nop_mnt_idmap - no-op mount ID map for xattr.c */
struct mnt_idmap nop_mnt_idmap;
-/* Quota stubs for xattr.c */
-int dquot_alloc_space_nodirty(struct inode *inode, loff_t size)
-{
- return 0;
-}
-
-void dquot_free_space_nodirty(struct inode *inode, loff_t size)
-{
-}
-
-int dquot_alloc_block(struct inode *inode, loff_t nr)
-{
- /*
- * Update i_blocks to reflect the allocated blocks.
- * i_blocks is in 512-byte units, so convert from fs blocks.
- */
- inode->i_blocks += nr << (inode->i_blkbits - 9);
-
- return 0;
-}
-
-void dquot_free_block(struct inode *inode, loff_t nr)
-{
- /*
- * Update i_blocks to reflect the freed blocks.
- * i_blocks is in 512-byte units, so convert from fs blocks.
- */
- inode->i_blocks -= nr << (inode->i_blkbits - 9);
-}
+/* Quota stubs are now macros in linux/quotaops.h */
/*
* JBD2 stubs - temporary stubs until other jbd2 files are added
@@ -6,27 +6,62 @@
* Author: Marco van Wieringen <mvw@planets.elm.net>
*
* Stub definitions for quota operations.
- * U-Boot doesn't support disk quotas.
+ * U-Boot does not support disk quotas.
*/
#ifndef _LINUX_QUOTAOPS_H
#define _LINUX_QUOTAOPS_H
+#include <linux/types.h>
+
struct inode;
struct dentry;
struct kqid;
+struct mnt_idmap;
+struct iattr;
+struct super_block;
+
+/* Quota initialisation and cleanup */
+#define dquot_initialize(inode) ({ (void)(inode); 0; })
+#define dquot_initialize_needed(inode) (0)
+#define dquot_drop(inode) do { (void)(inode); } while (0)
+
+/* Inode quota operations */
+#define dquot_alloc_inode(inode) ({ (void)(inode); 0; })
+#define dquot_free_inode(inode) do { (void)(inode); } while (0)
-#define dquot_initialize(inode) 0
-#define dquot_drop(inode) do { } while (0)
-#define dquot_alloc_inode(inode) 0
-#define dquot_free_inode(inode) do { } while (0)
-#define dquot_transfer(inode, attr) 0
+/* Block quota operations */
+#define dquot_alloc_block(inode, nr) \
+ ({ (inode)->i_blocks += (nr) << ((inode)->i_blkbits - 9); 0; })
+#define dquot_alloc_block_nofail(inode, nr) \
+ ({ (inode)->i_blocks += (nr) << ((inode)->i_blkbits - 9); 0; })
+#define dquot_free_block(inode, nr) \
+ do { (inode)->i_blocks -= (nr) << ((inode)->i_blkbits - 9); } while (0)
+#define dquot_claim_block(inode, nr) ({ (void)(inode); (void)(nr); 0; })
+#define dquot_reclaim_block(inode, nr) do { } while (0)
+#define dquot_reserve_block(inode, nr) ({ (void)(inode); (void)(nr); 0; })
+#define dquot_release_reservation_block(inode, nr) \
+ do { (void)(inode); (void)(nr); } while (0)
+
+/* Space quota operations */
+#define dquot_alloc_space_nodirty(inode, size) ({ (void)(inode); (void)(size); 0; })
+#define dquot_free_space_nodirty(inode, size) do { (void)(inode); (void)(size); } while (0)
#define dquot_claim_space_nodirty(inode, nr) 0
#define dquot_reclaim_space_nodirty(inode, nr) do { } while (0)
-#define dquot_disable(sb, type, flags) 0
-#define dquot_suspend(sb, type) 0
-#define dquot_resume(sb, type) 0
-#define dquot_file_open(inode, file) 0
+/* Transfer and modification checks */
+#define dquot_transfer(idmap, inode, attr) \
+ ({ (void)(idmap); (void)(inode); (void)(attr); 0; })
+#define is_quota_modification(idmap, inode, attr) \
+ ({ (void)(idmap); (void)(inode); (void)(attr); 0; })
+
+/* Quota control */
+#define dquot_disable(sb, type, flags) 0
+#define dquot_suspend(sb, type) ({ (void)(sb); (void)(type); 0; })
+#define dquot_resume(sb, type) do { (void)(sb); (void)(type); } while (0)
+#define dquot_writeback_dquots(sb, type) do { (void)(sb); (void)(type); } while (0)
+#define dquot_file_open(inode, file) ({ (void)(inode); (void)(file); 0; })
+
+/* Quota status queries */
#define sb_has_quota_usage_enabled(sb, type) 0
#define sb_has_quota_limits_enabled(sb, type) 0
#define sb_has_quota_suspended(sb, type) 0
@@ -34,5 +69,6 @@ struct kqid;
#define sb_has_quota_active(sb, type) 0
#define sb_any_quota_loaded(sb) 0
#define sb_any_quota_active(sb) 0
+#define sb_any_quota_suspended(sb) ({ (void)(sb); 0; })
#endif /* _LINUX_QUOTAOPS_H */