Re: [PATCH VER 6] xfsprogs: projid32bit handling

Arkadiusz Miskiewicz
2010-09-26T06:13:07Z

On Sunday 26 of September 2010, Arkadiusz Miśkiewicz wrote:
> Add projid32bit handling to userspace. mkfs.xfs is able to enable this
> feature for new filesystems. xfs_db knows what projid_lo/hi are.

... and xfs_admin if someone needs it anyway.

News:
- use 0x80 instead of 0x20 for PROJID32BIT superblock bit (as 0x20
and 0x40 are reserved)

diff --git a/db/xfs_admin.sh b/db/xfs_admin.sh
index a7a3fdb..ec8424d 100755
--- a/db/xfs_admin.sh
+++ b/db/xfs_admin.sh
@@ -6,9 +6,43 @@
status=0
DB_OPTS=""
REPAIR_OPTS=""
-USAGE="Usage: xfs_admin [-efjluV] [-c 0|1] [-L label] [-U uuid] device"
+USAGE="Usage: xfs_admin [-efjlpuV] [-c 0|1] [-L label] [-U uuid] device"

-while getopts "efjluc:L:U:V" c
+set_features2_bit() {
+ device="$1"
+ bit="$2"
+
+ if [ -z "$device" ]; then
+ echo "$0: device name is missing" >&2
+ return 1
+ fi
+
+ if [ -z "$bit" ]; then
+ echo "$0: bits to set are missing" >&2
+ return 1
+ fi
+
+ # read current bits
+ features2=$(xfs_db -p xfs_admin -x -r -c 'sb' -c 'print features2' "$device" | awk ' { print $3 } ')
+ if [ -z "$features2" ]; then
+ echo "$0: can't read features2 from superblock!" >&2
+ return 1
+ fi
+ bad_features2=$(xfs_db -p xfs_admin -x -r -c 'sb' -c 'print bad_features2' "$device" | awk ' { print $3 } ')
+ if [ -z "$bad_features2" ]; then
+ echo "$0: can't read bad_features2 from superblock!" >&2
+ return 1
+ fi
+
+ # set new bits
+ features2=$((features2 | bit))
+ bad_features2=$((bad_features2 | bit))
+ xfs_db -p xfs_admin -x -c 'sb' -c "write features2 $features2" "$device" && \
+ xfs_db -p xfs_admin -x -c 'sb' -c "write bad_features2 $bad_features2" "$device"
+ return $?
+}
+
+while getopts "efjlu3c:L:U:V" c
do
case $c in
c) REPAIR_OPTS=$REPAIR_OPTS" -c lazycount="$OPTARG;;
@@ -17,6 +51,7 @@ do
j) DB_OPTS=$DB_OPTS" -c 'version log2'";;
l) DB_OPTS=$DB_OPTS" -r -c label";;
L) DB_OPTS=$DB_OPTS" -c 'label "$OPTARG"'";;
+ 3) FEATURES_BIT="0x80";;
u) DB_OPTS=$DB_OPTS" -r -c uuid";;
U) DB_OPTS=$DB_OPTS" -c 'uuid "$OPTARG"'";;
V) xfs_db -p xfs_admin -V
@@ -31,7 +66,12 @@ done
set -- extra $@
shift $OPTIND
case $# in
- 1) if [ -n "$DB_OPTS" ]
+ 1) if [ -n "$FEATURES_BIT" ]
+ then
+ set_features2_bit "$1" "$FEATURES_BIT"
+ status=$?
+ fi
+ if [ -n "$DB_OPTS" ]
then
eval xfs_db -x -p xfs_admin $DB_OPTS $1
status=$?
diff --git a/man/man8/xfs_admin.8 b/man/man8/xfs_admin.8
index 8e3155b..6b727f3 100644
--- a/man/man8/xfs_admin.8
+++ b/man/man8/xfs_admin.8
@@ -4,7 +4,7 @@ xfs_admin \- change parameters of an XFS filesystem
.SH SYNOPSIS
.B xfs_admin
[
-.B \-eflu
+.B \-eflu3
] [
.BR "\-c 0" | 1
] [
@@ -55,6 +55,9 @@ Print the current filesystem label.
.B \-u
Print the current filesystem UUID (Universally Unique IDentifier).
.TP
+.B \-3
+Enable 32bit project identifier support (PROJID32BIT feature).
+.TP
.BR "\-c 0" | 1
Enable (1) or disable (0) lazy-counters in the filesystem.
This operation may take quite a bit of time on large filesystems as the

--
Arkadiusz Miśkiewicz PLD/Linux Team
arekm / maven.pl http://ftp.pld-linux.org/