Skip to content

Commit

Permalink
Merge tag 'gfs2-for-5.3' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/gfs2/linux-gfs2

Pull gfs2 updates from Andreas Gruenbacher:
 "Some relatively minor changes for gfs2:

   - An initial batch of obvious cleanups and fixes from Bob's recovery
     patch queue.

   - Two iomap conversion patches and some cleanups from Christoph
     Hellwig.

   - A cosmetic cleanup from Kefeng Wang (Huawei).

   - Another minor fix and cleanup by me"

* tag 'gfs2-for-5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2:
  gfs2: Remove unused gfs2_iomap_alloc argument
  gfs2: don't use buffer_heads in gfs2_allocate_page_backing
  gfs2: use iomap_bmap instead of generic_block_bmap
  gfs2: mark stuffed_readpage static
  gfs2: merge gfs2_writepage_common into gfs2_writepage
  gfs2: merge gfs2_writeback_aops and gfs2_ordered_aops
  gfs2: remove the unused gfs2_stuffed_write_end function
  gfs2: use page_offset in gfs2_page_mkwrite
  gfs2: replace more printk with calls to fs_info and friends
  gfs2: dump fsid when dumping glock problems
  gfs2: simplify gfs2_freeze by removing case
  gfs2: Rename SDF_SHUTDOWN to SDF_WITHDRAWN
  gfs2: Warn when a journal replay overwrites a rgrp with buffers
  gfs2: log which portion of the journal is replayed
  gfs2: eliminate tr_num_revoke_rm
  gfs2: kthread and remount improvements
  gfs2: Use IS_ERR_OR_NULL
  gfs2: Clean up freeing struct gfs2_sbd
  • Loading branch information
Linus Torvalds committed Jul 11, 2019
2 parents 2e75675 + bb4cb25 commit 0248a8b
Show file tree
Hide file tree
Showing 23 changed files with 190 additions and 230 deletions.
110 changes: 13 additions & 97 deletions fs/gfs2/aops.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,11 @@ static int gfs2_get_block_noalloc(struct inode *inode, sector_t lblock,
}

/**
* gfs2_writepage_common - Common bits of writepage
* @page: The page to be written
* gfs2_writepage - Write page for writeback mappings
* @page: The page
* @wbc: The writeback control
*
* Returns: 1 if writepage is ok, otherwise an error code or zero if no error.
*/

static int gfs2_writepage_common(struct page *page,
struct writeback_control *wbc)
static int gfs2_writepage(struct page *page, struct writeback_control *wbc)
{
struct inode *inode = page->mapping->host;
struct gfs2_inode *ip = GFS2_I(inode);
Expand All @@ -109,32 +105,16 @@ static int gfs2_writepage_common(struct page *page,
page->mapping->a_ops->invalidatepage(page, 0, PAGE_SIZE);
goto out;
}
return 1;

return nobh_writepage(page, gfs2_get_block_noalloc, wbc);

redirty:
redirty_page_for_writepage(wbc, page);
out:
unlock_page(page);
return 0;
}

/**
* gfs2_writepage - Write page for writeback mappings
* @page: The page
* @wbc: The writeback control
*
*/

static int gfs2_writepage(struct page *page, struct writeback_control *wbc)
{
int ret;

ret = gfs2_writepage_common(page, wbc);
if (ret <= 0)
return ret;

return nobh_writepage(page, gfs2_get_block_noalloc, wbc);
}

/* This is the same as calling block_write_full_page, but it also
* writes pages outside of i_size
*/
Expand Down Expand Up @@ -454,8 +434,7 @@ static int gfs2_jdata_writepages(struct address_space *mapping,
*
* Returns: errno
*/

int stuffed_readpage(struct gfs2_inode *ip, struct page *page)
static int stuffed_readpage(struct gfs2_inode *ip, struct page *page)
{
struct buffer_head *dibh;
u64 dsize = i_size_read(&ip->i_inode);
Expand Down Expand Up @@ -518,7 +497,7 @@ static int __gfs2_readpage(void *file, struct page *page)
error = mpage_readpage(page, gfs2_block_map);
}

if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
if (unlikely(test_bit(SDF_WITHDRAWN, &sdp->sd_flags)))
return -EIO;

return error;
Expand Down Expand Up @@ -635,7 +614,7 @@ static int gfs2_readpages(struct file *file, struct address_space *mapping,
gfs2_glock_dq(&gh);
out_uninit:
gfs2_holder_uninit(&gh);
if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
if (unlikely(test_bit(SDF_WITHDRAWN, &sdp->sd_flags)))
ret = -EIO;
return ret;
}
Expand Down Expand Up @@ -685,47 +664,6 @@ void adjust_fs_space(struct inode *inode)
gfs2_trans_end(sdp);
}

/**
* gfs2_stuffed_write_end - Write end for stuffed files
* @inode: The inode
* @dibh: The buffer_head containing the on-disk inode
* @pos: The file position
* @copied: How much was actually copied by the VFS
* @page: The page
*
* This copies the data from the page into the inode block after
* the inode data structure itself.
*
* Returns: copied bytes or errno
*/
int gfs2_stuffed_write_end(struct inode *inode, struct buffer_head *dibh,
loff_t pos, unsigned copied,
struct page *page)
{
struct gfs2_inode *ip = GFS2_I(inode);
u64 to = pos + copied;
void *kaddr;
unsigned char *buf = dibh->b_data + sizeof(struct gfs2_dinode);

BUG_ON(pos + copied > gfs2_max_stuffed_size(ip));

kaddr = kmap_atomic(page);
memcpy(buf + pos, kaddr + pos, copied);
flush_dcache_page(page);
kunmap_atomic(kaddr);

WARN_ON(!PageUptodate(page));
unlock_page(page);
put_page(page);

if (copied) {
if (inode->i_size < to)
i_size_write(inode, to);
mark_inode_dirty(inode);
}
return copied;
}

/**
* jdata_set_page_dirty - Page dirtying function
* @page: The page to dirty
Expand Down Expand Up @@ -759,7 +697,7 @@ static sector_t gfs2_bmap(struct address_space *mapping, sector_t lblock)
return 0;

if (!gfs2_is_stuffed(ip))
dblock = generic_block_bmap(mapping, lblock, gfs2_block_map);
dblock = iomap_bmap(mapping, lblock, &gfs2_iomap_ops);

gfs2_glock_dq_uninit(&i_gh);

Expand Down Expand Up @@ -888,7 +826,7 @@ int gfs2_releasepage(struct page *page, gfp_t gfp_mask)
return 0;
}

static const struct address_space_operations gfs2_writeback_aops = {
static const struct address_space_operations gfs2_aops = {
.writepage = gfs2_writepage,
.writepages = gfs2_writepages,
.readpage = gfs2_readpage,
Expand All @@ -902,21 +840,6 @@ static const struct address_space_operations gfs2_writeback_aops = {
.error_remove_page = generic_error_remove_page,
};

static const struct address_space_operations gfs2_ordered_aops = {
.writepage = gfs2_writepage,
.writepages = gfs2_writepages,
.readpage = gfs2_readpage,
.readpages = gfs2_readpages,
.set_page_dirty = __set_page_dirty_buffers,
.bmap = gfs2_bmap,
.invalidatepage = gfs2_invalidatepage,
.releasepage = gfs2_releasepage,
.direct_IO = noop_direct_IO,
.migratepage = buffer_migrate_page,
.is_partially_uptodate = block_is_partially_uptodate,
.error_remove_page = generic_error_remove_page,
};

static const struct address_space_operations gfs2_jdata_aops = {
.writepage = gfs2_jdata_writepage,
.writepages = gfs2_jdata_writepages,
Expand All @@ -932,15 +855,8 @@ static const struct address_space_operations gfs2_jdata_aops = {

void gfs2_set_aops(struct inode *inode)
{
struct gfs2_inode *ip = GFS2_I(inode);
struct gfs2_sbd *sdp = GFS2_SB(inode);

if (gfs2_is_jdata(ip))
if (gfs2_is_jdata(GFS2_I(inode)))
inode->i_mapping->a_ops = &gfs2_jdata_aops;
else if (gfs2_is_writeback(sdp))
inode->i_mapping->a_ops = &gfs2_writeback_aops;
else if (gfs2_is_ordered(sdp))
inode->i_mapping->a_ops = &gfs2_ordered_aops;
else
BUG();
inode->i_mapping->a_ops = &gfs2_aops;
}
4 changes: 0 additions & 4 deletions fs/gfs2/aops.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@

#include "incore.h"

extern int stuffed_readpage(struct gfs2_inode *ip, struct page *page);
extern int gfs2_stuffed_write_end(struct inode *inode, struct buffer_head *dibh,
loff_t pos, unsigned copied,
struct page *page);
extern void adjust_fs_space(struct inode *inode);
extern void gfs2_page_add_databufs(struct gfs2_inode *ip, struct page *page,
unsigned int from, unsigned int len);
Expand Down
14 changes: 6 additions & 8 deletions fs/gfs2/bmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,6 @@ enum alloc_state {
* gfs2_iomap_alloc - Build a metadata tree of the requested height
* @inode: The GFS2 inode
* @iomap: The iomap structure
* @flags: iomap flags
* @mp: The metapath, with proper height information calculated
*
* In this routine we may have to alloc:
Expand All @@ -622,7 +621,7 @@ enum alloc_state {
*/

static int gfs2_iomap_alloc(struct inode *inode, struct iomap *iomap,
unsigned flags, struct metapath *mp)
struct metapath *mp)
{
struct gfs2_inode *ip = GFS2_I(inode);
struct gfs2_sbd *sdp = GFS2_SB(inode);
Expand Down Expand Up @@ -1088,7 +1087,7 @@ static int gfs2_iomap_begin_write(struct inode *inode, loff_t pos,
}

if (iomap->type == IOMAP_HOLE) {
ret = gfs2_iomap_alloc(inode, iomap, flags, mp);
ret = gfs2_iomap_alloc(inode, iomap, mp);
if (ret) {
gfs2_trans_end(sdp);
gfs2_inplace_release(ip);
Expand Down Expand Up @@ -1234,7 +1233,7 @@ int gfs2_block_map(struct inode *inode, sector_t lblock,
if (create) {
ret = gfs2_iomap_get(inode, pos, length, IOMAP_WRITE, &iomap, &mp);
if (!ret && iomap.type == IOMAP_HOLE)
ret = gfs2_iomap_alloc(inode, &iomap, IOMAP_WRITE, &mp);
ret = gfs2_iomap_alloc(inode, &iomap, &mp);
release_metapath(&mp);
} else {
ret = gfs2_iomap_get(inode, pos, length, 0, &iomap, &mp);
Expand Down Expand Up @@ -1464,7 +1463,7 @@ int gfs2_iomap_get_alloc(struct inode *inode, loff_t pos, loff_t length,

ret = gfs2_iomap_get(inode, pos, length, IOMAP_WRITE, iomap, &mp);
if (!ret && iomap->type == IOMAP_HOLE)
ret = gfs2_iomap_alloc(inode, iomap, IOMAP_WRITE, &mp);
ret = gfs2_iomap_alloc(inode, iomap, &mp);
release_metapath(&mp);
return ret;
}
Expand Down Expand Up @@ -1864,9 +1863,8 @@ static int punch_hole(struct gfs2_inode *ip, u64 offset, u64 length)
gfs2_assert_withdraw(sdp, bh);
if (gfs2_assert_withdraw(sdp,
prev_bnr != bh->b_blocknr)) {
printk(KERN_EMERG "GFS2: fsid=%s:inode %llu, "
"block:%llu, i_h:%u, s_h:%u, mp_h:%u\n",
sdp->sd_fsname,
fs_emerg(sdp, "inode %llu, block:%llu, i_h:%u,"
"s_h:%u, mp_h:%u\n",
(unsigned long long)ip->i_no_addr,
prev_bnr, ip->i_height, strip_h, mp_h);
}
Expand Down
4 changes: 2 additions & 2 deletions fs/gfs2/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ static struct gfs2_dirent *gfs2_dirent_split_alloc(struct inode *inode,
struct gfs2_dirent *dent;
dent = gfs2_dirent_scan(inode, bh->b_data, bh->b_size,
gfs2_dirent_find_offset, name, ptr);
if (!dent || IS_ERR(dent))
if (IS_ERR_OR_NULL(dent))
return dent;
return do_init_dirent(inode, dent, name, bh,
(unsigned)(ptr - (void *)dent));
Expand Down Expand Up @@ -854,7 +854,7 @@ static struct gfs2_dirent *gfs2_dirent_search(struct inode *inode,
return ERR_PTR(error);
dent = gfs2_dirent_scan(inode, bh->b_data, bh->b_size, scan, name, NULL);
got_dent:
if (unlikely(dent == NULL || IS_ERR(dent))) {
if (IS_ERR_OR_NULL(dent)) {
brelse(bh);
bh = NULL;
}
Expand Down
37 changes: 18 additions & 19 deletions fs/gfs2/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,31 +363,30 @@ static void gfs2_size_hint(struct file *filep, loff_t offset, size_t size)
}

/**
* gfs2_allocate_page_backing - Use bmap to allocate blocks
* gfs2_allocate_page_backing - Allocate blocks for a write fault
* @page: The (locked) page to allocate backing for
*
* We try to allocate all the blocks required for the page in
* one go. This might fail for various reasons, so we keep
* trying until all the blocks to back this page are allocated.
* If some of the blocks are already allocated, thats ok too.
* We try to allocate all the blocks required for the page in one go. This
* might fail for various reasons, so we keep trying until all the blocks to
* back this page are allocated. If some of the blocks are already allocated,
* that is ok too.
*/

static int gfs2_allocate_page_backing(struct page *page)
{
struct inode *inode = page->mapping->host;
struct buffer_head bh;
unsigned long size = PAGE_SIZE;
u64 lblock = page->index << (PAGE_SHIFT - inode->i_blkbits);
u64 pos = page_offset(page);
u64 size = PAGE_SIZE;

do {
bh.b_state = 0;
bh.b_size = size;
gfs2_block_map(inode, lblock, &bh, 1);
if (!buffer_mapped(&bh))
struct iomap iomap = { };

if (gfs2_iomap_get_alloc(page->mapping->host, pos, 1, &iomap))
return -EIO;
size -= bh.b_size;
lblock += (bh.b_size >> inode->i_blkbits);
} while(size > 0);

iomap.length = min(iomap.length, size);
size -= iomap.length;
pos += iomap.length;
} while (size > 0);

return 0;
}

Expand All @@ -408,7 +407,7 @@ static vm_fault_t gfs2_page_mkwrite(struct vm_fault *vmf)
struct gfs2_sbd *sdp = GFS2_SB(inode);
struct gfs2_alloc_parms ap = { .aflags = 0, };
unsigned long last_index;
u64 pos = page->index << PAGE_SHIFT;
u64 pos = page_offset(page);
unsigned int data_blocks, ind_blocks, rblocks;
struct gfs2_holder gh;
loff_t size;
Expand Down Expand Up @@ -1166,7 +1165,7 @@ static int gfs2_lock(struct file *file, int cmd, struct file_lock *fl)
cmd = F_SETLK;
fl->fl_type = F_UNLCK;
}
if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) {
if (unlikely(test_bit(SDF_WITHDRAWN, &sdp->sd_flags))) {
if (fl->fl_type == F_UNLCK)
locks_lock_file_wait(file, fl);
return -EIO;
Expand Down
Loading

0 comments on commit 0248a8b

Please sign in to comment.