* GPL HEADER END
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
+ *
+ * Copyright (c) 2011, 2012, Whamcloud, Inc.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
# include <sys/statfs.h>
#endif
-#include <sysio.h>
-#ifdef HAVE_XTIO_H
-#include <xtio.h>
-#endif
-#include <fs.h>
-#include <mount.h>
-#include <inode.h>
-#ifdef HAVE_FILE_H
-#include <file.h>
-#endif
-
#include "llite_lib.h"
#ifndef MAY_EXEC
if (lsm != NULL) {
if (lli->lli_smd == NULL) {
- cl_inode_init(inode, md);
+ cl_file_inode_init(inode, md);
lli->lli_smd = lsm;
lli->lli_maxbytes = lsm->lsm_maxbytes;
- if (lli->lli_maxbytes > PAGE_CACHE_MAXBYTES)
- lli->lli_maxbytes = PAGE_CACHE_MAXBYTES;
+ if (lli->lli_maxbytes > MAX_LFS_FILESIZE)
+ lli->lli_maxbytes = MAX_LFS_FILESIZE;
} else {
if (lov_stripe_md_cmp(lli->lli_smd, lsm)) {
CERROR("lsm mismatch for inode %lld\n",
}
}
- if (body->valid & OBD_MD_FLMTIME &&
- body->mtime > LTIME_S(st->st_mtime))
- LTIME_S(st->st_mtime) = body->mtime;
- if (body->valid & OBD_MD_FLATIME &&
- body->atime > LTIME_S(st->st_atime))
- LTIME_S(st->st_atime) = body->atime;
-
- /* mtime is always updated with ctime, but can be set in past.
- As write and utime(2) may happen within 1 second, and utime's
- mtime has a priority over write's one, so take mtime from mds
- for the same ctimes. */
- if (body->valid & OBD_MD_FLCTIME &&
- body->ctime >= LTIME_S(st->st_ctime)) {
- LTIME_S(st->st_ctime) = body->ctime;
- if (body->valid & OBD_MD_FLMTIME)
+ if (body->valid & OBD_MD_FLATIME) {
+ if (body->atime > LTIME_S(st->st_atime))
+ LTIME_S(st->st_atime) = body->atime;
+ lli->lli_lvb.lvb_atime = body->atime;
+ }
+ if (body->valid & OBD_MD_FLMTIME) {
+ if (body->mtime > LTIME_S(st->st_mtime))
LTIME_S(st->st_mtime) = body->mtime;
+ lli->lli_lvb.lvb_mtime = body->mtime;
+ }
+ if (body->valid & OBD_MD_FLCTIME) {
+ if (body->ctime > LTIME_S(st->st_ctime))
+ LTIME_S(st->st_ctime) = body->ctime;
+ lli->lli_lvb.lvb_ctime = body->ctime;
}
- if (S_ISREG(st->st_mode))
+ if (S_ISREG(st->st_mode))
st->st_blksize = min(2UL * PTLRPC_MAX_BRW_SIZE, LL_MAX_BLKSIZE);
else
st->st_blksize = 4096;
valid &= src->o_valid;
+ LASSERTF(!(valid & (OBD_MD_FLTYPE | OBD_MD_FLGENER | OBD_MD_FLFID |
+ OBD_MD_FLID | OBD_MD_FLGROUP)),
+ "object "LPU64"/"LPU64", valid %x\n",
+ src->o_id, src->o_seq, valid);
+
if (valid & (OBD_MD_FLCTIME | OBD_MD_FLMTIME))
CDEBUG(D_INODE,"valid "LPX64", cur time "CFS_TIME_T"/"CFS_TIME_T
- ", new %lu/%lu\n",
+ ", new %lu/%lu\n",
src->o_valid,
LTIME_S(st->st_mtime), LTIME_S(st->st_ctime),
(long)src->o_mtime, (long)src->o_ctime);
lli->lli_st_flags = src->o_flags;
}
-#define S_IRWXUGO (S_IRWXU|S_IRWXG|S_IRWXO)
-#define S_IALLUGO (S_ISUID|S_ISGID|S_ISVTX|S_IRWXUGO)
-
-void obdo_from_inode(struct obdo *dst, struct inode *src, obd_flag valid)
-{
- struct llu_inode_info *lli = llu_i2info(src);
- struct intnl_stat *st = llu_i2stat(src);
- obd_flag newvalid = 0;
-
- if (valid & (OBD_MD_FLCTIME | OBD_MD_FLMTIME))
- CDEBUG(D_INODE, "valid %x, new time "CFS_TIME_T"/"CFS_TIME_T"\n",
- valid, LTIME_S(st->st_mtime),
- LTIME_S(st->st_ctime));
-
- if (valid & OBD_MD_FLATIME) {
- dst->o_atime = LTIME_S(st->st_atime);
- newvalid |= OBD_MD_FLATIME;
- }
- if (valid & OBD_MD_FLMTIME) {
- dst->o_mtime = LTIME_S(st->st_mtime);
- newvalid |= OBD_MD_FLMTIME;
- }
- if (valid & OBD_MD_FLCTIME) {
- dst->o_ctime = LTIME_S(st->st_ctime);
- newvalid |= OBD_MD_FLCTIME;
- }
- if (valid & OBD_MD_FLSIZE) {
- dst->o_size = st->st_size;
- newvalid |= OBD_MD_FLSIZE;
- }
- if (valid & OBD_MD_FLBLOCKS) { /* allocation of space (x512 bytes) */
- dst->o_blocks = st->st_blocks;
- newvalid |= OBD_MD_FLBLOCKS;
- }
- if (valid & OBD_MD_FLBLKSZ) { /* optimal block size */
- dst->o_blksize = st->st_blksize;
- newvalid |= OBD_MD_FLBLKSZ;
- }
- if (valid & OBD_MD_FLTYPE) {
- dst->o_mode = (dst->o_mode & S_IALLUGO)|(st->st_mode & S_IFMT);
- newvalid |= OBD_MD_FLTYPE;
- }
- if (valid & OBD_MD_FLMODE) {
- dst->o_mode = (dst->o_mode & S_IFMT)|(st->st_mode & S_IALLUGO);
- newvalid |= OBD_MD_FLMODE;
- }
- if (valid & OBD_MD_FLUID) {
- dst->o_uid = st->st_uid;
- newvalid |= OBD_MD_FLUID;
- }
- if (valid & OBD_MD_FLGID) {
- dst->o_gid = st->st_gid;
- newvalid |= OBD_MD_FLGID;
- }
- if (valid & OBD_MD_FLFLAGS) {
- dst->o_flags = lli->lli_st_flags;
- newvalid |= OBD_MD_FLFLAGS;
- }
- if (valid & OBD_MD_FLGENER) {
- dst->o_generation = lli->lli_st_generation;
- newvalid |= OBD_MD_FLGENER;
- }
- if (valid & OBD_MD_FLFID) {
- dst->o_fid = st->st_ino;
- newvalid |= OBD_MD_FLFID;
- }
-
- dst->o_valid |= newvalid;
-}
-
/**
* Performs the getattr on the inode and updates its fields.
* If @sync != 0, perform the getattr under the server-side lock.
oinfo.oi_md = lsm;
oinfo.oi_oa = obdo;
oinfo.oi_oa->o_id = lsm->lsm_object_id;
- oinfo.oi_oa->o_gr = lsm->lsm_object_gr;
+ oinfo.oi_oa->o_seq = lsm->lsm_object_seq;
oinfo.oi_oa->o_mode = S_IFREG;
oinfo.oi_oa->o_ioepoch = ioepoch;
oinfo.oi_oa->o_valid = OBD_MD_FLID | OBD_MD_FLTYPE |
OBD_MD_FLBLKSZ | OBD_MD_FLMTIME |
OBD_MD_FLCTIME | OBD_MD_FLGROUP |
OBD_MD_FLATIME | OBD_MD_FLEPOCH;
+ obdo_set_parent_fid(oinfo.oi_oa, &llu_i2info(inode)->lli_fid);
if (sync) {
oinfo.oi_oa->o_valid |= OBD_MD_FLFLAGS;
oinfo.oi_oa->o_flags |= OBD_FL_SRVLOCK;
OBD_MD_FLSIZE;
obdo_refresh_inode(inode, oinfo.oi_oa, oinfo.oi_oa->o_valid);
- CDEBUG(D_INODE, "objid "LPX64" size %Lu, blocks %Lu, "
- "blksize %Lu\n", lli->lli_smd->lsm_object_id,
+ CDEBUG(D_INODE, "objid "LPX64" size %llu, blocks %llu, "
+ "blksize %llu\n", lli->lli_smd->lsm_object_id,
(long long unsigned)llu_i2stat(inode)->st_size,
(long long unsigned)llu_i2stat(inode)->st_blocks,
(long long unsigned)llu_i2stat(inode)->st_blksize);
static int llu_inode_revalidate(struct inode *inode)
{
- struct lov_stripe_md *lsm = NULL;
+ struct llu_inode_info *lli = llu_i2info(inode);
+ struct intnl_stat *st = llu_i2stat(inode);
ENTRY;
if (!inode) {
struct lustre_md md;
struct ptlrpc_request *req = NULL;
struct llu_sb_info *sbi = llu_i2sbi(inode);
+ struct md_op_data op_data = { { 0 } };
unsigned long valid = OBD_MD_FLGETATTR;
int rc, ealen = 0;
/* Why don't we update all valid MDS fields here, if we're
* doing an RPC anyways? -phil */
- if (S_ISREG(llu_i2stat(inode)->st_mode)) {
+ if (S_ISREG(st->st_mode)) {
ealen = obd_size_diskmd(sbi->ll_dt_exp, NULL);
valid |= OBD_MD_FLEASIZE;
}
- rc = md_getattr(sbi->ll_md_exp, ll_inode2fid(inode),
- NULL, valid, ealen, &req);
+
+ llu_prep_md_op_data(&op_data, inode, NULL, NULL, 0, ealen,
+ LUSTRE_OPC_ANY);
+ op_data.op_valid = valid;
+
+ rc = md_getattr(sbi->ll_md_exp, &op_data, &req);
if (rc) {
CERROR("failure %d inode %llu\n", rc,
- (long long)llu_i2stat(inode)->st_ino);
+ (long long)st->st_ino);
RETURN(-abs(rc));
}
rc = md_get_lustre_md(sbi->ll_md_exp, req,
llu_update_inode(inode, &md);
- if (md.lsm != NULL && llu_i2info(inode)->lli_smd != md.lsm)
+ if (md.lsm != NULL && lli->lli_smd != md.lsm)
obd_free_memmd(sbi->ll_dt_exp, &md.lsm);
ptlrpc_req_finished(req);
}
- lsm = llu_i2info(inode)->lli_smd;
- if (!lsm) /* object not yet allocated, don't validate size */
+ if (!lli->lli_smd) {
+ /* object not yet allocated, don't validate size */
+ st->st_atime = lli->lli_lvb.lvb_atime;
+ st->st_mtime = lli->lli_lvb.lvb_mtime;
+ st->st_ctime = lli->lli_lvb.lvb_ctime;
RETURN(0);
+ }
/* ll_glimpse_size will prefer locally cached writes if they extend
* the file */
attr->ia_mtime = CFS_CURRENT_TIME;
attr->ia_valid |= ATTR_MTIME_SET;
}
- if ((attr->ia_valid & ATTR_CTIME) && !(attr->ia_valid & ATTR_MTIME)) {
- /* To avoid stale mtime on mds, obtain it from ost and send
- to mds. */
- rc = cl_glimpse_size(inode);
- if (rc)
- RETURN(rc);
-
- attr->ia_valid |= ATTR_MTIME_SET | ATTR_MTIME;
- attr->ia_mtime = inode->i_stbuf.st_mtime;
- }
if (attr->ia_valid & (ATTR_MTIME | ATTR_CTIME))
CDEBUG(D_INODE, "setting mtime "CFS_TIME_T", ctime "CFS_TIME_T
inode_setattr(inode, attr);
}
- if (ia_valid & ATTR_SIZE) {
- rc = cl_setattr_do_truncate(inode, attr->ia_size, NULL);
- } else if (ia_valid & (ATTR_MTIME | ATTR_MTIME_SET)) {
- CDEBUG(D_INODE, "set mtime on OST inode %llu to %lu\n",
- (long long unsigned)st->st_ino, LTIME_S(attr->ia_mtime));
- rc = cl_setattr_ost(inode, NULL);
- }
+ if (ia_valid & ATTR_SIZE)
+ attr->ia_valid |= ATTR_SIZE;
+ if (ia_valid & (ATTR_SIZE |
+ ATTR_ATIME | ATTR_ATIME_SET |
+ ATTR_MTIME | ATTR_MTIME_SET))
+ /* on truncate and utimes send attributes to osts, setting
+ * mtime/atime to past will be performed under PW 0:EOF extent
+ * lock (new_size:EOF for truncate)
+ * it may seem excessive to send mtime/atime updates to osts
+ * when not setting times to past, but it is necessary due to
+ * possible time de-synchronization */
+ rc = cl_setattr_ost(inode, attr, NULL);
EXIT;
out:
if (op_data.op_ioepoch)
struct llu_sb_info *sbi = llu_i2sbi(inode);
struct mdt_body *body;
struct intnl_stat *st = llu_i2stat(inode);
+ struct md_op_data op_data = {{ 0 }};
int rc, symlen = st->st_size + 1;
ENTRY;
RETURN(0);
}
- rc = md_getattr(sbi->ll_md_exp, ll_inode2fid(inode), NULL,
- OBD_MD_LINKNAME, symlen, request);
+ llu_prep_md_op_data(&op_data, inode, NULL, NULL, 0, symlen,
+ LUSTRE_OPC_ANY);
+ op_data.op_valid = OBD_MD_LINKNAME;
+
+ rc = md_getattr(sbi->ll_md_exp, &op_data, request);
if (rc) {
CERROR("inode %llu: rc = %d\n", (long long)st->st_ino, rc);
RETURN(rc);
/* For now we will always get up-to-date statfs values, but in the
* future we may allow some amount of caching on the client (e.g.
* from QOS or lprocfs updates). */
- rc = llu_statfs_internal(sbi, &osfs, cfs_time_current_64() - CFS_HZ);
+ rc = llu_statfs_internal(sbi, &osfs,
+ cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS));
if (rc)
return rc;
struct lustre_md md;
class_uuid_t uuid;
struct config_llog_instance cfg = {0, };
- char ll_instance[sizeof(sbi) * 2 + 1];
struct lustre_profile *lprof;
char *zconf_mgsnid, *zconf_profile;
char *osc = NULL, *mdc = NULL;
int async = 1, err = -EINVAL;
struct obd_connect_data ocd = {0,};
+ struct md_op_data op_data = {{0}};
+ /* %p for void* in printf needs 16+2 characters: 0xffffffffffffffff */
+ const int instlen = sizeof(cfg.cfg_instance) * 2 + 2;
ENTRY;
/* generate a string unique to this super, let's try
the address of the super itself.*/
- sprintf(ll_instance, "%p", sbi);
+ cfg.cfg_instance = sbi;
/* retrive & parse config log */
- cfg.cfg_instance = ll_instance;
cfg.cfg_uuid = sbi->ll_sb_uuid;
err = liblustre_process_log(&cfg, zconf_mgsnid, zconf_profile, 1);
if (err < 0) {
CERROR("No profile found: %s\n", zconf_profile);
GOTO(out_free, err = -EINVAL);
}
- OBD_ALLOC(osc, strlen(lprof->lp_dt) + strlen(ll_instance) + 2);
- sprintf(osc, "%s-%s", lprof->lp_dt, ll_instance);
+ OBD_ALLOC(osc, strlen(lprof->lp_dt) + instlen + 2);
+ sprintf(osc, "%s-%p", lprof->lp_dt, cfg.cfg_instance);
- OBD_ALLOC(mdc, strlen(lprof->lp_md) + strlen(ll_instance) + 2);
- sprintf(mdc, "%s-%s", lprof->lp_md, ll_instance);
+ OBD_ALLOC(mdc, strlen(lprof->lp_md) + instlen + 2);
+ sprintf(mdc, "%s-%p", lprof->lp_md, cfg.cfg_instance);
if (!osc) {
CERROR("no osc\n");
ocd.ocd_connect_flags = OBD_CONNECT_IBITS | OBD_CONNECT_VERSION |
OBD_CONNECT_FID | OBD_CONNECT_AT |
- OBD_CONNECT_VBR | OBD_CONNECT_SOM;
+ OBD_CONNECT_VBR | OBD_CONNECT_FULL20;
+
#ifdef LIBLUSTRE_POSIX_ACL
ocd.ocd_connect_flags |= OBD_CONNECT_ACL;
#endif
ocd.ocd_connect_flags = OBD_CONNECT_SRVLOCK | OBD_CONNECT_REQPORTAL |
OBD_CONNECT_VERSION | OBD_CONNECT_TRUNCLOCK |
OBD_CONNECT_FID | OBD_CONNECT_AT |
- OBD_CONNECT_SOM;
+ OBD_CONNECT_FULL20 | OBD_CONNECT_EINPROGRESS;
ocd.ocd_version = LUSTRE_VERSION_CODE;
err = obd_connect(NULL, &sbi->ll_dt_exp, obd, &sbi->ll_sb_uuid, &ocd, NULL);
}
CDEBUG(D_SUPER, "rootfid "DFID"\n", PFID(&sbi->ll_root_fid));
+ op_data.op_fid1 = sbi->ll_root_fid;
+ op_data.op_valid = OBD_MD_FLGETATTR | OBD_MD_FLBLOCKS;
/* fetch attr of root inode */
- err = md_getattr(sbi->ll_md_exp, &sbi->ll_root_fid, NULL,
- OBD_MD_FLGETATTR | OBD_MD_FLBLOCKS, 0, &request);
+ err = md_getattr(sbi->ll_md_exp, &op_data, &request);
if (err) {
CERROR("md_getattr failed for root: rc = %d\n", err);
GOTO(out_lock_cn_cb, err);
ptlrpc_req_finished(request);
CDEBUG(D_SUPER, "LibLustre: %s mounted successfully!\n", source);
- liblustre_wait_idle();
-
- return 0;
+ err = 0;
+ goto out_free;
out_inode:
_sysio_i_gone(root);
obd_disconnect(sbi->ll_md_exp);
out_free:
if (osc)
- OBD_FREE(osc, strlen(osc) + 1);
+ OBD_FREE(osc, strlen(lprof->lp_dt) + instlen + 2);
if (mdc)
- OBD_FREE(mdc, strlen(mdc) + 1);
+ OBD_FREE(mdc, strlen(lprof->lp_md) + instlen + 2);
OBD_FREE(sbi, sizeof(*sbi));
liblustre_wait_idle();
return err;