Skip to content

Commit

Permalink
Revert "Bugfix: Only free space if the removed file was the last link"
Browse files Browse the repository at this point in the history
This reverts commit 07c68a0.

The patch breaks dcache causing deletes to fail
  • Loading branch information
kschwank committed Mar 29, 2015
1 parent fb1563e commit b86e89c
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ public PnfsId createSymLink(Subject subject, String path, String dest, int uid,
}

@Override
public int deleteEntry(Subject subject, PnfsId pnfsId)
public void deleteEntry(Subject subject, PnfsId pnfsId)
throws CacheException
{
try {
Expand Down Expand Up @@ -341,7 +341,6 @@ public int deleteEntry(Subject subject, PnfsId pnfsId)
}

_fs.remove(inode);
return inode.stat().getNlink();
}catch(FileNotFoundHimeraFsException fnf) {
throw new FileNotFoundCacheException("No such file or directory: " + pnfsId);
}catch(DirNotEmptyHimeraFsException e) {
Expand All @@ -353,7 +352,7 @@ public int deleteEntry(Subject subject, PnfsId pnfsId)
}

@Override
public int deleteEntry(Subject subject, String path)
public void deleteEntry(Subject subject, String path)
throws CacheException
{
try {
Expand Down Expand Up @@ -387,7 +386,6 @@ public int deleteEntry(Subject subject, String path)
}

_fs.remove(path);
return pathToInode(subject, path).stat().getNlink();
}catch(FileNotFoundHimeraFsException fnf) {
throw new FileNotFoundCacheException("No such file or directory: " + path);
}catch(DirNotEmptyHimeraFsException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,14 @@ public class PnfsDeleteEntryMessage extends PnfsMessage
*/
private final Set<FileType> _allowed;

/**
* remaining hardlinks for the file
*/
private int _remainingLinks;

public PnfsDeleteEntryMessage(String path)
{
this(null, path);
this(null, path);
}

public PnfsDeleteEntryMessage(PnfsId pnfsId)
{
this(pnfsId, (String) null);
this(pnfsId, (String) null);
}

public PnfsDeleteEntryMessage(PnfsId pnfsId, String path)
Expand All @@ -55,24 +50,16 @@ public PnfsDeleteEntryMessage(PnfsId pnfsId, Set<FileType> allowed)
public PnfsDeleteEntryMessage(PnfsId pnfsId, String path,
Set<FileType> allowed)
{
super(pnfsId);
super(pnfsId);
_allowed = allowed;
_path = path;
_path = path;
setPnfsPath(path);
setReplyRequired(false);
}

public void setRemainingLinks(int nLinks) {
_remainingLinks = nLinks;
}

public int getRemainingLinks() {
return _remainingLinks;
setReplyRequired(false);
}

public String getPath()
{
return _path;
return _path;
}

public Set<FileType> getAllowedFileTypes()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ public PnfsId createSymLink(Subject subject, String path, String dest, int uid,
}

@Override
public int deleteEntry(Subject subject, PnfsId pnfsId)
public void deleteEntry(Subject subject, PnfsId pnfsId)
throws CacheException
{
throw new UnsupportedOperationException();
}

@Override
public int deleteEntry(Subject subject, String path)
public void deleteEntry(Subject subject, String path)
throws CacheException
{
throw new UnsupportedOperationException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,16 @@ FileAttributes createFile(Subject subject, String path, int uid, int gid, int mo
* @param subject Subject of user who invoked this method.
* @param pnfsId
* @throws CacheException
* @return remaining number of links for the underlying inode
*/
int deleteEntry(Subject subject, PnfsId pnfsId) throws CacheException;
void deleteEntry(Subject subject, PnfsId pnfsId) throws CacheException;

/**
* remove file or directory
* @param subject Subject of user who invoked this method.
* @param path
* @throws CacheException
* @return remaining number of links for the underlying inode
*/
int deleteEntry(Subject subject, String path) throws CacheException;
void deleteEntry(Subject subject, String path) throws CacheException;

void renameEntry(Subject subject, PnfsId pnfsId, String newName,
boolean overwrite) throws CacheException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -1295,7 +1296,7 @@ public void deleteEntry(PnfsDeleteEntryMessage pnfsMessage){
pnfsMessage.getAccessMask());

/*
* race condition check:
* raice condition check:
*
* in some cases ( srm overwrite ) one failed transfer may remove a file
* which belongs to an other transfer.
Expand All @@ -1320,7 +1321,7 @@ public void deleteEntry(PnfsDeleteEntryMessage pnfsMessage){
}

_log.info("delete PNFS entry for "+ path );
pnfsMessage.setRemainingLinks(_nameSpaceProvider.deleteEntry(subject, path));
_nameSpaceProvider.deleteEntry(subject, path);
} else {
if (!isOfType(pnfsId, allowed)) {
if (allowed.contains(FileType.DIR)) {
Expand All @@ -1333,7 +1334,7 @@ public void deleteEntry(PnfsDeleteEntryMessage pnfsMessage){
checkMask(pnfsMessage);

_log.info("delete PNFS entry for "+ pnfsId );
pnfsMessage.setRemainingLinks(_nameSpaceProvider.deleteEntry(subject, pnfsId));
_nameSpaceProvider.deleteEntry(subject, pnfsId);
}

pnfsMessage.setSucceeded();
Expand All @@ -1349,8 +1350,7 @@ public void deleteEntry(PnfsDeleteEntryMessage pnfsMessage){
}

if( pnfsMessage.getReturnCode() == 0 &&
_pnfsDeleteNotificationRelay != null &&
pnfsMessage.getRemainingLinks() == 0) {
_pnfsDeleteNotificationRelay != null ) {
PnfsDeleteEntryNotificationMessage deleteNotification =
new PnfsDeleteEntryNotificationMessage(pnfsId,path);
try{
Expand Down
14 changes: 7 additions & 7 deletions modules/dcache/src/main/java/diskCacheV111/util/PnfsHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -336,22 +336,22 @@ public PnfsId deletePnfsEntry(String path, Set<FileType> allowed)
return pnfsRequest(new PnfsDeleteEntryMessage(null, path, allowed)).getPnfsId();
}

public int deletePnfsEntry(PnfsId pnfsid) throws CacheException
public void deletePnfsEntry(PnfsId pnfsid) throws CacheException
{
return deletePnfsEntry(pnfsid, null);
deletePnfsEntry(pnfsid, null);
}

public int deletePnfsEntry(PnfsId pnfsid, String path)
public void deletePnfsEntry(PnfsId pnfsid, String path)
throws CacheException
{
return deletePnfsEntry(pnfsid, path, EnumSet.allOf(FileType.class));
deletePnfsEntry(pnfsid, path, EnumSet.allOf(FileType.class));
}

public int deletePnfsEntry(PnfsId pnfsid, String path,
public void deletePnfsEntry(PnfsId pnfsid, String path,
Set<FileType> allowed)
throws CacheException
{
return pnfsRequest(new PnfsDeleteEntryMessage(pnfsid, path, allowed)).getRemainingLinks();
pnfsRequest(new PnfsDeleteEntryMessage(pnfsid, path, allowed));
}

/**
Expand All @@ -364,7 +364,7 @@ public long getPnfsTimeout() {

/**
* Setter for property __pnfsTimeout.
* @param pnfsTimeout New value of property __pnfsTimeout.
* @param __pnfsTimeout New value of property __pnfsTimeout.
*/
public void setPnfsTimeout(long pnfsTimeout) {
_cellStub.setTimeout(pnfsTimeout);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,17 @@ public PnfsId createSymLink(Subject subject, String path, String dest,
}

@Override
public int deleteEntry(Subject subject, PnfsId id) throws CacheException
public void deleteEntry(Subject subject, PnfsId id) throws CacheException
{
PnfsHandler pnfs = new PnfsHandler(_pnfs, subject);
return pnfs.deletePnfsEntry(id);
pnfs.deletePnfsEntry(id);
}

@Override
public int deleteEntry(Subject subject, String path) throws CacheException
public void deleteEntry(Subject subject, String path) throws CacheException
{
PnfsHandler pnfs = new PnfsHandler(_pnfs, subject);
return pnfs.deletePnfsEntry(null, path);
pnfs.deletePnfsEntry(path);
}

@Override
Expand Down

0 comments on commit b86e89c

Please sign in to comment.