Re: [PATCH 01/19] cifs: Add SendReceive3

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

 



Ronnie Sahlberg <lsahlber@xxxxxxxxxx> writes:
> +
> +	new_iov = kmalloc(sizeof(struct kvec) * (n_vec + 1), GFP_KERNEL);
> +	if (!new_iov)
> +		return -ENOMEM;
> +
> +	/* 1st iov is an RFC1002 Session Message length */
> +	memcpy(new_iov + 1, iov, (sizeof(struct kvec) * n_vec));
> +
> +	count = 0;
> +	for (i = 1; i < n_vec + 1; i++)
> +		count += new_iov[i].iov_len;
> +
> +	rfc1002_marker = cpu_to_be32(count);
> +
> +	new_iov[0].iov_base = &rfc1002_marker;
> +	new_iov[0].iov_len = 4;
> +
> +	memset(&rqst, 0, sizeof(struct smb_rqst));
> +	rqst.rq_iov = new_iov;
> +	rqst.rq_nvec = n_vec + 1;
> +
> +	rc = cifs_send_recv(xid, ses, &rqst, resp_buf_type, flags, resp_iov);
> +	kfree(new_iov);
> +	return rc;
> +}
> +

I know this is kind of unrelated but I've been thinking to myself we
should try to get rid of this dynamic allocation at some point.

IIUC the iovec never has more than a couple of elements, so we could
have something like a fixed sized stack allocated iovec array +
MAX_IOVEC_LENGTH macro.

Doing a kmalloc() for every packet defeats the purpose of the memory
pool optimization we use for small/large buffers.

-- 
Aurélien Aptel / SUSE Labs Samba Team
GPG: 1839 CB5F 9F5B FB9B AA97  8C99 03C8 A49B 521B D5D3
SUSE Linux GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux