Description of problem: Enabling trash feature for a volume is resulting in wrong permissions being set on previous copy of a truncated file for which a corresponding path does not exists under trash directory. This only happens for the first truncation of file under same directory hierarchy. Subsequent truncations creates previous copies with correct permissions. Version-Release number of selected component (if applicable): mainline How reproducible: always Steps to Reproduce: 1. Create, start and mount a simple distributed volume. 2. Enable trash for the volume and change to mount point. # gluster volume set <VOLNAME> features.trash on 3. Create a temporary directory under root. # mkdir tmp 4. Create a file inside tmp/ with some content. # echo 'Hello, World' > tmp/foo 5. Change permissions on tmp/foo # chmod 0777 tmp/foo 5. truncate tmp/foo # truncate -s 3 tmp/foo 6. Check the permissions of the previous copy of foo created inside .trashcan/tmp/ # ls -l .trashcan/tmp Actual results: .trashcan/tmp/foo_xxxx has different permissions than that of tmp/foo Expected results: .trashcan/tmp/foo_xxxx and tmp/foo should match their permission bits.
REVIEW: http://review.gluster.org/13461 (features/trash: Retain file permissions during truncate) posted (#1) for review on master by Anoop C S (anoopcs)
COMMIT: http://review.gluster.org/13461 committed in master by Jeff Darcy (jdarcy) ------ commit b1cb581424305592fac5394a578b307117b22fe7 Author: Anoop C S <anoopcs> Date: Wed Feb 17 15:50:05 2016 +0530 features/trash: Retain file permissions during truncate Consider the situation where directory path for a truncated file does not exists under trash directory. In this scenario after creating the required path we failed to create the orginal file with proper permissions. Eventhough we try to fetch permissions from local->origpath, it was never filled with required value in truncate and ftruncate call paths. This change will copy original location to local->origpath inside both fop handling functions. Change-Id: If5930b6d368d08e58f04db999f3f9edb9250bcb9 BUG: 1309342 Signed-off-by: Anoop C S <anoopcs> Reviewed-on: http://review.gluster.org/13461 Smoke: Gluster Build System <jenkins.com> CentOS-regression: Gluster Build System <jenkins.com> NetBSD-regression: NetBSD Build System <jenkins.org> Reviewed-by: jiffin tony Thottan <jthottan> Reviewed-by: Jeff Darcy <jdarcy>