]> Pileus Git - ~andy/linux/commitdiff
Merge git://git.kernel.org/pub/scm/linux/kernel/git/steve/gfs2-3.0-nmw
authorLinus Torvalds <torvalds@linux-foundation.org>
Sun, 8 Jan 2012 21:07:54 +0000 (13:07 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sun, 8 Jan 2012 21:07:54 +0000 (13:07 -0800)
* git://git.kernel.org/pub/scm/linux/kernel/git/steve/gfs2-3.0-nmw:
  GFS2: local functions should be static
  GFS2: We only need one ACL getting function
  GFS2: Fix multi-block allocation
  GFS2: decouple quota allocations from block allocations
  GFS2: split function rgblk_search
  GFS2: Fix up "off by one" in the previous patch
  GFS2: move toward a generic multi-block allocator
  GFS2: O_(D)SYNC support for fallocate
  GFS2: remove vestigial al_alloced
  GFS2: combine gfs2_alloc_block and gfs2_alloc_di
  GFS2: Add non-try locks back to get_local_rgrp
  GFS2: f_ra is always valid in dir readahead function
  GFS2: Fix very unlikley memory leak in ACL xattr code
  GFS2: More automated code analysis fixes
  GFS2: Add readahead to sequential directory traversal
  GFS2: Fix up REQ flags

1  2 
fs/gfs2/file.c
fs/gfs2/inode.c
fs/gfs2/super.c

diff --combined fs/gfs2/file.c
index b8927d4f3bf20a662b14a766ae6a84a1a70e32cd,42ceb23651e55cc9a564dd9f34a789ed5b8821a8..c5fb3597f696c819453ae86b5561ca46d9bbfba3
@@@ -105,7 -105,7 +105,7 @@@ static int gfs2_readdir(struct file *fi
                return error;
        }
  
-       error = gfs2_dir_read(dir, &offset, dirent, filldir);
+       error = gfs2_dir_read(dir, &offset, dirent, filldir, &file->f_ra);
  
        gfs2_glock_dq_uninit(&d_gh);
  
@@@ -223,7 -223,7 +223,7 @@@ static int do_gfs2_set_flags(struct fil
        int error;
        u32 new_flags, flags;
  
 -      error = mnt_want_write(filp->f_path.mnt);
 +      error = mnt_want_write_file(filp);
        if (error)
                return error;
  
@@@ -285,7 -285,7 +285,7 @@@ out_trans_end
  out:
        gfs2_glock_dq_uninit(&gh);
  out_drop_write:
 -      mnt_drop_write(filp->f_path.mnt);
 +      mnt_drop_write_file(filp);
        return error;
  }
  
@@@ -365,7 -365,7 +365,7 @@@ static int gfs2_page_mkwrite(struct vm_
        u64 pos = page->index << PAGE_CACHE_SHIFT;
        unsigned int data_blocks, ind_blocks, rblocks;
        struct gfs2_holder gh;
-       struct gfs2_alloc *al;
+       struct gfs2_qadata *qa;
        loff_t size;
        int ret;
  
        }
  
        ret = -ENOMEM;
-       al = gfs2_alloc_get(ip);
-       if (al == NULL)
+       qa = gfs2_qadata_get(ip);
+       if (qa == NULL)
                goto out_unlock;
  
        ret = gfs2_quota_lock_check(ip);
        if (ret)
                goto out_alloc_put;
        gfs2_write_calc_reserv(ip, PAGE_CACHE_SIZE, &data_blocks, &ind_blocks);
-       al->al_requested = data_blocks + ind_blocks;
-       ret = gfs2_inplace_reserve(ip);
+       ret = gfs2_inplace_reserve(ip, data_blocks + ind_blocks);
        if (ret)
                goto out_quota_unlock;
  
@@@ -448,7 -447,7 +447,7 @@@ out_trans_fail
  out_quota_unlock:
        gfs2_quota_unlock(ip);
  out_alloc_put:
-       gfs2_alloc_put(ip);
+       gfs2_qadata_put(ip);
  out_unlock:
        gfs2_glock_dq(&gh);
  out:
@@@ -609,7 -608,7 +608,7 @@@ static int gfs2_fsync(struct file *file
        struct inode *inode = mapping->host;
        int sync_state = inode->i_state & (I_DIRTY_SYNC|I_DIRTY_DATASYNC);
        struct gfs2_inode *ip = GFS2_I(inode);
-       int ret, ret1 = 0;
+       int ret = 0, ret1 = 0;
  
        if (mapping->nrpages) {
                ret1 = filemap_fdatawrite_range(mapping, start, end);
@@@ -750,8 -749,10 +749,10 @@@ static long gfs2_fallocate(struct file 
        struct gfs2_inode *ip = GFS2_I(inode);
        unsigned int data_blocks = 0, ind_blocks = 0, rblocks;
        loff_t bytes, max_bytes;
-       struct gfs2_alloc *al;
+       struct gfs2_qadata *qa;
        int error;
+       const loff_t pos = offset;
+       const loff_t count = len;
        loff_t bsize_mask = ~((loff_t)sdp->sd_sb.sb_bsize - 1);
        loff_t next = (offset + len - 1) >> sdp->sd_sb.sb_bsize_shift;
        loff_t max_chunk_size = UINT_MAX & bsize_mask;
        while (len > 0) {
                if (len < bytes)
                        bytes = len;
-               al = gfs2_alloc_get(ip);
-               if (!al) {
+               qa = gfs2_qadata_get(ip);
+               if (!qa) {
                        error = -ENOMEM;
                        goto out_unlock;
                }
  retry:
                gfs2_write_calc_reserv(ip, bytes, &data_blocks, &ind_blocks);
  
-               al->al_requested = data_blocks + ind_blocks;
-               error = gfs2_inplace_reserve(ip);
+               error = gfs2_inplace_reserve(ip, data_blocks + ind_blocks);
                if (error) {
                        if (error == -ENOSPC && bytes > sdp->sd_sb.sb_bsize) {
                                bytes >>= 1;
                max_bytes = bytes;
                calc_max_reserv(ip, (len > max_chunk_size)? max_chunk_size: len,
                                &max_bytes, &data_blocks, &ind_blocks);
-               al->al_requested = data_blocks + ind_blocks;
  
                rblocks = RES_DINODE + ind_blocks + RES_STATFS + RES_QUOTA +
                          RES_RG_HDR + gfs2_rg_blocks(ip);
                offset += max_bytes;
                gfs2_inplace_release(ip);
                gfs2_quota_unlock(ip);
-               gfs2_alloc_put(ip);
+               gfs2_qadata_put(ip);
        }
+       if (error == 0)
+               error = generic_write_sync(file, pos, count);
        goto out_unlock;
  
  out_trans_fail:
  out_qunlock:
        gfs2_quota_unlock(ip);
  out_alloc_put:
-       gfs2_alloc_put(ip);
+       gfs2_qadata_put(ip);
  out_unlock:
        gfs2_glock_dq(&ip->i_gh);
  out_uninit:
diff --combined fs/gfs2/inode.c
index 4b0e59e0a249b55111e595bcddf0ec40ca406386,cb818985e28cce7504030cccc207ebca07663c80..017960cf1d7aaa198bef71664bdfed82a6fa7f9b
@@@ -333,7 -333,7 +333,7 @@@ out
   */
  
  static int create_ok(struct gfs2_inode *dip, const struct qstr *name,
 -                   unsigned int mode)
 +                   umode_t mode)
  {
        int error;
  
        return 0;
  }
  
 -static void munge_mode_uid_gid(struct gfs2_inode *dip, unsigned int *mode,
 +static void munge_mode_uid_gid(struct gfs2_inode *dip, umode_t *mode,
                               unsigned int *uid, unsigned int *gid)
  {
        if (GFS2_SB(&dip->i_inode)->sd_args.ar_suiddir &&
@@@ -389,12 -389,13 +389,13 @@@ static int alloc_dinode(struct gfs2_ino
  {
        struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
        int error;
+       int dblocks = 1;
  
-       if (gfs2_alloc_get(dip) == NULL)
-               return -ENOMEM;
+       error = gfs2_rindex_update(sdp);
+       if (error)
+               fs_warn(sdp, "rindex update returns %d\n", error);
  
-       dip->i_alloc->al_requested = RES_DINODE;
-       error = gfs2_inplace_reserve(dip);
+       error = gfs2_inplace_reserve(dip, RES_DINODE);
        if (error)
                goto out;
  
        if (error)
                goto out_ipreserv;
  
-       error = gfs2_alloc_di(dip, no_addr, generation);
+       error = gfs2_alloc_blocks(dip, no_addr, &dblocks, 1, generation);
  
        gfs2_trans_end(sdp);
  
  out_ipreserv:
        gfs2_inplace_release(dip);
  out:
-       gfs2_alloc_put(dip);
        return error;
  }
  
@@@ -447,7 -447,7 +447,7 @@@ static void gfs2_init_dir(struct buffer
   */
  
  static void init_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl,
 -                      const struct gfs2_inum_host *inum, unsigned int mode,
 +                      const struct gfs2_inum_host *inum, umode_t mode,
                        unsigned int uid, unsigned int gid,
                        const u64 *generation, dev_t dev, const char *symname,
                        unsigned size, struct buffer_head **bhp)
  }
  
  static int make_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl,
 -                     unsigned int mode, const struct gfs2_inum_host *inum,
 +                     umode_t mode, const struct gfs2_inum_host *inum,
                       const u64 *generation, dev_t dev, const char *symname,
                       unsigned int size, struct buffer_head **bhp)
  {
        int error;
  
        munge_mode_uid_gid(dip, &mode, &uid, &gid);
-       if (!gfs2_alloc_get(dip))
+       if (!gfs2_qadata_get(dip))
                return -ENOMEM;
  
        error = gfs2_quota_lock(dip, uid, gid);
  out_quota:
        gfs2_quota_unlock(dip);
  out:
-       gfs2_alloc_put(dip);
+       gfs2_qadata_put(dip);
        return error;
  }
  
@@@ -555,13 -555,13 +555,13 @@@ static int link_dinode(struct gfs2_inod
                       struct gfs2_inode *ip)
  {
        struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
-       struct gfs2_alloc *al;
+       struct gfs2_qadata *qa;
        int alloc_required;
        struct buffer_head *dibh;
        int error;
  
-       al = gfs2_alloc_get(dip);
-       if (!al)
+       qa = gfs2_qadata_get(dip);
+       if (!qa)
                return -ENOMEM;
  
        error = gfs2_quota_lock(dip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
                if (error)
                        goto fail_quota_locks;
  
-               al->al_requested = sdp->sd_max_dirres;
-               error = gfs2_inplace_reserve(dip);
+               error = gfs2_inplace_reserve(dip, sdp->sd_max_dirres);
                if (error)
                        goto fail_quota_locks;
  
@@@ -619,11 -617,11 +617,11 @@@ fail_quota_locks
        gfs2_quota_unlock(dip);
  
  fail:
-       gfs2_alloc_put(dip);
+       gfs2_qadata_put(dip);
        return error;
  }
  
- int gfs2_initxattrs(struct inode *inode, const struct xattr *xattr_array,
static int gfs2_initxattrs(struct inode *inode, const struct xattr *xattr_array,
                    void *fs_info)
  {
        const struct xattr *xattr;
@@@ -659,7 -657,7 +657,7 @@@ static int gfs2_security_init(struct gf
   */
  
  static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
 -                           unsigned int mode, dev_t dev, const char *symname,
 +                           umode_t mode, dev_t dev, const char *symname,
                             unsigned int size, int excl)
  {
        const struct qstr *name = &dentry->d_name;
                brelse(bh);
  
        gfs2_trans_end(sdp);
-       gfs2_inplace_release(dip);
+       /* Check if we reserved space in the rgrp. Function link_dinode may
+          not, depending on whether alloc is required. */
+       if (dip->i_res)
+               gfs2_inplace_release(dip);
        gfs2_quota_unlock(dip);
-       gfs2_alloc_put(dip);
+       gfs2_qadata_put(dip);
        mark_inode_dirty(inode);
        gfs2_glock_dq_uninit_m(2, ghs);
        d_instantiate(dentry, inode);
@@@ -760,7 -761,7 +761,7 @@@ fail
   */
  
  static int gfs2_create(struct inode *dir, struct dentry *dentry,
 -                     int mode, struct nameidata *nd)
 +                     umode_t mode, struct nameidata *nd)
  {
        int excl = 0;
        if (nd && (nd->flags & LOOKUP_EXCL))
@@@ -875,8 -876,9 +876,9 @@@ static int gfs2_link(struct dentry *old
        error = 0;
  
        if (alloc_required) {
-               struct gfs2_alloc *al = gfs2_alloc_get(dip);
-               if (!al) {
+               struct gfs2_qadata *qa = gfs2_qadata_get(dip);
+               if (!qa) {
                        error = -ENOMEM;
                        goto out_gunlock;
                }
                if (error)
                        goto out_alloc;
  
-               al->al_requested = sdp->sd_max_dirres;
-               error = gfs2_inplace_reserve(dip);
+               error = gfs2_inplace_reserve(dip, sdp->sd_max_dirres);
                if (error)
                        goto out_gunlock_q;
  
@@@ -930,7 -930,7 +930,7 @@@ out_gunlock_q
                gfs2_quota_unlock(dip);
  out_alloc:
        if (alloc_required)
-               gfs2_alloc_put(dip);
+               gfs2_qadata_put(dip);
  out_gunlock:
        gfs2_glock_dq(ghs + 1);
  out_child:
@@@ -1037,12 -1037,14 +1037,14 @@@ static int gfs2_unlink(struct inode *di
        struct buffer_head *bh;
        struct gfs2_holder ghs[3];
        struct gfs2_rgrpd *rgd;
-       int error;
+       int error = -EROFS;
  
        gfs2_holder_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, ghs);
        gfs2_holder_init(ip->i_gl,  LM_ST_EXCLUSIVE, 0, ghs + 1);
  
        rgd = gfs2_blk2rgrpd(sdp, ip->i_no_addr);
+       if (!rgd)
+               goto out_inodes;
        gfs2_holder_init(rgd->rd_gl, LM_ST_EXCLUSIVE, 0, ghs + 2);
  
  
@@@ -1088,12 -1090,13 +1090,13 @@@ out_end_trans
  out_gunlock:
        gfs2_glock_dq(ghs + 2);
  out_rgrp:
-       gfs2_holder_uninit(ghs + 2);
        gfs2_glock_dq(ghs + 1);
  out_child:
-       gfs2_holder_uninit(ghs + 1);
        gfs2_glock_dq(ghs);
  out_parent:
+       gfs2_holder_uninit(ghs + 2);
+ out_inodes:
+       gfs2_holder_uninit(ghs + 1);
        gfs2_holder_uninit(ghs);
        return error;
  }
@@@ -1129,7 -1132,7 +1132,7 @@@ static int gfs2_symlink(struct inode *d
   * Returns: errno
   */
  
 -static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, int mode)
 +static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
  {
        return gfs2_create_inode(dir, dentry, S_IFDIR | mode, 0, NULL, 0, 0);
  }
   *
   */
  
 -static int gfs2_mknod(struct inode *dir, struct dentry *dentry, int mode,
 +static int gfs2_mknod(struct inode *dir, struct dentry *dentry, umode_t mode,
                      dev_t dev)
  {
        return gfs2_create_inode(dir, dentry, mode, dev, NULL, 0, 0);
@@@ -1350,8 -1353,9 +1353,9 @@@ static int gfs2_rename(struct inode *od
        error = 0;
  
        if (alloc_required) {
-               struct gfs2_alloc *al = gfs2_alloc_get(ndip);
-               if (!al) {
+               struct gfs2_qadata *qa = gfs2_qadata_get(ndip);
+               if (!qa) {
                        error = -ENOMEM;
                        goto out_gunlock;
                }
                if (error)
                        goto out_alloc;
  
-               al->al_requested = sdp->sd_max_dirres;
-               error = gfs2_inplace_reserve(ndip);
+               error = gfs2_inplace_reserve(ndip, sdp->sd_max_dirres);
                if (error)
                        goto out_gunlock_q;
  
@@@ -1423,7 -1425,7 +1425,7 @@@ out_gunlock_q
                gfs2_quota_unlock(ndip);
  out_alloc:
        if (alloc_required)
-               gfs2_alloc_put(ndip);
+               gfs2_qadata_put(ndip);
  out_gunlock:
        while (x--) {
                gfs2_glock_dq(ghs + x);
@@@ -1584,7 -1586,7 +1586,7 @@@ static int setattr_chown(struct inode *
        if (!(attr->ia_valid & ATTR_GID) || ogid == ngid)
                ogid = ngid = NO_QUOTA_CHANGE;
  
-       if (!gfs2_alloc_get(ip))
+       if (!gfs2_qadata_get(ip))
                return -ENOMEM;
  
        error = gfs2_quota_lock(ip, nuid, ngid);
@@@ -1616,7 -1618,7 +1618,7 @@@ out_end_trans
  out_gunlock_q:
        gfs2_quota_unlock(ip);
  out_alloc:
-       gfs2_alloc_put(ip);
+       gfs2_qadata_put(ip);
        return error;
  }
  
diff --combined fs/gfs2/super.c
index 10c7733a899b3f3b81344db37813b942bdc9e676,69eb56876db4b9708d72a5a97f72c156f224e5b5..4553ce515f62f3a8c3f59b2c65a0921f10806e08
@@@ -1284,18 -1284,18 +1284,18 @@@ static int is_ancestor(const struct den
  /**
   * gfs2_show_options - Show mount options for /proc/mounts
   * @s: seq_file structure
 - * @mnt: vfsmount
 + * @root: root of this (sub)tree
   *
   * Returns: 0 on success or error code
   */
  
 -static int gfs2_show_options(struct seq_file *s, struct vfsmount *mnt)
 +static int gfs2_show_options(struct seq_file *s, struct dentry *root)
  {
 -      struct gfs2_sbd *sdp = mnt->mnt_sb->s_fs_info;
 +      struct gfs2_sbd *sdp = root->d_sb->s_fs_info;
        struct gfs2_args *args = &sdp->sd_args;
        int val;
  
 -      if (is_ancestor(mnt->mnt_root, sdp->sd_master_dir))
 +      if (is_ancestor(root, sdp->sd_master_dir))
                seq_printf(s, ",meta");
        if (args->ar_lockproto[0])
                seq_printf(s, ",lockproto=%s", args->ar_lockproto);
@@@ -1399,8 -1399,9 +1399,9 @@@ static void gfs2_final_release_pages(st
  static int gfs2_dinode_dealloc(struct gfs2_inode *ip)
  {
        struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
-       struct gfs2_alloc *al;
+       struct gfs2_qadata *qa;
        struct gfs2_rgrpd *rgd;
+       struct gfs2_holder gh;
        int error;
  
        if (gfs2_get_inode_blocks(&ip->i_inode) != 1) {
                return -EIO;
        }
  
-       al = gfs2_alloc_get(ip);
-       if (!al)
+       qa = gfs2_qadata_get(ip);
+       if (!qa)
                return -ENOMEM;
  
        error = gfs2_quota_hold(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
                goto out_qs;
        }
  
-       error = gfs2_glock_nq_init(rgd->rd_gl, LM_ST_EXCLUSIVE, 0,
-                                  &al->al_rgd_gh);
+       error = gfs2_glock_nq_init(rgd->rd_gl, LM_ST_EXCLUSIVE, 0, &gh);
        if (error)
                goto out_qs;
  
        gfs2_trans_end(sdp);
  
  out_rg_gunlock:
-       gfs2_glock_dq_uninit(&al->al_rgd_gh);
+       gfs2_glock_dq_uninit(&gh);
  out_qs:
        gfs2_quota_unhold(ip);
  out:
-       gfs2_alloc_put(ip);
+       gfs2_qadata_put(ip);
        return error;
  }
  
@@@ -1582,6 -1582,7 +1582,6 @@@ static struct inode *gfs2_alloc_inode(s
  static void gfs2_i_callback(struct rcu_head *head)
  {
        struct inode *inode = container_of(head, struct inode, i_rcu);
 -      INIT_LIST_HEAD(&inode->i_dentry);
        kmem_cache_free(gfs2_inode_cachep, inode);
  }