aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2016-06-20 19:52:47 -0400
committerDave Chinner <david@fromorbit.com>2016-06-20 19:52:47 -0400
commit3b3dce05279b97525741b7949208017307e05621 (patch)
tree0e57f8c1489b1fba16bc20e85ad9833c49882fd0
parent8be9f564d25e7adc582f9f3689040ce5aa6f1f5b (diff)
xfs: make xfs_bmbt_to_iomap available outside of xfs_pnfs.c
And ensure it works for RT subvolume files an set the block device, both of which will be needed to be able to use the function in the buffered write path. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Bob Peterson <rpeterso@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
-rw-r--r--fs/xfs/xfs_iomap.c27
-rw-r--r--fs/xfs/xfs_iomap.h4
-rw-r--r--fs/xfs/xfs_pnfs.c26
3 files changed, 31 insertions, 26 deletions
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index 58391355a44d..2f3719461cbd 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -15,6 +15,7 @@
15 * along with this program; if not, write the Free Software Foundation, 15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */ 17 */
18#include <linux/iomap.h>
18#include "xfs.h" 19#include "xfs.h"
19#include "xfs_fs.h" 20#include "xfs_fs.h"
20#include "xfs_shared.h" 21#include "xfs_shared.h"
@@ -940,3 +941,29 @@ error_on_bmapi_transaction:
940 xfs_iunlock(ip, XFS_ILOCK_EXCL); 941 xfs_iunlock(ip, XFS_ILOCK_EXCL);
941 return error; 942 return error;
942} 943}
944
945void
946xfs_bmbt_to_iomap(
947 struct xfs_inode *ip,
948 struct iomap *iomap,
949 struct xfs_bmbt_irec *imap)
950{
951 struct xfs_mount *mp = ip->i_mount;
952
953 if (imap->br_startblock == HOLESTARTBLOCK) {
954 iomap->blkno = IOMAP_NULL_BLOCK;
955 iomap->type = IOMAP_HOLE;
956 } else if (imap->br_startblock == DELAYSTARTBLOCK) {
957 iomap->blkno = IOMAP_NULL_BLOCK;
958 iomap->type = IOMAP_DELALLOC;
959 } else {
960 iomap->blkno = xfs_fsb_to_db(ip, imap->br_startblock);
961 if (imap->br_state == XFS_EXT_UNWRITTEN)
962 iomap->type = IOMAP_UNWRITTEN;
963 else
964 iomap->type = IOMAP_MAPPED;
965 }
966 iomap->offset = XFS_FSB_TO_B(mp, imap->br_startoff);
967 iomap->length = XFS_FSB_TO_B(mp, imap->br_blockcount);
968 iomap->bdev = xfs_find_bdev_for_inode(VFS_I(ip));
969}
diff --git a/fs/xfs/xfs_iomap.h b/fs/xfs/xfs_iomap.h
index 8688e663d744..718f07c5c0d2 100644
--- a/fs/xfs/xfs_iomap.h
+++ b/fs/xfs/xfs_iomap.h
@@ -18,6 +18,7 @@
18#ifndef __XFS_IOMAP_H__ 18#ifndef __XFS_IOMAP_H__
19#define __XFS_IOMAP_H__ 19#define __XFS_IOMAP_H__
20 20
21struct iomap;
21struct xfs_inode; 22struct xfs_inode;
22struct xfs_bmbt_irec; 23struct xfs_bmbt_irec;
23 24
@@ -29,4 +30,7 @@ int xfs_iomap_write_allocate(struct xfs_inode *, xfs_off_t,
29 struct xfs_bmbt_irec *); 30 struct xfs_bmbt_irec *);
30int xfs_iomap_write_unwritten(struct xfs_inode *, xfs_off_t, xfs_off_t); 31int xfs_iomap_write_unwritten(struct xfs_inode *, xfs_off_t, xfs_off_t);
31 32
33void xfs_bmbt_to_iomap(struct xfs_inode *, struct iomap *,
34 struct xfs_bmbt_irec *);
35
32#endif /* __XFS_IOMAP_H__*/ 36#endif /* __XFS_IOMAP_H__*/
diff --git a/fs/xfs/xfs_pnfs.c b/fs/xfs/xfs_pnfs.c
index db3c7df52e30..0f14b2e4bf6c 100644
--- a/fs/xfs/xfs_pnfs.c
+++ b/fs/xfs/xfs_pnfs.c
@@ -80,32 +80,6 @@ xfs_fs_get_uuid(
80 return 0; 80 return 0;
81} 81}
82 82
83static void
84xfs_bmbt_to_iomap(
85 struct xfs_inode *ip,
86 struct iomap *iomap,
87 struct xfs_bmbt_irec *imap)
88{
89 struct xfs_mount *mp = ip->i_mount;
90
91 if (imap->br_startblock == HOLESTARTBLOCK) {
92 iomap->blkno = IOMAP_NULL_BLOCK;
93 iomap->type = IOMAP_HOLE;
94 } else if (imap->br_startblock == DELAYSTARTBLOCK) {
95 iomap->blkno = IOMAP_NULL_BLOCK;
96 iomap->type = IOMAP_DELALLOC;
97 } else {
98 iomap->blkno =
99 XFS_FSB_TO_DADDR(ip->i_mount, imap->br_startblock);
100 if (imap->br_state == XFS_EXT_UNWRITTEN)
101 iomap->type = IOMAP_UNWRITTEN;
102 else
103 iomap->type = IOMAP_MAPPED;
104 }
105 iomap->offset = XFS_FSB_TO_B(mp, imap->br_startoff);
106 iomap->length = XFS_FSB_TO_B(mp, imap->br_blockcount);
107}
108
109/* 83/*
110 * Get a layout for the pNFS client. 84 * Get a layout for the pNFS client.
111 */ 85 */