Skip to content

Commit

Permalink
[GFS2] Macros removal in gfs2.h
Browse files Browse the repository at this point in the history
As suggested by Pekka Enberg <penberg@cs.helsinki.fi>.

The DIV_RU macro is renamed DIV_ROUND_UP and and moved to kernel.h
The other macros are gone from gfs2.h as (although not requested
by Pekka Enberg) are a number of included header file which are now
included individually. The inode number comparison function is
now an inline function.

The DT2IF and IF2DT may be addressed in a future patch.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
  • Loading branch information
Steven Whitehouse committed Feb 27, 2006
1 parent f3b270a commit 5c676f6
Show file tree
Hide file tree
Showing 40 changed files with 416 additions and 272 deletions.
8 changes: 6 additions & 2 deletions fs/gfs2/acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,19 @@
#include <linux/posix_acl.h>
#include <linux/posix_acl_xattr.h>
#include <asm/semaphore.h>
#include <linux/gfs2_ondisk.h>

#include "gfs2.h"
#include "lm_interface.h"
#include "incore.h"
#include "acl.h"
#include "eaops.h"
#include "eattr.h"
#include "glock.h"
#include "inode.h"
#include "meta_io.h"
#include "trans.h"
#include "util.h"

#define ACL_ACCESS 1
#define ACL_DEFAULT 0
Expand Down Expand Up @@ -157,7 +161,7 @@ int gfs2_check_acl_locked(struct inode *inode, int mask)
struct posix_acl *acl = NULL;
int error;

error = acl_get(get_v2ip(inode), ACL_ACCESS, &acl, NULL, NULL, NULL);
error = acl_get(inode->u.generic_ip, ACL_ACCESS, &acl, NULL, NULL, NULL);
if (error)
return error;

Expand All @@ -172,7 +176,7 @@ int gfs2_check_acl_locked(struct inode *inode, int mask)

int gfs2_check_acl(struct inode *inode, int mask)
{
struct gfs2_inode *ip = get_v2ip(inode);
struct gfs2_inode *ip = inode->u.generic_ip;
struct gfs2_holder i_gh;
int error;

Expand Down
4 changes: 4 additions & 0 deletions fs/gfs2/bits.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@
#include <linux/spinlock.h>
#include <linux/completion.h>
#include <linux/buffer_head.h>
#include <linux/gfs2_ondisk.h>
#include <asm/semaphore.h>

#include "gfs2.h"
#include "lm_interface.h"
#include "incore.h"
#include "bits.h"
#include "util.h"

static const char valid_change[16] = {
/* current */
Expand Down
10 changes: 7 additions & 3 deletions fs/gfs2/bmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@
#include <linux/spinlock.h>
#include <linux/completion.h>
#include <linux/buffer_head.h>
#include <linux/gfs2_ondisk.h>
#include <asm/semaphore.h>

#include "gfs2.h"
#include "lm_interface.h"
#include "incore.h"
#include "bmap.h"
#include "glock.h"
#include "inode.h"
Expand All @@ -24,6 +27,7 @@
#include "rgrp.h"
#include "trans.h"
#include "dir.h"
#include "util.h"

/* This doesn't need to be that large as max 64 bit pointers in a 4k
* block is 512, so __u16 is fine for that. It saves stack space to
Expand Down Expand Up @@ -660,7 +664,7 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh,

for (x = 0; x < rlist.rl_rgrps; x++) {
struct gfs2_rgrpd *rgd;
rgd = get_gl2rgd(rlist.rl_ghs[x].gh_gl);
rgd = rlist.rl_ghs[x].gh_gl->gl_object;
rg_blocks += rgd->rd_ri.ri_length;
}

Expand Down Expand Up @@ -1021,15 +1025,15 @@ void gfs2_write_calc_reserv(struct gfs2_inode *ip, unsigned int len,
unsigned int tmp;

if (gfs2_is_dir(ip)) {
*data_blocks = DIV_RU(len, sdp->sd_jbsize) + 2;
*data_blocks = DIV_ROUND_UP(len, sdp->sd_jbsize) + 2;
*ind_blocks = 3 * (sdp->sd_max_jheight - 1);
} else {
*data_blocks = (len >> sdp->sd_sb.sb_bsize_shift) + 3;
*ind_blocks = 3 * (sdp->sd_max_height - 1);
}

for (tmp = *data_blocks; tmp > sdp->sd_diptrs;) {
tmp = DIV_RU(tmp, sdp->sd_inptrs);
tmp = DIV_ROUND_UP(tmp, sdp->sd_inptrs);
*ind_blocks += tmp;
}
}
Expand Down
4 changes: 4 additions & 0 deletions fs/gfs2/daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,20 @@
#include <linux/buffer_head.h>
#include <linux/kthread.h>
#include <linux/delay.h>
#include <linux/gfs2_ondisk.h>
#include <asm/semaphore.h>

#include "gfs2.h"
#include "lm_interface.h"
#include "incore.h"
#include "daemon.h"
#include "glock.h"
#include "log.h"
#include "quota.h"
#include "recovery.h"
#include "super.h"
#include "unlinked.h"
#include "util.h"

/* This uses schedule_timeout() instead of msleep() because it's good for
the daemons to wake up more often than the timeout when unmounting so
Expand Down
8 changes: 6 additions & 2 deletions fs/gfs2/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,12 @@
#include <linux/completion.h>
#include <linux/buffer_head.h>
#include <linux/sort.h>
#include <linux/gfs2_ondisk.h>
#include <asm/semaphore.h>

#include "gfs2.h"
#include "lm_interface.h"
#include "incore.h"
#include "dir.h"
#include "glock.h"
#include "inode.h"
Expand All @@ -70,6 +73,7 @@
#include "rgrp.h"
#include "trans.h"
#include "bmap.h"
#include "util.h"

#define IS_LEAF 1 /* Hashed (leaf) directory */
#define IS_DINODE 2 /* Linear (stuffed dinode block) directory */
Expand Down Expand Up @@ -2196,7 +2200,7 @@ static int leaf_dealloc(struct gfs2_inode *dip, uint32_t index, uint32_t len,

for (x = 0; x < rlist.rl_rgrps; x++) {
struct gfs2_rgrpd *rgd;
rgd = get_gl2rgd(rlist.rl_ghs[x].gh_gl);
rgd = rlist.rl_ghs[x].gh_gl->gl_object;
rg_blocks += rgd->rd_ri.ri_length;
}

Expand All @@ -2205,7 +2209,7 @@ static int leaf_dealloc(struct gfs2_inode *dip, uint32_t index, uint32_t len,
goto out_rlist;

error = gfs2_trans_begin(sdp,
rg_blocks + (DIV_RU(size, sdp->sd_jbsize) + 1) +
rg_blocks + (DIV_ROUND_UP(size, sdp->sd_jbsize) + 1) +
RES_DINODE + RES_STATFS + RES_QUOTA, l_blocks);
if (error)
goto out_rg_gunlock;
Expand Down
4 changes: 4 additions & 0 deletions fs/gfs2/eaops.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@
#include <linux/completion.h>
#include <linux/buffer_head.h>
#include <linux/xattr.h>
#include <linux/gfs2_ondisk.h>
#include <asm/semaphore.h>
#include <asm/uaccess.h>

#include "gfs2.h"
#include "lm_interface.h"
#include "incore.h"
#include "acl.h"
#include "eaops.h"
#include "eattr.h"
#include "util.h"

/**
* gfs2_ea_name2type - get the type of the ea, and truncate type from the name
Expand Down
19 changes: 12 additions & 7 deletions fs/gfs2/eattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@
#include <linux/completion.h>
#include <linux/buffer_head.h>
#include <linux/xattr.h>
#include <linux/gfs2_ondisk.h>
#include <asm/semaphore.h>
#include <asm/uaccess.h>

#include "gfs2.h"
#include "lm_interface.h"
#include "incore.h"
#include "acl.h"
#include "eaops.h"
#include "eattr.h"
Expand All @@ -26,6 +29,7 @@
#include "quota.h"
#include "rgrp.h"
#include "trans.h"
#include "util.h"

/**
* ea_calc_size - returns the acutal number of bytes the request will take up
Expand Down Expand Up @@ -478,7 +482,7 @@ static int ea_get_unstuffed(struct gfs2_inode *ip, struct gfs2_ea_header *ea,
struct gfs2_sbd *sdp = ip->i_sbd;
struct buffer_head **bh;
unsigned int amount = GFS2_EA_DATA_LEN(ea);
unsigned int nptrs = DIV_RU(amount, sdp->sd_jbsize);
unsigned int nptrs = DIV_ROUND_UP(amount, sdp->sd_jbsize);
uint64_t *dataptrs = GFS2_EA2DATAPTRS(ea);
unsigned int x;
int error = 0;
Expand Down Expand Up @@ -676,7 +680,7 @@ static int ea_write(struct gfs2_inode *ip, struct gfs2_ea_header *ea,
unsigned int copy;
unsigned int x;

ea->ea_num_ptrs = DIV_RU(er->er_data_len, sdp->sd_jbsize);
ea->ea_num_ptrs = DIV_ROUND_UP(er->er_data_len, sdp->sd_jbsize);
for (x = 0; x < ea->ea_num_ptrs; x++) {
struct buffer_head *bh;
uint64_t block;
Expand Down Expand Up @@ -810,7 +814,7 @@ static int ea_init(struct gfs2_inode *ip, struct gfs2_ea_request *er)
unsigned int blks = 1;

if (GFS2_EAREQ_SIZE_STUFFED(er) > jbsize)
blks += DIV_RU(er->er_data_len, jbsize);
blks += DIV_ROUND_UP(er->er_data_len, jbsize);

return ea_alloc_skeleton(ip, er, blks, ea_init_i, NULL);
}
Expand Down Expand Up @@ -962,7 +966,8 @@ static int ea_set_simple(struct gfs2_inode *ip, struct buffer_head *bh,

es->es_bh = bh;
es->es_ea = ea;
blks = 2 + DIV_RU(es->es_er->er_data_len, ip->i_sbd->sd_jbsize);
blks = 2 + DIV_ROUND_UP(es->es_er->er_data_len,
ip->i_sbd->sd_jbsize);

error = ea_alloc_skeleton(ip, es->es_er, blks,
ea_set_simple_alloc, es);
Expand Down Expand Up @@ -1066,7 +1071,7 @@ static int ea_set_i(struct gfs2_inode *ip, struct gfs2_ea_request *er,
if (!(ip->i_di.di_flags & GFS2_DIF_EA_INDIRECT))
blks++;
if (GFS2_EAREQ_SIZE_STUFFED(er) > ip->i_sbd->sd_jbsize)
blks += DIV_RU(er->er_data_len, ip->i_sbd->sd_jbsize);
blks += DIV_ROUND_UP(er->er_data_len, ip->i_sbd->sd_jbsize);

return ea_alloc_skeleton(ip, er, blks, ea_set_block, el);
}
Expand Down Expand Up @@ -1250,7 +1255,7 @@ static int ea_acl_chmod_unstuffed(struct gfs2_inode *ip,
struct gfs2_sbd *sdp = ip->i_sbd;
struct buffer_head **bh;
unsigned int amount = GFS2_EA_DATA_LEN(ea);
unsigned int nptrs = DIV_RU(amount, sdp->sd_jbsize);
unsigned int nptrs = DIV_ROUND_UP(amount, sdp->sd_jbsize);
uint64_t *dataptrs = GFS2_EA2DATAPTRS(ea);
unsigned int x;
int error;
Expand Down Expand Up @@ -1402,7 +1407,7 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip)

for (x = 0; x < rlist.rl_rgrps; x++) {
struct gfs2_rgrpd *rgd;
rgd = get_gl2rgd(rlist.rl_ghs[x].gh_gl);
rgd = rlist.rl_ghs[x].gh_gl->gl_object;
rg_blocks += rgd->rd_ri.ri_length;
}

Expand Down
2 changes: 1 addition & 1 deletion fs/gfs2/eattr.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ALIGN(sizeof(struct gfs2_ea_header) + (er)->er_name_len + (er)->er_data_len, 8)

#define GFS2_EAREQ_SIZE_UNSTUFFED(sdp, er) \
ALIGN(sizeof(struct gfs2_ea_header) + (er)->er_name_len + \
sizeof(uint64_t) * DIV_RU((er)->er_data_len, (sdp)->sd_jbsize), 8)
sizeof(uint64_t) * DIV_ROUND_UP((er)->er_data_len, (sdp)->sd_jbsize), 8)

#define GFS2_EA2NAME(ea) ((char *)((struct gfs2_ea_header *)(ea) + 1))
#define GFS2_EA2DATA(ea) (GFS2_EA2NAME(ea) + (ea)->ea_name_len)
Expand Down
29 changes: 0 additions & 29 deletions fs/gfs2/gfs2.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@
#ifndef __GFS2_DOT_H__
#define __GFS2_DOT_H__

#include <linux/gfs2_ondisk.h>

#include "lm_interface.h"
#include "lvb.h"
#include "incore.h"
#include "util.h"

enum {
NO_CREATE = 0,
CREATE = 1,
Expand All @@ -32,29 +25,7 @@ enum {
FORCE = 1,
};

/* Divide num by den. Round up if there is a remainder. */
#define DIV_RU(num, den) (((num) + (den) - 1) / (den))

#define GFS2_FAST_NAME_SIZE 8

#define get_v2sdp(sb) ((struct gfs2_sbd *)(sb)->s_fs_info)
#define set_v2sdp(sb, sdp) (sb)->s_fs_info = (sdp)
#define get_v2ip(inode) ((struct gfs2_inode *)(inode)->u.generic_ip)
#define set_v2ip(inode, ip) (inode)->u.generic_ip = (ip)
#define get_v2fp(file) ((struct gfs2_file *)(file)->private_data)
#define set_v2fp(file, fp) (file)->private_data = (fp)
#define get_v2bd(bh) ((struct gfs2_bufdata *)(bh)->b_private)
#define set_v2bd(bh, bd) (bh)->b_private = (bd)

#define get_transaction ((struct gfs2_trans *)(current->journal_info))
#define set_transaction(tr) (current->journal_info) = (tr)

#define get_gl2ip(gl) ((struct gfs2_inode *)(gl)->gl_object)
#define set_gl2ip(gl, ip) (gl)->gl_object = (ip)
#define get_gl2rgd(gl) ((struct gfs2_rgrpd *)(gl)->gl_object)
#define set_gl2rgd(gl, rgd) (gl)->gl_object = (rgd)
#define get_gl2gl(gl) ((struct gfs2_glock *)(gl)->gl_object)
#define set_gl2gl(gl, gl2) (gl)->gl_object = (gl2)

#endif /* __GFS2_DOT_H__ */

Loading

0 comments on commit 5c676f6

Please sign in to comment.