GFS2: Switch fiemap implementation to use iomap
This patch switches GFS2's implementation of fiemap from the old block_map code to the new iomap interface. Signed-off-by: Bob Peterson <rpeterso@redhat.com> Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
This commit is contained in:

committed by
Andreas Gruenbacher

parent
3974320ca6
commit
aac1a55b45
@@ -4,6 +4,7 @@ config GFS2_FS
|
|||||||
select FS_POSIX_ACL
|
select FS_POSIX_ACL
|
||||||
select CRC32
|
select CRC32
|
||||||
select QUOTACTL
|
select QUOTACTL
|
||||||
|
select FS_IOMAP
|
||||||
help
|
help
|
||||||
A cluster filesystem.
|
A cluster filesystem.
|
||||||
|
|
||||||
|
@@ -18,7 +18,7 @@
|
|||||||
#include <linux/posix_acl.h>
|
#include <linux/posix_acl.h>
|
||||||
#include <linux/gfs2_ondisk.h>
|
#include <linux/gfs2_ondisk.h>
|
||||||
#include <linux/crc32.h>
|
#include <linux/crc32.h>
|
||||||
#include <linux/fiemap.h>
|
#include <linux/iomap.h>
|
||||||
#include <linux/security.h>
|
#include <linux/security.h>
|
||||||
#include <linux/uaccess.h>
|
#include <linux/uaccess.h>
|
||||||
|
|
||||||
@@ -2003,6 +2003,10 @@ static int gfs2_getattr(const struct path *path, struct kstat *stat,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const struct iomap_ops gfs2_iomap_ops = {
|
||||||
|
.iomap_begin = gfs2_iomap_begin,
|
||||||
|
};
|
||||||
|
|
||||||
static int gfs2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
|
static int gfs2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
|
||||||
u64 start, u64 len)
|
u64 start, u64 len)
|
||||||
{
|
{
|
||||||
@@ -2010,38 +2014,18 @@ static int gfs2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
|
|||||||
struct gfs2_holder gh;
|
struct gfs2_holder gh;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = fiemap_check_flags(fieinfo, FIEMAP_FLAG_SYNC);
|
inode_lock_shared(inode);
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
inode_lock(inode);
|
|
||||||
|
|
||||||
ret = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, 0, &gh);
|
ret = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, 0, &gh);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (gfs2_is_stuffed(ip)) {
|
ret = iomap_fiemap(inode, fieinfo, start, len, &gfs2_iomap_ops);
|
||||||
u64 phys = ip->i_no_addr << inode->i_blkbits;
|
|
||||||
u64 size = i_size_read(inode);
|
|
||||||
u32 flags = FIEMAP_EXTENT_LAST|FIEMAP_EXTENT_NOT_ALIGNED|
|
|
||||||
FIEMAP_EXTENT_DATA_INLINE;
|
|
||||||
phys += sizeof(struct gfs2_dinode);
|
|
||||||
phys += start;
|
|
||||||
if (start + len > size)
|
|
||||||
len = size - start;
|
|
||||||
if (start < size)
|
|
||||||
ret = fiemap_fill_next_extent(fieinfo, start, phys,
|
|
||||||
len, flags);
|
|
||||||
if (ret == 1)
|
|
||||||
ret = 0;
|
|
||||||
} else {
|
|
||||||
ret = __generic_block_fiemap(inode, fieinfo, start, len,
|
|
||||||
gfs2_block_map);
|
|
||||||
}
|
|
||||||
|
|
||||||
gfs2_glock_dq_uninit(&gh);
|
gfs2_glock_dq_uninit(&gh);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
inode_unlock(inode);
|
inode_unlock_shared(inode);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user