Merge android12-5.10 into android12-5.10-lts
This merges the android12-5.10 branch into the -lts branch, catching it up with the latest changes in there. It contains the following commits: *29bf3aa759Merge tag 'android12-5.10.239_r00' into android12-5.10 *f0ab6d6cf3UPSTREAM: f2fs: compress: fix error path of inc_valid_block_count() *449b3695f7BACKPORT: f2fs: compress: fix to avoid inconsistence bewteen i_blocks and dnode *a40d88b654UPSTREAM: posix-cpu-timers: fix race between handle_posix_cpu_timers() and posix_cpu_timer_del() Change-Id: Ic8dc4e3e5197ef28e7e5fe6780aa98ae604d7c4b Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
@@ -1117,7 +1117,8 @@ int f2fs_reserve_new_blocks(struct dnode_of_data *dn, blkcnt_t count)
|
||||
|
||||
if (unlikely(is_inode_flag_set(dn->inode, FI_NO_ALLOC)))
|
||||
return -EPERM;
|
||||
if (unlikely((err = inc_valid_block_count(sbi, dn->inode, &count))))
|
||||
err = inc_valid_block_count(sbi, dn->inode, &count, true);
|
||||
if (unlikely(err))
|
||||
return err;
|
||||
|
||||
trace_f2fs_reserve_new_blocks(dn->inode, dn->nid,
|
||||
@@ -1384,7 +1385,7 @@ static int __allocate_data_block(struct dnode_of_data *dn, int seg_type)
|
||||
if (dn->data_blkaddr != NULL_ADDR)
|
||||
goto alloc;
|
||||
|
||||
if (unlikely((err = inc_valid_block_count(sbi, dn->inode, &count))))
|
||||
if (unlikely((err = inc_valid_block_count(sbi, dn->inode, &count, true))))
|
||||
return err;
|
||||
|
||||
alloc:
|
||||
|
||||
@@ -2293,9 +2293,9 @@ static inline unsigned int get_available_block_count(struct f2fs_sb_info *sbi,
|
||||
|
||||
static inline void f2fs_i_blocks_write(struct inode *, block_t, bool, bool);
|
||||
static inline int inc_valid_block_count(struct f2fs_sb_info *sbi,
|
||||
struct inode *inode, blkcnt_t *count)
|
||||
struct inode *inode, blkcnt_t *count, bool partial)
|
||||
{
|
||||
blkcnt_t diff = 0, release = 0;
|
||||
long long diff = 0, release = 0;
|
||||
block_t avail_user_block_count;
|
||||
int ret;
|
||||
|
||||
@@ -2316,21 +2316,27 @@ static inline int inc_valid_block_count(struct f2fs_sb_info *sbi,
|
||||
percpu_counter_add(&sbi->alloc_valid_block_count, (*count));
|
||||
|
||||
spin_lock(&sbi->stat_lock);
|
||||
sbi->total_valid_block_count += (block_t)(*count);
|
||||
avail_user_block_count = get_available_block_count(sbi, inode, true);
|
||||
|
||||
if (unlikely(sbi->total_valid_block_count > avail_user_block_count)) {
|
||||
diff = sbi->total_valid_block_count - avail_user_block_count;
|
||||
avail_user_block_count = get_available_block_count(sbi, inode, true);
|
||||
diff = (long long)sbi->total_valid_block_count + *count -
|
||||
avail_user_block_count;
|
||||
if (unlikely(diff > 0)) {
|
||||
if (!partial) {
|
||||
spin_unlock(&sbi->stat_lock);
|
||||
release = *count;
|
||||
goto enospc;
|
||||
}
|
||||
if (diff > *count)
|
||||
diff = *count;
|
||||
*count -= diff;
|
||||
release = diff;
|
||||
sbi->total_valid_block_count -= diff;
|
||||
if (!*count) {
|
||||
spin_unlock(&sbi->stat_lock);
|
||||
goto enospc;
|
||||
}
|
||||
}
|
||||
sbi->total_valid_block_count += (block_t)(*count);
|
||||
|
||||
spin_unlock(&sbi->stat_lock);
|
||||
|
||||
if (unlikely(release)) {
|
||||
|
||||
@@ -3713,14 +3713,16 @@ static int reserve_compress_blocks(struct dnode_of_data *dn, pgoff_t count)
|
||||
blkcnt_t to_reserved;
|
||||
int ret;
|
||||
|
||||
for (i = 0; i < cluster_size; i++, dn->ofs_in_node++) {
|
||||
blkaddr = f2fs_data_blkaddr(dn);
|
||||
for (i = 0; i < cluster_size; i++) {
|
||||
blkaddr = data_blkaddr(dn->inode, dn->node_page,
|
||||
dn->ofs_in_node + i);
|
||||
|
||||
if (i == 0) {
|
||||
if (blkaddr == COMPRESS_ADDR)
|
||||
continue;
|
||||
dn->ofs_in_node += cluster_size;
|
||||
goto next;
|
||||
if (blkaddr != COMPRESS_ADDR) {
|
||||
dn->ofs_in_node += cluster_size;
|
||||
goto next;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3736,9 +3738,6 @@ static int reserve_compress_blocks(struct dnode_of_data *dn, pgoff_t count)
|
||||
compr_blocks++;
|
||||
continue;
|
||||
}
|
||||
|
||||
dn->data_blkaddr = NEW_ADDR;
|
||||
f2fs_set_data_blkaddr(dn);
|
||||
}
|
||||
|
||||
to_reserved = cluster_size - compr_blocks - reserved;
|
||||
@@ -3749,12 +3748,16 @@ static int reserve_compress_blocks(struct dnode_of_data *dn, pgoff_t count)
|
||||
goto next;
|
||||
}
|
||||
|
||||
ret = inc_valid_block_count(sbi, dn->inode, &to_reserved);
|
||||
if (ret)
|
||||
ret = inc_valid_block_count(sbi, dn->inode, &to_reserved, false);
|
||||
if (unlikely(ret))
|
||||
return ret;
|
||||
|
||||
if (reserved != cluster_size - compr_blocks)
|
||||
return -ENOSPC;
|
||||
for (i = 0; i < cluster_size; i++, dn->ofs_in_node++) {
|
||||
if (f2fs_data_blkaddr(dn) == NULL_ADDR) {
|
||||
dn->data_blkaddr = NEW_ADDR;
|
||||
f2fs_set_data_blkaddr(dn);
|
||||
}
|
||||
}
|
||||
|
||||
f2fs_i_compr_blocks_update(dn->inode, compr_blocks, true);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user