Includes fix for type == 0 (truncate) problem.
Removes ost_get_info call - it is not used and causes confusion.
int ll_direct_IO(int rw, struct inode *inode, struct kiobuf *iobuf,
unsigned long blocknr, int blocksize)
{
- int i;
obd_count num_obdo = 1;
obd_count bufs_per_obdo = iobuf->nr_pages;
- struct obdo *oa = NULL;
+ struct obdo *oa = NULL;
obd_size *count = NULL;
obd_off *offset = NULL;
obd_flag *flags = NULL;
int rc = 0;
+ int i;
ENTRY;
spin_unlock(&pagecache_lock);
- OBD_ALLOC(count, sizeof(obd_size) * bufs_per_obdo);
- if (!count)
- GOTO(out, err=-ENOMEM);
-
- OBD_ALLOC(offset, sizeof(obd_off) * bufs_per_obdo);
- if (!offset)
- GOTO(out, err=-ENOMEM);
-
- OBD_ALLOC(flags, sizeof(obd_flag) * bufs_per_obdo);
- if (!flags)
- GOTO(out, err=-ENOMEM);
+ OBD_ALLOC(count, sizeof(*count) * bufs_per_obdo);
+ OBD_ALLOC(offset, sizeof(*offset) * bufs_per_obdo);
+ OBD_ALLOC(flags, sizeof(*flags) * bufs_per_obdo);
+ if (!count || !offset || !flags)
+ GOTO(out, err=-ENOMEM);
#if 0
for (i = 0 ; i < bufs_per_obdo ; i++) {
#endif
out:
obdo_free(oa);
- OBD_FREE(flags, sizeof(obd_flag) * bufs_per_obdo);
- OBD_FREE(count, sizeof(obd_count) * bufs_per_obdo);
- OBD_FREE(offset, sizeof(obd_off) * bufs_per_obdo);
+ OBD_FREE(flags, sizeof(*flags) * bufs_per_obdo);
+ OBD_FREE(count, sizeof(*count) * bufs_per_obdo);
+ OBD_FREE(offset, sizeof(*offset) * bufs_per_obdo);
RETURN(err);
}
EXIT;
}
+#ifndef log2
+#define log2(n) ffz(~(n))
+#endif
+
static struct super_block * ll_read_super(struct super_block *sb,
void *data, int silent)
{
int devno;
int err;
struct ll_fid rootfid;
+ struct statfs sfs;
__u64 last_committed, last_rcvd;
__u32 last_xid;
struct ptlrpc_request *request = NULL;
CERROR("cannot mds_connect: rc = %d\n", err);
GOTO(out_disc, sb = NULL);
}
- CDEBUG(D_SUPER, "rootfid %ld\n", (unsigned long)rootfid.id);
+ CDEBUG(D_SUPER, "rootfid %Ld\n", (unsigned long long)rootfid.id);
sbi->ll_rootino = rootfid.id;
- sb->s_maxbytes = 1ULL << 36;
- /* XXX get this with a get_info call (like we have in OBDFS),
- this info call should return the blocksize of the MDS (statfs?) */
- sb->s_blocksize = 4096;
- sb->s_blocksize_bits = 12;
+ memset(&sfs, 0, sizeof(sfs));
+ err = mdc_statfs(&sbi->ll_mdc_conn, &sfs, &request);
+ sb->s_blocksize = sfs.f_bsize;
+ sb->s_blocksize_bits = log2(sfs.f_bsize);
sb->s_magic = LL_SUPER_MAGIC;
+ sb->s_maxbytes = (1ULL << (32 + 9)) - sfs.f_bsize;
+
sb->s_op = &ll_super_operations;
/* make root inode */
static int ll_statfs(struct super_block *sb, struct statfs *sfs)
{
struct ptlrpc_request *request = NULL;
+ struct statfs obd_sfs;
struct ll_sb_info *sbi = ll_s2sbi(sb);
- int err;
+ int rc;
ENTRY;
memset(sfs, 0, sizeof(*sfs));
- err = mdc_statfs(&sbi->ll_mdc_conn, sfs, &request);
- if (err)
- CERROR("obd_statfs fails (%d)\n", err);
- else
- CDEBUG(D_SUPER,
- "statfs returns blocks %ld/%ld objects %ld/%ld\n",
- sfs->f_bavail, sfs->f_blocks, sfs->f_files,sfs->f_ffree);
-
+ rc = mdc_statfs(&sbi->ll_mdc_conn, sfs, &request);
ptlrpc_req_finished(request);
+ if (rc) {
+ CERROR("obd_statfs fails: rc = %d\n", rc);
+ GOTO(out, rc);
+ }
+ CDEBUG(D_SUPER, "statfs returns blocks %ld/%ld objects %ld/%ld\n",
+ sfs->f_bavail, sfs->f_blocks, sfs->f_files,sfs->f_ffree);
+
+ /* temporary until mds_statfs returns statfs info for all OSTs */
+ rc = obd_statfs(&sbi->ll_osc_conn, &obd_sfs);
+ if (rc) {
+ CERROR("obd_statfs fails: rc = %d\n", rc);
+ GOTO(out, rc);
+ }
+ CDEBUG(D_SUPER, "obd_statfs returns blocks %ld/%ld\n",
+ obd_sfs.f_bavail, obd_sfs.f_blocks);
- RETURN(err);
+ sfs->f_bfree = obd_sfs.f_bfree;
+ sfs->f_bavail = obd_sfs.f_bavail;
+ sfs->f_blocks = obd_sfs.f_blocks;
+
+out:
+ RETURN(rc);
}
static void ll_to_inode(struct inode *dst, struct ll_inode_md *md)
}
osfs = lustre_msg_buf(req->rq_repmsg, 0);
memset(osfs, 0, size);
- /* FIXME: hack until the MDS gets the OST data, next month */
- sfs.f_blocks = -1;
- sfs.f_bfree = -1;
- sfs.f_bavail = -1;
obd_statfs_pack(osfs, &sfs);
out:
int rc;
ENTRY;
- dentry = filter_fid2dentry(obd, filter_parent(obd, oa->o_mode),
- oa->o_id, oa->o_mode);
+ iattr_from_obdo(&iattr, oa);
+ iattr.ia_mode = (iattr.ia_mode & ~S_IFMT) | S_IFREG;
+ dentry = filter_fid2dentry(obd, filter_parent(obd, iattr.ia_mode),
+ oa->o_id, iattr.ia_mode);
if (IS_ERR(dentry))
RETURN(PTR_ERR(dentry));
inode = dentry->d_inode;
- iattr_from_obdo(&iattr, oa);
- iattr.ia_mode &= ~S_IFMT;
- iattr.ia_mode |= S_IFREG;
lock_kernel();
if (iattr.ia_mode & ATTR_SIZE)
down(&inode->i_sem);
static int filter_destroy(struct lustre_handle *conn, struct obdo *oa)
{
- struct obd_run_ctxt saved;
struct obd_device *obd;
+ struct filter_obd *filter;
+ struct obd_run_ctxt saved;
struct obd_export *export;
struct inode *inode;
struct dentry *dir_dentry, *object_dentry;
RETURN(-EINVAL);
}
- CDEBUG(D_INODE, "destroying object %Ld\n",oa->o_id);
+ CDEBUG(D_INODE, "destroying object %Ld\n", oa->o_id);
obd = class_conn2obd(conn);
dir_dentry = filter_parent(obd, oa->o_mode);
inode = object_dentry->d_inode;
if (inode->i_nlink != 1) {
CERROR("destroying inode with nlink = %d\n", inode->i_nlink);
+ LBUG();
inode->i_nlink = 1;
}
inode->i_mode = S_IFREG;
- push_ctxt(&saved, &obd->u.filter.fo_ctxt);
+ filter = &obd->u.filter;
+ push_ctxt(&saved, &filter->fo_ctxt);
rc = vfs_unlink(dir_dentry->d_inode, object_dentry);
pop_ctxt(&saved);
RETURN(0);
}
-static int filter_statfs(struct lustre_handle *conn, struct statfs * statfs)
+static int filter_statfs(struct lustre_handle *conn, struct statfs *statfs)
{
- struct super_block *sb;
- int err;
- ENTRY;
-
- if (!class_conn2export(conn)) {
- CDEBUG(D_IOCTL, "invalid client %Lx\n", conn->addr);
- RETURN(-EINVAL);
- }
-
- sb = class_conn2obd(conn)->u.filter.fo_sb;
-
- err = sb->s_op->statfs(sb, statfs);
- RETURN(err);
-} /* filter_statfs */
+ struct obd_device *obd = class_conn2obd(conn);
+ ENTRY;
+ RETURN(vfs_statfs(obd->u.filter.fo_sb, statfs));
+}
static int filter_get_info(struct lustre_handle *conn, obd_count keylen,
void *key, obd_count *vallen, void **val)
if ( keylen == strlen("root_ino") &&
memcmp(key, "root_ino", keylen) == 0 ){
- *vallen = sizeof(long);
- *val = (void *)(long)FILTER_ROOTINO;
+ *vallen = sizeof(obd_id);
+ *val = (void *)(obd_id)FILTER_ROOTINO;
RETURN(0);
}
modulefs_DATA = osc.o
EXTRA_PROGRAMS = osc
-LINX= obd_pack.c
+LINX= obd_pack.c ll_pack.c
osc_SOURCES = obd_pack.c osc_request.c # super.c rw.c file.c dir.c sysctl.c super.c namei.c symlink.c
obd_pack.c:
test -e obd_pack.c || ln -sf $(top_srcdir)/lib/obd_pack.c
+ll_pack.c:
+ test -e ll_pack.c || ln -sf $(top_srcdir)/lib/ll_pack.c
+
dist-hook:
list='$(LINX)'; for f in $$list; do rm -f $(distdir)/$$f; done
EXIT;
out:
ptlrpc_free_req(request);
- return 0;
+ return rc;
}
static int osc_open(struct lustre_handle *conn, struct obdo *oa)
EXIT;
out:
ptlrpc_free_req(request);
- return 0;
+ return rc;
}
static int osc_setattr(struct lustre_handle *conn, struct obdo *oa)
out:
ptlrpc_free_req(request);
- return 0;
+ return rc;
}
static int osc_create(struct lustre_handle *conn, struct obdo *oa)
EXIT;
out:
ptlrpc_free_req(request);
- return 0;
+ return rc;
}
static int osc_punch(struct lustre_handle *conn, struct obdo *oa, obd_size count,
EXIT;
out:
ptlrpc_free_req(request);
- return 0;
+ return rc;
}
static int osc_destroy(struct lustre_handle *conn, struct obdo *oa)
EXIT;
out:
ptlrpc_free_req(request);
- return 0;
+ return rc;
}
struct osc_brw_cb_data {
return 0;
}
-#if 0
-static int osc_statfs(struct lustre_handle *conn, struct statfs *sfs);
+static int osc_statfs(struct lustre_handle *conn, struct statfs *sfs)
{
struct ptlrpc_request *request;
struct ptlrpc_client *cl;
rc = ptlrpc_queue_wait(request);
rc = ptlrpc_check_status(request, rc);
- if (rc)
+ if (rc) {
+ CERROR("%s failed: rc = %d\n", __FUNCTION__, rc);
GOTO(out, rc);
+ }
osfs = lustre_msg_buf(request->rq_repmsg, 0);
- obd_statfs_unpack(sfs, osfs);
+ obd_statfs_unpack(osfs, sfs);
EXIT;
out:
ptlrpc_free_req(request);
- return 0;
+ return rc;
}
-#endif
struct obd_ops osc_obd_ops = {
- o_setup: osc_setup,
- o_cleanup: osc_cleanup,
- o_create: osc_create,
- o_destroy: osc_destroy,
- o_getattr: osc_getattr,
- o_setattr: osc_setattr,
- o_open: osc_open,
- o_close: osc_close,
- o_connect: osc_connect,
- o_disconnect: osc_disconnect,
- o_brw: osc_brw,
- o_punch: osc_punch,
- o_enqueue: osc_enqueue,
- o_cancel: osc_cancel
+ o_setup: osc_setup,
+ o_cleanup: osc_cleanup,
+ o_statfs: osc_statfs,
+ o_create: osc_create,
+ o_destroy: osc_destroy,
+ o_getattr: osc_getattr,
+ o_setattr: osc_setattr,
+ o_open: osc_open,
+ o_close: osc_close,
+ o_connect: osc_connect,
+ o_disconnect: osc_disconnect,
+ o_brw: osc_brw,
+ o_punch: osc_punch,
+ o_enqueue: osc_enqueue,
+ o_cancel: osc_cancel
};
static int __init osc_init(void)
modulefs_DATA = ost.o
EXTRA_PROGRAMS = ost
-LINX=page.c obd_pack.c l_net.c
+LINX=page.c obd_pack.c l_net.c ll_pack.c
+ll_pack.c:
+ test -e ll_pack.c || ln -sf $(top_srcdir)/lib/ll_pack.c
+
obd_pack.c:
test -e obd_pack.c || ln -sf $(top_srcdir)/lib/obd_pack.c
RETURN(0);
}
+static int ost_statfs(struct ptlrpc_request *req)
+{
+ struct lustre_handle *conn = (struct lustre_handle *)req->rq_reqmsg;
+ struct obd_statfs *osfs;
+ struct statfs sfs;
+ int rc, size = sizeof(*osfs);
+ ENTRY;
+
+ rc = lustre_pack_msg(1, &size, NULL, &req->rq_replen, &req->rq_repmsg);
+ if (rc)
+ RETURN(rc);
+
+ rc = obd_statfs(conn, &sfs);
+ if (rc) {
+ CERROR("ost: statfs failed: rc %d\n", rc);
+ GOTO(out, rc);
+ }
+ osfs = lustre_msg_buf(req->rq_repmsg, 0);
+ memset(osfs, 0, size);
+ obd_statfs_pack(osfs, &sfs);
+out:
+ req->rq_status = rc;
+ RETURN(0);
+}
+
static int ost_open(struct ptlrpc_request *req)
{
struct lustre_handle *conn = (struct lustre_handle *)req->rq_reqmsg;
RETURN(0);
}
-static int ost_get_info(struct ptlrpc_request *req)
-{
- struct lustre_handle *conn = (struct lustre_handle *)req->rq_reqmsg;
- struct ost_body *body;
- int rc, size[2] = {sizeof(*body)};
- char *bufs[2] = {NULL, NULL}, *ptr;
- ENTRY;
-
- body = lustre_msg_buf(req->rq_reqmsg, 0);
-
- ptr = lustre_msg_buf(req->rq_reqmsg, 1);
- if (!ptr)
- RETURN(-EINVAL);
-
- req->rq_status = obd_get_info(conn, req->rq_reqmsg->buflens[1], ptr,
- &(size[1]), (void **)&(bufs[1]));
-
- rc = lustre_pack_msg(2, size, bufs, &req->rq_replen, &req->rq_repmsg);
- if (rc)
- CERROR("cannot pack reply\n");
-
- RETURN(rc);
-}
-
static int ost_brw_read(struct ptlrpc_request *req)
{
struct lustre_handle *conn = (struct lustre_handle *)req->rq_reqmsg;
OBD_FAIL_RETURN(OBD_FAIL_OST_PUNCH_NET, 0);
rc = ost_punch(req);
break;
-#if 0
case OST_STATFS:
CDEBUG(D_INODE, "statfs\n");
OBD_FAIL_RETURN(OBD_FAIL_OST_STATFS_NET, 0);
rc = ost_statfs(req);
break;
-#endif
default:
req->rq_status = -ENOTSUPP;
rc = ptlrpc_error(req->rq_svc, req);