Skip to content

Commit 26064ea

Browse files
committed
Merge tag 'gfs2-4.16.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2
Pull GFS2 updates from Bob Peterson: "We've got 30 patches for this merge window. These generally fall into five categories: - code cleanups - patches related to adding PUNCH_HOLE support to GFS2 - support for new fields in resource group headers - a few bug fixes - support for new fields in journal log headers. These new fields, which were previously unused, are designed to make it easier to track down file system corruption, and allow fsck.gfs2 to make more intelligent decisions when finding and fixing file system corruption. Details: - Two patches from Abhi Das, to trim the ordered writes list, which used to grow uncontrollably until unmount. - Several patches from Andreas Gruenbacher: remove an unused parameter from function gfs2_write_jdata_pagevec, remove a pointless BUG_ON, clean up an error patch in trunc_start, remove some unused parameters from truncate, make gfs2_journaled_truncate more efficient, clean up the support functions for truncate, fix metadata read-ahead for truncate to make it faster, fix up the non-recursive truncate code, rework and rename gfs2_block_truncate_page, generalize the non-recursive truncate code so it can take a range of values for punch_hole support, introduce new PUNCH_HOLE support that take advantage of the previous patches, add fallocate support with PUNCH_HOLE, fix some typos in the comments, add the function gfs2_max_stuffed_size to replace a piece of code that was needlessly repeated throughout GFS2, a minor cleanup to function gfs2_page_add_databufs, get rid of function gfs2_log_header_in in preparation for the new log header fields, and also fix up some missing newlines in kernel messages. - Andy Price added a new field to resource groups to indicate where the next one should be, to allow fsck.gfs2 to make better repairs. He also added new rindex fields for consistency checking, and added a crc field to resource group headers for consistency checking. - I reduced redundancy in functions common to freeing dinodes, and when writing log headers between the journalling code and journal recovery code. Also added new fields to journal log headers based on a prototype from Steve Whitehouse, and log the source of journal log headers so we can better track down journal corruption. Minor comment typo fix and a fix for a BUG in an unlink error path. - Steve Whitehouse contributed a patch to fix an incorrect use of the gfs2_blk2rgrpd function. - Tetsuo Handa contributed a patch that fixes incorrect error handling in function init_gfs2_fs" * tag 'gfs2-4.16.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2: (30 commits) gfs2: Add a few missing newlines in messages gfs2: Remove inode from ordered write list in gfs2_write_inode() GFS2: Don't try to end a non-existent transaction in unlink GFS2: Fix minor comment typo GFS2: Log the reason for log flushes in every log header GFS2: Introduce new gfs2_log_header_v2 gfs2: Get rid of gfs2_log_header_in gfs2: Minor gfs2_page_add_databufs cleanup gfs2: Add gfs2_max_stuffed_size gfs2: Typo fixes gfs2: Implement fallocate(FALLOC_FL_PUNCH_HOLE) gfs2: Turn trunc_dealloc into punch_hole gfs2: Generalize truncate code Turn gfs2_block_truncate_page into gfs2_block_zero_range gfs2: Improve non-recursive delete algorithm gfs2: Fix metadata read-ahead during truncate gfs2: Clean up {lookup,fillup}_metapath gfs2: Remove minor gfs2_journaled_truncate inefficiencies gfs2: truncate: Remove unnecessary oldsize parameters gfs2: Clean up trunc_start error path ...
2 parents c9cc8d0 + af38816 commit 26064ea

24 files changed

Lines changed: 758 additions & 427 deletions

‎fs/gfs2/Kconfig‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ config GFS2_FS
33
depends on (64BIT || LBDAF)
44
select FS_POSIX_ACL
55
select CRC32
6+
select CRYPTO
7+
select CRYPTO_CRC32C
68
select QUOTACTL
79
select FS_IOMAP
810
help

‎fs/gfs2/aops.c‎

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,21 @@
3939

4040

4141
static void gfs2_page_add_databufs(struct gfs2_inode *ip, struct page *page,
42-
unsigned int from, unsigned int to)
42+
unsigned int from, unsigned int len)
4343
{
4444
struct buffer_head *head = page_buffers(page);
4545
unsigned int bsize = head->b_size;
4646
struct buffer_head *bh;
47+
unsigned int to = from + len;
4748
unsigned int start, end;
4849

4950
for (bh = head, start = 0; bh != head || !start;
5051
bh = bh->b_this_page, start = end) {
5152
end = start + bsize;
52-
if (end <= from || start >= to)
53+
if (end <= from)
5354
continue;
55+
if (start >= to)
56+
break;
5457
if (gfs2_is_jdata(ip))
5558
set_buffer_uptodate(bh);
5659
gfs2_trans_add_data(ip->i_gl, bh);
@@ -189,7 +192,7 @@ static int __gfs2_jdata_writepage(struct page *page, struct writeback_control *w
189192
create_empty_buffers(page, inode->i_sb->s_blocksize,
190193
BIT(BH_Dirty)|BIT(BH_Uptodate));
191194
}
192-
gfs2_page_add_databufs(ip, page, 0, sdp->sd_vfs->s_blocksize-1);
195+
gfs2_page_add_databufs(ip, page, 0, sdp->sd_vfs->s_blocksize);
193196
}
194197
return gfs2_write_full_page(page, gfs2_get_block_noalloc, wbc);
195198
}
@@ -255,7 +258,6 @@ static int gfs2_writepages(struct address_space *mapping,
255258
* @wbc: The writeback control
256259
* @pvec: The vector of pages
257260
* @nr_pages: The number of pages to write
258-
* @end: End position
259261
* @done_index: Page index
260262
*
261263
* Returns: non-zero if loop should terminate, zero otherwise
@@ -264,7 +266,7 @@ static int gfs2_writepages(struct address_space *mapping,
264266
static int gfs2_write_jdata_pagevec(struct address_space *mapping,
265267
struct writeback_control *wbc,
266268
struct pagevec *pvec,
267-
int nr_pages, pgoff_t end,
269+
int nr_pages,
268270
pgoff_t *done_index)
269271
{
270272
struct inode *inode = mapping->host;
@@ -402,7 +404,7 @@ static int gfs2_write_cache_jdata(struct address_space *mapping,
402404
if (nr_pages == 0)
403405
break;
404406

405-
ret = gfs2_write_jdata_pagevec(mapping, wbc, &pvec, nr_pages, end, &done_index);
407+
ret = gfs2_write_jdata_pagevec(mapping, wbc, &pvec, nr_pages, &done_index);
406408
if (ret)
407409
done = 1;
408410
if (ret > 0)
@@ -446,7 +448,8 @@ static int gfs2_jdata_writepages(struct address_space *mapping,
446448

447449
ret = gfs2_write_cache_jdata(mapping, wbc);
448450
if (ret == 0 && wbc->sync_mode == WB_SYNC_ALL) {
449-
gfs2_log_flush(sdp, ip->i_gl, NORMAL_FLUSH);
451+
gfs2_log_flush(sdp, ip->i_gl, GFS2_LOG_HEAD_FLUSH_NORMAL |
452+
GFS2_LFC_JDATA_WPAGES);
450453
ret = gfs2_write_cache_jdata(mapping, wbc);
451454
}
452455
return ret;
@@ -483,8 +486,8 @@ static int stuffed_readpage(struct gfs2_inode *ip, struct page *page)
483486
return error;
484487

485488
kaddr = kmap_atomic(page);
486-
if (dsize > (dibh->b_size - sizeof(struct gfs2_dinode)))
487-
dsize = (dibh->b_size - sizeof(struct gfs2_dinode));
489+
if (dsize > gfs2_max_stuffed_size(ip))
490+
dsize = gfs2_max_stuffed_size(ip);
488491
memcpy(kaddr, dibh->b_data + sizeof(struct gfs2_dinode), dsize);
489492
memset(kaddr + dsize, 0, PAGE_SIZE - dsize);
490493
kunmap_atomic(kaddr);
@@ -501,10 +504,9 @@ static int stuffed_readpage(struct gfs2_inode *ip, struct page *page)
501504
* @file: The file to read a page for
502505
* @page: The page to read
503506
*
504-
* This is the core of gfs2's readpage. Its used by the internal file
505-
* reading code as in that case we already hold the glock. Also its
507+
* This is the core of gfs2's readpage. It's used by the internal file
508+
* reading code as in that case we already hold the glock. Also it's
506509
* called by gfs2_readpage() once the required lock has been granted.
507-
*
508510
*/
509511

510512
static int __gfs2_readpage(void *file, struct page *page)
@@ -725,7 +727,7 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping,
725727

726728
if (gfs2_is_stuffed(ip)) {
727729
error = 0;
728-
if (pos + len > sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode)) {
730+
if (pos + len > gfs2_max_stuffed_size(ip)) {
729731
error = gfs2_unstuff_dinode(ip, page);
730732
if (error == 0)
731733
goto prepare_write;
@@ -832,7 +834,8 @@ static int gfs2_stuffed_write_end(struct inode *inode, struct buffer_head *dibh,
832834
void *kaddr;
833835
unsigned char *buf = dibh->b_data + sizeof(struct gfs2_dinode);
834836

835-
BUG_ON((pos + len) > (dibh->b_size - sizeof(struct gfs2_dinode)));
837+
BUG_ON(pos + len > gfs2_max_stuffed_size(ip));
838+
836839
kaddr = kmap_atomic(page);
837840
memcpy(buf + pos, kaddr + pos, copied);
838841
flush_dcache_page(page);
@@ -890,8 +893,6 @@ static int gfs2_write_end(struct file *file, struct address_space *mapping,
890893
struct gfs2_sbd *sdp = GFS2_SB(inode);
891894
struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode);
892895
struct buffer_head *dibh;
893-
unsigned int from = pos & (PAGE_SIZE - 1);
894-
unsigned int to = from + len;
895896
int ret;
896897
struct gfs2_trans *tr = current->journal_info;
897898
BUG_ON(!tr);
@@ -909,7 +910,7 @@ static int gfs2_write_end(struct file *file, struct address_space *mapping,
909910
return gfs2_stuffed_write_end(inode, dibh, pos, len, copied, page);
910911

911912
if (!gfs2_is_writeback(ip))
912-
gfs2_page_add_databufs(ip, page, from, to);
913+
gfs2_page_add_databufs(ip, page, pos & ~PAGE_MASK, len);
913914

914915
ret = generic_write_end(file, mapping, pos, len, copied, page, fsdata);
915916
if (tr->tr_num_buf_new)

0 commit comments

Comments
 (0)