From 56246f9ae4cfa95b460f9dfbcfb1b772d85db046 Mon Sep 17 00:00:00 2001 From: Eric Sandeen Date: Sun, 16 May 2010 09:00:00 -0400 Subject: quota: use flags interface for dquot alloc/free space Switch __dquot_alloc_space and __dquot_free_space to take flags to indicate whether to warn and/or to reserve (or free reserve). This is slightly more readable at the callpoints, and makes it cleaner to add a "nofail" option in the next patch. Signed-off-by: Eric Sandeen Signed-off-by: "Theodore Ts'o" --- include/linux/quotaops.h | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'include') diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h index e6fa7ac..9edd53c 100644 --- a/include/linux/quotaops.h +++ b/include/linux/quotaops.h @@ -9,6 +9,9 @@ #include +#define DQUOT_SPACE_WARN 0x1 +#define DQUOT_SPACE_RESERVE 0x2 + static inline struct quota_info *sb_dqopt(struct super_block *sb) { return &sb->s_dquot; @@ -33,9 +36,8 @@ int dquot_scan_active(struct super_block *sb, struct dquot *dquot_alloc(struct super_block *sb, int type); void dquot_destroy(struct dquot *dquot); -int __dquot_alloc_space(struct inode *inode, qsize_t number, - int warn, int reserve); -void __dquot_free_space(struct inode *inode, qsize_t number, int reserve); +int __dquot_alloc_space(struct inode *inode, qsize_t number, int flags); +void __dquot_free_space(struct inode *inode, qsize_t number, int flags); int dquot_alloc_inode(const struct inode *inode); @@ -231,17 +233,17 @@ static inline int dquot_transfer(struct inode *inode, struct iattr *iattr) } static inline int __dquot_alloc_space(struct inode *inode, qsize_t number, - int warn, int reserve) + int flags) { - if (!reserve) + if (!(flags & DQUOT_SPACE_RESERVE)) inode_add_bytes(inode, number); return 0; } static inline void __dquot_free_space(struct inode *inode, qsize_t number, - int reserve) + int flags) { - if (!reserve) + if (!(flags & DQUOT_SPACE_RESERVE)) inode_sub_bytes(inode, number); } @@ -257,7 +259,7 @@ static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number) static inline int dquot_alloc_space_nodirty(struct inode *inode, qsize_t nr) { - return __dquot_alloc_space(inode, nr, 1, 0); + return __dquot_alloc_space(inode, nr, DQUOT_SPACE_WARN); } static inline int dquot_alloc_space(struct inode *inode, qsize_t nr) @@ -282,7 +284,7 @@ static inline int dquot_alloc_block(struct inode *inode, qsize_t nr) static inline int dquot_prealloc_block_nodirty(struct inode *inode, qsize_t nr) { - return __dquot_alloc_space(inode, nr << inode->i_blkbits, 0, 0); + return __dquot_alloc_space(inode, nr << inode->i_blkbits, 0); } static inline int dquot_prealloc_block(struct inode *inode, qsize_t nr) @@ -297,7 +299,8 @@ static inline int dquot_prealloc_block(struct inode *inode, qsize_t nr) static inline int dquot_reserve_block(struct inode *inode, qsize_t nr) { - return __dquot_alloc_space(inode, nr << inode->i_blkbits, 1, 1); + return __dquot_alloc_space(inode, nr << inode->i_blkbits, + DQUOT_SPACE_WARN|DQUOT_SPACE_RESERVE); } static inline int dquot_claim_block(struct inode *inode, qsize_t nr) @@ -334,7 +337,7 @@ static inline void dquot_free_block(struct inode *inode, qsize_t nr) static inline void dquot_release_reservation_block(struct inode *inode, qsize_t nr) { - __dquot_free_space(inode, nr << inode->i_blkbits, 1); + __dquot_free_space(inode, nr << inode->i_blkbits, DQUOT_SPACE_RESERVE); } #endif /* _LINUX_QUOTAOPS_ */ -- cgit v1.1 From 0e05842bc117ea70ceb979cca798fd026879951b Mon Sep 17 00:00:00 2001 From: Eric Sandeen Date: Sun, 16 May 2010 10:00:00 -0400 Subject: quota: add the option to not fail with EDQUOT in block To simplify metadata tracking for delalloc writes, ext4 will simply claim metadata blocks at allocation time, without first speculatively reserving the worst case and then freeing what was not used. To do this, we need a mechanism to track allocations in the quota subsystem, but potentially allow that allocation to actually go over quota. This patch adds a DQUOT_SPACE_NOFAIL flag and function variants for this purpose. Signed-off-by: Eric Sandeen Signed-off-by: "Theodore Ts'o" --- include/linux/quotaops.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include') diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h index 9edd53c..f8dbeb0 100644 --- a/include/linux/quotaops.h +++ b/include/linux/quotaops.h @@ -11,6 +11,7 @@ #define DQUOT_SPACE_WARN 0x1 #define DQUOT_SPACE_RESERVE 0x2 +#define DQUOT_SPACE_NOFAIL 0x4 static inline struct quota_info *sb_dqopt(struct super_block *sb) { @@ -262,6 +263,12 @@ static inline int dquot_alloc_space_nodirty(struct inode *inode, qsize_t nr) return __dquot_alloc_space(inode, nr, DQUOT_SPACE_WARN); } +static inline void dquot_alloc_space_nofail(struct inode *inode, qsize_t nr) +{ + __dquot_alloc_space(inode, nr, DQUOT_SPACE_WARN|DQUOT_SPACE_NOFAIL); + mark_inode_dirty(inode); +} + static inline int dquot_alloc_space(struct inode *inode, qsize_t nr) { int ret; @@ -277,6 +284,11 @@ static inline int dquot_alloc_block_nodirty(struct inode *inode, qsize_t nr) return dquot_alloc_space_nodirty(inode, nr << inode->i_blkbits); } +static inline void dquot_alloc_block_nofail(struct inode *inode, qsize_t nr) +{ + dquot_alloc_space_nofail(inode, nr << inode->i_blkbits); +} + static inline int dquot_alloc_block(struct inode *inode, qsize_t nr) { return dquot_alloc_space(inode, nr << inode->i_blkbits); -- cgit v1.1 From f307333e14f6b18045eb4198fe646d9b6028f3ed Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 17 May 2010 03:00:00 -0400 Subject: ext4: Add new tracepoints to track mballoc's buddy bitmap loads Signed-off-by: "Theodore Ts'o" --- include/trace/events/ext4.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'include') diff --git a/include/trace/events/ext4.h b/include/trace/events/ext4.h index 2aa6aa3..99fbf1d 100644 --- a/include/trace/events/ext4.h +++ b/include/trace/events/ext4.h @@ -974,6 +974,39 @@ TRACE_EVENT(ext4_da_release_space, __entry->reserved_meta_blocks, __entry->allocated_meta_blocks) ); +DECLARE_EVENT_CLASS(ext4__bitmap_load, + TP_PROTO(struct super_block *sb, unsigned long group), + + TP_ARGS(sb, group), + + TP_STRUCT__entry( + __field( dev_t, dev ) + __field( __u32, group ) + + ), + + TP_fast_assign( + __entry->dev = sb->s_dev; + __entry->group = group; + ), + + TP_printk("dev %s group %u", + jbd2_dev_to_name(__entry->dev), __entry->group) +); + +DEFINE_EVENT(ext4__bitmap_load, ext4_mb_bitmap_load, + + TP_PROTO(struct super_block *sb, unsigned long group), + + TP_ARGS(sb, group) +); + +DEFINE_EVENT(ext4__bitmap_load, ext4_mb_buddy_bitmap_load, + + TP_PROTO(struct super_block *sb, unsigned long group), + + TP_ARGS(sb, group) +); #endif /* _TRACE_EXT4_H */ -- cgit v1.1 From f084db932e6fe877bf8362bc256fc850de196deb Mon Sep 17 00:00:00 2001 From: Li Zefan Date: Mon, 17 May 2010 04:00:00 -0400 Subject: tracing: Convert more ext4 events to DEFINE_EVENT Use DECLARE_EVENT_CLASS, and save ~2.7K: text data bss dec hex filename 274441 7200 260 281901 44d2d fs/ext4/ext4.o.orig 271881 7040 256 279177 44289 fs/ext4/ext4.o 4 events are converted: ext4__mb_new_pa: ext4_mb_new_inode_pa, ext4_mb_new_group_pa ext4__mballoc: ext4_mballoc_discard, ext4_mballoc_free No change in functionality. Signed-off-by: Li Zefan Signed-off-by: "Theodore Ts'o" --- include/trace/events/ext4.h | 61 +++++++++++++-------------------------------- 1 file changed, 17 insertions(+), 44 deletions(-) (limited to 'include') diff --git a/include/trace/events/ext4.h b/include/trace/events/ext4.h index 99fbf1d..5d60ad4 100644 --- a/include/trace/events/ext4.h +++ b/include/trace/events/ext4.h @@ -353,7 +353,7 @@ TRACE_EVENT(ext4_discard_blocks, jbd2_dev_to_name(__entry->dev), __entry->blk, __entry->count) ); -TRACE_EVENT(ext4_mb_new_inode_pa, +DECLARE_EVENT_CLASS(ext4__mb_new_pa, TP_PROTO(struct ext4_allocation_context *ac, struct ext4_prealloc_space *pa), @@ -381,32 +381,20 @@ TRACE_EVENT(ext4_mb_new_inode_pa, __entry->pa_pstart, __entry->pa_len, __entry->pa_lstart) ); -TRACE_EVENT(ext4_mb_new_group_pa, +DEFINE_EVENT(ext4__mb_new_pa, ext4_mb_new_inode_pa, + TP_PROTO(struct ext4_allocation_context *ac, struct ext4_prealloc_space *pa), - TP_ARGS(ac, pa), - - TP_STRUCT__entry( - __field( dev_t, dev ) - __field( ino_t, ino ) - __field( __u64, pa_pstart ) - __field( __u32, pa_len ) - __field( __u64, pa_lstart ) + TP_ARGS(ac, pa) +); - ), +DEFINE_EVENT(ext4__mb_new_pa, ext4_mb_new_group_pa, - TP_fast_assign( - __entry->dev = ac->ac_sb->s_dev; - __entry->ino = ac->ac_inode->i_ino; - __entry->pa_pstart = pa->pa_pstart; - __entry->pa_len = pa->pa_len; - __entry->pa_lstart = pa->pa_lstart; - ), + TP_PROTO(struct ext4_allocation_context *ac, + struct ext4_prealloc_space *pa), - TP_printk("dev %s ino %lu pstart %llu len %u lstart %llu", - jbd2_dev_to_name(__entry->dev), (unsigned long) __entry->ino, - __entry->pa_pstart, __entry->pa_len, __entry->pa_lstart) + TP_ARGS(ac, pa) ); TRACE_EVENT(ext4_mb_release_inode_pa, @@ -790,7 +778,7 @@ TRACE_EVENT(ext4_mballoc_prealloc, __entry->result_len, __entry->result_logical) ); -TRACE_EVENT(ext4_mballoc_discard, +DECLARE_EVENT_CLASS(ext4__mballoc, TP_PROTO(struct ext4_allocation_context *ac), TP_ARGS(ac), @@ -819,33 +807,18 @@ TRACE_EVENT(ext4_mballoc_discard, __entry->result_len, __entry->result_logical) ); -TRACE_EVENT(ext4_mballoc_free, +DEFINE_EVENT(ext4__mballoc, ext4_mballoc_discard, + TP_PROTO(struct ext4_allocation_context *ac), - TP_ARGS(ac), + TP_ARGS(ac) +); - TP_STRUCT__entry( - __field( dev_t, dev ) - __field( ino_t, ino ) - __field( __u32, result_logical ) - __field( int, result_start ) - __field( __u32, result_group ) - __field( int, result_len ) - ), +DEFINE_EVENT(ext4__mballoc, ext4_mballoc_free, - TP_fast_assign( - __entry->dev = ac->ac_inode->i_sb->s_dev; - __entry->ino = ac->ac_inode->i_ino; - __entry->result_logical = ac->ac_b_ex.fe_logical; - __entry->result_start = ac->ac_b_ex.fe_start; - __entry->result_group = ac->ac_b_ex.fe_group; - __entry->result_len = ac->ac_b_ex.fe_len; - ), + TP_PROTO(struct ext4_allocation_context *ac), - TP_printk("dev %s inode %lu extent %u/%d/%u@%u ", - jbd2_dev_to_name(__entry->dev), (unsigned long) __entry->ino, - __entry->result_group, __entry->result_start, - __entry->result_len, __entry->result_logical) + TP_ARGS(ac) ); TRACE_EVENT(ext4_forget, -- cgit v1.1