gfs2: eliminate ssize parameter from gfs2_struct2blk

Every caller of function gfs2_struct2blk specified sizeof(u64).

This patch eliminates the unnecessary parameter and replaces the
size calculation with a new superblock variable that is computed
to be the maximum number of block pointers we can fit inside a
log descriptor, as is done for pointers per dinode and indirect
block.

Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Reviewed-by: Andrew Price <anprice@redhat.com>
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
This commit is contained in:
Bob Peterson 2019-12-13 08:10:51 -06:00 коммит произвёл Andreas Gruenbacher
Родитель eed0f953b9
Коммит 2e9eeaa117
7 изменённых файлов: 12 добавлений и 14 удалений

Просмотреть файл

@ -95,7 +95,7 @@ static void gfs2_ail_empty_gl(struct gfs2_glock *gl)
/* A shortened, inline version of gfs2_trans_begin() /* A shortened, inline version of gfs2_trans_begin()
* tr->alloced is not set since the transaction structure is * tr->alloced is not set since the transaction structure is
* on the stack */ * on the stack */
tr.tr_reserved = 1 + gfs2_struct2blk(sdp, tr.tr_revokes, sizeof(u64)); tr.tr_reserved = 1 + gfs2_struct2blk(sdp, tr.tr_revokes);
tr.tr_ip = _RET_IP_; tr.tr_ip = _RET_IP_;
if (gfs2_log_reserve(sdp, tr.tr_reserved) < 0) if (gfs2_log_reserve(sdp, tr.tr_reserved) < 0)
return; return;

Просмотреть файл

@ -703,6 +703,7 @@ struct gfs2_sbd {
u32 sd_fsb2bb_shift; u32 sd_fsb2bb_shift;
u32 sd_diptrs; /* Number of pointers in a dinode */ u32 sd_diptrs; /* Number of pointers in a dinode */
u32 sd_inptrs; /* Number of pointers in a indirect block */ u32 sd_inptrs; /* Number of pointers in a indirect block */
u32 sd_ldptrs; /* Number of pointers in a log descriptor block */
u32 sd_jbsize; /* Size of a journaled data block */ u32 sd_jbsize; /* Size of a journaled data block */
u32 sd_hash_bsize; /* sizeof(exhash block) */ u32 sd_hash_bsize; /* sizeof(exhash block) */
u32 sd_hash_bsize_shift; u32 sd_hash_bsize_shift;

Просмотреть файл

@ -37,7 +37,6 @@ static void gfs2_log_shutdown(struct gfs2_sbd *sdp);
* gfs2_struct2blk - compute stuff * gfs2_struct2blk - compute stuff
* @sdp: the filesystem * @sdp: the filesystem
* @nstruct: the number of structures * @nstruct: the number of structures
* @ssize: the size of the structures
* *
* Compute the number of log descriptor blocks needed to hold a certain number * Compute the number of log descriptor blocks needed to hold a certain number
* of structures of a certain size. * of structures of a certain size.
@ -45,18 +44,16 @@ static void gfs2_log_shutdown(struct gfs2_sbd *sdp);
* Returns: the number of blocks needed (minimum is always 1) * Returns: the number of blocks needed (minimum is always 1)
*/ */
unsigned int gfs2_struct2blk(struct gfs2_sbd *sdp, unsigned int nstruct, unsigned int gfs2_struct2blk(struct gfs2_sbd *sdp, unsigned int nstruct)
unsigned int ssize)
{ {
unsigned int blks; unsigned int blks;
unsigned int first, second; unsigned int first, second;
blks = 1; blks = 1;
first = (sdp->sd_sb.sb_bsize - sizeof(struct gfs2_log_descriptor)) / ssize; first = sdp->sd_ldptrs;
if (nstruct > first) { if (nstruct > first) {
second = (sdp->sd_sb.sb_bsize - second = sdp->sd_inptrs;
sizeof(struct gfs2_meta_header)) / ssize;
blks += DIV_ROUND_UP(nstruct - first, second); blks += DIV_ROUND_UP(nstruct - first, second);
} }
@ -473,8 +470,7 @@ static unsigned int calc_reserved(struct gfs2_sbd *sdp)
} }
if (sdp->sd_log_commited_revoke > 0) if (sdp->sd_log_commited_revoke > 0)
reserved += gfs2_struct2blk(sdp, sdp->sd_log_commited_revoke, reserved += gfs2_struct2blk(sdp, sdp->sd_log_commited_revoke);
sizeof(u64));
/* One for the overall header */ /* One for the overall header */
if (reserved) if (reserved)
reserved++; reserved++;

Просмотреть файл

@ -60,9 +60,9 @@ static inline void gfs2_ordered_add_inode(struct gfs2_inode *ip)
spin_unlock(&sdp->sd_ordered_lock); spin_unlock(&sdp->sd_ordered_lock);
} }
} }
extern void gfs2_ordered_del_inode(struct gfs2_inode *ip); extern void gfs2_ordered_del_inode(struct gfs2_inode *ip);
extern unsigned int gfs2_struct2blk(struct gfs2_sbd *sdp, unsigned int nstruct, extern unsigned int gfs2_struct2blk(struct gfs2_sbd *sdp, unsigned int nstruct);
unsigned int ssize);
extern void gfs2_log_release(struct gfs2_sbd *sdp, unsigned int blks); extern void gfs2_log_release(struct gfs2_sbd *sdp, unsigned int blks);
extern int gfs2_log_reserve(struct gfs2_sbd *sdp, unsigned int blks); extern int gfs2_log_reserve(struct gfs2_sbd *sdp, unsigned int blks);

Просмотреть файл

@ -866,7 +866,7 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
if (!sdp->sd_log_num_revoke) if (!sdp->sd_log_num_revoke)
return; return;
length = gfs2_struct2blk(sdp, sdp->sd_log_num_revoke, sizeof(u64)); length = gfs2_struct2blk(sdp, sdp->sd_log_num_revoke);
page = gfs2_get_log_desc(sdp, GFS2_LOG_DESC_REVOKE, length, sdp->sd_log_num_revoke); page = gfs2_get_log_desc(sdp, GFS2_LOG_DESC_REVOKE, length, sdp->sd_log_num_revoke);
offset = sizeof(struct gfs2_log_descriptor); offset = sizeof(struct gfs2_log_descriptor);

Просмотреть файл

@ -298,6 +298,8 @@ static int gfs2_read_sb(struct gfs2_sbd *sdp, int silent)
sizeof(struct gfs2_dinode)) / sizeof(u64); sizeof(struct gfs2_dinode)) / sizeof(u64);
sdp->sd_inptrs = (sdp->sd_sb.sb_bsize - sdp->sd_inptrs = (sdp->sd_sb.sb_bsize -
sizeof(struct gfs2_meta_header)) / sizeof(u64); sizeof(struct gfs2_meta_header)) / sizeof(u64);
sdp->sd_ldptrs = (sdp->sd_sb.sb_bsize -
sizeof(struct gfs2_log_descriptor)) / sizeof(u64);
sdp->sd_jbsize = sdp->sd_sb.sb_bsize - sizeof(struct gfs2_meta_header); sdp->sd_jbsize = sdp->sd_sb.sb_bsize - sizeof(struct gfs2_meta_header);
sdp->sd_hash_bsize = sdp->sd_sb.sb_bsize / 2; sdp->sd_hash_bsize = sdp->sd_sb.sb_bsize / 2;
sdp->sd_hash_bsize_shift = sdp->sd_sb.sb_bsize_shift - 1; sdp->sd_hash_bsize_shift = sdp->sd_sb.sb_bsize_shift - 1;

Просмотреть файл

@ -49,8 +49,7 @@ int gfs2_trans_begin(struct gfs2_sbd *sdp, unsigned int blocks,
if (blocks) if (blocks)
tr->tr_reserved += 6 + blocks; tr->tr_reserved += 6 + blocks;
if (revokes) if (revokes)
tr->tr_reserved += gfs2_struct2blk(sdp, revokes, tr->tr_reserved += gfs2_struct2blk(sdp, revokes);
sizeof(u64));
INIT_LIST_HEAD(&tr->tr_databuf); INIT_LIST_HEAD(&tr->tr_databuf);
INIT_LIST_HEAD(&tr->tr_buf); INIT_LIST_HEAD(&tr->tr_buf);