aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Monakhov <dmonakhov@openvz.org>2009-12-14 07:21:14 -0500
committerJan Kara <jack@suse.cz>2009-12-23 07:33:55 -0500
commita9e7f4472075fb6937c545af3f6329e9946bbe66 (patch)
tree399e294982e1c9691332eca72942910a7f74e9f8
parentfd8fbfc1709822bd94247c5b2ab15a5f5041e103 (diff)
ext4: Convert to generic reserved quota's space management.
This patch also fixes write vs chown race condition. Acked-by: "Theodore Ts'o" <tytso@mit.edu> Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org> Signed-off-by: Jan Kara <jack@suse.cz>
-rw-r--r--fs/ext4/ext4.h6
-rw-r--r--fs/ext4/inode.c16
-rw-r--r--fs/ext4/super.c5
3 files changed, 17 insertions, 10 deletions
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index ab31e65d46d0..56f9271ee8cc 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -704,6 +704,10 @@ struct ext4_inode_info {
704 __u16 i_extra_isize; 704 __u16 i_extra_isize;
705 705
706 spinlock_t i_block_reservation_lock; 706 spinlock_t i_block_reservation_lock;
707#ifdef CONFIG_QUOTA
708 /* quota space reservation, managed internally by quota code */
709 qsize_t i_reserved_quota;
710#endif
707 711
708 /* completed async DIOs that might need unwritten extents handling */ 712 /* completed async DIOs that might need unwritten extents handling */
709 struct list_head i_aio_dio_complete_list; 713 struct list_head i_aio_dio_complete_list;
@@ -1435,7 +1439,7 @@ extern int ext4_chunk_trans_blocks(struct inode *, int nrblocks);
1435extern int ext4_block_truncate_page(handle_t *handle, 1439extern int ext4_block_truncate_page(handle_t *handle,
1436 struct address_space *mapping, loff_t from); 1440 struct address_space *mapping, loff_t from);
1437extern int ext4_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf); 1441extern int ext4_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf);
1438extern qsize_t ext4_get_reserved_space(struct inode *inode); 1442extern qsize_t *ext4_get_reserved_space(struct inode *inode);
1439extern int flush_aio_dio_completed_IO(struct inode *inode); 1443extern int flush_aio_dio_completed_IO(struct inode *inode);
1440/* ioctl.c */ 1444/* ioctl.c */
1441extern long ext4_ioctl(struct file *, unsigned int, unsigned long); 1445extern long ext4_ioctl(struct file *, unsigned int, unsigned long);
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 5352db1a3086..a31980dd9b86 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1003,17 +1003,12 @@ out:
1003 return err; 1003 return err;
1004} 1004}
1005 1005
1006qsize_t ext4_get_reserved_space(struct inode *inode) 1006#ifdef CONFIG_QUOTA
1007qsize_t *ext4_get_reserved_space(struct inode *inode)
1007{ 1008{
1008 unsigned long long total; 1009 return &EXT4_I(inode)->i_reserved_quota;
1009
1010 spin_lock(&EXT4_I(inode)->i_block_reservation_lock);
1011 total = EXT4_I(inode)->i_reserved_data_blocks +
1012 EXT4_I(inode)->i_reserved_meta_blocks;
1013 spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
1014
1015 return (total << inode->i_blkbits);
1016} 1010}
1011#endif
1017/* 1012/*
1018 * Calculate the number of metadata blocks need to reserve 1013 * Calculate the number of metadata blocks need to reserve
1019 * to allocate @blocks for non extent file based file 1014 * to allocate @blocks for non extent file based file
@@ -4794,6 +4789,9 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
4794 ((__u64)le16_to_cpu(raw_inode->i_file_acl_high)) << 32; 4789 ((__u64)le16_to_cpu(raw_inode->i_file_acl_high)) << 32;
4795 inode->i_size = ext4_isize(raw_inode); 4790 inode->i_size = ext4_isize(raw_inode);
4796 ei->i_disksize = inode->i_size; 4791 ei->i_disksize = inode->i_size;
4792#ifdef CONFIG_QUOTA
4793 ei->i_reserved_quota = 0;
4794#endif
4797 inode->i_generation = le32_to_cpu(raw_inode->i_generation); 4795 inode->i_generation = le32_to_cpu(raw_inode->i_generation);
4798 ei->i_block_group = iloc.block_group; 4796 ei->i_block_group = iloc.block_group;
4799 ei->i_last_alloc_group = ~0; 4797 ei->i_last_alloc_group = ~0;
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 827bde1f2594..6ed9aa91f27d 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -704,6 +704,9 @@ static struct inode *ext4_alloc_inode(struct super_block *sb)
704 ei->i_allocated_meta_blocks = 0; 704 ei->i_allocated_meta_blocks = 0;
705 ei->i_delalloc_reserved_flag = 0; 705 ei->i_delalloc_reserved_flag = 0;
706 spin_lock_init(&(ei->i_block_reservation_lock)); 706 spin_lock_init(&(ei->i_block_reservation_lock));
707#ifdef CONFIG_QUOTA
708 ei->i_reserved_quota = 0;
709#endif
707 INIT_LIST_HEAD(&ei->i_aio_dio_complete_list); 710 INIT_LIST_HEAD(&ei->i_aio_dio_complete_list);
708 ei->cur_aio_dio = NULL; 711 ei->cur_aio_dio = NULL;
709 ei->i_sync_tid = 0; 712 ei->i_sync_tid = 0;
@@ -1014,7 +1017,9 @@ static const struct dquot_operations ext4_quota_operations = {
1014 .reserve_space = dquot_reserve_space, 1017 .reserve_space = dquot_reserve_space,
1015 .claim_space = dquot_claim_space, 1018 .claim_space = dquot_claim_space,
1016 .release_rsv = dquot_release_reserved_space, 1019 .release_rsv = dquot_release_reserved_space,
1020#ifdef CONFIG_QUOTA
1017 .get_reserved_space = ext4_get_reserved_space, 1021 .get_reserved_space = ext4_get_reserved_space,
1022#endif
1018 .alloc_inode = dquot_alloc_inode, 1023 .alloc_inode = dquot_alloc_inode,
1019 .free_space = dquot_free_space, 1024 .free_space = dquot_free_space,
1020 .free_inode = dquot_free_inode, 1025 .free_inode = dquot_free_inode,