Merge branch 'work.sendmsg' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 2 Mar 2017 23:16:38 +0000 (15:16 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 2 Mar 2017 23:16:38 +0000 (15:16 -0800)
Pull vfs sendmsg updates from Al Viro:
 "More sendmsg work.

  This is a fairly separate isolated stuff (there's a continuation
  around lustre, but that one was too late to soak in -next), thus the
  separate pull request"

* 'work.sendmsg' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  ncpfs: switch to sock_sendmsg()
  ncpfs: don't mess with manually advancing iovec on send
  ncpfs: sendmsg does *not* bugger iovec these days
  ceph_tcp_sendpage(): use ITER_BVEC sendmsg
  afs_send_pages(): use ITER_BVEC
  rds: remove dead code
  ceph: switch to sock_recvmsg()
  usbip_recv(): switch to sock_recvmsg()
  iscsi_target: deal with short writes on the tx side
  [nbd] pass iov_iter to nbd_xmit()
  [nbd] switch sock_xmit() to sock_{send,recv}msg()
  [drbd] use sock_sendmsg()

1  2 
drivers/block/drbd/drbd_main.c
drivers/block/nbd.c
drivers/target/iscsi/iscsi_target_util.c
drivers/usb/usbip/usbip_common.c
fs/afs/rxrpc.c
fs/ncpfs/sock.c
net/ceph/messenger.c
net/rds/rds.h

Simple merge
index 0bf2b21a62cb770a3129889b59a0b5f735eddc52,3c2dbe412c0235ef98664a39b2e239bef8e6f574..1541cb880744cbfe2ad00c9d8532bcc5b2ad2f69
@@@ -263,39 -256,26 +248,41 @@@ static int sock_xmit(struct nbd_device 
  static int nbd_send_cmd(struct nbd_device *nbd, struct nbd_cmd *cmd, int index)
  {
        struct request *req = blk_mq_rq_from_pdu(cmd);
 -      int result, flags;
 +      int result;
-       struct nbd_request request;
+       struct nbd_request request = {.magic = htonl(NBD_REQUEST_MAGIC)};
+       struct kvec iov = {.iov_base = &request, .iov_len = sizeof(request)};
+       struct iov_iter from;
        unsigned long size = blk_rq_bytes(req);
        struct bio *bio;
        u32 type;
        u32 tag = blk_mq_unique_tag(req);
  
 -      if (req_op(req) == REQ_OP_DISCARD)
+       iov_iter_kvec(&from, WRITE | ITER_KVEC, &iov, 1, sizeof(request));
 +      switch (req_op(req)) {
 +      case REQ_OP_DISCARD:
                type = NBD_CMD_TRIM;
 -      else if (req_op(req) == REQ_OP_FLUSH)
 +              break;
 +      case REQ_OP_FLUSH:
                type = NBD_CMD_FLUSH;
 -      else if (rq_data_dir(req) == WRITE)
 +              break;
 +      case REQ_OP_WRITE:
                type = NBD_CMD_WRITE;
 -      else
 +              break;
 +      case REQ_OP_READ:
                type = NBD_CMD_READ;
 +              break;
 +      default:
 +              return -EIO;
 +      }
 +
 +      if (rq_data_dir(req) == WRITE &&
 +          (nbd->flags & NBD_FLAG_READ_ONLY)) {
 +              dev_err_ratelimited(disk_to_dev(nbd->disk),
 +                                  "Write on read-only\n");
 +              return -EIO;
 +      }
  
-       memset(&request, 0, sizeof(request));
-       request.magic = htonl(NBD_REQUEST_MAGIC);
        request.type = htonl(type);
        if (type != NBD_CMD_FLUSH) {
                request.from = cpu_to_be64((u64)blk_rq_pos(req) << 9);
  
                bio_for_each_segment(bvec, bio, iter) {
                        bool is_last = !next && bio_iter_last(bvec, iter);
 +                      int flags = is_last ? 0 : MSG_MORE;
  
 -                      if (is_last)
 -                              flags = MSG_MORE;
                        dev_dbg(nbd_to_dev(nbd), "request %p: sending %d bytes data\n",
                                cmd, bvec.bv_len);
-                       result = sock_send_bvec(nbd, index, &bvec, flags);
+                       iov_iter_bvec(&from, ITER_BVEC | WRITE,
+                                     &bvec, 1, bvec.bv_len);
+                       result = sock_xmit(nbd, index, 1, &from, flags);
                        if (result <= 0) {
                                dev_err(disk_to_dev(nbd->disk),
                                        "Send data failed (result %d)\n",
index cc59588824313fc3d79c259726f966c8a084884f,a9ba2479374f52863757b195d714198d6540ed70..5041a9c8bdcbfd9bf9eb9368e850bdb8792a6be9
@@@ -1369,15 -1336,58 +1337,31 @@@ int tx_data
        if (!conn || !conn->sock || !conn->conn_ops)
                return -1;
  
-       memset(&c, 0, sizeof(struct iscsi_data_count));
-       c.iov = iov;
-       c.iov_count = iov_count;
-       c.data_length = data;
-       c.type = ISCSI_TX_DATA;
+       if (data <= 0) {
+               pr_err("Data length is: %d\n", data);
+               return -1;
+       }
+       memset(&msg, 0, sizeof(struct msghdr));
+       iov_iter_kvec(&msg.msg_iter, WRITE | ITER_KVEC,
+                     iov, iov_count, data);
+       while (msg_data_left(&msg)) {
+               int tx_loop = sock_sendmsg(conn->sock, &msg);
+               if (tx_loop <= 0) {
+                       pr_debug("tx_loop: %d total_tx %d\n",
+                               tx_loop, total_tx);
+                       return tx_loop;
+               }
+               total_tx += tx_loop;
+               pr_debug("tx_loop: %d, total_tx: %d, data: %d\n",
+                                       tx_loop, total_tx, data);
+       }
  
-       return iscsit_do_tx_data(conn, &c);
+       return total_tx;
  }
  
 -static bool sockaddr_equal(struct sockaddr_storage *x, struct sockaddr_storage *y)
 -{
 -      switch (x->ss_family) {
 -      case AF_INET: {
 -              struct sockaddr_in *sinx = (struct sockaddr_in *)x;
 -              struct sockaddr_in *siny = (struct sockaddr_in *)y;
 -              if (sinx->sin_addr.s_addr != siny->sin_addr.s_addr)
 -                      return false;
 -              if (sinx->sin_port != siny->sin_port)
 -                      return false;
 -              break;
 -      }
 -      case AF_INET6: {
 -              struct sockaddr_in6 *sinx = (struct sockaddr_in6 *)x;
 -              struct sockaddr_in6 *siny = (struct sockaddr_in6 *)y;
 -              if (!ipv6_addr_equal(&sinx->sin6_addr, &siny->sin6_addr))
 -                      return false;
 -              if (sinx->sin6_port != siny->sin6_port)
 -                      return false;
 -              break;
 -      }
 -      default:
 -              return false;
 -      }
 -      return true;
 -}
 -
  void iscsit_collect_login_stats(
        struct iscsi_conn *conn,
        u8 status_class,
Simple merge
diff --cc fs/afs/rxrpc.c
Simple merge
diff --cc fs/ncpfs/sock.c
Simple merge
Simple merge
diff --cc net/rds/rds.h
Simple merge