Skip to content

Commit aa8fb4b

Browse files
author
Chandan Babu R
committed
Merge tag 'buftarg-cleanups-6.9_2024-02-23' of https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux into xfs-6.9-mergeC
xfs: buftarg cleanups Clean up the buffer target code in preparation for adding the ability to target tmpfs files. That will enable the creation of in memory btrees. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Chandan Babu R <chandanbabu@kernel.org> * tag 'buftarg-cleanups-6.9_2024-02-23' of https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux: xfs: move setting bt_logical_sectorsize out of xfs_setsize_buftarg xfs: remove xfs_setsize_buftarg_early xfs: remove the xfs_buftarg_t typedef
2 parents a7ade7e + 1c51ac0 commit aa8fb4b

4 files changed

Lines changed: 26 additions & 34 deletions

File tree

fs/xfs/xfs_buf.c

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1980,7 +1980,7 @@ xfs_free_buftarg(
19801980

19811981
int
19821982
xfs_setsize_buftarg(
1983-
xfs_buftarg_t *btp,
1983+
struct xfs_buftarg *btp,
19841984
unsigned int sectorsize)
19851985
{
19861986
/* Set up metadata sector size info */
@@ -1994,31 +1994,15 @@ xfs_setsize_buftarg(
19941994
return -EINVAL;
19951995
}
19961996

1997-
/* Set up device logical sector size mask */
1998-
btp->bt_logical_sectorsize = bdev_logical_block_size(btp->bt_bdev);
1999-
btp->bt_logical_sectormask = bdev_logical_block_size(btp->bt_bdev) - 1;
2000-
20011997
return 0;
20021998
}
20031999

2004-
/*
2005-
* When allocating the initial buffer target we have not yet
2006-
* read in the superblock, so don't know what sized sectors
2007-
* are being used at this early stage. Play safe.
2008-
*/
2009-
STATIC int
2010-
xfs_setsize_buftarg_early(
2011-
xfs_buftarg_t *btp)
2012-
{
2013-
return xfs_setsize_buftarg(btp, bdev_logical_block_size(btp->bt_bdev));
2014-
}
2015-
20162000
struct xfs_buftarg *
20172001
xfs_alloc_buftarg(
20182002
struct xfs_mount *mp,
20192003
struct bdev_handle *bdev_handle)
20202004
{
2021-
xfs_buftarg_t *btp;
2005+
struct xfs_buftarg *btp;
20222006
const struct dax_holder_operations *ops = NULL;
20232007

20242008
#if defined(CONFIG_FS_DAX) && defined(CONFIG_MEMORY_FAILURE)
@@ -2033,16 +2017,24 @@ xfs_alloc_buftarg(
20332017
btp->bt_daxdev = fs_dax_get_by_bdev(btp->bt_bdev, &btp->bt_dax_part_off,
20342018
mp, ops);
20352019

2020+
/*
2021+
* When allocating the buftargs we have not yet read the super block and
2022+
* thus don't know the file system sector size yet.
2023+
*/
2024+
if (xfs_setsize_buftarg(btp, bdev_logical_block_size(btp->bt_bdev)))
2025+
goto error_free;
2026+
2027+
/* Set up device logical sector size mask */
2028+
btp->bt_logical_sectorsize = bdev_logical_block_size(btp->bt_bdev);
2029+
btp->bt_logical_sectormask = bdev_logical_block_size(btp->bt_bdev) - 1;
2030+
20362031
/*
20372032
* Buffer IO error rate limiting. Limit it to no more than 10 messages
20382033
* per 30 seconds so as to not spam logs too much on repeated errors.
20392034
*/
20402035
ratelimit_state_init(&btp->bt_ioerror_rl, 30 * HZ,
20412036
DEFAULT_RATELIMIT_BURST);
20422037

2043-
if (xfs_setsize_buftarg_early(btp))
2044-
goto error_free;
2045-
20462038
if (list_lru_init(&btp->bt_lru))
20472039
goto error_free;
20482040

fs/xfs/xfs_buf.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ typedef unsigned int xfs_buf_flags_t;
9696
* The latter is derived from the underlying device, and controls direct IO
9797
* alignment constraints.
9898
*/
99-
typedef struct xfs_buftarg {
99+
struct xfs_buftarg {
100100
dev_t bt_dev;
101101
struct bdev_handle *bt_bdev_handle;
102102
struct block_device *bt_bdev;
@@ -114,7 +114,7 @@ typedef struct xfs_buftarg {
114114

115115
struct percpu_counter bt_io_count;
116116
struct ratelimit_state bt_ioerror_rl;
117-
} xfs_buftarg_t;
117+
};
118118

119119
#define XB_PAGES 2
120120

fs/xfs/xfs_log.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -633,14 +633,14 @@ xlog_state_release_iclog(
633633
*/
634634
int
635635
xfs_log_mount(
636-
xfs_mount_t *mp,
637-
xfs_buftarg_t *log_target,
638-
xfs_daddr_t blk_offset,
639-
int num_bblks)
640-
{
641-
struct xlog *log;
642-
int error = 0;
643-
int min_logfsbs;
636+
xfs_mount_t *mp,
637+
struct xfs_buftarg *log_target,
638+
xfs_daddr_t blk_offset,
639+
int num_bblks)
640+
{
641+
struct xlog *log;
642+
int error = 0;
643+
int min_logfsbs;
644644

645645
if (!xfs_has_norecovery(mp)) {
646646
xfs_notice(mp, "Mounting V%d Filesystem %pU",

fs/xfs/xfs_mount.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ typedef struct xfs_mount {
9494
struct xfs_inode *m_rsumip; /* pointer to summary inode */
9595
struct xfs_inode *m_rootip; /* pointer to root directory */
9696
struct xfs_quotainfo *m_quotainfo; /* disk quota information */
97-
xfs_buftarg_t *m_ddev_targp; /* saves taking the address */
98-
xfs_buftarg_t *m_logdev_targp;/* ptr to log device */
99-
xfs_buftarg_t *m_rtdev_targp; /* ptr to rt device */
97+
struct xfs_buftarg *m_ddev_targp; /* data device */
98+
struct xfs_buftarg *m_logdev_targp;/* log device */
99+
struct xfs_buftarg *m_rtdev_targp; /* rt device */
100100
void __percpu *m_inodegc; /* percpu inodegc structures */
101101

102102
/*

0 commit comments

Comments
 (0)