HDFS-3940. Merging change r1465851 from trunk

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1466101 13f79535-47bb-0310-9956-ffa450edef68
HDFS-4676. Merging change 1466099 from trunk

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1466102 13f79535-47bb-0310-9956-ffa450edef68