]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux...
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 28 Oct 2010 03:13:18 +0000 (20:13 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 28 Oct 2010 03:13:18 +0000 (20:13 -0700)
* 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs-2.6: (24 commits)
  quota: Fix possible oops in __dquot_initialize()
  ext3: Update kernel-doc comments
  jbd/2: fixed typos
  ext2: fixed typo.
  ext3: Fix debug messages in ext3_group_extend()
  jbd: Convert atomic_inc() to get_bh()
  ext3: Remove misplaced BUFFER_TRACE() in ext3_truncate()
  jbd: Fix debug message in do_get_write_access()
  jbd: Check return value of __getblk()
  ext3: Use DIV_ROUND_UP() on group desc block counting
  ext3: Return proper error code on ext3_fill_super()
  ext3: Remove unnecessary casts on bh->b_data
  ext3: Cleanup ext3_setup_super()
  quota: Fix issuing of warnings from dquot_transfer
  quota: fix dquot_disable vs dquot_transfer race v2
  jbd: Convert bitops to buffer fns
  ext3/jbd: Avoid WARN() messages when failing to write the superblock
  jbd: Use offset_in_page() instead of manual calculation
  jbd: Remove unnecessary goto statement
  jbd: Use printk_ratelimited() in journal_alloc_journal_head()
  ...

1  2 
fs/ext3/inode.c
fs/ext3/super.c
fs/jbd/commit.c
fs/jbd2/journal.c

diff --combined fs/ext3/inode.c
index ad05353040a12338c1a0c84626abcfc20f96408f,ef1c23a225f71be074ff02531af0decf6633577a..a9580617edd24dc4b4e94df75265f1ce25cec8f1
@@@ -498,7 -498,7 +498,7 @@@ static ext3_fsblk_t ext3_find_goal(stru
  }
  
  /**
-  *    ext3_blks_to_allocate: Look up the block map and count the number
+  *    ext3_blks_to_allocate - Look up the block map and count the number
   *    of direct blocks need to be allocated for the given branch.
   *
   *    @branch: chain of indirect blocks
@@@ -536,14 -536,18 +536,18 @@@ static int ext3_blks_to_allocate(Indire
  }
  
  /**
-  *    ext3_alloc_blocks: multiple allocate blocks needed for a branch
+  *    ext3_alloc_blocks - multiple allocate blocks needed for a branch
+  *    @handle: handle for this transaction
+  *    @inode: owner
+  *    @goal: preferred place for allocation
   *    @indirect_blks: the number of blocks need to allocate for indirect
   *                    blocks
-  *
+  *    @blks:  number of blocks need to allocated for direct blocks
   *    @new_blocks: on return it will store the new block numbers for
   *    the indirect blocks(if needed) and the first direct block,
-  *    @blks:  on return it will store the total number of allocated
-  *            direct blocks
+  *    @err: here we store the error value
+  *
+  *    return the number of direct blocks allocated
   */
  static int ext3_alloc_blocks(handle_t *handle, struct inode *inode,
                        ext3_fsblk_t goal, int indirect_blks, int blks,
@@@ -598,9 -602,11 +602,11 @@@ failed_out
  
  /**
   *    ext3_alloc_branch - allocate and set up a chain of blocks.
+  *    @handle: handle for this transaction
   *    @inode: owner
   *    @indirect_blks: number of allocated indirect blocks
   *    @blks: number of allocated direct blocks
+  *    @goal: preferred place for allocation
   *    @offsets: offsets (in the blocks) to store the pointers to next.
   *    @branch: place to store the chain in.
   *
@@@ -700,10 -706,9 +706,9 @@@ failed
  
  /**
   * ext3_splice_branch - splice the allocated branch onto inode.
+  * @handle: handle for this transaction
   * @inode: owner
   * @block: (logical) number of block we are adding
-  * @chain: chain of indirect blocks (with a missing link - see
-  *    ext3_alloc_branch)
   * @where: location of missing link
   * @num:   number of indirect blocks we are adding
   * @blks:  number of direct blocks we are adding
@@@ -1696,8 -1701,8 +1701,8 @@@ static int ext3_journalled_writepage(st
                 * doesn't seem much point in redirtying the page here.
                 */
                ClearPageChecked(page);
 -              ret = block_prepare_write(page, 0, PAGE_CACHE_SIZE,
 -                                      ext3_get_block);
 +              ret = __block_write_begin(page, 0, PAGE_CACHE_SIZE,
 +                                        ext3_get_block);
                if (ret != 0) {
                        ext3_journal_stop(handle);
                        goto out_unlock;
@@@ -2530,7 -2535,6 +2535,6 @@@ void ext3_truncate(struct inode *inode
                         */
                } else {
                        /* Shared branch grows from an indirect block */
-                       BUFFER_TRACE(partial->bh, "get_write_access");
                        ext3_free_branches(handle, inode, partial->bh,
                                        partial->p,
                                        partial->p+1, (chain+n-1) - partial);
diff --combined fs/ext3/super.c
index 37776800910670e2a675e4fd11378f3d8eb35446,1c6875118b1e3e0557aa6cdf818d0a71dd3a2bb6..db87413d3479c15ecc36223ad4b02c8c6c06f07e
@@@ -411,6 -411,9 +411,6 @@@ static void ext3_put_super (struct supe
        int i, err;
  
        dquot_disable(sb, -1, DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED);
 -
 -      lock_kernel();
 -
        ext3_xattr_put_super(sb);
        err = journal_destroy(sbi->s_journal);
        sbi->s_journal = NULL;
        sb->s_fs_info = NULL;
        kfree(sbi->s_blockgroup_lock);
        kfree(sbi);
 -
 -      unlock_kernel();
  }
  
  static struct kmem_cache *ext3_inode_cachep;
@@@ -1301,9 -1306,9 +1301,9 @@@ static int ext3_setup_super(struct supe
                ext3_msg(sb, KERN_WARNING,
                        "warning: mounting fs with errors, "
                        "running e2fsck is recommended");
-       else if ((__s16) le16_to_cpu(es->s_max_mnt_count) >= 0 &&
+       else if ((__s16) le16_to_cpu(es->s_max_mnt_count) > 0 &&
                 le16_to_cpu(es->s_mnt_count) >=
-                (unsigned short) (__s16) le16_to_cpu(es->s_max_mnt_count))
+                       le16_to_cpu(es->s_max_mnt_count))
                ext3_msg(sb, KERN_WARNING,
                        "warning: maximal mount count reached, "
                        "running e2fsck is recommended");
                     valid forever! :) */
        es->s_state &= cpu_to_le16(~EXT3_VALID_FS);
  #endif
-       if (!(__s16) le16_to_cpu(es->s_max_mnt_count))
+       if (!le16_to_cpu(es->s_max_mnt_count))
                es->s_max_mnt_count = cpu_to_le16(EXT3_DFL_MAX_MNT_COUNT);
        le16_add_cpu(&es->s_mnt_count, 1);
        es->s_mtime = cpu_to_le32(get_seconds());
@@@ -1622,6 -1627,8 +1622,6 @@@ static int ext3_fill_super (struct supe
        sbi->s_resgid = EXT3_DEF_RESGID;
        sbi->s_sb_block = sb_block;
  
 -      unlock_kernel();
 -
        blocksize = sb_min_blocksize(sb, EXT3_MIN_BLOCK_SIZE);
        if (!blocksize) {
                ext3_msg(sb, KERN_ERR, "error: unable to set blocksize");
         * Note: s_es must be initialized as soon as possible because
         *       some ext3 macro-instructions depend on its value
         */
-       es = (struct ext3_super_block *) (((char *)bh->b_data) + offset);
+       es = (struct ext3_super_block *) (bh->b_data + offset);
        sbi->s_es = es;
        sb->s_magic = le16_to_cpu(es->s_magic);
        if (sb->s_magic != EXT3_SUPER_MAGIC)
                               "error: can't read superblock on 2nd try");
                        goto failed_mount;
                }
-               es = (struct ext3_super_block *)(((char *)bh->b_data) + offset);
+               es = (struct ext3_super_block *)(bh->b_data + offset);
                sbi->s_es = es;
                if (es->s_magic != cpu_to_le16(EXT3_SUPER_MAGIC)) {
                        ext3_msg(sb, KERN_ERR,
                goto failed_mount;
        }
  
 -      if (le32_to_cpu(es->s_blocks_count) >
 -                  (sector_t)(~0ULL) >> (sb->s_blocksize_bits - 9)) {
 +      if (generic_check_addressable(sb->s_blocksize_bits,
 +                                    le32_to_cpu(es->s_blocks_count))) {
                ext3_msg(sb, KERN_ERR,
                        "error: filesystem is too large to mount safely");
                if (sizeof(sector_t) < 8)
        sbi->s_groups_count = ((le32_to_cpu(es->s_blocks_count) -
                               le32_to_cpu(es->s_first_data_block) - 1)
                                       / EXT3_BLOCKS_PER_GROUP(sb)) + 1;
-       db_count = (sbi->s_groups_count + EXT3_DESC_PER_BLOCK(sb) - 1) /
-                  EXT3_DESC_PER_BLOCK(sb);
+       db_count = DIV_ROUND_UP(sbi->s_groups_count, EXT3_DESC_PER_BLOCK(sb));
        sbi->s_group_desc = kmalloc(db_count * sizeof (struct buffer_head *),
                                    GFP_KERNEL);
        if (sbi->s_group_desc == NULL) {
                ext3_msg(sb, KERN_ERR,
                        "error: not enough memory");
+               ret = -ENOMEM;
                goto failed_mount;
        }
  
        }
        if (err) {
                ext3_msg(sb, KERN_ERR, "error: insufficient memory");
+               ret = err;
                goto failed_mount3;
        }
  
                test_opt(sb,DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA ? "ordered":
                "writeback");
  
 -      lock_kernel();
        return 0;
  
  cantfind_ext3:
@@@ -2047,6 -2056,7 +2048,6 @@@ out_fail
        sb->s_fs_info = NULL;
        kfree(sbi->s_blockgroup_lock);
        kfree(sbi);
 -      lock_kernel();
        return ret;
  }
  
@@@ -2159,7 -2169,7 +2160,7 @@@ static journal_t *ext3_get_dev_journal(
                goto out_bdev;
        }
  
-       es = (struct ext3_super_block *) (((char *)bh->b_data) + offset);
+       es = (struct ext3_super_block *) (bh->b_data + offset);
        if ((le16_to_cpu(es->s_magic) != EXT3_SUPER_MAGIC) ||
            !(le32_to_cpu(es->s_feature_incompat) &
              EXT3_FEATURE_INCOMPAT_JOURNAL_DEV)) {
@@@ -2352,6 -2362,21 +2353,21 @@@ static int ext3_commit_super(struct sup
  
        if (!sbh)
                return error;
+       if (buffer_write_io_error(sbh)) {
+               /*
+                * Oh, dear.  A previous attempt to write the
+                * superblock failed.  This could happen because the
+                * USB device was yanked out.  Or it could happen to
+                * be a transient write error and maybe the block will
+                * be remapped.  Nothing we can do but to retry the
+                * write and hope for the best.
+                */
+               ext3_msg(sb, KERN_ERR, "previous I/O error to "
+                      "superblock detected");
+               clear_buffer_write_io_error(sbh);
+               set_buffer_uptodate(sbh);
+       }
        /*
         * If the file system is mounted read-only, don't update the
         * superblock write time.  This avoids updating the superblock
        es->s_free_inodes_count = cpu_to_le32(ext3_count_free_inodes(sb));
        BUFFER_TRACE(sbh, "marking dirty");
        mark_buffer_dirty(sbh);
-       if (sync)
+       if (sync) {
                error = sync_dirty_buffer(sbh);
+               if (buffer_write_io_error(sbh)) {
+                       ext3_msg(sb, KERN_ERR, "I/O error while writing "
+                              "superblock");
+                       clear_buffer_write_io_error(sbh);
+                       set_buffer_uptodate(sbh);
+               }
+       }
        return error;
  }
  
@@@ -2529,6 -2561,8 +2552,6 @@@ static int ext3_remount (struct super_b
        int i;
  #endif
  
 -      lock_kernel();
 -
        /* Store the original options */
        lock_super(sb);
        old_sb_flags = sb->s_flags;
                        kfree(old_opts.s_qf_names[i]);
  #endif
        unlock_super(sb);
 -      unlock_kernel();
  
        if (enable_quota)
                dquot_resume(sb, -1);
@@@ -2657,6 -2692,7 +2680,6 @@@ restore_opts
        }
  #endif
        unlock_super(sb);
 -      unlock_kernel();
        return err;
  }
  
diff --combined fs/jbd/commit.c
index 85a6883c0aca265b898431eb2a2254632a8a8ef7,a89c4630b1ed8a0048a36cfb9718d9aaba3a08ec..34a4861c14b85d493a8b653c4ce700a4c580842e
@@@ -137,10 -137,34 +137,10 @@@ static int journal_write_commit_record(
        JBUFFER_TRACE(descriptor, "write commit block");
        set_buffer_dirty(bh);
  
 -      if (journal->j_flags & JFS_BARRIER) {
 -              ret = __sync_dirty_buffer(bh, WRITE_SYNC | WRITE_BARRIER);
 -
 -              /*
 -               * Is it possible for another commit to fail at roughly
 -               * the same time as this one?  If so, we don't want to
 -               * trust the barrier flag in the super, but instead want
 -               * to remember if we sent a barrier request
 -               */
 -              if (ret == -EOPNOTSUPP) {
 -                      char b[BDEVNAME_SIZE];
 -
 -                      printk(KERN_WARNING
 -                              "JBD: barrier-based sync failed on %s - "
 -                              "disabling barriers\n",
 -                              bdevname(journal->j_dev, b));
 -                      spin_lock(&journal->j_state_lock);
 -                      journal->j_flags &= ~JFS_BARRIER;
 -                      spin_unlock(&journal->j_state_lock);
 -
 -                      /* And try again, without the barrier */
 -                      set_buffer_uptodate(bh);
 -                      set_buffer_dirty(bh);
 -                      ret = sync_dirty_buffer(bh);
 -              }
 -      } else {
 +      if (journal->j_flags & JFS_BARRIER)
 +              ret = __sync_dirty_buffer(bh, WRITE_SYNC | WRITE_FLUSH_FUA);
 +      else
                ret = sync_dirty_buffer(bh);
 -      }
  
        put_bh(bh);             /* One for getblk() */
        journal_put_journal_head(descriptor);
@@@ -294,7 -318,7 +294,7 @@@ void journal_commit_transaction(journal
        int first_tag = 0;
        int tag_flag;
        int i;
 -      int write_op = WRITE;
 +      int write_op = WRITE_SYNC;
  
        /*
         * First job: lock down the current transaction and wait for
                /* Bump b_count to prevent truncate from stumbling over
                     the shadowed buffer!  @@@ This can go if we ever get
                     rid of the BJ_IO/BJ_Shadow pairing of buffers. */
-               atomic_inc(&jh2bh(jh)->b_count);
+               get_bh(jh2bh(jh));
  
                /* Make a temporary IO buffer with which to write it out
                     (this will requeue both the metadata buffer and the
                     temporary IO buffer). new_bh goes on BJ_IO*/
  
-               set_bit(BH_JWrite, &jh2bh(jh)->b_state);
+               set_buffer_jwrite(jh2bh(jh));
                /*
                 * akpm: journal_write_metadata_buffer() sets
                 * new_bh->b_transaction to commit_transaction.
                JBUFFER_TRACE(jh, "ph3: write metadata");
                flags = journal_write_metadata_buffer(commit_transaction,
                                                      jh, &new_jh, blocknr);
-               set_bit(BH_JWrite, &jh2bh(new_jh)->b_state);
+               set_buffer_jwrite(jh2bh(new_jh));
                wbuf[bufs++] = jh2bh(new_jh);
  
                /* Record the new block's tag in the current descriptor
@@@ -713,7 -737,7 +713,7 @@@ wait_for_iobuf
                     shadowed buffer */
                jh = commit_transaction->t_shadow_list->b_tprev;
                bh = jh2bh(jh);
-               clear_bit(BH_JWrite, &bh->b_state);
+               clear_buffer_jwrite(bh);
                J_ASSERT_BH(bh, buffer_jbddirty(bh));
  
                /* The metadata is now released for reuse, but we need
diff --combined fs/jbd2/journal.c
index 262419f83d800bfb6e4bbfb0ca93e3af2c3f64be,2b9a342551b9895fcfacdbd035ac07090fd42113..168d1894317a184dc32aeeaab4cbf43c81fc84b4
@@@ -478,7 -478,7 +478,7 @@@ int __jbd2_log_start_commit(journal_t *
         */
        if (!tid_geq(journal->j_commit_request, target)) {
                /*
-                * We want a new commit: OK, mark the request and wakup the
+                * We want a new commit: OK, mark the request and wakeup the
                 * commit thread.  We do _not_ do the commit ourselves.
                 */
  
@@@ -1371,10 -1371,6 +1371,10 @@@ int jbd2_journal_check_used_features (j
  
        if (!compat && !ro && !incompat)
                return 1;
 +      /* Load journal superblock if it is not loaded yet. */
 +      if (journal->j_format_version == 0 &&
 +          journal_get_superblock(journal) != 0)
 +              return 0;
        if (journal->j_format_version == 1)
                return 0;