aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2/inode.c
diff options
context:
space:
mode:
authorBob Peterson <rpeterso@redhat.com>2017-02-16 15:13:54 -0500
committerAndreas Gruenbacher <agruenba@redhat.com>2017-10-31 09:26:34 -0400
commitaac1a55b450c623ec236c0635cdb68408f632e9c (patch)
tree9247d57672ea2594810cd03415b1949fb3717596 /fs/gfs2/inode.c
parent3974320ca6aa68d479051f208d5c95afd1e47a4c (diff)
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>
Diffstat (limited to 'fs/gfs2/inode.c')
-rw-r--r--fs/gfs2/inode.c34
1 files changed, 9 insertions, 25 deletions
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index b288cf2f85e6..321da48ca123 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -18,7 +18,7 @@
18#include <linux/posix_acl.h> 18#include <linux/posix_acl.h>
19#include <linux/gfs2_ondisk.h> 19#include <linux/gfs2_ondisk.h>
20#include <linux/crc32.h> 20#include <linux/crc32.h>
21#include <linux/fiemap.h> 21#include <linux/iomap.h>
22#include <linux/security.h> 22#include <linux/security.h>
23#include <linux/uaccess.h> 23#include <linux/uaccess.h>
24 24
@@ -2003,6 +2003,10 @@ static int gfs2_getattr(const struct path *path, struct kstat *stat,
2003 return 0; 2003 return 0;
2004} 2004}
2005 2005
2006const struct iomap_ops gfs2_iomap_ops = {
2007 .iomap_begin = gfs2_iomap_begin,
2008};
2009
2006static int gfs2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, 2010static int gfs2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
2007 u64 start, u64 len) 2011 u64 start, u64 len)
2008{ 2012{
@@ -2010,38 +2014,18 @@ static int gfs2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
2010 struct gfs2_holder gh; 2014 struct gfs2_holder gh;
2011 int ret; 2015 int ret;
2012 2016
2013 ret = fiemap_check_flags(fieinfo, FIEMAP_FLAG_SYNC); 2017 inode_lock_shared(inode);
2014 if (ret)
2015 return ret;
2016
2017 inode_lock(inode);
2018 2018
2019 ret = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, 0, &gh); 2019 ret = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, 0, &gh);
2020 if (ret) 2020 if (ret)
2021 goto out; 2021 goto out;
2022 2022
2023 if (gfs2_is_stuffed(ip)) { 2023 ret = iomap_fiemap(inode, fieinfo, start, len, &gfs2_iomap_ops);
2024 u64 phys = ip->i_no_addr << inode->i_blkbits;
2025 u64 size = i_size_read(inode);
2026 u32 flags = FIEMAP_EXTENT_LAST|FIEMAP_EXTENT_NOT_ALIGNED|
2027 FIEMAP_EXTENT_DATA_INLINE;
2028 phys += sizeof(struct gfs2_dinode);
2029 phys += start;
2030 if (start + len > size)
2031 len = size - start;
2032 if (start < size)
2033 ret = fiemap_fill_next_extent(fieinfo, start, phys,
2034 len, flags);
2035 if (ret == 1)
2036 ret = 0;
2037 } else {
2038 ret = __generic_block_fiemap(inode, fieinfo, start, len,
2039 gfs2_block_map);
2040 }
2041 2024
2042 gfs2_glock_dq_uninit(&gh); 2025 gfs2_glock_dq_uninit(&gh);
2026
2043out: 2027out:
2044 inode_unlock(inode); 2028 inode_unlock_shared(inode);
2045 return ret; 2029 return ret;
2046} 2030}
2047 2031