From: Mark Tinguely <tinguely@sgi.com>
To: jeff.liu@oracle.com
Cc: Christoph Hellwig <hch@infradead.org>, Ben Myers <bpm@sgi.com>,
Chris Mason <chris.mason@oracle.com>,
xfs@oss.sgi.com
Subject: Re: Introduce SEEK_DATA/SEEK_HOLE to XFS V5
Date: Wed, 11 Jan 2012 15:06:09 -0600 [thread overview]
Message-ID: <4F0DF9C1.2060302@sgi.com> (raw)
In-Reply-To: <4F0D21E5.7010908@oracle.com>
Good work. I know this is an important addition.
The test in the for loop of the xfs_seek_data() and xfs_seek_hole()
routines,
are independent of each other except in order of them being called.
One could add a "continue" statement after computing the offset for the next
iteration of the loop.
This allows the addition of an error condition if no conditions are matched.
Rough patch relative to your patch of the idea.
--- fs/xfs/xfs_file.c.orig 2012-01-11 08:50:50.000000000 -0600
+++ fs/xfs/xfs_file.c 2012-01-11 09:12:47.000000000 -0600
@@ -1265,7 +1265,7 @@ xfs_seek_data(
ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
len = XFS_B_TO_FSB(mp, isize);
- for (;;) {
+ do {
struct xfs_bmbt_irec map[2];
int nmap = 2;
loff_t seekoff;
@@ -1323,6 +1323,7 @@ xfs_seek_data(
}
fsbno = map[1].br_startoff + map[1].br_blockcount;
+ continue;
}
/*
@@ -1366,6 +1367,7 @@ xfs_seek_data(
}
fsbno = map[1].br_startoff + map[1].br_blockcount;
+ continue;
}
/* Landed in a delay allocated extent or a real data extent */
@@ -1376,11 +1378,14 @@ xfs_seek_data(
break;
}
+ error = ENXIO;
+ goto out_lock;
+ } while (XFS_FSB_TO_B(mp, fsbno) < isize);
+
/* Return ENXIO if beyond eof */
- if (XFS_FSB_TO_B(mp, fsbno) > isize) {
- error = ENXIO;
- goto out_lock;
- }
+ if (XFS_FSB_TO_B(mp, fsbno) > isize) {
+ error = ENXIO;
+ goto out_lock;
}
if (offset < start)
@@ -1424,7 +1429,7 @@ xfs_seek_hole(
ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
len = XFS_B_TO_FSB(mp, isize);
- for (;;) {
+ do {
struct xfs_bmbt_irec map[2];
int nmap = 2;
loff_t seekoff;
@@ -1507,6 +1512,7 @@ xfs_seek_hole(
}
fsbno = map[1].br_startoff + map[1].br_blockcount;
+ continue;
}
/*
@@ -1555,6 +1561,7 @@ xfs_seek_hole(
}
fsbno = map[1].br_startoff + map[1].br_blockcount;
+ continue;
}
/* Landed in a hole, its fine to return */
@@ -1564,11 +1571,14 @@ xfs_seek_hole(
break;
}
+ error = ENXIO;
+ goto out_lock;
+ } while (XFS_FSB_TO_B(mp, fsbno) < isize);
+
/* Return ENXIO if beyond eof */
- if (XFS_FSB_TO_B(mp, fsbno) > isize) {
- error = ENXIO;
- goto out_lock;
- }
+ if (XFS_FSB_TO_B(mp, fsbno) > isize) {
+ error = ENXIO;
+ goto out_lock;
}
if (offset < start)
--Mark Tinguely
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2012-01-11 21:06 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-06 13:28 Introduce SEEK_DATA/SEEK_HOLE to XFS V5 Jeff Liu
2012-01-10 17:18 ` Ben Myers
2012-01-11 5:45 ` Jeff Liu
2012-01-11 21:06 ` Mark Tinguely [this message]
2012-01-12 16:22 ` Christoph Hellwig
2012-01-12 17:50 ` Ben Myers
2012-01-11 21:07 ` Mark Tinguely
2012-01-12 13:29 ` Jeff Liu
2012-01-12 16:39 ` Christoph Hellwig
2012-01-13 2:14 ` Jeff Liu
2012-01-11 21:12 ` Mark Tinguely
2012-01-12 13:52 ` Jeff Liu
2012-01-12 15:01 ` Mark Tinguely
2012-01-12 16:41 ` Christoph Hellwig
2012-01-12 17:39 ` Ben Myers
2012-01-13 2:41 ` Jeff Liu
2012-01-11 15:43 ` Ben Myers
2012-01-11 22:28 ` Ben Myers
2012-01-12 13:21 ` Jeff Liu
2012-01-12 12:53 ` Jeff Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F0DF9C1.2060302@sgi.com \
--to=tinguely@sgi.com \
--cc=bpm@sgi.com \
--cc=chris.mason@oracle.com \
--cc=hch@infradead.org \
--cc=jeff.liu@oracle.com \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox