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>
This commit is contained in:
parent
fd8fbfc170
commit
a9e7f44720
|
@ -704,6 +704,10 @@ struct ext4_inode_info {
|
||||||
__u16 i_extra_isize;
|
__u16 i_extra_isize;
|
||||||
|
|
||||||
spinlock_t i_block_reservation_lock;
|
spinlock_t i_block_reservation_lock;
|
||||||
|
#ifdef CONFIG_QUOTA
|
||||||
|
/* quota space reservation, managed internally by quota code */
|
||||||
|
qsize_t i_reserved_quota;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* completed async DIOs that might need unwritten extents handling */
|
/* completed async DIOs that might need unwritten extents handling */
|
||||||
struct list_head i_aio_dio_complete_list;
|
struct list_head i_aio_dio_complete_list;
|
||||||
|
@ -1435,7 +1439,7 @@ extern int ext4_chunk_trans_blocks(struct inode *, int nrblocks);
|
||||||
extern int ext4_block_truncate_page(handle_t *handle,
|
extern int ext4_block_truncate_page(handle_t *handle,
|
||||||
struct address_space *mapping, loff_t from);
|
struct address_space *mapping, loff_t from);
|
||||||
extern int ext4_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf);
|
extern int ext4_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf);
|
||||||
extern qsize_t ext4_get_reserved_space(struct inode *inode);
|
extern qsize_t *ext4_get_reserved_space(struct inode *inode);
|
||||||
extern int flush_aio_dio_completed_IO(struct inode *inode);
|
extern int flush_aio_dio_completed_IO(struct inode *inode);
|
||||||
/* ioctl.c */
|
/* ioctl.c */
|
||||||
extern long ext4_ioctl(struct file *, unsigned int, unsigned long);
|
extern long ext4_ioctl(struct file *, unsigned int, unsigned long);
|
||||||
|
|
|
@ -1003,17 +1003,12 @@ out:
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
qsize_t ext4_get_reserved_space(struct inode *inode)
|
#ifdef CONFIG_QUOTA
|
||||||
|
qsize_t *ext4_get_reserved_space(struct inode *inode)
|
||||||
{
|
{
|
||||||
unsigned long long total;
|
return &EXT4_I(inode)->i_reserved_quota;
|
||||||
|
|
||||||
spin_lock(&EXT4_I(inode)->i_block_reservation_lock);
|
|
||||||
total = EXT4_I(inode)->i_reserved_data_blocks +
|
|
||||||
EXT4_I(inode)->i_reserved_meta_blocks;
|
|
||||||
spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
|
|
||||||
|
|
||||||
return (total << inode->i_blkbits);
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
/*
|
/*
|
||||||
* Calculate the number of metadata blocks need to reserve
|
* Calculate the number of metadata blocks need to reserve
|
||||||
* to allocate @blocks for non extent file based file
|
* to allocate @blocks for non extent file based file
|
||||||
|
@ -4794,6 +4789,9 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
|
||||||
((__u64)le16_to_cpu(raw_inode->i_file_acl_high)) << 32;
|
((__u64)le16_to_cpu(raw_inode->i_file_acl_high)) << 32;
|
||||||
inode->i_size = ext4_isize(raw_inode);
|
inode->i_size = ext4_isize(raw_inode);
|
||||||
ei->i_disksize = inode->i_size;
|
ei->i_disksize = inode->i_size;
|
||||||
|
#ifdef CONFIG_QUOTA
|
||||||
|
ei->i_reserved_quota = 0;
|
||||||
|
#endif
|
||||||
inode->i_generation = le32_to_cpu(raw_inode->i_generation);
|
inode->i_generation = le32_to_cpu(raw_inode->i_generation);
|
||||||
ei->i_block_group = iloc.block_group;
|
ei->i_block_group = iloc.block_group;
|
||||||
ei->i_last_alloc_group = ~0;
|
ei->i_last_alloc_group = ~0;
|
||||||
|
|
|
@ -704,6 +704,9 @@ static struct inode *ext4_alloc_inode(struct super_block *sb)
|
||||||
ei->i_allocated_meta_blocks = 0;
|
ei->i_allocated_meta_blocks = 0;
|
||||||
ei->i_delalloc_reserved_flag = 0;
|
ei->i_delalloc_reserved_flag = 0;
|
||||||
spin_lock_init(&(ei->i_block_reservation_lock));
|
spin_lock_init(&(ei->i_block_reservation_lock));
|
||||||
|
#ifdef CONFIG_QUOTA
|
||||||
|
ei->i_reserved_quota = 0;
|
||||||
|
#endif
|
||||||
INIT_LIST_HEAD(&ei->i_aio_dio_complete_list);
|
INIT_LIST_HEAD(&ei->i_aio_dio_complete_list);
|
||||||
ei->cur_aio_dio = NULL;
|
ei->cur_aio_dio = NULL;
|
||||||
ei->i_sync_tid = 0;
|
ei->i_sync_tid = 0;
|
||||||
|
@ -1014,7 +1017,9 @@ static const struct dquot_operations ext4_quota_operations = {
|
||||||
.reserve_space = dquot_reserve_space,
|
.reserve_space = dquot_reserve_space,
|
||||||
.claim_space = dquot_claim_space,
|
.claim_space = dquot_claim_space,
|
||||||
.release_rsv = dquot_release_reserved_space,
|
.release_rsv = dquot_release_reserved_space,
|
||||||
|
#ifdef CONFIG_QUOTA
|
||||||
.get_reserved_space = ext4_get_reserved_space,
|
.get_reserved_space = ext4_get_reserved_space,
|
||||||
|
#endif
|
||||||
.alloc_inode = dquot_alloc_inode,
|
.alloc_inode = dquot_alloc_inode,
|
||||||
.free_space = dquot_free_space,
|
.free_space = dquot_free_space,
|
||||||
.free_inode = dquot_free_inode,
|
.free_inode = dquot_free_inode,
|
||||||
|
|
Loading…
Reference in a new issue