All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: kbuild@lists.01.org
Subject: Re: [PATCH 3/3] cifs: cache the directory content for shroot
Date: Mon, 05 Oct 2020 14:47:01 +0800	[thread overview]
Message-ID: <202010051404.5A11Hvxu-lkp@intel.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 15037 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <20201005023754.13604-4-lsahlber@redhat.com>
References: <20201005023754.13604-4-lsahlber@redhat.com>
TO: Ronnie Sahlberg <lsahlber@redhat.com>
TO: "linux-cifs" <linux-cifs@vger.kernel.org>
CC: Steve French <smfrench@gmail.com>

Hi Ronnie,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on cifs/for-next]
[also build test WARNING on v5.9-rc8 next-20201002]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Ronnie-Sahlberg/cifs-cache-the-directory-content-for-shroot/20201005-104037
base:   git://git.samba.org/sfrench/cifs-2.6.git for-next
:::::: branch date: 4 hours ago
:::::: commit date: 4 hours ago
config: i386-randconfig-c001-20201005 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Julia Lawall <julia.lawall@lip6.fr>

	echo
	echo "coccinelle warnings: (new ones prefixed by >>)"
	echo
>> fs/cifs/readdir.c:1184:1-7: preceding lock on line 1040

vim +1184 fs/cifs/readdir.c

^1da177e4c3f415 Linus Torvalds   2005-04-16  1010  
be4ccdcc2575ae1 Al Viro          2013-05-22  1011  int cifs_readdir(struct file *file, struct dir_context *ctx)
^1da177e4c3f415 Linus Torvalds   2005-04-16  1012  {
^1da177e4c3f415 Linus Torvalds   2005-04-16  1013  	int rc = 0;
6d5786a34d98bff Pavel Shilovsky  2012-06-20  1014  	unsigned int xid;
6d5786a34d98bff Pavel Shilovsky  2012-06-20  1015  	int i;
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1016  	struct cifs_tcon *tcon, *mtcon;
^1da177e4c3f415 Linus Torvalds   2005-04-16  1017  	struct cifsFileInfo *cifsFile = NULL;
^1da177e4c3f415 Linus Torvalds   2005-04-16  1018  	char *current_entry;
^1da177e4c3f415 Linus Torvalds   2005-04-16  1019  	int num_to_fill = 0;
^1da177e4c3f415 Linus Torvalds   2005-04-16  1020  	char *tmp_buf = NULL;
^1da177e4c3f415 Linus Torvalds   2005-04-16  1021  	char *end_of_smb;
18295796a30cada Jeff Layton      2009-04-30  1022  	unsigned int max_len;
010d984773e7614 Ronnie Sahlberg  2020-10-05  1023  	char *full_path = NULL;
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1024  	struct cached_fid *cfid = NULL;
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1025  	struct cifs_sb_info *cifs_sb = CIFS_FILE_SB(file);
^1da177e4c3f415 Linus Torvalds   2005-04-16  1026  
6d5786a34d98bff Pavel Shilovsky  2012-06-20  1027  	xid = get_xid();
010d984773e7614 Ronnie Sahlberg  2020-10-05  1028  	full_path = build_path_from_dentry(file_dentry(file));
010d984773e7614 Ronnie Sahlberg  2020-10-05  1029  	if (full_path == NULL) {
010d984773e7614 Ronnie Sahlberg  2020-10-05  1030  		rc = -ENOMEM;
010d984773e7614 Ronnie Sahlberg  2020-10-05  1031  		goto rddir2_exit;
010d984773e7614 Ronnie Sahlberg  2020-10-05  1032  	}
010d984773e7614 Ronnie Sahlberg  2020-10-05  1033  
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1034  	mtcon = cifs_sb_master_tcon(cifs_sb);
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1035  	if (!is_smb1_server(mtcon->ses->server) && !strcmp(full_path, "")) {
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1036  		rc = open_shroot(xid, mtcon, cifs_sb, &cfid);
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1037  		if (rc)
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1038  			goto cache_not_found;
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1039  
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05 @1040  		mutex_lock(&cfid->dirents.de_mutex);
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1041  		/*
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1042  		 * If this was reading from the start of the directory
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1043  		 * we need to initialize scanning and storing the
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1044  		 * directory content.
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1045  		 */
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1046  		if (ctx->pos == 0 && cfid->dirents.ctx == NULL) {
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1047  			cfid->dirents.ctx = ctx;
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1048  			cfid->dirents.pos = 2;
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1049  		}
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1050  		/*
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1051  		 * If we already have the entire directory cached then
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1052  		 * we can just serve the cache.
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1053  		 */
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1054  		if (cfid->dirents.is_valid) {
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1055  			if (!dir_emit_dots(file, ctx))
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1056  				goto rddir2_exit;
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1057  			emit_cached_dirents(&cfid->dirents, ctx);
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1058  			mutex_unlock(&cfid->dirents.de_mutex);
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1059  			goto rddir2_exit;
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1060  		}
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1061  		mutex_unlock(&cfid->dirents.de_mutex);
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1062  	}
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1063   cache_not_found:
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1064  
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1065  	/* Drop the cache while calling initiate_cifs_search and
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1066  	 * find_cifs_entry in case there will be reconnects during
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1067  	 * query_directory.
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1068  	 */
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1069  	if (cfid) {
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1070  		close_shroot(cfid);
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1071  		cfid = NULL;
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1072  	}
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1073  
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1074  
6221ddd0f5e2ddc Suresh Jayaraman 2010-10-01  1075  	/*
6221ddd0f5e2ddc Suresh Jayaraman 2010-10-01  1076  	 * Ensure FindFirst doesn't fail before doing filldir() for '.' and
6221ddd0f5e2ddc Suresh Jayaraman 2010-10-01  1077  	 * '..'. Otherwise we won't be able to notify VFS in case of failure.
6221ddd0f5e2ddc Suresh Jayaraman 2010-10-01  1078  	 */
6221ddd0f5e2ddc Suresh Jayaraman 2010-10-01  1079  	if (file->private_data == NULL) {
010d984773e7614 Ronnie Sahlberg  2020-10-05  1080  		rc = initiate_cifs_search(xid, file, full_path);
f96637be081141d Joe Perches      2013-05-04  1081  		cifs_dbg(FYI, "initiate cifs search rc %d\n", rc);
6221ddd0f5e2ddc Suresh Jayaraman 2010-10-01  1082  		if (rc)
6221ddd0f5e2ddc Suresh Jayaraman 2010-10-01  1083  			goto rddir2_exit;
6221ddd0f5e2ddc Suresh Jayaraman 2010-10-01  1084  	}
6221ddd0f5e2ddc Suresh Jayaraman 2010-10-01  1085  
be4ccdcc2575ae1 Al Viro          2013-05-22  1086  	if (!dir_emit_dots(file, ctx))
be4ccdcc2575ae1 Al Viro          2013-05-22  1087  		goto rddir2_exit;
be4ccdcc2575ae1 Al Viro          2013-05-22  1088  
^1da177e4c3f415 Linus Torvalds   2005-04-16  1089  	/* 1) If search is active,
^1da177e4c3f415 Linus Torvalds   2005-04-16  1090  		is in current search buffer?
^1da177e4c3f415 Linus Torvalds   2005-04-16  1091  		if it before then restart search
^1da177e4c3f415 Linus Torvalds   2005-04-16  1092  		if after then keep searching till find it */
^1da177e4c3f415 Linus Torvalds   2005-04-16  1093  
^1da177e4c3f415 Linus Torvalds   2005-04-16  1094  	cifsFile = file->private_data;
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1095  	tcon = tlink_tcon(cifsFile->tlink);
^1da177e4c3f415 Linus Torvalds   2005-04-16  1096  	if (cifsFile->srch_inf.endOfSearch) {
^1da177e4c3f415 Linus Torvalds   2005-04-16  1097  		if (cifsFile->srch_inf.emptyDir) {
f96637be081141d Joe Perches      2013-05-04  1098  			cifs_dbg(FYI, "End of search, empty dir\n");
^1da177e4c3f415 Linus Torvalds   2005-04-16  1099  			rc = 0;
be4ccdcc2575ae1 Al Viro          2013-05-22  1100  			goto rddir2_exit;
^1da177e4c3f415 Linus Torvalds   2005-04-16  1101  		}
^1da177e4c3f415 Linus Torvalds   2005-04-16  1102  	} /* else {
4b18f2a9c3964f7 Steve French     2008-04-29  1103  		cifsFile->invalidHandle = true;
92fc65a74a2be13 Pavel Shilovsky  2012-09-18  1104  		tcon->ses->server->close(xid, tcon, &cifsFile->fid);
aaa9bbe039febf1 Steve French     2008-05-23  1105  	} */
^1da177e4c3f415 Linus Torvalds   2005-04-16  1106  
010d984773e7614 Ronnie Sahlberg  2020-10-05  1107  	rc = find_cifs_entry(xid, tcon, ctx->pos, file, full_path,
010d984773e7614 Ronnie Sahlberg  2020-10-05  1108  			     &current_entry, &num_to_fill);
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1109  	if (!is_smb1_server(tcon->ses->server) && !strcmp(full_path, "")) {
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1110  		open_shroot(xid, mtcon, cifs_sb, &cfid);
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1111  	}
^1da177e4c3f415 Linus Torvalds   2005-04-16  1112  	if (rc) {
f96637be081141d Joe Perches      2013-05-04  1113  		cifs_dbg(FYI, "fce error %d\n", rc);
^1da177e4c3f415 Linus Torvalds   2005-04-16  1114  		goto rddir2_exit;
^1da177e4c3f415 Linus Torvalds   2005-04-16  1115  	} else if (current_entry != NULL) {
be4ccdcc2575ae1 Al Viro          2013-05-22  1116  		cifs_dbg(FYI, "entry %lld found\n", ctx->pos);
^1da177e4c3f415 Linus Torvalds   2005-04-16  1117  	} else {
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1118  		if (cfid) {
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1119  			mutex_lock(&cfid->dirents.de_mutex);
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1120  			finished_cached_dirents_count(&cfid->dirents, ctx);
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1121  			mutex_unlock(&cfid->dirents.de_mutex);
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1122  		}
a0a3036b81f1f66 Joe Perches      2020-04-14  1123  		cifs_dbg(FYI, "Could not find entry\n");
^1da177e4c3f415 Linus Torvalds   2005-04-16  1124  		goto rddir2_exit;
^1da177e4c3f415 Linus Torvalds   2005-04-16  1125  	}
f96637be081141d Joe Perches      2013-05-04  1126  	cifs_dbg(FYI, "loop through %d times filling dir for net buf %p\n",
b6b38f704a8193d Joe Perches      2010-04-21  1127  		 num_to_fill, cifsFile->srch_inf.ntwrk_buf_start);
92fc65a74a2be13 Pavel Shilovsky  2012-09-18  1128  	max_len = tcon->ses->server->ops->calc_smb_size(
9ec672bd17131fe Ronnie Sahlberg  2018-04-22  1129  			cifsFile->srch_inf.ntwrk_buf_start,
9ec672bd17131fe Ronnie Sahlberg  2018-04-22  1130  			tcon->ses->server);
5bafd76593f0605 Steve French     2006-06-07  1131  	end_of_smb = cifsFile->srch_inf.ntwrk_buf_start + max_len;
5bafd76593f0605 Steve French     2006-06-07  1132  
f58841666bc22e8 Jeff Layton      2009-04-30  1133  	tmp_buf = kmalloc(UNICODE_NAME_MAX, GFP_KERNEL);
f55fdcca6bf1c17 Kulikov Vasiliy  2010-07-16  1134  	if (tmp_buf == NULL) {
f55fdcca6bf1c17 Kulikov Vasiliy  2010-07-16  1135  		rc = -ENOMEM;
be4ccdcc2575ae1 Al Viro          2013-05-22  1136  		goto rddir2_exit;
f55fdcca6bf1c17 Kulikov Vasiliy  2010-07-16  1137  	}
f55fdcca6bf1c17 Kulikov Vasiliy  2010-07-16  1138  
be4ccdcc2575ae1 Al Viro          2013-05-22  1139  	for (i = 0; i < num_to_fill; i++) {
^1da177e4c3f415 Linus Torvalds   2005-04-16  1140  		if (current_entry == NULL) {
^1da177e4c3f415 Linus Torvalds   2005-04-16  1141  			/* evaluate whether this case is an error */
f96637be081141d Joe Perches      2013-05-04  1142  			cifs_dbg(VFS, "past SMB end,  num to fill %d i %d\n",
b6b38f704a8193d Joe Perches      2010-04-21  1143  				 num_to_fill, i);
^1da177e4c3f415 Linus Torvalds   2005-04-16  1144  			break;
^1da177e4c3f415 Linus Torvalds   2005-04-16  1145  		}
92fc65a74a2be13 Pavel Shilovsky  2012-09-18  1146  		/*
92fc65a74a2be13 Pavel Shilovsky  2012-09-18  1147  		 * if buggy server returns . and .. late do we want to
92fc65a74a2be13 Pavel Shilovsky  2012-09-18  1148  		 * check for that here?
92fc65a74a2be13 Pavel Shilovsky  2012-09-18  1149  		 */
01b9b0b28626db4 Vasily Averin    2016-01-14  1150  		*tmp_buf = 0;
be4ccdcc2575ae1 Al Viro          2013-05-22  1151  		rc = cifs_filldir(current_entry, file, ctx,
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1152  				  tmp_buf, max_len, cfid);
be4ccdcc2575ae1 Al Viro          2013-05-22  1153  		if (rc) {
be4ccdcc2575ae1 Al Viro          2013-05-22  1154  			if (rc > 0)
7ca85ba752e521f Steve French     2006-10-30  1155  				rc = 0;
7ca85ba752e521f Steve French     2006-10-30  1156  			break;
7ca85ba752e521f Steve French     2006-10-30  1157  		}
7ca85ba752e521f Steve French     2006-10-30  1158  
be4ccdcc2575ae1 Al Viro          2013-05-22  1159  		ctx->pos++;
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1160  		if (cfid) {
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1161  			mutex_lock(&cfid->dirents.de_mutex);
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1162  			update_cached_dirents_count(&cfid->dirents, ctx);
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1163  			mutex_unlock(&cfid->dirents.de_mutex);
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1164  		}
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1165  
be4ccdcc2575ae1 Al Viro          2013-05-22  1166  		if (ctx->pos ==
3979877e5606ecc Steve French     2006-05-31  1167  			cifsFile->srch_inf.index_of_last_entry) {
f96637be081141d Joe Perches      2013-05-04  1168  			cifs_dbg(FYI, "last entry in buf at pos %lld %s\n",
be4ccdcc2575ae1 Al Viro          2013-05-22  1169  				 ctx->pos, tmp_buf);
^1da177e4c3f415 Linus Torvalds   2005-04-16  1170  			cifs_save_resume_key(current_entry, cifsFile);
^1da177e4c3f415 Linus Torvalds   2005-04-16  1171  			break;
^1da177e4c3f415 Linus Torvalds   2005-04-16  1172  		} else
5bafd76593f0605 Steve French     2006-06-07  1173  			current_entry =
5bafd76593f0605 Steve French     2006-06-07  1174  				nxt_dir_entry(current_entry, end_of_smb,
5bafd76593f0605 Steve French     2006-06-07  1175  					cifsFile->srch_inf.info_level);
^1da177e4c3f415 Linus Torvalds   2005-04-16  1176  	}
^1da177e4c3f415 Linus Torvalds   2005-04-16  1177  	kfree(tmp_buf);
^1da177e4c3f415 Linus Torvalds   2005-04-16  1178  
^1da177e4c3f415 Linus Torvalds   2005-04-16  1179  rddir2_exit:
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1180  	if (cfid)
7975d587dc0ef40 Ronnie Sahlberg  2020-10-05  1181  		close_shroot(cfid);
010d984773e7614 Ronnie Sahlberg  2020-10-05  1182  	kfree(full_path);
6d5786a34d98bff Pavel Shilovsky  2012-06-20  1183  	free_xid(xid);
^1da177e4c3f415 Linus Torvalds   2005-04-16 @1184  	return rc;

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 30782 bytes --]

             reply	other threads:[~2020-10-05  6:47 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-05  6:47 kernel test robot [this message]
  -- strict thread matches above, loose matches on Subject: below --
2020-10-05 21:16 [PATCH 3/3] cifs: cache the directory content for shroot Ronnie Sahlberg
2020-10-07 12:21 ` Aurélien Aptel
2020-10-05  2:37 [PATCH 0/3 V1] " Ronnie Sahlberg
2020-10-05  2:37 ` [PATCH 3/3] " Ronnie Sahlberg
2020-10-04 23:37 [PATCH 0/3 V2]: cifs: cache " Ronnie Sahlberg
2020-10-04 23:37 ` [PATCH 3/3] cifs: cache the " Ronnie Sahlberg
2020-10-01 20:50 [PATCH 0/3] cifs: cache " Ronnie Sahlberg
2020-10-01 20:50 ` [PATCH 3/3] cifs: cache the " Ronnie Sahlberg
2020-10-01 22:24   ` Steve French
2020-10-02 15:29   ` Aurélien Aptel
2020-10-04 23:19     ` ronnie sahlberg
     [not found]       ` <CAH2r5mvijc=-JdmPMUxAUqmJKy0-x3o72NsHx+QcByBnggGXMA@mail.gmail.com>
2020-10-05  0:20         ` ronnie sahlberg
2020-10-20 10:28   ` Shyam Prasad N

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202010051404.5A11Hvxu-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=kbuild@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.