Useful PNFS/Chimera SQL Queries

NOTE: This page assumes you are running Chimera/PNFS rather than the older PNFS from dCache 1.8.x or earlier.

First query: Fix PNFS directory structure. We have had cases where certain PNFS directories are not deletable because "directory is not empty". However an 'ls' of the directory shows no files.

To fix this run the following (adapted from similar LFC/MySQL code from Sarah Williams):

create table fscknlink as select ipnfsid,inlink AS oldinlink, (select count(*) from t_dirs as c 
where t_inodes.ipnfsid=c.iparent) AS newinlink from t_inodes where itype=16384;

This will create a new table showing the number of original 'inlinks' (contents) and the current 'inlinks'.

To check the results:
 select ipnfsid,oldinlink,newinlink from fscknlink where oldinlink<>newinlink;

To repair simple run the following query:

UPDATE t_inodes SET inlink = fscknlink.newinlink FROM fscknlink WHERE t_inodes.ipnfsid = fscknlink.ipnfsid AND fscknlink.oldinlink<>fscknlink.newinlink;

Then your PNFS directory structure should be consistent again. You can drop table fscknlink; to remove the temporary table above.

Getting a list of "empty" directories

The following query in the 'chimera' DB will show the pnfs path to all empty directories:
select inode2path(ipnfsid) from t_inodes where itype=16384 and inlink=2;
You can output the list to a file using the Postgres \o command and just use 'rmdir' to remove them (as long as /pnfs is mounted). For example:

for d in $( cat my_empty_pnfs_dirs.dat ); do rmdir -v $d; done

-- ShawnMcKee - 08 Jun 2009
Topic revision: r5 - 16 Oct 2009 - 20:14:45 - TomRockwell
 

This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback