Commit c0816a50 authored by Linus Torvalds's avatar Linus Torvalds

Merge http://xfs.org:8090/xfs-linux-2.6

into home.osdl.org:/home/torvalds/v2.5/linux
parents 66cb679e 5b3597e4
...@@ -407,8 +407,10 @@ map_unwritten( ...@@ -407,8 +407,10 @@ map_unwritten(
offset <<= PAGE_CACHE_SHIFT; offset <<= PAGE_CACHE_SHIFT;
offset += p_offset; offset += p_offset;
pb = pagebuf_lookup(iomapp->iomap_target, /* get an "empty" pagebuf to manage IO completion
iomapp->iomap_offset, iomapp->iomap_bsize, 0); * Proper values will be set before returning */
pb = pagebuf_lookup(iomapp->iomap_target, 0, 0, 0);
if (!pb) if (!pb)
return -EAGAIN; return -EAGAIN;
...@@ -471,6 +473,11 @@ map_unwritten( ...@@ -471,6 +473,11 @@ map_unwritten(
nblocks += bs; nblocks += bs;
atomic_add(bs, &pb->pb_io_remaining); atomic_add(bs, &pb->pb_io_remaining);
convert_page(inode, page, iomapp, pb, startio, all_bh); convert_page(inode, page, iomapp, pb, startio, all_bh);
/* stop if converting the next page might add
* enough blocks that the corresponding byte
* count won't fit in our ulong page buf length */
if (nblocks >= ((ULONG_MAX - PAGE_SIZE) >> block_bits))
goto enough;
} }
if (tindex == tlast && if (tindex == tlast &&
...@@ -481,16 +488,20 @@ map_unwritten( ...@@ -481,16 +488,20 @@ map_unwritten(
nblocks += bs; nblocks += bs;
atomic_add(bs, &pb->pb_io_remaining); atomic_add(bs, &pb->pb_io_remaining);
convert_page(inode, page, iomapp, pb, startio, all_bh); convert_page(inode, page, iomapp, pb, startio, all_bh);
if (nblocks >= ((ULONG_MAX - PAGE_SIZE) >> block_bits))
goto enough;
} }
} }
} }
enough:
size = nblocks; /* NB: using 64bit number here */ size = nblocks; /* NB: using 64bit number here */
size <<= block_bits; /* convert fsb's to byte range */ size <<= block_bits; /* convert fsb's to byte range */
XFS_BUF_DATAIO(pb); XFS_BUF_DATAIO(pb);
XFS_BUF_ASYNC(pb); XFS_BUF_ASYNC(pb);
XFS_BUF_SET_SIZE(pb, size); XFS_BUF_SET_SIZE(pb, size);
XFS_BUF_SET_COUNT(pb, size);
XFS_BUF_SET_OFFSET(pb, offset); XFS_BUF_SET_OFFSET(pb, offset);
XFS_BUF_SET_FSPRIVATE(pb, LINVFS_GET_VP(inode)); XFS_BUF_SET_FSPRIVATE(pb, LINVFS_GET_VP(inode));
XFS_BUF_SET_IODONE_FUNC(pb, linvfs_unwritten_convert); XFS_BUF_SET_IODONE_FUNC(pb, linvfs_unwritten_convert);
...@@ -925,8 +936,10 @@ linvfs_get_block_core( ...@@ -925,8 +936,10 @@ linvfs_get_block_core(
} }
if (blocks) { if (blocks) {
size = (iomap.iomap_bsize - iomap.iomap_delta); loff_t iosize;
bh_result->b_size = min_t(ssize_t, size, blocks << inode->i_blkbits); iosize = (iomap.iomap_bsize - iomap.iomap_delta);
bh_result->b_size =
(ssize_t)min(iosize, (loff_t)(blocks << inode->i_blkbits));
} }
return 0; return 0;
......
...@@ -66,27 +66,26 @@ typedef enum { ...@@ -66,27 +66,26 @@ typedef enum {
/* /*
* xfs_iomap_t: File system I/O map * xfs_iomap_t: File system I/O map
* *
* The iomap_bn, iomap_offset and iomap_length fields are expressed in disk blocks. * The iomap_bn field is expressed in 512-byte blocks, and is where the
* The iomap_length field specifies the size of the underlying backing store * mapping starts on disk.
* for the particular mapping.
* *
* The iomap_bsize, iomap_size and iomap_delta fields are in bytes and indicate * The iomap_offset, iomap_bsize and iomap_delta fields are in bytes.
* the size of the mapping, the number of bytes that are valid to access * iomap_offset is the offset of the mapping in the file itself.
* (read or write), and the offset into the mapping, given the offset * iomap_bsize is the size of the mapping, iomap_delta is the
* supplied to the file I/O map routine. iomap_delta is the offset of the * desired data's offset into the mapping, given the offset supplied
* desired data from the beginning of the mapping. * to the file I/O map routine.
* *
* When a request is made to read beyond the logical end of the object, * 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 * iomap_size may be set to 0, but iomap_offset and iomap_length should be set
* the actual amount of underlying storage that has been allocated, if any. * to the actual amount of underlying storage that has been allocated, if any.
*/ */
typedef struct xfs_iomap { typedef struct xfs_iomap {
xfs_daddr_t iomap_bn; xfs_daddr_t iomap_bn; /* first 512b blk of mapping */
xfs_buftarg_t *iomap_target; xfs_buftarg_t *iomap_target;
loff_t iomap_offset; loff_t iomap_offset; /* offset of mapping, bytes */
size_t iomap_delta; loff_t iomap_bsize; /* size of mapping, bytes */
size_t iomap_bsize; size_t iomap_delta; /* offset into mapping, bytes */
iomap_flags_t iomap_flags; iomap_flags_t iomap_flags;
} xfs_iomap_t; } xfs_iomap_t;
......
...@@ -330,7 +330,7 @@ xfs_bulkstat( ...@@ -330,7 +330,7 @@ xfs_bulkstat(
* inode returned; 0 means start of the allocation group. * inode returned; 0 means start of the allocation group.
*/ */
rval = 0; rval = 0;
while ((ubleft/statstruct_size) > 0 && agno < mp->m_sb.sb_agcount) { while (ubleft >= statstruct_size && agno < mp->m_sb.sb_agcount) {
bp = NULL; bp = NULL;
down_read(&mp->m_peraglock); down_read(&mp->m_peraglock);
error = xfs_ialloc_read_agi(mp, tp, agno, &agbp); error = xfs_ialloc_read_agi(mp, tp, agno, &agbp);
...@@ -415,7 +415,7 @@ xfs_bulkstat( ...@@ -415,7 +415,7 @@ xfs_bulkstat(
* Loop through inode btree records in this ag, * Loop through inode btree records in this ag,
* until we run out of inodes or space in the buffer. * until we run out of inodes or space in the buffer.
*/ */
while (irbp < irbufend && icount < (ubleft/statstruct_size)) { while (irbp < irbufend && icount < ubcount) {
/* /*
* Loop as long as we're unable to read the * Loop as long as we're unable to read the
* inode btree. * inode btree.
...@@ -467,7 +467,7 @@ xfs_bulkstat( ...@@ -467,7 +467,7 @@ xfs_bulkstat(
*/ */
irbufend = irbp; irbufend = irbp;
for (irbp = irbuf; for (irbp = irbuf;
irbp < irbufend && (ubleft/statstruct_size) > 0; irbp++) { irbp < irbufend && ubleft >= statstruct_size; irbp++) {
/* /*
* Read-ahead the next chunk's worth of inodes. * Read-ahead the next chunk's worth of inodes.
*/ */
......
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