[Ocfs2-commits] rev 21 - in trunk/src: . inc
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Wed Feb 4 01:25:29 CST 2004
Author: manish
Date: 2004-02-04 01:25:27 -0600 (Wed, 04 Feb 2004)
New Revision: 21
Modified:
trunk/src/file.c
trunk/src/inc/ocfs.h
trunk/src/osb.c
Log:
* add an osb-wide "extend-sem" to serialize file extends in
ocfs_file_write. This will not help us if truncate/extend is called
from a setattr though :(
Modified: trunk/src/file.c
===================================================================
--- trunk/src/file.c 2004-02-04 07:24:00 UTC (rev 20)
+++ trunk/src/file.c 2004-02-04 07:25:27 UTC (rev 21)
@@ -682,17 +682,25 @@
}
}
+ newsize = count + *ppos;
- if (filp->f_flags & O_APPEND)
- newsize = count + inode->i_size;
- else
- newsize = count + *ppos;
+ if ((newsize > inode->i_size) || (filp->f_flags & O_APPEND)) {
+ down(&osb->extend_sem);
+ writingAtEOF = true;
- if (newsize > inode->i_size) {
- writingAtEOF = true;
- LOG_TRACE_STR ("Writing at EOF");
+ if (filp->f_flags & O_APPEND)
+ newsize = count + inode->i_size;
+
+ /* did someone beat us to it? */
+ if (newsize <= inode->i_size) {
+ writingAtEOF = false;
+ up(&osb->extend_sem);
+ }
}
+ if (writingAtEOF)
+ LOG_TRACE_STR ("Writing at EOF");
+
LOG_TRACE_ARGS ("ppos=%u.%u newsize=%u.%u cursize=%u.%u\n",
HI (*ppos), LO (*ppos), HI (newsize), LO (newsize),
HI (inode->i_size), LO (inode->i_size));
@@ -712,6 +720,7 @@
ret = -ENOSPC;
} else
ret = status;
+ up(&osb->extend_sem);
goto bail;
}
}
@@ -721,11 +730,12 @@
else
ret = generic_file_write (filp, buf, count, ppos);
- if (writingAtEOF && ret >= 0) {
+ if (writingAtEOF) {
LOG_TRACE_STR
("Generic_file_write ok, asking for OIN update now");
inode->i_size = newsize;
inode->i_blocks = (newsize + sb->s_blocksize) >> sb->s_blocksize_bits;
+ up(&osb->extend_sem);
}
bail:
Modified: trunk/src/inc/ocfs.h
===================================================================
--- trunk/src/inc/ocfs.h 2004-02-04 07:24:00 UTC (rev 20)
+++ trunk/src/inc/ocfs.h 2004-02-04 07:25:27 UTC (rev 21)
@@ -2022,6 +2022,7 @@
/* Protected by the trans_lock. */
struct buffer_head *local_alloc_bh;
ocfs_inode_hash inode_hash;
+ struct semaphore extend_sem;
};
typedef struct _ocfs_comm_info
Modified: trunk/src/osb.c
===================================================================
--- trunk/src/osb.c 2004-02-04 07:24:00 UTC (rev 20)
+++ trunk/src/osb.c 2004-02-04 07:25:27 UTC (rev 21)
@@ -53,6 +53,7 @@
init_MUTEX (&(osb->comm_lock));
init_MUTEX (&(osb->trans_lock));
+ init_MUTEX (&(osb->extend_sem));
spin_lock_init(&osb->recovery_map_lock);
osb->recovery_map = 0;
More information about the Ocfs2-commits
mailing list