[Ocfs2-commits] mfasheh commits r1284 - trunk/src
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Mon Jul 19 22:53:05 CDT 2004
Author: mfasheh
Date: 2004-07-19 21:53:04 -0500 (Mon, 19 Jul 2004)
New Revision: 1284
Modified:
trunk/src/alloc.c
Log:
* fix the logic in lookup_file_allocation for rechecking the extent
map after having re-acquired ip_sem and ip_io_sem.
* make a printk in lookup_file_allocation more informative
Modified: trunk/src/alloc.c
===================================================================
--- trunk/src/alloc.c 2004-07-19 19:56:15 UTC (rev 1283)
+++ trunk/src/alloc.c 2004-07-20 02:53:04 UTC (rev 1284)
@@ -2583,14 +2583,23 @@
if (!locked)
down(&(OCFS_I(inode)->ip_sem));
+ /* Make sure we're not trying to read past end of file --
+ * alloc_size should be up to date as any nodes changing it
+ * will have sent us an UPDATE_INODE message. */
+ if (Vbo >= OCFS_I(inode)->ip_alloc_size) {
+ if (!locked)
+ up(&(OCFS_I(inode)->ip_sem));
+ status = -EIO;
+ LOG_ERROR_STATUS(status);
+ goto finally;
+ }
+
check_alloc_sz:
status = 0;
- if (Vbo < OCFS_I(inode)->ip_alloc_size)
- status = ocfs_lookup_extent_map_entry(osb,
- &(OCFS_I(inode)->ip_ext_map),
- Vbo, Lbo, &cnt,
- &NumIndex);
+ status = ocfs_lookup_extent_map_entry(osb,
+ &(OCFS_I(inode)->ip_ext_map),
+ Vbo, Lbo, &cnt, &NumIndex);
if (!locked)
up(&(OCFS_I(inode)->ip_sem));
@@ -2605,24 +2614,18 @@
/* Ok, we didn't find it in the extent map (or we need to
* refresh as alloc sizes don't match up. */
- if (!locked) {
+ if (!locked && !have_io_sem) {
/* yay for lock ordering. We must take ip_io_sem
* before ip_sem. */
down_read(&OCFS_I(inode)->ip_io_sem);
down(&OCFS_I(inode)->ip_sem);
- }
+ have_io_sem = 1;
- /* Make sure we still need to hit disk. */
- if (Vbo >= OCFS_I(inode)->ip_alloc_size) {
- if (!locked)
- up_read(&OCFS_I(inode)->ip_io_sem);
+ /* check one more time in case someone has updated the
+ * extent map underneath us. */
goto check_alloc_sz;
}
- up(&OCFS_I(inode)->ip_sem);
- if (!locked)
- have_io_sem = 1;
-
remainingLength = (u64)bytecount;
localVbo = Vbo;
@@ -2741,7 +2744,7 @@
status = 0;
} else {
status = -EFAIL;
- printk("failed to lookup extmap... vbo=%llu mapcount=%d\n", Vbo, OCFS_I(inode)->ip_ext_map.count);
+ printk("failed to lookup extmap... vbo=%llu mapcount=%d, inode = %lu, alloc_size = %llu\n", Vbo, OCFS_I(inode)->ip_ext_map.count, inode->i_ino, OCFS_I(inode)->ip_alloc_size);
}
if (!locked)
up(&(OCFS_I(inode)->ip_sem));
More information about the Ocfs2-commits
mailing list