vfs: push dentry_unhash on rename_dir into file systems
[linux-2.6.git] / fs / hpfs / file.c
index 5b53e5c..9b9eb69 100644 (file)
 
 static int hpfs_file_release(struct inode *inode, struct file *file)
 {
-       lock_kernel();
+       hpfs_lock(inode->i_sb);
        hpfs_write_if_changed(inode);
-       unlock_kernel();
+       hpfs_unlock(inode->i_sb);
        return 0;
 }
 
-int hpfs_file_fsync(struct file *file, struct dentry *dentry, int datasync)
+int hpfs_file_fsync(struct file *file, int datasync)
 {
-       /*return file_fsync(file, dentry);*/
+       /*return file_fsync(file, datasync);*/
        return 0; /* Don't fsync :-) */
 }
 
@@ -48,14 +48,14 @@ static secno hpfs_bmap(struct inode *inode, unsigned file_secno)
 static void hpfs_truncate(struct inode *i)
 {
        if (IS_IMMUTABLE(i)) return /*-EPERM*/;
-       lock_kernel();
+       hpfs_lock(i->i_sb);
        hpfs_i(i)->i_n_secs = 0;
        i->i_blocks = 1 + ((i->i_size + 511) >> 9);
        hpfs_i(i)->mmu_private = i->i_size;
        hpfs_truncate_btree(i->i_sb, i->i_ino, 1, ((i->i_size + 511) >> 9));
        hpfs_write_inode(i);
        hpfs_i(i)->i_n_secs = 0;
-       unlock_kernel();
+       hpfs_unlock(i->i_sb);
 }
 
 static int hpfs_get_block(struct inode *inode, sector_t iblock, struct buffer_head *bh_result, int create)
@@ -86,25 +86,41 @@ static int hpfs_writepage(struct page *page, struct writeback_control *wbc)
 {
        return block_write_full_page(page,hpfs_get_block, wbc);
 }
+
 static int hpfs_readpage(struct file *file, struct page *page)
 {
        return block_read_full_page(page,hpfs_get_block);
 }
-static int hpfs_prepare_write(struct file *file, struct page *page, unsigned from, unsigned to)
+
+static int hpfs_write_begin(struct file *file, struct address_space *mapping,
+                       loff_t pos, unsigned len, unsigned flags,
+                       struct page **pagep, void **fsdata)
 {
-       return cont_prepare_write(page,from,to,hpfs_get_block,
-               &hpfs_i(page->mapping->host)->mmu_private);
+       int ret;
+
+       *pagep = NULL;
+       ret = cont_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
+                               hpfs_get_block,
+                               &hpfs_i(mapping->host)->mmu_private);
+       if (unlikely(ret)) {
+               loff_t isize = mapping->host->i_size;
+               if (pos + len > isize)
+                       vmtruncate(mapping->host, isize);
+       }
+
+       return ret;
 }
+
 static sector_t _hpfs_bmap(struct address_space *mapping, sector_t block)
 {
        return generic_block_bmap(mapping,block,hpfs_get_block);
 }
+
 const struct address_space_operations hpfs_aops = {
        .readpage = hpfs_readpage,
        .writepage = hpfs_writepage,
-       .sync_page = block_sync_page,
-       .prepare_write = hpfs_prepare_write,
-       .commit_write = generic_commit_write,
+       .write_begin = hpfs_write_begin,
+       .write_end = generic_write_end,
        .bmap = _hpfs_bmap
 };
 
@@ -135,5 +151,5 @@ const struct file_operations hpfs_file_ops =
 const struct inode_operations hpfs_file_iops =
 {
        .truncate       = hpfs_truncate,
-       .setattr        = hpfs_notify_change,
+       .setattr        = hpfs_setattr,
 };