[PATCH] reiserfs: use generic_permission
[powerpc.git] / fs / reiserfs / file.c
index c20babd..1cad5d0 100644 (file)
@@ -49,7 +49,7 @@ static int reiserfs_file_release(struct inode *inode, struct file *filp)
        }
 
        reiserfs_write_lock(inode->i_sb);
-       down(&inode->i_sem);
+       mutex_lock(&inode->i_mutex);
        /* freeing preallocation only involves relogging blocks that
         * are already in the current transaction.  preallocation gets
         * freed at the end of each transaction, so it is impossible for
@@ -100,7 +100,7 @@ static int reiserfs_file_release(struct inode *inode, struct file *filp)
                err = reiserfs_truncate_file(inode, 0);
        }
       out:
-       up(&inode->i_sem);
+       mutex_unlock(&inode->i_mutex);
        reiserfs_write_unlock(inode->i_sb);
        return err;
 }
@@ -192,6 +192,8 @@ static int reiserfs_allocate_blocks_for_region(struct reiserfs_transaction_handl
 
        allocated_blocks = kmalloc((blocks_to_allocate + will_prealloc) *
                                   sizeof(b_blocknr_t), GFP_NOFS);
+       if (!allocated_blocks)
+               return -ENOMEM;
 
        /* First we compose a key to point at the writing position, we want to do
           that outside of any locking region. */
@@ -251,12 +253,12 @@ static int reiserfs_allocate_blocks_for_region(struct reiserfs_transaction_handl
                                                       blocks_to_allocate,
                                                       blocks_to_allocate);
                        if (res != CARRY_ON) {
-                               res = -ENOSPC;
+                               res = res == QUOTA_EXCEEDED ? -EDQUOT : -ENOSPC;
                                pathrelse(&path);
                                goto error_exit;
                        }
                } else {
-                       res = -ENOSPC;
+                       res = res == QUOTA_EXCEEDED ? -EDQUOT : -ENOSPC;
                        pathrelse(&path);
                        goto error_exit;
                }
@@ -1342,7 +1344,7 @@ static ssize_t reiserfs_file_write(struct file *file,     /* the file we are going t
        if (unlikely(!access_ok(VERIFY_READ, buf, count)))
                return -EFAULT;
 
-       down(&inode->i_sem);    // locks the entire file for just us
+       mutex_lock(&inode->i_mutex);    // locks the entire file for just us
 
        pos = *ppos;
 
@@ -1360,7 +1362,7 @@ static ssize_t reiserfs_file_write(struct file *file,     /* the file we are going t
        if (res)
                goto out;
 
-       inode_update_time(inode, 1);    /* Both mtime and ctime */
+       file_update_time(file);
 
        // Ok, we are done with all the checks.
 
@@ -1532,12 +1534,12 @@ static ssize_t reiserfs_file_write(struct file *file,   /* the file we are going t
                    generic_osync_inode(inode, file->f_mapping,
                                        OSYNC_METADATA | OSYNC_DATA);
 
-       up(&inode->i_sem);
+       mutex_unlock(&inode->i_mutex);
        reiserfs_async_progress_wait(inode->i_sb);
        return (already_written != 0) ? already_written : res;
 
       out:
-       up(&inode->i_sem);      // unlock the file on exit.
+       mutex_unlock(&inode->i_mutex);  // unlock the file on exit.
        return res;
 }