diff options
Diffstat (limited to 'fs/btrfs/file.c')
| -rw-r--r-- | fs/btrfs/file.c | 31 | 
1 files changed, 7 insertions, 24 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 1f2b99cb55ea..ff1cc0399b9a 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -1838,6 +1838,8 @@ out:  int btrfs_release_file(struct inode *inode, struct file *filp)  { +	if (filp->private_data) +		btrfs_ioctl_trans_end(filp);  	/*  	 * ordered_data_close is set by settattr when we are about to truncate  	 * a file from a non-zero size to a zero size.  This tries to @@ -1845,26 +1847,8 @@ int btrfs_release_file(struct inode *inode, struct file *filp)  	 * application were using truncate to replace a file in place.  	 */  	if (test_and_clear_bit(BTRFS_INODE_ORDERED_DATA_CLOSE, -			       &BTRFS_I(inode)->runtime_flags)) { -		struct btrfs_trans_handle *trans; -		struct btrfs_root *root = BTRFS_I(inode)->root; - -		/* -		 * We need to block on a committing transaction to keep us from -		 * throwing a ordered operation on to the list and causing -		 * something like sync to deadlock trying to flush out this -		 * inode. -		 */ -		trans = btrfs_start_transaction(root, 0); -		if (IS_ERR(trans)) -			return PTR_ERR(trans); -		btrfs_add_ordered_operation(trans, BTRFS_I(inode)->root, inode); -		btrfs_end_transaction(trans, root); -		if (inode->i_size > BTRFS_ORDERED_OPERATIONS_FLUSH_LIMIT) +			       &BTRFS_I(inode)->runtime_flags))  			filemap_flush(inode->i_mapping); -	} -	if (filp->private_data) -		btrfs_ioctl_trans_end(filp);  	return 0;  } @@ -1982,7 +1966,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)  	btrfs_init_log_ctx(&ctx); -	ret = btrfs_log_dentry_safe(trans, root, dentry, &ctx); +	ret = btrfs_log_dentry_safe(trans, root, dentry, start, end, &ctx);  	if (ret < 0) {  		/* Fallthrough and commit/free transaction. */  		ret = 1; @@ -2112,10 +2096,9 @@ static int fill_holes(struct btrfs_trans_handle *trans, struct inode *inode,  		goto out;  	} -	if (hole_mergeable(inode, leaf, path->slots[0]+1, offset, end)) { +	if (hole_mergeable(inode, leaf, path->slots[0], offset, end)) {  		u64 num_bytes; -		path->slots[0]++;  		key.offset = offset;  		btrfs_set_item_key_safe(root, path, &key);  		fi = btrfs_item_ptr(leaf, path->slots[0], @@ -2240,7 +2223,7 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)  		goto out_only_mutex;  	} -	lockstart = round_up(offset , BTRFS_I(inode)->root->sectorsize); +	lockstart = round_up(offset, BTRFS_I(inode)->root->sectorsize);  	lockend = round_down(offset + len,  			     BTRFS_I(inode)->root->sectorsize) - 1;  	same_page = ((offset >> PAGE_CACHE_SHIFT) == @@ -2301,7 +2284,7 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)  						tail_start + tail_len, 0, 1);  				if (ret)  					goto out_only_mutex; -				} +			}  		}  	}  |