* [samba-ksmbd:for-next 4/4] fs/smb/client/smb2pdu.c:5595:22: warning: variable 'total_len' set but not used
@ 2026-05-10 14:40 kernel test robot
0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2026-05-10 14:40 UTC (permalink / raw)
To: Steve French; +Cc: oe-kbuild-all, Shyam Prasad N
tree: git://git.samba.org/ksmbd.git for-next
head: 8c24bfe7980824c3a1f4f5bf598a4b307f22084d
commit: 8c24bfe7980824c3a1f4f5bf598a4b307f22084d [4/4] cifs: optimize readdir for larger directories
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20260510/202605102210.PDoRL7sB-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 15.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260510/202605102210.PDoRL7sB-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202605102210.PDoRL7sB-lkp@intel.com/
All warnings (new ones prefixed by >>):
fs/smb/client/smb2pdu.c: In function 'SMB2_query_directory_large':
>> fs/smb/client/smb2pdu.c:5595:22: warning: variable 'total_len' set but not used [-Wunused-but-set-variable]
5595 | unsigned int total_len;
| ^~~~~~~~~
vim +/total_len +5595 fs/smb/client/smb2pdu.c
5580
5581 /*
5582 * QueryDirectory with large buffer and multi-credit support.
5583 * Uses async infrastructure but waits for completion synchronously.
5584 */
5585 int
5586 SMB2_query_directory_large(struct cifs_query_dir_io *qd_io, unsigned int buf_size)
5587 {
5588 int rc, flags = 0;
5589 char *buf;
5590 struct smb2_hdr *shdr;
5591 struct smb_rqst rqst = { .rq_iov = &qd_io->iov[0],
5592 .rq_nvec = SMB2_QUERY_DIRECTORY_IOV_SIZE };
5593 struct TCP_Server_Info *server = qd_io->server;
5594 struct cifs_tcon *tcon = qd_io->tcon;
> 5595 unsigned int total_len;
5596 int credit_request;
5597
5598 cifs_dbg(FYI, "%s: buf_size=%u\n", __func__, buf_size);
5599
5600 /* Cap buffer size to avoid kmalloc failures for very large allocations.
5601 * SMB2_MAX_QD_DATABUF_SIZE is a safe limit that stays well below typical
5602 * kmalloc constraints while still allowing large directory listings.
5603 */
5604 if (buf_size > SMB2_MAX_QD_DATABUF_SIZE)
5605 buf_size = SMB2_MAX_QD_DATABUF_SIZE;
5606
5607 /* Allocate response buffer. Since we'll build a combined header+data buffer,
5608 * we need space for both. We'll request a slightly smaller OutputBufferLength
5609 * from the server to ensure the total response fits.
5610 */
5611 qd_io->combined_iov.iov_base = kmalloc(buf_size, GFP_KERNEL);
5612 if (!qd_io->combined_iov.iov_base)
5613 return -ENOMEM;
5614 /* Store total capacity in iov_len; updated to actual data length by receive handler */
5615 qd_io->combined_iov.iov_len = buf_size;
5616
5617 /* Initialize completion */
5618 init_completion(&qd_io->done);
5619
5620 /* Request less data from server to leave room for the response header.
5621 * Use MAX_CIFS_SMALL_BUFFER_SIZE as a safety margin.
5622 */
5623 rc = SMB2_query_directory_init(qd_io->xid, tcon, server,
5624 &rqst, qd_io->persistent_fid,
5625 qd_io->volatile_fid, qd_io->index,
5626 qd_io->srch_inf->info_level,
5627 buf_size - MAX_CIFS_SMALL_BUFFER_SIZE);
5628 if (rc) {
5629 kfree(qd_io->combined_iov.iov_base);
5630 qd_io->combined_iov.iov_base = NULL;
5631 return rc;
5632 }
5633
5634 if (smb3_encryption_required(tcon))
5635 flags |= CIFS_TRANSFORM_REQ;
5636
5637 buf = rqst.rq_iov[0].iov_base;
5638 total_len = rqst.rq_iov[0].iov_len;
5639
5640 shdr = (struct smb2_hdr *)buf;
5641
5642 if (qd_io->replay) {
5643 /* Back-off before retry */
5644 if (qd_io->cur_sleep)
5645 msleep(qd_io->cur_sleep);
5646 smb2_set_replay(server, &rqst);
5647 }
5648
5649 /* Set credit charge based on buffer size */
5650 if (qd_io->credits.value > 0) {
5651 shdr->CreditCharge = cpu_to_le16(DIV_ROUND_UP(buf_size,
5652 SMB2_MAX_BUFFER_SIZE));
5653 credit_request = le16_to_cpu(shdr->CreditCharge) + 8;
5654 if (server->credits >= server->max_credits)
5655 shdr->CreditRequest = cpu_to_le16(0);
5656 else
5657 shdr->CreditRequest = cpu_to_le16(
5658 min_t(int, server->max_credits -
5659 server->credits, credit_request));
5660
5661 flags |= CIFS_HAS_CREDITS;
5662 }
5663
5664 rc = cifs_call_async(server, &rqst,
5665 cifs_query_dir_receive, smb2_query_dir_callback,
5666 smb2_query_dir_handle_data, qd_io, flags,
5667 &qd_io->credits);
5668 if (rc) {
5669 cifs_stats_fail_inc(tcon, SMB2_QUERY_DIRECTORY_HE);
5670 trace_smb3_query_dir_err(qd_io->xid, qd_io->persistent_fid,
5671 tcon->tid, tcon->ses->Suid,
5672 qd_io->index, 0, rc);
5673 kfree(qd_io->combined_iov.iov_base);
5674 qd_io->combined_iov.iov_base = NULL;
5675 }
5676
5677 /* Free request buffer immediately after async call */
5678 cifs_small_buf_release(buf);
5679
5680 if (rc)
5681 return rc;
5682
5683 /* Wait for the async operation to complete */
5684 wait_for_completion(&qd_io->done);
5685 return qd_io->result;
5686 }
5687
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-05-10 14:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-10 14:40 [samba-ksmbd:for-next 4/4] fs/smb/client/smb2pdu.c:5595:22: warning: variable 'total_len' set but not used kernel test robot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.