mbox series

[0/6] Overhaul free objectid code

Message ID 20201207153237.1073887-1-nborisov@suse.com (mailing list archive)
Headers show
Series Overhaul free objectid code | expand

Message

Nikolay Borisov Dec. 7, 2020, 3:32 p.m. UTC
This series aims to make the free objectid code more straighforward. Currently
the highest used objectid is used which implies that when btrfs_get_free_objectid
is called the pre-increment operator is used. At the same time when looking
at how highest_objectid is initialised in find_free_objectid it's using the,
at first looko unusual, 'BTRFS_FREE_OBJECTID - 1'. Furthermore btrfs_find_free_objectid
is badly named as it's used only in initializaion context.

With the series applied the following is achieved:
 * The 2 functions related to free objectid have better naming which describes
 their semantic meaning.

 * highest_objectid is renamed to free_objectid which clearly states what it's
 supposed to hold, also btrfs_get_free_objectid now returns the value and
 does a post-increment which seems more logical than the previous cod.

 * Now it's not necessary to re-initialize free_objectid in create_subvol
 since that member is now consistently initialized when a given root is read
 for the first time in btrfs_init_fs_root->btrfs_init_root_free_objectid.
 Additionally in btrfs_init_root_free_objectid free_objectid is now initialized
 to BTRFS_FIRST_FREE_OBJECTID so it's self-explanatory.

This series survived xfstest as well as a new xfstest which verifies precisely
this functionality.


Nikolay Borisov (6):
  btrfs: Rename btrfs_find_highest_objectid to
    btrfs_init_root_free_objectid
  btrfs: Rename btrfs_find_free_objectid to btrfs_get_free_objectid
  btrfs: Remove useless ASSERTS
  btrfs: Rename highest_objectid to free_objectid
  btrfs: Make free_objectid hold the next available objectid in the root
  btrfs: Remove new_dirid argument from btrfs_create_subvol_root

 fs/btrfs/ctree.h            |  5 ++---
 fs/btrfs/disk-io.c          | 25 ++++++++++---------------
 fs/btrfs/disk-io.h          |  4 ++--
 fs/btrfs/free-space-cache.c |  2 +-
 fs/btrfs/inode.c            | 23 +++++++++++++----------
 fs/btrfs/ioctl.c            | 11 +++--------
 fs/btrfs/relocation.c       |  2 +-
 fs/btrfs/transaction.c      |  2 +-
 fs/btrfs/tree-log.c         |  3 +--
 9 files changed, 34 insertions(+), 43 deletions(-)

--
2.25.1

Comments

Josef Bacik Dec. 7, 2020, 4:27 p.m. UTC | #1
On 12/7/20 10:32 AM, Nikolay Borisov wrote:
> This series aims to make the free objectid code more straighforward. Currently
> the highest used objectid is used which implies that when btrfs_get_free_objectid
> is called the pre-increment operator is used. At the same time when looking
> at how highest_objectid is initialised in find_free_objectid it's using the,
> at first looko unusual, 'BTRFS_FREE_OBJECTID - 1'. Furthermore btrfs_find_free_objectid
> is badly named as it's used only in initializaion context.
> 
> With the series applied the following is achieved:
>   * The 2 functions related to free objectid have better naming which describes
>   their semantic meaning.
> 
>   * highest_objectid is renamed to free_objectid which clearly states what it's
>   supposed to hold, also btrfs_get_free_objectid now returns the value and
>   does a post-increment which seems more logical than the previous cod.
> 
>   * Now it's not necessary to re-initialize free_objectid in create_subvol
>   since that member is now consistently initialized when a given root is read
>   for the first time in btrfs_init_fs_root->btrfs_init_root_free_objectid.
>   Additionally in btrfs_init_root_free_objectid free_objectid is now initialized
>   to BTRFS_FIRST_FREE_OBJECTID so it's self-explanatory.
> 
> This series survived xfstest as well as a new xfstest which verifies precisely
> this functionality.
> 

You can add

Reviewed-by: Josef Bacik <josef@toxicpanda.com>

to the series, thanks,

Josef
David Sterba Dec. 15, 2020, 5:08 p.m. UTC | #2
On Mon, Dec 07, 2020 at 05:32:31PM +0200, Nikolay Borisov wrote:
> This series aims to make the free objectid code more straighforward. Currently
> the highest used objectid is used which implies that when btrfs_get_free_objectid
> is called the pre-increment operator is used. At the same time when looking
> at how highest_objectid is initialised in find_free_objectid it's using the,
> at first looko unusual, 'BTRFS_FREE_OBJECTID - 1'. Furthermore btrfs_find_free_objectid
> is badly named as it's used only in initializaion context.
> 
> With the series applied the following is achieved:
>  * The 2 functions related to free objectid have better naming which describes
>  their semantic meaning.
> 
>  * highest_objectid is renamed to free_objectid which clearly states what it's
>  supposed to hold, also btrfs_get_free_objectid now returns the value and
>  does a post-increment which seems more logical than the previous cod.
> 
>  * Now it's not necessary to re-initialize free_objectid in create_subvol
>  since that member is now consistently initialized when a given root is read
>  for the first time in btrfs_init_fs_root->btrfs_init_root_free_objectid.
>  Additionally in btrfs_init_root_free_objectid free_objectid is now initialized
>  to BTRFS_FIRST_FREE_OBJECTID so it's self-explanatory.
> 
> This series survived xfstest as well as a new xfstest which verifies precisely
> this functionality.
> 
> 
> Nikolay Borisov (6):
>   btrfs: Rename btrfs_find_highest_objectid to
>     btrfs_init_root_free_objectid
>   btrfs: Rename btrfs_find_free_objectid to btrfs_get_free_objectid
>   btrfs: Remove useless ASSERTS
>   btrfs: Rename highest_objectid to free_objectid
>   btrfs: Make free_objectid hold the next available objectid in the root
>   btrfs: Remove new_dirid argument from btrfs_create_subvol_root

Except patch 3 (the assert) added to misc-next, thanks.