#include <linux/sort.h>
#include <linux/gfs2_ondisk.h>
#include <linux/crc32.h>
+#include <linux/lm_interface.h>
+#include <linux/security.h>
#include "gfs2.h"
-#include "lm_interface.h"
#include "incore.h"
#include "acl.h"
#include "bmap.h"
void gfs2_inode_attr_in(struct gfs2_inode *ip)
{
struct inode *inode = &ip->i_inode;
+ struct gfs2_dinode *di = &ip->i_di;
inode->i_ino = ip->i_num.no_addr;
- switch (ip->i_di.di_mode & S_IFMT) {
+ switch (di->di_mode & S_IFMT) {
case S_IFBLK:
case S_IFCHR:
- inode->i_rdev = MKDEV(ip->i_di.di_major, ip->i_di.di_minor);
+ inode->i_rdev = MKDEV(di->di_major, di->di_minor);
break;
default:
inode->i_rdev = 0;
break;
};
- inode->i_mode = ip->i_di.di_mode;
- inode->i_nlink = ip->i_di.di_nlink;
- inode->i_uid = ip->i_di.di_uid;
- inode->i_gid = ip->i_di.di_gid;
- i_size_write(inode, ip->i_di.di_size);
- inode->i_atime.tv_sec = ip->i_di.di_atime;
- inode->i_mtime.tv_sec = ip->i_di.di_mtime;
- inode->i_ctime.tv_sec = ip->i_di.di_ctime;
+ inode->i_mode = di->di_mode;
+ inode->i_nlink = di->di_nlink;
+ inode->i_uid = di->di_uid;
+ inode->i_gid = di->di_gid;
+ i_size_write(inode, di->di_size);
+ inode->i_atime.tv_sec = di->di_atime;
+ inode->i_mtime.tv_sec = di->di_mtime;
+ inode->i_ctime.tv_sec = di->di_ctime;
inode->i_atime.tv_nsec = 0;
inode->i_mtime.tv_nsec = 0;
inode->i_ctime.tv_nsec = 0;
- inode->i_blksize = PAGE_SIZE;
- inode->i_blocks = ip->i_di.di_blocks <<
+ inode->i_blocks = di->di_blocks <<
(GFS2_SB(inode)->sd_sb.sb_bsize_shift - GFS2_BASIC_BLOCK_SHIFT);
- if (ip->i_di.di_flags & GFS2_DIF_IMMUTABLE)
+ if (di->di_flags & GFS2_DIF_IMMUTABLE)
inode->i_flags |= S_IMMUTABLE;
else
inode->i_flags &= ~S_IMMUTABLE;
- if (ip->i_di.di_flags & GFS2_DIF_APPENDONLY)
+ if (di->di_flags & GFS2_DIF_APPENDONLY)
inode->i_flags |= S_APPEND;
else
inode->i_flags &= ~S_APPEND;
void gfs2_inode_attr_out(struct gfs2_inode *ip)
{
struct inode *inode = &ip->i_inode;
-
+ struct gfs2_dinode *di = &ip->i_di;
gfs2_assert_withdraw(GFS2_SB(inode),
- (ip->i_di.di_mode & S_IFMT) == (inode->i_mode & S_IFMT));
- ip->i_di.di_mode = inode->i_mode;
- ip->i_di.di_uid = inode->i_uid;
- ip->i_di.di_gid = inode->i_gid;
- ip->i_di.di_atime = inode->i_atime.tv_sec;
- ip->i_di.di_mtime = inode->i_mtime.tv_sec;
- ip->i_di.di_ctime = inode->i_ctime.tv_sec;
+ (di->di_mode & S_IFMT) == (inode->i_mode & S_IFMT));
+ di->di_mode = inode->i_mode;
+ di->di_uid = inode->i_uid;
+ di->di_gid = inode->i_gid;
+ di->di_atime = inode->i_atime.tv_sec;
+ di->di_mtime = inode->i_mtime.tv_sec;
+ di->di_ctime = inode->i_ctime.tv_sec;
}
static int iget_test(struct inode *inode, void *opaque)
struct gfs2_glock *io_gl;
int error;
+ if (!inode)
+ return ERR_PTR(-ENOBUFS);
+
if (inode->i_state & I_NEW) {
struct gfs2_sbd *sdp = GFS2_SB(inode);
umode_t mode = DT2IF(type);
- inode->u.generic_ip = ip;
+ inode->i_private = ip;
inode->i_mode = mode;
if (S_ISREG(mode)) {
{
struct gfs2_sbd *sdp = ip->i_inode.i_sb->s_fs_info;
struct buffer_head *dibh;
- uint32_t nlink;
+ u32 nlink;
int error;
BUG_ON(ip->i_di.di_nlink != ip->i_inode.i_nlink);
if (error)
goto out_norgrp;
+ clear_nlink(&ip->i_inode);
gfs2_unlink_di(&ip->i_inode); /* mark inode unlinked */
gfs2_glock_dq_uninit(&rg_gh);
out_norgrp:
struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name,
int is_root, struct nameidata *nd)
-
{
struct super_block *sb = dir->i_sb;
struct gfs2_inode *dip = GFS2_I(dir);
return inode;
}
-static int pick_formal_ino_1(struct gfs2_sbd *sdp, uint64_t *formal_ino)
+static int pick_formal_ino_1(struct gfs2_sbd *sdp, u64 *formal_ino)
{
struct gfs2_inode *ip = GFS2_I(sdp->sd_ir_inode);
struct buffer_head *bh;
return 1;
}
-static int pick_formal_ino_2(struct gfs2_sbd *sdp, uint64_t *formal_ino)
+static int pick_formal_ino_2(struct gfs2_sbd *sdp, u64 *formal_ino)
{
struct gfs2_inode *ip = GFS2_I(sdp->sd_ir_inode);
struct gfs2_inode *m_ip = GFS2_I(sdp->sd_inum_inode);
error = gfs2_meta_inode_buffer(ip, &bh);
if (error)
goto out_end_trans;
-
+
gfs2_inum_range_in(&ir, bh->b_data + sizeof(struct gfs2_dinode));
if (!ir.ir_length) {
struct buffer_head *m_bh;
- uint64_t x, y;
+ u64 x, y;
error = gfs2_meta_inode_buffer(m_ip, &m_bh);
if (error)
goto out_brelse;
- x = *(uint64_t *)(m_bh->b_data + sizeof(struct gfs2_dinode));
+ x = *(u64 *)(m_bh->b_data + sizeof(struct gfs2_dinode));
x = y = be64_to_cpu(x);
ir.ir_start = x;
ir.ir_length = GFS2_INUM_QUANTUM;
gfs2_consist_inode(m_ip);
x = cpu_to_be64(x);
gfs2_trans_add_bh(m_ip->i_gl, m_bh, 1);
- *(uint64_t *)(m_bh->b_data + sizeof(struct gfs2_dinode)) = x;
+ *(u64 *)(m_bh->b_data + sizeof(struct gfs2_dinode)) = x;
brelse(m_bh);
}
return error;
}
-static int pick_formal_ino(struct gfs2_sbd *sdp, uint64_t *inum)
+static int pick_formal_ino(struct gfs2_sbd *sdp, u64 *inum)
{
int error;
return error;
}
- if (dip->i_di.di_entries == (uint32_t)-1)
+ if (dip->i_di.di_entries == (u32)-1)
return -EFBIG;
- if (S_ISDIR(mode) && dip->i_di.di_nlink == (uint32_t)-1)
+ if (S_ISDIR(mode) && dip->i_di.di_nlink == (u32)-1)
return -EMLINK;
return 0;
error = gfs2_trans_begin(sdp, sdp->sd_max_dirres +
al->al_rgd->rd_ri.ri_length +
- 2 * RES_DINODE +
+ 2 * RES_DINODE +
RES_STATFS + RES_QUOTA, 0);
if (error)
goto fail_ipreserv;
return error;
}
+static int gfs2_security_init(struct gfs2_inode *dip, struct gfs2_inode *ip)
+{
+ int err;
+ size_t len;
+ void *value;
+ char *name;
+ struct gfs2_ea_request er;
+
+ err = security_inode_init_security(&ip->i_inode, &dip->i_inode,
+ &name, &value, &len);
+
+ if (err) {
+ if (err == -EOPNOTSUPP)
+ return 0;
+ return err;
+ }
+
+ memset(&er, 0, sizeof(struct gfs2_ea_request));
+
+ er.er_type = GFS2_EATYPE_SECURITY;
+ er.er_name = name;
+ er.er_data = value;
+ er.er_name_len = strlen(name);
+ er.er_data_len = len;
+
+ err = gfs2_ea_set_i(ip, &er);
+
+ kfree(value);
+ kfree(name);
+
+ return err;
+}
+
/**
* gfs2_createi - Create a new inode
* @ghs: An array of two holders
if (error)
goto fail_iput;
+ error = gfs2_security_init(dip, GFS2_I(inode));
+ if (error)
+ goto fail_iput;
+
error = link_dinode(dip, name, GFS2_I(inode));
if (error)
goto fail_iput;
struct gfs2_glock *gl = gh->gh_gl;
struct gfs2_sbd *sdp = gl->gl_sbd;
struct gfs2_inode *ip = gl->gl_object;
- int64_t curtime, quantum = gfs2_tune_get(sdp, gt_atime_quantum);
+ s64 curtime, quantum = gfs2_tune_get(sdp, gt_atime_quantum);
unsigned int state;
int flags;
int error;
curtime = get_seconds();
if (curtime - ip->i_di.di_atime >= quantum) {
struct buffer_head *dibh;
+ struct gfs2_dinode *di;
error = gfs2_trans_begin(sdp, RES_DINODE, 0);
if (error == -EROFS)
ip->i_di.di_atime = curtime;
gfs2_trans_add_bh(ip->i_gl, dibh, 1);
- gfs2_dinode_out(&ip->i_di, dibh->b_data);
+ di = (struct gfs2_dinode *)dibh->b_data;
+ di->di_atime = cpu_to_be64(ip->i_di.di_atime);
brelse(dibh);
gfs2_trans_end(sdp);
*
* Returns: 1 if A > B
* -1 if A < B
- * 0 if A = B
+ * 0 if A == B
*/
static int glock_compare_atime(const void *arg_a, const void *arg_b)
{
- struct gfs2_holder *gh_a = *(struct gfs2_holder **)arg_a;
- struct gfs2_holder *gh_b = *(struct gfs2_holder **)arg_b;
- struct lm_lockname *a = &gh_a->gh_gl->gl_name;
- struct lm_lockname *b = &gh_b->gh_gl->gl_name;
- int ret = 0;
+ const struct gfs2_holder *gh_a = *(const struct gfs2_holder **)arg_a;
+ const struct gfs2_holder *gh_b = *(const struct gfs2_holder **)arg_b;
+ const struct lm_lockname *a = &gh_a->gh_gl->gl_name;
+ const struct lm_lockname *b = &gh_b->gh_gl->gl_name;
if (a->ln_number > b->ln_number)
- ret = 1;
- else if (a->ln_number < b->ln_number)
- ret = -1;
- else {
- if (gh_a->gh_state == LM_ST_SHARED &&
- gh_b->gh_state == LM_ST_EXCLUSIVE)
- ret = 1;
- else if (gh_a->gh_state == LM_ST_SHARED &&
- (gh_b->gh_flags & GL_ATIME))
- ret = 1;
- }
+ return 1;
+ if (a->ln_number < b->ln_number)
+ return -1;
+ if (gh_a->gh_state == LM_ST_SHARED && gh_b->gh_state == LM_ST_EXCLUSIVE)
+ return 1;
+ if (gh_a->gh_state == LM_ST_SHARED && (gh_b->gh_flags & GL_ATIME))
+ return 1;
- return ret;
+ return 0;
}
/**