diff mbox

[3/5] nfsd4: define ->op_release for compound ops

Message ID 1500063895-29457-4-git-send-email-bfields@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Bruce Fields July 14, 2017, 8:24 p.m. UTC
From: "J. Bruce Fields" <bfields@redhat.com>

Run a separate ->op_release function if necessary instead of depending
on the xdr encoder to do this.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
---
 fs/nfsd/nfs4proc.c | 31 +++++++++++++++++++++++++++++++
 fs/nfsd/nfs4xdr.c  |  9 +++------
 fs/nfsd/xdr4.h     |  1 +
 3 files changed, 35 insertions(+), 6 deletions(-)

Comments

kernel test robot July 15, 2017, 9:27 a.m. UTC | #1
Hi Bruce,

[auto build test ERROR on next-20170710]
[cannot apply to nfsd/nfsd-next v4.12 v4.12-rc7 v4.12-rc6 v4.12]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/J-Bruce-Fields/skip-op-encoders-in-error-cases/20170715-165807
config: xtensa-allyesconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 4.9.0
reproduce:
        wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=xtensa 

All error/warnings (new ones prefixed by >>):

   fs/nfsd/nfs4proc.c: In function 'nfsd4_getdeviceinfo_release':
>> fs/nfsd/nfs4proc.c:1356:8: error: 'gdev' undeclared (first use in this function)
     kfree(gdev->gd_device);
           ^
   fs/nfsd/nfs4proc.c:1356:8: note: each undeclared identifier is reported only once for each function it appears in
   fs/nfsd/nfs4proc.c: At top level:
>> fs/nfsd/nfs4proc.c:1439:1: warning: return type defaults to 'int' [-Wreturn-type]
    nfsd4_layoutget_release(union nfsd4_op_u *u)
    ^
   fs/nfsd/nfs4proc.c: In function 'nfsd4_layoutget_release':
>> fs/nfsd/nfs4proc.c:1441:8: error: 'lgp' undeclared (first use in this function)
     kfree(lgp->lg_content);
           ^
   fs/nfsd/nfs4proc.c: At top level:
>> fs/nfsd/nfs4proc.c:2401:3: warning: initialization from incompatible pointer type
      .op_release = nfsd4_layoutget_release,
      ^
   fs/nfsd/nfs4proc.c:2401:3: warning: (near initialization for 'nfsd4_ops[50].op_release')
   fs/nfsd/nfs4proc.c: In function 'nfsd4_layoutget_release':
>> fs/nfsd/nfs4proc.c:1442:1: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^

vim +/gdev +1356 fs/nfsd/nfs4proc.c

  1352	
  1353	static void
  1354	nfsd4_getdeviceinfo_release(union nfsd4_op_u *u)
  1355	{
> 1356		kfree(gdev->gd_device);
  1357	}
  1358	
  1359	static __be32
  1360	nfsd4_layoutget(struct svc_rqst *rqstp,
  1361			struct nfsd4_compound_state *cstate, union nfsd4_op_u *u)
  1362	{
  1363		struct nfsd4_layoutget *lgp = &u->layoutget;
  1364		struct svc_fh *current_fh = &cstate->current_fh;
  1365		const struct nfsd4_layout_ops *ops;
  1366		struct nfs4_layout_stateid *ls;
  1367		__be32 nfserr;
  1368		int accmode;
  1369	
  1370		switch (lgp->lg_seg.iomode) {
  1371		case IOMODE_READ:
  1372			accmode = NFSD_MAY_READ;
  1373			break;
  1374		case IOMODE_RW:
  1375			accmode = NFSD_MAY_READ | NFSD_MAY_WRITE;
  1376			break;
  1377		default:
  1378			dprintk("%s: invalid iomode %d\n",
  1379				__func__, lgp->lg_seg.iomode);
  1380			nfserr = nfserr_badiomode;
  1381			goto out;
  1382		}
  1383	
  1384		nfserr = fh_verify(rqstp, current_fh, 0, accmode);
  1385		if (nfserr)
  1386			goto out;
  1387	
  1388		nfserr = nfserr_layoutunavailable;
  1389		ops = nfsd4_layout_verify(current_fh->fh_export, lgp->lg_layout_type);
  1390		if (!ops)
  1391			goto out;
  1392	
  1393		/*
  1394		 * Verify minlength and range as per RFC5661:
  1395		 *  o  If loga_length is less than loga_minlength,
  1396		 *     the metadata server MUST return NFS4ERR_INVAL.
  1397		 *  o  If the sum of loga_offset and loga_minlength exceeds
  1398		 *     NFS4_UINT64_MAX, and loga_minlength is not
  1399		 *     NFS4_UINT64_MAX, the error NFS4ERR_INVAL MUST result.
  1400		 *  o  If the sum of loga_offset and loga_length exceeds
  1401		 *     NFS4_UINT64_MAX, and loga_length is not NFS4_UINT64_MAX,
  1402		 *     the error NFS4ERR_INVAL MUST result.
  1403		 */
  1404		nfserr = nfserr_inval;
  1405		if (lgp->lg_seg.length < lgp->lg_minlength ||
  1406		    (lgp->lg_minlength != NFS4_MAX_UINT64 &&
  1407		     lgp->lg_minlength > NFS4_MAX_UINT64 - lgp->lg_seg.offset) ||
  1408		    (lgp->lg_seg.length != NFS4_MAX_UINT64 &&
  1409		     lgp->lg_seg.length > NFS4_MAX_UINT64 - lgp->lg_seg.offset))
  1410			goto out;
  1411		if (lgp->lg_seg.length == 0)
  1412			goto out;
  1413	
  1414		nfserr = nfsd4_preprocess_layout_stateid(rqstp, cstate, &lgp->lg_sid,
  1415							true, lgp->lg_layout_type, &ls);
  1416		if (nfserr) {
  1417			trace_layout_get_lookup_fail(&lgp->lg_sid);
  1418			goto out;
  1419		}
  1420	
  1421		nfserr = nfserr_recallconflict;
  1422		if (atomic_read(&ls->ls_stid.sc_file->fi_lo_recalls))
  1423			goto out_put_stid;
  1424	
  1425		nfserr = ops->proc_layoutget(d_inode(current_fh->fh_dentry),
  1426					     current_fh, lgp);
  1427		if (nfserr)
  1428			goto out_put_stid;
  1429	
  1430		nfserr = nfsd4_insert_layout(lgp, ls);
  1431	
  1432	out_put_stid:
  1433		mutex_unlock(&ls->ls_mutex);
  1434		nfs4_put_stid(&ls->ls_stid);
  1435	out:
  1436		return nfserr;
  1437	}
  1438	
> 1439	nfsd4_layoutget_release(union nfsd4_op_u *u)
  1440	{
> 1441		kfree(lgp->lg_content);
> 1442	}
  1443	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
kernel test robot July 15, 2017, 9:30 a.m. UTC | #2
Hi Bruce,

[auto build test ERROR on next-20170710]
[cannot apply to nfsd/nfsd-next v4.12 v4.12-rc7 v4.12-rc6 v4.12]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/J-Bruce-Fields/skip-op-encoders-in-error-cases/20170715-165807
config: sparc64-allyesconfig (attached as .config)
compiler: sparc64-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
        wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=sparc64 

All errors (new ones prefixed by >>):

   fs//nfsd/nfs4proc.c: In function 'nfsd4_getdeviceinfo_release':
   fs//nfsd/nfs4proc.c:1356:8: error: 'gdev' undeclared (first use in this function)
     kfree(gdev->gd_device);
           ^~~~
   fs//nfsd/nfs4proc.c:1356:8: note: each undeclared identifier is reported only once for each function it appears in
   fs//nfsd/nfs4proc.c: At top level:
   fs//nfsd/nfs4proc.c:1439:1: warning: return type defaults to 'int' [-Wreturn-type]
    nfsd4_layoutget_release(union nfsd4_op_u *u)
    ^~~~~~~~~~~~~~~~~~~~~~~
   fs//nfsd/nfs4proc.c: In function 'nfsd4_layoutget_release':
   fs//nfsd/nfs4proc.c:1441:8: error: 'lgp' undeclared (first use in this function)
     kfree(lgp->lg_content);
           ^~~
   fs//nfsd/nfs4proc.c: At top level:
>> fs//nfsd/nfs4proc.c:2401:17: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
      .op_release = nfsd4_layoutget_release,
                    ^~~~~~~~~~~~~~~~~~~~~~~
   fs//nfsd/nfs4proc.c:2401:17: note: (near initialization for 'nfsd4_ops[50].op_release')
   fs//nfsd/nfs4proc.c: In function 'nfsd4_layoutget_release':
   fs//nfsd/nfs4proc.c:1442:1: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^
   cc1: some warnings being treated as errors

vim +2401 fs//nfsd/nfs4proc.c

  2089	
  2090	static const struct nfsd4_operation nfsd4_ops[] = {
  2091		[OP_ACCESS] = {
  2092			.op_func = nfsd4_access,
  2093			.op_name = "OP_ACCESS",
  2094			.op_rsize_bop = nfsd4_access_rsize,
  2095		},
  2096		[OP_CLOSE] = {
  2097			.op_func = nfsd4_close,
  2098			.op_flags = OP_MODIFIES_SOMETHING,
  2099			.op_name = "OP_CLOSE",
  2100			.op_rsize_bop = nfsd4_status_stateid_rsize,
  2101			.op_get_currentstateid = nfsd4_get_closestateid,
  2102			.op_set_currentstateid = nfsd4_set_closestateid,
  2103		},
  2104		[OP_COMMIT] = {
  2105			.op_func = nfsd4_commit,
  2106			.op_flags = OP_MODIFIES_SOMETHING,
  2107			.op_name = "OP_COMMIT",
  2108			.op_rsize_bop = nfsd4_commit_rsize,
  2109		},
  2110		[OP_CREATE] = {
  2111			.op_func = nfsd4_create,
  2112			.op_flags = OP_MODIFIES_SOMETHING | OP_CACHEME | OP_CLEAR_STATEID,
  2113			.op_name = "OP_CREATE",
  2114			.op_rsize_bop = nfsd4_create_rsize,
  2115		},
  2116		[OP_DELEGRETURN] = {
  2117			.op_func = nfsd4_delegreturn,
  2118			.op_flags = OP_MODIFIES_SOMETHING,
  2119			.op_name = "OP_DELEGRETURN",
  2120			.op_rsize_bop = nfsd4_only_status_rsize,
  2121			.op_get_currentstateid = nfsd4_get_delegreturnstateid,
  2122		},
  2123		[OP_GETATTR] = {
  2124			.op_func = nfsd4_getattr,
  2125			.op_flags = ALLOWED_ON_ABSENT_FS,
  2126			.op_rsize_bop = nfsd4_getattr_rsize,
  2127			.op_name = "OP_GETATTR",
  2128		},
  2129		[OP_GETFH] = {
  2130			.op_func = nfsd4_getfh,
  2131			.op_name = "OP_GETFH",
  2132			.op_rsize_bop = nfsd4_getfh_rsize,
  2133		},
  2134		[OP_LINK] = {
  2135			.op_func = nfsd4_link,
  2136			.op_flags = ALLOWED_ON_ABSENT_FS | OP_MODIFIES_SOMETHING
  2137					| OP_CACHEME,
  2138			.op_name = "OP_LINK",
  2139			.op_rsize_bop = nfsd4_link_rsize,
  2140		},
  2141		[OP_LOCK] = {
  2142			.op_func = nfsd4_lock,
  2143			.op_flags = OP_MODIFIES_SOMETHING,
  2144			.op_name = "OP_LOCK",
  2145			.op_rsize_bop = nfsd4_lock_rsize,
  2146			.op_set_currentstateid = nfsd4_set_lockstateid,
  2147		},
  2148		[OP_LOCKT] = {
  2149			.op_func = nfsd4_lockt,
  2150			.op_name = "OP_LOCKT",
  2151			.op_rsize_bop = nfsd4_lock_rsize,
  2152		},
  2153		[OP_LOCKU] = {
  2154			.op_func = nfsd4_locku,
  2155			.op_flags = OP_MODIFIES_SOMETHING,
  2156			.op_name = "OP_LOCKU",
  2157			.op_rsize_bop = nfsd4_status_stateid_rsize,
  2158			.op_get_currentstateid = nfsd4_get_lockustateid,
  2159		},
  2160		[OP_LOOKUP] = {
  2161			.op_func = nfsd4_lookup,
  2162			.op_flags = OP_HANDLES_WRONGSEC | OP_CLEAR_STATEID,
  2163			.op_name = "OP_LOOKUP",
  2164			.op_rsize_bop = nfsd4_only_status_rsize,
  2165		},
  2166		[OP_LOOKUPP] = {
  2167			.op_func = nfsd4_lookupp,
  2168			.op_flags = OP_HANDLES_WRONGSEC | OP_CLEAR_STATEID,
  2169			.op_name = "OP_LOOKUPP",
  2170			.op_rsize_bop = nfsd4_only_status_rsize,
  2171		},
  2172		[OP_NVERIFY] = {
  2173			.op_func = nfsd4_nverify,
  2174			.op_name = "OP_NVERIFY",
  2175			.op_rsize_bop = nfsd4_only_status_rsize,
  2176		},
  2177		[OP_OPEN] = {
  2178			.op_func = nfsd4_open,
  2179			.op_flags = OP_HANDLES_WRONGSEC | OP_MODIFIES_SOMETHING,
  2180			.op_name = "OP_OPEN",
  2181			.op_rsize_bop = nfsd4_open_rsize,
  2182			.op_set_currentstateid = nfsd4_set_openstateid,
  2183		},
  2184		[OP_OPEN_CONFIRM] = {
  2185			.op_func = nfsd4_open_confirm,
  2186			.op_flags = OP_MODIFIES_SOMETHING,
  2187			.op_name = "OP_OPEN_CONFIRM",
  2188			.op_rsize_bop = nfsd4_status_stateid_rsize,
  2189		},
  2190		[OP_OPEN_DOWNGRADE] = {
  2191			.op_func = nfsd4_open_downgrade,
  2192			.op_flags = OP_MODIFIES_SOMETHING,
  2193			.op_name = "OP_OPEN_DOWNGRADE",
  2194			.op_rsize_bop = nfsd4_status_stateid_rsize,
  2195			.op_get_currentstateid = nfsd4_get_opendowngradestateid,
  2196			.op_set_currentstateid = nfsd4_set_opendowngradestateid,
  2197		},
  2198		[OP_PUTFH] = {
  2199			.op_func = nfsd4_putfh,
  2200			.op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS
  2201					| OP_IS_PUTFH_LIKE | OP_CLEAR_STATEID,
  2202			.op_name = "OP_PUTFH",
  2203			.op_rsize_bop = nfsd4_only_status_rsize,
  2204		},
  2205		[OP_PUTPUBFH] = {
  2206			.op_func = nfsd4_putrootfh,
  2207			.op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS
  2208					| OP_IS_PUTFH_LIKE | OP_CLEAR_STATEID,
  2209			.op_name = "OP_PUTPUBFH",
  2210			.op_rsize_bop = nfsd4_only_status_rsize,
  2211		},
  2212		[OP_PUTROOTFH] = {
  2213			.op_func = nfsd4_putrootfh,
  2214			.op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS
  2215					| OP_IS_PUTFH_LIKE | OP_CLEAR_STATEID,
  2216			.op_name = "OP_PUTROOTFH",
  2217			.op_rsize_bop = nfsd4_only_status_rsize,
  2218		},
  2219		[OP_READ] = {
  2220			.op_func = nfsd4_read,
  2221			.op_release = nfsd4_read_release,
  2222			.op_name = "OP_READ",
  2223			.op_rsize_bop = nfsd4_read_rsize,
  2224			.op_get_currentstateid = nfsd4_get_readstateid,
  2225		},
  2226		[OP_READDIR] = {
  2227			.op_func = nfsd4_readdir,
  2228			.op_name = "OP_READDIR",
  2229			.op_rsize_bop = nfsd4_readdir_rsize,
  2230		},
  2231		[OP_READLINK] = {
  2232			.op_func = nfsd4_readlink,
  2233			.op_name = "OP_READLINK",
  2234			.op_rsize_bop = nfsd4_readlink_rsize,
  2235		},
  2236		[OP_REMOVE] = {
  2237			.op_func = nfsd4_remove,
  2238			.op_flags = OP_MODIFIES_SOMETHING | OP_CACHEME,
  2239			.op_name = "OP_REMOVE",
  2240			.op_rsize_bop = nfsd4_remove_rsize,
  2241		},
  2242		[OP_RENAME] = {
  2243			.op_func = nfsd4_rename,
  2244			.op_flags = OP_MODIFIES_SOMETHING | OP_CACHEME,
  2245			.op_name = "OP_RENAME",
  2246			.op_rsize_bop = nfsd4_rename_rsize,
  2247		},
  2248		[OP_RENEW] = {
  2249			.op_func = nfsd4_renew,
  2250			.op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS
  2251					| OP_MODIFIES_SOMETHING,
  2252			.op_name = "OP_RENEW",
  2253			.op_rsize_bop = nfsd4_only_status_rsize,
  2254	
  2255		},
  2256		[OP_RESTOREFH] = {
  2257			.op_func = nfsd4_restorefh,
  2258			.op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS
  2259					| OP_IS_PUTFH_LIKE | OP_MODIFIES_SOMETHING,
  2260			.op_name = "OP_RESTOREFH",
  2261			.op_rsize_bop = nfsd4_only_status_rsize,
  2262		},
  2263		[OP_SAVEFH] = {
  2264			.op_func = nfsd4_savefh,
  2265			.op_flags = OP_HANDLES_WRONGSEC | OP_MODIFIES_SOMETHING,
  2266			.op_name = "OP_SAVEFH",
  2267			.op_rsize_bop = nfsd4_only_status_rsize,
  2268		},
  2269		[OP_SECINFO] = {
  2270			.op_func = nfsd4_secinfo,
  2271			.op_release = nfsd4_secinfo_release,
  2272			.op_flags = OP_HANDLES_WRONGSEC,
  2273			.op_name = "OP_SECINFO",
  2274			.op_rsize_bop = nfsd4_secinfo_rsize,
  2275		},
  2276		[OP_SETATTR] = {
  2277			.op_func = nfsd4_setattr,
  2278			.op_name = "OP_SETATTR",
  2279			.op_flags = OP_MODIFIES_SOMETHING | OP_CACHEME,
  2280			.op_rsize_bop = nfsd4_setattr_rsize,
  2281			.op_get_currentstateid = nfsd4_get_setattrstateid,
  2282		},
  2283		[OP_SETCLIENTID] = {
  2284			.op_func = nfsd4_setclientid,
  2285			.op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS
  2286					| OP_MODIFIES_SOMETHING | OP_CACHEME,
  2287			.op_name = "OP_SETCLIENTID",
  2288			.op_rsize_bop = nfsd4_setclientid_rsize,
  2289		},
  2290		[OP_SETCLIENTID_CONFIRM] = {
  2291			.op_func = nfsd4_setclientid_confirm,
  2292			.op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS
  2293					| OP_MODIFIES_SOMETHING | OP_CACHEME,
  2294			.op_name = "OP_SETCLIENTID_CONFIRM",
  2295			.op_rsize_bop = nfsd4_only_status_rsize,
  2296		},
  2297		[OP_VERIFY] = {
  2298			.op_func = nfsd4_verify,
  2299			.op_name = "OP_VERIFY",
  2300			.op_rsize_bop = nfsd4_only_status_rsize,
  2301		},
  2302		[OP_WRITE] = {
  2303			.op_func = nfsd4_write,
  2304			.op_flags = OP_MODIFIES_SOMETHING | OP_CACHEME,
  2305			.op_name = "OP_WRITE",
  2306			.op_rsize_bop = nfsd4_write_rsize,
  2307			.op_get_currentstateid = nfsd4_get_writestateid,
  2308		},
  2309		[OP_RELEASE_LOCKOWNER] = {
  2310			.op_func = nfsd4_release_lockowner,
  2311			.op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS
  2312					| OP_MODIFIES_SOMETHING,
  2313			.op_name = "OP_RELEASE_LOCKOWNER",
  2314			.op_rsize_bop = nfsd4_only_status_rsize,
  2315		},
  2316	
  2317		/* NFSv4.1 operations */
  2318		[OP_EXCHANGE_ID] = {
  2319			.op_func = nfsd4_exchange_id,
  2320			.op_flags = ALLOWED_WITHOUT_FH | ALLOWED_AS_FIRST_OP
  2321					| OP_MODIFIES_SOMETHING,
  2322			.op_name = "OP_EXCHANGE_ID",
  2323			.op_rsize_bop = nfsd4_exchange_id_rsize,
  2324		},
  2325		[OP_BACKCHANNEL_CTL] = {
  2326			.op_func = nfsd4_backchannel_ctl,
  2327			.op_flags = ALLOWED_WITHOUT_FH | OP_MODIFIES_SOMETHING,
  2328			.op_name = "OP_BACKCHANNEL_CTL",
  2329			.op_rsize_bop = nfsd4_only_status_rsize,
  2330		},
  2331		[OP_BIND_CONN_TO_SESSION] = {
  2332			.op_func = nfsd4_bind_conn_to_session,
  2333			.op_flags = ALLOWED_WITHOUT_FH | ALLOWED_AS_FIRST_OP
  2334					| OP_MODIFIES_SOMETHING,
  2335			.op_name = "OP_BIND_CONN_TO_SESSION",
  2336			.op_rsize_bop = nfsd4_bind_conn_to_session_rsize,
  2337		},
  2338		[OP_CREATE_SESSION] = {
  2339			.op_func = nfsd4_create_session,
  2340			.op_flags = ALLOWED_WITHOUT_FH | ALLOWED_AS_FIRST_OP
  2341					| OP_MODIFIES_SOMETHING,
  2342			.op_name = "OP_CREATE_SESSION",
  2343			.op_rsize_bop = nfsd4_create_session_rsize,
  2344		},
  2345		[OP_DESTROY_SESSION] = {
  2346			.op_func = nfsd4_destroy_session,
  2347			.op_flags = ALLOWED_WITHOUT_FH | ALLOWED_AS_FIRST_OP
  2348					| OP_MODIFIES_SOMETHING,
  2349			.op_name = "OP_DESTROY_SESSION",
  2350			.op_rsize_bop = nfsd4_only_status_rsize,
  2351		},
  2352		[OP_SEQUENCE] = {
  2353			.op_func = nfsd4_sequence,
  2354			.op_flags = ALLOWED_WITHOUT_FH | ALLOWED_AS_FIRST_OP,
  2355			.op_name = "OP_SEQUENCE",
  2356			.op_rsize_bop = nfsd4_sequence_rsize,
  2357		},
  2358		[OP_DESTROY_CLIENTID] = {
  2359			.op_func = nfsd4_destroy_clientid,
  2360			.op_flags = ALLOWED_WITHOUT_FH | ALLOWED_AS_FIRST_OP
  2361					| OP_MODIFIES_SOMETHING,
  2362			.op_name = "OP_DESTROY_CLIENTID",
  2363			.op_rsize_bop = nfsd4_only_status_rsize,
  2364		},
  2365		[OP_RECLAIM_COMPLETE] = {
  2366			.op_func = nfsd4_reclaim_complete,
  2367			.op_flags = ALLOWED_WITHOUT_FH | OP_MODIFIES_SOMETHING,
  2368			.op_name = "OP_RECLAIM_COMPLETE",
  2369			.op_rsize_bop = nfsd4_only_status_rsize,
  2370		},
  2371		[OP_SECINFO_NO_NAME] = {
  2372			.op_func = nfsd4_secinfo_no_name,
  2373			.op_release = nfsd4_secinfo_release,
  2374			.op_flags = OP_HANDLES_WRONGSEC,
  2375			.op_name = "OP_SECINFO_NO_NAME",
  2376			.op_rsize_bop = nfsd4_secinfo_rsize,
  2377		},
  2378		[OP_TEST_STATEID] = {
  2379			.op_func = nfsd4_test_stateid,
  2380			.op_flags = ALLOWED_WITHOUT_FH,
  2381			.op_name = "OP_TEST_STATEID",
  2382			.op_rsize_bop = nfsd4_test_stateid_rsize,
  2383		},
  2384		[OP_FREE_STATEID] = {
  2385			.op_func = nfsd4_free_stateid,
  2386			.op_flags = ALLOWED_WITHOUT_FH | OP_MODIFIES_SOMETHING,
  2387			.op_name = "OP_FREE_STATEID",
  2388			.op_get_currentstateid = nfsd4_get_freestateid,
  2389			.op_rsize_bop = nfsd4_only_status_rsize,
  2390		},
  2391	#ifdef CONFIG_NFSD_PNFS
  2392		[OP_GETDEVICEINFO] = {
  2393			.op_func = nfsd4_getdeviceinfo,
  2394			.op_release = nfsd4_getdeviceinfo_release,
  2395			.op_flags = ALLOWED_WITHOUT_FH,
  2396			.op_name = "OP_GETDEVICEINFO",
  2397			.op_rsize_bop = nfsd4_getdeviceinfo_rsize,
  2398		},
  2399		[OP_LAYOUTGET] = {
  2400			.op_func = nfsd4_layoutget,
> 2401			.op_release = nfsd4_layoutget_release,
  2402			.op_flags = OP_MODIFIES_SOMETHING,
  2403			.op_name = "OP_LAYOUTGET",
  2404			.op_rsize_bop = nfsd4_layoutget_rsize,
  2405		},
  2406		[OP_LAYOUTCOMMIT] = {
  2407			.op_func = nfsd4_layoutcommit,
  2408			.op_flags = OP_MODIFIES_SOMETHING,
  2409			.op_name = "OP_LAYOUTCOMMIT",
  2410			.op_rsize_bop = nfsd4_layoutcommit_rsize,
  2411		},
  2412		[OP_LAYOUTRETURN] = {
  2413			.op_func = nfsd4_layoutreturn,
  2414			.op_flags = OP_MODIFIES_SOMETHING,
  2415			.op_name = "OP_LAYOUTRETURN",
  2416			.op_rsize_bop = nfsd4_layoutreturn_rsize,
  2417		},
  2418	#endif /* CONFIG_NFSD_PNFS */
  2419	
  2420		/* NFSv4.2 operations */
  2421		[OP_ALLOCATE] = {
  2422			.op_func = nfsd4_allocate,
  2423			.op_flags = OP_MODIFIES_SOMETHING | OP_CACHEME,
  2424			.op_name = "OP_ALLOCATE",
  2425			.op_rsize_bop = nfsd4_only_status_rsize,
  2426		},
  2427		[OP_DEALLOCATE] = {
  2428			.op_func = nfsd4_deallocate,
  2429			.op_flags = OP_MODIFIES_SOMETHING | OP_CACHEME,
  2430			.op_name = "OP_DEALLOCATE",
  2431			.op_rsize_bop = nfsd4_only_status_rsize,
  2432		},
  2433		[OP_CLONE] = {
  2434			.op_func = nfsd4_clone,
  2435			.op_flags = OP_MODIFIES_SOMETHING | OP_CACHEME,
  2436			.op_name = "OP_CLONE",
  2437			.op_rsize_bop = nfsd4_only_status_rsize,
  2438		},
  2439		[OP_COPY] = {
  2440			.op_func = nfsd4_copy,
  2441			.op_flags = OP_MODIFIES_SOMETHING | OP_CACHEME,
  2442			.op_name = "OP_COPY",
  2443			.op_rsize_bop = nfsd4_copy_rsize,
  2444		},
  2445		[OP_SEEK] = {
  2446			.op_func = nfsd4_seek,
  2447			.op_name = "OP_SEEK",
  2448			.op_rsize_bop = nfsd4_seek_rsize,
  2449		},
  2450	};
  2451	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
J. Bruce Fields July 17, 2017, 6:44 p.m. UTC | #3
On Sat, Jul 15, 2017 at 05:27:48PM +0800, kbuild test robot wrote:
> Hi Bruce,
> 
> [auto build test ERROR on next-20170710]
> [cannot apply to nfsd/nfsd-next v4.12 v4.12-rc7 v4.12-rc6 v4.12]
> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

These patches depend on patches that are in 13-rc1.

--b.

> 
> url:    https://github.com/0day-ci/linux/commits/J-Bruce-Fields/skip-op-encoders-in-error-cases/20170715-165807
> config: xtensa-allyesconfig (attached as .config)
> compiler: xtensa-linux-gcc (GCC) 4.9.0
> reproduce:
>         wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # save the attached .config to linux build tree
>         make.cross ARCH=xtensa 
> 
> All error/warnings (new ones prefixed by >>):
> 
>    fs/nfsd/nfs4proc.c: In function 'nfsd4_getdeviceinfo_release':
> >> fs/nfsd/nfs4proc.c:1356:8: error: 'gdev' undeclared (first use in this function)
>      kfree(gdev->gd_device);
>            ^
>    fs/nfsd/nfs4proc.c:1356:8: note: each undeclared identifier is reported only once for each function it appears in
>    fs/nfsd/nfs4proc.c: At top level:
> >> fs/nfsd/nfs4proc.c:1439:1: warning: return type defaults to 'int' [-Wreturn-type]
>     nfsd4_layoutget_release(union nfsd4_op_u *u)
>     ^
>    fs/nfsd/nfs4proc.c: In function 'nfsd4_layoutget_release':
> >> fs/nfsd/nfs4proc.c:1441:8: error: 'lgp' undeclared (first use in this function)
>      kfree(lgp->lg_content);
>            ^
>    fs/nfsd/nfs4proc.c: At top level:
> >> fs/nfsd/nfs4proc.c:2401:3: warning: initialization from incompatible pointer type
>       .op_release = nfsd4_layoutget_release,
>       ^
>    fs/nfsd/nfs4proc.c:2401:3: warning: (near initialization for 'nfsd4_ops[50].op_release')
>    fs/nfsd/nfs4proc.c: In function 'nfsd4_layoutget_release':
> >> fs/nfsd/nfs4proc.c:1442:1: warning: control reaches end of non-void function [-Wreturn-type]
>     }
>     ^
> 
> vim +/gdev +1356 fs/nfsd/nfs4proc.c
> 
>   1352	
>   1353	static void
>   1354	nfsd4_getdeviceinfo_release(union nfsd4_op_u *u)
>   1355	{
> > 1356		kfree(gdev->gd_device);
>   1357	}
>   1358	
>   1359	static __be32
>   1360	nfsd4_layoutget(struct svc_rqst *rqstp,
>   1361			struct nfsd4_compound_state *cstate, union nfsd4_op_u *u)
>   1362	{
>   1363		struct nfsd4_layoutget *lgp = &u->layoutget;
>   1364		struct svc_fh *current_fh = &cstate->current_fh;
>   1365		const struct nfsd4_layout_ops *ops;
>   1366		struct nfs4_layout_stateid *ls;
>   1367		__be32 nfserr;
>   1368		int accmode;
>   1369	
>   1370		switch (lgp->lg_seg.iomode) {
>   1371		case IOMODE_READ:
>   1372			accmode = NFSD_MAY_READ;
>   1373			break;
>   1374		case IOMODE_RW:
>   1375			accmode = NFSD_MAY_READ | NFSD_MAY_WRITE;
>   1376			break;
>   1377		default:
>   1378			dprintk("%s: invalid iomode %d\n",
>   1379				__func__, lgp->lg_seg.iomode);
>   1380			nfserr = nfserr_badiomode;
>   1381			goto out;
>   1382		}
>   1383	
>   1384		nfserr = fh_verify(rqstp, current_fh, 0, accmode);
>   1385		if (nfserr)
>   1386			goto out;
>   1387	
>   1388		nfserr = nfserr_layoutunavailable;
>   1389		ops = nfsd4_layout_verify(current_fh->fh_export, lgp->lg_layout_type);
>   1390		if (!ops)
>   1391			goto out;
>   1392	
>   1393		/*
>   1394		 * Verify minlength and range as per RFC5661:
>   1395		 *  o  If loga_length is less than loga_minlength,
>   1396		 *     the metadata server MUST return NFS4ERR_INVAL.
>   1397		 *  o  If the sum of loga_offset and loga_minlength exceeds
>   1398		 *     NFS4_UINT64_MAX, and loga_minlength is not
>   1399		 *     NFS4_UINT64_MAX, the error NFS4ERR_INVAL MUST result.
>   1400		 *  o  If the sum of loga_offset and loga_length exceeds
>   1401		 *     NFS4_UINT64_MAX, and loga_length is not NFS4_UINT64_MAX,
>   1402		 *     the error NFS4ERR_INVAL MUST result.
>   1403		 */
>   1404		nfserr = nfserr_inval;
>   1405		if (lgp->lg_seg.length < lgp->lg_minlength ||
>   1406		    (lgp->lg_minlength != NFS4_MAX_UINT64 &&
>   1407		     lgp->lg_minlength > NFS4_MAX_UINT64 - lgp->lg_seg.offset) ||
>   1408		    (lgp->lg_seg.length != NFS4_MAX_UINT64 &&
>   1409		     lgp->lg_seg.length > NFS4_MAX_UINT64 - lgp->lg_seg.offset))
>   1410			goto out;
>   1411		if (lgp->lg_seg.length == 0)
>   1412			goto out;
>   1413	
>   1414		nfserr = nfsd4_preprocess_layout_stateid(rqstp, cstate, &lgp->lg_sid,
>   1415							true, lgp->lg_layout_type, &ls);
>   1416		if (nfserr) {
>   1417			trace_layout_get_lookup_fail(&lgp->lg_sid);
>   1418			goto out;
>   1419		}
>   1420	
>   1421		nfserr = nfserr_recallconflict;
>   1422		if (atomic_read(&ls->ls_stid.sc_file->fi_lo_recalls))
>   1423			goto out_put_stid;
>   1424	
>   1425		nfserr = ops->proc_layoutget(d_inode(current_fh->fh_dentry),
>   1426					     current_fh, lgp);
>   1427		if (nfserr)
>   1428			goto out_put_stid;
>   1429	
>   1430		nfserr = nfsd4_insert_layout(lgp, ls);
>   1431	
>   1432	out_put_stid:
>   1433		mutex_unlock(&ls->ls_mutex);
>   1434		nfs4_put_stid(&ls->ls_stid);
>   1435	out:
>   1436		return nfserr;
>   1437	}
>   1438	
> > 1439	nfsd4_layoutget_release(union nfsd4_op_u *u)
>   1440	{
> > 1441		kfree(lgp->lg_content);
> > 1442	}
>   1443	
> 
> ---
> 0-DAY kernel test infrastructure                Open Source Technology Center
> https://lists.01.org/pipermail/kbuild-all                   Intel Corporation


--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index 01d7f2456f62..8944b00fd3cd 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -784,6 +784,14 @@  nfsd4_read(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
 	return status;
 }
 
+
+static void
+nfsd4_read_release(union nfsd4_op_u *u)
+{
+	if (u->read.rd_filp)
+		fput(u->read.rd_filp);
+}
+
 static __be32
 nfsd4_readdir(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
 	      union nfsd4_op_u *u)
@@ -912,6 +920,13 @@  nfsd4_secinfo_no_name(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstat
 	return nfs_ok;
 }
 
+static void
+nfsd4_secinfo_release(union nfsd4_op_u *u)
+{
+	if (u->secinfo.si_exp)
+		exp_put(u->secinfo.si_exp);
+}
+
 static __be32
 nfsd4_setattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
 	      union nfsd4_op_u *u)
@@ -1335,6 +1350,12 @@  nfsd4_getdeviceinfo(struct svc_rqst *rqstp,
 	return nfserr;
 }
 
+static void
+nfsd4_getdeviceinfo_release(union nfsd4_op_u *u)
+{
+	kfree(gdev->gd_device);
+}
+
 static __be32
 nfsd4_layoutget(struct svc_rqst *rqstp,
 		struct nfsd4_compound_state *cstate, union nfsd4_op_u *u)
@@ -1415,6 +1436,11 @@  nfsd4_layoutget(struct svc_rqst *rqstp,
 	return nfserr;
 }
 
+nfsd4_layoutget_release(union nfsd4_op_u *u)
+{
+	kfree(lgp->lg_content);
+}
+
 static __be32
 nfsd4_layoutcommit(struct svc_rqst *rqstp,
 		struct nfsd4_compound_state *cstate, union nfsd4_op_u *u)
@@ -2192,6 +2218,7 @@  static const struct nfsd4_operation nfsd4_ops[] = {
 	},
 	[OP_READ] = {
 		.op_func = nfsd4_read,
+		.op_release = nfsd4_read_release,
 		.op_name = "OP_READ",
 		.op_rsize_bop = nfsd4_read_rsize,
 		.op_get_currentstateid = nfsd4_get_readstateid,
@@ -2241,6 +2268,7 @@  static const struct nfsd4_operation nfsd4_ops[] = {
 	},
 	[OP_SECINFO] = {
 		.op_func = nfsd4_secinfo,
+		.op_release = nfsd4_secinfo_release,
 		.op_flags = OP_HANDLES_WRONGSEC,
 		.op_name = "OP_SECINFO",
 		.op_rsize_bop = nfsd4_secinfo_rsize,
@@ -2342,6 +2370,7 @@  static const struct nfsd4_operation nfsd4_ops[] = {
 	},
 	[OP_SECINFO_NO_NAME] = {
 		.op_func = nfsd4_secinfo_no_name,
+		.op_release = nfsd4_secinfo_release,
 		.op_flags = OP_HANDLES_WRONGSEC,
 		.op_name = "OP_SECINFO_NO_NAME",
 		.op_rsize_bop = nfsd4_secinfo_rsize,
@@ -2362,12 +2391,14 @@  static const struct nfsd4_operation nfsd4_ops[] = {
 #ifdef CONFIG_NFSD_PNFS
 	[OP_GETDEVICEINFO] = {
 		.op_func = nfsd4_getdeviceinfo,
+		.op_release = nfsd4_getdeviceinfo_release,
 		.op_flags = ALLOWED_WITHOUT_FH,
 		.op_name = "OP_GETDEVICEINFO",
 		.op_rsize_bop = nfsd4_getdeviceinfo_rsize,
 	},
 	[OP_LAYOUTGET] = {
 		.op_func = nfsd4_layoutget,
+		.op_release = nfsd4_layoutget_release,
 		.op_flags = OP_MODIFIES_SOMETHING,
 		.op_name = "OP_LAYOUTGET",
 		.op_rsize_bop = nfsd4_layoutget_rsize,
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 40ed23fda814..7d683e3aebf0 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -3593,8 +3593,6 @@  nfsd4_encode_read(struct nfsd4_compoundres *resp, __be32 nfserr,
 		xdr_truncate_encode(xdr, starting_len);
 
 out:
-	if (file)
-		fput(file);
 	return nfserr;
 }
 
@@ -3838,8 +3836,6 @@  nfsd4_do_encode_secinfo(struct xdr_stream *xdr,
 	*flavorsp = htonl(supported);
 	nfserr = 0;
 out:
-	if (exp)
-		exp_put(exp);
 	return nfserr;
 }
 
@@ -4172,7 +4168,6 @@  nfsd4_encode_getdeviceinfo(struct nfsd4_compoundres *resp, __be32 nfserr,
 
 	nfserr = 0;
 out:
-	kfree(gdev->gd_device);
 	dprintk("%s: done: %d\n", __func__, be32_to_cpu(nfserr));
 	return nfserr;
 
@@ -4221,7 +4216,6 @@  nfsd4_encode_layoutget(struct nfsd4_compoundres *resp, __be32 nfserr,
 	ops = nfsd4_layout_ops[lgp->lg_layout_type];
 	nfserr = ops->encode_layoutget(xdr, lgp);
 out:
-	kfree(lgp->lg_content);
 	return nfserr;
 }
 
@@ -4452,6 +4446,7 @@  nfsd4_encode_operation(struct nfsd4_compoundres *resp, struct nfsd4_op *op)
 	struct xdr_stream *xdr = &resp->xdr;
 	struct nfs4_stateowner *so = resp->cstate.replay_owner;
 	struct svc_rqst *rqstp = resp->rqstp;
+	const struct nfsd4_operation *opdesc = op->opdesc;
 	int post_err_offset;
 	nfsd4_enc encoder;
 	__be32 *p;
@@ -4470,6 +4465,8 @@  nfsd4_encode_operation(struct nfsd4_compoundres *resp, struct nfsd4_op *op)
 	       !nfsd4_enc_ops[op->opnum]);
 	encoder = nfsd4_enc_ops[op->opnum];
 	op->status = encoder(resp, op->status, &op->u);
+	if (opdesc && opdesc->op_release)
+		opdesc->op_release(&op->u);
 	xdr_commit_encode(xdr);
 
 	/* nfsd4_check_resp_size guarantees enough room for error status */
diff --git a/fs/nfsd/xdr4.h b/fs/nfsd/xdr4.h
index 90b928006bc7..1e6274e0e066 100644
--- a/fs/nfsd/xdr4.h
+++ b/fs/nfsd/xdr4.h
@@ -783,6 +783,7 @@  enum nfsd4_op_flags {
 struct nfsd4_operation {
 	__be32 (*op_func)(struct svc_rqst *, struct nfsd4_compound_state *,
 			union nfsd4_op_u *);
+	void (*op_release)(union nfsd4_op_u *);
 	u32 op_flags;
 	char *op_name;
 	/* Try to get response size before operation */