btrfs: btrfs_check_shared should manage its own transaction

Commit afce772e87 ("btrfs: fix check_shared for fiemap ioctl") added
transaction semantics around calls to btrfs_check_shared() in order to
provide accurate accounting of delayed refs. The transaction management
should be done inside btrfs_check_shared(), so that callers do not need
to manage transactions individually.

Signed-off-by: Edmund Nadolski <enadolski@suse.com>
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Edmund Nadolski
2017-06-28 21:56:58 -06:00
committed by David Sterba
parent e0c476b128
commit bb739cf08e
3 changed files with 23 additions and 33 deletions

View File

@@ -20,7 +20,6 @@
#include "locking.h"
#include "rcu-string.h"
#include "backref.h"
#include "transaction.h"
static struct kmem_cache *extent_state_cache;
static struct kmem_cache *extent_buffer_cache;
@@ -4606,24 +4605,11 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
flags |= (FIEMAP_EXTENT_DELALLOC |
FIEMAP_EXTENT_UNKNOWN);
} else if (fieinfo->fi_extents_max) {
struct btrfs_trans_handle *trans;
u64 bytenr = em->block_start -
(em->start - em->orig_start);
disko = em->block_start + offset_in_extent;
/*
* We need a trans handle to get delayed refs
*/
trans = btrfs_join_transaction(root);
/*
* It's OK if we can't start a trans we can still check
* from commit_root
*/
if (IS_ERR(trans))
trans = NULL;
/*
* As btrfs supports shared space, this information
* can be exported to userspace tools via
@@ -4631,11 +4617,9 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
* then we're just getting a count and we can skip the
* lookup stuff.
*/
ret = btrfs_check_shared(trans, root->fs_info,
root->objectid,
btrfs_ino(BTRFS_I(inode)), bytenr);
if (trans)
btrfs_end_transaction(trans);
ret = btrfs_check_shared(root,
btrfs_ino(BTRFS_I(inode)),
bytenr);
if (ret < 0)
goto out_free;
if (ret)