Skip to content

Commit de47e4c

Browse files
author
Darrick J. Wong
committed
xfs: add a bi_entry helper
Add a helper to translate from the item list head to the bmap_intent structure and use it so shorten assignments and avoid the need for extra local variables. Inspired-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de>
1 parent 372fe0b commit de47e4c

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

fs/xfs/xfs_bmap_item.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -221,18 +221,21 @@ static const struct xfs_item_ops xfs_bud_item_ops = {
221221
.iop_intent = xfs_bud_item_intent,
222222
};
223223

224+
static inline struct xfs_bmap_intent *bi_entry(const struct list_head *e)
225+
{
226+
return list_entry(e, struct xfs_bmap_intent, bi_list);
227+
}
228+
224229
/* Sort bmap intents by inode. */
225230
static int
226231
xfs_bmap_update_diff_items(
227232
void *priv,
228233
const struct list_head *a,
229234
const struct list_head *b)
230235
{
231-
struct xfs_bmap_intent *ba;
232-
struct xfs_bmap_intent *bb;
236+
struct xfs_bmap_intent *ba = bi_entry(a);
237+
struct xfs_bmap_intent *bb = bi_entry(b);
233238

234-
ba = container_of(a, struct xfs_bmap_intent, bi_list);
235-
bb = container_of(b, struct xfs_bmap_intent, bi_list);
236239
return ba->bi_owner->i_ino - bb->bi_owner->i_ino;
237240
}
238241

@@ -348,11 +351,9 @@ xfs_bmap_update_finish_item(
348351
struct list_head *item,
349352
struct xfs_btree_cur **state)
350353
{
351-
struct xfs_bmap_intent *bi;
354+
struct xfs_bmap_intent *bi = bi_entry(item);
352355
int error;
353356

354-
bi = container_of(item, struct xfs_bmap_intent, bi_list);
355-
356357
error = xfs_bmap_finish_one(tp, bi);
357358
if (!error && bi->bi_bmap.br_blockcount > 0) {
358359
ASSERT(bi->bi_type == XFS_BMAP_UNMAP);
@@ -377,9 +378,7 @@ STATIC void
377378
xfs_bmap_update_cancel_item(
378379
struct list_head *item)
379380
{
380-
struct xfs_bmap_intent *bi;
381-
382-
bi = container_of(item, struct xfs_bmap_intent, bi_list);
381+
struct xfs_bmap_intent *bi = bi_entry(item);
383382

384383
xfs_bmap_update_put_group(bi);
385384
kmem_cache_free(xfs_bmap_intent_cache, bi);

0 commit comments

Comments
 (0)