forked from luck/tmp_suning_uos_patched
Merge git://git.kvack.org/~bcrl/aio-next
Pull aio changes from Ben LaHaise: "First off, sorry for this pull request being late in the merge window. Al had raised a couple of concerns about 2 items in the series below. I addressed the first issue (the race introduced by Gu's use of mm_populate()), but he has not provided any further details on how he wants to rework the anon_inode.c changes (which were sent out months ago but have yet to be commented on). The bulk of the changes have been sitting in the -next tree for a few months, with all the issues raised being addressed" * git://git.kvack.org/~bcrl/aio-next: (22 commits) aio: rcu_read_lock protection for new rcu_dereference calls aio: fix race in ring buffer page lookup introduced by page migration support aio: fix rcu sparse warnings introduced by ioctx table lookup patch aio: remove unnecessary debugging from aio_free_ring() aio: table lookup: verify ctx pointer staging/lustre: kiocb->ki_left is removed aio: fix error handling and rcu usage in "convert the ioctx list to table lookup v3" aio: be defensive to ensure request batching is non-zero instead of BUG_ON() aio: convert the ioctx list to table lookup v3 aio: double aio_max_nr in calculations aio: Kill ki_dtor aio: Kill ki_users aio: Kill unneeded kiocb members aio: Kill aio_rw_vect_retry() aio: Don't use ctx->tail unnecessarily aio: io_cancel() no longer returns the io_event aio: percpu ioctx refcount aio: percpu reqs_available aio: reqs_active -> reqs_available aio: fix build when migration is disabled ...
This commit is contained in:
commit
9bf12df31f
|
@ -481,7 +481,7 @@ static ssize_t logger_aio_write(struct kiocb *iocb, const struct iovec *iov,
|
|||
header.sec = now.tv_sec;
|
||||
header.nsec = now.tv_nsec;
|
||||
header.euid = current_euid();
|
||||
header.len = min_t(size_t, iocb->ki_left, LOGGER_ENTRY_MAX_PAYLOAD);
|
||||
header.len = min_t(size_t, iocb->ki_nbytes, LOGGER_ENTRY_MAX_PAYLOAD);
|
||||
header.hdr_size = sizeof(struct logger_entry);
|
||||
|
||||
/* null writes succeed, return zero */
|
||||
|
|
|
@ -1009,7 +1009,7 @@ static ssize_t ll_file_read(struct file *file, char *buf, size_t count,
|
|||
local_iov->iov_len = count;
|
||||
init_sync_kiocb(kiocb, file);
|
||||
kiocb->ki_pos = *ppos;
|
||||
kiocb->ki_left = count;
|
||||
kiocb->ki_nbytes = count;
|
||||
|
||||
result = ll_file_aio_read(kiocb, local_iov, 1, kiocb->ki_pos);
|
||||
*ppos = kiocb->ki_pos;
|
||||
|
@ -1068,7 +1068,7 @@ static ssize_t ll_file_write(struct file *file, const char *buf, size_t count,
|
|||
local_iov->iov_len = count;
|
||||
init_sync_kiocb(kiocb, file);
|
||||
kiocb->ki_pos = *ppos;
|
||||
kiocb->ki_left = count;
|
||||
kiocb->ki_nbytes = count;
|
||||
|
||||
result = ll_file_aio_write(kiocb, local_iov, 1, kiocb->ki_pos);
|
||||
*ppos = kiocb->ki_pos;
|
||||
|
|
|
@ -524,7 +524,7 @@ struct kiocb_priv {
|
|||
unsigned actual;
|
||||
};
|
||||
|
||||
static int ep_aio_cancel(struct kiocb *iocb, struct io_event *e)
|
||||
static int ep_aio_cancel(struct kiocb *iocb)
|
||||
{
|
||||
struct kiocb_priv *priv = iocb->private;
|
||||
struct ep_data *epdata;
|
||||
|
@ -540,7 +540,6 @@ static int ep_aio_cancel(struct kiocb *iocb, struct io_event *e)
|
|||
// spin_unlock(&epdata->dev->lock);
|
||||
local_irq_enable();
|
||||
|
||||
aio_put_req(iocb);
|
||||
return value;
|
||||
}
|
||||
|
||||
|
@ -709,11 +708,11 @@ ep_aio_read(struct kiocb *iocb, const struct iovec *iov,
|
|||
if (unlikely(usb_endpoint_dir_in(&epdata->desc)))
|
||||
return -EINVAL;
|
||||
|
||||
buf = kmalloc(iocb->ki_left, GFP_KERNEL);
|
||||
buf = kmalloc(iocb->ki_nbytes, GFP_KERNEL);
|
||||
if (unlikely(!buf))
|
||||
return -ENOMEM;
|
||||
|
||||
return ep_aio_rwtail(iocb, buf, iocb->ki_left, epdata, iov, nr_segs);
|
||||
return ep_aio_rwtail(iocb, buf, iocb->ki_nbytes, epdata, iov, nr_segs);
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
|
@ -728,7 +727,7 @@ ep_aio_write(struct kiocb *iocb, const struct iovec *iov,
|
|||
if (unlikely(!usb_endpoint_dir_in(&epdata->desc)))
|
||||
return -EINVAL;
|
||||
|
||||
buf = kmalloc(iocb->ki_left, GFP_KERNEL);
|
||||
buf = kmalloc(iocb->ki_nbytes, GFP_KERNEL);
|
||||
if (unlikely(!buf))
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
|
@ -108,6 +108,72 @@ static struct file_system_type anon_inode_fs_type = {
|
|||
.kill_sb = kill_anon_super,
|
||||
};
|
||||
|
||||
/**
|
||||
* anon_inode_getfile_private - creates a new file instance by hooking it up to an
|
||||
* anonymous inode, and a dentry that describe the "class"
|
||||
* of the file
|
||||
*
|
||||
* @name: [in] name of the "class" of the new file
|
||||
* @fops: [in] file operations for the new file
|
||||
* @priv: [in] private data for the new file (will be file's private_data)
|
||||
* @flags: [in] flags
|
||||
*
|
||||
*
|
||||
* Similar to anon_inode_getfile, but each file holds a single inode.
|
||||
*
|
||||
*/
|
||||
struct file *anon_inode_getfile_private(const char *name,
|
||||
const struct file_operations *fops,
|
||||
void *priv, int flags)
|
||||
{
|
||||
struct qstr this;
|
||||
struct path path;
|
||||
struct file *file;
|
||||
struct inode *inode;
|
||||
|
||||
if (fops->owner && !try_module_get(fops->owner))
|
||||
return ERR_PTR(-ENOENT);
|
||||
|
||||
inode = anon_inode_mkinode(anon_inode_mnt->mnt_sb);
|
||||
if (IS_ERR(inode)) {
|
||||
file = ERR_PTR(-ENOMEM);
|
||||
goto err_module;
|
||||
}
|
||||
|
||||
/*
|
||||
* Link the inode to a directory entry by creating a unique name
|
||||
* using the inode sequence number.
|
||||
*/
|
||||
file = ERR_PTR(-ENOMEM);
|
||||
this.name = name;
|
||||
this.len = strlen(name);
|
||||
this.hash = 0;
|
||||
path.dentry = d_alloc_pseudo(anon_inode_mnt->mnt_sb, &this);
|
||||
if (!path.dentry)
|
||||
goto err_module;
|
||||
|
||||
path.mnt = mntget(anon_inode_mnt);
|
||||
|
||||
d_instantiate(path.dentry, inode);
|
||||
|
||||
file = alloc_file(&path, OPEN_FMODE(flags), fops);
|
||||
if (IS_ERR(file))
|
||||
goto err_dput;
|
||||
|
||||
file->f_mapping = inode->i_mapping;
|
||||
file->f_flags = flags & (O_ACCMODE | O_NONBLOCK);
|
||||
file->private_data = priv;
|
||||
|
||||
return file;
|
||||
|
||||
err_dput:
|
||||
path_put(&path);
|
||||
err_module:
|
||||
module_put(fops->owner);
|
||||
return file;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(anon_inode_getfile_private);
|
||||
|
||||
/**
|
||||
* anon_inode_getfile - creates a new file instance by hooking it up to an
|
||||
* anonymous inode, and a dentry that describe the "class"
|
||||
|
|
|
@ -1542,7 +1542,7 @@ static ssize_t blkdev_aio_read(struct kiocb *iocb, const struct iovec *iov,
|
|||
return 0;
|
||||
|
||||
size -= pos;
|
||||
if (size < iocb->ki_left)
|
||||
if (size < iocb->ki_nbytes)
|
||||
nr_segs = iov_shorten((struct iovec *)iov, nr_segs, size);
|
||||
return generic_file_aio_read(iocb, iov, nr_segs, pos);
|
||||
}
|
||||
|
|
|
@ -130,7 +130,6 @@ ssize_t nfs_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov, loff_
|
|||
|
||||
return -EINVAL;
|
||||
#else
|
||||
VM_BUG_ON(iocb->ki_left != PAGE_SIZE);
|
||||
VM_BUG_ON(iocb->ki_nbytes != PAGE_SIZE);
|
||||
|
||||
if (rw == READ || rw == KERNEL_READ)
|
||||
|
|
|
@ -2242,7 +2242,7 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb,
|
|||
file->f_path.dentry->d_name.name,
|
||||
(unsigned int)nr_segs);
|
||||
|
||||
if (iocb->ki_left == 0)
|
||||
if (iocb->ki_nbytes == 0)
|
||||
return 0;
|
||||
|
||||
appending = file->f_flags & O_APPEND ? 1 : 0;
|
||||
|
@ -2293,7 +2293,7 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb,
|
|||
|
||||
can_do_direct = direct_io;
|
||||
ret = ocfs2_prepare_inode_for_write(file, ppos,
|
||||
iocb->ki_left, appending,
|
||||
iocb->ki_nbytes, appending,
|
||||
&can_do_direct, &has_refcount);
|
||||
if (ret < 0) {
|
||||
mlog_errno(ret);
|
||||
|
@ -2301,7 +2301,7 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb,
|
|||
}
|
||||
|
||||
if (direct_io && !is_sync_kiocb(iocb))
|
||||
unaligned_dio = ocfs2_is_io_unaligned(inode, iocb->ki_left,
|
||||
unaligned_dio = ocfs2_is_io_unaligned(inode, iocb->ki_nbytes,
|
||||
*ppos);
|
||||
|
||||
/*
|
||||
|
|
|
@ -367,7 +367,6 @@ ssize_t do_sync_read(struct file *filp, char __user *buf, size_t len, loff_t *pp
|
|||
|
||||
init_sync_kiocb(&kiocb, filp);
|
||||
kiocb.ki_pos = *ppos;
|
||||
kiocb.ki_left = len;
|
||||
kiocb.ki_nbytes = len;
|
||||
|
||||
ret = filp->f_op->aio_read(&kiocb, &iov, 1, kiocb.ki_pos);
|
||||
|
@ -417,7 +416,6 @@ ssize_t do_sync_write(struct file *filp, const char __user *buf, size_t len, lof
|
|||
|
||||
init_sync_kiocb(&kiocb, filp);
|
||||
kiocb.ki_pos = *ppos;
|
||||
kiocb.ki_left = len;
|
||||
kiocb.ki_nbytes = len;
|
||||
|
||||
ret = filp->f_op->aio_write(&kiocb, &iov, 1, kiocb.ki_pos);
|
||||
|
@ -599,7 +597,6 @@ static ssize_t do_sync_readv_writev(struct file *filp, const struct iovec *iov,
|
|||
|
||||
init_sync_kiocb(&kiocb, filp);
|
||||
kiocb.ki_pos = *ppos;
|
||||
kiocb.ki_left = len;
|
||||
kiocb.ki_nbytes = len;
|
||||
|
||||
ret = fn(&kiocb, iov, nr_segs, kiocb.ki_pos);
|
||||
|
|
|
@ -141,7 +141,7 @@ static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
|
|||
struct file *file = iocb->ki_filp;
|
||||
struct inode *inode = file_inode(file);
|
||||
int err, pos;
|
||||
size_t count = iocb->ki_left;
|
||||
size_t count = iocb->ki_nbytes;
|
||||
struct udf_inode_info *iinfo = UDF_I(inode);
|
||||
|
||||
down_write(&iinfo->i_data_sem);
|
||||
|
|
|
@ -27,15 +27,13 @@ struct kiocb;
|
|||
*/
|
||||
#define KIOCB_CANCELLED ((void *) (~0ULL))
|
||||
|
||||
typedef int (kiocb_cancel_fn)(struct kiocb *, struct io_event *);
|
||||
typedef int (kiocb_cancel_fn)(struct kiocb *);
|
||||
|
||||
struct kiocb {
|
||||
atomic_t ki_users;
|
||||
|
||||
struct file *ki_filp;
|
||||
struct kioctx *ki_ctx; /* NULL for sync ops */
|
||||
kiocb_cancel_fn *ki_cancel;
|
||||
void (*ki_dtor)(struct kiocb *);
|
||||
void *private;
|
||||
|
||||
union {
|
||||
void __user *user;
|
||||
|
@ -44,17 +42,7 @@ struct kiocb {
|
|||
|
||||
__u64 ki_user_data; /* user's data for completion */
|
||||
loff_t ki_pos;
|
||||
|
||||
void *private;
|
||||
/* State that we remember to be able to restart/retry */
|
||||
unsigned short ki_opcode;
|
||||
size_t ki_nbytes; /* copy of iocb->aio_nbytes */
|
||||
char __user *ki_buf; /* remaining iocb->aio_buf */
|
||||
size_t ki_left; /* remaining bytes */
|
||||
struct iovec ki_inline_vec; /* inline vector */
|
||||
struct iovec *ki_iovec;
|
||||
unsigned long ki_nr_segs;
|
||||
unsigned long ki_cur_seg;
|
||||
size_t ki_nbytes; /* copy of iocb->aio_nbytes */
|
||||
|
||||
struct list_head ki_list; /* the aio core uses this
|
||||
* for cancellation */
|
||||
|
@ -74,7 +62,6 @@ static inline bool is_sync_kiocb(struct kiocb *kiocb)
|
|||
static inline void init_sync_kiocb(struct kiocb *kiocb, struct file *filp)
|
||||
{
|
||||
*kiocb = (struct kiocb) {
|
||||
.ki_users = ATOMIC_INIT(1),
|
||||
.ki_ctx = NULL,
|
||||
.ki_filp = filp,
|
||||
.ki_obj.tsk = current,
|
||||
|
@ -84,7 +71,6 @@ static inline void init_sync_kiocb(struct kiocb *kiocb, struct file *filp)
|
|||
/* prototypes */
|
||||
#ifdef CONFIG_AIO
|
||||
extern ssize_t wait_on_sync_kiocb(struct kiocb *iocb);
|
||||
extern void aio_put_req(struct kiocb *iocb);
|
||||
extern void aio_complete(struct kiocb *iocb, long res, long res2);
|
||||
struct mm_struct;
|
||||
extern void exit_aio(struct mm_struct *mm);
|
||||
|
@ -93,7 +79,6 @@ extern long do_io_submit(aio_context_t ctx_id, long nr,
|
|||
void kiocb_set_cancel_fn(struct kiocb *req, kiocb_cancel_fn *cancel);
|
||||
#else
|
||||
static inline ssize_t wait_on_sync_kiocb(struct kiocb *iocb) { return 0; }
|
||||
static inline void aio_put_req(struct kiocb *iocb) { }
|
||||
static inline void aio_complete(struct kiocb *iocb, long res, long res2) { }
|
||||
struct mm_struct;
|
||||
static inline void exit_aio(struct mm_struct *mm) { }
|
||||
|
|
|
@ -13,6 +13,9 @@ struct file_operations;
|
|||
struct file *anon_inode_getfile(const char *name,
|
||||
const struct file_operations *fops,
|
||||
void *priv, int flags);
|
||||
struct file *anon_inode_getfile_private(const char *name,
|
||||
const struct file_operations *fops,
|
||||
void *priv, int flags);
|
||||
int anon_inode_getfd(const char *name, const struct file_operations *fops,
|
||||
void *priv, int flags);
|
||||
|
||||
|
|
|
@ -53,6 +53,9 @@ extern int migrate_vmas(struct mm_struct *mm,
|
|||
extern void migrate_page_copy(struct page *newpage, struct page *page);
|
||||
extern int migrate_huge_page_move_mapping(struct address_space *mapping,
|
||||
struct page *newpage, struct page *page);
|
||||
extern int migrate_page_move_mapping(struct address_space *mapping,
|
||||
struct page *newpage, struct page *page,
|
||||
struct buffer_head *head, enum migrate_mode mode);
|
||||
#else
|
||||
|
||||
static inline void putback_lru_pages(struct list_head *l) {}
|
||||
|
|
|
@ -322,6 +322,7 @@ struct mm_rss_stat {
|
|||
atomic_long_t count[NR_MM_COUNTERS];
|
||||
};
|
||||
|
||||
struct kioctx_table;
|
||||
struct mm_struct {
|
||||
struct vm_area_struct * mmap; /* list of VMAs */
|
||||
struct rb_root mm_rb;
|
||||
|
@ -383,8 +384,8 @@ struct mm_struct {
|
|||
|
||||
struct core_state *core_state; /* coredumping support */
|
||||
#ifdef CONFIG_AIO
|
||||
spinlock_t ioctx_lock;
|
||||
struct hlist_head ioctx_list;
|
||||
spinlock_t ioctx_lock;
|
||||
struct kioctx_table __rcu *ioctx_table;
|
||||
#endif
|
||||
#ifdef CONFIG_MM_OWNER
|
||||
/*
|
||||
|
|
|
@ -519,7 +519,7 @@ static void mm_init_aio(struct mm_struct *mm)
|
|||
{
|
||||
#ifdef CONFIG_AIO
|
||||
spin_lock_init(&mm->ioctx_lock);
|
||||
INIT_HLIST_HEAD(&mm->ioctx_list);
|
||||
mm->ioctx_table = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -311,7 +311,7 @@ static inline bool buffer_migrate_lock_buffers(struct buffer_head *head,
|
|||
* 2 for pages with a mapping
|
||||
* 3 for pages with a mapping and PagePrivate/PagePrivate2 set.
|
||||
*/
|
||||
static int migrate_page_move_mapping(struct address_space *mapping,
|
||||
int migrate_page_move_mapping(struct address_space *mapping,
|
||||
struct page *newpage, struct page *page,
|
||||
struct buffer_head *head, enum migrate_mode mode)
|
||||
{
|
||||
|
|
|
@ -266,7 +266,6 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
|
|||
|
||||
init_sync_kiocb(&kiocb, swap_file);
|
||||
kiocb.ki_pos = page_file_offset(page);
|
||||
kiocb.ki_left = PAGE_SIZE;
|
||||
kiocb.ki_nbytes = PAGE_SIZE;
|
||||
|
||||
set_page_writeback(page);
|
||||
|
|
15
net/socket.c
15
net/socket.c
|
@ -854,11 +854,6 @@ int kernel_recvmsg(struct socket *sock, struct msghdr *msg,
|
|||
}
|
||||
EXPORT_SYMBOL(kernel_recvmsg);
|
||||
|
||||
static void sock_aio_dtor(struct kiocb *iocb)
|
||||
{
|
||||
kfree(iocb->private);
|
||||
}
|
||||
|
||||
static ssize_t sock_sendpage(struct file *file, struct page *page,
|
||||
int offset, size_t size, loff_t *ppos, int more)
|
||||
{
|
||||
|
@ -889,12 +884,8 @@ static ssize_t sock_splice_read(struct file *file, loff_t *ppos,
|
|||
static struct sock_iocb *alloc_sock_iocb(struct kiocb *iocb,
|
||||
struct sock_iocb *siocb)
|
||||
{
|
||||
if (!is_sync_kiocb(iocb)) {
|
||||
siocb = kmalloc(sizeof(*siocb), GFP_KERNEL);
|
||||
if (!siocb)
|
||||
return NULL;
|
||||
iocb->ki_dtor = sock_aio_dtor;
|
||||
}
|
||||
if (!is_sync_kiocb(iocb))
|
||||
BUG();
|
||||
|
||||
siocb->kiocb = iocb;
|
||||
iocb->private = siocb;
|
||||
|
@ -931,7 +922,7 @@ static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
|
|||
if (pos != 0)
|
||||
return -ESPIPE;
|
||||
|
||||
if (iocb->ki_left == 0) /* Match SYS5 behaviour */
|
||||
if (iocb->ki_nbytes == 0) /* Match SYS5 behaviour */
|
||||
return 0;
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user