mmc: msm: fix compile error on MSM7x30
[safe/jmp/linux-2.6] / fs / quota / quota_tree.c
index 3a5a90c..24f0340 100644 (file)
@@ -33,7 +33,7 @@ static int get_index(struct qtree_mem_dqinfo *info, qid_t id, int depth)
 }
 
 /* Number of entries in one blocks */
-static inline int qtree_dqstr_in_blk(struct qtree_mem_dqinfo *info)
+static int qtree_dqstr_in_blk(struct qtree_mem_dqinfo *info)
 {
        return (info->dqi_usable_bs - sizeof(struct qt_disk_dqdbheader))
               / info->dqi_entry_size;
@@ -43,11 +43,12 @@ static char *getdqbuf(size_t size)
 {
        char *buf = kmalloc(size, GFP_NOFS);
        if (!buf)
-               printk(KERN_WARNING "VFS: Not enough memory for quota buffers.\n");
+               printk(KERN_WARNING
+                      "VFS: Not enough memory for quota buffers.\n");
        return buf;
 }
 
-static inline ssize_t read_blk(struct qtree_mem_dqinfo *info, uint blk, char *buf)
+static ssize_t read_blk(struct qtree_mem_dqinfo *info, uint blk, char *buf)
 {
        struct super_block *sb = info->dqi_sb;
 
@@ -56,12 +57,20 @@ static inline ssize_t read_blk(struct qtree_mem_dqinfo *info, uint blk, char *bu
               info->dqi_usable_bs, blk << info->dqi_blocksize_bits);
 }
 
-static inline ssize_t write_blk(struct qtree_mem_dqinfo *info, uint blk, char *buf)
+static ssize_t write_blk(struct qtree_mem_dqinfo *info, uint blk, char *buf)
 {
        struct super_block *sb = info->dqi_sb;
+       ssize_t ret;
 
-       return sb->s_op->quota_write(sb, info->dqi_type, buf,
+       ret = sb->s_op->quota_write(sb, info->dqi_type, buf,
               info->dqi_usable_bs, blk << info->dqi_blocksize_bits);
+       if (ret != info->dqi_usable_bs) {
+               q_warn(KERN_WARNING "VFS: dquota write failed on "
+                       "dev %s\n", sb->s_id);
+               if (ret >= 0)
+                       ret = -EIO;
+       }
+       return ret;
 }
 
 /* Remove empty block from list and return it */
@@ -113,7 +122,8 @@ static int put_free_dqblk(struct qtree_mem_dqinfo *info, char *buf, uint blk)
 }
 
 /* Remove given block from the list of blocks with free entries */
-static int remove_free_dqentry(struct qtree_mem_dqinfo *info, char *buf, uint blk)
+static int remove_free_dqentry(struct qtree_mem_dqinfo *info, char *buf,
+                              uint blk)
 {
        char *tmpbuf = getdqbuf(info->dqi_usable_bs);
        struct qt_disk_dqdbheader *dh = (struct qt_disk_dqdbheader *)buf;
@@ -150,7 +160,9 @@ static int remove_free_dqentry(struct qtree_mem_dqinfo *info, char *buf, uint bl
        dh->dqdh_next_free = dh->dqdh_prev_free = cpu_to_le32(0);
        /* No matter whether write succeeds block is out of list */
        if (write_blk(info, blk, buf) < 0)
-               printk(KERN_ERR "VFS: Can't write block (%u) with free entries.\n", blk);
+               q_warn(KERN_ERR
+                      "VFS: Can't write block (%u) with free entries.\n",
+                      blk);
        return 0;
 out_buf:
        kfree(tmpbuf);
@@ -158,7 +170,8 @@ out_buf:
 }
 
 /* Insert given block to the beginning of list with free entries */
-static int insert_free_dqentry(struct qtree_mem_dqinfo *info, char *buf, uint blk)
+static int insert_free_dqentry(struct qtree_mem_dqinfo *info, char *buf,
+                              uint blk)
 {
        char *tmpbuf = getdqbuf(info->dqi_usable_bs);
        struct qt_disk_dqdbheader *dh = (struct qt_disk_dqdbheader *)buf;
@@ -230,7 +243,8 @@ static uint find_free_dqentry(struct qtree_mem_dqinfo *info,
                        return 0;
                }
                memset(buf, 0, info->dqi_usable_bs);
-               /* This is enough as block is already zeroed and entry list is empty... */
+               /* This is enough as the block is already zeroed and the entry
+                * list is empty... */
                info->dqi_free_entry = blk;
                mark_info_dirty(dquot->dq_sb, dquot->dq_type);
        }
@@ -238,7 +252,7 @@ static uint find_free_dqentry(struct qtree_mem_dqinfo *info,
        if (le16_to_cpu(dh->dqdh_entries) + 1 >= qtree_dqstr_in_blk(info)) {
                *err = remove_free_dqentry(info, buf, blk);
                if (*err < 0) {
-                       printk(KERN_ERR "VFS: find_free_dqentry(): Can't "
+                       q_warn(KERN_ERR "VFS: find_free_dqentry(): Can't "
                               "remove block (%u) from entry free list.\n",
                               blk);
                        goto out_buf;
@@ -246,10 +260,12 @@ static uint find_free_dqentry(struct qtree_mem_dqinfo *info,
        }
        le16_add_cpu(&dh->dqdh_entries, 1);
        /* Find free structure in block */
-       for (i = 0, ddquot = buf + sizeof(struct qt_disk_dqdbheader);
-            i < qtree_dqstr_in_blk(info) && !qtree_entry_unused(info, ddquot);
-            i++, ddquot += info->dqi_entry_size)
-               ;
+       ddquot = buf + sizeof(struct qt_disk_dqdbheader);
+       for (i = 0; i < qtree_dqstr_in_blk(info); i++) {
+               if (qtree_entry_unused(info, ddquot))
+                       break;
+               ddquot += info->dqi_entry_size;
+       }
 #ifdef __QUOTA_QT_PARANOIA
        if (i == qtree_dqstr_in_blk(info)) {
                printk(KERN_ERR "VFS: find_free_dqentry(): Data block full "
@@ -260,7 +276,7 @@ static uint find_free_dqentry(struct qtree_mem_dqinfo *info,
 #endif
        *err = write_blk(info, blk, buf);
        if (*err < 0) {
-               printk(KERN_ERR "VFS: find_free_dqentry(): Can't write quota "
+               q_warn(KERN_ERR "VFS: find_free_dqentry(): Can't write quota "
                                "data block %u.\n", blk);
                goto out_buf;
        }
@@ -295,7 +311,7 @@ static int do_insert_tree(struct qtree_mem_dqinfo *info, struct dquot *dquot,
        } else {
                ret = read_blk(info, *treeblk, buf);
                if (ret < 0) {
-                       printk(KERN_ERR "VFS: Can't read tree quota block "
+                       q_warn(KERN_ERR "VFS: Can't read tree quota block "
                                        "%u.\n", *treeblk);
                        goto out_buf;
                }
@@ -340,7 +356,8 @@ static inline int dq_insert_tree(struct qtree_mem_dqinfo *info,
 }
 
 /*
- *     We don't have to be afraid of deadlocks as we never have quotas on quota files...
+ * We don't have to be afraid of deadlocks as we never have quotas on quota
+ * files...
  */
 int qtree_write_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot)
 {
@@ -356,7 +373,7 @@ int qtree_write_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot)
        if (!dquot->dq_off) {
                ret = dq_insert_tree(info, dquot);
                if (ret < 0) {
-                       printk(KERN_ERR "VFS: Error %zd occurred while "
+                       q_warn(KERN_ERR "VFS: Error %zd occurred while "
                                        "creating quota.\n", ret);
                        kfree(ddquot);
                        return ret;
@@ -368,14 +385,14 @@ int qtree_write_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot)
        ret = sb->s_op->quota_write(sb, type, ddquot, info->dqi_entry_size,
                                    dquot->dq_off);
        if (ret != info->dqi_entry_size) {
-               printk(KERN_WARNING "VFS: dquota write failed on dev %s\n",
+               q_warn(KERN_WARNING "VFS: dquota write failed on dev %s\n",
                       sb->s_id);
                if (ret >= 0)
                        ret = -ENOSPC;
        } else {
                ret = 0;
        }
-       dqstats.writes++;
+       dqstats_inc(DQST_WRITES);
        kfree(ddquot);
 
        return ret;
@@ -393,14 +410,14 @@ static int free_dqentry(struct qtree_mem_dqinfo *info, struct dquot *dquot,
        if (!buf)
                return -ENOMEM;
        if (dquot->dq_off >> info->dqi_blocksize_bits != blk) {
-               printk(KERN_ERR "VFS: Quota structure has offset to other "
+               q_warn(KERN_ERR "VFS: Quota structure has offset to other "
                  "block (%u) than it should (%u).\n", blk,
                  (uint)(dquot->dq_off >> info->dqi_blocksize_bits));
                goto out_buf;
        }
        ret = read_blk(info, blk, buf);
        if (ret < 0) {
-               printk(KERN_ERR "VFS: Can't read quota data block %u\n", blk);
+               q_warn(KERN_ERR "VFS: Can't read quota data block %u\n", blk);
                goto out_buf;
        }
        dh = (struct qt_disk_dqdbheader *)buf;
@@ -410,7 +427,7 @@ static int free_dqentry(struct qtree_mem_dqinfo *info, struct dquot *dquot,
                if (ret >= 0)
                        ret = put_free_dqblk(info, buf, blk);
                if (ret < 0) {
-                       printk(KERN_ERR "VFS: Can't move quota data block (%u) "
+                       q_warn(KERN_ERR "VFS: Can't move quota data block (%u) "
                          "to free list.\n", blk);
                        goto out_buf;
                }
@@ -423,14 +440,14 @@ static int free_dqentry(struct qtree_mem_dqinfo *info, struct dquot *dquot,
                        /* Insert will write block itself */
                        ret = insert_free_dqentry(info, buf, blk);
                        if (ret < 0) {
-                               printk(KERN_ERR "VFS: Can't insert quota data "
+                               q_warn(KERN_ERR "VFS: Can't insert quota data "
                                       "block (%u) to free entry list.\n", blk);
                                goto out_buf;
                        }
                } else {
                        ret = write_blk(info, blk, buf);
                        if (ret < 0) {
-                               printk(KERN_ERR "VFS: Can't write quota data "
+                               q_warn(KERN_ERR "VFS: Can't write quota data "
                                  "block %u\n", blk);
                                goto out_buf;
                        }
@@ -455,7 +472,7 @@ static int remove_tree(struct qtree_mem_dqinfo *info, struct dquot *dquot,
                return -ENOMEM;
        ret = read_blk(info, *blk, buf);
        if (ret < 0) {
-               printk(KERN_ERR "VFS: Can't read quota data block %u\n", *blk);
+               q_warn(KERN_ERR "VFS: Can't read quota data block %u\n", *blk);
                goto out_buf;
        }
        newblk = le32_to_cpu(ref[get_index(info, dquot->dq_id, depth)]);
@@ -479,7 +496,7 @@ static int remove_tree(struct qtree_mem_dqinfo *info, struct dquot *dquot,
                } else {
                        ret = write_blk(info, *blk, buf);
                        if (ret < 0)
-                               printk(KERN_ERR "VFS: Can't write quota tree "
+                               q_warn(KERN_ERR "VFS: Can't write quota tree "
                                  "block %u.\n", *blk);
                }
        }
@@ -512,15 +529,17 @@ static loff_t find_block_dqentry(struct qtree_mem_dqinfo *info,
                return -ENOMEM;
        ret = read_blk(info, blk, buf);
        if (ret < 0) {
-               printk(KERN_ERR "VFS: Can't read quota tree block %u.\n", blk);
+               q_warn(KERN_ERR "VFS: Can't read quota tree block %u.\n", blk);
                goto out_buf;
        }
-       for (i = 0, ddquot = buf + sizeof(struct qt_disk_dqdbheader);
-            i < qtree_dqstr_in_blk(info) && !info->dqi_ops->is_id(ddquot, dquot);
-            i++, ddquot += info->dqi_entry_size)
-               ;
+       ddquot = buf + sizeof(struct qt_disk_dqdbheader);
+       for (i = 0; i < qtree_dqstr_in_blk(info); i++) {
+               if (info->dqi_ops->is_id(ddquot, dquot))
+                       break;
+               ddquot += info->dqi_entry_size;
+       }
        if (i == qtree_dqstr_in_blk(info)) {
-               printk(KERN_ERR "VFS: Quota for id %u referenced "
+               q_warn(KERN_ERR "VFS: Quota for id %u referenced "
                  "but not present.\n", dquot->dq_id);
                ret = -EIO;
                goto out_buf;
@@ -545,7 +564,7 @@ static loff_t find_tree_dqentry(struct qtree_mem_dqinfo *info,
                return -ENOMEM;
        ret = read_blk(info, blk, buf);
        if (ret < 0) {
-               printk(KERN_ERR "VFS: Can't read quota tree block %u.\n", blk);
+               q_warn(KERN_ERR "VFS: Can't read quota tree block %u.\n", blk);
                goto out_buf;
        }
        ret = 0;
@@ -588,7 +607,7 @@ int qtree_read_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot)
                offset = find_dqentry(info, dquot);
                if (offset <= 0) {      /* Entry not present? */
                        if (offset < 0)
-                               printk(KERN_ERR "VFS: Can't read quota "
+                               q_warn(KERN_ERR "VFS: Can't read quota "
                                  "structure for id %u.\n", dquot->dq_id);
                        dquot->dq_off = 0;
                        set_bit(DQ_FAKE_B, &dquot->dq_flags);
@@ -606,7 +625,7 @@ int qtree_read_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot)
        if (ret != info->dqi_entry_size) {
                if (ret >= 0)
                        ret = -EIO;
-               printk(KERN_ERR "VFS: Error while reading quota "
+               q_warn(KERN_ERR "VFS: Error while reading quota "
                                "structure for id %u.\n", dquot->dq_id);
                set_bit(DQ_FAKE_B, &dquot->dq_flags);
                memset(&dquot->dq_dqb, 0, sizeof(struct mem_dqblk));
@@ -623,7 +642,7 @@ int qtree_read_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot)
        spin_unlock(&dq_data_lock);
        kfree(ddquot);
 out:
-       dqstats.reads++;
+       dqstats_inc(DQST_READS);
        return ret;
 }
 EXPORT_SYMBOL(qtree_read_dquot);
@@ -632,7 +651,8 @@ EXPORT_SYMBOL(qtree_read_dquot);
  * the only one operating on dquot (thanks to dq_lock) */
 int qtree_release_dquot(struct qtree_mem_dqinfo *info, struct dquot *dquot)
 {
-       if (test_bit(DQ_FAKE_B, &dquot->dq_flags) && !(dquot->dq_dqb.dqb_curinodes | dquot->dq_dqb.dqb_curspace))
+       if (test_bit(DQ_FAKE_B, &dquot->dq_flags) &&
+           !(dquot->dq_dqb.dqb_curinodes | dquot->dq_dqb.dqb_curspace))
                return qtree_delete_dquot(info, dquot);
        return 0;
 }