Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

aio: Kill aio_rw_vect_retry()

This code doesn't serve any purpose anymore, since the aio retry
infrastructure has been removed.

This change should be safe because aio_read/write are also used for
synchronous IO, and called from do_sync_read()/do_sync_write() - and
there's no looping done in the sync case (the read and write syscalls).

Signed-off-by: Kent Overstreet <koverstreet@google.com>
Cc: Zach Brown <zab@redhat.com>
Cc: Felipe Balbi <balbi@ti.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Mark Fasheh <mfasheh@suse.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Asai Thambi S P <asamymuthupa@micron.com>
Cc: Selvan Mani <smani@micron.com>
Cc: Sam Bradshaw <sbradshaw@micron.com>
Cc: Jeff Moyer <jmoyer@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Benjamin LaHaise <bcrl@kvack.org>
Signed-off-by: Benjamin LaHaise <bcrl@kvack.org>

authored by

Kent Overstreet and committed by
Benjamin LaHaise
73a7075e 5ffac122

+28 -90
+1 -1
drivers/staging/android/logger.c
··· 481 481 header.sec = now.tv_sec; 482 482 header.nsec = now.tv_nsec; 483 483 header.euid = current_euid(); 484 - header.len = min_t(size_t, iocb->ki_left, LOGGER_ENTRY_MAX_PAYLOAD); 484 + header.len = min_t(size_t, iocb->ki_nbytes, LOGGER_ENTRY_MAX_PAYLOAD); 485 485 header.hdr_size = sizeof(struct logger_entry); 486 486 487 487 /* null writes succeed, return zero */
+3 -3
drivers/usb/gadget/inode.c
··· 708 708 if (unlikely(usb_endpoint_dir_in(&epdata->desc))) 709 709 return -EINVAL; 710 710 711 - buf = kmalloc(iocb->ki_left, GFP_KERNEL); 711 + buf = kmalloc(iocb->ki_nbytes, GFP_KERNEL); 712 712 if (unlikely(!buf)) 713 713 return -ENOMEM; 714 714 715 - return ep_aio_rwtail(iocb, buf, iocb->ki_left, epdata, iov, nr_segs); 715 + return ep_aio_rwtail(iocb, buf, iocb->ki_nbytes, epdata, iov, nr_segs); 716 716 } 717 717 718 718 static ssize_t ··· 727 727 if (unlikely(!usb_endpoint_dir_in(&epdata->desc))) 728 728 return -EINVAL; 729 729 730 - buf = kmalloc(iocb->ki_left, GFP_KERNEL); 730 + buf = kmalloc(iocb->ki_nbytes, GFP_KERNEL); 731 731 if (unlikely(!buf)) 732 732 return -ENOMEM; 733 733
+18 -73
fs/aio.c
··· 707 707 if (unlikely(!req)) 708 708 goto out_put; 709 709 710 - atomic_set(&req->ki_users, 2); 710 + atomic_set(&req->ki_users, 1); 711 711 req->ki_ctx = ctx; 712 712 return req; 713 713 out_put: ··· 1051 1051 return -EINVAL; 1052 1052 } 1053 1053 1054 - static void aio_advance_iovec(struct kiocb *iocb, ssize_t ret) 1055 - { 1056 - struct iovec *iov = &iocb->ki_iovec[iocb->ki_cur_seg]; 1057 - 1058 - BUG_ON(ret <= 0); 1059 - 1060 - while (iocb->ki_cur_seg < iocb->ki_nr_segs && ret > 0) { 1061 - ssize_t this = min((ssize_t)iov->iov_len, ret); 1062 - iov->iov_base += this; 1063 - iov->iov_len -= this; 1064 - iocb->ki_left -= this; 1065 - ret -= this; 1066 - if (iov->iov_len == 0) { 1067 - iocb->ki_cur_seg++; 1068 - iov++; 1069 - } 1070 - } 1071 - 1072 - /* the caller should not have done more io than what fit in 1073 - * the remaining iovecs */ 1074 - BUG_ON(ret > 0 && iocb->ki_left == 0); 1075 - } 1076 - 1077 1054 typedef ssize_t (aio_rw_op)(struct kiocb *, const struct iovec *, 1078 1055 unsigned long, loff_t); 1079 - 1080 - static ssize_t aio_rw_vect_retry(struct kiocb *iocb, int rw, aio_rw_op *rw_op) 1081 - { 1082 - struct file *file = iocb->ki_filp; 1083 - struct address_space *mapping = file->f_mapping; 1084 - struct inode *inode = mapping->host; 1085 - ssize_t ret = 0; 1086 - 1087 - /* This matches the pread()/pwrite() logic */ 1088 - if (iocb->ki_pos < 0) 1089 - return -EINVAL; 1090 - 1091 - if (rw == WRITE) 1092 - file_start_write(file); 1093 - do { 1094 - ret = rw_op(iocb, &iocb->ki_iovec[iocb->ki_cur_seg], 1095 - iocb->ki_nr_segs - iocb->ki_cur_seg, 1096 - iocb->ki_pos); 1097 - if (ret > 0) 1098 - aio_advance_iovec(iocb, ret); 1099 - 1100 - /* retry all partial writes. retry partial reads as long as its a 1101 - * regular file. */ 1102 - } while (ret > 0 && iocb->ki_left > 0 && 1103 - (rw == WRITE || 1104 - (!S_ISFIFO(inode->i_mode) && !S_ISSOCK(inode->i_mode)))); 1105 - if (rw == WRITE) 1106 - file_end_write(file); 1107 - 1108 - /* This means we must have transferred all that we could */ 1109 - /* No need to retry anymore */ 1110 - if ((ret == 0) || (iocb->ki_left == 0)) 1111 - ret = iocb->ki_nbytes - iocb->ki_left; 1112 - 1113 - /* If we managed to write some out we return that, rather than 1114 - * the eventual error. */ 1115 - if (rw == WRITE 1116 - && ret < 0 && ret != -EIOCBQUEUED 1117 - && iocb->ki_nbytes - iocb->ki_left) 1118 - ret = iocb->ki_nbytes - iocb->ki_left; 1119 - 1120 - return ret; 1121 - } 1122 1056 1123 1057 static ssize_t aio_setup_vectored_rw(int rw, struct kiocb *kiocb, bool compat) 1124 1058 { ··· 1138 1204 return ret; 1139 1205 1140 1206 req->ki_nbytes = ret; 1141 - req->ki_left = ret; 1142 1207 1143 - ret = aio_rw_vect_retry(req, rw, rw_op); 1208 + /* XXX: move/kill - rw_verify_area()? */ 1209 + /* This matches the pread()/pwrite() logic */ 1210 + if (req->ki_pos < 0) { 1211 + ret = -EINVAL; 1212 + break; 1213 + } 1214 + 1215 + if (rw == WRITE) 1216 + file_start_write(file); 1217 + 1218 + ret = rw_op(req, req->ki_iovec, 1219 + req->ki_nr_segs, req->ki_pos); 1220 + 1221 + if (rw == WRITE) 1222 + file_end_write(file); 1144 1223 break; 1145 1224 1146 1225 case IOCB_CMD_FDSYNC: ··· 1248 1301 req->ki_pos = iocb->aio_offset; 1249 1302 1250 1303 req->ki_buf = (char __user *)(unsigned long)iocb->aio_buf; 1251 - req->ki_left = req->ki_nbytes = iocb->aio_nbytes; 1304 + req->ki_nbytes = iocb->aio_nbytes; 1252 1305 req->ki_opcode = iocb->aio_lio_opcode; 1253 1306 1254 1307 ret = aio_run_iocb(req, compat); 1255 1308 if (ret) 1256 1309 goto out_put_req; 1257 1310 1258 - aio_put_req(req); /* drop extra ref to req */ 1259 1311 return 0; 1260 1312 out_put_req: 1261 1313 put_reqs_available(ctx, 1); 1262 - aio_put_req(req); /* drop extra ref to req */ 1263 - aio_put_req(req); /* drop i/o ref to req */ 1314 + aio_put_req(req); 1264 1315 return ret; 1265 1316 } 1266 1317
+1 -1
fs/block_dev.c
··· 1542 1542 return 0; 1543 1543 1544 1544 size -= pos; 1545 - if (size < iocb->ki_left) 1545 + if (size < iocb->ki_nbytes) 1546 1546 nr_segs = iov_shorten((struct iovec *)iov, nr_segs, size); 1547 1547 return generic_file_aio_read(iocb, iov, nr_segs, pos); 1548 1548 }
-1
fs/nfs/direct.c
··· 130 130 131 131 return -EINVAL; 132 132 #else 133 - VM_BUG_ON(iocb->ki_left != PAGE_SIZE); 134 133 VM_BUG_ON(iocb->ki_nbytes != PAGE_SIZE); 135 134 136 135 if (rw == READ || rw == KERNEL_READ)
+3 -3
fs/ocfs2/file.c
··· 2245 2245 file->f_path.dentry->d_name.name, 2246 2246 (unsigned int)nr_segs); 2247 2247 2248 - if (iocb->ki_left == 0) 2248 + if (iocb->ki_nbytes == 0) 2249 2249 return 0; 2250 2250 2251 2251 appending = file->f_flags & O_APPEND ? 1 : 0; ··· 2296 2296 2297 2297 can_do_direct = direct_io; 2298 2298 ret = ocfs2_prepare_inode_for_write(file, ppos, 2299 - iocb->ki_left, appending, 2299 + iocb->ki_nbytes, appending, 2300 2300 &can_do_direct, &has_refcount); 2301 2301 if (ret < 0) { 2302 2302 mlog_errno(ret); ··· 2304 2304 } 2305 2305 2306 2306 if (direct_io && !is_sync_kiocb(iocb)) 2307 - unaligned_dio = ocfs2_is_io_unaligned(inode, iocb->ki_left, 2307 + unaligned_dio = ocfs2_is_io_unaligned(inode, iocb->ki_nbytes, 2308 2308 *ppos); 2309 2309 2310 2310 /*
-3
fs/read_write.c
··· 367 367 368 368 init_sync_kiocb(&kiocb, filp); 369 369 kiocb.ki_pos = *ppos; 370 - kiocb.ki_left = len; 371 370 kiocb.ki_nbytes = len; 372 371 373 372 ret = filp->f_op->aio_read(&kiocb, &iov, 1, kiocb.ki_pos); ··· 416 417 417 418 init_sync_kiocb(&kiocb, filp); 418 419 kiocb.ki_pos = *ppos; 419 - kiocb.ki_left = len; 420 420 kiocb.ki_nbytes = len; 421 421 422 422 ret = filp->f_op->aio_write(&kiocb, &iov, 1, kiocb.ki_pos); ··· 597 599 598 600 init_sync_kiocb(&kiocb, filp); 599 601 kiocb.ki_pos = *ppos; 600 - kiocb.ki_left = len; 601 602 kiocb.ki_nbytes = len; 602 603 603 604 ret = fn(&kiocb, iov, nr_segs, kiocb.ki_pos);
+1 -1
fs/udf/file.c
··· 141 141 struct file *file = iocb->ki_filp; 142 142 struct inode *inode = file_inode(file); 143 143 int err, pos; 144 - size_t count = iocb->ki_left; 144 + size_t count = iocb->ki_nbytes; 145 145 struct udf_inode_info *iinfo = UDF_I(inode); 146 146 147 147 down_write(&iinfo->i_data_sem);
-2
include/linux/aio.h
··· 50 50 unsigned short ki_opcode; 51 51 size_t ki_nbytes; /* copy of iocb->aio_nbytes */ 52 52 char __user *ki_buf; /* remaining iocb->aio_buf */ 53 - size_t ki_left; /* remaining bytes */ 54 53 struct iovec ki_inline_vec; /* inline vector */ 55 54 struct iovec *ki_iovec; 56 55 unsigned long ki_nr_segs; 57 - unsigned long ki_cur_seg; 58 56 59 57 struct list_head ki_list; /* the aio core uses this 60 58 * for cancellation */
-1
mm/page_io.c
··· 266 266 267 267 init_sync_kiocb(&kiocb, swap_file); 268 268 kiocb.ki_pos = page_file_offset(page); 269 - kiocb.ki_left = PAGE_SIZE; 270 269 kiocb.ki_nbytes = PAGE_SIZE; 271 270 272 271 set_page_writeback(page);
+1 -1
net/socket.c
··· 931 931 if (pos != 0) 932 932 return -ESPIPE; 933 933 934 - if (iocb->ki_left == 0) /* Match SYS5 behaviour */ 934 + if (iocb->ki_nbytes == 0) /* Match SYS5 behaviour */ 935 935 return 0; 936 936 937 937