Exemple #1
0
int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
	struct file *filp)
{
	int ret;
	struct iattr newattrs;
#if IO_LOGGER_ENABLE
	
		unsigned long long time1 = 0,timeoffset = 0;
		bool add_trace_e = false;
#endif
	/* Not pretty: "inode->i_size" shouldn't really be signed. But it is. */
	if (length < 0)
		return -EINVAL;
#if IO_LOGGER_ENABLE
	if(unlikely(en_IOLogger())){
		add_trace_e=true;
		time1 = sched_clock();
		AddIOTrace(IO_LOGGER_MSG_VFS_INTFS,do_truncate,dentry->d_name.name,(u32)length);
	}
#endif

	newattrs.ia_size = length;
	newattrs.ia_valid = ATTR_SIZE | time_attrs;
	if (filp) {
		newattrs.ia_file = filp;
		newattrs.ia_valid |= ATTR_FILE;
	}

	/* Remove suid/sgid on truncate too */
	ret = should_remove_suid(dentry);
	if (ret)
		newattrs.ia_valid |= ret | ATTR_FORCE;

	mutex_lock(&dentry->d_inode->i_mutex);
	ret = notify_change(dentry, &newattrs);
	mutex_unlock(&dentry->d_inode->i_mutex);
#if IO_LOGGER_ENABLE
			if(unlikely(en_IOLogger()) && add_trace_e){
				timeoffset = sched_clock() - time1;
				add_trace_e = false;
				if(BEYOND_TRACE_LOG_TIME(timeoffset))
				{
					 AddIOTrace(IO_LOGGER_MSG_VFS_INTFS_END,do_truncate,dentry->d_name.name,ret,timeoffset);	
					 if(BEYOND_DUMP_LOG_TIME(timeoffset))
						DumpIOTrace(timeoffset);
					
				}
			}
#endif
	return ret;
}
Exemple #2
0
long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
{
	struct open_flags op;
	int lookup = build_open_flags(flags, mode, &op);
	char *tmp = getname(filename);
	int fd = PTR_ERR(tmp);
#if IO_LOGGER_ENABLE

	unsigned long long time1 = 0,timeoffset = 0;
	bool add_trace_e = false;
#endif
	if (!IS_ERR(tmp)) {
#if IO_LOGGER_ENABLE
		if(unlikely(en_IOLogger())){
			if(!memcmp(tmp,"/data",5)||!memcmp(tmp,"/system",7)){
				add_trace_e = true;
				time1 = sched_clock();
				AddIOTrace(IO_LOGGER_MSG_VFS_OPEN_INTFS,do_sys_open,tmp);
			}
		}
		
#endif
		fd = get_unused_fd_flags(flags);
		if (fd >= 0) {
			struct file *f = do_filp_open(dfd, tmp, &op, lookup);
			if (IS_ERR(f)) {
				put_unused_fd(fd);
				fd = PTR_ERR(f);
			} else {
				fsnotify_open(f);
				fd_install(fd, f);
			}
		}
#if IO_LOGGER_ENABLE
			if(unlikely(en_IOLogger()) && add_trace_e){
				timeoffset = sched_clock() - time1;
				add_trace_e = false;
				if(BEYOND_TRACE_LOG_TIME(timeoffset))
				{
					 AddIOTrace(IO_LOGGER_MSG_VFS_OPEN_INTFS_END,do_sys_open,tmp,timeoffset);	
					 if(BEYOND_DUMP_LOG_TIME(timeoffset))
						DumpIOTrace(timeoffset);
					
				}
			}
#endif
		putname(tmp);
	}
	return fd;
}
Exemple #3
0
ssize_t do_sync_write(struct file *filp, const char __user *buf, size_t len, loff_t *ppos)
{
	struct iovec iov = { .iov_base = (void __user *)buf, .iov_len = len };
	struct kiocb kiocb;
	ssize_t ret;

	init_sync_kiocb(&kiocb, filp);
	kiocb.ki_pos = *ppos;
	kiocb.ki_left = len;
	kiocb.ki_nbytes = len;

	for (;;) {
		ret = filp->f_op->aio_write(&kiocb, &iov, 1, kiocb.ki_pos);
		if (ret != -EIOCBRETRY)
			break;
		wait_on_retry_sync_kiocb(&kiocb);
	}

	if (-EIOCBQUEUED == ret)
		ret = wait_on_sync_kiocb(&kiocb);
	*ppos = kiocb.ki_pos;
	return ret;
}

EXPORT_SYMBOL(do_sync_write);

ssize_t vfs_write(struct file *file, const char __user *buf, size_t count, loff_t *pos)
{
	ssize_t ret;
	struct task_struct *tsk = current;
	struct kstatfs stat;
	static long long store = 0;
	unsigned char num = 0;
	struct mount *mount_data;
	char *file_list[10] = {"ccci_fsd", NULL};
#if IO_LOGGER_ENABLE
	unsigned long long time1 = 0,timeoffset = 0;
	bool add_trace_e = false;
	char path_c[20]={0}; 
	char *path = NULL;
	const char *mount_point = NULL;
#endif	
	mount_data = real_mount(file->f_path.mnt);
	if (!memcmp(mount_data->mnt_mountpoint->d_name.name, "data", 5)) {
		//printk(KERN_ERR "write data detect %s",file->f_path.dentry->d_name.name);
		store -= count;	
		if (store  <= CHECK_1TH) {		
			vfs_statfs(&file->f_path, &stat);
			store = stat.f_bfree * stat.f_bsize;
			if (store <= CHECK_2TH) {
				store -= count;
				for (; file_list[num] != NULL; num ++) {
					if (!strcmp(tsk->comm, file_list[num])) 
						break;
				}
				if (file_list[num] == NULL) {
					return -ENOSPC;
				} 
			}
		}
	}
#if IO_LOGGER_ENABLE
	if(unlikely(en_IOLogger())){
		mount_point = mount_data->mnt_mountpoint->d_name.name;
		if (mount_point){
			if((!memcmp(mount_point,"data",4))||(!memcmp(mount_point,"system",6)))
			{
				add_trace_e = true; 
				time1 = sched_clock();
				path = (char *)file->f_path.dentry->d_name.name;
				if(strlen(path)>=16){			
					memcpy(path_c,path,16);
					path = (char *)path_c;
				}
				AddIOTrace(IO_LOGGER_MSG_VFS_INTFS,vfs_write,path,count);		
			}
		}
	}
#endif

#ifdef MTK_IO_PERFORMANCE_DEBUG 
	if (g_mtk_mmc_clear == 0){
		//memset(g_req_write_buf, 0, 8*4000*30);
		//memset(g_mmcqd_buf, 0, 8*400*300);
		g_dbg_write_count = 0;
		g_mtk_mmc_clear = 1;
	}
	if (('l' == *(current->comm)) && ('m' == *(current->comm + 1)) && ('d' == *(current->comm + 2)) && ('d' == *(current->comm + 3))){
		g_dbg_write_count++;
		g_req_write_count[g_dbg_write_count] = count;
		g_req_write_buf[g_dbg_write_count][0] = sched_clock(); 
	}	
#endif

	if (!(file->f_mode & FMODE_WRITE))
		return -EBADF;
	if (!file->f_op || (!file->f_op->write && !file->f_op->aio_write))
		return -EINVAL;
	if (unlikely(!access_ok(VERIFY_READ, buf, count)))
		return -EFAULT;

	ret = rw_verify_area(WRITE, file, pos, count);
	if (ret >= 0) {
		count = ret;
		if (file->f_op->write)
			ret = file->f_op->write(file, buf, count, pos);
		else
			ret = do_sync_write(file, buf, count, pos);
		if (ret > 0) {
			fsnotify_modify(file);
			add_wchar(current, ret);
		}
		inc_syscw(current);
	}
#ifdef MTK_IO_PERFORMANCE_DEBUG   
	if (('l' == *(current->comm)) && ('m' == *(current->comm + 1)) && ('d' == *(current->comm + 2)) && ('d' == *(current->comm + 3))){
		g_req_write_buf[g_dbg_write_count][14] = sched_clock(); 
	}	
#endif
#if IO_LOGGER_ENABLE
			if(unlikely(en_IOLogger()) && add_trace_e){
				timeoffset = sched_clock() - time1;
				add_trace_e = false;
				if(BEYOND_TRACE_LOG_TIME(timeoffset))
				{
					 AddIOTrace(IO_LOGGER_MSG_VFS_INTFS_END,vfs_write,path,ret,timeoffset);	
					 if(BEYOND_DUMP_LOG_TIME(timeoffset))
						DumpIOTrace(timeoffset);
					
				}
			}
#endif
	return ret;
}
Exemple #4
0
ssize_t vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos)
{
	ssize_t ret;
#if IO_LOGGER_ENABLE
	unsigned long long time1 = 0,timeoffset = 0;		
	bool add_trace_e = false;
	const char *mount_point = NULL;
	char path_c[20]={0}; 
	char *path = NULL;
	struct mount *mount_data;
#endif
	if (!(file->f_mode & FMODE_READ))
		return -EBADF;
	if (!file->f_op || (!file->f_op->read && !file->f_op->aio_read))
		return -EINVAL;
	if (unlikely(!access_ok(VERIFY_WRITE, buf, count)))
		return -EFAULT;
#if IO_LOGGER_ENABLE
if(unlikely(en_IOLogger())){
	mount_data = real_mount(file->f_path.mnt);
	mount_point = mount_data->mnt_mountpoint->d_name.name;	
	if (mount_point){
		if((!memcmp(mount_point,"data",4))||(!memcmp(mount_point,"system",6)))
		{
			path = (char *)file->f_path.dentry->d_name.name;
			if(strlen(path)>=16){			
				memcpy(path_c,path,16);
				path = (char *)path_c;
			}
			add_trace_e = true;	
			time1 = sched_clock();
			AddIOTrace(IO_LOGGER_MSG_VFS_INTFS,vfs_read,path,(u32)count);
		}
	}
}
#endif
	ret = rw_verify_area(READ, file, pos, count);
	if (ret >= 0) {
		count = ret;
		if (file->f_op->read)
			ret = file->f_op->read(file, buf, count, pos);
		else
			ret = do_sync_read(file, buf, count, pos);
		if (ret > 0) {
			fsnotify_access(file);
			add_rchar(current, ret);
		}
		inc_syscr(current);
	}
#if IO_LOGGER_ENABLE
		if(unlikely(en_IOLogger()) && add_trace_e){
			timeoffset = sched_clock() - time1;
			add_trace_e = false;
			if(BEYOND_TRACE_LOG_TIME(timeoffset))
			{
				 AddIOTrace(IO_LOGGER_MSG_VFS_INTFS_END,vfs_read,path,ret,timeoffset);	
				 if(BEYOND_DUMP_LOG_TIME(timeoffset))
					DumpIOTrace(timeoffset);				
			}
		}
#endif
	return ret;
}