mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	btrfs: send: use GFP_KERNEL everywhere
The send operation is not on the critical writeback path we don't need to use GFP_NOFS for allocations. All error paths are handled and the whole operation is restartable. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
		
							parent
							
								
									388f7b1d6e
								
							
						
					
					
						commit
						e780b0d1c1
					
				
					 2 changed files with 19 additions and 19 deletions
				
			
		| 
						 | 
					@ -5361,7 +5361,7 @@ int btrfs_compare_trees(struct btrfs_root *left_root,
 | 
				
			||||||
		goto out;
 | 
							goto out;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tmp_buf = kmalloc(left_root->nodesize, GFP_NOFS);
 | 
						tmp_buf = kmalloc(left_root->nodesize, GFP_KERNEL);
 | 
				
			||||||
	if (!tmp_buf) {
 | 
						if (!tmp_buf) {
 | 
				
			||||||
		ret = -ENOMEM;
 | 
							ret = -ENOMEM;
 | 
				
			||||||
		goto out;
 | 
							goto out;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -304,7 +304,7 @@ static struct fs_path *fs_path_alloc(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct fs_path *p;
 | 
						struct fs_path *p;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	p = kmalloc(sizeof(*p), GFP_NOFS);
 | 
						p = kmalloc(sizeof(*p), GFP_KERNEL);
 | 
				
			||||||
	if (!p)
 | 
						if (!p)
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
	p->reversed = 0;
 | 
						p->reversed = 0;
 | 
				
			||||||
| 
						 | 
					@ -363,11 +363,11 @@ static int fs_path_ensure_buf(struct fs_path *p, int len)
 | 
				
			||||||
	 * First time the inline_buf does not suffice
 | 
						 * First time the inline_buf does not suffice
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	if (p->buf == p->inline_buf) {
 | 
						if (p->buf == p->inline_buf) {
 | 
				
			||||||
		tmp_buf = kmalloc(len, GFP_NOFS);
 | 
							tmp_buf = kmalloc(len, GFP_KERNEL);
 | 
				
			||||||
		if (tmp_buf)
 | 
							if (tmp_buf)
 | 
				
			||||||
			memcpy(tmp_buf, p->buf, old_buf_len);
 | 
								memcpy(tmp_buf, p->buf, old_buf_len);
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		tmp_buf = krealloc(p->buf, len, GFP_NOFS);
 | 
							tmp_buf = krealloc(p->buf, len, GFP_KERNEL);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (!tmp_buf)
 | 
						if (!tmp_buf)
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
| 
						 | 
					@ -995,7 +995,7 @@ static int iterate_dir_item(struct btrfs_root *root, struct btrfs_path *path,
 | 
				
			||||||
	 * values are small.
 | 
						 * values are small.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	buf_len = PATH_MAX;
 | 
						buf_len = PATH_MAX;
 | 
				
			||||||
	buf = kmalloc(buf_len, GFP_NOFS);
 | 
						buf = kmalloc(buf_len, GFP_KERNEL);
 | 
				
			||||||
	if (!buf) {
 | 
						if (!buf) {
 | 
				
			||||||
		ret = -ENOMEM;
 | 
							ret = -ENOMEM;
 | 
				
			||||||
		goto out;
 | 
							goto out;
 | 
				
			||||||
| 
						 | 
					@ -1042,7 +1042,7 @@ static int iterate_dir_item(struct btrfs_root *root, struct btrfs_path *path,
 | 
				
			||||||
				buf = NULL;
 | 
									buf = NULL;
 | 
				
			||||||
			} else {
 | 
								} else {
 | 
				
			||||||
				char *tmp = krealloc(buf, buf_len,
 | 
									char *tmp = krealloc(buf, buf_len,
 | 
				
			||||||
						     GFP_NOFS | __GFP_NOWARN);
 | 
											GFP_KERNEL | __GFP_NOWARN);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				if (!tmp)
 | 
									if (!tmp)
 | 
				
			||||||
					kfree(buf);
 | 
										kfree(buf);
 | 
				
			||||||
| 
						 | 
					@ -1303,7 +1303,7 @@ static int find_extent_clone(struct send_ctx *sctx,
 | 
				
			||||||
	/* We only use this path under the commit sem */
 | 
						/* We only use this path under the commit sem */
 | 
				
			||||||
	tmp_path->need_commit_sem = 0;
 | 
						tmp_path->need_commit_sem = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	backref_ctx = kmalloc(sizeof(*backref_ctx), GFP_NOFS);
 | 
						backref_ctx = kmalloc(sizeof(*backref_ctx), GFP_KERNEL);
 | 
				
			||||||
	if (!backref_ctx) {
 | 
						if (!backref_ctx) {
 | 
				
			||||||
		ret = -ENOMEM;
 | 
							ret = -ENOMEM;
 | 
				
			||||||
		goto out;
 | 
							goto out;
 | 
				
			||||||
| 
						 | 
					@ -1984,7 +1984,7 @@ static int name_cache_insert(struct send_ctx *sctx,
 | 
				
			||||||
	nce_head = radix_tree_lookup(&sctx->name_cache,
 | 
						nce_head = radix_tree_lookup(&sctx->name_cache,
 | 
				
			||||||
			(unsigned long)nce->ino);
 | 
								(unsigned long)nce->ino);
 | 
				
			||||||
	if (!nce_head) {
 | 
						if (!nce_head) {
 | 
				
			||||||
		nce_head = kmalloc(sizeof(*nce_head), GFP_NOFS);
 | 
							nce_head = kmalloc(sizeof(*nce_head), GFP_KERNEL);
 | 
				
			||||||
		if (!nce_head) {
 | 
							if (!nce_head) {
 | 
				
			||||||
			kfree(nce);
 | 
								kfree(nce);
 | 
				
			||||||
			return -ENOMEM;
 | 
								return -ENOMEM;
 | 
				
			||||||
| 
						 | 
					@ -2179,7 +2179,7 @@ static int __get_cur_name_and_parent(struct send_ctx *sctx,
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * Store the result of the lookup in the name cache.
 | 
						 * Store the result of the lookup in the name cache.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	nce = kmalloc(sizeof(*nce) + fs_path_len(dest) + 1, GFP_NOFS);
 | 
						nce = kmalloc(sizeof(*nce) + fs_path_len(dest) + 1, GFP_KERNEL);
 | 
				
			||||||
	if (!nce) {
 | 
						if (!nce) {
 | 
				
			||||||
		ret = -ENOMEM;
 | 
							ret = -ENOMEM;
 | 
				
			||||||
		goto out;
 | 
							goto out;
 | 
				
			||||||
| 
						 | 
					@ -2315,7 +2315,7 @@ static int send_subvol_begin(struct send_ctx *sctx)
 | 
				
			||||||
	if (!path)
 | 
						if (!path)
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	name = kmalloc(BTRFS_PATH_NAME_MAX, GFP_NOFS);
 | 
						name = kmalloc(BTRFS_PATH_NAME_MAX, GFP_KERNEL);
 | 
				
			||||||
	if (!name) {
 | 
						if (!name) {
 | 
				
			||||||
		btrfs_free_path(path);
 | 
							btrfs_free_path(path);
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
| 
						 | 
					@ -2730,7 +2730,7 @@ static int __record_ref(struct list_head *head, u64 dir,
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct recorded_ref *ref;
 | 
						struct recorded_ref *ref;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ref = kmalloc(sizeof(*ref), GFP_NOFS);
 | 
						ref = kmalloc(sizeof(*ref), GFP_KERNEL);
 | 
				
			||||||
	if (!ref)
 | 
						if (!ref)
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2755,7 +2755,7 @@ static int dup_ref(struct recorded_ref *ref, struct list_head *list)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct recorded_ref *new;
 | 
						struct recorded_ref *new;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	new = kmalloc(sizeof(*ref), GFP_NOFS);
 | 
						new = kmalloc(sizeof(*ref), GFP_KERNEL);
 | 
				
			||||||
	if (!new)
 | 
						if (!new)
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2818,7 +2818,7 @@ add_orphan_dir_info(struct send_ctx *sctx, u64 dir_ino)
 | 
				
			||||||
	struct rb_node *parent = NULL;
 | 
						struct rb_node *parent = NULL;
 | 
				
			||||||
	struct orphan_dir_info *entry, *odi;
 | 
						struct orphan_dir_info *entry, *odi;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	odi = kmalloc(sizeof(*odi), GFP_NOFS);
 | 
						odi = kmalloc(sizeof(*odi), GFP_KERNEL);
 | 
				
			||||||
	if (!odi)
 | 
						if (!odi)
 | 
				
			||||||
		return ERR_PTR(-ENOMEM);
 | 
							return ERR_PTR(-ENOMEM);
 | 
				
			||||||
	odi->ino = dir_ino;
 | 
						odi->ino = dir_ino;
 | 
				
			||||||
| 
						 | 
					@ -2973,7 +2973,7 @@ static int add_waiting_dir_move(struct send_ctx *sctx, u64 ino, bool orphanized)
 | 
				
			||||||
	struct rb_node *parent = NULL;
 | 
						struct rb_node *parent = NULL;
 | 
				
			||||||
	struct waiting_dir_move *entry, *dm;
 | 
						struct waiting_dir_move *entry, *dm;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	dm = kmalloc(sizeof(*dm), GFP_NOFS);
 | 
						dm = kmalloc(sizeof(*dm), GFP_KERNEL);
 | 
				
			||||||
	if (!dm)
 | 
						if (!dm)
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
	dm->ino = ino;
 | 
						dm->ino = ino;
 | 
				
			||||||
| 
						 | 
					@ -3040,7 +3040,7 @@ static int add_pending_dir_move(struct send_ctx *sctx,
 | 
				
			||||||
	int exists = 0;
 | 
						int exists = 0;
 | 
				
			||||||
	int ret;
 | 
						int ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pm = kmalloc(sizeof(*pm), GFP_NOFS);
 | 
						pm = kmalloc(sizeof(*pm), GFP_KERNEL);
 | 
				
			||||||
	if (!pm)
 | 
						if (!pm)
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
	pm->parent_ino = parent_ino;
 | 
						pm->parent_ino = parent_ino;
 | 
				
			||||||
| 
						 | 
					@ -4280,7 +4280,7 @@ static int __find_xattr(int num, struct btrfs_key *di_key,
 | 
				
			||||||
	    strncmp(name, ctx->name, name_len) == 0) {
 | 
						    strncmp(name, ctx->name, name_len) == 0) {
 | 
				
			||||||
		ctx->found_idx = num;
 | 
							ctx->found_idx = num;
 | 
				
			||||||
		ctx->found_data_len = data_len;
 | 
							ctx->found_data_len = data_len;
 | 
				
			||||||
		ctx->found_data = kmemdup(data, data_len, GFP_NOFS);
 | 
							ctx->found_data = kmemdup(data, data_len, GFP_KERNEL);
 | 
				
			||||||
		if (!ctx->found_data)
 | 
							if (!ctx->found_data)
 | 
				
			||||||
			return -ENOMEM;
 | 
								return -ENOMEM;
 | 
				
			||||||
		return 1;
 | 
							return 1;
 | 
				
			||||||
| 
						 | 
					@ -4481,7 +4481,7 @@ static ssize_t fill_read_buf(struct send_ctx *sctx, u64 offset, u32 len)
 | 
				
			||||||
	while (index <= last_index) {
 | 
						while (index <= last_index) {
 | 
				
			||||||
		unsigned cur_len = min_t(unsigned, len,
 | 
							unsigned cur_len = min_t(unsigned, len,
 | 
				
			||||||
					 PAGE_CACHE_SIZE - pg_offset);
 | 
										 PAGE_CACHE_SIZE - pg_offset);
 | 
				
			||||||
		page = find_or_create_page(inode->i_mapping, index, GFP_NOFS);
 | 
							page = find_or_create_page(inode->i_mapping, index, GFP_KERNEL);
 | 
				
			||||||
		if (!page) {
 | 
							if (!page) {
 | 
				
			||||||
			ret = -ENOMEM;
 | 
								ret = -ENOMEM;
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
| 
						 | 
					@ -5989,7 +5989,7 @@ long btrfs_ioctl_send(struct file *mnt_file, void __user *arg_)
 | 
				
			||||||
		goto out;
 | 
							goto out;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	sctx = kzalloc(sizeof(struct send_ctx), GFP_NOFS);
 | 
						sctx = kzalloc(sizeof(struct send_ctx), GFP_KERNEL);
 | 
				
			||||||
	if (!sctx) {
 | 
						if (!sctx) {
 | 
				
			||||||
		ret = -ENOMEM;
 | 
							ret = -ENOMEM;
 | 
				
			||||||
		goto out;
 | 
							goto out;
 | 
				
			||||||
| 
						 | 
					@ -5997,7 +5997,7 @@ long btrfs_ioctl_send(struct file *mnt_file, void __user *arg_)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	INIT_LIST_HEAD(&sctx->new_refs);
 | 
						INIT_LIST_HEAD(&sctx->new_refs);
 | 
				
			||||||
	INIT_LIST_HEAD(&sctx->deleted_refs);
 | 
						INIT_LIST_HEAD(&sctx->deleted_refs);
 | 
				
			||||||
	INIT_RADIX_TREE(&sctx->name_cache, GFP_NOFS);
 | 
						INIT_RADIX_TREE(&sctx->name_cache, GFP_KERNEL);
 | 
				
			||||||
	INIT_LIST_HEAD(&sctx->name_cache_list);
 | 
						INIT_LIST_HEAD(&sctx->name_cache_list);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	sctx->flags = arg->flags;
 | 
						sctx->flags = arg->flags;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue