linux-i-alloc-sem-usage-20030701
authorDerrick Brashear <shadow@dementia.org>
Tue, 1 Jul 2003 23:21:34 +0000 (23:21 +0000)
committerDerrick Brashear <shadow@dementia.org>
Tue, 1 Jul 2003 23:21:34 +0000 (23:21 +0000)
modern kernels appear to use i_alloc_sem around truncation

acconfig.h
acinclude.m4
src/afs/LINUX/osi_file.c
src/afs/afs_vcache.c
src/cf/linux-test2.m4

index e3a6f32..f31222d 100644 (file)
@@ -45,6 +45,7 @@ static /**/const char *const rcsid[] = { (char *)rcsid, "\100(#)" msg }
 #undef STRUCT_FS_HAS_FS_ROLLED
 #undef STRUCT_INODE_HAS_I_DEVICES
 #undef STRUCT_INODE_HAS_I_DIRTY_DATA_BUFFERS
+#undef STRUCT_INODE_HAS_I_ALLOC_SEM
 #undef STRUCT_INODE_HAS_I_TRUNCATE_SEM
 #undef STRUCT_TASK_STRUCT_HAS_PARENT
 #undef STRUCT_TASK_STRUCT_HAS_REAL_PARENT
index dc23b9b..1fcc527 100644 (file)
@@ -165,6 +165,7 @@ case $system in
                 LINUX_EXPORTS_TASKLIST_LOCK
                 LINUX_FS_STRUCT_ADDRESS_SPACE_HAS_PAGE_LOCK
                 LINUX_FS_STRUCT_ADDRESS_SPACE_HAS_GFP_MASK
+                LINUX_FS_STRUCT_INODE_HAS_I_ALLOC_SEM
                 LINUX_FS_STRUCT_INODE_HAS_I_TRUNCATE_SEM
                 LINUX_FS_STRUCT_INODE_HAS_I_DIRTY_DATA_BUFFERS
                 LINUX_FS_STRUCT_INODE_HAS_I_DEVICES
@@ -254,6 +255,9 @@ case $system in
                 if test "x$ac_cv_linux_fs_struct_inode_has_i_truncate_sem" = "xyes"; then 
                  AC_DEFINE(STRUCT_INODE_HAS_I_TRUNCATE_SEM, 1, [define if your struct inode has truncate_sem])
                 fi
+                if test "x$ac_cv_linux_fs_struct_inode_has_i_alloc_sem" = "xyes"; then 
+                 AC_DEFINE(STRUCT_INODE_HAS_I_ALLOC_SEM, 1, [define if your struct inode has alloc_sem])
+                fi
                 if test "x$ac_cv_linux_fs_struct_inode_has_i_devices" = "xyes"; then 
                  AC_DEFINE(STRUCT_INODE_HAS_I_DEVICES, 1, [define if you struct inode has i_devices])
                 fi
index 8fe665a..73d2316 100644 (file)
@@ -122,6 +122,9 @@ int osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize)
     if (code || tstat.size <= asize) return code;
     MObtainWriteLock(&afs_xosi,321);    
     AFS_GUNLOCK();
+#ifdef STRUCT_INODE_HAS_I_ALLOC_SEM
+    down_write(&inode->i_alloc_sem);
+#endif
     down(&inode->i_sem);
     inode->i_size = newattrs.ia_size = asize;
     newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
@@ -152,6 +155,9 @@ int osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize)
 #endif
     code = -code;
     up(&inode->i_sem);
+#ifdef STRUCT_INODE_HAS_I_ALLOC_SEM
+    up_write(&inode->i_alloc_sem);
+#endif
     AFS_GLOCK();
     MReleaseWriteLock(&afs_xosi);
     return code;
index 9b3c010..8103d5f 100644 (file)
@@ -1088,6 +1088,9 @@ struct vcache *afs_NewVCache(struct VenusFid *afid, struct server *serverp)
 #ifdef STRUCT_INODE_HAS_I_TRUNCATE_SEM
        init_rwsem(&ip->i_truncate_sem);
 #endif
+#ifdef STRUCT_INODE_HAS_I_ALLOC_SEM
+       init_rwsem(&ip->i_alloc_sem);
+#endif
 #else
        sema_init(&ip->i_atomic_write, 1);
        init_waitqueue(&ip->i_wait);
index 3451ed6..2362dc0 100644 (file)
@@ -28,6 +28,21 @@ ac_cv_linux_fs_struct_inode_has_i_bytes=no)])
 AC_MSG_RESULT($ac_cv_linux_fs_struct_inode_has_i_bytes)
 CPPFLAGS="$save_CPPFLAGS"])
 
+AC_DEFUN(LINUX_FS_STRUCT_INODE_HAS_I_ALLOC_SEM, [
+AC_MSG_CHECKING(for i_alloc_sem in struct inode)
+save_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="-I${LINUX_KERNEL_PATH}/include -D__KERNEL__ $CPPFLAGS"
+AC_CACHE_VAL(ac_cv_linux_fs_struct_inode_has_i_alloc_sem,
+[
+AC_TRY_COMPILE(
+[#include <linux/fs.h>],
+[struct inode _i;
+printf("%x\n", _i.i_alloc_sem);], 
+ac_cv_linux_fs_struct_inode_has_i_alloc_sem=yes,
+ac_cv_linux_fs_struct_inode_has_i_alloc_sem=no)])
+AC_MSG_RESULT($ac_cv_linux_fs_struct_inode_has_i_alloc_sem)
+CPPFLAGS="$save_CPPFLAGS"])
+
 AC_DEFUN(LINUX_FS_STRUCT_INODE_HAS_I_TRUNCATE_SEM, [
 AC_MSG_CHECKING(for i_truncate_sem in struct inode)
 save_CPPFLAGS="$CPPFLAGS"