Commit 207d0416 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Alex Elder

xfs: kill struct xfs_iomap

Now that struct xfs_iomap contains exactly the same units as struct
xfs_bmbt_irec we can just use the latter directly in the aops code.
Replace the missing IOMAP_NEW flag with a new boolean output
parameter to xfs_iomap.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarAlex Elder <aelder@sgi.com>
parent e513182d
...@@ -310,23 +310,24 @@ xfs_map_blocks( ...@@ -310,23 +310,24 @@ xfs_map_blocks(
struct inode *inode, struct inode *inode,
loff_t offset, loff_t offset,
ssize_t count, ssize_t count,
xfs_iomap_t *mapp, struct xfs_bmbt_irec *imap,
int flags) int flags)
{ {
int nmaps = 1; int nmaps = 1;
int new = 0;
return -xfs_iomap(XFS_I(inode), offset, count, flags, mapp, &nmaps); return -xfs_iomap(XFS_I(inode), offset, count, flags, imap, &nmaps, &new);
} }
STATIC int STATIC int
xfs_iomap_valid( xfs_iomap_valid(
struct inode *inode, struct inode *inode,
xfs_iomap_t *iomapp, struct xfs_bmbt_irec *imap,
loff_t offset) loff_t offset)
{ {
struct xfs_mount *mp = XFS_I(inode)->i_mount; struct xfs_mount *mp = XFS_I(inode)->i_mount;
xfs_off_t iomap_offset = XFS_FSB_TO_B(mp, iomapp->iomap_offset); xfs_off_t iomap_offset = XFS_FSB_TO_B(mp, imap->br_startoff);
xfs_off_t iomap_bsize = XFS_FSB_TO_B(mp, iomapp->iomap_bsize); xfs_off_t iomap_bsize = XFS_FSB_TO_B(mp, imap->br_blockcount);
return offset >= iomap_offset && return offset >= iomap_offset &&
offset < iomap_offset + iomap_bsize; offset < iomap_offset + iomap_bsize;
...@@ -562,16 +563,16 @@ STATIC void ...@@ -562,16 +563,16 @@ STATIC void
xfs_map_buffer( xfs_map_buffer(
struct inode *inode, struct inode *inode,
struct buffer_head *bh, struct buffer_head *bh,
xfs_iomap_t *mp, struct xfs_bmbt_irec *imap,
xfs_off_t offset) xfs_off_t offset)
{ {
sector_t bn; sector_t bn;
struct xfs_mount *m = XFS_I(inode)->i_mount; struct xfs_mount *m = XFS_I(inode)->i_mount;
xfs_off_t iomap_offset = XFS_FSB_TO_B(m, mp->iomap_offset); xfs_off_t iomap_offset = XFS_FSB_TO_B(m, imap->br_startoff);
xfs_daddr_t iomap_bn = xfs_fsb_to_db(XFS_I(inode), mp->iomap_bn); xfs_daddr_t iomap_bn = xfs_fsb_to_db(XFS_I(inode), imap->br_startblock);
ASSERT(mp->iomap_bn != HOLESTARTBLOCK); ASSERT(imap->br_startblock != HOLESTARTBLOCK);
ASSERT(mp->iomap_bn != DELAYSTARTBLOCK); ASSERT(imap->br_startblock != DELAYSTARTBLOCK);
bn = (iomap_bn >> (inode->i_blkbits - BBSHIFT)) + bn = (iomap_bn >> (inode->i_blkbits - BBSHIFT)) +
((offset - iomap_offset) >> inode->i_blkbits); ((offset - iomap_offset) >> inode->i_blkbits);
...@@ -586,14 +587,14 @@ STATIC void ...@@ -586,14 +587,14 @@ STATIC void
xfs_map_at_offset( xfs_map_at_offset(
struct inode *inode, struct inode *inode,
struct buffer_head *bh, struct buffer_head *bh,
xfs_iomap_t *iomapp, struct xfs_bmbt_irec *imap,
xfs_off_t offset) xfs_off_t offset)
{ {
ASSERT(iomapp->iomap_bn != HOLESTARTBLOCK); ASSERT(imap->br_startblock != HOLESTARTBLOCK);
ASSERT(iomapp->iomap_bn != DELAYSTARTBLOCK); ASSERT(imap->br_startblock != DELAYSTARTBLOCK);
lock_buffer(bh); lock_buffer(bh);
xfs_map_buffer(inode, bh, iomapp, offset); xfs_map_buffer(inode, bh, imap, offset);
bh->b_bdev = xfs_find_bdev_for_inode(inode); bh->b_bdev = xfs_find_bdev_for_inode(inode);
set_buffer_mapped(bh); set_buffer_mapped(bh);
clear_buffer_delay(bh); clear_buffer_delay(bh);
...@@ -750,7 +751,7 @@ xfs_convert_page( ...@@ -750,7 +751,7 @@ xfs_convert_page(
struct inode *inode, struct inode *inode,
struct page *page, struct page *page,
loff_t tindex, loff_t tindex,
xfs_iomap_t *mp, struct xfs_bmbt_irec *imap,
xfs_ioend_t **ioendp, xfs_ioend_t **ioendp,
struct writeback_control *wbc, struct writeback_control *wbc,
int startio, int startio,
...@@ -815,15 +816,15 @@ xfs_convert_page( ...@@ -815,15 +816,15 @@ xfs_convert_page(
else else
type = IOMAP_DELAY; type = IOMAP_DELAY;
if (!xfs_iomap_valid(inode, mp, offset)) { if (!xfs_iomap_valid(inode, imap, offset)) {
done = 1; done = 1;
continue; continue;
} }
ASSERT(mp->iomap_bn != HOLESTARTBLOCK); ASSERT(imap->br_startblock != HOLESTARTBLOCK);
ASSERT(mp->iomap_bn != DELAYSTARTBLOCK); ASSERT(imap->br_startblock != DELAYSTARTBLOCK);
xfs_map_at_offset(inode, bh, mp, offset); xfs_map_at_offset(inode, bh, imap, offset);
if (startio) { if (startio) {
xfs_add_to_ioend(inode, bh, offset, xfs_add_to_ioend(inode, bh, offset,
type, ioendp, done); type, ioendp, done);
...@@ -875,7 +876,7 @@ STATIC void ...@@ -875,7 +876,7 @@ STATIC void
xfs_cluster_write( xfs_cluster_write(
struct inode *inode, struct inode *inode,
pgoff_t tindex, pgoff_t tindex,
xfs_iomap_t *iomapp, struct xfs_bmbt_irec *imap,
xfs_ioend_t **ioendp, xfs_ioend_t **ioendp,
struct writeback_control *wbc, struct writeback_control *wbc,
int startio, int startio,
...@@ -894,7 +895,7 @@ xfs_cluster_write( ...@@ -894,7 +895,7 @@ xfs_cluster_write(
for (i = 0; i < pagevec_count(&pvec); i++) { for (i = 0; i < pagevec_count(&pvec); i++) {
done = xfs_convert_page(inode, pvec.pages[i], tindex++, done = xfs_convert_page(inode, pvec.pages[i], tindex++,
iomapp, ioendp, wbc, startio, all_bh); imap, ioendp, wbc, startio, all_bh);
if (done) if (done)
break; break;
} }
...@@ -1051,7 +1052,7 @@ xfs_page_state_convert( ...@@ -1051,7 +1052,7 @@ xfs_page_state_convert(
int unmapped) /* also implies page uptodate */ int unmapped) /* also implies page uptodate */
{ {
struct buffer_head *bh, *head; struct buffer_head *bh, *head;
xfs_iomap_t iomap; struct xfs_bmbt_irec imap;
xfs_ioend_t *ioend = NULL, *iohead = NULL; xfs_ioend_t *ioend = NULL, *iohead = NULL;
loff_t offset; loff_t offset;
unsigned long p_offset = 0; unsigned long p_offset = 0;
...@@ -1125,7 +1126,7 @@ xfs_page_state_convert( ...@@ -1125,7 +1126,7 @@ xfs_page_state_convert(
} }
if (iomap_valid) if (iomap_valid)
iomap_valid = xfs_iomap_valid(inode, &iomap, offset); iomap_valid = xfs_iomap_valid(inode, &imap, offset);
/* /*
* First case, map an unwritten extent and prepare for * First case, map an unwritten extent and prepare for
...@@ -1177,13 +1178,13 @@ xfs_page_state_convert( ...@@ -1177,13 +1178,13 @@ xfs_page_state_convert(
} }
err = xfs_map_blocks(inode, offset, size, err = xfs_map_blocks(inode, offset, size,
&iomap, flags); &imap, flags);
if (err) if (err)
goto error; goto error;
iomap_valid = xfs_iomap_valid(inode, &iomap, offset); iomap_valid = xfs_iomap_valid(inode, &imap, offset);
} }
if (iomap_valid) { if (iomap_valid) {
xfs_map_at_offset(inode, bh, &iomap, offset); xfs_map_at_offset(inode, bh, &imap, offset);
if (startio) { if (startio) {
xfs_add_to_ioend(inode, bh, offset, xfs_add_to_ioend(inode, bh, offset,
type, &ioend, type, &ioend,
...@@ -1207,10 +1208,10 @@ xfs_page_state_convert( ...@@ -1207,10 +1208,10 @@ xfs_page_state_convert(
size = xfs_probe_cluster(inode, page, bh, size = xfs_probe_cluster(inode, page, bh,
head, 1); head, 1);
err = xfs_map_blocks(inode, offset, size, err = xfs_map_blocks(inode, offset, size,
&iomap, flags); &imap, flags);
if (err) if (err)
goto error; goto error;
iomap_valid = xfs_iomap_valid(inode, &iomap, offset); iomap_valid = xfs_iomap_valid(inode, &imap, offset);
} }
/* /*
...@@ -1251,13 +1252,13 @@ xfs_page_state_convert( ...@@ -1251,13 +1252,13 @@ xfs_page_state_convert(
if (ioend && iomap_valid) { if (ioend && iomap_valid) {
struct xfs_mount *m = XFS_I(inode)->i_mount; struct xfs_mount *m = XFS_I(inode)->i_mount;
xfs_off_t iomap_offset = XFS_FSB_TO_B(m, iomap.iomap_offset); xfs_off_t iomap_offset = XFS_FSB_TO_B(m, imap.br_startoff);
xfs_off_t iomap_bsize = XFS_FSB_TO_B(m, iomap.iomap_bsize); xfs_off_t iomap_bsize = XFS_FSB_TO_B(m, imap.br_blockcount);
offset = (iomap_offset + iomap_bsize - 1) >> offset = (iomap_offset + iomap_bsize - 1) >>
PAGE_CACHE_SHIFT; PAGE_CACHE_SHIFT;
tlast = min_t(pgoff_t, offset, last_index); tlast = min_t(pgoff_t, offset, last_index);
xfs_cluster_write(inode, page->index + 1, &iomap, &ioend, xfs_cluster_write(inode, page->index + 1, &imap, &ioend,
wbc, startio, all_bh, tlast); wbc, startio, all_bh, tlast);
} }
...@@ -1460,10 +1461,11 @@ __xfs_get_blocks( ...@@ -1460,10 +1461,11 @@ __xfs_get_blocks(
int direct, int direct,
bmapi_flags_t flags) bmapi_flags_t flags)
{ {
xfs_iomap_t iomap; struct xfs_bmbt_irec imap;
xfs_off_t offset; xfs_off_t offset;
ssize_t size; ssize_t size;
int niomap = 1; int nimap = 1;
int new = 0;
int error; int error;
offset = (xfs_off_t)iblock << inode->i_blkbits; offset = (xfs_off_t)iblock << inode->i_blkbits;
...@@ -1474,21 +1476,21 @@ __xfs_get_blocks( ...@@ -1474,21 +1476,21 @@ __xfs_get_blocks(
return 0; return 0;
error = xfs_iomap(XFS_I(inode), offset, size, error = xfs_iomap(XFS_I(inode), offset, size,
create ? flags : BMAPI_READ, &iomap, &niomap); create ? flags : BMAPI_READ, &imap, &nimap, &new);
if (error) if (error)
return -error; return -error;
if (niomap == 0) if (nimap == 0)
return 0; return 0;
if (iomap.iomap_bn != HOLESTARTBLOCK && if (imap.br_startblock != HOLESTARTBLOCK &&
iomap.iomap_bn != DELAYSTARTBLOCK) { imap.br_startblock != DELAYSTARTBLOCK) {
/* /*
* For unwritten extents do not report a disk address on * For unwritten extents do not report a disk address on
* the read case (treat as if we're reading into a hole). * the read case (treat as if we're reading into a hole).
*/ */
if (create || !(iomap.iomap_flags & IOMAP_UNWRITTEN)) if (create || !ISUNWRITTEN(&imap))
xfs_map_buffer(inode, bh_result, &iomap, offset); xfs_map_buffer(inode, bh_result, &imap, offset);
if (create && (iomap.iomap_flags & IOMAP_UNWRITTEN)) { if (create && ISUNWRITTEN(&imap)) {
if (direct) if (direct)
bh_result->b_private = inode; bh_result->b_private = inode;
set_buffer_unwritten(bh_result); set_buffer_unwritten(bh_result);
...@@ -1513,10 +1515,10 @@ __xfs_get_blocks( ...@@ -1513,10 +1515,10 @@ __xfs_get_blocks(
if (create && if (create &&
((!buffer_mapped(bh_result) && !buffer_uptodate(bh_result)) || ((!buffer_mapped(bh_result) && !buffer_uptodate(bh_result)) ||
(offset >= i_size_read(inode)) || (offset >= i_size_read(inode)) ||
(iomap.iomap_flags & (IOMAP_NEW|IOMAP_UNWRITTEN)))) (new || ISUNWRITTEN(&imap))))
set_buffer_new(bh_result); set_buffer_new(bh_result);
if (iomap.iomap_bn == DELAYSTARTBLOCK) { if (imap.br_startblock == DELAYSTARTBLOCK) {
BUG_ON(direct); BUG_ON(direct);
if (create) { if (create) {
set_buffer_uptodate(bh_result); set_buffer_uptodate(bh_result);
...@@ -1527,9 +1529,9 @@ __xfs_get_blocks( ...@@ -1527,9 +1529,9 @@ __xfs_get_blocks(
if (direct || size > (1 << inode->i_blkbits)) { if (direct || size > (1 << inode->i_blkbits)) {
struct xfs_mount *mp = XFS_I(inode)->i_mount; struct xfs_mount *mp = XFS_I(inode)->i_mount;
xfs_off_t iomap_offset = XFS_FSB_TO_B(mp, iomap.iomap_offset); xfs_off_t iomap_offset = XFS_FSB_TO_B(mp, imap.br_startoff);
xfs_off_t iomap_delta = offset - iomap_offset; xfs_off_t iomap_delta = offset - iomap_offset;
xfs_off_t iomap_bsize = XFS_FSB_TO_B(mp, iomap.iomap_bsize); xfs_off_t iomap_bsize = XFS_FSB_TO_B(mp, imap.br_blockcount);
ASSERT(iomap_bsize - iomap_delta > 0); ASSERT(iomap_bsize - iomap_delta > 0);
offset = min_t(xfs_off_t, offset = min_t(xfs_off_t,
......
...@@ -55,46 +55,25 @@ ...@@ -55,46 +55,25 @@
#define XFS_STRAT_WRITE_IMAPS 2 #define XFS_STRAT_WRITE_IMAPS 2
#define XFS_WRITE_IMAPS XFS_BMAP_MAX_NMAP #define XFS_WRITE_IMAPS XFS_BMAP_MAX_NMAP
STATIC void
xfs_imap_to_bmap(
xfs_inode_t *ip,
xfs_off_t offset,
xfs_bmbt_irec_t *imap,
xfs_iomap_t *iomapp,
int imaps, /* Number of imap entries */
int flags)
{
iomapp->iomap_offset = imap->br_startoff;
iomapp->iomap_bsize = imap->br_blockcount;
iomapp->iomap_flags = flags;
iomapp->iomap_bn = imap->br_startblock;
if (imap->br_startblock != HOLESTARTBLOCK &&
imap->br_startblock != DELAYSTARTBLOCK &&
ISUNWRITTEN(imap))
iomapp->iomap_flags |= IOMAP_UNWRITTEN;
}
int int
xfs_iomap( xfs_iomap(
xfs_inode_t *ip, struct xfs_inode *ip,
xfs_off_t offset, xfs_off_t offset,
ssize_t count, ssize_t count,
int flags, int flags,
xfs_iomap_t *iomapp, struct xfs_bmbt_irec *imap,
int *niomaps) int *nimaps,
int *new)
{ {
xfs_mount_t *mp = ip->i_mount; struct xfs_mount *mp = ip->i_mount;
xfs_fileoff_t offset_fsb, end_fsb; xfs_fileoff_t offset_fsb, end_fsb;
int error = 0; int error = 0;
int lockmode = 0; int lockmode = 0;
xfs_bmbt_irec_t imap; int bmapi_flags = 0;
int nimaps = 1;
int bmapi_flags = 0;
int iomap_flags = 0;
ASSERT((ip->i_d.di_mode & S_IFMT) == S_IFREG); ASSERT((ip->i_d.di_mode & S_IFMT) == S_IFREG);
ASSERT(niomaps && *niomaps == 1);
*new = 0;
if (XFS_FORCED_SHUTDOWN(mp)) if (XFS_FORCED_SHUTDOWN(mp))
return XFS_ERROR(EIO); return XFS_ERROR(EIO);
...@@ -136,8 +115,8 @@ xfs_iomap( ...@@ -136,8 +115,8 @@ xfs_iomap(
error = xfs_bmapi(NULL, ip, offset_fsb, error = xfs_bmapi(NULL, ip, offset_fsb,
(xfs_filblks_t)(end_fsb - offset_fsb), (xfs_filblks_t)(end_fsb - offset_fsb),
bmapi_flags, NULL, 0, &imap, bmapi_flags, NULL, 0, imap,
&nimaps, NULL, NULL); nimaps, NULL, NULL);
if (error) if (error)
goto out; goto out;
...@@ -145,45 +124,41 @@ xfs_iomap( ...@@ -145,45 +124,41 @@ xfs_iomap(
switch (flags & (BMAPI_WRITE|BMAPI_ALLOCATE)) { switch (flags & (BMAPI_WRITE|BMAPI_ALLOCATE)) {
case BMAPI_WRITE: case BMAPI_WRITE:
/* If we found an extent, return it */ /* If we found an extent, return it */
if (nimaps && if (*nimaps &&
(imap.br_startblock != HOLESTARTBLOCK) && (imap->br_startblock != HOLESTARTBLOCK) &&
(imap.br_startblock != DELAYSTARTBLOCK)) { (imap->br_startblock != DELAYSTARTBLOCK)) {
trace_xfs_iomap_found(ip, offset, count, flags, &imap); trace_xfs_iomap_found(ip, offset, count, flags, imap);
break; break;
} }
if (flags & (BMAPI_DIRECT|BMAPI_MMAP)) { if (flags & (BMAPI_DIRECT|BMAPI_MMAP)) {
error = xfs_iomap_write_direct(ip, offset, count, flags, error = xfs_iomap_write_direct(ip, offset, count, flags,
&imap, &nimaps, nimaps); imap, nimaps, *nimaps);
} else { } else {
error = xfs_iomap_write_delay(ip, offset, count, flags, error = xfs_iomap_write_delay(ip, offset, count, flags,
&imap, &nimaps); imap, nimaps);
} }
if (!error) { if (!error) {
trace_xfs_iomap_alloc(ip, offset, count, flags, &imap); trace_xfs_iomap_alloc(ip, offset, count, flags, imap);
} }
iomap_flags = IOMAP_NEW; *new = 1;
break; break;
case BMAPI_ALLOCATE: case BMAPI_ALLOCATE:
/* If we found an extent, return it */ /* If we found an extent, return it */
xfs_iunlock(ip, lockmode); xfs_iunlock(ip, lockmode);
lockmode = 0; lockmode = 0;
if (nimaps && !isnullstartblock(imap.br_startblock)) { if (*nimaps && !isnullstartblock(imap->br_startblock)) {
trace_xfs_iomap_found(ip, offset, count, flags, &imap); trace_xfs_iomap_found(ip, offset, count, flags, imap);
break; break;
} }
error = xfs_iomap_write_allocate(ip, offset, count, error = xfs_iomap_write_allocate(ip, offset, count,
&imap, &nimaps); imap, nimaps);
break; break;
} }
ASSERT(nimaps <= 1); ASSERT(*nimaps <= 1);
if (nimaps)
xfs_imap_to_bmap(ip, offset, &imap, iomapp, nimaps, iomap_flags);
*niomaps = nimaps;
out: out:
if (lockmode) if (lockmode)
...@@ -191,7 +166,6 @@ xfs_iomap( ...@@ -191,7 +166,6 @@ xfs_iomap(
return XFS_ERROR(error); return XFS_ERROR(error);
} }
STATIC int STATIC int
xfs_iomap_eof_align_last_fsb( xfs_iomap_eof_align_last_fsb(
xfs_mount_t *mp, xfs_mount_t *mp,
......
...@@ -47,35 +47,11 @@ typedef enum { ...@@ -47,35 +47,11 @@ typedef enum {
{ BMAPI_MMAP, "MMAP" }, \ { BMAPI_MMAP, "MMAP" }, \
{ BMAPI_TRYLOCK, "TRYLOCK" } { BMAPI_TRYLOCK, "TRYLOCK" }
/*
* xfs_iomap_t: File system I/O map
*
* The iomap_bn field is expressed in 512-byte blocks, and is where the
* mapping starts on disk.
*
* The iomap_offset, iomap_bsize and iomap_delta fields are in bytes.
* iomap_offset is the offset of the mapping in the file itself.
* iomap_bsize is the size of the mapping, iomap_delta is the
* desired data's offset into the mapping, given the offset supplied
* to the file I/O map routine.
*
* When a request is made to read beyond the logical end of the object,
* iomap_size may be set to 0, but iomap_offset and iomap_length should be set
* to the actual amount of underlying storage that has been allocated, if any.
*/
typedef struct xfs_iomap {
xfs_daddr_t iomap_bn; /* first 512B blk of mapping */
xfs_off_t iomap_offset; /* offset of mapping, bytes */
xfs_off_t iomap_bsize; /* size of mapping, bytes */
iomap_flags_t iomap_flags;
} xfs_iomap_t;
struct xfs_inode; struct xfs_inode;
struct xfs_bmbt_irec; struct xfs_bmbt_irec;
extern int xfs_iomap(struct xfs_inode *, xfs_off_t, ssize_t, int, extern int xfs_iomap(struct xfs_inode *, xfs_off_t, ssize_t, int,
struct xfs_iomap *, int *); struct xfs_bmbt_irec *, int *, int *);
extern int xfs_iomap_write_direct(struct xfs_inode *, xfs_off_t, size_t, extern int xfs_iomap_write_direct(struct xfs_inode *, xfs_off_t, size_t,
int, struct xfs_bmbt_irec *, int *, int); int, struct xfs_bmbt_irec *, int *, int);
extern int xfs_iomap_write_delay(struct xfs_inode *, xfs_off_t, size_t, int, extern int xfs_iomap_write_delay(struct xfs_inode *, xfs_off_t, size_t, int,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment