Skip to content

Commit f2c8083

Browse files
committed
Merge tag 'gfs2-for-5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2
Pull gfs2 updates from Andreas Gruenbacher: - Fix some compiler and kernel-doc warnings - Various minor cleanups and optimizations - Add a new sysfs gfs2 status file with some filesystem wide information * tag 'gfs2-for-5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2: gfs2: Fix fall-through warnings for Clang gfs2: Fix a number of kernel-doc warnings gfs2: Make gfs2_setattr_simple static gfs2: Add new sysfs file for gfs2 status gfs2: Silence possible null pointer dereference warning gfs2: Turn gfs2_meta_indirect_buffer into gfs2_meta_buffer gfs2: Replace gfs2_lblk_to_dblk with gfs2_get_extent gfs2: Turn gfs2_extent_map into gfs2_{get,alloc}_extent gfs2: Add new gfs2_iomap_get helper gfs2: Remove unused variable sb_format gfs2: Fix dir.c function parameter descriptions gfs2: Eliminate gh parameter from go_xmote_bh func gfs2: don't create empty buffers for NO_CREATE
2 parents 8ae8932 + e5966cf commit f2c8083

23 files changed

+312
-243
lines changed

fs/gfs2/aops.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -540,10 +540,7 @@ int gfs2_internal_read(struct gfs2_inode *ip, char *buf, loff_t *pos,
540540

541541
/**
542542
* gfs2_readahead - Read a bunch of pages at once
543-
* @file: The file to read from
544-
* @mapping: Address space info
545-
* @pages: List of pages to read
546-
* @nr_pages: Number of pages to read
543+
* @rac: Read-ahead control structure
547544
*
548545
* Some notes:
549546
* 1. This is only for readahead, so we can simply ignore any things

fs/gfs2/bmap.c

Lines changed: 78 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ static int __fillup_metapath(struct gfs2_inode *ip, struct metapath *mp,
331331

332332
if (!dblock)
333333
break;
334-
ret = gfs2_meta_indirect_buffer(ip, x + 1, dblock, &mp->mp_bh[x + 1]);
334+
ret = gfs2_meta_buffer(ip, GFS2_METATYPE_IN, dblock, &mp->mp_bh[x + 1]);
335335
if (ret)
336336
return ret;
337337
}
@@ -632,7 +632,7 @@ enum alloc_state {
632632
};
633633

634634
/**
635-
* gfs2_iomap_alloc - Build a metadata tree of the requested height
635+
* __gfs2_iomap_alloc - Build a metadata tree of the requested height
636636
* @inode: The GFS2 inode
637637
* @iomap: The iomap structure
638638
* @mp: The metapath, with proper height information calculated
@@ -642,7 +642,7 @@ enum alloc_state {
642642
* ii) Indirect blocks to fill in lower part of the metadata tree
643643
* iii) Data blocks
644644
*
645-
* This function is called after gfs2_iomap_get, which works out the
645+
* This function is called after __gfs2_iomap_get, which works out the
646646
* total number of blocks which we need via gfs2_alloc_size.
647647
*
648648
* We then do the actual allocation asking for an extent at a time (if
@@ -660,8 +660,8 @@ enum alloc_state {
660660
* Returns: errno on error
661661
*/
662662

663-
static int gfs2_iomap_alloc(struct inode *inode, struct iomap *iomap,
664-
struct metapath *mp)
663+
static int __gfs2_iomap_alloc(struct inode *inode, struct iomap *iomap,
664+
struct metapath *mp)
665665
{
666666
struct gfs2_inode *ip = GFS2_I(inode);
667667
struct gfs2_sbd *sdp = GFS2_SB(inode);
@@ -802,10 +802,10 @@ static u64 gfs2_alloc_size(struct inode *inode, struct metapath *mp, u64 size)
802802

803803
/*
804804
* For writes to stuffed files, this function is called twice via
805-
* gfs2_iomap_get, before and after unstuffing. The size we return the
805+
* __gfs2_iomap_get, before and after unstuffing. The size we return the
806806
* first time needs to be large enough to get the reservation and
807807
* allocation sizes right. The size we return the second time must
808-
* be exact or else gfs2_iomap_alloc won't do the right thing.
808+
* be exact or else __gfs2_iomap_alloc won't do the right thing.
809809
*/
810810

811811
if (gfs2_is_stuffed(ip) || mp->mp_fheight != mp->mp_aheight) {
@@ -829,7 +829,7 @@ static u64 gfs2_alloc_size(struct inode *inode, struct metapath *mp, u64 size)
829829
}
830830

831831
/**
832-
* gfs2_iomap_get - Map blocks from an inode to disk blocks
832+
* __gfs2_iomap_get - Map blocks from an inode to disk blocks
833833
* @inode: The inode
834834
* @pos: Starting position in bytes
835835
* @length: Length to map, in bytes
@@ -839,9 +839,9 @@ static u64 gfs2_alloc_size(struct inode *inode, struct metapath *mp, u64 size)
839839
*
840840
* Returns: errno
841841
*/
842-
static int gfs2_iomap_get(struct inode *inode, loff_t pos, loff_t length,
843-
unsigned flags, struct iomap *iomap,
844-
struct metapath *mp)
842+
static int __gfs2_iomap_get(struct inode *inode, loff_t pos, loff_t length,
843+
unsigned flags, struct iomap *iomap,
844+
struct metapath *mp)
845845
{
846846
struct gfs2_inode *ip = GFS2_I(inode);
847847
struct gfs2_sbd *sdp = GFS2_SB(inode);
@@ -961,32 +961,6 @@ static int gfs2_iomap_get(struct inode *inode, loff_t pos, loff_t length,
961961
goto out;
962962
}
963963

964-
/**
965-
* gfs2_lblk_to_dblk - convert logical block to disk block
966-
* @inode: the inode of the file we're mapping
967-
* @lblock: the block relative to the start of the file
968-
* @dblock: the returned dblock, if no error
969-
*
970-
* This function maps a single block from a file logical block (relative to
971-
* the start of the file) to a file system absolute block using iomap.
972-
*
973-
* Returns: the absolute file system block, or an error
974-
*/
975-
int gfs2_lblk_to_dblk(struct inode *inode, u32 lblock, u64 *dblock)
976-
{
977-
struct iomap iomap = { };
978-
struct metapath mp = { .mp_aheight = 1, };
979-
loff_t pos = (loff_t)lblock << inode->i_blkbits;
980-
int ret;
981-
982-
ret = gfs2_iomap_get(inode, pos, i_blocksize(inode), 0, &iomap, &mp);
983-
release_metapath(&mp);
984-
if (ret == 0)
985-
*dblock = iomap.addr >> inode->i_blkbits;
986-
987-
return ret;
988-
}
989-
990964
static int gfs2_write_lock(struct inode *inode)
991965
{
992966
struct gfs2_inode *ip = GFS2_I(inode);
@@ -1109,14 +1083,14 @@ static int gfs2_iomap_begin_write(struct inode *inode, loff_t pos,
11091083
if (ret)
11101084
goto out_trans_end;
11111085
release_metapath(mp);
1112-
ret = gfs2_iomap_get(inode, iomap->offset,
1113-
iomap->length, flags, iomap, mp);
1086+
ret = __gfs2_iomap_get(inode, iomap->offset,
1087+
iomap->length, flags, iomap, mp);
11141088
if (ret)
11151089
goto out_trans_end;
11161090
}
11171091

11181092
if (iomap->type == IOMAP_HOLE) {
1119-
ret = gfs2_iomap_alloc(inode, iomap, mp);
1093+
ret = __gfs2_iomap_alloc(inode, iomap, mp);
11201094
if (ret) {
11211095
gfs2_trans_end(sdp);
11221096
gfs2_inplace_release(ip);
@@ -1168,7 +1142,7 @@ static int gfs2_iomap_begin(struct inode *inode, loff_t pos, loff_t length,
11681142
goto out;
11691143
}
11701144

1171-
ret = gfs2_iomap_get(inode, pos, length, flags, iomap, &mp);
1145+
ret = __gfs2_iomap_get(inode, pos, length, flags, iomap, &mp);
11721146
if (ret)
11731147
goto out_unlock;
11741148

@@ -1290,20 +1264,18 @@ int gfs2_block_map(struct inode *inode, sector_t lblock,
12901264
struct gfs2_inode *ip = GFS2_I(inode);
12911265
loff_t pos = (loff_t)lblock << inode->i_blkbits;
12921266
loff_t length = bh_map->b_size;
1293-
struct metapath mp = { .mp_aheight = 1, };
12941267
struct iomap iomap = { };
1295-
int flags = create ? IOMAP_WRITE : 0;
12961268
int ret;
12971269

12981270
clear_buffer_mapped(bh_map);
12991271
clear_buffer_new(bh_map);
13001272
clear_buffer_boundary(bh_map);
13011273
trace_gfs2_bmap(ip, bh_map, lblock, create, 1);
13021274

1303-
ret = gfs2_iomap_get(inode, pos, length, flags, &iomap, &mp);
1304-
if (create && !ret && iomap.type == IOMAP_HOLE)
1305-
ret = gfs2_iomap_alloc(inode, &iomap, &mp);
1306-
release_metapath(&mp);
1275+
if (!create)
1276+
ret = gfs2_iomap_get(inode, pos, length, &iomap);
1277+
else
1278+
ret = gfs2_iomap_alloc(inode, pos, length, &iomap);
13071279
if (ret)
13081280
goto out;
13091281

@@ -1324,28 +1296,47 @@ int gfs2_block_map(struct inode *inode, sector_t lblock,
13241296
return ret;
13251297
}
13261298

1327-
/*
1328-
* Deprecated: do not use in new code
1329-
*/
1330-
int gfs2_extent_map(struct inode *inode, u64 lblock, int *new, u64 *dblock, unsigned *extlen)
1299+
int gfs2_get_extent(struct inode *inode, u64 lblock, u64 *dblock,
1300+
unsigned int *extlen)
13311301
{
1332-
struct buffer_head bh = { .b_state = 0, .b_blocknr = 0 };
1302+
unsigned int blkbits = inode->i_blkbits;
1303+
struct iomap iomap = { };
1304+
unsigned int len;
13331305
int ret;
1334-
int create = *new;
1335-
1336-
BUG_ON(!extlen);
1337-
BUG_ON(!dblock);
1338-
BUG_ON(!new);
1339-
1340-
bh.b_size = BIT(inode->i_blkbits + (create ? 0 : 5));
1341-
ret = gfs2_block_map(inode, lblock, &bh, create);
1342-
*extlen = bh.b_size >> inode->i_blkbits;
1343-
*dblock = bh.b_blocknr;
1344-
if (buffer_new(&bh))
1345-
*new = 1;
1346-
else
1347-
*new = 0;
1348-
return ret;
1306+
1307+
ret = gfs2_iomap_get(inode, lblock << blkbits, *extlen << blkbits,
1308+
&iomap);
1309+
if (ret)
1310+
return ret;
1311+
if (iomap.type != IOMAP_MAPPED)
1312+
return -EIO;
1313+
*dblock = iomap.addr >> blkbits;
1314+
len = iomap.length >> blkbits;
1315+
if (len < *extlen)
1316+
*extlen = len;
1317+
return 0;
1318+
}
1319+
1320+
int gfs2_alloc_extent(struct inode *inode, u64 lblock, u64 *dblock,
1321+
unsigned int *extlen, bool *new)
1322+
{
1323+
unsigned int blkbits = inode->i_blkbits;
1324+
struct iomap iomap = { };
1325+
unsigned int len;
1326+
int ret;
1327+
1328+
ret = gfs2_iomap_alloc(inode, lblock << blkbits, *extlen << blkbits,
1329+
&iomap);
1330+
if (ret)
1331+
return ret;
1332+
if (iomap.type != IOMAP_MAPPED)
1333+
return -EIO;
1334+
*dblock = iomap.addr >> blkbits;
1335+
len = iomap.length >> blkbits;
1336+
if (len < *extlen)
1337+
*extlen = len;
1338+
*new = iomap.flags & IOMAP_F_NEW;
1339+
return 0;
13491340
}
13501341

13511342
/*
@@ -1461,23 +1452,34 @@ static int trunc_start(struct inode *inode, u64 newsize)
14611452
return error;
14621453
}
14631454

1464-
int gfs2_iomap_get_alloc(struct inode *inode, loff_t pos, loff_t length,
1465-
struct iomap *iomap)
1455+
int gfs2_iomap_get(struct inode *inode, loff_t pos, loff_t length,
1456+
struct iomap *iomap)
14661457
{
14671458
struct metapath mp = { .mp_aheight = 1, };
14681459
int ret;
14691460

1470-
ret = gfs2_iomap_get(inode, pos, length, IOMAP_WRITE, iomap, &mp);
1461+
ret = __gfs2_iomap_get(inode, pos, length, 0, iomap, &mp);
1462+
release_metapath(&mp);
1463+
return ret;
1464+
}
1465+
1466+
int gfs2_iomap_alloc(struct inode *inode, loff_t pos, loff_t length,
1467+
struct iomap *iomap)
1468+
{
1469+
struct metapath mp = { .mp_aheight = 1, };
1470+
int ret;
1471+
1472+
ret = __gfs2_iomap_get(inode, pos, length, IOMAP_WRITE, iomap, &mp);
14711473
if (!ret && iomap->type == IOMAP_HOLE)
1472-
ret = gfs2_iomap_alloc(inode, iomap, &mp);
1474+
ret = __gfs2_iomap_alloc(inode, iomap, &mp);
14731475
release_metapath(&mp);
14741476
return ret;
14751477
}
14761478

14771479
/**
14781480
* sweep_bh_for_rgrps - find an rgrp in a meta buffer and free blocks therein
14791481
* @ip: inode
1480-
* @rg_gh: holder of resource group glock
1482+
* @rd_gh: holder of resource group glock
14811483
* @bh: buffer head to sweep
14821484
* @start: starting point in bh
14831485
* @end: end point in bh
@@ -1658,8 +1660,11 @@ static bool mp_eq_to_hgt(struct metapath *mp, __u16 *list, unsigned int h)
16581660

16591661
/**
16601662
* find_nonnull_ptr - find a non-null pointer given a metapath and height
1663+
* @sdp: The superblock
16611664
* @mp: starting metapath
16621665
* @h: desired height to search
1666+
* @end_list: See punch_hole().
1667+
* @end_aligned: See punch_hole().
16631668
*
16641669
* Assumes the metapath is valid (with buffers) out to height h.
16651670
* Returns: true if a non-null pointer was found in the metapath buffer
@@ -2519,7 +2524,6 @@ int __gfs2_punch_hole(struct file *file, loff_t offset, loff_t length)
25192524
static int gfs2_map_blocks(struct iomap_writepage_ctx *wpc, struct inode *inode,
25202525
loff_t offset)
25212526
{
2522-
struct metapath mp = { .mp_aheight = 1, };
25232527
int ret;
25242528

25252529
if (WARN_ON_ONCE(gfs2_is_stuffed(GFS2_I(inode))))
@@ -2530,8 +2534,7 @@ static int gfs2_map_blocks(struct iomap_writepage_ctx *wpc, struct inode *inode,
25302534
return 0;
25312535

25322536
memset(&wpc->iomap, 0, sizeof(wpc->iomap));
2533-
ret = gfs2_iomap_get(inode, offset, INT_MAX, 0, &wpc->iomap, &mp);
2534-
release_metapath(&mp);
2537+
ret = gfs2_iomap_get(inode, offset, INT_MAX, &wpc->iomap);
25352538
return ret;
25362539
}
25372540

fs/gfs2/bmap.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,14 @@ extern const struct iomap_writeback_ops gfs2_writeback_ops;
4949
extern int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page);
5050
extern int gfs2_block_map(struct inode *inode, sector_t lblock,
5151
struct buffer_head *bh, int create);
52-
extern int gfs2_iomap_get_alloc(struct inode *inode, loff_t pos, loff_t length,
53-
struct iomap *iomap);
54-
extern int gfs2_extent_map(struct inode *inode, u64 lblock, int *new,
55-
u64 *dblock, unsigned *extlen);
52+
extern int gfs2_iomap_get(struct inode *inode, loff_t pos, loff_t length,
53+
struct iomap *iomap);
54+
extern int gfs2_iomap_alloc(struct inode *inode, loff_t pos, loff_t length,
55+
struct iomap *iomap);
56+
extern int gfs2_get_extent(struct inode *inode, u64 lblock, u64 *dblock,
57+
unsigned int *extlen);
58+
extern int gfs2_alloc_extent(struct inode *inode, u64 lblock, u64 *dblock,
59+
unsigned *extlen, bool *new);
5660
extern int gfs2_setattr_size(struct inode *inode, u64 size);
5761
extern void gfs2_trim_blocks(struct inode *inode);
5862
extern int gfs2_truncatei_resume(struct gfs2_inode *ip);
@@ -62,6 +66,5 @@ extern int gfs2_write_alloc_required(struct gfs2_inode *ip, u64 offset,
6266
extern int gfs2_map_journal_extents(struct gfs2_sbd *sdp, struct gfs2_jdesc *jd);
6367
extern void gfs2_free_journal_extents(struct gfs2_jdesc *jd);
6468
extern int __gfs2_punch_hole(struct file *file, loff_t offset, loff_t length);
65-
extern int gfs2_lblk_to_dblk(struct inode *inode, u32 lblock, u64 *dblock);
6669

6770
#endif /* __BMAP_DOT_H__ */

0 commit comments

Comments
 (0)