]> err.no Git - linux-2.6/commitdiff
ocfs2: Remember rw lock level during direct io
authorMark Fasheh <mark.fasheh@oracle.com>
Tue, 17 Apr 2007 00:28:51 +0000 (17:28 -0700)
committerMark Fasheh <mark.fasheh@oracle.com>
Thu, 26 Apr 2007 22:07:45 +0000 (15:07 -0700)
Cluster locking might have been redone because a direct write won't
complete, so this needs to be reflected in the iocb.

Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>
fs/ocfs2/aops.c
fs/ocfs2/aops.h
fs/ocfs2/file.c

index b74971e19d54cf58744b53e0a58aa6474b29954d..56963e6c46c06acb21a9990887b48d46fd808d9b 100644 (file)
@@ -522,12 +522,17 @@ static void ocfs2_dio_end_io(struct kiocb *iocb,
                             void *private)
 {
        struct inode *inode = iocb->ki_filp->f_path.dentry->d_inode;
+       int level;
 
        /* this io's submitter should not have unlocked this before we could */
        BUG_ON(!ocfs2_iocb_is_rw_locked(iocb));
+
        ocfs2_iocb_clear_rw_locked(iocb);
-       up_read(&inode->i_alloc_sem);
-       ocfs2_rw_unlock(inode, 0);
+
+       level = ocfs2_iocb_rw_locked_level(iocb);
+       if (!level)
+               up_read(&inode->i_alloc_sem);
+       ocfs2_rw_unlock(inode, level);
 }
 
 /*
index 1b4ba5356a42cc19e5401169de575c7a7bf1c207..45821d479b5a3662028d99847dc64835f39b92fb 100644 (file)
@@ -97,9 +97,16 @@ int ocfs2_map_and_write_splice_data(struct inode *inode,
 /* all ocfs2_dio_end_io()'s fault */
 #define ocfs2_iocb_is_rw_locked(iocb) \
        test_bit(0, (unsigned long *)&iocb->private)
-#define ocfs2_iocb_set_rw_locked(iocb) \
-       set_bit(0, (unsigned long *)&iocb->private)
+static inline void ocfs2_iocb_set_rw_locked(struct kiocb *iocb, int level)
+{
+       set_bit(0, (unsigned long *)&iocb->private);
+       if (level)
+               set_bit(1, (unsigned long *)&iocb->private);
+       else
+               clear_bit(1, (unsigned long *)&iocb->private);
+}
 #define ocfs2_iocb_clear_rw_locked(iocb) \
        clear_bit(0, (unsigned long *)&iocb->private)
-
+#define ocfs2_iocb_rw_locked_level(iocb) \
+       test_bit(1, (unsigned long *)&iocb->private)
 #endif /* OCFS2_FILE_H */
index e34474c0467877e556b92f0116a601e7edce3f96..520a2a6d7670641db08d10c2f57143ea8c752d28 100644 (file)
@@ -1542,7 +1542,7 @@ relock:
        pos = *ppos;
 
        /* communicate with ocfs2_dio_end_io */
-       ocfs2_iocb_set_rw_locked(iocb);
+       ocfs2_iocb_set_rw_locked(iocb, rw_level);
 
        if (direct_io) {
                written = generic_file_direct_write(iocb, iov, &nr_segs, *ppos,
@@ -1788,7 +1788,7 @@ static ssize_t ocfs2_file_aio_read(struct kiocb *iocb,
                }
                rw_level = 0;
                /* communicate with ocfs2_dio_end_io */
-               ocfs2_iocb_set_rw_locked(iocb);
+               ocfs2_iocb_set_rw_locked(iocb, rw_level);
        }
 
        /*