Re: [PATCH v9 10/25] RDMA/rtrs: server: main functionality

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Mar 1, 2020 at 2:42 AM Bart Van Assche <bvanassche@xxxxxxx> wrote:
>
> On 2020-02-21 02:47, Jack Wang wrote:
> > +int rtrs_srv_get_sess_name(struct rtrs_srv *srv, char *sessname, size_t len)
> > +{
> > +     struct rtrs_srv_sess *sess;
> > +     int err = -ENOTCONN;
> > +
> > +     mutex_lock(&srv->paths_mutex);
> > +     list_for_each_entry(sess, &srv->paths_list, s.entry) {
> > +             if (sess->state != RTRS_SRV_CONNECTED)
> > +                     continue;
> > +             memcpy(sessname, sess->s.sessname,
> > +                    min_t(size_t, sizeof(sess->s.sessname), len));
> > +             err = 0;
> > +             break;
> > +     }
> > +     mutex_unlock(&srv->paths_mutex);
> > +
> > +     return err;
> > +}
> > +EXPORT_SYMBOL(rtrs_srv_get_sess_name);
>
> Please make sure that the returned string is '\0'-terminated, e.g. by
> using strlcpy().
Ok.
>
> > +static int rtrs_rdma_do_accept(struct rtrs_srv_sess *sess,
> > +                            struct rdma_cm_id *cm_id)
> > +{
> > +     struct rtrs_srv *srv = sess->srv;
> > +     struct rtrs_msg_conn_rsp msg;
> > +     struct rdma_conn_param param;
> > +     int err;
> > +
> > +     param = (struct rdma_conn_param) {
> > +     .rnr_retry_count = 7,
> > +     .private_data = &msg,
> > +     .private_data_len = sizeof(msg),
> > +     };
> > +
> > +     msg = (struct rtrs_msg_conn_rsp) {
> > +     .magic = cpu_to_le16(RTRS_MAGIC),
> > +     .version = cpu_to_le16(RTRS_PROTO_VER),
> > +     .queue_depth = cpu_to_le16(srv->queue_depth),
> > +     .max_io_size = cpu_to_le32(max_chunk_size - MAX_HDR_SIZE),
> > +     .max_hdr_size = cpu_to_le32(MAX_HDR_SIZE),
> > +     };
> > +
> > +     if (always_invalidate)
> > +             msg.flags = cpu_to_le32(RTRS_MSG_NEW_RKEY_F);
> > +
> > +     err = rdma_accept(cm_id, &param);
> > +     if (err)
> > +             pr_err("rdma_accept(), err: %d\n", err);
> > +
> > +     return err;
> > +}
>
> Please indent the members in the structure assignments.
ok.
>
> > +static int rtrs_rdma_do_reject(struct rdma_cm_id *cm_id, int errno)
> > +{
> > +     struct rtrs_msg_conn_rsp msg;
> > +     int err;
> > +
> > +     msg = (struct rtrs_msg_conn_rsp) {
> > +     .magic = cpu_to_le16(RTRS_MAGIC),
> > +     .version = cpu_to_le16(RTRS_PROTO_VER),
> > +     .errno = cpu_to_le16(errno),
> > +     };
> > +
> > +     err = rdma_reject(cm_id, &msg, sizeof(msg));
> > +     if (err)
> > +             pr_err("rdma_reject(), err: %d\n", err);
> > +
> > +     /* Bounce errno back */
> > +     return errno;
> > +}
>
> Same comment for this function.
Ok, thanks Bart
>
> Thanks,
>
> Bart.



[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux