diff options
author | Eric Van Hensbergen <ericvh@gmail.com> | 2008-10-13 21:36:15 -0400 |
---|---|---|
committer | Eric Van Hensbergen <ericvh@gmail.com> | 2008-10-17 12:04:43 -0400 |
commit | 06b55b464ee5b305aca75cb7d9424b184bf07f68 (patch) | |
tree | fb2bba4546ad4b800f1e49a75774b01fc6fcdb6b /net/9p/client.c | |
parent | dfb0ec2e13a906ff19a0bbfa9208caab50cfc2e3 (diff) |
9p: move dirread to fs layer
Currently reading a directory is implemented in the client code.
This function is not actually a wire operation, but a meta operation
which calls read operations and processes the results.
This patch moves this functionality to the fs layer and calls component
wire operations instead of constructing their packets. This provides a
cleaner separation and will help when we reorganize the client functions
and protocol processing methods.
Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
Diffstat (limited to 'net/9p/client.c')
-rw-r--r-- | net/9p/client.c | 103 |
1 files changed, 0 insertions, 103 deletions
diff --git a/net/9p/client.c b/net/9p/client.c index d5ea042eabb0..90ee9efeede3 100644 --- a/net/9p/client.c +++ b/net/9p/client.c | |||
@@ -559,8 +559,6 @@ static struct p9_fid *p9_fid_create(struct p9_client *clnt) | |||
559 | memset(&fid->qid, 0, sizeof(struct p9_qid)); | 559 | memset(&fid->qid, 0, sizeof(struct p9_qid)); |
560 | fid->mode = -1; | 560 | fid->mode = -1; |
561 | fid->rdir_fpos = 0; | 561 | fid->rdir_fpos = 0; |
562 | fid->rdir_pos = 0; | ||
563 | fid->rdir_fcall = NULL; | ||
564 | fid->uid = current->fsuid; | 562 | fid->uid = current->fsuid; |
565 | fid->clnt = clnt; | 563 | fid->clnt = clnt; |
566 | fid->aux = NULL; | 564 | fid->aux = NULL; |
@@ -586,7 +584,6 @@ static void p9_fid_destroy(struct p9_fid *fid) | |||
586 | spin_lock(&clnt->lock); | 584 | spin_lock(&clnt->lock); |
587 | list_del(&fid->flist); | 585 | list_del(&fid->flist); |
588 | spin_unlock(&clnt->lock); | 586 | spin_unlock(&clnt->lock); |
589 | kfree(fid->rdir_fcall); | ||
590 | kfree(fid); | 587 | kfree(fid); |
591 | } | 588 | } |
592 | 589 | ||
@@ -1261,103 +1258,3 @@ done: | |||
1261 | return err; | 1258 | return err; |
1262 | } | 1259 | } |
1263 | EXPORT_SYMBOL(p9_client_wstat); | 1260 | EXPORT_SYMBOL(p9_client_wstat); |
1264 | |||
1265 | struct p9_stat *p9_client_dirread(struct p9_fid *fid, u64 offset) | ||
1266 | { | ||
1267 | int err, n, m; | ||
1268 | struct p9_fcall *tc, *rc; | ||
1269 | struct p9_client *clnt; | ||
1270 | struct p9_stat st, *ret; | ||
1271 | |||
1272 | P9_DPRINTK(P9_DEBUG_9P, "fid %d offset %llu\n", fid->fid, | ||
1273 | (long long unsigned) offset); | ||
1274 | err = 0; | ||
1275 | tc = NULL; | ||
1276 | rc = NULL; | ||
1277 | ret = NULL; | ||
1278 | clnt = fid->clnt; | ||
1279 | |||
1280 | /* if the offset is below or above the current response, free it */ | ||
1281 | if (offset < fid->rdir_fpos || (fid->rdir_fcall && | ||
1282 | offset >= fid->rdir_fpos+fid->rdir_fcall->params.rread.count)) { | ||
1283 | fid->rdir_pos = 0; | ||
1284 | if (fid->rdir_fcall) | ||
1285 | fid->rdir_fpos += fid->rdir_fcall->params.rread.count; | ||
1286 | |||
1287 | kfree(fid->rdir_fcall); | ||
1288 | fid->rdir_fcall = NULL; | ||
1289 | if (offset < fid->rdir_fpos) | ||
1290 | fid->rdir_fpos = 0; | ||
1291 | } | ||
1292 | |||
1293 | if (!fid->rdir_fcall) { | ||
1294 | n = fid->iounit; | ||
1295 | if (!n || n > clnt->msize-P9_IOHDRSZ) | ||
1296 | n = clnt->msize - P9_IOHDRSZ; | ||
1297 | |||
1298 | while (1) { | ||
1299 | if (fid->rdir_fcall) { | ||
1300 | fid->rdir_fpos += | ||
1301 | fid->rdir_fcall->params.rread.count; | ||
1302 | kfree(fid->rdir_fcall); | ||
1303 | fid->rdir_fcall = NULL; | ||
1304 | } | ||
1305 | |||
1306 | tc = p9_create_tread(fid->fid, fid->rdir_fpos, n); | ||
1307 | if (IS_ERR(tc)) { | ||
1308 | err = PTR_ERR(tc); | ||
1309 | tc = NULL; | ||
1310 | goto error; | ||
1311 | } | ||
1312 | |||
1313 | err = p9_client_rpc(clnt, tc, &rc); | ||
1314 | if (err) | ||
1315 | goto error; | ||
1316 | |||
1317 | n = rc->params.rread.count; | ||
1318 | if (n == 0) | ||
1319 | goto done; | ||
1320 | |||
1321 | fid->rdir_fcall = rc; | ||
1322 | rc = NULL; | ||
1323 | if (offset >= fid->rdir_fpos && | ||
1324 | offset < fid->rdir_fpos+n) | ||
1325 | break; | ||
1326 | } | ||
1327 | |||
1328 | fid->rdir_pos = 0; | ||
1329 | } | ||
1330 | |||
1331 | m = offset - fid->rdir_fpos; | ||
1332 | if (m < 0) | ||
1333 | goto done; | ||
1334 | |||
1335 | n = p9_deserialize_stat(fid->rdir_fcall->params.rread.data + m, | ||
1336 | fid->rdir_fcall->params.rread.count - m, &st, clnt->dotu); | ||
1337 | |||
1338 | if (!n) { | ||
1339 | err = -EIO; | ||
1340 | goto error; | ||
1341 | } | ||
1342 | |||
1343 | fid->rdir_pos += n; | ||
1344 | st.size = n; | ||
1345 | ret = p9_clone_stat(&st, clnt->dotu); | ||
1346 | if (IS_ERR(ret)) { | ||
1347 | err = PTR_ERR(ret); | ||
1348 | ret = NULL; | ||
1349 | goto error; | ||
1350 | } | ||
1351 | |||
1352 | done: | ||
1353 | kfree(tc); | ||
1354 | kfree(rc); | ||
1355 | return ret; | ||
1356 | |||
1357 | error: | ||
1358 | kfree(tc); | ||
1359 | kfree(rc); | ||
1360 | kfree(ret); | ||
1361 | return ERR_PTR(err); | ||
1362 | } | ||
1363 | EXPORT_SYMBOL(p9_client_dirread); | ||