Skip to content

Commit a62aa6f

Browse files
committed
Merge tag 'gfs2-for-5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2
Pull gfs2 updates from Andreas Gruenbacher: - Fix some corner cases on filesystems with a block size < page size. - Fix a corner case that could expose incorrect access times over nfs. - Revert an otherwise sensible revoke accounting cleanup that causes assertion failures. The revoke accounting is whacky and needs to be fixed properly before we can add back this cleanup. - Various other minor cleanups. In addition, please expect to see another pull request from Bob Peterson about his gfs2 recovery patch queue shortly. * tag 'gfs2-for-5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2: Revert "gfs2: eliminate tr_num_revoke_rm" gfs2: remove unused LBIT macros fs/gfs2: remove unused IS_DINODE and IS_LEAF macros gfs2: Remove GFS2_MIN_LVB_SIZE define gfs2: Fix incorrect variable name gfs2: Avoid access time thrashing in gfs2_inode_lookup gfs2: minor cleanup: remove unneeded variable ret in gfs2_jdata_writepage gfs2: eliminate ssize parameter from gfs2_struct2blk gfs2: Another gfs2_find_jhead fix
2 parents 677b60d + a31b4ec commit a62aa6f

File tree

12 files changed

+73
-70
lines changed

12 files changed

+73
-70
lines changed

fs/gfs2/aops.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,12 @@ static int gfs2_jdata_writepage(struct page *page, struct writeback_control *wbc
183183
struct inode *inode = page->mapping->host;
184184
struct gfs2_inode *ip = GFS2_I(inode);
185185
struct gfs2_sbd *sdp = GFS2_SB(inode);
186-
int ret;
187186

188187
if (gfs2_assert_withdraw(sdp, gfs2_glock_is_held_excl(ip->i_gl)))
189188
goto out;
190189
if (PageChecked(page) || current->journal_info)
191190
goto out_ignore;
192-
ret = __gfs2_jdata_writepage(page, wbc);
193-
return ret;
191+
return __gfs2_jdata_writepage(page, wbc);
194192

195193
out_ignore:
196194
redirty_page_for_writepage(wbc, page);

fs/gfs2/dir.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,6 @@
7373
#include "bmap.h"
7474
#include "util.h"
7575

76-
#define IS_LEAF 1 /* Hashed (leaf) directory */
77-
#define IS_DINODE 2 /* Linear (stuffed dinode block) directory */
78-
7976
#define MAX_RA_BLOCKS 32 /* max read-ahead blocks */
8077

8178
#define gfs2_disk_hash2offset(h) (((u64)(h)) >> 1)

fs/gfs2/glock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,
826826
memset(&gl->gl_lksb, 0, sizeof(struct dlm_lksb));
827827

828828
if (glops->go_flags & GLOF_LVB) {
829-
gl->gl_lksb.sb_lvbptr = kzalloc(GFS2_MIN_LVB_SIZE, GFP_NOFS);
829+
gl->gl_lksb.sb_lvbptr = kzalloc(GDLM_LVB_SIZE, GFP_NOFS);
830830
if (!gl->gl_lksb.sb_lvbptr) {
831831
kmem_cache_free(cachep, gl);
832832
return -ENOMEM;

fs/gfs2/glops.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ static void gfs2_ail_empty_gl(struct gfs2_glock *gl)
9595
/* A shortened, inline version of gfs2_trans_begin()
9696
* tr->alloced is not set since the transaction structure is
9797
* on the stack */
98-
tr.tr_reserved = 1 + gfs2_struct2blk(sdp, tr.tr_revokes, sizeof(u64));
98+
tr.tr_reserved = 1 + gfs2_struct2blk(sdp, tr.tr_revokes);
9999
tr.tr_ip = _RET_IP_;
100100
if (gfs2_log_reserve(sdp, tr.tr_reserved) < 0)
101101
return;

fs/gfs2/incore.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,6 @@ struct gfs2_glock {
387387
struct rhash_head gl_node;
388388
};
389389

390-
#define GFS2_MIN_LVB_SIZE 32 /* Min size of LVB that gfs2 supports */
391-
392390
enum {
393391
GIF_INVALID = 0,
394392
GIF_QD_LOCKED = 1,
@@ -505,6 +503,7 @@ struct gfs2_trans {
505503
unsigned int tr_num_buf_rm;
506504
unsigned int tr_num_databuf_rm;
507505
unsigned int tr_num_revoke;
506+
unsigned int tr_num_revoke_rm;
508507

509508
struct list_head tr_list;
510509
struct list_head tr_databuf;
@@ -703,6 +702,7 @@ struct gfs2_sbd {
703702
u32 sd_fsb2bb_shift;
704703
u32 sd_diptrs; /* Number of pointers in a dinode */
705704
u32 sd_inptrs; /* Number of pointers in a indirect block */
705+
u32 sd_ldptrs; /* Number of pointers in a log descriptor block */
706706
u32 sd_jbsize; /* Size of a journaled data block */
707707
u32 sd_hash_bsize; /* sizeof(exhash block) */
708708
u32 sd_hash_bsize_shift;
@@ -803,7 +803,7 @@ struct gfs2_sbd {
803803

804804
struct gfs2_trans *sd_log_tr;
805805
unsigned int sd_log_blks_reserved;
806-
int sd_log_commited_revoke;
806+
int sd_log_committed_revoke;
807807

808808
atomic_t sd_log_pinned;
809809
unsigned int sd_log_num_revoke;

fs/gfs2/inode.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned int type,
136136

137137
if (inode->i_state & I_NEW) {
138138
struct gfs2_sbd *sdp = GFS2_SB(inode);
139-
ip->i_no_formal_ino = no_formal_ino;
140139

141140
error = gfs2_glock_get(sdp, no_addr, &gfs2_inode_glops, CREATE, &ip->i_gl);
142141
if (unlikely(error))
@@ -175,21 +174,22 @@ struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned int type,
175174
gfs2_glock_put(io_gl);
176175
io_gl = NULL;
177176

177+
/* Lowest possible timestamp; will be overwritten in gfs2_dinode_in. */
178+
inode->i_atime.tv_sec = 1LL << (8 * sizeof(inode->i_atime.tv_sec) - 1);
179+
inode->i_atime.tv_nsec = 0;
180+
178181
if (type == DT_UNKNOWN) {
179182
/* Inode glock must be locked already */
180183
error = gfs2_inode_refresh(GFS2_I(inode));
181184
if (error)
182185
goto fail_refresh;
183186
} else {
187+
ip->i_no_formal_ino = no_formal_ino;
184188
inode->i_mode = DT2IF(type);
185189
}
186190

187191
gfs2_set_iop(inode);
188192

189-
/* Lowest possible timestamp; will be overwritten in gfs2_dinode_in. */
190-
inode->i_atime.tv_sec = 1LL << (8 * sizeof(inode->i_atime.tv_sec) - 1);
191-
inode->i_atime.tv_nsec = 0;
192-
193193
unlock_new_inode(inode);
194194
}
195195

fs/gfs2/log.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,23 @@ static void gfs2_log_shutdown(struct gfs2_sbd *sdp);
3737
* gfs2_struct2blk - compute stuff
3838
* @sdp: the filesystem
3939
* @nstruct: the number of structures
40-
* @ssize: the size of the structures
4140
*
4241
* Compute the number of log descriptor blocks needed to hold a certain number
4342
* of structures of a certain size.
4443
*
4544
* Returns: the number of blocks needed (minimum is always 1)
4645
*/
4746

48-
unsigned int gfs2_struct2blk(struct gfs2_sbd *sdp, unsigned int nstruct,
49-
unsigned int ssize)
47+
unsigned int gfs2_struct2blk(struct gfs2_sbd *sdp, unsigned int nstruct)
5048
{
5149
unsigned int blks;
5250
unsigned int first, second;
5351

5452
blks = 1;
55-
first = (sdp->sd_sb.sb_bsize - sizeof(struct gfs2_log_descriptor)) / ssize;
53+
first = sdp->sd_ldptrs;
5654

5755
if (nstruct > first) {
58-
second = (sdp->sd_sb.sb_bsize -
59-
sizeof(struct gfs2_meta_header)) / ssize;
56+
second = sdp->sd_inptrs;
6057
blks += DIV_ROUND_UP(nstruct - first, second);
6158
}
6259

@@ -472,9 +469,8 @@ static unsigned int calc_reserved(struct gfs2_sbd *sdp)
472469
reserved += DIV_ROUND_UP(dbuf, databuf_limit(sdp));
473470
}
474471

475-
if (sdp->sd_log_commited_revoke > 0)
476-
reserved += gfs2_struct2blk(sdp, sdp->sd_log_commited_revoke,
477-
sizeof(u64));
472+
if (sdp->sd_log_committed_revoke > 0)
473+
reserved += gfs2_struct2blk(sdp, sdp->sd_log_committed_revoke);
478474
/* One for the overall header */
479475
if (reserved)
480476
reserved++;
@@ -829,7 +825,7 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, u32 flags)
829825
if (unlikely(state == SFS_FROZEN))
830826
gfs2_assert_withdraw(sdp, !sdp->sd_log_num_revoke);
831827
gfs2_assert_withdraw(sdp,
832-
sdp->sd_log_num_revoke == sdp->sd_log_commited_revoke);
828+
sdp->sd_log_num_revoke == sdp->sd_log_committed_revoke);
833829

834830
gfs2_ordered_write(sdp);
835831
lops_before_commit(sdp, tr);
@@ -848,7 +844,7 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, u32 flags)
848844
gfs2_log_lock(sdp);
849845
sdp->sd_log_head = sdp->sd_log_flush_head;
850846
sdp->sd_log_blks_reserved = 0;
851-
sdp->sd_log_commited_revoke = 0;
847+
sdp->sd_log_committed_revoke = 0;
852848

853849
spin_lock(&sdp->sd_ail_lock);
854850
if (tr && !list_empty(&tr->tr_ail1_list)) {
@@ -899,6 +895,7 @@ static void gfs2_merge_trans(struct gfs2_trans *old, struct gfs2_trans *new)
899895
old->tr_num_buf_rm += new->tr_num_buf_rm;
900896
old->tr_num_databuf_rm += new->tr_num_databuf_rm;
901897
old->tr_num_revoke += new->tr_num_revoke;
898+
old->tr_num_revoke_rm += new->tr_num_revoke_rm;
902899

903900
list_splice_tail_init(&new->tr_databuf, &old->tr_databuf);
904901
list_splice_tail_init(&new->tr_buf, &old->tr_buf);
@@ -920,7 +917,7 @@ static void log_refund(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
920917
set_bit(TR_ATTACHED, &tr->tr_flags);
921918
}
922919

923-
sdp->sd_log_commited_revoke += tr->tr_num_revoke;
920+
sdp->sd_log_committed_revoke += tr->tr_num_revoke - tr->tr_num_revoke_rm;
924921
reserved = calc_reserved(sdp);
925922
maxres = sdp->sd_log_blks_reserved + tr->tr_reserved;
926923
gfs2_assert_withdraw(sdp, maxres >= reserved);

fs/gfs2/log.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ static inline void gfs2_ordered_add_inode(struct gfs2_inode *ip)
6060
spin_unlock(&sdp->sd_ordered_lock);
6161
}
6262
}
63+
6364
extern void gfs2_ordered_del_inode(struct gfs2_inode *ip);
64-
extern unsigned int gfs2_struct2blk(struct gfs2_sbd *sdp, unsigned int nstruct,
65-
unsigned int ssize);
65+
extern unsigned int gfs2_struct2blk(struct gfs2_sbd *sdp, unsigned int nstruct);
6666

6767
extern void gfs2_log_release(struct gfs2_sbd *sdp, unsigned int blks);
6868
extern int gfs2_log_reserve(struct gfs2_sbd *sdp, unsigned int blks);

fs/gfs2/lops.c

Lines changed: 45 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ static struct bio *gfs2_log_alloc_bio(struct gfs2_sbd *sdp, u64 blkno,
259259
struct super_block *sb = sdp->sd_vfs;
260260
struct bio *bio = bio_alloc(GFP_NOIO, BIO_MAX_PAGES);
261261

262-
bio->bi_iter.bi_sector = blkno * (sb->s_blocksize >> 9);
262+
bio->bi_iter.bi_sector = blkno << (sb->s_blocksize_bits - 9);
263263
bio_set_dev(bio, sb->s_bdev);
264264
bio->bi_end_io = end_io;
265265
bio->bi_private = sdp;
@@ -472,6 +472,20 @@ static void gfs2_jhead_process_page(struct gfs2_jdesc *jd, unsigned long index,
472472
put_page(page); /* Once more for find_or_create_page */
473473
}
474474

475+
static struct bio *gfs2_chain_bio(struct bio *prev, unsigned int nr_iovecs)
476+
{
477+
struct bio *new;
478+
479+
new = bio_alloc(GFP_NOIO, nr_iovecs);
480+
bio_copy_dev(new, prev);
481+
new->bi_iter.bi_sector = bio_end_sector(prev);
482+
new->bi_opf = prev->bi_opf;
483+
new->bi_write_hint = prev->bi_write_hint;
484+
bio_chain(new, prev);
485+
submit_bio(prev);
486+
return new;
487+
}
488+
475489
/**
476490
* gfs2_find_jhead - find the head of a log
477491
* @jd: The journal descriptor
@@ -488,15 +502,15 @@ int gfs2_find_jhead(struct gfs2_jdesc *jd, struct gfs2_log_header_host *head,
488502
struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
489503
struct address_space *mapping = jd->jd_inode->i_mapping;
490504
unsigned int block = 0, blocks_submitted = 0, blocks_read = 0;
491-
unsigned int bsize = sdp->sd_sb.sb_bsize;
505+
unsigned int bsize = sdp->sd_sb.sb_bsize, off;
492506
unsigned int bsize_shift = sdp->sd_sb.sb_bsize_shift;
493507
unsigned int shift = PAGE_SHIFT - bsize_shift;
494-
unsigned int readhead_blocks = BIO_MAX_PAGES << shift;
508+
unsigned int readahead_blocks = BIO_MAX_PAGES << shift;
495509
struct gfs2_journal_extent *je;
496510
int sz, ret = 0;
497511
struct bio *bio = NULL;
498512
struct page *page = NULL;
499-
bool done = false;
513+
bool bio_chained = false, done = false;
500514
errseq_t since;
501515

502516
memset(head, 0, sizeof(*head));
@@ -505,9 +519,9 @@ int gfs2_find_jhead(struct gfs2_jdesc *jd, struct gfs2_log_header_host *head,
505519

506520
since = filemap_sample_wb_err(mapping);
507521
list_for_each_entry(je, &jd->extent_list, list) {
508-
for (; block < je->lblock + je->blocks; block++) {
509-
u64 dblock;
522+
u64 dblock = je->dblock;
510523

524+
for (; block < je->lblock + je->blocks; block++, dblock++) {
511525
if (!page) {
512526
page = find_or_create_page(mapping,
513527
block >> shift, GFP_NOFS);
@@ -516,35 +530,41 @@ int gfs2_find_jhead(struct gfs2_jdesc *jd, struct gfs2_log_header_host *head,
516530
done = true;
517531
goto out;
518532
}
533+
off = 0;
519534
}
520535

521-
if (bio) {
522-
unsigned int off;
523-
524-
off = (block << bsize_shift) & ~PAGE_MASK;
536+
if (!bio || (bio_chained && !off)) {
537+
/* start new bio */
538+
} else {
525539
sz = bio_add_page(bio, page, bsize, off);
526-
if (sz == bsize) { /* block added */
527-
if (off + bsize == PAGE_SIZE) {
528-
page = NULL;
529-
goto page_added;
530-
}
531-
continue;
540+
if (sz == bsize)
541+
goto block_added;
542+
if (off) {
543+
unsigned int blocks =
544+
(PAGE_SIZE - off) >> bsize_shift;
545+
546+
bio = gfs2_chain_bio(bio, blocks);
547+
bio_chained = true;
548+
goto add_block_to_new_bio;
532549
}
550+
}
551+
552+
if (bio) {
533553
blocks_submitted = block + 1;
534554
submit_bio(bio);
535-
bio = NULL;
536555
}
537556

538-
dblock = je->dblock + (block - je->lblock);
539557
bio = gfs2_log_alloc_bio(sdp, dblock, gfs2_end_log_read);
540558
bio->bi_opf = REQ_OP_READ;
541-
sz = bio_add_page(bio, page, bsize, 0);
542-
gfs2_assert_warn(sdp, sz == bsize);
543-
if (bsize == PAGE_SIZE)
559+
bio_chained = false;
560+
add_block_to_new_bio:
561+
sz = bio_add_page(bio, page, bsize, off);
562+
BUG_ON(sz != bsize);
563+
block_added:
564+
off += bsize;
565+
if (off == PAGE_SIZE)
544566
page = NULL;
545-
546-
page_added:
547-
if (blocks_submitted < blocks_read + readhead_blocks) {
567+
if (blocks_submitted < blocks_read + readahead_blocks) {
548568
/* Keep at least one bio in flight */
549569
continue;
550570
}
@@ -846,7 +866,7 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
846866
if (!sdp->sd_log_num_revoke)
847867
return;
848868

849-
length = gfs2_struct2blk(sdp, sdp->sd_log_num_revoke, sizeof(u64));
869+
length = gfs2_struct2blk(sdp, sdp->sd_log_num_revoke);
850870
page = gfs2_get_log_desc(sdp, GFS2_LOG_DESC_REVOKE, length, sdp->sd_log_num_revoke);
851871
offset = sizeof(struct gfs2_log_descriptor);
852872

fs/gfs2/ops_fstype.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,8 @@ static int gfs2_read_sb(struct gfs2_sbd *sdp, int silent)
298298
sizeof(struct gfs2_dinode)) / sizeof(u64);
299299
sdp->sd_inptrs = (sdp->sd_sb.sb_bsize -
300300
sizeof(struct gfs2_meta_header)) / sizeof(u64);
301+
sdp->sd_ldptrs = (sdp->sd_sb.sb_bsize -
302+
sizeof(struct gfs2_log_descriptor)) / sizeof(u64);
301303
sdp->sd_jbsize = sdp->sd_sb.sb_bsize - sizeof(struct gfs2_meta_header);
302304
sdp->sd_hash_bsize = sdp->sd_sb.sb_bsize / 2;
303305
sdp->sd_hash_bsize_shift = sdp->sd_sb.sb_bsize_shift - 1;

0 commit comments

Comments
 (0)