Skip to content

Commit f3f5edc

Browse files
committed
Merge tag 'xfs-merge-6.17' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
Pull xfs updates from Carlos Maiolino: "This doesn't contain any new features. It mostly is a collection of clean ups and code refactoring that I preferred to postpone to the merge window. It includes removal of several unused tracepoints, refactoring key comparing routines under the B-Trees management and cleanup of xfs journaling code" * tag 'xfs-merge-6.17' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux: (44 commits) xfs: don't use a xfs_log_iovec for ri_buf in log recovery xfs: don't use a xfs_log_iovec for attr_item names and values xfs: use better names for size members in xfs_log_vec xfs: cleanup the ordered item logic in xlog_cil_insert_format_items xfs: don't pass the old lv to xfs_cil_prepare_item xfs: remove unused trace event xfs_reflink_cow_enospc xfs: remove unused trace event xfs_discard_rtrelax xfs: remove unused trace event xfs_log_cil_return xfs: remove unused trace event xfs_dqreclaim_dirty fs/xfs: replace strncpy with memtostr_pad() xfs: Remove unused label in xfs_dax_notify_dev_failure xfs: improve the comments in xfs_select_zone_nowait xfs: improve the comments in xfs_max_open_zones xfs: stop passing an inode to the zone space reservation helpers xfs: rename oz_write_pointer to oz_allocated xfs: use a uint32_t to cache i_used_blocks in xfs_init_zone xfs: improve the xg_active_ref check in xfs_group_free xfs: remove the xlog_ticket_t typedef xfs: remove xrep_trans_{alloc,cancel}_hook_dummy xfs: return the allocated transaction from xchk_trans_alloc_empty ...
2 parents 76a9701 + ded74fd commit f3f5edc

71 files changed

Lines changed: 636 additions & 944 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

fs/xfs/libxfs/xfs_alloc_btree.c

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -186,65 +186,57 @@ xfs_allocbt_init_ptr_from_cur(
186186
ptr->s = agf->agf_cnt_root;
187187
}
188188

189-
STATIC int64_t
190-
xfs_bnobt_key_diff(
189+
STATIC int
190+
xfs_bnobt_cmp_key_with_cur(
191191
struct xfs_btree_cur *cur,
192192
const union xfs_btree_key *key)
193193
{
194194
struct xfs_alloc_rec_incore *rec = &cur->bc_rec.a;
195195
const struct xfs_alloc_rec *kp = &key->alloc;
196196

197-
return (int64_t)be32_to_cpu(kp->ar_startblock) - rec->ar_startblock;
197+
return cmp_int(be32_to_cpu(kp->ar_startblock),
198+
rec->ar_startblock);
198199
}
199200

200-
STATIC int64_t
201-
xfs_cntbt_key_diff(
201+
STATIC int
202+
xfs_cntbt_cmp_key_with_cur(
202203
struct xfs_btree_cur *cur,
203204
const union xfs_btree_key *key)
204205
{
205206
struct xfs_alloc_rec_incore *rec = &cur->bc_rec.a;
206207
const struct xfs_alloc_rec *kp = &key->alloc;
207-
int64_t diff;
208208

209-
diff = (int64_t)be32_to_cpu(kp->ar_blockcount) - rec->ar_blockcount;
210-
if (diff)
211-
return diff;
212-
213-
return (int64_t)be32_to_cpu(kp->ar_startblock) - rec->ar_startblock;
209+
return cmp_int(be32_to_cpu(kp->ar_blockcount), rec->ar_blockcount) ?:
210+
cmp_int(be32_to_cpu(kp->ar_startblock), rec->ar_startblock);
214211
}
215212

216-
STATIC int64_t
217-
xfs_bnobt_diff_two_keys(
213+
STATIC int
214+
xfs_bnobt_cmp_two_keys(
218215
struct xfs_btree_cur *cur,
219216
const union xfs_btree_key *k1,
220217
const union xfs_btree_key *k2,
221218
const union xfs_btree_key *mask)
222219
{
223220
ASSERT(!mask || mask->alloc.ar_startblock);
224221

225-
return (int64_t)be32_to_cpu(k1->alloc.ar_startblock) -
226-
be32_to_cpu(k2->alloc.ar_startblock);
222+
return cmp_int(be32_to_cpu(k1->alloc.ar_startblock),
223+
be32_to_cpu(k2->alloc.ar_startblock));
227224
}
228225

229-
STATIC int64_t
230-
xfs_cntbt_diff_two_keys(
226+
STATIC int
227+
xfs_cntbt_cmp_two_keys(
231228
struct xfs_btree_cur *cur,
232229
const union xfs_btree_key *k1,
233230
const union xfs_btree_key *k2,
234231
const union xfs_btree_key *mask)
235232
{
236-
int64_t diff;
237-
238233
ASSERT(!mask || (mask->alloc.ar_blockcount &&
239234
mask->alloc.ar_startblock));
240235

241-
diff = be32_to_cpu(k1->alloc.ar_blockcount) -
242-
be32_to_cpu(k2->alloc.ar_blockcount);
243-
if (diff)
244-
return diff;
245-
246-
return be32_to_cpu(k1->alloc.ar_startblock) -
247-
be32_to_cpu(k2->alloc.ar_startblock);
236+
return cmp_int(be32_to_cpu(k1->alloc.ar_blockcount),
237+
be32_to_cpu(k2->alloc.ar_blockcount)) ?:
238+
cmp_int(be32_to_cpu(k1->alloc.ar_startblock),
239+
be32_to_cpu(k2->alloc.ar_startblock));
248240
}
249241

250242
static xfs_failaddr_t
@@ -438,9 +430,9 @@ const struct xfs_btree_ops xfs_bnobt_ops = {
438430
.init_high_key_from_rec = xfs_bnobt_init_high_key_from_rec,
439431
.init_rec_from_cur = xfs_allocbt_init_rec_from_cur,
440432
.init_ptr_from_cur = xfs_allocbt_init_ptr_from_cur,
441-
.key_diff = xfs_bnobt_key_diff,
433+
.cmp_key_with_cur = xfs_bnobt_cmp_key_with_cur,
442434
.buf_ops = &xfs_bnobt_buf_ops,
443-
.diff_two_keys = xfs_bnobt_diff_two_keys,
435+
.cmp_two_keys = xfs_bnobt_cmp_two_keys,
444436
.keys_inorder = xfs_bnobt_keys_inorder,
445437
.recs_inorder = xfs_bnobt_recs_inorder,
446438
.keys_contiguous = xfs_allocbt_keys_contiguous,
@@ -468,9 +460,9 @@ const struct xfs_btree_ops xfs_cntbt_ops = {
468460
.init_high_key_from_rec = xfs_cntbt_init_high_key_from_rec,
469461
.init_rec_from_cur = xfs_allocbt_init_rec_from_cur,
470462
.init_ptr_from_cur = xfs_allocbt_init_ptr_from_cur,
471-
.key_diff = xfs_cntbt_key_diff,
463+
.cmp_key_with_cur = xfs_cntbt_cmp_key_with_cur,
472464
.buf_ops = &xfs_cntbt_buf_ops,
473-
.diff_two_keys = xfs_cntbt_diff_two_keys,
465+
.cmp_two_keys = xfs_cntbt_cmp_two_keys,
474466
.keys_inorder = xfs_cntbt_keys_inorder,
475467
.recs_inorder = xfs_cntbt_recs_inorder,
476468
.keys_contiguous = NULL, /* not needed right now */

fs/xfs/libxfs/xfs_bmap_btree.c

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -369,38 +369,26 @@ xfs_bmbt_init_rec_from_cur(
369369
xfs_bmbt_disk_set_all(&rec->bmbt, &cur->bc_rec.b);
370370
}
371371

372-
STATIC int64_t
373-
xfs_bmbt_key_diff(
372+
STATIC int
373+
xfs_bmbt_cmp_key_with_cur(
374374
struct xfs_btree_cur *cur,
375375
const union xfs_btree_key *key)
376376
{
377-
return (int64_t)be64_to_cpu(key->bmbt.br_startoff) -
378-
cur->bc_rec.b.br_startoff;
377+
return cmp_int(be64_to_cpu(key->bmbt.br_startoff),
378+
cur->bc_rec.b.br_startoff);
379379
}
380380

381-
STATIC int64_t
382-
xfs_bmbt_diff_two_keys(
381+
STATIC int
382+
xfs_bmbt_cmp_two_keys(
383383
struct xfs_btree_cur *cur,
384384
const union xfs_btree_key *k1,
385385
const union xfs_btree_key *k2,
386386
const union xfs_btree_key *mask)
387387
{
388-
uint64_t a = be64_to_cpu(k1->bmbt.br_startoff);
389-
uint64_t b = be64_to_cpu(k2->bmbt.br_startoff);
390-
391388
ASSERT(!mask || mask->bmbt.br_startoff);
392389

393-
/*
394-
* Note: This routine previously casted a and b to int64 and subtracted
395-
* them to generate a result. This lead to problems if b was the
396-
* "maximum" key value (all ones) being signed incorrectly, hence this
397-
* somewhat less efficient version.
398-
*/
399-
if (a > b)
400-
return 1;
401-
if (b > a)
402-
return -1;
403-
return 0;
390+
return cmp_int(be64_to_cpu(k1->bmbt.br_startoff),
391+
be64_to_cpu(k2->bmbt.br_startoff));
404392
}
405393

406394
static xfs_failaddr_t
@@ -647,8 +635,8 @@ const struct xfs_btree_ops xfs_bmbt_ops = {
647635
.init_key_from_rec = xfs_bmbt_init_key_from_rec,
648636
.init_high_key_from_rec = xfs_bmbt_init_high_key_from_rec,
649637
.init_rec_from_cur = xfs_bmbt_init_rec_from_cur,
650-
.key_diff = xfs_bmbt_key_diff,
651-
.diff_two_keys = xfs_bmbt_diff_two_keys,
638+
.cmp_key_with_cur = xfs_bmbt_cmp_key_with_cur,
639+
.cmp_two_keys = xfs_bmbt_cmp_two_keys,
652640
.buf_ops = &xfs_bmbt_buf_ops,
653641
.keys_inorder = xfs_bmbt_keys_inorder,
654642
.recs_inorder = xfs_bmbt_recs_inorder,

fs/xfs/libxfs/xfs_btree.c

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1985,7 +1985,7 @@ xfs_btree_lookup(
19851985
int *stat) /* success/failure */
19861986
{
19871987
struct xfs_btree_block *block; /* current btree block */
1988-
int64_t diff; /* difference for the current key */
1988+
int cmp_r; /* current key comparison result */
19891989
int error; /* error return value */
19901990
int keyno; /* current key number */
19911991
int level; /* level in the btree */
@@ -2013,13 +2013,13 @@ xfs_btree_lookup(
20132013
* on the lookup record, then follow the corresponding block
20142014
* pointer down to the next level.
20152015
*/
2016-
for (level = cur->bc_nlevels - 1, diff = 1; level >= 0; level--) {
2016+
for (level = cur->bc_nlevels - 1, cmp_r = 1; level >= 0; level--) {
20172017
/* Get the block we need to do the lookup on. */
20182018
error = xfs_btree_lookup_get_block(cur, level, pp, &block);
20192019
if (error)
20202020
goto error0;
20212021

2022-
if (diff == 0) {
2022+
if (cmp_r == 0) {
20232023
/*
20242024
* If we already had a key match at a higher level, we
20252025
* know we need to use the first entry in this block.
@@ -2065,15 +2065,16 @@ xfs_btree_lookup(
20652065
keyno, block, &key);
20662066

20672067
/*
2068-
* Compute difference to get next direction:
2068+
* Compute comparison result to get next
2069+
* direction:
20692070
* - less than, move right
20702071
* - greater than, move left
20712072
* - equal, we're done
20722073
*/
2073-
diff = cur->bc_ops->key_diff(cur, kp);
2074-
if (diff < 0)
2074+
cmp_r = cur->bc_ops->cmp_key_with_cur(cur, kp);
2075+
if (cmp_r < 0)
20752076
low = keyno + 1;
2076-
else if (diff > 0)
2077+
else if (cmp_r > 0)
20772078
high = keyno - 1;
20782079
else
20792080
break;
@@ -2089,7 +2090,7 @@ xfs_btree_lookup(
20892090
* If we moved left, need the previous key number,
20902091
* unless there isn't one.
20912092
*/
2092-
if (diff > 0 && --keyno < 1)
2093+
if (cmp_r > 0 && --keyno < 1)
20932094
keyno = 1;
20942095
pp = xfs_btree_ptr_addr(cur, keyno, block);
20952096

@@ -2102,7 +2103,7 @@ xfs_btree_lookup(
21022103
}
21032104

21042105
/* Done with the search. See if we need to adjust the results. */
2105-
if (dir != XFS_LOOKUP_LE && diff < 0) {
2106+
if (dir != XFS_LOOKUP_LE && cmp_r < 0) {
21062107
keyno++;
21072108
/*
21082109
* If ge search and we went off the end of the block, but it's
@@ -2125,14 +2126,14 @@ xfs_btree_lookup(
21252126
*stat = 1;
21262127
return 0;
21272128
}
2128-
} else if (dir == XFS_LOOKUP_LE && diff > 0)
2129+
} else if (dir == XFS_LOOKUP_LE && cmp_r > 0)
21292130
keyno--;
21302131
cur->bc_levels[0].ptr = keyno;
21312132

21322133
/* Return if we succeeded or not. */
21332134
if (keyno == 0 || keyno > xfs_btree_get_numrecs(block))
21342135
*stat = 0;
2135-
else if (dir != XFS_LOOKUP_EQ || diff == 0)
2136+
else if (dir != XFS_LOOKUP_EQ || cmp_r == 0)
21362137
*stat = 1;
21372138
else
21382139
*stat = 0;
@@ -5058,7 +5059,7 @@ xfs_btree_simple_query_range(
50585059
int error;
50595060

50605061
ASSERT(cur->bc_ops->init_high_key_from_rec);
5061-
ASSERT(cur->bc_ops->diff_two_keys);
5062+
ASSERT(cur->bc_ops->cmp_two_keys);
50625063

50635064
/*
50645065
* Find the leftmost record. The btree cursor must be set
@@ -5352,15 +5353,15 @@ xfs_btree_count_blocks(
53525353
}
53535354

53545355
/* Compare two btree pointers. */
5355-
int64_t
5356-
xfs_btree_diff_two_ptrs(
5356+
int
5357+
xfs_btree_cmp_two_ptrs(
53575358
struct xfs_btree_cur *cur,
53585359
const union xfs_btree_ptr *a,
53595360
const union xfs_btree_ptr *b)
53605361
{
53615362
if (cur->bc_ops->ptr_len == XFS_BTREE_LONG_PTR_LEN)
5362-
return (int64_t)be64_to_cpu(a->l) - be64_to_cpu(b->l);
5363-
return (int64_t)be32_to_cpu(a->s) - be32_to_cpu(b->s);
5363+
return cmp_int(be64_to_cpu(a->l), be64_to_cpu(b->l));
5364+
return cmp_int(be32_to_cpu(a->s), be32_to_cpu(b->s));
53645365
}
53655366

53665367
struct xfs_btree_has_records {

fs/xfs/libxfs/xfs_btree.h

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -171,20 +171,23 @@ struct xfs_btree_ops {
171171
void (*init_high_key_from_rec)(union xfs_btree_key *key,
172172
const union xfs_btree_rec *rec);
173173

174-
/* difference between key value and cursor value */
175-
int64_t (*key_diff)(struct xfs_btree_cur *cur,
176-
const union xfs_btree_key *key);
174+
/*
175+
* Compare key value and cursor value -- positive if key > cur,
176+
* negative if key < cur, and zero if equal.
177+
*/
178+
int (*cmp_key_with_cur)(struct xfs_btree_cur *cur,
179+
const union xfs_btree_key *key);
177180

178181
/*
179-
* Difference between key2 and key1 -- positive if key1 > key2,
180-
* negative if key1 < key2, and zero if equal. If the @mask parameter
181-
* is non NULL, each key field to be used in the comparison must
182-
* contain a nonzero value.
182+
* Compare key1 and key2 -- positive if key1 > key2, negative if
183+
* key1 < key2, and zero if equal. If the @mask parameter is non NULL,
184+
* each key field to be used in the comparison must contain a nonzero
185+
* value.
183186
*/
184-
int64_t (*diff_two_keys)(struct xfs_btree_cur *cur,
185-
const union xfs_btree_key *key1,
186-
const union xfs_btree_key *key2,
187-
const union xfs_btree_key *mask);
187+
int (*cmp_two_keys)(struct xfs_btree_cur *cur,
188+
const union xfs_btree_key *key1,
189+
const union xfs_btree_key *key2,
190+
const union xfs_btree_key *mask);
188191

189192
const struct xfs_buf_ops *buf_ops;
190193

@@ -516,9 +519,9 @@ struct xfs_btree_block *xfs_btree_get_block(struct xfs_btree_cur *cur,
516519
int level, struct xfs_buf **bpp);
517520
bool xfs_btree_ptr_is_null(struct xfs_btree_cur *cur,
518521
const union xfs_btree_ptr *ptr);
519-
int64_t xfs_btree_diff_two_ptrs(struct xfs_btree_cur *cur,
520-
const union xfs_btree_ptr *a,
521-
const union xfs_btree_ptr *b);
522+
int xfs_btree_cmp_two_ptrs(struct xfs_btree_cur *cur,
523+
const union xfs_btree_ptr *a,
524+
const union xfs_btree_ptr *b);
522525
void xfs_btree_get_sibling(struct xfs_btree_cur *cur,
523526
struct xfs_btree_block *block,
524527
union xfs_btree_ptr *ptr, int lr);
@@ -546,7 +549,7 @@ xfs_btree_keycmp_lt(
546549
const union xfs_btree_key *key1,
547550
const union xfs_btree_key *key2)
548551
{
549-
return cur->bc_ops->diff_two_keys(cur, key1, key2, NULL) < 0;
552+
return cur->bc_ops->cmp_two_keys(cur, key1, key2, NULL) < 0;
550553
}
551554

552555
static inline bool
@@ -555,7 +558,7 @@ xfs_btree_keycmp_gt(
555558
const union xfs_btree_key *key1,
556559
const union xfs_btree_key *key2)
557560
{
558-
return cur->bc_ops->diff_two_keys(cur, key1, key2, NULL) > 0;
561+
return cur->bc_ops->cmp_two_keys(cur, key1, key2, NULL) > 0;
559562
}
560563

561564
static inline bool
@@ -564,7 +567,7 @@ xfs_btree_keycmp_eq(
564567
const union xfs_btree_key *key1,
565568
const union xfs_btree_key *key2)
566569
{
567-
return cur->bc_ops->diff_two_keys(cur, key1, key2, NULL) == 0;
570+
return cur->bc_ops->cmp_two_keys(cur, key1, key2, NULL) == 0;
568571
}
569572

570573
static inline bool
@@ -602,7 +605,7 @@ xfs_btree_masked_keycmp_lt(
602605
const union xfs_btree_key *key2,
603606
const union xfs_btree_key *mask)
604607
{
605-
return cur->bc_ops->diff_two_keys(cur, key1, key2, mask) < 0;
608+
return cur->bc_ops->cmp_two_keys(cur, key1, key2, mask) < 0;
606609
}
607610

608611
static inline bool
@@ -612,7 +615,7 @@ xfs_btree_masked_keycmp_gt(
612615
const union xfs_btree_key *key2,
613616
const union xfs_btree_key *mask)
614617
{
615-
return cur->bc_ops->diff_two_keys(cur, key1, key2, mask) > 0;
618+
return cur->bc_ops->cmp_two_keys(cur, key1, key2, mask) > 0;
616619
}
617620

618621
static inline bool

fs/xfs/libxfs/xfs_format.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ typedef struct xfs_sb {
112112
uint16_t sb_sectsize; /* volume sector size, bytes */
113113
uint16_t sb_inodesize; /* inode size, bytes */
114114
uint16_t sb_inopblock; /* inodes per block */
115-
char sb_fname[XFSLABEL_MAX]; /* file system name */
115+
char sb_fname[XFSLABEL_MAX] __nonstring; /* file system name */
116116
uint8_t sb_blocklog; /* log2 of sb_blocksize */
117117
uint8_t sb_sectlog; /* log2 of sb_sectsize */
118118
uint8_t sb_inodelog; /* log2 of sb_inodesize */

fs/xfs/libxfs/xfs_group.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ xfs_group_free(
172172

173173
/* drop the mount's active reference */
174174
xfs_group_rele(xg);
175-
XFS_IS_CORRUPT(mp, atomic_read(&xg->xg_active_ref) != 0);
175+
XFS_IS_CORRUPT(mp, atomic_read(&xg->xg_active_ref) > 0);
176+
XFS_IS_CORRUPT(mp, atomic_read(&xg->xg_active_ref) < 0);
176177
kfree_rcu_mightsleep(xg);
177178
}
178179

0 commit comments

Comments
 (0)