extent-tree.c (24af7dd1881f9f5c13c7d82e22d7858137383766) extent-tree.c (6c255e67cec1c38a0569c7f823eba63f9449ccf8)
1/*
2 * Copyright (C) 2007 Oracle. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License v2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,

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

3966 avail >>= 1;
3967
3968 if (used + bytes < space_info->total_bytes + avail)
3969 return 1;
3970 return 0;
3971}
3972
3973static void btrfs_writeback_inodes_sb_nr(struct btrfs_root *root,
1/*
2 * Copyright (C) 2007 Oracle. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License v2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,

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

3966 avail >>= 1;
3967
3968 if (used + bytes < space_info->total_bytes + avail)
3969 return 1;
3970 return 0;
3971}
3972
3973static void btrfs_writeback_inodes_sb_nr(struct btrfs_root *root,
3974 unsigned long nr_pages)
3974 unsigned long nr_pages, int nr_items)
3975{
3976 struct super_block *sb = root->fs_info->sb;
3977
3978 if (down_read_trylock(&sb->s_umount)) {
3979 writeback_inodes_sb_nr(sb, nr_pages, WB_REASON_FS_FREE_SPACE);
3980 up_read(&sb->s_umount);
3981 } else {
3982 /*
3983 * We needn't worry the filesystem going from r/w to r/o though
3984 * we don't acquire ->s_umount mutex, because the filesystem
3985 * should guarantee the delalloc inodes list be empty after
3986 * the filesystem is readonly(all dirty pages are written to
3987 * the disk).
3988 */
3975{
3976 struct super_block *sb = root->fs_info->sb;
3977
3978 if (down_read_trylock(&sb->s_umount)) {
3979 writeback_inodes_sb_nr(sb, nr_pages, WB_REASON_FS_FREE_SPACE);
3980 up_read(&sb->s_umount);
3981 } else {
3982 /*
3983 * We needn't worry the filesystem going from r/w to r/o though
3984 * we don't acquire ->s_umount mutex, because the filesystem
3985 * should guarantee the delalloc inodes list be empty after
3986 * the filesystem is readonly(all dirty pages are written to
3987 * the disk).
3988 */
3989 btrfs_start_delalloc_roots(root->fs_info, 0);
3989 btrfs_start_delalloc_roots(root->fs_info, 0, nr_items);
3990 if (!current->journal_info)
3990 if (!current->journal_info)
3991 btrfs_wait_ordered_roots(root->fs_info, -1);
3991 btrfs_wait_ordered_roots(root->fs_info, nr_items);
3992 }
3993}
3994
3995static inline int calc_reclaim_items_nr(struct btrfs_root *root, u64 to_reclaim)
3996{
3997 u64 bytes;
3998 int nr;
3999

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

4040 btrfs_wait_ordered_roots(root->fs_info, items);
4041 return;
4042 }
4043
4044 loops = 0;
4045 while (delalloc_bytes && loops < 3) {
4046 max_reclaim = min(delalloc_bytes, to_reclaim);
4047 nr_pages = max_reclaim >> PAGE_CACHE_SHIFT;
3992 }
3993}
3994
3995static inline int calc_reclaim_items_nr(struct btrfs_root *root, u64 to_reclaim)
3996{
3997 u64 bytes;
3998 int nr;
3999

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

4040 btrfs_wait_ordered_roots(root->fs_info, items);
4041 return;
4042 }
4043
4044 loops = 0;
4045 while (delalloc_bytes && loops < 3) {
4046 max_reclaim = min(delalloc_bytes, to_reclaim);
4047 nr_pages = max_reclaim >> PAGE_CACHE_SHIFT;
4048 btrfs_writeback_inodes_sb_nr(root, nr_pages);
4048 btrfs_writeback_inodes_sb_nr(root, nr_pages, items);
4049 /*
4050 * We need to wait for the async pages to actually start before
4051 * we do anything.
4052 */
4053 max_reclaim = atomic_read(&root->fs_info->async_delalloc_pages);
4054 if (!max_reclaim)
4055 goto skip_async;
4056

--- 4912 unchanged lines hidden ---
4049 /*
4050 * We need to wait for the async pages to actually start before
4051 * we do anything.
4052 */
4053 max_reclaim = atomic_read(&root->fs_info->async_delalloc_pages);
4054 if (!max_reclaim)
4055 goto skip_async;
4056

--- 4912 unchanged lines hidden ---