dCache / dcache

dCache - a system for storing and retrieving huge amounts of data, distributed among a large number of heterogenous server nodes, under a single virtual filesystem tree with a variety of standard access methods
https://dcache.org
284 stars 135 forks source link

inumber2path return empty string for fs root #2389

Open kofemann opened 8 years ago

kofemann commented 8 years ago

if N is an inumber of a root inode, then inumber2path(N) will return empty string:

chimera=# select inumber from t_inodes where ipnfsid='000000000000000000000000000000000000';
 inumber 
---------
       8
(1 row)

chimera=# select inumber2path(8);
 inumber2path 
--------------

(1 row)

chimera=# 
gbehrmann commented 8 years ago

Isn't that the same behavior as we had before? inode2path also returned an empty string when called with the root pnfsid. That's the behavior I tried to keep.

kofemann commented 8 years ago

Yes, the original code from 2005 has this. But this does not prevent as from fixing. Obviously that flow was never used up to now. We have discovered it by accident.

gbehrmann commented 8 years ago

Well, I knew about it and didn't dare to change it as you probably had good reasons to implement it that way :-) But feel free to "fix".

calestyo commented 8 years ago

It seems that these functions could deserve some more polishing (dcache 2.15): path2inode('000000000000000000000000000000000000', '') ); foo="" => function gives an error foo='/' => empty foo='//' => empty (and so on) foo='pnfs' => works foo='pnfs/' => empty

I think sice there cannot be a directory of an empty name, that would justify to handle e.g. pnfs/foo differently from pnfs//foo, these functions should because of robustness automatically collapse any // and also remove and leading and trailing / as necessary,... shouldn't it?

gbehrmann commented 8 years ago

Well, these functions are not for direct user input and thus dcache already does that kind of cleaning of the input. These are used by dcache itself. Pgsql isn't the fastest of all languages and thus I wouldn't add stuff like this.

kofemann commented 8 years ago

As Gerd already said, inumber2path is not designed to be used by users. It's a postgres specific optimization used by dcache.

calestyo commented 8 years ago

hmm, I see.. would it perhaps make sense to have "export" versions of these functions, basically wrappers which sanitise the input? It seems to make sense, as 3rd party stuff like the recent chimera_find.sh case do make use of these functions.