您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ EXT4_I函数代码示例

51自学网 2021-06-01 20:36:27
  C++
这篇教程C++ EXT4_I函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中EXT4_I函数的典型用法代码示例。如果您正苦于以下问题:C++ EXT4_I函数的具体用法?C++ EXT4_I怎么用?C++ EXT4_I使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了EXT4_I函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: EXT4_I

/** * ext4_get_crypto_ctx() - Gets an encryption context * @inode:       The inode for which we are doing the crypto * * Allocates and initializes an encryption context. * * Return: An allocated and initialized encryption context on success; error * value or NULL otherwise. */struct ext4_crypto_ctx *ext4_get_crypto_ctx(struct inode *inode){	struct ext4_crypto_ctx *ctx = NULL;	int res = 0;	unsigned long flags;	struct ext4_crypt_info *ci = EXT4_I(inode)->i_crypt_info;	if (ci == NULL)		return ERR_PTR(-ENOKEY);	/*	 * We first try getting the ctx from a free list because in	 * the common case the ctx will have an allocated and	 * initialized crypto tfm, so it's probably a worthwhile	 * optimization. For the bounce page, we first try getting it	 * from the kernel allocator because that's just about as fast	 * as getting it from a list and because a cache of free pages	 * should generally be a "last resort" option for a filesystem	 * to be able to do its job.	 */	spin_lock_irqsave(&ext4_crypto_ctx_lock, flags);	ctx = list_first_entry_or_null(&ext4_free_crypto_ctxs,				       struct ext4_crypto_ctx, free_list);	if (ctx)		list_del(&ctx->free_list);	spin_unlock_irqrestore(&ext4_crypto_ctx_lock, flags);	if (!ctx) {		ctx = kmem_cache_zalloc(ext4_crypto_ctx_cachep, GFP_NOFS);		if (!ctx) {			res = -ENOMEM;			goto out;		}		ctx->flags |= EXT4_CTX_REQUIRES_FREE_ENCRYPT_FL;	} else {		ctx->flags &= ~EXT4_CTX_REQUIRES_FREE_ENCRYPT_FL;	}	ctx->flags &= ~EXT4_WRITE_PATH_FL;out:	if (res) {		if (!IS_ERR_OR_NULL(ctx))			ext4_release_crypto_ctx(ctx);		ctx = ERR_PTR(res);	}	return ctx;}
开发者ID:jiaming77,项目名称:DORIMANX_LG_STOCK_LP_KERNEL,代码行数:55,


示例2: ext4_sync_file

int ext4_sync_file(struct file *file, struct dentry *dentry, int datasync){	struct inode *inode = dentry->d_inode;	struct ext4_inode_info *ei = EXT4_I(inode);	journal_t *journal = EXT4_SB(inode->i_sb)->s_journal;	int ret;	tid_t commit_tid;	J_ASSERT(ext4_journal_current_handle() == NULL);	trace_ext4_sync_file(file, dentry, datasync);	if (inode->i_sb->s_flags & MS_RDONLY)		return 0;	ret = flush_aio_dio_completed_IO(inode);	if (ret < 0)		return ret;		if (!journal)		return simple_fsync(file, dentry, datasync);	/*	 * data=writeback,ordered:	 *  The caller's filemap_fdatawrite()/wait will sync the data.	 *  Metadata is in the journal, we wait for proper transaction to	 *  commit here.	 *	 * data=journal:	 *  filemap_fdatawrite won't do anything (the buffers are clean).	 *  ext4_force_commit will write the file data into the journal and	 *  will wait on that.	 *  filemap_fdatawait() will encounter a ton of newly-dirtied pages	 *  (they were dirtied by commit).  But that's OK - the blocks are	 *  safe in-journal, which is all fsync() needs to ensure.	 */	if (ext4_should_journal_data(inode))		return ext4_force_commit(inode->i_sb);	commit_tid = datasync ? ei->i_datasync_tid : ei->i_sync_tid;	if (jbd2_log_start_commit(journal, commit_tid))		jbd2_log_wait_commit(journal, commit_tid);	else if (journal->j_flags & JBD2_BARRIER)		blkdev_issue_flush(inode->i_sb->s_bdev, NULL);	return ret;}
开发者ID:Aircell,项目名称:asp-kernel,代码行数:46,


示例3: ext4_free_io_end

void ext4_free_io_end(ext4_io_end_t *io){	int i;	wait_queue_head_t *wq;	BUG_ON(!io);	if (io->page)		put_page(io->page);	for (i = 0; i < io->num_io_pages; i++)		put_io_page(io->pages[i]);	io->num_io_pages = 0;	wq = to_ioend_wq(io->inode);	if (atomic_dec_and_test(&EXT4_I(io->inode)->i_ioend_count) &&	    waitqueue_active(wq))		wake_up_all(wq);	kmem_cache_free(io_end_cachep, io);}
开发者ID:BackupTheBerlios,项目名称:gemini-board,代码行数:17,


示例4: ext4_finish_convert_inline_dir

static int ext4_finish_convert_inline_dir(handle_t *handle,					  struct inode *inode,					  struct buffer_head *dir_block,					  void *buf,					  int inline_size){	int err, csum_size = 0, header_size = 0;	struct ext4_dir_entry_2 *de;	struct ext4_dir_entry_tail *t;	void *target = dir_block->b_data;	/*	 * First create "." and ".." and then copy the dir information	 * back to the block.	 */	de = (struct ext4_dir_entry_2 *)target;	de = ext4_init_dot_dotdot(inode, de,		inode->i_sb->s_blocksize, csum_size,		le32_to_cpu(((struct ext4_dir_entry_2 *)buf)->inode), 1);	header_size = (void *)de - target;	memcpy((void *)de, buf + EXT4_INLINE_DOTDOT_SIZE,		inline_size - EXT4_INLINE_DOTDOT_SIZE);	if (ext4_has_metadata_csum(inode->i_sb))		csum_size = sizeof(struct ext4_dir_entry_tail);	inode->i_size = inode->i_sb->s_blocksize;	i_size_write(inode, inode->i_sb->s_blocksize);	EXT4_I(inode)->i_disksize = inode->i_sb->s_blocksize;	ext4_update_final_de(dir_block->b_data,			inline_size - EXT4_INLINE_DOTDOT_SIZE + header_size,			inode->i_sb->s_blocksize - csum_size);	if (csum_size) {		t = EXT4_DIRENT_TAIL(dir_block->b_data,				     inode->i_sb->s_blocksize);		initialize_dirent_tail(t, inode->i_sb->s_blocksize);	}	set_buffer_uptodate(dir_block);	err = ext4_handle_dirty_dirent_node(handle, inode, dir_block);	if (err)		return err;	set_buffer_verified(dir_block);	return ext4_mark_inode_dirty(handle, inode);}
开发者ID:asmalldev,项目名称:linux,代码行数:46,


示例5: ext4_d_revalidate

/* * Validate dentries for encrypted directories to make sure we aren't * potentially caching stale data after a key has been added or * removed. */static int ext4_d_revalidate(struct dentry *dentry, unsigned int flags){	struct inode *dir = d_inode(dentry->d_parent);	struct ext4_crypt_info *ci = EXT4_I(dir)->i_crypt_info;	int dir_has_key, cached_with_key;	if (!ext4_encrypted_inode(dir))		return 0;	if (ci && ci->ci_keyring_key &&	    (ci->ci_keyring_key->flags & ((1 << KEY_FLAG_INVALIDATED) |					  (1 << KEY_FLAG_REVOKED) |					  (1 << KEY_FLAG_DEAD))))		ci = NULL;	/* this should eventually be an flag in d_flags */	cached_with_key = dentry->d_fsdata != NULL;	dir_has_key = (ci != NULL);	/*	 * If the dentry was cached without the key, and it is a	 * negative dentry, it might be a valid name.  We can't check	 * if the key has since been made available due to locking	 * reasons, so we fail the validation so ext4_lookup() can do	 * this check.	 *	 * We also fail the validation if the dentry was created with	 * the key present, but we no longer have the key, or vice versa.	 */	if ((!cached_with_key && d_is_negative(dentry)) ||	    (!cached_with_key && dir_has_key) ||	    (cached_with_key && !dir_has_key)) {#if 0				/* Revalidation debug */		char buf[80];		char *cp = simple_dname(dentry, buf, sizeof(buf));		if (IS_ERR(cp))			cp = (char *) "???";		pr_err("revalidate: %s %p %d %d %d/n", cp, dentry->d_fsdata,		       cached_with_key, d_is_negative(dentry),		       dir_has_key);#endif		return 0;	}	return 1;}
开发者ID:jiaming77,项目名称:DORIMANX_LG_STOCK_LP_KERNEL,代码行数:51,


示例6: ext4_release_io_end

static void ext4_release_io_end(ext4_io_end_t *io_end){	struct bio *bio, *next_bio;	BUG_ON(!list_empty(&io_end->list));	BUG_ON(io_end->flag & EXT4_IO_END_UNWRITTEN);	WARN_ON(io_end->handle);	if (atomic_dec_and_test(&EXT4_I(io_end->inode)->i_ioend_count))		wake_up_all(ext4_ioend_wq(io_end->inode));	for (bio = io_end->bio; bio; bio = next_bio) {		next_bio = bio->bi_private;		ext4_finish_bio(bio);		bio_put(bio);	}	kmem_cache_free(io_end_cachep, io_end);}
开发者ID:Seagate,项目名称:SMR_FS-EXT4,代码行数:18,


示例7: ext4_es_print_tree

static void ext4_es_print_tree(struct inode *inode){	struct ext4_es_tree *tree;	struct rb_node *node;	printk(KERN_DEBUG "status extents for inode %lu:", inode->i_ino);	tree = &EXT4_I(inode)->i_es_tree;	node = rb_first(&tree->root);	while (node) {		struct extent_status *es;		es = rb_entry(node, struct extent_status, rb_node);		printk(KERN_DEBUG " [%u/%u) %llu %x",		       es->es_lblk, es->es_len,		       ext4_es_pblock(es), ext4_es_status(es));		node = rb_next(node);	}	printk(KERN_DEBUG "/n");}
开发者ID:MaxChina,项目名称:linux,代码行数:18,


示例8: ext4_inode_by_name

static unsigned long ext4_inode_by_name(struct inode *inode, struct qstr *unit){	struct super_block *sb = inode->i_sb;	struct ext4_sb_info *e4_sbi;	struct ext4_inode_info *e4_ini = EXT4_I(inode);	struct ext4_dir_entry_2 *e4_de;	struct ext4_inode *parent = e4_ini->i_e4in;	char buff[inode->i_sb->s_blocksize];	size_t len = 0;	int blocks, i;	size_t block_size;	e4_sbi = sb->s_fs_info;	block_size = 1024 << e4_sbi->e4_sb.s_log_block_size;	blocks = (parent->i_size_lo + block_size - 1) / block_size;	__le32 block_indexs[blocks];	ext4_get_blknums(inode, 0, block_indexs, blocks);	for (i = 0; i < blocks; i++) {		__ext4_read_block(sb, buff, block_indexs[i]);		e4_de = (struct ext4_dir_entry_2 *)buff;		while (e4_de->rec_len > 0 && len < parent->i_size_lo && len < (i + 1) * block_size) {			e4_de->name[e4_de->name_len] = '/0';			DPRINT("%s: inode = %d, e4_de size = %d, name size = %d, block = %d/n",				e4_de->name, e4_de->inode, e4_de->rec_len, e4_de->name_len, i);			if (unit->len == e4_de->name_len && /				!strncmp(e4_de->name, unit->name, e4_de->name_len))				return  e4_de->inode;			e4_de = (struct ext4_dir_entry_2 *)((char *)e4_de + e4_de->rec_len);			len += e4_de->rec_len;		}	}	GEN_DBG("/"%s/" not found!/n", unit->name);	return 0;}
开发者ID:JansZeng,项目名称:g-bios,代码行数:44,


示例9: free_ext_block

/* * Free the extent meta data blocks only */static int free_ext_block(handle_t *handle, struct inode *inode){	int i, retval = 0;	struct ext4_inode_info *ei = EXT4_I(inode);	struct ext4_extent_header *eh = (struct ext4_extent_header *)ei->i_data;	struct ext4_extent_idx *ix;	if (eh->eh_depth == 0)		/*		 * No extra blocks allocated for extent meta data		 */		return 0;	ix = EXT_FIRST_INDEX(eh);	for (i = 0; i < le16_to_cpu(eh->eh_entries); i++, ix++) {		retval = free_ext_idx(handle, inode, ix);		if (retval)			return retval;	}	return retval;}
开发者ID:AICP,项目名称:kernel_moto_shamu,代码行数:22,


示例10: ext4_end_io_work

/* * work on completed aio dio IO, to convert unwritten extents to extents */static void ext4_end_io_work(struct work_struct *work){	ext4_io_end_t		*io = container_of(work, ext4_io_end_t, work);	struct inode		*inode = io->inode;	struct ext4_inode_info	*ei = EXT4_I(inode);	unsigned long		flags;	spin_lock_irqsave(&ei->i_completed_io_lock, flags);	if (io->flag & EXT4_IO_END_IN_FSYNC)		goto requeue;	if (list_empty(&io->list)) {		spin_unlock_irqrestore(&ei->i_completed_io_lock, flags);		goto free;	}	if (!mutex_trylock(&inode->i_mutex)) {		bool was_queued;requeue:		was_queued = !!(io->flag & EXT4_IO_END_QUEUED);		io->flag |= EXT4_IO_END_QUEUED;		spin_unlock_irqrestore(&ei->i_completed_io_lock, flags);		/*		 * Requeue the work instead of waiting so that the work		 * items queued after this can be processed.		 */		queue_work(EXT4_SB(inode->i_sb)->dio_unwritten_wq, &io->work);		/*		 * To prevent the ext4-dio-unwritten thread from keeping		 * requeueing end_io requests and occupying cpu for too long,		 * yield the cpu if it sees an end_io request that has already		 * been requeued.		 */		if (was_queued)			yield();		return;	}	list_del_init(&io->list);	spin_unlock_irqrestore(&ei->i_completed_io_lock, flags);	(void) ext4_end_io_nolock(io);	mutex_unlock(&inode->i_mutex);free:	ext4_free_io_end(io);}
开发者ID:jing-git,项目名称:rt-n56u,代码行数:46,


示例11: ext4_end_io_nolock

/* * check a range of space and convert unwritten extents to written. */int ext4_end_io_nolock(ext4_io_end_t *io){	struct inode *inode = io->inode;	loff_t offset = io->offset;	ssize_t size = io->size;	wait_queue_head_t *wq;	int ret = 0;	ext4_debug("ext4_end_io_nolock: io 0x%p from inode %lu,list->next 0x%p,"		   "list->prev 0x%p/n",		   io, inode->i_ino, io->list.next, io->list.prev);	if (list_empty(&io->list))		return ret;	if (!(io->flag & EXT4_IO_END_UNWRITTEN))		return ret;	ret = ext4_convert_unwritten_extents(inode, offset, size);	if (ret < 0) {		printk(KERN_EMERG "%s: failed to convert unwritten "			"extents to written extents, error is %d "			"io is still on inode %lu aio dio list/n",		       __func__, ret, inode->i_ino);		return ret;	}	if (io->iocb)		aio_complete(io->iocb, io->result, 0);	/* clear the DIO AIO unwritten flag */	if (io->flag & EXT4_IO_END_UNWRITTEN) {		io->flag &= ~EXT4_IO_END_UNWRITTEN;		/* Wake up anyone waiting on unwritten extent conversion */		wq = ext4_ioend_wq(io->inode);		if (atomic_dec_and_test(&EXT4_I(inode)->i_aiodio_unwritten) &&		    waitqueue_active(wq)) {			wake_up_all(wq);		}	}	return ret;}
开发者ID:CSCLOG,项目名称:beaglebone,代码行数:45,


示例12: ext4_set_gps_location

long ext4_set_gps_location(struct inode *inode){	struct gps_location loc;	struct ext4_inode_info *iinfo = EXT4_I(inode);	long ts;	if (!test_opt(inode->i_sb, GPS_AWARE_INODE))		return -ENODEV;	kget_gps_location(&loc, &ts);	ts = CURRENT_TIME_SEC.tv_sec - ts;	write_lock(&iinfo->i_gps_lock);	memcpy(&iinfo->i_latitude, &loc.latitude, sizeof(long long));	memcpy(&iinfo->i_longitude, &loc.longitude, sizeof(long long));	memcpy(&iinfo->i_accuracy, &loc.accuracy, sizeof(long));	memcpy(&iinfo->i_coord_age, &ts, sizeof(long));	write_unlock(&iinfo->i_gps_lock);	return 0;}
开发者ID:keyu-lai,项目名称:Geo-tagged-Filesystem,代码行数:20,


示例13: ext4_file_open

static int ext4_file_open(struct inode * inode, struct file * filp){	struct super_block *sb = inode->i_sb;	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);	struct ext4_inode_info *ei = EXT4_I(inode);	struct vfsmount *mnt = filp->f_path.mnt;	struct path path;	char buf[64], *cp;	if (unlikely(!(sbi->s_mount_flags & EXT4_MF_MNTDIR_SAMPLED) &&		     !(sb->s_flags & MS_RDONLY))) {		sbi->s_mount_flags |= EXT4_MF_MNTDIR_SAMPLED;		memset(buf, 0, sizeof(buf));		path.mnt = mnt;		path.dentry = mnt->mnt_root;		cp = d_path(&path, buf, sizeof(buf));		if (!IS_ERR(cp)) {			strlcpy(sbi->s_es->s_last_mounted, cp,				sizeof(sbi->s_es->s_last_mounted));			ext4_mark_super_dirty(sb);		}	}	if (sbi->s_journal && !ei->jinode && (filp->f_mode & FMODE_WRITE)) {		struct jbd2_inode *jinode = jbd2_alloc_inode(GFP_KERNEL);		spin_lock(&inode->i_lock);		if (!ei->jinode) {			if (!jinode) {				spin_unlock(&inode->i_lock);				return -ENOMEM;			}			ei->jinode = jinode;			jbd2_journal_init_jbd_inode(ei->jinode, inode);			jinode = NULL;		}		spin_unlock(&inode->i_lock);		if (unlikely(jinode != NULL))			jbd2_free_inode(jinode);	}	return dquot_file_open(inode, filp);}
开发者ID:jiugui1,项目名称:kernel-mm-m8,代码行数:41,


示例14: ext4_try_create_inline_dir

/* * Try to create the inline data for the new dir. * If it succeeds, return 0, otherwise return the error. * In case of ENOSPC, the caller should create the normal disk layout dir. */int ext4_try_create_inline_dir(handle_t *handle, struct inode *parent,			       struct inode *inode){	int ret, inline_size = EXT4_MIN_INLINE_DATA_SIZE;	struct ext4_iloc iloc;	struct ext4_dir_entry_2 *de;	ret = ext4_get_inode_loc(inode, &iloc);	if (ret)		return ret;	ret = ext4_prepare_inline_data(handle, inode, inline_size);	if (ret)		goto out;	de = (struct ext4_dir_entry_2 *)ext4_raw_inode(&iloc)->i_block;	ext4_init_dot_dotdot(parent, inode, de, inline_size);	inode->i_size = EXT4_I(inode)->i_disksize = inline_size;out:	brelse(iloc.bh);	return ret;}
开发者ID:285452612,项目名称:ali_kernel,代码行数:27,


示例15: ext4_ioctl_check_project

static int ext4_ioctl_check_project(struct inode *inode, struct fsxattr *fa){	/*	 * Project Quota ID state is only allowed to change from within the init	 * namespace. Enforce that restriction only if we are trying to change	 * the quota ID state. Everything else is allowed in user namespaces.	 */	if (current_user_ns() == &init_user_ns)		return 0;	if (__kprojid_val(EXT4_I(inode)->i_projid) != fa->fsx_projid)		return -EINVAL;	if (ext4_test_inode_flag(inode, EXT4_INODE_PROJINHERIT)) {		if (!(fa->fsx_xflags & FS_XFLAG_PROJINHERIT))			return -EINVAL;	} else {		if (fa->fsx_xflags & FS_XFLAG_PROJINHERIT)			return -EINVAL;	}	return 0;}
开发者ID:Anjali05,项目名称:linux,代码行数:23,


示例16: ext4_prepare_inline_data

static int ext4_prepare_inline_data(handle_t *handle, struct inode *inode,				    unsigned int len){	int ret, size, no_expand;	struct ext4_inode_info *ei = EXT4_I(inode);	if (!ext4_test_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA))		return -ENOSPC;	size = ext4_get_max_inline_size(inode);	if (size < len)		return -ENOSPC;	ext4_write_lock_xattr(inode, &no_expand);	if (ei->i_inline_off)		ret = ext4_update_inline_data(handle, inode, len);	else		ret = ext4_create_inline_data(handle, inode, len);	ext4_write_unlock_xattr(inode, &no_expand);	return ret;}
开发者ID:asmalldev,项目名称:linux,代码行数:23,


示例17: ext4_inline_data_truncate

void ext4_inline_data_truncate(struct inode *inode, int *has_inline){	handle_t *handle;	int inline_size, value_len, needed_blocks;	size_t i_size;	void *value = NULL;	struct ext4_xattr_ibody_find is = {		.s = { .not_found = -ENODATA, },	};	struct ext4_xattr_info i = {		.name_index = EXT4_XATTR_INDEX_SYSTEM,		.name = EXT4_XATTR_SYSTEM_DATA,	};	needed_blocks = ext4_writepage_trans_blocks(inode);	handle = ext4_journal_start(inode, EXT4_HT_INODE, needed_blocks);	if (IS_ERR(handle))		return;	down_write(&EXT4_I(inode)->xattr_sem);	if (!ext4_has_inline_data(inode)) {		*has_inline = 0;		ext4_journal_stop(handle);		return;	}	if (ext4_orphan_add(handle, inode))		goto out;	if (ext4_get_inode_loc(inode, &is.iloc))		goto out;	down_write(&EXT4_I(inode)->i_data_sem);	i_size = inode->i_size;	inline_size = ext4_get_inline_size(inode);	EXT4_I(inode)->i_disksize = i_size;	if (i_size < inline_size) {		/* Clear the content in the xattr space. */		if (inline_size > EXT4_MIN_INLINE_DATA_SIZE) {			if (ext4_xattr_ibody_find(inode, &i, &is))				goto out_error;			BUG_ON(is.s.not_found);			value_len = le32_to_cpu(is.s.here->e_value_size);			value = kmalloc(value_len, GFP_NOFS);			if (!value)				goto out_error;			if (ext4_xattr_ibody_get(inode, i.name_index, i.name,						value, value_len))				goto out_error;			i.value = value;			i.value_len = i_size > EXT4_MIN_INLINE_DATA_SIZE ?					i_size - EXT4_MIN_INLINE_DATA_SIZE : 0;			if (ext4_xattr_ibody_inline_set(handle, inode, &i, &is))				goto out_error;		}		/* Clear the content within i_blocks. */		if (i_size < EXT4_MIN_INLINE_DATA_SIZE) {			void *p = (void *) ext4_raw_inode(&is.iloc)->i_block;			memset(p + i_size, 0,			       EXT4_MIN_INLINE_DATA_SIZE - i_size);		}		EXT4_I(inode)->i_inline_size = i_size <					EXT4_MIN_INLINE_DATA_SIZE ?					EXT4_MIN_INLINE_DATA_SIZE : i_size;	}out_error:	up_write(&EXT4_I(inode)->i_data_sem);out:	brelse(is.iloc.bh);	up_write(&EXT4_I(inode)->xattr_sem);	kfree(value);	if (inode->i_nlink)		ext4_orphan_del(handle, inode);	inode->i_mtime = inode->i_ctime = ext4_current_time(inode);	ext4_mark_inode_dirty(handle, inode);	if (IS_SYNC(inode))		ext4_handle_sync(handle);	ext4_journal_stop(handle);	return;}
开发者ID:shengwenhui,项目名称:aufs4-linux,代码行数:91,


示例18: ext4_try_to_write_inline_data

/* * Try to write data in the inode. * If the inode has inline data, check whether the new write can be * in the inode also. If not, create the page the handle, move the data * to the page make it update and let the later codes create extent for it. */int ext4_try_to_write_inline_data(struct address_space *mapping,				  struct inode *inode,				  loff_t pos, unsigned len,				  unsigned flags,				  struct page **pagep){	int ret;	handle_t *handle;	struct page *page;	struct ext4_iloc iloc;	if (pos + len > ext4_get_max_inline_size(inode))		goto convert;	ret = ext4_get_inode_loc(inode, &iloc);	if (ret)		return ret;	/*	 * The possible write could happen in the inode,	 * so try to reserve the space in inode first.	 */	handle = ext4_journal_start(inode, EXT4_HT_INODE, 1);	if (IS_ERR(handle)) {		ret = PTR_ERR(handle);		handle = NULL;		goto out;	}	ret = ext4_prepare_inline_data(handle, inode, pos + len);	if (ret && ret != -ENOSPC)		goto out;	/* We don't have space in inline inode, so convert it to extent. */	if (ret == -ENOSPC) {		ext4_journal_stop(handle);		brelse(iloc.bh);		goto convert;	}	flags |= AOP_FLAG_NOFS;	page = grab_cache_page_write_begin(mapping, 0, flags);	if (!page) {		ret = -ENOMEM;		goto out;	}	*pagep = page;	down_read(&EXT4_I(inode)->xattr_sem);	if (!ext4_has_inline_data(inode)) {		ret = 0;		unlock_page(page);		page_cache_release(page);		goto out_up_read;	}	if (!PageUptodate(page)) {		ret = ext4_read_inline_page(inode, page);		if (ret < 0)			goto out_up_read;	}	ret = 1;	handle = NULL;out_up_read:	up_read(&EXT4_I(inode)->xattr_sem);out:	if (handle)		ext4_journal_stop(handle);	brelse(iloc.bh);	return ret;convert:	return ext4_convert_inline_data_to_extent(mapping,						  inode, flags);}
开发者ID:shengwenhui,项目名称:aufs4-linux,代码行数:82,


示例19: ext4_da_write_inline_data_begin

/* * Prepare the write for the inline data. * If the the data can be written into the inode, we just read * the page and make it uptodate, and start the journal. * Otherwise read the page, makes it dirty so that it can be * handle in writepages(the i_disksize update is left to the * normal ext4_da_write_end). */int ext4_da_write_inline_data_begin(struct address_space *mapping,				    struct inode *inode,				    loff_t pos, unsigned len,				    unsigned flags,				    struct page **pagep,				    void **fsdata){	int ret, inline_size;	handle_t *handle;	struct page *page;	struct ext4_iloc iloc;	int retries;	ret = ext4_get_inode_loc(inode, &iloc);	if (ret)		return ret;retry_journal:	handle = ext4_journal_start(inode, EXT4_HT_INODE, 1);	if (IS_ERR(handle)) {		ret = PTR_ERR(handle);		goto out;	}	inline_size = ext4_get_max_inline_size(inode);	ret = -ENOSPC;	if (inline_size >= pos + len) {		ret = ext4_prepare_inline_data(handle, inode, pos + len);		if (ret && ret != -ENOSPC)			goto out_journal;	}	/*	 * We cannot recurse into the filesystem as the transaction	 * is already started.	 */	flags |= AOP_FLAG_NOFS;	if (ret == -ENOSPC) {		ret = ext4_da_convert_inline_data_to_extent(mapping,							    inode,							    flags,							    fsdata);		ext4_journal_stop(handle);		if (ret == -ENOSPC &&		    ext4_should_retry_alloc(inode->i_sb, &retries))			goto retry_journal;		goto out;	}	page = grab_cache_page_write_begin(mapping, 0, flags);	if (!page) {		ret = -ENOMEM;		goto out_journal;	}	down_read(&EXT4_I(inode)->xattr_sem);	if (!ext4_has_inline_data(inode)) {		ret = 0;		goto out_release_page;	}	if (!PageUptodate(page)) {		ret = ext4_read_inline_page(inode, page);		if (ret < 0)			goto out_release_page;	}	up_read(&EXT4_I(inode)->xattr_sem);	*pagep = page;	brelse(iloc.bh);	return 1;out_release_page:	up_read(&EXT4_I(inode)->xattr_sem);	unlock_page(page);	page_cache_release(page);out_journal:	ext4_journal_stop(handle);out:	brelse(iloc.bh);	return ret;}
开发者ID:shengwenhui,项目名称:aufs4-linux,代码行数:92,


示例20: ext4_convert_inline_data_to_extent

static int ext4_convert_inline_data_to_extent(struct address_space *mapping,					      struct inode *inode,					      unsigned flags){	int ret, needed_blocks;	handle_t *handle = NULL;	int retries = 0, sem_held = 0;	struct page *page = NULL;	unsigned from, to;	struct ext4_iloc iloc;	if (!ext4_has_inline_data(inode)) {		/*		 * clear the flag so that no new write		 * will trap here again.		 */		ext4_clear_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA);		return 0;	}	needed_blocks = ext4_writepage_trans_blocks(inode);	ret = ext4_get_inode_loc(inode, &iloc);	if (ret)		return ret;retry:	handle = ext4_journal_start(inode, EXT4_HT_WRITE_PAGE, needed_blocks);	if (IS_ERR(handle)) {		ret = PTR_ERR(handle);		handle = NULL;		goto out;	}	/* We cannot recurse into the filesystem as the transaction is already	 * started */	flags |= AOP_FLAG_NOFS;	page = grab_cache_page_write_begin(mapping, 0, flags);	if (!page) {		ret = -ENOMEM;		goto out;	}	down_write(&EXT4_I(inode)->xattr_sem);	sem_held = 1;	/* If some one has already done this for us, just exit. */	if (!ext4_has_inline_data(inode)) {		ret = 0;		goto out;	}	from = 0;	to = ext4_get_inline_size(inode);	if (!PageUptodate(page)) {		ret = ext4_read_inline_page(inode, page);		if (ret < 0)			goto out;	}	ret = ext4_destroy_inline_data_nolock(handle, inode);	if (ret)		goto out;	if (ext4_should_dioread_nolock(inode)) {		ret = __block_write_begin(page, from, to,					  ext4_get_block_unwritten);	} else		ret = __block_write_begin(page, from, to, ext4_get_block);	if (!ret && ext4_should_journal_data(inode)) {		ret = ext4_walk_page_buffers(handle, page_buffers(page),					     from, to, NULL,					     do_journal_get_write_access);	}	if (ret) {		unlock_page(page);		page_cache_release(page);		page = NULL;		ext4_orphan_add(handle, inode);		up_write(&EXT4_I(inode)->xattr_sem);		sem_held = 0;		ext4_journal_stop(handle);		handle = NULL;		ext4_truncate_failed_write(inode);		/*		 * If truncate failed early the inode might		 * still be on the orphan list; we need to		 * make sure the inode is removed from the		 * orphan list in that case.		 */		if (inode->i_nlink)			ext4_orphan_del(NULL, inode);	}	if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries))		goto retry;	if (page)//.........这里部分代码省略.........
开发者ID:shengwenhui,项目名称:aufs4-linux,代码行数:101,


示例21: ext4_destroy_inline_data_nolock

static int ext4_destroy_inline_data_nolock(handle_t *handle,					   struct inode *inode){	struct ext4_inode_info *ei = EXT4_I(inode);	struct ext4_xattr_ibody_find is = {		.s = { .not_found = 0, },	};	struct ext4_xattr_info i = {		.name_index = EXT4_XATTR_INDEX_SYSTEM,		.name = EXT4_XATTR_SYSTEM_DATA,		.value = NULL,		.value_len = 0,	};	int error;	if (!ei->i_inline_off)		return 0;	error = ext4_get_inode_loc(inode, &is.iloc);	if (error)		return error;	error = ext4_xattr_ibody_find(inode, &i, &is);	if (error)		goto out;	BUFFER_TRACE(is.iloc.bh, "get_write_access");	error = ext4_journal_get_write_access(handle, is.iloc.bh);	if (error)		goto out;	error = ext4_xattr_ibody_inline_set(handle, inode, &i, &is);	if (error)		goto out;	memset((void *)ext4_raw_inode(&is.iloc)->i_block,		0, EXT4_MIN_INLINE_DATA_SIZE);	if (ext4_has_feature_extents(inode->i_sb)) {		if (S_ISDIR(inode->i_mode) ||		    S_ISREG(inode->i_mode) || S_ISLNK(inode->i_mode)) {			ext4_set_inode_flag(inode, EXT4_INODE_EXTENTS);			ext4_ext_tree_init(handle, inode);		}	}	ext4_clear_inode_flag(inode, EXT4_INODE_INLINE_DATA);	get_bh(is.iloc.bh);	error = ext4_mark_iloc_dirty(handle, inode, &is.iloc);	EXT4_I(inode)->i_inline_off = 0;	EXT4_I(inode)->i_inline_size = 0;	ext4_clear_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA);out:	brelse(is.iloc.bh);	if (error == -ENODATA)		error = 0;	return error;}static int ext4_read_inline_page(struct inode *inode, struct page *page){	void *kaddr;	int ret = 0;	size_t len;	struct ext4_iloc iloc;	BUG_ON(!PageLocked(page));	BUG_ON(!ext4_has_inline_data(inode));	BUG_ON(page->index);	if (!EXT4_I(inode)->i_inline_off) {		ext4_warning(inode->i_sb, "inode %lu doesn't have inline data.",			     inode->i_ino);		goto out;	}	ret = ext4_get_inode_loc(inode, &iloc);	if (ret)		goto out;	len = min_t(size_t, ext4_get_inline_size(inode), i_size_read(inode));	kaddr = kmap_atomic(page);	ret = ext4_read_inline_data(inode, kaddr, len, &iloc);	flush_dcache_page(page);	kunmap_atomic(kaddr);	zero_user_segment(page, len, PAGE_CACHE_SIZE);	SetPageUptodate(page);	brelse(iloc.bh);out:	return ret;}
开发者ID:shengwenhui,项目名称:aufs4-linux,代码行数:93,


示例22: ext4_read_inline_dir

/* * So this function is called when the volume is mkfsed with * dir_index disabled. In order to keep f_pos persistent * after we convert from an inlined dir to a blocked based, * we just pretend that we are a normal dir and return the * offset as if '.' and '..' really take place. * */int ext4_read_inline_dir(struct file *file,			 struct dir_context *ctx,			 int *has_inline_data){	unsigned int offset, parent_ino;	int i;	struct ext4_dir_entry_2 *de;	struct super_block *sb;	struct inode *inode = file_inode(file);	int ret, inline_size = 0;	struct ext4_iloc iloc;	void *dir_buf = NULL;	int dotdot_offset, dotdot_size, extra_offset, extra_size;	ret = ext4_get_inode_loc(inode, &iloc);	if (ret)		return ret;	down_read(&EXT4_I(inode)->xattr_sem);	if (!ext4_has_inline_data(inode)) {		up_read(&EXT4_I(inode)->xattr_sem);		*has_inline_data = 0;		goto out;	}	inline_size = ext4_get_inline_size(inode);	dir_buf = kmalloc(inline_size, GFP_NOFS);	if (!dir_buf) {		ret = -ENOMEM;		up_read(&EXT4_I(inode)->xattr_sem);		goto out;	}	ret = ext4_read_inline_data(inode, dir_buf, inline_size, &iloc);	up_read(&EXT4_I(inode)->xattr_sem);	if (ret < 0)		goto out;	ret = 0;	sb = inode->i_sb;	parent_ino = le32_to_cpu(((struct ext4_dir_entry_2 *)dir_buf)->inode);	offset = ctx->pos;	/*	 * dotdot_offset and dotdot_size is the real offset and	 * size for ".." and "." if the dir is block based while	 * the real size for them are only EXT4_INLINE_DOTDOT_SIZE.	 * So we will use extra_offset and extra_size to indicate them	 * during the inline dir iteration.	 */	dotdot_offset = EXT4_DIR_REC_LEN(1);	dotdot_size = dotdot_offset + EXT4_DIR_REC_LEN(2);	extra_offset = dotdot_size - EXT4_INLINE_DOTDOT_SIZE;	extra_size = extra_offset + inline_size;	/*	 * If the version has changed since the last call to	 * readdir(2), then we might be pointing to an invalid	 * dirent right now.  Scan from the start of the inline	 * dir to make sure.	 */	if (file->f_version != inode->i_version) {		for (i = 0; i < extra_size && i < offset;) {			/*			 * "." is with offset 0 and			 * ".." is dotdot_offset.			 */			if (!i) {				i = dotdot_offset;				continue;			} else if (i == dotdot_offset) {				i = dotdot_size;				continue;			}			/* for other entry, the real offset in			 * the buf has to be tuned accordingly.			 */			de = (struct ext4_dir_entry_2 *)				(dir_buf + i - extra_offset);			/* It's too expensive to do a full			 * dirent test each time round this			 * loop, but we do have to test at			 * least that it is non-zero.  A			 * failure will be detected in the			 * dirent test below. */			if (ext4_rec_len_from_disk(de->rec_len, extra_size)				< EXT4_DIR_REC_LEN(1))				break;			i += ext4_rec_len_from_disk(de->rec_len,						    extra_size);		}		offset = i;//.........这里部分代码省略.........
开发者ID:shengwenhui,项目名称:aufs4-linux,代码行数:101,


示例23: ext4_ioctl

long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg){	struct inode *inode = file_inode(filp);	struct super_block *sb = inode->i_sb;	struct ext4_inode_info *ei = EXT4_I(inode);	unsigned int flags;	ext4_debug("cmd = %u, arg = %lu/n", cmd, arg);	switch (cmd) {	case EXT4_IOC_GETFLAGS:		ext4_get_inode_flags(ei);		flags = ei->i_flags & EXT4_FL_USER_VISIBLE;		return put_user(flags, (int __user *) arg);	case EXT4_IOC_SETFLAGS: {		handle_t *handle = NULL;		int err, migrate = 0;		struct ext4_iloc iloc;		unsigned int oldflags, mask, i;		unsigned int jflag;		if (!inode_owner_or_capable(inode))			return -EACCES;		if (get_user(flags, (int __user *) arg))			return -EFAULT;		err = mnt_want_write_file(filp);		if (err)			return err;		flags = ext4_mask_flags(inode->i_mode, flags);		err = -EPERM;		mutex_lock(&inode->i_mutex);		/* Is it quota file? Do not allow user to mess with it */		if (IS_NOQUOTA(inode))			goto flags_out;		oldflags = ei->i_flags;		/* The JOURNAL_DATA flag is modifiable only by root */		jflag = flags & EXT4_JOURNAL_DATA_FL;		/*		 * The IMMUTABLE and APPEND_ONLY flags can only be changed by		 * the relevant capability.		 *		 * This test looks nicer. Thanks to Pauline Middelink		 */		if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {			if (!capable(CAP_LINUX_IMMUTABLE))				goto flags_out;		}		/*		 * The JOURNAL_DATA flag can only be changed by		 * the relevant capability.		 */		if ((jflag ^ oldflags) & (EXT4_JOURNAL_DATA_FL)) {			if (!capable(CAP_SYS_RESOURCE))				goto flags_out;		}		if ((flags ^ oldflags) & EXT4_EXTENTS_FL)			migrate = 1;		if (flags & EXT4_EOFBLOCKS_FL) {			/* we don't support adding EOFBLOCKS flag */			if (!(oldflags & EXT4_EOFBLOCKS_FL)) {				err = -EOPNOTSUPP;				goto flags_out;			}		} else if (oldflags & EXT4_EOFBLOCKS_FL)			ext4_truncate(inode);		handle = ext4_journal_start(inode, EXT4_HT_INODE, 1);		if (IS_ERR(handle)) {			err = PTR_ERR(handle);			goto flags_out;		}		if (IS_SYNC(inode))			ext4_handle_sync(handle);		err = ext4_reserve_inode_write(handle, inode, &iloc);		if (err)			goto flags_err;		for (i = 0, mask = 1; i < 32; i++, mask <<= 1) {			if (!(mask & EXT4_FL_USER_MODIFIABLE))				continue;			if (mask & flags)				ext4_set_inode_flag(inode, i);			else				ext4_clear_inode_flag(inode, i);		}		ext4_set_inode_flags(inode);		inode->i_ctime = ext4_current_time(inode);		err = ext4_mark_iloc_dirty(handle, inode, &iloc);flags_err://.........这里部分代码省略.........
开发者ID:acorn-marvell,项目名称:brillo_pxa_kernel,代码行数:101,


示例24: ext4_fname_encrypt

/** * ext4_fname_encrypt() - * * This function encrypts the input filename, and returns the length of the * ciphertext. Errors are returned as negative numbers.  We trust the caller to * allocate sufficient memory to oname string. */static int ext4_fname_encrypt(struct inode *inode,			      const struct qstr *iname,			      struct ext4_str *oname){	u32 ciphertext_len;	struct ablkcipher_request *req = NULL;	DECLARE_EXT4_COMPLETION_RESULT(ecr);	struct ext4_crypt_info *ci = EXT4_I(inode)->i_crypt_info;	struct crypto_ablkcipher *tfm = ci->ci_ctfm;	int res = 0;	char iv[EXT4_CRYPTO_BLOCK_SIZE];	struct scatterlist src_sg, dst_sg;	int padding = 4 << (ci->ci_flags & EXT4_POLICY_FLAGS_PAD_MASK);	char *workbuf, buf[32], *alloc_buf = NULL;	unsigned lim = max_name_len(inode);	if (iname->len <= 0 || iname->len > lim)		return -EIO;	ciphertext_len = (iname->len < EXT4_CRYPTO_BLOCK_SIZE) ?		EXT4_CRYPTO_BLOCK_SIZE : iname->len;	ciphertext_len = ext4_fname_crypto_round_up(ciphertext_len, padding);	ciphertext_len = (ciphertext_len > lim)			? lim : ciphertext_len;	if (ciphertext_len <= sizeof(buf)) {		workbuf = buf;	} else {		alloc_buf = kmalloc(ciphertext_len, GFP_NOFS);		if (!alloc_buf)			return -ENOMEM;		workbuf = alloc_buf;	}	/* Allocate request */	req = ablkcipher_request_alloc(tfm, GFP_NOFS);	if (!req) {		printk_ratelimited(		    KERN_ERR "%s: crypto_request_alloc() failed/n", __func__);		kfree(alloc_buf);		return -ENOMEM;	}	ablkcipher_request_set_callback(req,		CRYPTO_TFM_REQ_MAY_BACKLOG | CRYPTO_TFM_REQ_MAY_SLEEP,		ext4_dir_crypt_complete, &ecr);	/* Copy the input */	memcpy(workbuf, iname->name, iname->len);	if (iname->len < ciphertext_len)		memset(workbuf + iname->len, 0, ciphertext_len - iname->len);	/* Initialize IV */	memset(iv, 0, EXT4_CRYPTO_BLOCK_SIZE);	/* Create encryption request */	sg_init_one(&src_sg, workbuf, ciphertext_len);	sg_init_one(&dst_sg, oname->name, ciphertext_len);	ablkcipher_request_set_crypt(req, &src_sg, &dst_sg, ciphertext_len, iv);	res = crypto_ablkcipher_encrypt(req);	if (res == -EINPROGRESS || res == -EBUSY) {		BUG_ON(req->base.data != &ecr);		wait_for_completion(&ecr.completion);		res = ecr.res;	}	kfree(alloc_buf);	ablkcipher_request_free(req);	if (res < 0) {		printk_ratelimited(		    KERN_ERR "%s: Error (error code %d)/n", __func__, res);	}	oname->len = ciphertext_len;	return res;}
开发者ID:DenisLug,项目名称:mptcp,代码行数:80,


示例25: ext4_create_inline_data

static int ext4_create_inline_data(handle_t *handle,				   struct inode *inode, unsigned len){	int error;	void *value = NULL;	struct ext4_xattr_ibody_find is = {		.s = { .not_found = -ENODATA, },	};	struct ext4_xattr_info i = {		.name_index = EXT4_XATTR_INDEX_SYSTEM,		.name = EXT4_XATTR_SYSTEM_DATA,	};	error = ext4_get_inode_loc(inode, &is.iloc);	if (error)		return error;	BUFFER_TRACE(is.iloc.bh, "get_write_access");	error = ext4_journal_get_write_access(handle, is.iloc.bh);	if (error)		goto out;	if (len > EXT4_MIN_INLINE_DATA_SIZE) {		value = EXT4_ZERO_XATTR_VALUE;		len -= EXT4_MIN_INLINE_DATA_SIZE;	} else {		value = "";		len = 0;	}	/* Insert the the xttr entry. */	i.value = value;	i.value_len = len;	error = ext4_xattr_ibody_find(inode, &i, &is);	if (error)		goto out;	BUG_ON(!is.s.not_found);	error = ext4_xattr_ibody_inline_set(handle, inode, &i, &is);	if (error) {		if (error == -ENOSPC)			ext4_clear_inode_state(inode,					       EXT4_STATE_MAY_INLINE_DATA);		goto out;	}	memset((void *)ext4_raw_inode(&is.iloc)->i_block,		0, EXT4_MIN_INLINE_DATA_SIZE);	EXT4_I(inode)->i_inline_off = (u16)((void *)is.s.here -				      (void *)ext4_raw_inode(&is.iloc));	EXT4_I(inode)->i_inline_size = len + EXT4_MIN_INLINE_DATA_SIZE;	ext4_clear_inode_flag(inode, EXT4_INODE_EXTENTS);	ext4_set_inode_flag(inode, EXT4_INODE_INLINE_DATA);	get_bh(is.iloc.bh);	error = ext4_mark_iloc_dirty(handle, inode, &is.iloc);out:	brelse(is.iloc.bh);	return error;}
开发者ID:shengwenhui,项目名称:aufs4-linux,代码行数:63,


示例26: swap_inode_boot_loader

/** * Swap the information from the given @inode and the inode * EXT4_BOOT_LOADER_INO. It will basically swap i_data and all other * important fields of the inodes. * * @sb:         the super block of the filesystem * @inode:      the inode to swap with EXT4_BOOT_LOADER_INO * */static long swap_inode_boot_loader(struct super_block *sb,				struct inode *inode){	handle_t *handle;	int err;	struct inode *inode_bl;	struct ext4_inode_info *ei_bl;	struct ext4_sb_info *sbi = EXT4_SB(sb);	if (inode->i_nlink != 1 || !S_ISREG(inode->i_mode)) {		err = -EINVAL;		goto swap_boot_out;	}	if (!inode_owner_or_capable(inode) || !capable(CAP_SYS_ADMIN)) {		err = -EPERM;		goto swap_boot_out;	}	inode_bl = ext4_iget(sb, EXT4_BOOT_LOADER_INO);	if (IS_ERR(inode_bl)) {		err = PTR_ERR(inode_bl);		goto swap_boot_out;	}	ei_bl = EXT4_I(inode_bl);	filemap_flush(inode->i_mapping);	filemap_flush(inode_bl->i_mapping);	/* Protect orig inodes against a truncate and make sure,	 * that only 1 swap_inode_boot_loader is running. */	lock_two_nondirectories(inode, inode_bl);	truncate_inode_pages(&inode->i_data, 0);	truncate_inode_pages(&inode_bl->i_data, 0);	/* Wait for all existing dio workers */	ext4_inode_block_unlocked_dio(inode);	ext4_inode_block_unlocked_dio(inode_bl);	inode_dio_wait(inode);	inode_dio_wait(inode_bl);	handle = ext4_journal_start(inode_bl, EXT4_HT_MOVE_EXTENTS, 2);	if (IS_ERR(handle)) {		err = -EINVAL;		goto journal_err_out;	}	/* Protect extent tree against block allocations via delalloc */	ext4_double_down_write_data_sem(inode, inode_bl);	if (inode_bl->i_nlink == 0) {		/* this inode has never been used as a BOOT_LOADER */		set_nlink(inode_bl, 1);		i_uid_write(inode_bl, 0);		i_gid_write(inode_bl, 0);		inode_bl->i_flags = 0;		ei_bl->i_flags = 0;		inode_bl->i_version = 1;		i_size_write(inode_bl, 0);		inode_bl->i_mode = S_IFREG;		if (EXT4_HAS_INCOMPAT_FEATURE(sb,					      EXT4_FEATURE_INCOMPAT_EXTENTS)) {			ext4_set_inode_flag(inode_bl, EXT4_INODE_EXTENTS);			ext4_ext_tree_init(handle, inode_bl);		} else			memset(ei_bl->i_data, 0, sizeof(ei_bl->i_data));	}	swap_inode_data(inode, inode_bl);	inode->i_ctime = inode_bl->i_ctime = ext4_current_time(inode);	spin_lock(&sbi->s_next_gen_lock);	inode->i_generation = sbi->s_next_generation++;	inode_bl->i_generation = sbi->s_next_generation++;	spin_unlock(&sbi->s_next_gen_lock);	ext4_discard_preallocations(inode);	err = ext4_mark_inode_dirty(handle, inode);	if (err < 0) {		ext4_warning(inode->i_sb,			"couldn't mark inode #%lu dirty (err %d)",			inode->i_ino, err);		/* Revert all changes: */		swap_inode_data(inode, inode_bl);	} else {		err = ext4_mark_inode_dirty(handle, inode_bl);		if (err < 0) {			ext4_warning(inode_bl->i_sb,//.........这里部分代码省略.........
开发者ID:acorn-marvell,项目名称:brillo_pxa_kernel,代码行数:101,


示例27: ext4_update_inline_data

static int ext4_update_inline_data(handle_t *handle, struct inode *inode,				   unsigned int len){	int error;	void *value = NULL;	struct ext4_xattr_ibody_find is = {		.s = { .not_found = -ENODATA, },	};	struct ext4_xattr_info i = {		.name_index = EXT4_XATTR_INDEX_SYSTEM,		.name = EXT4_XATTR_SYSTEM_DATA,	};	/* If the old space is ok, write the data directly. */	if (len <= EXT4_I(inode)->i_inline_size)		return 0;	error = ext4_get_inode_loc(inode, &is.iloc);	if (error)		return error;	error = ext4_xattr_ibody_find(inode, &i, &is);	if (error)		goto out;	BUG_ON(is.s.not_found);	len -= EXT4_MIN_INLINE_DATA_SIZE;	value = kzalloc(len, GFP_NOFS);	if (!value)		goto out;	error = ext4_xattr_ibody_get(inode, i.name_index, i.name,				     value, len);	if (error == -ENODATA)		goto out;	BUFFER_TRACE(is.iloc.bh, "get_write_access");	error = ext4_journal_get_write_access(handle, is.iloc.bh);	if (error)		goto out;	/* Update the xttr entry. */	i.value = value;	i.value_len = len;	error = ext4_xattr_ibody_inline_set(handle, inode, &i, &is);	if (error)		goto out;	EXT4_I(inode)->i_inline_off = (u16)((void *)is.s.here -				      (void *)ext4_raw_inode(&is.iloc));	EXT4_I(inode)->i_inline_size = EXT4_MIN_INLINE_DATA_SIZE +				le32_to_cpu(is.s.here->e_value_size);	ext4_set_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA);	get_bh(is.iloc.bh);	error = ext4_mark_iloc_dirty(handle, inode, &is.iloc);out:	kfree(value);	brelse(is.iloc.bh);	return error;}
开发者ID:shengwenhui,项目名称:aufs4-linux,代码行数:63,



注:本文中的EXT4_I函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ EXT4_SB函数代码示例
C++ EXT3_I函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。