__u64 ctime;
__u64 blocks; /* XID, in the case of MDS_READPAGE */
__u64 io_epoch;
- __u64 ino;
__u32 fsuid;
__u32 fsgid;
__u32 capability;
__u32 flags; /* from vfs for pin/unpin, MDS_BFLAG for close */
__u32 rdev;
__u32 nlink; /* #bytes to read in the case of MDS_READPAGE */
- __u32 generation;
__u32 suppgid;
__u32 eadatasize;
__u32 aclsize;
__u32 max_mdsize;
- __u32 max_cookiesize; /* also fix lustre_swab_mds_body */
- __u32 padding_4; /* also fix lustre_swab_mds_body */
+ __u32 max_cookiesize; /* also fix lustre_swab_mdt_body */
};
struct mds_body {
install-exec-hook:
endif
-libllite_a_SOURCES = llite_lib.c super.c namei.c rw.c file.c dir.c \
+libllite_a_SOURCES = llite_lib.c llite_fid.c super.c namei.c rw.c file.c dir.c \
lutil.c lutil.h llite_lib.h
# for make rpms -- need cleanup
-liblustre_a_SOURCES = llite_lib.c super.c namei.c rw.c file.c dir.c \
+liblustre_a_SOURCES = llite_lib.c llite_fid.c super.c namei.c rw.c file.c dir.c \
llite_lib.h
liblustre.a : $(LUSTRE_LIBS) $(LND_LIBS) $(LNET_LIBS) $(SYSIO_LIBS) $(QUOTA_LIBS)
struct lustre_handle lockh;
struct mdt_body *body;
struct lookup_intent it = { .it_op = IT_READDIR };
- struct mdc_op_data data;
+ struct mdc_op_data data = { { 0 } };
struct obd_device *obddev = class_exp2obd(sbi->ll_mdc_exp);
struct ldlm_res_id res_id =
- { .name = {st->st_ino, (__u64)lli->lli_st_generation} };
+ { .name = {fid_seq(&lli->lli_fid), fid_num(&lli->lli_fid)} };
ldlm_policy_data_t policy = { .l_inodebits = { MDS_INODELOCK_UPDATE } };
ENTRY;
LASSERT(i1);
ll_i2gids(data->suppgids, i1, i2);
- ll_inode2fid(&data->fid1, i1);
+ data->fid1 = *ll_inode2fid(i1);
if (i2)
- ll_inode2fid(&data->fid2, i2);
- else
- memset(&data->fid2, 0, sizeof(data->fid2));
+ data->fid2 = *ll_inode2fid(i2);
data->name = name;
data->namelen = namelen;
struct ptlrpc_request *req = NULL;
struct obd_client_handle *och = &fd->fd_mds_och;
struct intnl_stat *st = llu_i2stat(inode);
- struct mdc_op_data op_data;
+ struct mdc_op_data op_data = { { 0 } };
int rc;
ENTRY;
--- /dev/null
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * Lustre Light Super operations
+ *
+ * Copyright (c) 2006 Cluster File Systems, Inc.
+ *
+ * This file is part of Lustre, http://www.lustre.org.
+ *
+ * Lustre is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * Lustre is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Lustre; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/queue.h>
+
+#ifdef HAVE_XTIO_H
+#include <xtio.h>
+#endif
+#include <sysio.h>
+#include <fs.h>
+#include <mount.h>
+#include <inode.h>
+#ifdef HAVE_FILE_H
+#include <file.h>
+#endif
+
+/* both sys/queue.h (libsysio require it) and portals/lists.h have definition
+ * of 'LIST_HEAD'. undef it to suppress warnings
+ */
+#undef LIST_HEAD
+#include <lnet/lnetctl.h> /* needed for parse_dump */
+
+#include "lutil.h"
+#include "llite_lib.h"
+#include <linux/lustre_ver.h>
+
+/* allocates passed fid, that is assigns f_num and f_seq to the @fid */
+int llu_fid_md_alloc(struct llu_sb_info *sbi, struct lu_fid *fid)
+{
+ ENTRY;
+
+ if (sbi->ll_fid.f_oid < LUSTRE_FID_SEQ_WIDTH) {
+ sbi->ll_fid.f_oid += 1;
+ *fid = sbi->ll_fid;
+ } else {
+ CERROR("sequence is exhausted. Switching to "
+ "new one is not yet implemented\n");
+ RETURN(-ERANGE);
+ }
+
+ RETURN(0);
+}
+
+/* allocates passed fid, that is assigns f_num and f_seq to the @fid */
+int llu_fid_dt_alloc(struct llu_sb_info *sbi, struct lu_fid *fid)
+{
+ ENTRY;
+ RETURN(-EOPNOTSUPP);
+}
+
+/* build inode number on passed @fid */
+unsigned long llu_fid_build_ino(struct llu_sb_info *sbi, struct lu_fid *fid)
+{
+ unsigned long ino;
+ ENTRY;
+
+ /* very stupid and having many downsides inode allocation algorithm
+ * based on fid. */
+ ino = (fid_seq(fid) - 1) * LUSTRE_FID_SEQ_WIDTH + fid_oid(fid);
+ RETURN(ino);
+}
unsigned long fd_gid;
};
-struct llu_sb_info
-{
+struct llu_sb_info {
struct obd_uuid ll_sb_uuid;
struct obd_export *ll_mdc_exp;
struct obd_export *ll_osc_exp;
struct obd_uuid ll_mds_uuid;
struct obd_uuid ll_mds_peer_uuid;
char *ll_instance;
+
+ struct lu_fid ll_fid;
};
#define LL_SBI_NOLCK 0x1
#define LL_LOOKUP_POSITIVE 1
#define LL_LOOKUP_NEGATIVE 2
-static inline void ll_inode2fid(struct lu_fid *fid, struct inode *inode)
+static inline struct lu_fid *ll_inode2fid(struct inode *inode)
{
- LASSERT(fid != NULL);
- LASSERT(fid != NULL);
- *fid = llu_i2info(inode)->lli_fid;
+ LASSERT(inode != NULL);
+ return &llu_i2info(inode)->lli_fid;
}
struct it_cb_data {
ssize_t llu_iop_filldirentries(struct inode *ino, _SYSIO_OFF_T *basep,
char *buf, size_t nbytes);
+/* liblustre/llite_fid.c*/
+int llu_fid_md_alloc(struct llu_sb_info *sbi, struct lu_fid *fid);
+int llu_fid_dt_alloc(struct llu_sb_info *sbi, struct lu_fid *fid);
+unsigned long llu_fid_build_ino(struct llu_sb_info *sbi, struct lu_fid *fid);
+
/* ext2 related */
#define EXT2_NAME_LEN (255)
if (bits & MDS_INODELOCK_UPDATE)
clear_bit(LLI_F_HAVE_MDS_SIZE_LOCK, &lli->lli_flags);
- if (lock->l_resource->lr_name.name[0] != st->st_ino ||
- lock->l_resource->lr_name.name[1] !=lli->lli_st_generation){
- LDLM_ERROR(lock, "data mismatch with ino %llu/%lu",
- (long long)st->st_ino,lli->lli_st_generation);
+ if (lock->l_resource->lr_name.name[0] != fid_seq(&lli->lli_fid) ||
+ lock->l_resource->lr_name.name[1] != fid_num(&lli->lli_fid)) {
+ LDLM_ERROR(lock, "data mismatch with ino %llu/%llu",
+ (long long)fid_seq(&lli->lli_fid),
+ (long long)fid_num(&lli->lli_fid));
}
if (S_ISDIR(st->st_mode) &&
(bits & MDS_INODELOCK_UPDATE)) {
static int llu_lookup_it(struct inode *parent, struct pnode *pnode,
struct lookup_intent *it, int flags)
{
- struct mdc_op_data op_data;
+ struct mdc_op_data op_data = { { 0 } };
struct it_cb_data icbd;
struct ptlrpc_request *req = NULL;
struct lookup_intent lookup_it = { .it_op = IT_LOOKUP };
icbd.icbd_child = pnode;
icbd.icbd_parent = parent;
+ /* allocate new fid for child */
+ if (it->it_op == IT_OPEN || it->it_op == IT_CREAT) {
+ rc = llu_fid_md_alloc(llu_i2sbi(parent), &op_data.fid2);
+ if (rc) {
+ CERROR("can't allocate new fid, rc %d\n", rc);
+ LBUG();
+ }
+ }
llu_prepare_mdc_op_data(&op_data, parent, NULL,
pnode->p_base->pb_name.name,
pnode->p_base->pb_name.len, flags);
}
}
- if (body->valid & OBD_MD_FLID)
- st->st_ino = body->ino;
if (body->valid & OBD_MD_FLATIME &&
body->mtime > LTIME_S(st->st_mtime))
LTIME_S(st->st_mtime) = body->mtime;
st->st_blocks = body->blocks;
if (body->valid & OBD_MD_FLFLAGS)
lli->lli_st_flags = body->flags;
- if (body->valid & OBD_MD_FLGENER)
- lli->lli_st_generation = body->generation;
-
-#if 0
- /* fillin fid */
- if (body->valid & OBD_MD_FLID)
- lli->lli_fid.id = body->ino;
- if (body->valid & OBD_MD_FLGENER)
- lli->lli_fid.generation = body->generation;
- if (body->valid & OBD_MD_FLTYPE)
- lli->lli_fid.f_type = body->mode & S_IFMT;
-#endif
}
void obdo_to_inode(struct inode *dst, struct obdo *src, obd_flag valid)
st->st_gid = src->o_gid;
if (valid & OBD_MD_FLFLAGS)
lli->lli_st_flags = src->o_flags;
- if (valid & OBD_MD_FLGENER)
- lli->lli_st_generation = src->o_generation;
}
#define S_IRWXUGO (S_IRWXU|S_IRWXG|S_IRWXO)
LASSERT(inode);
obddev = sbi->ll_mdc_exp->exp_obd;
- res_id.name[0] = llu_i2stat(inode)->st_ino;
- res_id.name[1] = lli->lli_st_generation;
+ res_id.name[0] = fid_seq(&lli->lli_fid);
+ res_id.name[1] = fid_num(&lli->lli_fid);
CDEBUG(D_INFO, "trying to match res "LPU64"\n", res_id.name[0]);
struct lustre_md md;
struct ptlrpc_request *req = NULL;
struct llu_sb_info *sbi = llu_i2sbi(inode);
- struct lu_fid fid;
unsigned long valid = OBD_MD_FLGETATTR;
int rc, ealen = 0;
ealen = obd_size_diskmd(sbi->ll_osc_exp, NULL);
valid |= OBD_MD_FLEASIZE;
}
- ll_inode2fid(&fid, inode);
- rc = mdc_getattr(sbi->ll_mdc_exp, &fid, valid, ealen, &req);
+ rc = mdc_getattr(sbi->ll_mdc_exp, ll_inode2fid(inode),
+ valid, ealen, &req);
if (rc) {
CERROR("failure %d inode %llu\n", rc,
(long long)llu_i2stat(inode)->st_ino);
void llu_clear_inode(struct inode *inode)
{
- struct lu_fid fid;
struct llu_inode_info *lli = llu_i2info(inode);
struct llu_sb_info *sbi = llu_i2sbi(inode);
ENTRY;
(long long)llu_i2stat(inode)->st_ino, lli->lli_st_generation,
inode);
- ll_inode2fid(&fid, inode);
clear_bit(LLI_F_HAVE_MDS_SIZE_LOCK, &(lli->lli_flags));
- mdc_change_cbdata(sbi->ll_mdc_exp, &fid, null_if_equal, inode);
+ mdc_change_cbdata(sbi->ll_mdc_exp, ll_inode2fid(inode),
+ null_if_equal, inode);
if (lli->lli_smd)
obd_change_cbdata(sbi->ll_osc_exp, lli->lli_smd,
struct llu_sb_info *sbi = llu_i2sbi(inode);
struct intnl_stat *st = llu_i2stat(inode);
struct ptlrpc_request *request = NULL;
- struct mdc_op_data op_data;
+ struct mdc_op_data op_data = { { 0 } };
int ia_valid = attr->ia_valid;
int rc = 0;
ENTRY;
int len = qstr->len;
struct ptlrpc_request *request = NULL;
struct llu_sb_info *sbi = llu_i2sbi(dir);
- struct mdc_op_data op_data;
+ struct mdc_op_data op_data = { { 0 } };
int err = -EMLINK;
ENTRY;
if (llu_i2stat(dir)->st_nlink >= EXT2_LINK_MAX)
RETURN(err);
+ /* allocate new fid */
+ err = llu_fid_md_alloc(sbi, &op_data.fid2);
+ if (err) {
+ CERROR("can't allocate new fid, rc %d\n", err);
+ RETURN(err);
+ }
llu_prepare_mdc_op_data(&op_data, dir, NULL, name, len, 0);
err = mdc_create(sbi->ll_mdc_exp, &op_data,
tgt, strlen(tgt) + 1, S_IFLNK | S_IRWXUGO,
{
struct llu_inode_info *lli = llu_i2info(inode);
struct llu_sb_info *sbi = llu_i2sbi(inode);
- struct lu_fid fid;
struct mdt_body *body;
struct intnl_stat *st = llu_i2stat(inode);
int rc, symlen = st->st_size + 1;
RETURN(0);
}
- ll_inode2fid(&fid, inode);
- rc = mdc_getattr(sbi->ll_mdc_exp, &fid,
+ rc = mdc_getattr(sbi->ll_mdc_exp, ll_inode2fid(inode),
OBD_MD_LINKNAME, symlen, request);
if (rc) {
CERROR("inode %llu: rc = %d\n", (long long)st->st_ino, rc);
struct ptlrpc_request *request = NULL;
struct inode *dir = pno->p_parent->p_base->pb_ino;
struct llu_sb_info *sbi = llu_i2sbi(dir);
- struct mdc_op_data op_data;
+ struct mdc_op_data op_data = { { 0 } };
int err = -EMLINK;
ENTRY;
case S_IFBLK:
case S_IFIFO:
case S_IFSOCK:
+ /* allocate new fid */
+ err = llu_fid_md_alloc(sbi, &op_data.fid2);
+ if (err) {
+ CERROR("can't allocate new fid, rc %d\n", err);
+ RETURN(err);
+ }
+
llu_prepare_mdc_op_data(&op_data, dir, NULL,
pno->p_base->pb_name.name,
pno->p_base->pb_name.len,
const char *name = new->p_base->pb_name.name;
int namelen = new->p_base->pb_name.len;
struct ptlrpc_request *request = NULL;
- struct mdc_op_data op_data;
+ struct mdc_op_data op_data = { { 0 } };
int rc;
ENTRY;
int len = qstr->len;
struct inode *target = pno->p_base->pb_ino;
struct ptlrpc_request *request = NULL;
- struct mdc_op_data op_data;
+ struct mdc_op_data op_data = { { 0 } };
int rc;
ENTRY;
const char *newname = new->p_base->pb_name.name;
int newnamelen = new->p_base->pb_name.len;
struct ptlrpc_request *request = NULL;
- struct mdc_op_data op_data;
+ struct mdc_op_data op_data = { { 0 } };
int rc;
ENTRY;
int len = qstr->len;
struct ptlrpc_request *request = NULL;
struct intnl_stat *st = llu_i2stat(dir);
- struct mdc_op_data op_data;
+ struct mdc_op_data op_data = { { 0 } };
int err = -EMLINK;
ENTRY;
if (st->st_nlink >= EXT2_LINK_MAX)
RETURN(err);
+ /* allocate new fid */
+ err = llu_fid_md_alloc(llu_i2sbi(dir), &op_data.fid2);
+ if (err) {
+ CERROR("can't allocate new fid, rc %d\n", err);
+ RETURN(err);
+ }
llu_prepare_mdc_op_data(&op_data, dir, NULL, name, len, 0);
err = mdc_create(llu_i2sbi(dir)->ll_mdc_exp, &op_data, NULL, 0, mode,
current->fsuid, current->fsgid, current->cap_effective,
const char *name = qstr->name;
int len = qstr->len;
struct ptlrpc_request *request = NULL;
- struct mdc_op_data op_data;
+ struct mdc_op_data op_data = { { 0 } };
int rc;
ENTRY;
struct llu_inode_info *lli = llu_i2info(ino);
struct intnl_stat *st = llu_i2stat(ino);
struct ldlm_res_id res_id =
- { .name = {st->st_ino,
- lli->lli_st_generation, LDLM_FLOCK} };
+ { .name = {fid_seq(&lli->lli_fid),
+ fid_num(&lli->lli_fid), LDLM_FLOCK} };
struct lustre_handle lockh = {0};
ldlm_policy_data_t flock;
ldlm_mode_t mode = 0;
if (inode) {
struct llu_inode_info *lli = llu_i2info(inode);
- if (inode->i_zombie ||
- lli->lli_st_generation != md->body->generation) {
+ if (inode->i_zombie/* ||
+ lli->lli_st_generation != md->body->generation*/) {
I_RELE(inode);
}
else {
if (err)
GOTO(out_mdc, err);
+ /* initializing ->ll_fid. It is known that root object has separate
+ * sequence, so that we use what MDS returned to us and do not check if
+ * f_oid collides with root or not. */
+ sbi->ll_fid.f_seq = ocd.ocd_seq;
+ sbi->ll_fid.f_oid = LUSTRE_FID_INIT_OID;
+
/*
* FIXME fill fs stat data into sbi here!!! FIXME
*/
static int ll_dir_readpage(struct file *file, struct page *page)
{
struct inode *inode = page->mapping->host;
- struct lu_fid fid;
- __u64 offset;
struct ptlrpc_request *request;
struct mdt_body *body;
+ __u64 offset;
int rc = 0;
ENTRY;
CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p) off "LPU64"\n",
inode->i_ino, inode->i_generation, inode, offset);
- ll_inode2fid(&fid, inode);
-
- rc = mdc_readpage(ll_i2sbi(inode)->ll_mdc_exp, &fid,
+ rc = mdc_readpage(ll_i2sbi(inode)->ll_mdc_exp, ll_inode2fid(inode),
offset, page, &request);
if (!rc) {
body = lustre_msg_buf(request->rq_repmsg, 0, sizeof (*body));
static struct page *ll_get_dir_page(struct inode *dir, unsigned long n)
{
struct ldlm_res_id res_id =
- { .name = { dir->i_ino, (__u64)dir->i_generation} };
+ { .name = { fid_seq(ll_inode2fid(dir)), fid_num(ll_inode2fid(dir)) } };
struct lustre_handle lockh;
struct obd_device *obddev = class_exp2obd(ll_i2sbi(dir)->ll_mdc_exp);
struct address_space *mapping = dir->i_mapping;
*/
case IOC_MDC_LOOKUP: {
struct ptlrpc_request *request = NULL;
- struct lu_fid fid;
+ int namelen, rc, len = 0;
char *buf = NULL;
char *filename;
- int namelen, rc, len = 0;
rc = obd_ioctl_getdata(&buf, &len, (void *)arg);
if (rc)
GOTO(out, rc = -EINVAL);
}
- ll_inode2fid(&fid, inode);
- rc = mdc_getattr_name(sbi->ll_mdc_exp, &fid, filename, namelen,
- OBD_MD_FLID, 0, &request);
+ rc = mdc_getattr_name(sbi->ll_mdc_exp, ll_inode2fid(inode),
+ filename, namelen, OBD_MD_FLID, 0,
+ &request);
if (rc < 0) {
CDEBUG(D_INFO, "mdc_getattr_name: %d\n", rc);
GOTO(out, rc);
struct ptlrpc_request *request = NULL;
struct lov_user_md *lump = (struct lov_user_md *)arg;
struct lov_mds_md *lmm;
- struct lu_fid fid;
struct mdt_body *body;
int rc, lmmsize;
- ll_inode2fid(&fid, inode);
-
rc = ll_get_max_mdsize(sbi, &lmmsize);
if (rc)
RETURN(rc);
- rc = mdc_getattr(sbi->ll_mdc_exp, &fid, OBD_MD_FLDIREA,
- lmmsize, &request);
+ rc = mdc_getattr(sbi->ll_mdc_exp, ll_inode2fid(inode),
+ OBD_MD_FLDIREA, lmmsize, &request);
if (rc < 0) {
CDEBUG(D_INFO, "mdc_getattr failed: rc = %d\n", rc);
RETURN(rc);
case IOC_MDC_GETFILEINFO:
case IOC_MDC_GETSTRIPE: {
struct ptlrpc_request *request = NULL;
- struct lu_fid fid;
- struct mdt_body *body;
struct lov_user_md *lump;
struct lov_mds_md *lmm;
+ struct mdt_body *body;
char *filename;
int rc, lmmsize;
if (IS_ERR(filename))
RETURN(PTR_ERR(filename));
- ll_inode2fid(&fid, inode);
-
rc = ll_get_max_mdsize(sbi, &lmmsize);
if (rc)
RETURN(rc);
- rc = mdc_getattr_name(sbi->ll_mdc_exp, &fid, filename,
- strlen(filename) + 1, OBD_MD_FLEASIZE,
- lmmsize, &request);
+ rc = mdc_getattr_name(sbi->ll_mdc_exp, ll_inode2fid(inode),
+ filename, strlen(filename) + 1,
+ OBD_MD_FLEASIZE, lmmsize, &request);
if (rc < 0) {
CDEBUG(D_INFO, "mdc_getattr_name failed on %s: rc %d\n",
filename, rc);
st.st_atime = body->atime;
st.st_mtime = body->mtime;
st.st_ctime = body->ctime;
- st.st_ino = body->ino;
+ st.st_ino = inode->i_ino;
lmdp = (struct lov_user_mds_data *)arg;
rc = copy_to_user(&lmdp->lmd_st, &st, sizeof(st));
struct inode *inode = dentry->d_inode;
struct ll_inode_info *lli = ll_i2info(inode);
struct lov_stripe_md *lsm = lli->lli_smd;
- struct lu_fid fid;
struct ptlrpc_request *req;
int rc, err;
ENTRY;
rc = err;
}
- ll_inode2fid(&fid, inode);
- err = mdc_sync(ll_i2sbi(inode)->ll_mdc_exp, &fid, &req);
+ err = mdc_sync(ll_i2sbi(inode)->ll_mdc_exp,
+ ll_inode2fid(inode), &req);
if (!rc)
rc = err;
if (!err)
struct ll_sb_info *sbi = ll_i2sbi(inode);
struct obd_device *obddev;
struct ldlm_res_id res_id =
- { .name = {inode->i_ino, inode->i_generation, LDLM_FLOCK} };
+ { .name = { fid_seq(ll_inode2fid(inode)),
+ fid_num(ll_inode2fid(inode)),
+ LDLM_FLOCK} };
struct lustre_handle lockh = {0};
ldlm_policy_data_t flock;
ldlm_mode_t mode = 0;
RETURN(0);
obddev = sbi->ll_mdc_exp->exp_obd;
- res_id.name[0] = de->d_inode->i_ino;
- res_id.name[1] = de->d_inode->i_generation;
+ res_id.name[0] = fid_seq(ll_inode2fid(de->d_inode));
+ res_id.name[1] = fid_num(ll_inode2fid(de->d_inode));
CDEBUG(D_INFO, "trying to match res "LPU64"\n", res_id.name[0]);
if (!ll_have_md_lock(dentry)) {
struct ptlrpc_request *req = NULL;
struct ll_sb_info *sbi = ll_i2sbi(dentry->d_inode);
- struct lu_fid fid;
obd_valid valid = OBD_MD_FLGETATTR;
int ealen = 0;
RETURN(rc);
valid |= OBD_MD_FLEASIZE | OBD_MD_FLMODEASIZE;
}
- ll_inode2fid(&fid, inode);
- rc = mdc_getattr(sbi->ll_mdc_exp, &fid, valid, ealen, &req);
+ rc = mdc_getattr(sbi->ll_mdc_exp, ll_inode2fid(inode),
+ valid, ealen, &req);
if (rc) {
CERROR("failure %d inode %lu\n", rc, inode->i_ino);
RETURN(-abs(rc));
#include "llite_internal.h"
/* allocates passed fid, that is assigns f_num and f_seq to the @fid */
-int ll_fid_alloc(struct ll_sb_info *sbi, struct lu_fid *fid)
+int ll_fid_md_alloc(struct ll_sb_info *sbi, struct lu_fid *fid)
{
ENTRY;
spin_lock(&sbi->ll_fid_lock);
- if (sbi->ll_md_fid.f_oid < LUSTRE_FID_SEQ_WIDTH) {
- sbi->ll_md_fid.f_oid += 1;
- *fid = sbi->ll_md_fid;
+ if (sbi->ll_fid.f_oid < LUSTRE_FID_SEQ_WIDTH) {
+ sbi->ll_fid.f_oid += 1;
+ *fid = sbi->ll_fid;
} else {
CERROR("sequence is exhausted. Switching to "
"new one is not yet implemented\n");
- LBUG();
+ RETURN(-ERANGE);
}
spin_unlock(&sbi->ll_fid_lock);
RETURN(0);
}
+/* allocates passed fid, that is assigns f_num and f_seq to the @fid */
+int ll_fid_dt_alloc(struct ll_sb_info *sbi, struct lu_fid *fid)
+{
+ ENTRY;
+ RETURN(-EOPNOTSUPP);
+}
+
/* build inode number on passed @fid */
ino_t ll_fid_build_ino(struct ll_sb_info *sbi, struct lu_fid *fid)
{
struct inode lli_vfs_inode;
#endif
- /* inode fid */
struct lu_fid lli_fid;
};
/* last allocated fids */
spinlock_t ll_fid_lock;
- struct lu_fid ll_dt_fid;
- struct lu_fid ll_md_fid;
+ struct lu_fid ll_fid;
};
struct ll_ra_read {
return ll_s2mdcexp(inode->i_sb);
}
-static inline void ll_inode2fid(struct lu_fid *fid, struct inode *inode)
+static inline struct lu_fid *ll_inode2fid(struct inode *inode)
{
- LASSERT(fid != NULL);
LASSERT(inode != NULL);
- *fid = ll_i2info(inode)->lli_fid;
+ return &ll_i2info(inode)->lli_fid;
}
static inline int ll_mds_max_easize(struct super_block *sb)
int ll_removexattr(struct dentry *dentry, const char *name);
/* llite/llite_fid.c*/
-int ll_fid_alloc(struct ll_sb_info *sbi, struct lu_fid *fid);
+int ll_fid_md_alloc(struct ll_sb_info *sbi, struct lu_fid *fid);
+int ll_fid_dt_alloc(struct ll_sb_info *sbi, struct lu_fid *fid);
ino_t ll_fid_build_ino(struct ll_sb_info *sbi, struct lu_fid *fid);
#endif /* LLITE_INTERNAL_H */
struct lustre_md md;
struct obd_connect_data *data = NULL;
struct obd_connect_data *md_data = NULL;
- struct obd_connect_data *dt_data = NULL;
int err;
ENTRY;
RETURN(-ENOMEM);
OBD_ALLOC_PTR(md_data);
- if (md_data == NULL)
+ if (md_data == NULL) {
+ OBD_FREE_PTR(data);
RETURN(-ENOMEM);
+ }
- OBD_ALLOC_PTR(dt_data);
- if (dt_data == NULL)
- RETURN(-ENOMEM);
-
if (proc_lustre_fs_root) {
err = lprocfs_register_mountpoint(proc_lustre_fs_root, sb,
osc, mdc);
CERROR("cannot connect to %s: rc = %d\n", osc, err);
GOTO(out_mdc, err);
}
+
sbi->ll_osc_exp = class_conn2export(&osc_conn);
+
spin_lock(&sbi->ll_lco.lco_lock);
sbi->ll_lco.lco_flags = data->ocd_connect_flags;
spin_unlock(&sbi->ll_lco.lco_lock);
mdc_init_ea_size(sbi->ll_mdc_exp, sbi->ll_osc_exp);
- //*dt_data = class_exp2cliimp(sbi->ll_osc_exp)->imp_connect_data;
err = obd_prep_async_page(sbi->ll_osc_exp, NULL, NULL, NULL,
0, NULL, NULL, NULL);
spin_lock_init(&sbi->ll_fid_lock);
- /* initializing @ll_md_fid. It is known that root object has separate
+ /* initializing ->ll_fid. It is known that root object has separate
* sequence, so that we use what MDS returned to us and do not check if
* f_oid collides with root or not. */
- sbi->ll_md_fid.f_seq = md_data->ocd_seq;
- sbi->ll_md_fid.f_oid = LUSTRE_FID_INIT_OID;
-
- /* initializing @ll_dt_fid */
- //sbi->ll_dt_fid.f_seq = dt_data->ocd_seq;
- sbi->ll_dt_fid.f_oid = LUSTRE_FID_INIT_OID;
+ sbi->ll_fid.f_seq = md_data->ocd_seq;
+ sbi->ll_fid.f_oid = LUSTRE_FID_INIT_OID;
sb->s_op = &lustre_super_operations;
}
LASSERT(fid_oid(&sbi->ll_root_fid) != 0);
- /* ino/generation are taken from fid */
- md.body->ino = ll_fid_build_ino(sbi, &sbi->ll_root_fid);
-
root = ll_iget(sb, ll_fid_build_ino(sbi, &sbi->ll_root_fid), &md);
ptlrpc_req_finished(request);
OBD_FREE_PTR(data);
if (md_data != NULL)
OBD_FREE_PTR(md_data);
- if (dt_data != NULL)
- OBD_FREE_PTR(dt_data);
lprocfs_unregister_mountpoint(sbi);
RETURN(err);
}
void ll_clear_inode(struct inode *inode)
{
- struct lu_fid fid;
struct ll_inode_info *lli = ll_i2info(inode);
struct ll_sb_info *sbi = ll_i2sbi(inode);
ENTRY;
CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino,
inode->i_generation, inode);
- ll_inode2fid(&fid, inode);
clear_bit(LLI_F_HAVE_MDS_SIZE_LOCK, &(ll_i2info(inode)->lli_flags));
- mdc_change_cbdata(sbi->ll_mdc_exp, &fid, null_if_equal, inode);
+ mdc_change_cbdata(sbi->ll_mdc_exp, ll_inode2fid(inode),
+ null_if_equal, inode);
if (lli->lli_smd) {
obd_change_cbdata(sbi->ll_osc_exp, lli->lli_smd,
}
#endif
- if (body->valid & OBD_MD_FLID)
- inode->i_ino = body->ino;
if (body->valid & OBD_MD_FLATIME &&
body->atime > LTIME_S(inode->i_atime))
LTIME_S(inode->i_atime) = body->atime;
inode->i_flags = body->flags;
if (body->valid & OBD_MD_FLNLINK)
inode->i_nlink = body->nlink;
- if (body->valid & OBD_MD_FLGENER)
- inode->i_generation = body->generation;
if (body->valid & OBD_MD_FLRDEV)
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
inode->i_rdev = body->rdev;
struct ll_inode_info *lli = ll_i2info(inode);
ENTRY;
- CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino,
- inode->i_generation, inode);
+ CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n",
+ inode->i_ino, inode->i_generation, inode);
ll_lli_init(lli);
switch(cmd) {
case EXT3_IOC_GETFLAGS: {
- struct lu_fid fid;
struct mdt_body *body;
- ll_inode2fid(&fid, inode);
- rc = mdc_getattr(sbi->ll_mdc_exp, &fid, OBD_MD_FLFLAGS,0,&req);
+ rc = mdc_getattr(sbi->ll_mdc_exp, ll_inode2fid(inode),
+ OBD_MD_FLFLAGS, 0, &req);
if (rc) {
CERROR("failure %d inode %lu\n", rc, inode->i_ino);
RETURN(-abs(rc));
LASSERT(sb != NULL);
/* at this point server answers to client's RPC with same fid as
- * client generated for creating some inode. So using
- * md.body.fid1 is okay here. */
+ * client generated for creating some inode. So using ->fid1 is
+ * okay here. */
+ LASSERT(fid_num(&md.body->fid1) != 0);
+
*inode = ll_iget(sb, ll_fid_build_ino(sbi, &md.body->fid1), &md);
if (*inode == NULL || is_bad_inode(*inode)) {
mdc_free_lustre_md(exp, &md);
/* XXX: there is suspection that @datap is 5*4 bytes max long, so that
* 10*4 bytes (two fids + two times mode) does not fit into it. Not sure
* how to fix it though. */
- ll_fid_to_fh(&ll_i2info(child)->lli_fid, (__u32 *)&child->i_mode, datap);
+ ll_fid_to_fh(&ll_i2info(child)->lli_fid,
+ (__u32 *)&child->i_mode, datap);
+
if (*lenp == 5 || S_ISDIR(child->i_mode)) {
*lenp = 5;
return 1;
/* methods */
-/* called from iget{4,5_locked}->find_inode() under inode_lock spinlock */
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
-static int ll_test_inode(struct inode *inode, unsigned long ino, void *opaque)
-#else
-static int ll_test_inode(struct inode *inode, void *opaque)
-#endif
-{
- static int last_ino, last_gen, last_count;
- struct lustre_md *md = opaque;
-
- if (!(md->body->valid & (OBD_MD_FLGENER | OBD_MD_FLID))) {
- CERROR("MDS body missing inum or generation\n");
- return 0;
- }
-
- if (last_ino == md->body->ino && last_gen == md->body->generation &&
- last_count < 500) {
- last_count++;
- } else {
- if (last_count > 1)
- CDEBUG(D_VFSTRACE, "compared %u/%u %u times\n",
- last_ino, last_gen, last_count);
- last_count = 0;
- last_ino = md->body->ino;
- last_gen = md->body->generation;
- CDEBUG(D_VFSTRACE,
- "comparing inode %p ino %lu/%u to body "LPU64"/%u\n",
- inode, inode->i_ino, inode->i_generation,
- md->body->ino, md->body->generation);
- }
-
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
- if (inode->i_ino != md->body->ino)
- return 0;
-#endif
- if (inode->i_generation != md->body->generation) {
- struct ll_sb_info *sbi = ll_i2sbi(inode);
- struct ll_inode_info *lli = ll_i2info(inode);
-
- if (inode->i_state & (I_FREEING | I_CLEAR))
- return 0;
-
- atomic_inc(&inode->i_count);
- inode->i_nlink = 0;
- inode->i_state |= I_FREEING;
- LASSERT(list_empty(&lli->lli_dead_list));
- /* add "duplicate" inode into deathrow for destroy */
- spin_lock(&sbi->ll_deathrow_lock);
- list_add(&lli->lli_dead_list, &sbi->ll_deathrow);
- spin_unlock(&sbi->ll_deathrow_lock);
-
- /* remove inode from dirty/io lists */
- list_del_init(&inode->i_list);
-
- return 0;
- }
-
- /* Apply the attributes in 'opaque' to this inode */
- if (!(inode->i_state & (I_FREEING | I_CLEAR)))
- ll_update_inode(inode, md);
- return 1;
-}
-
extern struct dentry_operations ll_d_ops;
int ll_unlock(__u32 mode, struct lustre_handle *lockh)
struct lustre_md *md)
{
struct inode *inode;
-
LASSERT(hash != 0);
- inode = iget5_locked(sb, hash, ll_test_inode, ll_set_inode, md);
+ inode = iget_locked(sb, hash);
if (inode) {
- if (inode->i_state & I_NEW)
+ if (inode->i_state & I_NEW) {
+ ll_read_inode2(inode, md);
unlock_new_inode(inode);
- CDEBUG(D_VFSTRACE, "inode: %lu/%u(%p)\n", inode->i_ino,
- inode->i_generation, inode);
+ } else {
+ ll_update_inode(inode, md);
+ }
+ CDEBUG(D_VFSTRACE, "inode: %lu/%u(%p)\n",
+ inode->i_ino, inode->i_generation, inode);
}
return inode;
{
struct inode *inode;
LASSERT(hash != 0);
- inode = iget4(sb, hash, ll_test_inode, md);
- if (inode)
- CDEBUG(D_VFSTRACE, "inode: %lu/%u(%p)\n", inode->i_ino,
- inode->i_generation, inode);
+
+ inode = iget4(sb, hash, NULL, md);
+ if (inode) {
+ if (!(inode->i_state & (I_FREEING | I_CLEAR)))
+ ll_update_inode(inode, md);
+
+ CDEBUG(D_VFSTRACE, "inode: %lu/%u(%p)\n",
+ inode->i_ino, inode->i_generation, inode);
+ }
return inode;
}
#endif
if (inode == NULL)
break;
-#ifdef ENABLED_FID
- {
- struct ll_inode_info *lli;
-
- lli = ll_i2info(inode);
-
- /* DLM locks are taken using version component as well,
- * so we use fid_num() instead of fid_oid(). */
- if (lock->l_resource->lr_name.name[0] != fid_seq(&lli->lli_fid) ||
- lock->l_resource->lr_name.name[1] != fid_num(&lli->lli_fid)) {
- LDLM_ERROR(lock, "data mismatch with object "DLID3" (%p)",
- PLID3(&lli->lli_fid), inode);
- }
+ /* DLM locks are taken using version component as well,
+ * so we use fid_num() instead of fid_oid(). */
+ if (lock->l_resource->lr_name.name[0] != fid_seq(ll_inode2fid(inode)) ||
+ lock->l_resource->lr_name.name[1] != fid_num(ll_inode2fid(inode))) {
+ LDLM_ERROR(lock, "data mismatch with object "DFID3" (%p)",
+ PFID3(ll_inode2fid(inode)), inode);
}
-#else
- if (lock->l_resource->lr_name.name[0] != inode->i_ino ||
- lock->l_resource->lr_name.name[1] != inode->i_generation) {
- LDLM_ERROR(lock, "data mismatch with object %lu/%u (%p)",
- inode->i_ino, inode->i_generation, inode);
- }
-#endif
if (bits & MDS_INODELOCK_UPDATE)
clear_bit(LLI_F_HAVE_MDS_SIZE_LOCK,
int flags, void *opaque)
{
struct ldlm_res_id res_id =
- { .name = {inode->i_ino, inode->i_generation} };
+ { .name = {fid_seq(ll_inode2fid(inode)), fid_num(ll_inode2fid(inode))} };
struct obd_device *obddev = class_conn2obd(conn);
ENTRY;
/* allocate new fid for child */
if (it->it_op == IT_OPEN || it->it_op == IT_CREAT) {
- rc = ll_fid_alloc(ll_i2sbi(parent), &op_data.fid2);
+ rc = ll_fid_md_alloc(ll_i2sbi(parent), &op_data.fid2);
if (rc) {
CERROR("can't allocate new fid, rc %d\n", rc);
LBUG();
case S_IFIFO:
case S_IFSOCK:
/* allocate new fid */
- err = ll_fid_alloc(ll_i2sbi(dir), &op_data.fid2);
+ err = ll_fid_md_alloc(ll_i2sbi(dir), &op_data.fid2);
if (err) {
CERROR("can't allocate new fid, rc %d\n", err);
LBUG();
dir, tgt);
/* allocate new fid */
- err = ll_fid_alloc(ll_i2sbi(dir), &op_data.fid2);
+ err = ll_fid_md_alloc(ll_i2sbi(dir), &op_data.fid2);
if (err) {
CERROR("can't allocate new fid, rc %d\n", err);
LBUG();
mode = (mode & (S_IRWXUGO|S_ISVTX) & ~current->fs->umask) | S_IFDIR;
/* allocate new fid */
- err = ll_fid_alloc(ll_i2sbi(dir), &op_data.fid2);
+ err = ll_fid_md_alloc(ll_i2sbi(dir), &op_data.fid2);
if (err) {
CERROR("can't allocate new fid, rc %d\n", err);
LBUG();
{
struct ll_inode_info *lli = ll_i2info(inode);
struct ll_sb_info *sbi = ll_i2sbi(inode);
- struct lu_fid fid;
- struct mdt_body *body;
int rc, symlen = inode->i_size + 1;
+ struct mdt_body *body;
ENTRY;
*request = NULL;
RETURN(0);
}
- ll_inode2fid(&fid, inode);
- rc = mdc_getattr(sbi->ll_mdc_exp, &fid,
+ rc = mdc_getattr(sbi->ll_mdc_exp, ll_inode2fid(inode),
OBD_MD_LINKNAME, symlen, request);
if (rc) {
if (rc != -ENOENT)
{
struct ll_sb_info *sbi = ll_i2sbi(inode);
struct ptlrpc_request *req;
- struct lu_fid fid;
int xattr_type, rc;
ENTRY;
if (rc)
RETURN(rc);
- ll_inode2fid(&fid, inode);
- rc = mdc_setxattr(sbi->ll_mdc_exp, &fid, valid,
+ rc = mdc_setxattr(sbi->ll_mdc_exp, ll_inode2fid(inode), valid,
name, value, size, 0, flags, &req);
if (rc) {
if (rc == -EOPNOTSUPP && xattr_type == XATTR_USER_T) {
struct ll_sb_info *sbi = ll_i2sbi(inode);
struct ptlrpc_request *req = NULL;
struct mdt_body *body;
- struct lu_fid fid;
- void *xdata;
int xattr_type, rc;
+ void *xdata;
ENTRY;
CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n",
RETURN(rc);
do_getxattr:
- ll_inode2fid(&fid, inode);
- rc = mdc_getxattr(sbi->ll_mdc_exp, &fid, valid, name, NULL, 0,
- size, &req);
+ rc = mdc_getxattr(sbi->ll_mdc_exp, ll_inode2fid(inode), valid,
+ name, NULL, 0, size, &req);
if (rc) {
if (rc == -EOPNOTSUPP && xattr_type == XATTR_USER_T) {
LCONSOLE_INFO("Disabling user_xattr feature because "
__swab64s (&b->ctime);
__swab64s (&b->blocks);
__swab64s (&b->io_epoch);
- __swab64s (&b->ino);
__swab32s (&b->fsuid);
__swab32s (&b->fsgid);
__swab32s (&b->capability);
__swab32s (&b->flags);
__swab32s (&b->rdev);
__swab32s (&b->nlink);
- __swab32s (&b->generation);
__swab32s (&b->suppgid);
__swab32s (&b->eadatasize);
__swab32s (&b->aclsize);
__swab32s (&b->max_mdsize);
__swab32s (&b->max_cookiesize);
- __swab32s (&b->padding_4);
}
void lustre_swab_mgs_target_info(struct mgs_target_info *mti)