コード例 #1
0
ファイル: journal.c プロジェクト: alangenfeld/xv6
void
end_trans_man_action()
{
  int i;
  journal_start();
  //  panic("octomom");
  for(i = 0; i < b_index; i++){
    bwrite(bp[i]);
    brelse(bp[i]);
  }
  
  journal_end();
}
コード例 #2
0
ファイル: journal.c プロジェクト: alangenfeld/xv6
int 
j_writei(struct inode *ip, char *src, uint off, uint n)
{
  uint tot, m, i, j;
  struct buf *tbp;

  if(ip->type == T_DEV){
    if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].write)
      return -1;
    return devsw[ip->major].write(ip, src, n);
  }

  if(off + n < off)
    return -1;
  if(off + n > MAXFILE*BSIZE)
    n = MAXFILE*BSIZE - off;

  /* REAL CODE STARTS HERE */
  //  j_init();
  b_index = 0; // new xfer, start keeping track of open bufs

  /* allocate all space needed */
  for(i=0, j=off; i<n; i+=m, j+=m){
    j_bmap(ip, j/BSIZE);
    m = min(n - i, BSIZE - j%BSIZE);
  }

  for(tot=0; tot<n; tot+=m, off+=m, src+=m){
    bp[b_index] = bread(ip->dev, j_lookup(ip, off/BSIZE));
    m = min(n - tot, BSIZE - off%BSIZE);
    memmove(bp[b_index]->data + off%BSIZE, src, m);
    b_index++;
  }

  if(n > 0 && off > ip->size){
    ip->size = off;
    j_iupdate(ip);
  }
  
  journal_start();
  panic("octomom");
  for(i = 0; i < b_index; i++){
    bwrite(bp[i]);
    brelse(bp[i]);
  }
  
  journal_end();
  
  return n;

}
コード例 #3
0
int journal_force_commit(journal_t *journal)
{
	handle_t *handle;
	int ret;

	handle = journal_start(journal, 1);
	if (IS_ERR(handle)) {
		ret = PTR_ERR(handle);
	} else {
		handle->h_sync = 1;
		ret = journal_stop(handle);
	}
	return ret;
}
コード例 #4
0
ファイル: lowerfs_ext3.c プロジェクト: ddn-lixi/mtfs
static handle_t *_mlowerfs_ext3_journal_start_sb(struct super_block *sb, int nblocks)
{
	journal_t *journal;

	if (sb->s_flags & MS_RDONLY)
		return ERR_PTR(-EROFS);

	/* Special case here: if the journal has aborted behind our
	 * backs (eg. EIO in the commit thread), then we still need to
	 * take the FS itself readonly cleanly. */
	journal = EXT3_SB(sb)->s_journal;
	if (is_journal_aborted(journal)) {
		_mlowerfs_ext3_abort(sb, "Detected aborted journal");
		return ERR_PTR(-EROFS);
	}

	return journal_start(journal, nblocks);
}
コード例 #5
0
ファイル: journal.c プロジェクト: maraz/linux-2.6
/* pass it NULL and it will allocate a new handle object for you.  If
 * you pass it a handle however, it may still return error, in which
 * case it has free'd the passed handle for you. */
handle_t *ocfs2_start_trans(struct ocfs2_super *osb, int max_buffs)
{
	journal_t *journal = osb->journal->j_journal;
	handle_t *handle;

	BUG_ON(!osb || !osb->journal->j_journal);

	if (ocfs2_is_hard_readonly(osb))
		return ERR_PTR(-EROFS);

	BUG_ON(osb->journal->j_state == OCFS2_JOURNAL_FREE);
	BUG_ON(max_buffs <= 0);

	/* JBD might support this, but our journalling code doesn't yet. */
	if (journal_current_handle()) {
		mlog(ML_ERROR, "Recursive transaction attempted!\n");
		BUG();
	}

	down_read(&osb->journal->j_trans_barrier);

	handle = journal_start(journal, max_buffs);
	if (IS_ERR(handle)) {
		up_read(&osb->journal->j_trans_barrier);

		mlog_errno(PTR_ERR(handle));

		if (is_journal_aborted(journal)) {
			ocfs2_abort(osb->sb, "Detected aborted journal");
			handle = ERR_PTR(-EROFS);
		}
	} else {
		if (!ocfs2_mount_local(osb))
			atomic_inc(&(osb->journal->j_num_trans));
	}

	return handle;
}
コード例 #6
0
ファイル: ext3.c プロジェクト: kandeshvari/embox
static int ext3fs_create(struct node *parent_node, struct node *node) {
	struct fs_driver *drv;
	struct ext2_fs_info *fsi;
	journal_handle_t *handle;
	int res = -1;

	if(NULL == (drv = fs_driver_find_drv(EXT2_NAME))) {
		return -1;
	}
	fsi = parent_node->nas->fs->fsi;
	/**
	 * ext3_trans_blocks(1) - to modify parent_node's data block
	 * 2 blocks for child = 1 inode + 1 inode bitmap.
	 * 2 * (ext3_trans_blocks(1) + 2) blocks to create "." and ".."
	 */
	if (!(handle = journal_start(fsi->journal, 3 * (ext3_trans_blocks(1) + 2)))) {
		return -1;
	}
	res = drv->fsop->create_node(parent_node, node);
	journal_stop(handle);

	return res;
}
コード例 #7
0
ファイル: ext3.c プロジェクト: kandeshvari/embox
static size_t ext3fs_write(struct file_desc *desc, void *buff, size_t size) {
	struct fs_driver *drv;
	int res;
	size_t datablocks;
	struct ext2_fs_info *fsi;
	journal_handle_t *handle;

	if (NULL == (drv = fs_driver_find_drv(EXT2_NAME))) {
		return -1;
	}

	assert(desc->node);
	fsi = desc->node->nas->fs->fsi;
	/* N * SECTOR_SIZE + K bytes of data can dirty N + 2 only if K >= 2  */
	datablocks = (size + SECTOR_SIZE - 2) / SECTOR_SIZE + 1;
	/* TODO recalculate */
	if (!(handle = journal_start(fsi->journal, 4 * ext3_trans_blocks(datablocks)))) {
		return -1;
	}
	res = drv->file_op->write(desc, buff, size);
	journal_stop(handle);

	return res;
}
コード例 #8
0
ファイル: ext3.c プロジェクト: kandeshvari/embox
static int ext3fs_delete(struct node *node) {
	struct fs_driver *drv;
	struct ext2_fs_info *fsi;
	journal_handle_t *handle;
	int res;

	if(NULL == (drv = fs_driver_find_drv(EXT2_NAME))) {
		return -1;
	}

	fsi = node->nas->fs->fsi;
	/**
	 * Same as in ext3fs_create:
	 * ext3_trans_blocks(1) - to modify parent_node's data block
	 * 2 blocks for child = 1 inode + 1 inode bitmap
	 */
	if (!(handle = journal_start(fsi->journal, ext3_trans_blocks(1) + 2))) {
		return -1;
	}
	res = drv->fsop->delete_node(node);
	journal_stop(handle);

	return res;
}