Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chimera: fix get locality to work with id-type FsInode
The current implementation of ".(get)(filename)(locality)" relies on an FsInode type which embeds the filename and the "locality" argument. Since the filename is arbitrarily long, the encoded handle length could exceed the file handle length specified by NFS4. The solution is to change the handling of this command (file) to use the id FsInode type and to encode the operation directly into it. The id (pnfsid) is of fixed length, as is the code for the op. A new FsInode type (PLOC) has been created for this purpose. Several auxiliary methods and private classes which are no longer necessary have also been eliminated. Testing Done: The new code allows this operation to work successfully with both v4 and with the smaller handle size of v3 as well (both were tested). Target: master Request: 2.7 Patch: http://rb.dcache.org/r/6404 Require-book: no Require-notes: yes Acked-by: Tigran RELEASE NOTES: Fixes a bug in the ".(get)(filename)(locality)" preventing successful completion of the call when the filename is very long.
- Loading branch information
alrossi
committed
Jan 16, 2014
1 parent
623a93b
commit 9657929
Showing
4 changed files
with
113 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
modules/chimera/src/main/java/org/dcache/chimera/FsInode_PLOC.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* This library is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU Library General Public License as | ||
* published by the Free Software Foundation; either version 2 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Library General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Library General Public | ||
* License along with this program (see the file COPYING.LIB for more | ||
* details); if not, write to the Free Software Foundation, Inc., | ||
* 675 Mass Ave, Cambridge, MA 02139, USA. | ||
*/ | ||
package org.dcache.chimera; | ||
|
||
import org.dcache.chimera.posix.Stat; | ||
|
||
/** | ||
* This class retrieves file locality metadata via an invocation of | ||
* the pool manager. | ||
* | ||
* @author arossi | ||
*/ | ||
public class FsInode_PLOC extends FsInode { | ||
private String _locality; | ||
|
||
public FsInode_PLOC(FileSystemProvider fs, String id) { | ||
super(fs, id, FsInodeType.PLOC); | ||
} | ||
|
||
@Override | ||
public int read(long pos, byte[] data, int offset, int len) { | ||
String output = _locality == null? "\n" : _locality; | ||
|
||
byte[] b = output.getBytes(); | ||
|
||
if (pos > b.length) { | ||
return 0; | ||
} | ||
|
||
int copyLen = Math.min(len, b.length - (int) pos); | ||
System.arraycopy(b, (int) pos, data, 0, copyLen); | ||
|
||
return copyLen; | ||
} | ||
|
||
|
||
public void setLocality(String locality) { | ||
_locality = locality + "\n"; | ||
} | ||
|
||
@Override | ||
public Stat stat() throws ChimeraFsException { | ||
Stat ret = super.stat(); | ||
ret.setMode((ret.getMode() & 0000777) | UnixPermission.S_IFREG); | ||
ret.setSize(_locality == null ? 0 : _locality.length()); | ||
// invalidate NFS cache | ||
ret.setMTime(System.currentTimeMillis()); | ||
return ret; | ||
} | ||
|
||
@Override | ||
public int write(long pos, byte[] data, int offset, int len) { | ||
return -1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters