Skip to content

Commit

Permalink
nfsv3: simplify uid3, gid3 objects
Browse files Browse the repository at this point in the history
Motivation:
uid3 and gid3 object are wraps around uint32, which is by itself wrap around
int.

Modification:
simplify buid3 and gid3y wrapping directly int

Result:
less load on GC.

Acked-by: Paul Millar
Acked-by: Marina Sahakyan
Target: master
  • Loading branch information
kofemann committed Feb 26, 2021
1 parent 2056c67 commit 235e266
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions core/src/main/java/org/dcache/nfs/v3/HimeraNfsUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ public static void fill_attributes(Stat stat, fattr3 at) {
at.nlink= new uint32( stat.getNlink() );

//public int uid;
at.uid= new uid3( new uint32(stat.getUid()) );
at.uid= new uid3(stat.getUid());

//public int gid;
at.gid=new gid3(new uint32( stat.getGid()) );
at.gid=new gid3(stat.getGid());

//public int rdev;
at.rdev = new specdata3();
Expand Down Expand Up @@ -122,11 +122,11 @@ public static void set_sattr(Inode inode, VirtualFileSystem fs, sattr3 s) throws
long now = System.currentTimeMillis();

if( s.uid.set_it ) {
stat.setUid( s.uid.uid.value.value);
stat.setUid( s.uid.uid.value);
}

if( s.gid.set_it ) {
stat.setGid(s.gid.gid.value.value);
stat.setGid(s.gid.gid.value);
}

if( s.mode.set_it ) {
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/org/dcache/nfs/v3/NfsServerV3.java
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ public CREATE3res NFSPROC3_CREATE_3(RpcCall call$, CREATE3args arg1) {
if (newAttr != null) {
fmode = newAttr.mode.mode.value.value | Stat.S_IFREG;
if( newAttr.uid.set_it || newAttr.gid.set_it) {
actualSubject = UnixSubjects.toSubject(newAttr.uid.uid.value.value, newAttr.gid.gid.value.value);
actualSubject = UnixSubjects.toSubject(newAttr.uid.uid.value, newAttr.gid.gid.value);
}
}
inode = fs.create(parent, Stat.Type.REGULAR, path, actualSubject, fmode);
Expand Down Expand Up @@ -611,7 +611,7 @@ public MKDIR3res NFSPROC3_MKDIR_3(RpcCall call$, MKDIR3args arg1) {
if (attr != null) {
mode = attr.mode.mode.value.value | Stat.S_IFDIR;
if( attr.uid.set_it || attr.gid.set_it) {
actualSubject = UnixSubjects.toSubject(attr.uid.uid.value.value, attr.gid.gid.value.value);
actualSubject = UnixSubjects.toSubject(attr.uid.uid.value, attr.gid.gid.value);
}
}

Expand Down
10 changes: 5 additions & 5 deletions core/src/main/java/org/dcache/nfs/v3/xdr/gid3.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009 - 2012 Deutsches Elektronen-Synchroton,
* Copyright (c) 2009 - 2021 Deutsches Elektronen-Synchroton,
* Member of the Helmholtz Association, (DESY), HAMBURG, GERMANY
*
* This library is free software; you can redistribute it and/or modify
Expand All @@ -26,12 +26,12 @@

public class gid3 implements XdrAble {

public uint32 value;
public int value;

public gid3() {
}

public gid3(uint32 value) {
public gid3(int value) {
this.value = value;
}

Expand All @@ -42,12 +42,12 @@ public gid3(XdrDecodingStream xdr)

public void xdrEncode(XdrEncodingStream xdr)
throws OncRpcException, IOException {
value.xdrEncode(xdr);
xdr.xdrEncodeInt(value);
}

public void xdrDecode(XdrDecodingStream xdr)
throws OncRpcException, IOException {
value = new uint32(xdr);
value = xdr.xdrDecodeInt();
}

}
Expand Down
10 changes: 5 additions & 5 deletions core/src/main/java/org/dcache/nfs/v3/xdr/uid3.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009 - 2012 Deutsches Elektronen-Synchroton,
* Copyright (c) 2009 - 2021 Deutsches Elektronen-Synchroton,
* Member of the Helmholtz Association, (DESY), HAMBURG, GERMANY
*
* This library is free software; you can redistribute it and/or modify
Expand All @@ -26,12 +26,12 @@

public class uid3 implements XdrAble {

public uint32 value;
public int value;

public uid3() {
}

public uid3(uint32 value) {
public uid3(int value) {
this.value = value;
}

Expand All @@ -42,12 +42,12 @@ public uid3(XdrDecodingStream xdr)

public void xdrEncode(XdrEncodingStream xdr)
throws OncRpcException, IOException {
value.xdrEncode(xdr);
xdr.xdrEncodeInt(value);
}

public void xdrDecode(XdrDecodingStream xdr)
throws OncRpcException, IOException {
value = new uint32(xdr);
value = xdr.xdrDecodeInt();
}

}
Expand Down

0 comments on commit 235e266

Please sign in to comment.