cifs: fix pointer initialization and checks in cifs_follow_symlink (try #4)
[safe/jmp/linux-2.6] / fs / nilfs2 / mdt.c
index 6ab8475..bb78745 100644 (file)
@@ -77,19 +77,22 @@ static int nilfs_mdt_create_block(struct inode *inode, unsigned long block,
                                                     void *))
 {
        struct the_nilfs *nilfs = NILFS_MDT(inode)->mi_nilfs;
-       struct nilfs_sb_info *writer = NULL;
        struct super_block *sb = inode->i_sb;
        struct nilfs_transaction_info ti;
        struct buffer_head *bh;
        int err;
 
        if (!sb) {
-               writer = nilfs_get_writer(nilfs);
-               if (!writer) {
+               /*
+                * Make sure this function is not called from any
+                * read-only context.
+                */
+               if (!nilfs->ns_writer) {
+                       WARN_ON(1);
                        err = -EROFS;
                        goto out;
                }
-               sb = writer->s_super;
+               sb = nilfs->ns_writer->s_super;
        }
 
        nilfs_transaction_begin(sb, &ti, 0);
@@ -123,9 +126,10 @@ static int nilfs_mdt_create_block(struct inode *inode, unsigned long block,
        brelse(bh);
 
  failed_unlock:
-       nilfs_transaction_end(sb, !err);
-       if (writer)
-               nilfs_put_writer(nilfs);
+       if (likely(!err))
+               err = nilfs_transaction_commit(sb);
+       else
+               nilfs_transaction_abort(sb);
  out:
        return err;
 }
@@ -151,10 +155,8 @@ nilfs_mdt_submit_block(struct inode *inode, unsigned long blkoff,
                        ret = -EBUSY;
                        goto failed_bh;
                }
-       } else {
-               BUG_ON(mode != READ);
+       } else /* mode == READ */
                lock_buffer(bh);
-       }
 
        if (buffer_uptodate(bh)) {
                unlock_buffer(bh);
@@ -298,7 +300,7 @@ int nilfs_mdt_delete_block(struct inode *inode, unsigned long block)
        int err;
 
        err = nilfs_bmap_delete(ii->i_bmap, block);
-       if (likely(!err)) {
+       if (!err || err == -ENOENT) {
                nilfs_mdt_mark_dirty(inode);
                nilfs_mdt_forget_block(inode, block);
        }