mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-23 20:24:12 +08:00
gfs2: Clean up gfs2_unstuff_dinode
Split __gfs2_unstuff_inode off from gfs2_unstuff_dinode and clean up the code a little. All remaining callers now pass NULL as the page argument of gfs2_unstuff_dinode, so remove that argument. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
This commit is contained in:
parent
64090cbe4b
commit
7a607a41cd
@ -56,14 +56,6 @@ static int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh,
|
||||
u64 block, struct page *page)
|
||||
{
|
||||
struct inode *inode = &ip->i_inode;
|
||||
int release = 0;
|
||||
|
||||
if (!page || page->index) {
|
||||
page = find_or_create_page(inode->i_mapping, 0, GFP_NOFS);
|
||||
if (!page)
|
||||
return -ENOMEM;
|
||||
release = 1;
|
||||
}
|
||||
|
||||
if (!PageUptodate(page)) {
|
||||
void *kaddr = kmap(page);
|
||||
@ -97,26 +89,10 @@ static int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh,
|
||||
gfs2_ordered_add_inode(ip);
|
||||
}
|
||||
|
||||
if (release) {
|
||||
unlock_page(page);
|
||||
put_page(page);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* gfs2_unstuff_dinode - Unstuff a dinode when the data has grown too big
|
||||
* @ip: The GFS2 inode to unstuff
|
||||
* @page: The (optional) page. This is looked up if the @page is NULL
|
||||
*
|
||||
* This routine unstuffs a dinode and returns it to a "normal" state such
|
||||
* that the height can be grown in the traditional way.
|
||||
*
|
||||
* Returns: errno
|
||||
*/
|
||||
|
||||
int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page)
|
||||
static int __gfs2_unstuff_inode(struct gfs2_inode *ip, struct page *page)
|
||||
{
|
||||
struct buffer_head *bh, *dibh;
|
||||
struct gfs2_dinode *di;
|
||||
@ -124,11 +100,9 @@ int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page)
|
||||
int isdir = gfs2_is_dir(ip);
|
||||
int error;
|
||||
|
||||
down_write(&ip->i_rw_mutex);
|
||||
|
||||
error = gfs2_meta_inode_buffer(ip, &dibh);
|
||||
if (error)
|
||||
goto out;
|
||||
return error;
|
||||
|
||||
if (i_size_read(&ip->i_inode)) {
|
||||
/* Get a free block, fill it with the stuffed data,
|
||||
@ -170,12 +144,38 @@ int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page)
|
||||
|
||||
out_brelse:
|
||||
brelse(dibh);
|
||||
return error;
|
||||
}
|
||||
|
||||
/**
|
||||
* gfs2_unstuff_dinode - Unstuff a dinode when the data has grown too big
|
||||
* @ip: The GFS2 inode to unstuff
|
||||
*
|
||||
* This routine unstuffs a dinode and returns it to a "normal" state such
|
||||
* that the height can be grown in the traditional way.
|
||||
*
|
||||
* Returns: errno
|
||||
*/
|
||||
|
||||
int gfs2_unstuff_dinode(struct gfs2_inode *ip)
|
||||
{
|
||||
struct inode *inode = &ip->i_inode;
|
||||
struct page *page;
|
||||
int error;
|
||||
|
||||
down_write(&ip->i_rw_mutex);
|
||||
page = find_or_create_page(inode->i_mapping, 0, GFP_NOFS);
|
||||
error = -ENOMEM;
|
||||
if (!page)
|
||||
goto out;
|
||||
error = __gfs2_unstuff_inode(ip, page);
|
||||
unlock_page(page);
|
||||
put_page(page);
|
||||
out:
|
||||
up_write(&ip->i_rw_mutex);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* find_metapath - Find path through the metadata tree
|
||||
* @sdp: The superblock
|
||||
@ -1079,7 +1079,7 @@ static int gfs2_iomap_begin_write(struct inode *inode, loff_t pos,
|
||||
goto out_trans_fail;
|
||||
|
||||
if (unstuff) {
|
||||
ret = gfs2_unstuff_dinode(ip, NULL);
|
||||
ret = gfs2_unstuff_dinode(ip);
|
||||
if (ret)
|
||||
goto out_trans_end;
|
||||
release_metapath(mp);
|
||||
@ -2143,7 +2143,7 @@ static int do_grow(struct inode *inode, u64 size)
|
||||
goto do_grow_release;
|
||||
|
||||
if (unstuff) {
|
||||
error = gfs2_unstuff_dinode(ip, NULL);
|
||||
error = gfs2_unstuff_dinode(ip);
|
||||
if (error)
|
||||
goto do_end_trans;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ static inline void gfs2_write_calc_reserv(const struct gfs2_inode *ip,
|
||||
extern const struct iomap_ops gfs2_iomap_ops;
|
||||
extern const struct iomap_writeback_ops gfs2_writeback_ops;
|
||||
|
||||
extern int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page);
|
||||
extern int gfs2_unstuff_dinode(struct gfs2_inode *ip);
|
||||
extern int gfs2_block_map(struct inode *inode, sector_t lblock,
|
||||
struct buffer_head *bh, int create);
|
||||
extern int gfs2_iomap_get(struct inode *inode, loff_t pos, loff_t length,
|
||||
|
@ -172,7 +172,7 @@ static int gfs2_dir_write_data(struct gfs2_inode *ip, const char *buf,
|
||||
return -EINVAL;
|
||||
|
||||
if (gfs2_is_stuffed(ip)) {
|
||||
error = gfs2_unstuff_dinode(ip, NULL);
|
||||
error = gfs2_unstuff_dinode(ip);
|
||||
if (error)
|
||||
return error;
|
||||
}
|
||||
|
@ -512,7 +512,7 @@ static vm_fault_t gfs2_page_mkwrite(struct vm_fault *vmf)
|
||||
|
||||
/* Unstuff, if required, and allocate backing blocks for page */
|
||||
if (gfs2_is_stuffed(ip)) {
|
||||
err = gfs2_unstuff_dinode(ip, NULL);
|
||||
err = gfs2_unstuff_dinode(ip);
|
||||
if (err) {
|
||||
ret = block_page_mkwrite_return(err);
|
||||
goto out_trans_end;
|
||||
@ -981,7 +981,7 @@ static int fallocate_chunk(struct inode *inode, loff_t offset, loff_t len,
|
||||
gfs2_trans_add_meta(ip->i_gl, dibh);
|
||||
|
||||
if (gfs2_is_stuffed(ip)) {
|
||||
error = gfs2_unstuff_dinode(ip, NULL);
|
||||
error = gfs2_unstuff_dinode(ip);
|
||||
if (unlikely(error))
|
||||
goto out;
|
||||
}
|
||||
|
@ -825,7 +825,7 @@ static int gfs2_adjust_quota(struct gfs2_inode *ip, loff_t loc,
|
||||
u64 size;
|
||||
|
||||
if (gfs2_is_stuffed(ip)) {
|
||||
err = gfs2_unstuff_dinode(ip, NULL);
|
||||
err = gfs2_unstuff_dinode(ip);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user