]> Pileus Git - ~andy/linux/blobdiff - fs/gfs2/dir.c
Merge branch 'pci-for-jesse' of git://git.kernel.org/pub/scm/linux/kernel/git/tip...
[~andy/linux] / fs / gfs2 / dir.c
index 862aa3228f7a76ddf4dc5891d19fb053f11299cd..eed040d8ba3abc407496689af3a909030ae647fe 100644 (file)
@@ -159,6 +159,7 @@ static int gfs2_dir_write_data(struct gfs2_inode *ip, const char *buf,
        unsigned int o;
        int copied = 0;
        int error = 0;
+       int new = 0;
 
        if (!size)
                return 0;
@@ -183,7 +184,6 @@ static int gfs2_dir_write_data(struct gfs2_inode *ip, const char *buf,
        while (copied < size) {
                unsigned int amount;
                struct buffer_head *bh;
-               int new = 0;
 
                amount = size - copied;
                if (amount > sdp->sd_sb.sb_bsize - o)
@@ -1021,13 +1021,13 @@ static int dir_split_leaf(struct inode *inode, const struct qstr *name)
 
                        new->de_inum = dent->de_inum; /* No endian worries */
                        new->de_type = dent->de_type; /* No endian worries */
-                       nleaf->lf_entries = cpu_to_be16(be16_to_cpu(nleaf->lf_entries)+1);
+                       be16_add_cpu(&nleaf->lf_entries, 1);
 
                        dirent_del(dip, obh, prev, dent);
 
                        if (!oleaf->lf_entries)
                                gfs2_consist_inode(dip);
-                       oleaf->lf_entries = cpu_to_be16(be16_to_cpu(oleaf->lf_entries)-1);
+                       be16_add_cpu(&oleaf->lf_entries, -1);
 
                        if (!prev)
                                prev = dent;
@@ -1089,7 +1089,7 @@ static int dir_double_exhash(struct gfs2_inode *dip)
 
        /*  Allocate both the "from" and "to" buffers in one big chunk  */
 
-       buf = kcalloc(3, sdp->sd_hash_bsize, GFP_KERNEL | __GFP_NOFAIL);
+       buf = kcalloc(3, sdp->sd_hash_bsize, GFP_NOFS | __GFP_NOFAIL);
 
        for (block = dip->i_di.di_size >> sdp->sd_hash_bsize_shift; block--;) {
                error = gfs2_dir_read_data(dip, (char *)buf,
@@ -1378,7 +1378,7 @@ static int dir_e_read(struct inode *inode, u64 *offset, void *opaque,
        hash = gfs2_dir_offset2hash(*offset);
        index = hash >> (32 - dip->i_depth);
 
-       lp = kmalloc(sdp->sd_hash_bsize, GFP_KERNEL);
+       lp = kmalloc(sdp->sd_hash_bsize, GFP_NOFS);
        if (!lp)
                return -ENOMEM;
 
@@ -1443,7 +1443,7 @@ int gfs2_dir_read(struct inode *inode, u64 *offset, void *opaque,
 
        error = -ENOMEM;
        /* 96 is max number of dirents which can be stuffed into an inode */
-       darr = kmalloc(96 * sizeof(struct gfs2_dirent *), GFP_KERNEL);
+       darr = kmalloc(96 * sizeof(struct gfs2_dirent *), GFP_NOFS);
        if (darr) {
                g.pdent = darr;
                g.offset = 0;
@@ -1614,7 +1614,7 @@ int gfs2_dir_add(struct inode *inode, const struct qstr *name,
                        dent->de_type = cpu_to_be16(type);
                        if (ip->i_di.di_flags & GFS2_DIF_EXHASH) {
                                leaf = (struct gfs2_leaf *)bh->b_data;
-                               leaf->lf_entries = cpu_to_be16(be16_to_cpu(leaf->lf_entries) + 1);
+                               be16_add_cpu(&leaf->lf_entries, 1);
                        }
                        brelse(bh);
                        error = gfs2_meta_inode_buffer(ip, &bh);
@@ -1789,7 +1789,7 @@ static int foreach_leaf(struct gfs2_inode *dip, leaf_call_t lc, void *data)
                return -EIO;
        }
 
-       lp = kmalloc(sdp->sd_hash_bsize, GFP_KERNEL);
+       lp = kmalloc(sdp->sd_hash_bsize, GFP_NOFS);
        if (!lp)
                return -ENOMEM;
 
@@ -1864,15 +1864,18 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len,
 
        memset(&rlist, 0, sizeof(struct gfs2_rgrp_list));
 
-       ht = kzalloc(size, GFP_KERNEL);
+       ht = kzalloc(size, GFP_NOFS);
        if (!ht)
                return -ENOMEM;
 
-       gfs2_alloc_get(dip);
+       if (!gfs2_alloc_get(dip)) {
+               error = -ENOMEM;
+               goto out;
+       }
 
        error = gfs2_quota_hold(dip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
        if (error)
-               goto out;
+               goto out_put;
 
        error = gfs2_rindex_hold(sdp, &dip->i_alloc->al_ri_gh);
        if (error)
@@ -1946,8 +1949,9 @@ out_rlist:
        gfs2_glock_dq_uninit(&dip->i_alloc->al_ri_gh);
 out_qs:
        gfs2_quota_unhold(dip);
-out:
+out_put:
        gfs2_alloc_put(dip);
+out:
        kfree(ht);
        return error;
 }