Skip to content

Commit 018d21f

Browse files
committed
Merge tag 'gfs2-for-5.7' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2
Pull gfs2 updates from Bob Peterson: "We've got a lot of patches (39) for this merge window. Most of these patches are related to corruption that occurs when journals are replayed. For example: 1. A node fails while writing to the file system. 2. Other nodes use the metadata that was once used by the failed node. 3. When the node returns to the cluster, its journal is replayed, but the older metadata blocks overwrite the changes from step 2. Summary: - Fixed the recovery sequence to prevent corruption during journal replay. - Many bug fixes found during recovery testing. - New improved file system withdraw sequence. - Fixed how resource group buffers are managed. - Fixed how metadata revokes are tracked and written. - Improve processing of IO errors hit by daemons like logd and quotad. - Improved error checking in metadata writes. - Fixed how qadata quota data structures are managed" * tag 'gfs2-for-5.7' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2: (39 commits) gfs2: Fix oversight in gfs2_ail1_flush gfs2: change from write to read lock for sd_log_flush_lock in journal replay gfs2: instrumentation wrt ail1 stuck gfs2: don't lock sd_log_flush_lock in try_rgrp_unlink gfs2: Remove unnecessary gfs2_qa_{get,put} pairs gfs2: Split gfs2_rsqa_delete into gfs2_rs_delete and gfs2_qa_put gfs2: Change inode qa_data to allow multiple users gfs2: eliminate gfs2_rsqa_alloc in favor of gfs2_qa_alloc gfs2: Switch to list_{first,last}_entry gfs2: Clean up inode initialization and teardown gfs2: Additional information when gfs2_ail1_flush withdraws gfs2: leaf_dealloc needs to allocate one more revoke gfs2: allow journal replay to hold sd_log_flush_lock gfs2: don't allow releasepage to free bd still used for revokes gfs2: flesh out delayed withdraw for gfs2_log_flush gfs2: Do proper error checking for go_sync family of glops functions gfs2: Don't demote a glock until its revokes are written gfs2: drain the ail2 list after io errors gfs2: Withdraw in gfs2_ail1_flush if write_cache_pages fails gfs2: Do log_flush in gfs2_ail_empty_gl even if ail list is empty ...
2 parents 15c981d + 75b46c4 commit 018d21f

27 files changed

+1168
-509
lines changed

fs/gfs2/acl.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "glock.h"
2222
#include "inode.h"
2323
#include "meta_io.h"
24+
#include "quota.h"
2425
#include "rgrp.h"
2526
#include "trans.h"
2627
#include "util.h"
@@ -116,14 +117,14 @@ int gfs2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
116117
if (acl && acl->a_count > GFS2_ACL_MAX_ENTRIES(GFS2_SB(inode)))
117118
return -E2BIG;
118119

119-
ret = gfs2_rsqa_alloc(ip);
120+
ret = gfs2_qa_get(ip);
120121
if (ret)
121122
return ret;
122123

123124
if (!gfs2_glock_is_locked_by_me(ip->i_gl)) {
124125
ret = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
125126
if (ret)
126-
return ret;
127+
goto out;
127128
need_unlock = true;
128129
}
129130

@@ -143,5 +144,7 @@ int gfs2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
143144
unlock:
144145
if (need_unlock)
145146
gfs2_glock_dq_uninit(&gh);
147+
out:
148+
gfs2_qa_put(ip);
146149
return ret;
147150
}

fs/gfs2/aops.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -805,11 +805,16 @@ int gfs2_releasepage(struct page *page, gfp_t gfp_mask)
805805
bd = bh->b_private;
806806
if (bd) {
807807
gfs2_assert_warn(sdp, bd->bd_bh == bh);
808-
if (!list_empty(&bd->bd_list))
809-
list_del_init(&bd->bd_list);
810808
bd->bd_bh = NULL;
811809
bh->b_private = NULL;
812-
kmem_cache_free(gfs2_bufdata_cachep, bd);
810+
/*
811+
* The bd may still be queued as a revoke, in which
812+
* case we must not dequeue nor free it.
813+
*/
814+
if (!bd->bd_blkno && !list_empty(&bd->bd_list))
815+
list_del_init(&bd->bd_list);
816+
if (list_empty(&bd->bd_list))
817+
kmem_cache_free(gfs2_bufdata_cachep, bd);
813818
}
814819

815820
bh = bh->b_this_page;

fs/gfs2/bmap.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2183,7 +2183,7 @@ int gfs2_setattr_size(struct inode *inode, u64 newsize)
21832183

21842184
inode_dio_wait(inode);
21852185

2186-
ret = gfs2_rsqa_alloc(ip);
2186+
ret = gfs2_qa_get(ip);
21872187
if (ret)
21882188
goto out;
21892189

@@ -2194,7 +2194,8 @@ int gfs2_setattr_size(struct inode *inode, u64 newsize)
21942194

21952195
ret = do_shrink(inode, newsize);
21962196
out:
2197-
gfs2_rsqa_delete(ip, NULL);
2197+
gfs2_rs_delete(ip, NULL);
2198+
gfs2_qa_put(ip);
21982199
return ret;
21992200
}
22002201

@@ -2223,7 +2224,7 @@ void gfs2_free_journal_extents(struct gfs2_jdesc *jd)
22232224
struct gfs2_journal_extent *jext;
22242225

22252226
while(!list_empty(&jd->extent_list)) {
2226-
jext = list_entry(jd->extent_list.next, struct gfs2_journal_extent, list);
2227+
jext = list_first_entry(&jd->extent_list, struct gfs2_journal_extent, list);
22272228
list_del(&jext->list);
22282229
kfree(jext);
22292230
}
@@ -2244,7 +2245,7 @@ static int gfs2_add_jextent(struct gfs2_jdesc *jd, u64 lblock, u64 dblock, u64 b
22442245
struct gfs2_journal_extent *jext;
22452246

22462247
if (!list_empty(&jd->extent_list)) {
2247-
jext = list_entry(jd->extent_list.prev, struct gfs2_journal_extent, list);
2248+
jext = list_last_entry(&jd->extent_list, struct gfs2_journal_extent, list);
22482249
if ((jext->dblock + jext->blocks) == dblock) {
22492250
jext->blocks += blocks;
22502251
return 0;

fs/gfs2/dir.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2028,7 +2028,8 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len,
20282028

20292029
error = gfs2_trans_begin(sdp,
20302030
rg_blocks + (DIV_ROUND_UP(size, sdp->sd_jbsize) + 1) +
2031-
RES_DINODE + RES_STATFS + RES_QUOTA, l_blocks);
2031+
RES_DINODE + RES_STATFS + RES_QUOTA, RES_DINODE +
2032+
l_blocks);
20322033
if (error)
20332034
goto out_rg_gunlock;
20342035

fs/gfs2/file.c

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -458,10 +458,6 @@ static vm_fault_t gfs2_page_mkwrite(struct vm_fault *vmf)
458458

459459
sb_start_pagefault(inode->i_sb);
460460

461-
ret = gfs2_rsqa_alloc(ip);
462-
if (ret)
463-
goto out;
464-
465461
gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
466462
ret = gfs2_glock_nq(&gh);
467463
if (ret)
@@ -558,7 +554,6 @@ static vm_fault_t gfs2_page_mkwrite(struct vm_fault *vmf)
558554
set_page_dirty(page);
559555
wait_for_stable_page(page);
560556
}
561-
out:
562557
sb_end_pagefault(inode->i_sb);
563558
return block_page_mkwrite_return(ret);
564559
}
@@ -635,7 +630,17 @@ int gfs2_open_common(struct inode *inode, struct file *file)
635630

636631
gfs2_assert_warn(GFS2_SB(inode), !file->private_data);
637632
file->private_data = fp;
633+
if (file->f_mode & FMODE_WRITE) {
634+
ret = gfs2_qa_get(GFS2_I(inode));
635+
if (ret)
636+
goto fail;
637+
}
638638
return 0;
639+
640+
fail:
641+
kfree(file->private_data);
642+
file->private_data = NULL;
643+
return ret;
639644
}
640645

641646
/**
@@ -690,10 +695,10 @@ static int gfs2_release(struct inode *inode, struct file *file)
690695
kfree(file->private_data);
691696
file->private_data = NULL;
692697

693-
if (!(file->f_mode & FMODE_WRITE))
694-
return 0;
695-
696-
gfs2_rsqa_delete(ip, &inode->i_writecount);
698+
if (file->f_mode & FMODE_WRITE) {
699+
gfs2_rs_delete(ip, &inode->i_writecount);
700+
gfs2_qa_put(ip);
701+
}
697702
return 0;
698703
}
699704

@@ -849,10 +854,6 @@ static ssize_t gfs2_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
849854
struct gfs2_inode *ip = GFS2_I(inode);
850855
ssize_t ret;
851856

852-
ret = gfs2_rsqa_alloc(ip);
853-
if (ret)
854-
return ret;
855-
856857
gfs2_size_hint(file, iocb->ki_pos, iov_iter_count(from));
857858

858859
if (iocb->ki_flags & IOCB_APPEND) {
@@ -1149,17 +1150,11 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset, loff_t le
11491150
if (mode & FALLOC_FL_PUNCH_HOLE) {
11501151
ret = __gfs2_punch_hole(file, offset, len);
11511152
} else {
1152-
ret = gfs2_rsqa_alloc(ip);
1153-
if (ret)
1154-
goto out_putw;
1155-
11561153
ret = __gfs2_fallocate(file, mode, offset, len);
1157-
11581154
if (ret)
11591155
gfs2_rs_deltree(&ip->i_res);
11601156
}
11611157

1162-
out_putw:
11631158
put_write_access(inode);
11641159
out_unlock:
11651160
gfs2_glock_dq(&gh);
@@ -1173,16 +1168,12 @@ static ssize_t gfs2_file_splice_write(struct pipe_inode_info *pipe,
11731168
struct file *out, loff_t *ppos,
11741169
size_t len, unsigned int flags)
11751170
{
1176-
int error;
1177-
struct gfs2_inode *ip = GFS2_I(out->f_mapping->host);
1178-
1179-
error = gfs2_rsqa_alloc(ip);
1180-
if (error)
1181-
return (ssize_t)error;
1171+
ssize_t ret;
11821172

11831173
gfs2_size_hint(out, *ppos, len);
11841174

1185-
return iter_file_splice_write(pipe, out, ppos, len, flags);
1175+
ret = iter_file_splice_write(pipe, out, ppos, len, flags);
1176+
return ret;
11861177
}
11871178

11881179
#ifdef CONFIG_GFS2_FS_LOCKING_DLM

0 commit comments

Comments
 (0)