Skip to content

Commit

Permalink
[GFS2] 80 Column audit of GFS2
Browse files Browse the repository at this point in the history
Requested by:
Prarit Bhargava <prarit@redhat.com>

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
  • Loading branch information
Steven Whitehouse committed Feb 27, 2006
1 parent 3a8fe9b commit 568f4c9
Show file tree
Hide file tree
Showing 20 changed files with 146 additions and 72 deletions.
10 changes: 7 additions & 3 deletions fs/gfs2/bmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ int gfs2_unstuff_dinode(struct gfs2_inode *ip, gfs2_unstuffer_t unstuffer,
gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode));

if (ip->i_di.di_size) {
*(uint64_t *)(dibh->b_data + sizeof(struct gfs2_dinode)) = cpu_to_be64(block);
*(uint64_t *)(dibh->b_data + sizeof(struct gfs2_dinode)) =
cpu_to_be64(block);
ip->i_di.di_blocks++;
}

Expand Down Expand Up @@ -241,7 +242,9 @@ static int build_height(struct gfs2_inode *ip, int height)
gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode));

if (new_block) {
*(uint64_t *)(dibh->b_data + sizeof(struct gfs2_dinode)) = cpu_to_be64(block);
*(uint64_t *)(dibh->b_data +
sizeof(struct gfs2_dinode)) =
cpu_to_be64(block);
ip->i_di.di_blocks++;
}

Expand Down Expand Up @@ -313,7 +316,8 @@ static int build_height(struct gfs2_inode *ip, int height)
*
*/

static void find_metapath(struct gfs2_inode *ip, uint64_t block, struct metapath *mp)
static void find_metapath(struct gfs2_inode *ip, uint64_t block,
struct metapath *mp)
{
struct gfs2_sbd *sdp = ip->i_sbd;
uint64_t b = block;
Expand Down
30 changes: 20 additions & 10 deletions fs/gfs2/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ int gfs2_dir_get_buffer(struct gfs2_inode *ip, uint64_t block, int new,
gfs2_metatype_set(bh, GFS2_METATYPE_JD, GFS2_FORMAT_JD);
gfs2_buffer_clear_tail(bh, sizeof(struct gfs2_meta_header));
} else {
error = gfs2_meta_read(ip->i_gl, block, DIO_START | DIO_WAIT, &bh);
error = gfs2_meta_read(ip->i_gl, block, DIO_START | DIO_WAIT,
&bh);
if (error)
return error;
if (gfs2_metatype_check(ip->i_sbd, bh, GFS2_METATYPE_JD)) {
Expand Down Expand Up @@ -163,7 +164,8 @@ static int gfs2_dir_write_data(struct gfs2_inode *ip, const char *buf,

if (gfs2_is_stuffed(ip) &&
offset + size <= sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode))
return gfs2_dir_write_stuffed(ip, buf, (unsigned int)offset, size);
return gfs2_dir_write_stuffed(ip, buf, (unsigned int)offset,
size);

if (gfs2_assert_warn(sdp, gfs2_is_jdata(ip)))
return -EINVAL;
Expand All @@ -188,15 +190,18 @@ static int gfs2_dir_write_data(struct gfs2_inode *ip, const char *buf,

if (!extlen) {
new = 1;
error = gfs2_block_map(ip, lblock, &new, &dblock, &extlen);
error = gfs2_block_map(ip, lblock, &new, &dblock,
&extlen);
if (error)
goto fail;
error = -EIO;
if (gfs2_assert_withdraw(sdp, dblock))
goto fail;
}

error = gfs2_dir_get_buffer(ip, dblock, (amount == sdp->sd_jbsize) ? 1 : new, &bh);
error = gfs2_dir_get_buffer(ip, dblock,
(amount == sdp->sd_jbsize) ?
1 : new, &bh);
if (error)
goto fail;

Expand Down Expand Up @@ -280,7 +285,8 @@ static int gfs2_dir_read_data(struct gfs2_inode *ip, char *buf,
return 0;

if (gfs2_is_stuffed(ip))
return gfs2_dir_read_stuffed(ip, buf, (unsigned int)offset, size);
return gfs2_dir_read_stuffed(ip, buf, (unsigned int)offset,
size);

if (gfs2_assert_warn(sdp, gfs2_is_jdata(ip)))
return -EINVAL;
Expand All @@ -299,7 +305,8 @@ static int gfs2_dir_read_data(struct gfs2_inode *ip, char *buf,

if (!extlen) {
new = 0;
error = gfs2_block_map(ip, lblock, &new, &dblock, &extlen);
error = gfs2_block_map(ip, lblock, &new, &dblock,
&extlen);
if (error)
goto fail;
}
Expand Down Expand Up @@ -538,13 +545,15 @@ int gfs2_dirent_alloc(struct gfs2_inode *dip, struct buffer_head *bh,

if (dent->de_inum.no_addr) {
new = (struct gfs2_dirent *)((char *)dent +
GFS2_DIRENT_SIZE(cur_name_len));
GFS2_DIRENT_SIZE(cur_name_len));
memset(new, 0, sizeof(struct gfs2_dirent));

new->de_rec_len = cpu_to_be16(cur_rec_len - GFS2_DIRENT_SIZE(cur_name_len));
new->de_rec_len = cpu_to_be16(cur_rec_len -
GFS2_DIRENT_SIZE(cur_name_len));
new->de_name_len = cpu_to_be16(name_len);

dent->de_rec_len = cpu_to_be16(cur_rec_len - be16_to_cpu(new->de_rec_len));
dent->de_rec_len = cpu_to_be16(cur_rec_len -
be16_to_cpu(new->de_rec_len));

*dent_out = new;
return 0;
Expand Down Expand Up @@ -2281,7 +2290,8 @@ int gfs2_dir_exhash_dealloc(struct gfs2_inode *dip)
error = gfs2_meta_inode_buffer(dip, &bh);
if (!error) {
gfs2_trans_add_bh(dip->i_gl, bh, 1);
((struct gfs2_dinode *)bh->b_data)->di_mode = cpu_to_be32(S_IFREG);
((struct gfs2_dinode *)bh->b_data)->di_mode =
cpu_to_be32(S_IFREG);
brelse(bh);
}

Expand Down
4 changes: 2 additions & 2 deletions fs/gfs2/eattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,6 @@ static int ea_remove_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh,
return error;
}

/******************************************************************************/

static int gfs2_ea_repack_i(struct gfs2_inode *ip)
{
Expand Down Expand Up @@ -819,7 +818,8 @@ static int ea_init(struct gfs2_inode *ip, struct gfs2_ea_request *er)
static struct gfs2_ea_header *ea_split_ea(struct gfs2_ea_header *ea)
{
uint32_t ea_size = GFS2_EA_SIZE(ea);
struct gfs2_ea_header *new = (struct gfs2_ea_header *)((char *)ea + ea_size);
struct gfs2_ea_header *new = (struct gfs2_ea_header *)((char *)ea +
ea_size);
uint32_t new_size = GFS2_EA_REC_LEN(ea) - ea_size;
int last = ea->ea_flags & GFS2_EAFLAG_LAST;

Expand Down
9 changes: 6 additions & 3 deletions fs/gfs2/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1034,8 +1034,10 @@ static void init_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl,
gfs2_tune_get(sdp, gt_new_files_directio))
di->di_flags |= cpu_to_be32(GFS2_DIF_DIRECTIO);
} else if (S_ISDIR(mode)) {
di->di_flags |= cpu_to_be32(dip->i_di.di_flags & GFS2_DIF_INHERIT_DIRECTIO);
di->di_flags |= cpu_to_be32(dip->i_di.di_flags & GFS2_DIF_INHERIT_JDATA);
di->di_flags |= cpu_to_be32(dip->i_di.di_flags &
GFS2_DIF_INHERIT_DIRECTIO);
di->di_flags |= cpu_to_be32(dip->i_di.di_flags &
GFS2_DIF_INHERIT_JDATA);
}

di->__pad1 = 0;
Expand Down Expand Up @@ -1188,7 +1190,8 @@ static int link_dinode(struct gfs2_inode *dip, struct qstr *name,
* Returns: An inode
*/

struct inode *gfs2_createi(struct gfs2_holder *ghs, struct qstr *name, unsigned int mode)
struct inode *gfs2_createi(struct gfs2_holder *ghs, struct qstr *name,
unsigned int mode)
{
struct inode *inode;
struct gfs2_inode *dip = get_gl2ip(ghs->gh_gl);
Expand Down
3 changes: 2 additions & 1 deletion fs/gfs2/inode.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ int gfs2_inode_dealloc(struct gfs2_sbd *sdp, struct gfs2_unlinked *ul);
int gfs2_change_nlink(struct gfs2_inode *ip, int diff);
int gfs2_lookupi(struct inode *dir, struct qstr *name, int is_root,
struct inode **ipp);
struct inode *gfs2_createi(struct gfs2_holder *ghs, struct qstr *name, unsigned int mode);
struct inode *gfs2_createi(struct gfs2_holder *ghs, struct qstr *name,
unsigned int mode);
int gfs2_unlinki(struct gfs2_inode *dip, struct qstr *name,
struct gfs2_inode *ip, struct gfs2_unlinked *ul);
int gfs2_rmdiri(struct gfs2_inode *dip, struct qstr *name,
Expand Down
9 changes: 6 additions & 3 deletions fs/gfs2/lm.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ int gfs2_lm_mount(struct gfs2_sbd *sdp, int silent)
void gfs2_lm_others_may_mount(struct gfs2_sbd *sdp)
{
if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
sdp->sd_lockstruct.ls_ops->lm_others_may_mount(sdp->sd_lockstruct.ls_lockspace);
sdp->sd_lockstruct.ls_ops->lm_others_may_mount(
sdp->sd_lockstruct.ls_lockspace);
}

void gfs2_lm_unmount(struct gfs2_sbd *sdp)
Expand Down Expand Up @@ -124,7 +125,8 @@ int gfs2_lm_get_lock(struct gfs2_sbd *sdp, struct lm_lockname *name,
if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
error = -EIO;
else
error = sdp->sd_lockstruct.ls_ops->lm_get_lock(sdp->sd_lockstruct.ls_lockspace, name, lockp);
error = sdp->sd_lockstruct.ls_ops->lm_get_lock(
sdp->sd_lockstruct.ls_lockspace, name, lockp);
return error;
}

Expand Down Expand Up @@ -230,6 +232,7 @@ void gfs2_lm_recovery_done(struct gfs2_sbd *sdp, unsigned int jid,
unsigned int message)
{
if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
sdp->sd_lockstruct.ls_ops->lm_recovery_done(sdp->sd_lockstruct.ls_lockspace, jid, message);
sdp->sd_lockstruct.ls_ops->lm_recovery_done(
sdp->sd_lockstruct.ls_lockspace, jid, message);
}

12 changes: 8 additions & 4 deletions fs/gfs2/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,12 @@ unsigned int gfs2_struct2blk(struct gfs2_sbd *sdp, unsigned int nstruct,
unsigned int first, second;

blks = 1;
first = (sdp->sd_sb.sb_bsize - sizeof(struct gfs2_log_descriptor)) / ssize;
first = (sdp->sd_sb.sb_bsize - sizeof(struct gfs2_log_descriptor)) /
ssize;

if (nstruct > first) {
second = (sdp->sd_sb.sb_bsize - sizeof(struct gfs2_meta_header)) / ssize;
second = (sdp->sd_sb.sb_bsize -
sizeof(struct gfs2_meta_header)) / ssize;
blks += DIV_RU(nstruct - first, second);
}

Expand Down Expand Up @@ -255,7 +257,8 @@ static uint64_t log_bmap(struct gfs2_sbd *sdp, unsigned int lbn)
uint64_t dbn;
int error;

error = gfs2_block_map(get_v2ip(sdp->sd_jdesc->jd_inode), lbn, &new, &dbn, NULL);
error = gfs2_block_map(get_v2ip(sdp->sd_jdesc->jd_inode),
lbn, &new, &dbn, NULL);
gfs2_assert_withdraw(sdp, !error && dbn);

return dbn;
Expand Down Expand Up @@ -554,7 +557,8 @@ static void log_refund(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
gfs2_assert_withdraw(sdp, ((int)sdp->sd_log_commited_revoke) >= 0);

if (sdp->sd_log_commited_buf)
reserved += 1 + sdp->sd_log_commited_buf + sdp->sd_log_commited_buf/503;
reserved += 1 + sdp->sd_log_commited_buf +
sdp->sd_log_commited_buf/503;
if (sdp->sd_log_commited_revoke)
reserved += gfs2_struct2blk(sdp, sdp->sd_log_commited_revoke,
sizeof(uint64_t));
Expand Down
54 changes: 37 additions & 17 deletions fs/gfs2/lops.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ static void buf_lo_before_commit(struct gfs2_sbd *sdp)
memset(ld->ld_reserved, 0, sizeof(ld->ld_reserved));

n = 0;
list_for_each_entry_continue(bd1, &sdp->sd_log_le_buf, bd_le.le_list) {
list_for_each_entry_continue(bd1, &sdp->sd_log_le_buf,
bd_le.le_list) {
*ptr++ = cpu_to_be64(bd1->bd_bh->b_blocknr);
if (++n >= num)
break;
Expand All @@ -147,7 +148,8 @@ static void buf_lo_before_commit(struct gfs2_sbd *sdp)
ll_rw_block(WRITE, 1, &bh);

n = 0;
list_for_each_entry_continue(bd2, &sdp->sd_log_le_buf, bd_le.le_list) {
list_for_each_entry_continue(bd2, &sdp->sd_log_le_buf,
bd_le.le_list) {
bh = gfs2_log_fake_buf(sdp, bd2->bd_bh);
set_buffer_dirty(bh);
ll_rw_block(WRITE, 1, &bh);
Expand Down Expand Up @@ -239,7 +241,8 @@ static void buf_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)
struct gfs2_sbd *sdp = get_v2ip(jd->jd_inode)->i_sbd;

if (error) {
gfs2_meta_sync(get_v2ip(jd->jd_inode)->i_gl, DIO_START | DIO_WAIT);
gfs2_meta_sync(get_v2ip(jd->jd_inode)->i_gl,
DIO_START | DIO_WAIT);
return;
}
if (pass != 1)
Expand Down Expand Up @@ -283,7 +286,8 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp)
ld->ld_header.mh_type = cpu_to_be16(GFS2_METATYPE_LD);
ld->ld_header.mh_format = cpu_to_be16(GFS2_FORMAT_LD);
ld->ld_type = cpu_to_be32(GFS2_LOG_DESC_REVOKE);
ld->ld_length = cpu_to_be32(gfs2_struct2blk(sdp, sdp->sd_log_num_revoke, sizeof(uint64_t)));
ld->ld_length = cpu_to_be32(gfs2_struct2blk(sdp, sdp->sd_log_num_revoke,
sizeof(uint64_t)));
ld->ld_data1 = cpu_to_be32(sdp->sd_log_num_revoke);
ld->ld_data2 = cpu_to_be32(0);
memset(ld->ld_reserved, 0, sizeof(ld->ld_reserved));
Expand Down Expand Up @@ -515,27 +519,33 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp)
* into the log along with a header
*/
gfs2_log_lock(sdp);
bd2 = bd1 = list_prepare_entry(bd1, &sdp->sd_log_le_databuf, bd_le.le_list);
bd2 = bd1 = list_prepare_entry(bd1, &sdp->sd_log_le_databuf,
bd_le.le_list);
while(total_dbuf) {
num = total_jdata;
if (num > limit)
num = limit;
n = 0;
list_for_each_entry_safe_continue(bd1, bdt, &sdp->sd_log_le_databuf, bd_le.le_list) {
list_for_each_entry_safe_continue(bd1, bdt,
&sdp->sd_log_le_databuf,
bd_le.le_list) {
/* An ordered write buffer */
if (bd1->bd_bh && !buffer_pinned(bd1->bd_bh)) {
list_move(&bd1->bd_le.le_list, &started);
if (bd1 == bd2) {
bd2 = NULL;
bd2 = list_prepare_entry(bd2, &sdp->sd_log_le_databuf, bd_le.le_list);
bd2 = list_prepare_entry(bd2,
&sdp->sd_log_le_databuf,
bd_le.le_list);
}
total_dbuf--;
if (bd1->bd_bh) {
get_bh(bd1->bd_bh);
if (buffer_dirty(bd1->bd_bh)) {
gfs2_log_unlock(sdp);
wait_on_buffer(bd1->bd_bh);
ll_rw_block(WRITE, 1, &bd1->bd_bh);
ll_rw_block(WRITE, 1,
&bd1->bd_bh);
gfs2_log_lock(sdp);
}
brelse(bd1->bd_bh);
Expand All @@ -547,12 +557,17 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp)
gfs2_log_unlock(sdp);
if (!bh) {
bh = gfs2_log_get_buf(sdp);
ld = (struct gfs2_log_descriptor *)bh->b_data;
ld = (struct gfs2_log_descriptor *)
bh->b_data;
ptr = (__be64 *)(bh->b_data + offset);
ld->ld_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
ld->ld_header.mh_type = cpu_to_be16(GFS2_METATYPE_LD);
ld->ld_header.mh_format = cpu_to_be16(GFS2_FORMAT_LD);
ld->ld_type = cpu_to_be32(GFS2_LOG_DESC_JDATA);
ld->ld_header.mh_magic =
cpu_to_be32(GFS2_MAGIC);
ld->ld_header.mh_type =
cpu_to_be16(GFS2_METATYPE_LD);
ld->ld_header.mh_format =
cpu_to_be16(GFS2_FORMAT_LD);
ld->ld_type =
cpu_to_be32(GFS2_LOG_DESC_JDATA);
ld->ld_length = cpu_to_be32(num + 1);
ld->ld_data1 = cpu_to_be32(num);
ld->ld_data2 = cpu_to_be32(0);
Expand All @@ -577,7 +592,8 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp)
}
n = 0;
gfs2_log_lock(sdp);
list_for_each_entry_continue(bd2, &sdp->sd_log_le_databuf, bd_le.le_list) {
list_for_each_entry_continue(bd2, &sdp->sd_log_le_databuf,
bd_le.le_list) {
if (!bd2->bd_bh)
continue;
/* copy buffer if it needs escaping */
Expand All @@ -587,7 +603,9 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp)
struct page *page = bd2->bd_bh->b_page;
bh = gfs2_log_get_buf(sdp);
kaddr = kmap_atomic(page, KM_USER0);
memcpy(bh->b_data, kaddr + bh_offset(bd2->bd_bh), sdp->sd_sb.sb_bsize);
memcpy(bh->b_data,
kaddr + bh_offset(bd2->bd_bh),
sdp->sd_sb.sb_bsize);
kunmap_atomic(page, KM_USER0);
*(__be32 *)bh->b_data = 0;
} else {
Expand All @@ -608,7 +626,8 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp)
/* Wait on all ordered buffers */
while (!list_empty(&started)) {
gfs2_log_lock(sdp);
bd1 = list_entry(started.next, struct gfs2_bufdata, bd_le.le_list);
bd1 = list_entry(started.next, struct gfs2_bufdata,
bd_le.le_list);
list_del(&bd1->bd_le.le_list);
sdp->sd_log_num_databuf--;

Expand Down Expand Up @@ -685,7 +704,8 @@ static void databuf_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)
struct gfs2_sbd *sdp = get_v2ip(jd->jd_inode)->i_sbd;

if (error) {
gfs2_meta_sync(get_v2ip(jd->jd_inode)->i_gl, DIO_START | DIO_WAIT);
gfs2_meta_sync(get_v2ip(jd->jd_inode)->i_gl,
DIO_START | DIO_WAIT);
return;
}
if (pass != 1)
Expand Down
3 changes: 2 additions & 1 deletion fs/gfs2/lvb.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@

#include "gfs2.h"

#define pv(struct, member, fmt) printk(" "#member" = "fmt"\n", struct->member);
#define pv(struct, member, fmt) printk(KERN_INFO " "#member" = "fmt"\n", \
struct->member);

void gfs2_quota_lvb_in(struct gfs2_quota_lvb *qb, char *lvb)
{
Expand Down
Loading

0 comments on commit 568f4c9

Please sign in to comment.