mirror of
https://github.com/schoebel/mars
synced 2025-02-04 14:21:50 +00:00
all: adapt to kernel_{read,write}
This commit is contained in:
parent
1af680f0bc
commit
73a4b330d1
@ -662,13 +662,19 @@ static
|
||||
void out_to_file(struct file *file, char *buf, int len)
|
||||
{
|
||||
loff_t log_pos = 0;
|
||||
mm_segment_t oldfs;
|
||||
|
||||
if (file) {
|
||||
oldfs = get_fs();
|
||||
#ifdef MARS_HAS_KERNEL_READ
|
||||
(void)kernel_write(file,
|
||||
buf,
|
||||
len,
|
||||
&log_pos);
|
||||
#else
|
||||
mm_segment_t oldfs = get_fs();
|
||||
set_fs(get_ds());
|
||||
(void)vfs_write(file, buf, len, &log_pos);
|
||||
set_fs(oldfs);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -166,6 +166,18 @@ extern int _compat_unlink(
|
||||
#define MARS_HAS_NEW_GENERIC_BLK_ACCOUNTING
|
||||
#endif
|
||||
|
||||
/* vfs stuff */
|
||||
|
||||
/* Adapt to
|
||||
* eb031849d52e61d24ba54e9d27553189ff328174 and siblings
|
||||
* bdd1d2d3d251c65b74ac4493e08db18971c09240
|
||||
* e13ec939e96b13e664bb6cee361cc976a0ee621a
|
||||
* detected via e462ec50cb5fad19f6003a3d8087f4a0945dd2b1
|
||||
*/
|
||||
#ifdef SB_RDONLY
|
||||
#define MARS_HAS_KERNEL_READ
|
||||
#endif
|
||||
|
||||
/* for mm stuff, should disappear */
|
||||
|
||||
/* adapt to 68e21be2916b359fd8afb536c1911dc014cfd03e
|
||||
|
@ -230,9 +230,17 @@ loff_t mars_log_pos = 0;
|
||||
void _mars_log(char *buf, int len)
|
||||
{
|
||||
static DEFINE_MUTEX(trace_lock);
|
||||
|
||||
#ifdef MARS_HAS_KERNEL_READ
|
||||
mutex_lock(&trace_lock);
|
||||
(void)kernel_write(mars_log_file,
|
||||
buf,
|
||||
len,
|
||||
&mars_log_pos);
|
||||
mutex_unlock(&trace_lock);
|
||||
#else
|
||||
mm_segment_t oldfs;
|
||||
|
||||
|
||||
oldfs = get_fs();
|
||||
set_fs(get_ds());
|
||||
mutex_lock(&trace_lock);
|
||||
@ -241,6 +249,7 @@ void _mars_log(char *buf, int len)
|
||||
|
||||
mutex_unlock(&trace_lock);
|
||||
set_fs(oldfs);
|
||||
#endif
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(_mars_log);
|
||||
|
||||
|
@ -132,6 +132,7 @@ static void sio_ref_put(struct sio_output *output, struct mref_object *mref)
|
||||
sio_free_mref(mref);
|
||||
}
|
||||
|
||||
#ifndef MARS_HAS_KERNEL_READ
|
||||
// some code borrowed from the loopback driver
|
||||
|
||||
static int transfer_none(int cmd,
|
||||
@ -156,6 +157,7 @@ static int transfer_none(int cmd,
|
||||
cond_resched();
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static
|
||||
int write_aops(struct sio_output *output, struct mref_object *mref)
|
||||
@ -166,7 +168,12 @@ int write_aops(struct sio_output *output, struct mref_object *mref)
|
||||
int len = mref->ref_len;
|
||||
int ret = 0;
|
||||
|
||||
|
||||
#ifdef MARS_HAS_KERNEL_READ
|
||||
ret = kernel_write(file,
|
||||
data,
|
||||
len,
|
||||
&pos);
|
||||
#else
|
||||
#ifdef USE_VFS_WRITE
|
||||
mm_segment_t oldfs;
|
||||
|
||||
@ -239,6 +246,7 @@ fail:
|
||||
#if 1
|
||||
blk_run_address_space(mapping);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
@ -248,6 +256,7 @@ struct cookie_data {
|
||||
struct mref_object *mref;
|
||||
};
|
||||
|
||||
#ifndef MARS_HAS_KERNEL_READ
|
||||
static int
|
||||
sio_splice_actor(struct pipe_inode_info *pipe,
|
||||
struct pipe_buffer *buf,
|
||||
@ -283,6 +292,7 @@ sio_direct_splice_actor(struct pipe_inode_info *pipe, struct splice_desc *sd)
|
||||
{
|
||||
return __splice_from_pipe(pipe, sd, sio_splice_actor);
|
||||
}
|
||||
#endif
|
||||
|
||||
static
|
||||
int read_aops(struct sio_output *output, struct mref_object *mref)
|
||||
@ -291,6 +301,12 @@ int read_aops(struct sio_output *output, struct mref_object *mref)
|
||||
int len = mref->ref_len;
|
||||
int ret;
|
||||
|
||||
#ifdef MARS_HAS_KERNEL_READ
|
||||
ret = kernel_read(output->mf->mf_filp,
|
||||
mref->ref_data,
|
||||
len,
|
||||
&pos);
|
||||
#else
|
||||
#ifdef USE_VFS_READ
|
||||
mm_segment_t oldfs;
|
||||
(void) sio_direct_splice_actor; // shut up gcc
|
||||
@ -313,6 +329,7 @@ int read_aops(struct sio_output *output, struct mref_object *mref)
|
||||
};
|
||||
|
||||
ret = splice_direct_to_actor(output->mf->mf_filp, &sd, sio_direct_splice_actor);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (unlikely(ret < 0)) {
|
||||
|
Loading…
Reference in New Issue
Block a user