/*
* Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
- * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
#include <linux/completion.h>
#include <linux/buffer_head.h>
#include <linux/xattr.h>
-#include <asm/semaphore.h>
+#include <linux/gfs2_ondisk.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 "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
return error;
}
-/******************************************************************************/
-
-static int gfs2_ea_repack_i(struct gfs2_inode *ip)
-{
- return -EOPNOTSUPP;
-}
-
-int gfs2_ea_repack(struct gfs2_inode *ip)
-{
- struct gfs2_holder gh;
- int error;
-
- error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
- if (error)
- return error;
-
- /* Some sort of permissions checking would be nice */
-
- error = gfs2_ea_repack_i(ip);
-
- gfs2_glock_dq_uninit(&gh);
-
- return error;
-}
-
struct ea_list {
struct gfs2_ea_request *ei_er;
unsigned int ei_size;
{
struct ea_list *ei = private;
struct gfs2_ea_request *er = ei->ei_er;
- unsigned int ea_size = GFS2_EA_STRLEN(ea);
+ unsigned int ea_size = gfs2_ea_strlen(ea);
if (ea->ea_type == GFS2_EATYPE_UNUSED)
return 0;
if (ei->ei_size + ea_size > er->er_data_len)
return -ERANGE;
- if (ea->ea_type == GFS2_EATYPE_USR) {
+ switch (ea->ea_type) {
+ case GFS2_EATYPE_USR:
prefix = "user.";
l = 5;
- } else {
+ break;
+ case GFS2_EATYPE_SYS:
prefix = "system.";
l = 7;
+ break;
+ case GFS2_EATYPE_SECURITY:
+ prefix = "security.";
+ l = 9;
+ break;
+ default:
+ break;
}
memcpy(er->er_data + ei->ei_size,
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;
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;
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);
}
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;
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);
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);
}
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;
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;
}