Example #1
0
File: parser.c Project: GUI/lyaml
static void
parse_MAPPING_START (lyaml_parser *parser)
{
#define EVENTF(_f)	(parser->event.data.mapping_start._f)
   lua_State *L = parser->L;
   const char *style;

   switch (EVENTF (style))
   {
#define MENTRY(_s)		\
      case YAML_##_s##_MAPPING_STYLE: style = #_s; break

        MENTRY( ANY	);
        MENTRY( BLOCK	);
        MENTRY( FLOW	);
#undef MENTRY

      default:
         lua_pushfstring (L, "invalid mapping style %d", EVENTF (style));
         lua_error (L);
   }

   parser_push_eventtable (parser, "MAPPING_START", 4);
   RAWSET_EVENTF (anchor);
   RAWSET_EVENTF (tag);
   RAWSET_BOOLEAN ("implicit", EVENTF (implicit));
   RAWSET_STRING ("style", style);
#undef EVENTF
}
Example #2
0
File: parser.c Project: GUI/lyaml
static void
parse_STREAM_START (lyaml_parser *parser)
{
#define EVENTF(_f)	(parser->event.data.stream_start._f)
   lua_State *L = parser->L;
   const char *encoding;

   switch (EVENTF (encoding))
   {
#define MENTRY(_s)		\
      case YAML_##_s##_ENCODING: encoding = #_s; break

        MENTRY( ANY	);
        MENTRY( UTF8	);
        MENTRY( UTF16LE	);
        MENTRY( UTF16BE	);
#undef MENTRY

      default:
         lua_pushfstring (L, "invalid encoding %d", EVENTF (encoding));
         lua_error (L);
   }

   parser_push_eventtable (parser, "STREAM_START", 1);
   RAWSET_STRING ("encoding", encoding);
#undef EVENTF
}
Example #3
0
File: parser.c Project: GUI/lyaml
/* With the tag list on the top of the stack, append TAG. */
static void
parser_append_tag (lua_State *L, yaml_tag_directive_t tag)
{
   lua_createtable (L, 0, 2);
#define MENTRY(_s)	RAWSET_STRING(#_s, tag._s)
        MENTRY( handle	);
        MENTRY( prefix	);
#undef MENTRY
   lua_rawseti (L, -2, lua_objlen (L, -2) + 1);
}
Example #4
0
File: parser.c Project: GUI/lyaml
/* With the event result table on the top of the stack, insert
   a mark entry. */
static void
parser_set_mark (lua_State *L, const char *k, yaml_mark_t mark)
{
   lua_pushstring  (L, k);
   lua_createtable (L, 0, 3);
#define MENTRY(_s)	RAWSET_INTEGER(#_s, mark._s)
        MENTRY( index	);
        MENTRY( line	);
        MENTRY( column	);
#undef MENTRY
   lua_rawset (L, -3);
}
Example #5
0
File: parser.c Project: GUI/lyaml
/* Push a new event table, pre-populated with shared elements. */
static void
parser_push_eventtable (lyaml_parser *parser, const char *v, int n)
{
   lua_State *L = parser->L;

   lua_createtable (L, 0, n + 3);
   RAWSET_STRING   ("type", v);
#define MENTRY(_s)	parser_set_mark (L, #_s, parser->event._s)
        MENTRY( start_mark	);
        MENTRY( end_mark	);
#undef MENTRY
}
Example #6
0
File: parser.c Project: GUI/lyaml
static int
event_iter (lua_State *L)
{
   lyaml_parser *parser = (lyaml_parser *)lua_touserdata(L, lua_upvalueindex(1));
   char *str;

   parser_delete_event (parser);
   if (yaml_parser_parse (&parser->parser, &parser->event) != 1)
   {
      parser_generate_error_message (parser);
      return lua_error (L);
   }

   parser->validevent = 1;

   lua_newtable    (L);
   lua_pushliteral (L, "type");

   switch (parser->event.type)
   {
      /* First the simple events, generated right here... */
#define MENTRY(_s)		\
      case YAML_##_s##_EVENT: parser_push_eventtable (parser, #_s, 0); break
         MENTRY( STREAM_END	);
         MENTRY( SEQUENCE_END   );
         MENTRY( MAPPING_END	);
#undef MENTRY

      /* ...then the complex events, generated by a function call. */
#define MENTRY(_s)		\
      case YAML_##_s##_EVENT: parse_##_s (parser); break
         MENTRY( STREAM_START	);
         MENTRY( DOCUMENT_START	);
         MENTRY( DOCUMENT_END	);
         MENTRY( ALIAS		);
         MENTRY( SCALAR		);
         MENTRY( SEQUENCE_START	);
         MENTRY( MAPPING_START	);
#undef MENTRY

      case YAML_NO_EVENT:
         lua_pushnil (L);
         break;
      default:
         lua_pushfstring  (L, "invalid event %d", parser->event.type);
         return lua_error (L);
   }

   return 1;
}
Example #7
0
static int __mtrace_proc_dobitmasks(void *data, int write,
                                  loff_t pos, void *buffer, int nob)
{
	const int     tmpstrlen = 512;
	char         *tmpstr;
	int           ret;
	unsigned int *mask = data;
	int           is_ops = (mask == &mtrace_operations) ? 1 : 0;
	int           is_unit = (mask == &mtrace_units) ? 1 : 0;
	const char *(*mask2str)(int bit) = NULL;
	MENTRY();

	MTFS_ALLOC(tmpstr, tmpstrlen);
	if (tmpstr == NULL) {
		MERROR("not enough memory\n");
		ret = -ENOMEM;
		goto out;
	}

	MASSERT(is_ops || is_unit);

	if (is_ops) {
		mask2str = mtrace_ops2str;
	} else {
		mask2str = mtrace_unit2str;
	}

	ret = mtfs_common_proc_dobitmasks(data, write,
	                                  pos, buffer, nob,
	                                  0, tmpstr, tmpstrlen,
	                                  mask2str);
	MTFS_FREE(tmpstr, tmpstrlen);
out:
	MRETURN(ret);
}
Example #8
0
static int mtrace_io_init_rw(struct mtfs_io *io, int is_write,
                             struct file *file, const struct iovec *iov,
                             unsigned long nr_segs, loff_t *ppos, size_t rw_size)
{
	int ret = 0;
	mtfs_io_type_t type;
	struct mtfs_io_rw *io_rw = &io->u.mi_rw;
	MENTRY();

	type = is_write ? MIOT_WRITEV : MIOT_READV;
	io->mi_ops = &mtrace_io_ops[type];
	io->mi_type = type;
	io->mi_oplist_dentry = file->f_dentry;
	io->mi_bindex = 0;
	io->mi_bnum = mtfs_f2bnum(file);
	io->mi_break = 0;
	io->mi_oplist_dentry = file->f_dentry;

	io_rw->file = file;
	io_rw->iov = iov;
	io_rw->nr_segs = nr_segs;
	io_rw->ppos = ppos;
	io_rw->iov_length = sizeof(*iov) * nr_segs;
	io_rw->rw_size = rw_size;

	MRETURN(ret);
}
Example #9
0
static void mtrace_io_iter_start_rw(struct mtfs_io *io)
{
	struct mtfs_io_trace *io_trace = &io->subject.mi_trace;
	struct mtfs_io_rw *io_rw = &io->u.mi_rw;
	struct mrecord_head *head = &io_trace->head;
	struct msubject_trace_info *info = NULL;
	MENTRY();

	info = (struct msubject_trace_info *)mtfs_f2subinfo(io_rw->file);
	if (io->mi_bindex != io->mi_bnum - 1) {
		if ((io->mi_type == MIOT_WRITEV && mtrace_trace_type(TOPS_WRITE)) || 
		    (io->mi_type == MIOT_READV && mtrace_trace_type(TOPS_READ))) {
			do_gettimeofday(&io_trace->start);
		}
		mtfs_io_iter_start_rw_nonoplist(io);
		if ((io->mi_type == MIOT_WRITEV && mtrace_trace_type(TOPS_WRITE)) || 
		    (io->mi_type == MIOT_READV && mtrace_trace_type(TOPS_READ))) {
			do_gettimeofday(&io_trace->end);
		}
	} else {
		/* Trace branch */
		if ((io->mi_type == MIOT_WRITEV && mtrace_trace_type(TOPS_WRITE)) || 
		    (io->mi_type == MIOT_READV && mtrace_trace_type(TOPS_READ))) {
			head->mrh_len = sizeof(*io_trace);
			io_trace->type = io->mi_type;
			io_trace->result = io->mi_result;
			mrecord_add(&info->msti_handle, head);
		}
	}
	_MRETURN();
}
Example #10
0
File: log.c Project: ddn-lixi/mtfs
static int mlog_vfs_destroy(struct mlog_handle *handle)
{
	struct dentry *dentry = NULL;
	struct mlog_ctxt *ctxt = NULL;
	int ret = 0;
	struct vfsmount *mnt = NULL;
	MENTRY();

	dentry = handle->mgh_file->f_dentry;
	mnt = handle->mgh_file->f_vfsmnt;
	ctxt = handle->mgh_ctxt;
	MASSERT(dentry->d_parent == ctxt->moc_dlog);

	mntget(mnt);
	dget(dentry);
	ret = mlog_vfs_close(handle);
	if (ret == 0) {
		mutex_lock(&dentry->d_parent->d_inode->i_mutex);
		ret = vfs_unlink(dentry->d_parent->d_inode, dentry);
		mutex_unlock(&dentry->d_parent->d_inode->i_mutex);
	}
	dput(dentry);
	mntput(mnt);

	MRETURN(ret);
}
Example #11
0
File: log.c Project: ddn-lixi/mtfs
static struct file *mlog_vfs_create_open_new(struct mlog_ctxt *ctxt, struct mlog_logid *logid)
{
	struct dentry *dchild = NULL;
	struct file *file = NULL;
	int ret = 0;
	MENTRY();

	ret = mlog_vfs_create_new(ctxt, logid);
	if (ret) {
		MERROR("failed to create new log, ret = %d\n", ret);
		file = ERR_PTR(ret);
		goto out;
	}

	file = mlog_vfs_open_id(ctxt, logid);
	if (IS_ERR(file)) {
		MERROR("failed to open file, ret = %d\n", PTR_ERR(file));
		goto out_put_dchild;
	}
	goto out;
out_put_dchild:
	dput(dchild);
out:
	MRETURN(file);
}
Example #12
0
File: log.c Project: ddn-lixi/mtfs
static struct file *mlog_vfs_create_open_name(struct mlog_ctxt *ctxt, const char *name)
{
	struct dentry *dchild = NULL;
	struct file *file = NULL;
	MENTRY();

	dchild = mtfs_dchild_create(ctxt->moc_dlog,
				    name, strlen(name),
				    S_IFREG | S_IRWXU, 0, NULL, 0);
	if (IS_ERR(dchild)) {
		MERROR("failed to create [%.*s/%s], ret = %d\n",
		       ctxt->moc_dlog->d_name.len,
		       ctxt->moc_dlog->d_name.name,
		       name, PTR_ERR(dchild));
		file = (struct file *)dchild;
		goto out;
	}

	file = mtfs_dentry_open(dchild,
				mntget(ctxt->moc_mnt),
				O_RDWR | O_CREAT | O_LARGEFILE,
				current_cred()); 
	if (IS_ERR(file)) {
		MERROR("failed to open file\n");
		goto out_put_dchild;
	}

	goto out_free_name;
out_put_dchild:
	dput(dchild);
out_free_name:
	
out:
	MRETURN(file);
}
Example #13
0
File: log.c Project: ddn-lixi/mtfs
int mlog_process(struct mlog_handle *loghandle, mlog_cb_t cb,
                 void *data, void *catdata)
{
	struct mlog_process_info *mpi;
	int                       ret;
	MENTRY();

	MTFS_ALLOC_PTR(mpi);
	if (mpi == NULL) {
		MERROR("cannot alloc pointer\n");
		ret = -ENOMEM;
		goto out;
	}
	mpi->mpi_loghandle = loghandle;
	mpi->mpi_cb        = cb;
	mpi->mpi_cbdata    = data;
	mpi->mpi_catdata   = catdata;

#ifdef __KERNEL__
	init_completion(&mpi->mpi_completion);
	ret = mtfs_create_thread(mlog_process_thread, mpi, CLONE_VM | CLONE_FILES);
	if (ret < 0) {
		MERROR("cannot start thread: %d\n", ret);
		MTFS_FREE_PTR(mpi);
		goto out;
	}
	wait_for_completion(&mpi->mpi_completion);
#else
	mlog_process_thread(mpi);
#endif
	ret = mpi->mpi_ret;
	MTFS_FREE_PTR(mpi);
out:
	MRETURN(ret);
}
Example #14
0
File: log.c Project: ddn-lixi/mtfs
static int mlog_vfs_pad(struct mtfs_lowerfs *lowerfs,
		    struct file *file,
		    int len,
		    int index)
{
	struct mlog_rec_hdr rec = { 0 };
	struct mlog_rec_tail tail;
	int ret = 0;
	MENTRY();

	MASSERT(len >= MLOG_MIN_REC_SIZE && (len & 0x7) == 0);

	tail.mrt_len = rec.mrh_len = len;
	tail.mrt_index = rec.mrh_index = index;
	rec.mrh_type = MLOG_PAD_MAGIC;

	ret = mlowerfs_write_record(lowerfs, file, &rec, sizeof(rec), &file->f_pos, 0);
	if (ret) {
		MERROR("error writing padding record, ret = %d\n", ret);
		goto out;
	}

	file->f_pos += len - sizeof(rec) - sizeof(tail);
	ret = mlowerfs_write_record(lowerfs, file, &tail, sizeof(tail),&file->f_pos, 0);
	if (ret) {
		MERROR("error writing padding record, ret = %d\n", ret);
		goto out;
	}

 out:
	MRETURN(ret);
}
Example #15
0
File: flag.c Project: ddn-lixi/mtfs
int mtfs_branch_valid_flag(struct inode *inode, mtfs_bindex_t bindex, __u32 valid_flags)
{
	int is_valid = 1;
	__u32 mtfs_flag = 0;
	int ret = 0;
	MENTRY();

	if (mtfs_i2branch(inode, bindex) == NULL) {
		is_valid = 0;
		MDEBUG("branch[%d] is null, return invalid\n", bindex);
		goto out;
	}
	
	if (valid_flags == MTFS_BRANCH_VALID) {
		is_valid = 1;
		MDEBUG("branch[%d] is not null, return valid\n", bindex);
		goto out;
	}

	ret = mtfs_branch_getflag(inode, bindex, &mtfs_flag);
	if (ret) {
		MERROR("failed to get branch flag, ret = %d\n", ret);
		is_valid = 0;
		goto out;
	}

	if ((valid_flags & MTFS_DATA_VALID) != 0 &&
	    (mtfs_flag & MTFS_FLAG_DATABAD) != 0) {
		MDEBUG("data of branch[%d] is not valid\n", bindex); 
		is_valid = 0;
	}

out:
	MRETURN(is_valid);
}
Example #16
0
void mtfs_debug_dumplog(void)
{
        wait_queue_t wait;
        struct task_struct *dumper = NULL;
        MENTRY();

        /* we're being careful to ensure that the kernel thread is
         * able to set our state to running as it exits before we
         * get to schedule() */
	init_waitqueue_entry(&wait, current);
	set_current_state(TASK_INTERRUPTIBLE);
        add_wait_queue(&debug_ctlwq, &wait);

        dumper = mtfs_kthread_run(mtfs_debug_dumplog_thread,
                                 (void*)(long)current->pid,
                                 "mtfs_debug_dumper");
        if (IS_ERR(dumper)) {
                printk(KERN_ERR "MTFS Error: cannot start log dump thread:"
                       " %ld\n", PTR_ERR(dumper));
        } else {
                schedule();
	}

        /* be sure to teardown if cfs_create_thread() failed */
        remove_wait_queue(&debug_ctlwq, &wait);
        set_current_state(TASK_RUNNING);
}
Example #17
0
/*
 * Called by iput() when the inode reference count reaches zero
 * and the inode is not hashed anywhere.  Used to clear anything
 * that needs to be, before the inode is completely destroyed and put
 * on the inode free list.
 */
void mtfs_clear_inode(struct inode *inode)
{
	mtfs_bindex_t bindex = 0;
	mtfs_bindex_t bnum = 0;
	struct inode *hidden_inode = NULL;
	struct mtfs_lowerfs *lowerfs = NULL;
	MENTRY();

	for (bindex = 0; bindex < mtfs_i2bnum(inode); bindex++) {
		if (mtfs_i2branch(inode, bindex) == NULL) {
			continue;
		}
		lowerfs = mtfs_i2blowerfs(inode, bindex);
	}
	/*
	 * Decrease a reference to a hidden_inode, which was increased
	 * by our read_inode when inode was inited.
	 */
	bnum = mtfs_i2bnum(inode);
	for (bindex = 0; bindex < bnum; bindex++) {
		hidden_inode = mtfs_i2branch(inode, bindex);
		if (hidden_inode == NULL)
			continue;
		iput(hidden_inode);
	}

	_MRETURN();
}
Example #18
0
static void *mlowerfs_ext3_start(struct inode *inode, int op)
{
	int nblocks = EXT3_SINGLEDATA_TRANS_BLOCKS;
	//journal_t *journal = NULL;
	void *handle = NULL;
	MENTRY();

        if (current->journal_info) {
                goto journal_start;
        }

	/* Increase block number according to operation type */

journal_start:
	MASSERT(nblocks > 0);
	handle = _mlowerfs_ext3_journal_start(inode, nblocks);
	if (!IS_ERR(handle)) {
		MASSERT(current->journal_info == handle);
	} else {
		MERROR("error starting handle for op %u (%u credits): rc %ld\n",
		       op, nblocks, PTR_ERR(handle));
	}

	MRETURN(handle);
}
Example #19
0
static int mlowerfs_ext3_commit_async(struct inode *inode, void *h,
                               void **wait_handle)
{
	unsigned long tid = 0;
	transaction_t *transaction = NULL;
	handle_t *handle = h;
	journal_t *journal = NULL;
	int ret = 0;
	MENTRY();

	MASSERT(current->journal_info == handle);

	transaction = handle->h_transaction;
	journal = transaction->t_journal;
	tid = transaction->t_tid;
	/* we don't want to be blocked */
	handle->h_sync = 0;
	ret = _mlowerfs_ext3_journal_stop(handle);
	if (ret) {
		MERROR("error while stopping transaction: %d\n", ret);
		goto out;
	}
	log_start_commit(journal, tid);

	*wait_handle = (void *) tid;
out:
	MRETURN(ret);
}
Example #20
0
static int mlowerfs_ext3_extend(struct inode *inode, unsigned int nblocks, void *h)
{
	handle_t *handle = h;
	int ret = 0;
	MENTRY();

	/* fsfilt_extend called with nblocks = 0 for testing in special cases */
	if (nblocks == 0) {
		handle->h_buffer_credits = 0;
		MWARN("setting credits of handle %p to zero by request\n", h);
	}

	if (handle->h_buffer_credits > nblocks) {
		ret = 0;
		goto out;
	}

	if (_mlowerfs_ext3_journal_extend(handle, nblocks) == 0) {
		ret = 0;
		goto out;
	}

	MASSERT(inode->i_sb->s_op->dirty_inode);
	inode->i_sb->s_op->dirty_inode(inode);
	ret = _lowerfs_ext3_journal_restart(handle, nblocks);

out:
	MRETURN(ret);
}
Example #21
0
static int __init msync_init(void)
{
	int ret = 0;
	MENTRY();

	MRETURN(ret);
}
Example #22
0
int mtfs_show_options(struct seq_file *m, struct vfsmount *mnt)
{
	MENTRY();

	seq_printf(m, ",only_for_test");

	MRETURN(0);
}
Example #23
0
File: flag.c Project: ddn-lixi/mtfs
int mtfs_branch_invalidate(struct inode *inode, mtfs_bindex_t bindex, __u32 valid_flags)
{
	int ret = 0;
	MENTRY();

	ret = mtfs_branch_invalidate_flag(inode, bindex, valid_flags);
	MRETURN(ret);
}
Example #24
0
File: flag.c Project: ddn-lixi/mtfs
int mtfs_branch_valid(struct inode *inode, mtfs_bindex_t bindex, __u32 valid_flags)
{
	int is_valid = 1;
	MENTRY();

	is_valid = mtfs_branch_valid_flag(inode, bindex, valid_flags);
	MRETURN(is_valid);
}
Example #25
0
void mtfs_destroy_inode(struct inode *inode)
{
	struct mtfs_inode_info *inode_info = mtfs_i2info(inode);
	MENTRY();

	msubject_inode_fini(inode);
	mtfs_ii_free(inode_info);
	_MRETURN();
}
Example #26
0
ssize_t mtrace_file_readv(struct file *file, const struct iovec *iov,
                          unsigned long nr_segs, loff_t *ppos)
{
	ssize_t size = 0;
	MENTRY();

	size = mtrace_file_rw(READ, file, iov, nr_segs, ppos);

	MRETURN(size);
}
Example #27
0
File: log.c Project: ddn-lixi/mtfs
static int mlog_vfs_write_blob(struct mtfs_lowerfs *lowerfs,
			       struct file *file,
			       struct mlog_rec_hdr *rec,
			       void *buf,
			       loff_t off)
{
	int ret = 0;
	struct mlog_rec_tail end;
	loff_t saved_off = file->f_pos;
	int buflen = rec->mrh_len;
	MENTRY();

	file->f_pos = off;

	if (buflen == 0) {
		MWARN("0-length record\n");
	}

	if (!buf) {
		ret = mlowerfs_write_record(lowerfs, file, rec, buflen,&file->f_pos,0);
		if (ret) {
			MERROR("error writing log record, ret = %d\n", ret);
			goto out;
		}
		goto out;
	}

	/* the buf case */
	rec->mrh_len = sizeof(*rec) + buflen + sizeof(end);
	ret = mlowerfs_write_record(lowerfs, file, rec, sizeof(*rec), &file->f_pos, 0);
	if (ret) {
		MERROR("error writing log hdr, ret = %d\n", ret);
		goto out;
	}

	ret = mlowerfs_write_record(lowerfs, file, buf, buflen, &file->f_pos, 0);
	if (ret) {
		MERROR("error writing log buffer, ret = %d\n", ret);
		goto out;
	}

	end.mrt_len = rec->mrh_len;
	end.mrt_index = rec->mrh_index;
	ret = mlowerfs_write_record(lowerfs, file, &end, sizeof(end), &file->f_pos, 0);
	if (ret) {
		MERROR("error writing log tail, ret = %d\n", ret);
		goto out;
	}

 out:
	if (saved_off > file->f_pos)
		file->f_pos = saved_off;
	MASSERT(ret <= 0);
	MRETURN(ret);
}
Example #28
0
File: log.c Project: ddn-lixi/mtfs
static int mlog_vfs_close(struct mlog_handle *handle)
{
	int ret = 0;
	MENTRY();

	ret = filp_close(handle->mgh_file, 0);
	if (ret) {
		MERROR("error closing log, ret = %d\n", ret);
	}
	MRETURN(ret);
}
Example #29
0
File: parser.c Project: GUI/lyaml
static void
parse_DOCUMENT_START (lyaml_parser *parser)
{
#define EVENTF(_f)	(parser->event.data.document_start._f)
   lua_State *L = parser->L;

   /* increment document count */
   parser->document_count++;

   parser_push_eventtable (parser, "DOCUMENT_START", 1);
   RAWSET_BOOLEAN ("implicit", EVENTF (implicit));

   /* version_directive = { major = M, minor = N } */
   if (EVENTF (version_directive))
   {
      lua_pushliteral (L, "version_directive");
      lua_createtable (L, 0, 2);
#define MENTRY(_s)	RAWSET_INTEGER(#_s, EVENTF (version_directive->_s))
        MENTRY( major	);
        MENTRY( minor	);
#undef MENTRY
      lua_rawset (L, -3);
   }

   /* tag_directives = { {handle = H1, prefix = P1}, ... } */
   if (EVENTF (tag_directives.start) &&
       EVENTF (tag_directives.end)) {
      yaml_tag_directive_t *cur;

      lua_pushliteral (L, "tag_directives");
      lua_newtable (L);
      for (cur = EVENTF (tag_directives.start);
           cur != EVENTF (tag_directives.end);
           cur = cur + 1)
      {
         parser_append_tag (L, *cur);
      }
      lua_rawset (L, -3);
   }
#undef EVENTF
}
Example #30
0
int mtrace_super_fini(struct super_block *sb)
{
	int ret = 0;
	struct msubject_trace_info *info = NULL;
	MENTRY();

	info = (struct msubject_trace_info *)mtfs_s2subinfo(sb);
	unregister_sysctl_table(info->msti_ctl_table);
	mrecord_fini(&info->msti_handle);
	MTFS_FREE_PTR(info);
	MRETURN(ret);
}