file.c (025b3602b5fa216fb87bbfa4bff8bb378fe589a0) file.c (9bf1dcbdfdc8892d9cfeaeab02519c0ecf17fe51)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * fs/f2fs/file.c
4 *
5 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
6 * http://www.samsung.com/
7 */
8#include <linux/fs.h>

--- 1714 unchanged lines hidden (view full) ---

1723 block_t sec_blks = CAP_BLKS_PER_SEC(sbi);
1724 block_t sec_len = roundup(map.m_len, sec_blks);
1725
1726 map.m_len = sec_blks;
1727next_alloc:
1728 if (has_not_enough_free_secs(sbi, 0,
1729 GET_SEC_FROM_SEG(sbi, overprovision_segments(sbi)))) {
1730 f2fs_down_write(&sbi->gc_lock);
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * fs/f2fs/file.c
4 *
5 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
6 * http://www.samsung.com/
7 */
8#include <linux/fs.h>

--- 1714 unchanged lines hidden (view full) ---

1723 block_t sec_blks = CAP_BLKS_PER_SEC(sbi);
1724 block_t sec_len = roundup(map.m_len, sec_blks);
1725
1726 map.m_len = sec_blks;
1727next_alloc:
1728 if (has_not_enough_free_secs(sbi, 0,
1729 GET_SEC_FROM_SEG(sbi, overprovision_segments(sbi)))) {
1730 f2fs_down_write(&sbi->gc_lock);
1731 stat_inc_gc_call_count(sbi, FOREGROUND);
1731 err = f2fs_gc(sbi, &gc_control);
1732 if (err && err != -ENODATA)
1733 goto out_err;
1734 }
1735
1736 f2fs_down_write(&sbi->pin_sem);
1737
1738 f2fs_lock_op(sbi);

--- 732 unchanged lines hidden (view full) ---

2471 goto out;
2472 }
2473 } else {
2474 f2fs_down_write(&sbi->gc_lock);
2475 }
2476
2477 gc_control.init_gc_type = sync ? FG_GC : BG_GC;
2478 gc_control.err_gc_skipped = sync;
1732 err = f2fs_gc(sbi, &gc_control);
1733 if (err && err != -ENODATA)
1734 goto out_err;
1735 }
1736
1737 f2fs_down_write(&sbi->pin_sem);
1738
1739 f2fs_lock_op(sbi);

--- 732 unchanged lines hidden (view full) ---

2472 goto out;
2473 }
2474 } else {
2475 f2fs_down_write(&sbi->gc_lock);
2476 }
2477
2478 gc_control.init_gc_type = sync ? FG_GC : BG_GC;
2479 gc_control.err_gc_skipped = sync;
2480 stat_inc_gc_call_count(sbi, FOREGROUND);
2479 ret = f2fs_gc(sbi, &gc_control);
2480out:
2481 mnt_drop_write_file(filp);
2482 return ret;
2483}
2484
2485static int __f2fs_ioc_gc_range(struct file *filp, struct f2fs_gc_range *range)
2486{

--- 27 unchanged lines hidden (view full) ---

2514 ret = -EBUSY;
2515 goto out;
2516 }
2517 } else {
2518 f2fs_down_write(&sbi->gc_lock);
2519 }
2520
2521 gc_control.victim_segno = GET_SEGNO(sbi, range->start);
2481 ret = f2fs_gc(sbi, &gc_control);
2482out:
2483 mnt_drop_write_file(filp);
2484 return ret;
2485}
2486
2487static int __f2fs_ioc_gc_range(struct file *filp, struct f2fs_gc_range *range)
2488{

--- 27 unchanged lines hidden (view full) ---

2516 ret = -EBUSY;
2517 goto out;
2518 }
2519 } else {
2520 f2fs_down_write(&sbi->gc_lock);
2521 }
2522
2523 gc_control.victim_segno = GET_SEGNO(sbi, range->start);
2524 stat_inc_gc_call_count(sbi, FOREGROUND);
2522 ret = f2fs_gc(sbi, &gc_control);
2523 if (ret) {
2524 if (ret == -EBUSY)
2525 ret = -EAGAIN;
2526 goto out;
2527 }
2528 range->start += CAP_BLKS_PER_SEC(sbi);
2529 if (range->start <= end)

--- 466 unchanged lines hidden (view full) ---

2996 ret = -EBUSY;
2997 goto out;
2998 }
2999 sm->last_victim[GC_CB] = end_segno + 1;
3000 sm->last_victim[GC_GREEDY] = end_segno + 1;
3001 sm->last_victim[ALLOC_NEXT] = end_segno + 1;
3002
3003 gc_control.victim_segno = start_segno;
2525 ret = f2fs_gc(sbi, &gc_control);
2526 if (ret) {
2527 if (ret == -EBUSY)
2528 ret = -EAGAIN;
2529 goto out;
2530 }
2531 range->start += CAP_BLKS_PER_SEC(sbi);
2532 if (range->start <= end)

--- 466 unchanged lines hidden (view full) ---

2999 ret = -EBUSY;
3000 goto out;
3001 }
3002 sm->last_victim[GC_CB] = end_segno + 1;
3003 sm->last_victim[GC_GREEDY] = end_segno + 1;
3004 sm->last_victim[ALLOC_NEXT] = end_segno + 1;
3005
3006 gc_control.victim_segno = start_segno;
3007 stat_inc_gc_call_count(sbi, FOREGROUND);
3004 ret = f2fs_gc(sbi, &gc_control);
3005 if (ret == -EAGAIN)
3006 ret = 0;
3007 else if (ret < 0)
3008 break;
3009 start_segno++;
3010 }
3011out:

--- 1978 unchanged lines hidden ---
3008 ret = f2fs_gc(sbi, &gc_control);
3009 if (ret == -EAGAIN)
3010 ret = 0;
3011 else if (ret < 0)
3012 break;
3013 start_segno++;
3014 }
3015out:

--- 1978 unchanged lines hidden ---