summaryrefslogtreecommitdiff
path: root/fs/xfs/linux-2.6/xfs_lrw.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-07 19:12:12 -0800
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-07 19:12:12 -0800
commit0b61a2ba5dfd1620731e717d686e6ade657fd975 (patch)
treedea84efd43934a7d6139048f87c4ba86d68d4b6d /fs/xfs/linux-2.6/xfs_lrw.c
parenta13ff0bb3feda8b1fcffc69951320277ed7c4101 (diff)
parentde2eeea609b55e8c3994133a565b39edeaaaaf69 (diff)
Merge branch 'for-linus' of git://oss.sgi.com:8090/xfs/xfs-2.6
* 'for-linus' of git://oss.sgi.com:8090/xfs/xfs-2.6: (62 commits) [XFS] add __init/__exit mark to specific init/cleanup functions [XFS] Fix oops in xfs_file_readdir() [XFS] kill xfs_root [XFS] keep i_nlink updated and use proper accessors [XFS] stop updating inode->i_blocks [XFS] Make xfs_ail_check check less by default [XFS] Move AIL pushing into it's own thread [XFS] use generic_permission [XFS] stop re-checking permissions in xfs_swapext [XFS] clean up xfs_swapext [XFS] remove permission check from xfs_change_file_space [XFS] prevent panic during log recovery due to bogus op_hdr length [XFS] Cleanup various fid related bits: [XFS] Fix xfs_lowbit64 [XFS] Remove CFORK macros and use code directly in IFORK and DFORK macros. [XFS] kill superflous buffer locking (2nd attempt) [XFS] Use kernel-supplied "roundup_pow_of_two" for simplicity [XFS] Remove the BPCSHIFT and NB* based macros from XFS. [XFS] Remove bogus assert [XFS] optimize XFS_IS_REALTIME_INODE w/o realtime config ...
Diffstat (limited to 'fs/xfs/linux-2.6/xfs_lrw.c')
-rw-r--r--fs/xfs/linux-2.6/xfs_lrw.c122
1 files changed, 46 insertions, 76 deletions
diff --git a/fs/xfs/linux-2.6/xfs_lrw.c b/fs/xfs/linux-2.6/xfs_lrw.c
index 6f614f35f650..166353388490 100644
--- a/fs/xfs/linux-2.6/xfs_lrw.c
+++ b/fs/xfs/linux-2.6/xfs_lrw.c
@@ -58,14 +58,12 @@
void
xfs_rw_enter_trace(
int tag,
- xfs_iocore_t *io,
+ xfs_inode_t *ip,
void *data,
size_t segs,
loff_t offset,
int ioflags)
{
- xfs_inode_t *ip = XFS_IO_INODE(io);
-
if (ip->i_rwtrace == NULL)
return;
ktrace_enter(ip->i_rwtrace,
@@ -78,8 +76,8 @@ xfs_rw_enter_trace(
(void *)((unsigned long)((offset >> 32) & 0xffffffff)),
(void *)((unsigned long)(offset & 0xffffffff)),
(void *)((unsigned long)ioflags),
- (void *)((unsigned long)((io->io_new_size >> 32) & 0xffffffff)),
- (void *)((unsigned long)(io->io_new_size & 0xffffffff)),
+ (void *)((unsigned long)((ip->i_new_size >> 32) & 0xffffffff)),
+ (void *)((unsigned long)(ip->i_new_size & 0xffffffff)),
(void *)((unsigned long)current_pid()),
(void *)NULL,
(void *)NULL,
@@ -89,13 +87,12 @@ xfs_rw_enter_trace(
void
xfs_inval_cached_trace(
- xfs_iocore_t *io,
+ xfs_inode_t *ip,
xfs_off_t offset,
xfs_off_t len,
xfs_off_t first,
xfs_off_t last)
{
- xfs_inode_t *ip = XFS_IO_INODE(io);
if (ip->i_rwtrace == NULL)
return;
@@ -131,7 +128,7 @@ xfs_inval_cached_trace(
*/
STATIC int
xfs_iozero(
- struct inode *ip, /* inode */
+ struct xfs_inode *ip, /* inode */
loff_t pos, /* offset in file */
size_t count) /* size of data to zero */
{
@@ -139,7 +136,7 @@ xfs_iozero(
struct address_space *mapping;
int status;
- mapping = ip->i_mapping;
+ mapping = ip->i_vnode->i_mapping;
do {
unsigned offset, bytes;
void *fsdata;
@@ -205,7 +202,7 @@ xfs_read(
if (unlikely(ioflags & IO_ISDIRECT)) {
xfs_buftarg_t *target =
- (ip->i_d.di_flags & XFS_DIFLAG_REALTIME) ?
+ XFS_IS_REALTIME_INODE(ip) ?
mp->m_rtdev_targp : mp->m_ddev_targp;
if ((*offset & target->bt_smask) ||
(size & target->bt_smask)) {
@@ -246,9 +243,8 @@ xfs_read(
if (unlikely(ioflags & IO_ISDIRECT)) {
if (VN_CACHED(vp))
- ret = xfs_flushinval_pages(ip,
- ctooff(offtoct(*offset)),
- -1, FI_REMAPF_LOCKED);
+ ret = xfs_flushinval_pages(ip, (*offset & PAGE_CACHE_MASK),
+ -1, FI_REMAPF_LOCKED);
mutex_unlock(&inode->i_mutex);
if (ret) {
xfs_iunlock(ip, XFS_IOLOCK_SHARED);
@@ -256,7 +252,7 @@ xfs_read(
}
}
- xfs_rw_enter_trace(XFS_READ_ENTER, &ip->i_iocore,
+ xfs_rw_enter_trace(XFS_READ_ENTER, ip,
(void *)iovp, segs, *offset, ioflags);
iocb->ki_pos = *offset;
@@ -301,7 +297,7 @@ xfs_splice_read(
return -error;
}
}
- xfs_rw_enter_trace(XFS_SPLICE_READ_ENTER, &ip->i_iocore,
+ xfs_rw_enter_trace(XFS_SPLICE_READ_ENTER, ip,
pipe, count, *ppos, ioflags);
ret = generic_file_splice_read(infilp, ppos, pipe, count, flags);
if (ret > 0)
@@ -323,7 +319,6 @@ xfs_splice_write(
{
bhv_vnode_t *vp = XFS_ITOV(ip);
xfs_mount_t *mp = ip->i_mount;
- xfs_iocore_t *io = &ip->i_iocore;
ssize_t ret;
struct inode *inode = outfilp->f_mapping->host;
xfs_fsize_t isize, new_size;
@@ -350,10 +345,10 @@ xfs_splice_write(
xfs_ilock(ip, XFS_ILOCK_EXCL);
if (new_size > ip->i_size)
- io->io_new_size = new_size;
+ ip->i_new_size = new_size;
xfs_iunlock(ip, XFS_ILOCK_EXCL);
- xfs_rw_enter_trace(XFS_SPLICE_WRITE_ENTER, &ip->i_iocore,
+ xfs_rw_enter_trace(XFS_SPLICE_WRITE_ENTER, ip,
pipe, count, *ppos, ioflags);
ret = generic_file_splice_write(pipe, outfilp, ppos, count, flags);
if (ret > 0)
@@ -370,9 +365,9 @@ xfs_splice_write(
xfs_iunlock(ip, XFS_ILOCK_EXCL);
}
- if (io->io_new_size) {
+ if (ip->i_new_size) {
xfs_ilock(ip, XFS_ILOCK_EXCL);
- io->io_new_size = 0;
+ ip->i_new_size = 0;
if (ip->i_d.di_size > ip->i_size)
ip->i_d.di_size = ip->i_size;
xfs_iunlock(ip, XFS_ILOCK_EXCL);
@@ -389,20 +384,19 @@ xfs_splice_write(
*/
STATIC int /* error (positive) */
xfs_zero_last_block(
- struct inode *ip,
- xfs_iocore_t *io,
+ xfs_inode_t *ip,
xfs_fsize_t offset,
xfs_fsize_t isize)
{
xfs_fileoff_t last_fsb;
- xfs_mount_t *mp = io->io_mount;
+ xfs_mount_t *mp = ip->i_mount;
int nimaps;
int zero_offset;
int zero_len;
int error = 0;
xfs_bmbt_irec_t imap;
- ASSERT(ismrlocked(io->io_lock, MR_UPDATE) != 0);
+ ASSERT(ismrlocked(&ip->i_lock, MR_UPDATE) != 0);
zero_offset = XFS_B_FSB_OFFSET(mp, isize);
if (zero_offset == 0) {
@@ -415,7 +409,7 @@ xfs_zero_last_block(
last_fsb = XFS_B_TO_FSBT(mp, isize);
nimaps = 1;
- error = XFS_BMAPI(mp, NULL, io, last_fsb, 1, 0, NULL, 0, &imap,
+ error = xfs_bmapi(NULL, ip, last_fsb, 1, 0, NULL, 0, &imap,
&nimaps, NULL, NULL);
if (error) {
return error;
@@ -433,14 +427,14 @@ xfs_zero_last_block(
* out sync. We need to drop the ilock while we do this so we
* don't deadlock when the buffer cache calls back to us.
*/
- XFS_IUNLOCK(mp, io, XFS_ILOCK_EXCL| XFS_EXTSIZE_RD);
+ xfs_iunlock(ip, XFS_ILOCK_EXCL| XFS_EXTSIZE_RD);
zero_len = mp->m_sb.sb_blocksize - zero_offset;
if (isize + zero_len > offset)
zero_len = offset - isize;
error = xfs_iozero(ip, isize, zero_len);
- XFS_ILOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);
+ xfs_ilock(ip, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);
ASSERT(error >= 0);
return error;
}
@@ -458,35 +452,33 @@ xfs_zero_last_block(
int /* error (positive) */
xfs_zero_eof(
- bhv_vnode_t *vp,
- xfs_iocore_t *io,
+ xfs_inode_t *ip,
xfs_off_t offset, /* starting I/O offset */
xfs_fsize_t isize) /* current inode size */
{
- struct inode *ip = vn_to_inode(vp);
+ xfs_mount_t *mp = ip->i_mount;
xfs_fileoff_t start_zero_fsb;
xfs_fileoff_t end_zero_fsb;
xfs_fileoff_t zero_count_fsb;
xfs_fileoff_t last_fsb;
xfs_fileoff_t zero_off;
xfs_fsize_t zero_len;
- xfs_mount_t *mp = io->io_mount;
int nimaps;
int error = 0;
xfs_bmbt_irec_t imap;
- ASSERT(ismrlocked(io->io_lock, MR_UPDATE));
- ASSERT(ismrlocked(io->io_iolock, MR_UPDATE));
+ ASSERT(ismrlocked(&ip->i_lock, MR_UPDATE));
+ ASSERT(ismrlocked(&ip->i_iolock, MR_UPDATE));
ASSERT(offset > isize);
/*
* First handle zeroing the block on which isize resides.
* We only zero a part of that block so it is handled specially.
*/
- error = xfs_zero_last_block(ip, io, offset, isize);
+ error = xfs_zero_last_block(ip, offset, isize);
if (error) {
- ASSERT(ismrlocked(io->io_lock, MR_UPDATE));
- ASSERT(ismrlocked(io->io_iolock, MR_UPDATE));
+ ASSERT(ismrlocked(&ip->i_lock, MR_UPDATE));
+ ASSERT(ismrlocked(&ip->i_iolock, MR_UPDATE));
return error;
}
@@ -514,11 +506,11 @@ xfs_zero_eof(
while (start_zero_fsb <= end_zero_fsb) {
nimaps = 1;
zero_count_fsb = end_zero_fsb - start_zero_fsb + 1;
- error = XFS_BMAPI(mp, NULL, io, start_zero_fsb, zero_count_fsb,
+ error = xfs_bmapi(NULL, ip, start_zero_fsb, zero_count_fsb,
0, NULL, 0, &imap, &nimaps, NULL, NULL);
if (error) {
- ASSERT(ismrlocked(io->io_lock, MR_UPDATE));
- ASSERT(ismrlocked(io->io_iolock, MR_UPDATE));
+ ASSERT(ismrlocked(&ip->i_lock, MR_UPDATE));
+ ASSERT(ismrlocked(&ip->i_iolock, MR_UPDATE));
return error;
}
ASSERT(nimaps > 0);
@@ -542,7 +534,7 @@ xfs_zero_eof(
* Drop the inode lock while we're doing the I/O.
* We'll still have the iolock to protect us.
*/
- XFS_IUNLOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);
+ xfs_iunlock(ip, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);
zero_off = XFS_FSB_TO_B(mp, start_zero_fsb);
zero_len = XFS_FSB_TO_B(mp, imap.br_blockcount);
@@ -558,14 +550,13 @@ xfs_zero_eof(
start_zero_fsb = imap.br_startoff + imap.br_blockcount;
ASSERT(start_zero_fsb <= (end_zero_fsb + 1));
- XFS_ILOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);
+ xfs_ilock(ip, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);
}
return 0;
out_lock:
-
- XFS_ILOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);
+ xfs_ilock(ip, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);
ASSERT(error >= 0);
return error;
}
@@ -587,7 +578,6 @@ xfs_write(
xfs_mount_t *mp;
ssize_t ret = 0, error = 0;
xfs_fsize_t isize, new_size;
- xfs_iocore_t *io;
int iolock;
int eventsent = 0;
bhv_vrwlock_t locktype;
@@ -607,8 +597,7 @@ xfs_write(
if (count == 0)
return 0;
- io = &xip->i_iocore;
- mp = io->io_mount;
+ mp = xip->i_mount;
xfs_wait_for_freeze(mp, SB_FREEZE_WRITE);
@@ -667,7 +656,7 @@ start:
if (ioflags & IO_ISDIRECT) {
xfs_buftarg_t *target =
- (xip->i_d.di_flags & XFS_DIFLAG_REALTIME) ?
+ XFS_IS_REALTIME_INODE(xip) ?
mp->m_rtdev_targp : mp->m_ddev_targp;
if ((pos & target->bt_smask) || (count & target->bt_smask)) {
@@ -688,7 +677,7 @@ start:
new_size = pos + count;
if (new_size > xip->i_size)
- io->io_new_size = new_size;
+ xip->i_new_size = new_size;
if (likely(!(ioflags & IO_INVIS))) {
file_update_time(file);
@@ -706,7 +695,7 @@ start:
*/
if (pos > xip->i_size) {
- error = xfs_zero_eof(vp, io, pos, xip->i_size);
+ error = xfs_zero_eof(xip, pos, xip->i_size);
if (error) {
xfs_iunlock(xip, XFS_ILOCK_EXCL);
goto out_unlock_internal;
@@ -740,10 +729,10 @@ retry:
if ((ioflags & IO_ISDIRECT)) {
if (VN_CACHED(vp)) {
WARN_ON(need_i_mutex == 0);
- xfs_inval_cached_trace(io, pos, -1,
- ctooff(offtoct(pos)), -1);
+ xfs_inval_cached_trace(xip, pos, -1,
+ (pos & PAGE_CACHE_MASK), -1);
error = xfs_flushinval_pages(xip,
- ctooff(offtoct(pos)),
+ (pos & PAGE_CACHE_MASK),
-1, FI_REMAPF_LOCKED);
if (error)
goto out_unlock_internal;
@@ -751,7 +740,7 @@ retry:
if (need_i_mutex) {
/* demote the lock now the cached pages are gone */
- XFS_ILOCK_DEMOTE(mp, io, XFS_IOLOCK_EXCL);
+ xfs_ilock_demote(xip, XFS_IOLOCK_EXCL);
mutex_unlock(&inode->i_mutex);
iolock = XFS_IOLOCK_SHARED;
@@ -759,7 +748,7 @@ retry:
need_i_mutex = 0;
}
- xfs_rw_enter_trace(XFS_DIOWR_ENTER, io, (void *)iovp, segs,
+ xfs_rw_enter_trace(XFS_DIOWR_ENTER, xip, (void *)iovp, segs,
*offset, ioflags);
ret = generic_file_direct_write(iocb, iovp,
&segs, pos, offset, count, ocount);
@@ -779,7 +768,7 @@ retry:
goto relock;
}
} else {
- xfs_rw_enter_trace(XFS_WRITE_ENTER, io, (void *)iovp, segs,
+ xfs_rw_enter_trace(XFS_WRITE_ENTER, xip, (void *)iovp, segs,
*offset, ioflags);
ret = generic_file_buffered_write(iocb, iovp, segs,
pos, offset, count, ret);
@@ -843,9 +832,9 @@ retry:
}
out_unlock_internal:
- if (io->io_new_size) {
+ if (xip->i_new_size) {
xfs_ilock(xip, XFS_ILOCK_EXCL);
- io->io_new_size = 0;
+ xip->i_new_size = 0;
/*
* If this was a direct or synchronous I/O that failed (such
* as ENOSPC) then part of the I/O may have been written to
@@ -894,25 +883,6 @@ xfs_bdstrat_cb(struct xfs_buf *bp)
}
}
-
-int
-xfs_bmap(
- xfs_inode_t *ip,
- xfs_off_t offset,
- ssize_t count,
- int flags,
- xfs_iomap_t *iomapp,
- int *niomaps)
-{
- xfs_iocore_t *io = &ip->i_iocore;
-
- ASSERT((ip->i_d.di_mode & S_IFMT) == S_IFREG);
- ASSERT(((ip->i_d.di_flags & XFS_DIFLAG_REALTIME) != 0) ==
- ((ip->i_iocore.io_flags & XFS_IOCORE_RT) != 0));
-
- return xfs_iomap(io, offset, count, flags, iomapp, niomaps);
-}
-
/*
* Wrapper around bdstrat so that we can stop data
* from going to disk in case we are shutting down the filesystem.