f2fs.h (b8a742a8bd6dbc40894cd78fb34d99aabe4a1f81) | f2fs.h (81c975902b15701260f8f26b25235b50f043fb35) |
---|---|
1/* SPDX-License-Identifier: GPL-2.0 */ 2/* 3 * fs/f2fs/f2fs.h 4 * 5 * Copyright (c) 2012 Samsung Electronics Co., Ltd. 6 * http://www.samsung.com/ 7 */ 8#ifndef _LINUX_F2FS_H --- 2282 unchanged lines hidden (view full) --- 2291 2292 return avail_user_block_count; 2293} 2294 2295static inline void f2fs_i_blocks_write(struct inode *, block_t, bool, bool); 2296static inline int inc_valid_block_count(struct f2fs_sb_info *sbi, 2297 struct inode *inode, blkcnt_t *count, bool partial) 2298{ | 1/* SPDX-License-Identifier: GPL-2.0 */ 2/* 3 * fs/f2fs/f2fs.h 4 * 5 * Copyright (c) 2012 Samsung Electronics Co., Ltd. 6 * http://www.samsung.com/ 7 */ 8#ifndef _LINUX_F2FS_H --- 2282 unchanged lines hidden (view full) --- 2291 2292 return avail_user_block_count; 2293} 2294 2295static inline void f2fs_i_blocks_write(struct inode *, block_t, bool, bool); 2296static inline int inc_valid_block_count(struct f2fs_sb_info *sbi, 2297 struct inode *inode, blkcnt_t *count, bool partial) 2298{ |
2299 blkcnt_t diff = 0, release = 0; | 2299 long long diff = 0, release = 0; |
2300 block_t avail_user_block_count; 2301 int ret; 2302 2303 ret = dquot_reserve_block(inode, *count); 2304 if (ret) 2305 return ret; 2306 2307 if (time_to_inject(sbi, FAULT_BLOCK)) { 2308 release = *count; 2309 goto release_quota; 2310 } 2311 2312 /* 2313 * let's increase this in prior to actual block count change in order 2314 * for f2fs_sync_file to avoid data races when deciding checkpoint. 2315 */ 2316 percpu_counter_add(&sbi->alloc_valid_block_count, (*count)); 2317 2318 spin_lock(&sbi->stat_lock); | 2300 block_t avail_user_block_count; 2301 int ret; 2302 2303 ret = dquot_reserve_block(inode, *count); 2304 if (ret) 2305 return ret; 2306 2307 if (time_to_inject(sbi, FAULT_BLOCK)) { 2308 release = *count; 2309 goto release_quota; 2310 } 2311 2312 /* 2313 * let's increase this in prior to actual block count change in order 2314 * for f2fs_sync_file to avoid data races when deciding checkpoint. 2315 */ 2316 percpu_counter_add(&sbi->alloc_valid_block_count, (*count)); 2317 2318 spin_lock(&sbi->stat_lock); |
2319 sbi->total_valid_block_count += (block_t)(*count); 2320 avail_user_block_count = get_available_block_count(sbi, inode, true); | |
2321 | 2319 |
2322 if (unlikely(sbi->total_valid_block_count > avail_user_block_count)) { | 2320 avail_user_block_count = get_available_block_count(sbi, inode, true); 2321 diff = (long long)sbi->total_valid_block_count + *count - 2322 avail_user_block_count; 2323 if (unlikely(diff > 0)) { |
2323 if (!partial) { 2324 spin_unlock(&sbi->stat_lock); | 2324 if (!partial) { 2325 spin_unlock(&sbi->stat_lock); |
2326 release = *count; |
|
2325 goto enospc; 2326 } | 2327 goto enospc; 2328 } |
2327 2328 diff = sbi->total_valid_block_count - avail_user_block_count; | |
2329 if (diff > *count) 2330 diff = *count; 2331 *count -= diff; 2332 release = diff; | 2329 if (diff > *count) 2330 diff = *count; 2331 *count -= diff; 2332 release = diff; |
2333 sbi->total_valid_block_count -= diff; | |
2334 if (!*count) { 2335 spin_unlock(&sbi->stat_lock); 2336 goto enospc; 2337 } 2338 } | 2333 if (!*count) { 2334 spin_unlock(&sbi->stat_lock); 2335 goto enospc; 2336 } 2337 } |
2338 sbi->total_valid_block_count += (block_t)(*count); 2339 |
|
2339 spin_unlock(&sbi->stat_lock); 2340 2341 if (unlikely(release)) { 2342 percpu_counter_sub(&sbi->alloc_valid_block_count, release); 2343 dquot_release_reservation_block(inode, release); 2344 } 2345 f2fs_i_blocks_write(inode, *count, true, true); 2346 return 0; --- 2335 unchanged lines hidden --- | 2340 spin_unlock(&sbi->stat_lock); 2341 2342 if (unlikely(release)) { 2343 percpu_counter_sub(&sbi->alloc_valid_block_count, release); 2344 dquot_release_reservation_block(inode, release); 2345 } 2346 f2fs_i_blocks_write(inode, *count, true, true); 2347 return 0; --- 2335 unchanged lines hidden --- |