Re: [PATCH VER 5] xfsprogs: projid32bit handling (xfs_admin patch)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Friday 24 of September 2010, Arkadiusz MiÅkiewicz wrote:

> Note - there is no xfs_admin support for setting projid32bit.
> It would be a mess when doing that in shell code, similar to this one:
> http://pastebin.com/WWy8m1x7.
> 
> hch comments on this:
> 12:34 < hch> arekm: doesn't look too pretty indeed
> 12:34 < hch> arekm: let me think about hacking up some simple C code
>              for toggling feature bits
> 12:35 < hch> alternatively we could just do it in kernelspace
> 12:35 < hch> which seems more useful anyway as we could do online upgrades
> 12:53 < hch> I think adding an ioctl for enabling features is the better
> way 12:53 < hch> alternatively we could overload remount, but that weels a
> bit clumsy
> 
> Not sure if hch is going to implement that or only suggesting that
> solution. Anyway now projid32bit can be enabled at mkfs.xfs time (for new
> filesystems) or if you are smart enough via xfs_db (for existing
> filesystems).

But if someone really wants xfs_admin support in shell then here it is:

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="0x20";;
 	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

> 
> So if there are no new comments I'm asking for a merge for all 3 patches.
> Thanks!

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

_______________________________________________
xfs mailing list
xfs@xxxxxxxxxxx
http://oss.sgi.com/mailman/listinfo/xfs



[Index of Archives]     [Linux XFS Devel]     [Linux Filesystem Development]     [Filesystem Testing]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux