[DRBD-cvs] svn commit by lars - r2644 - in trunk: drbd scripts - auto adjust drbd_config.h again for redhat being specia

drbd-cvs at lists.linbit.com drbd-cvs at lists.linbit.com
Fri Dec 22 16:27:24 CET 2006


Author: lars
Date: 2006-12-22 16:27:22 +0100 (Fri, 22 Dec 2006)
New Revision: 2644

Added:
   trunk/scripts/adjust_drbd_config_h.sh
Modified:
   trunk/drbd/Makefile
   trunk/drbd/drbd_main.c
Log:
auto adjust drbd_config.h again for redhat being special (again)
and cosmetics (whitespace)


Modified: trunk/drbd/Makefile
===================================================================
--- trunk/drbd/Makefile	2006-12-22 14:25:36 UTC (rev 2643)
+++ trunk/drbd/Makefile	2006-12-22 15:27:22 UTC (rev 2644)
@@ -113,6 +113,8 @@
 
   kbuild: drbd_buildtag.c
 	@rm -f .drbd_kernelrelease*
+	-test -f ../scripts/adjust_drbd_config_h.sh && \
+	 KDIR=$(KDIR) O=$(O) $(SHELL) ../scripts/adjust_drbd_config_h.sh
     # previous to 2.6.6 (suse: 2.6.5-dunno), this should be:
 	$(MAKE) -C $(KDIR) SUBDIRS=$(DRBDSRC) $(ARCH_UM) modules
 # $(MAKE) -C $(KDIR) M=$(DRBDSRC) $(ARCH_UM) modules

Modified: trunk/drbd/drbd_main.c
===================================================================
--- trunk/drbd/drbd_main.c	2006-12-22 14:25:36 UTC (rev 2643)
+++ trunk/drbd/drbd_main.c	2006-12-22 15:27:22 UTC (rev 2644)
@@ -710,7 +710,7 @@
 	}
 
 	if( ns.i == os.i ) return SS_NothingToDo;
-	
+
 	if( !(flags & ChgStateHard) ) {
 		/*  pre-state-change checks ; only look at ns  */
 		/* See drbd_state_sw_errors in drbd_strings.c */
@@ -722,7 +722,7 @@
 
 			if( is_valid_state(mdev,os) == rv ) {
 				ERR("Forcing state change from bad state. "
-				    "Error would be: '%s'\n", 
+				    "Error would be: '%s'\n",
 				    set_st_err_name(rv));
 				print_st(mdev,"old",os);
 				print_st(mdev,"new",ns);
@@ -1845,12 +1845,14 @@
 	if(!mdev) return -ENODEV;
 
 	spin_lock_irqsave(&mdev->req_lock,flags);
-	/* The have a stable mdev->state.role and no race with updating open_cnt */
+	/* to have a stable mdev->state.role and no race with updating open_cnt */
 
-	if( mdev->state.role != Primary && !allow_oos) {
-		rv = -EMEDIUMTYPE;
-	} else if (file->f_mode & FMODE_WRITE && mdev->state.role != Primary) {
-		rv = -EROFS;
+	if (mdev->state.role != Primary) {
+		if (file->f_mode & FMODE_WRITE) {
+			rv = -EROFS;
+		} else if (!allow_oos) {
+			rv = -EMEDIUMTYPE;
+		}
 	}
 
 	if(!rv) mdev->open_cnt++;

Added: trunk/scripts/adjust_drbd_config_h.sh
===================================================================
--- trunk/scripts/adjust_drbd_config_h.sh	2006-12-22 14:25:36 UTC (rev 2643)
+++ trunk/scripts/adjust_drbd_config_h.sh	2006-12-22 15:27:22 UTC (rev 2644)
@@ -0,0 +1,74 @@
+#!/bin/bash
+# drbd_config.h auto edit magic for 2.4 kernels ...
+
+# expects KDIR in the environment to be set correctly!
+
+set -e
+sorry() {
+	cat <<___
+	Sorry, automagic adjustment of drdb_config.h failed.
+	For well known 2.6. kernels, no adjustment to the shipped drbd_config is necessary.
+	You need to verify it yourself.
+___
+}
+trap "sorry" 0
+grep_q() { grep "$@" /dev/null &>/dev/null ; }
+
+# PARANOIA:
+test -e ./linux/drbd_config.h || {
+       echo >&2 "oops, invoked in unexpected directory..."
+       exit 1
+}
+
+test -n "$KDIR"
+KDIR=${KDIR%/}
+if test -z "$O"; then
+	O=$KDIR;
+else
+	O=${O%/}
+fi
+
+# some paranoia: check that all files are where we expect them
+ls > /dev/null \
+$KDIR/{Makefile,include/linux/{gfp,types}.h}
+ls > /dev/null \
+$O/{.config,Makefile,include/linux/version.h}
+# test -e $KDIR/include/asm/bitops.h ||
+# test -e $O/include2/asm/bitops.h   ||
+# exit 1
+
+if grep_q "^PATCHLEVEL *= *6" $KDIR/Makefile ; then
+  # do we have gfp_t?
+  if grep_q "typedef.*gfp_t" $KDIR/include/linux/gfp.h $KDIR/include/linux/types.h; then
+    have_gfp_t=1
+  else
+    have_gfp_t=0
+  fi
+else
+    # not a 2.6. kernel. just leave it alone...
+    exit 0
+fi
+
+test -e ./linux/drbd_config.h.orig || cp ./linux/drbd_config.h{,.orig}
+
+perl -pe "
+ s{.*(#define KERNEL_HAS_GFP_T.*)}
+  { ( $have_gfp_t ? '' : '//' ) . \$1}e;" \
+	  < ./linux/drbd_config.h \
+	  > ./linux/drbd_config.h.new
+
+
+if ! DIFF=$(diff -s -U0 ./linux/drbd_config.h{,.new}) ; then
+  mv ./linux/drbd_config.h{.new,}
+  sed -e 's/^/  /' <<___
+
+Adjusted drbd_config.h:
+$DIFF
+
+___
+else
+	rm ./linux/drbd_config.h.new
+	echo -e "\n  Using unmodified drbd_config.h\n"
+fi
+trap - 0
+exit 0


Property changes on: trunk/scripts/adjust_drbd_config_h.sh
___________________________________________________________________
Name: svn:executable
   + *



More information about the drbd-cvs mailing list