Mercurial > nomad > experimental
changeset 645:054e8a326509
common: expand fscall_open & OPEN to allow open-by-inode-number
Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author | Josef 'Jeff' Sipek <jeffpc@josefsipek.net> |
---|---|
date | Fri, 15 Feb 2019 10:50:47 -0500 |
parents | 1642d345419c |
children | 6a08d8c54363 |
files | docs/fs-protocol.md src/common/fscall.c src/common/include/nomad/fscall.h src/common/rpc_fs.x src/fs/nomadfs.c |
diffstat | 5 files changed, 29 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/docs/fs-protocol.md Fri Feb 15 10:14:04 2019 -0500 +++ b/docs/fs-protocol.md Fri Feb 15 10:50:47 2019 -0500 @@ -170,8 +170,8 @@ OPEN (0x0006) ============= -Given a version of an object (oid and vector clock), open the specified -object and return an open file handle. +Given a version of an object (oid and vector clock, or inode number and +vector clock), open the specified object and return an open file handle. If a non-null vector clock is specified, only that version of the object is considered. If a null vector clock is specificied and there is only one @@ -182,6 +182,7 @@ Inputs ------ * oid +* inode number * vector clock Outputs
--- a/src/common/fscall.c Fri Feb 15 10:14:04 2019 -0500 +++ b/src/common/fscall.c Fri Feb 15 10:50:47 2019 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2018 Josef 'Jeff' Sipek <jeffpc@josefsipek.net> + * Copyright (c) 2016-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net> * Copyright (c) 2016 Steve Dougherty * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -129,13 +129,23 @@ } int fscall_open(struct fscall_state *state, const struct noid *oid, - uint32_t *handle) + uint64_t ino, uint32_t *handle) { struct rpc_open_req open_req; struct rpc_open_res open_res; int ret; - open_req.oid = *oid; + /* only one of oid and ino is allowed */ + if ((oid && !noid_is_null(oid) && ino) || + ((!oid || noid_is_null(oid)) && !ino)) + return -EINVAL; + + if (oid) + open_req.oid = *oid; + else + memset(&open_req.oid, 0, sizeof(open_req.oid)); + + open_req.ino = ino; memset(&open_req.clock, 0, sizeof(open_req.clock)); ret = __fscall(state->sock, NRPC_OPEN, @@ -486,7 +496,7 @@ if (ret) return ret; - ret = fscall_open(state, &state->root_oid, &state->root_ohandle); + ret = fscall_open(state, &state->root_oid, 0, &state->root_ohandle); if (ret) return ret;
--- a/src/common/include/nomad/fscall.h Fri Feb 15 10:14:04 2019 -0500 +++ b/src/common/include/nomad/fscall.h Fri Feb 15 10:50:47 2019 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2018 Josef 'Jeff' Sipek <jeffpc@josefsipek.net> + * Copyright (c) 2016-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -44,7 +44,7 @@ extern int fscall_login(struct fscall_state *state, const char *conn, const struct xuuid *volid); extern int fscall_open(struct fscall_state *state, const struct noid *oid, - uint32_t *handle); + uint64_t ino, uint32_t *handle); extern int fscall_close(struct fscall_state *state, const uint32_t handle); extern int fscall_getattr(struct fscall_state *state, const uint32_t handle, struct nattr *attr);
--- a/src/common/rpc_fs.x Fri Feb 15 10:14:04 2019 -0500 +++ b/src/common/rpc_fs.x Fri Feb 15 10:50:47 2019 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2018 Josef 'Jeff' Sipek <jeffpc@josefsipek.net> + * Copyright (c) 2015-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net> * Copyright (c) 2015 Holly Sipek * Copyright (c) 2015 Joshua Kahn <josh@joshuak.net> * Copyright (c) 2016 Steve Dougherty @@ -97,6 +97,7 @@ %/***** OPEN *****/ struct rpc_open_req { struct noid oid; + uint64_t ino; struct nvclock clock; };
--- a/src/fs/nomadfs.c Fri Feb 15 10:14:04 2019 -0500 +++ b/src/fs/nomadfs.c Fri Feb 15 10:50:47 2019 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2018 Josef 'Jeff' Sipek <jeffpc@josefsipek.net> + * Copyright (c) 2016-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -86,7 +86,7 @@ uint32_t ohandle; int ret; - ret = fscall_open(&state, oid, &ohandle); + ret = fscall_open(&state, oid, 0, &ohandle); if (ret) return ret; @@ -111,7 +111,7 @@ make_oid(&dir_oid, parent); - ret = fscall_open(&state, &dir_oid, &dir_ohandle); + ret = fscall_open(&state, &dir_oid, 0, &dir_ohandle); if (ret) return ret; @@ -176,7 +176,7 @@ stat_to_nattr(attr, &nattr); - ret = fscall_open(&state, &oid, &ohandle); + ret = fscall_open(&state, &oid, 0, &ohandle); if (ret) goto err; @@ -220,7 +220,7 @@ make_oid(&oid, parent); - ret = fscall_open(&state, &oid, &dir_ohandle); + ret = fscall_open(&state, &oid, 0, &dir_ohandle); if (ret) goto err; } @@ -229,7 +229,7 @@ if (ret) goto err_close_dir; - ret = fscall_open(&state, &child_oid, &child_ohandle); + ret = fscall_open(&state, &child_oid, 0, &child_ohandle); if (ret) goto err_close_dir; @@ -391,7 +391,7 @@ if (ret) goto err; - ret = fscall_open(&state, &child_oid, &ohandle); + ret = fscall_open(&state, &child_oid, 0, &ohandle); if (ret) goto err; @@ -427,7 +427,7 @@ make_oid(&oid, ino); - ret = fscall_open(&state, &oid, &ohandle); + ret = fscall_open(&state, &oid, 0, &ohandle); if (ret) goto err;