Re: [RFT][patch] Scheduling for HTT and not only

2012-02-17 Thread Alexander Motin

On 02/15/12 21:54, Jeff Roberson wrote:

On Wed, 15 Feb 2012, Alexander Motin wrote:

I've decided to stop those cache black magic practices and focus on
things that really exist in this world -- SMT and CPU load. I've
dropped most of cache related things from the patch and made the rest
of things more strict and predictable:
http://people.freebsd.org/~mav/sched.htt34.patch


This looks great. I think there is value in considering the other
approach further but I would like to do this part first. It would be
nice to also add priority as a greater influence in the load balancing
as well.


I haven't got good idea yet about balancing priorities, but I've 
rewritten balancer itself. As soon as sched_lowest() / sched_highest() 
are more intelligent now, they allowed to remove topology traversing 
from the balancer itself. That should fix double-swapping problem, allow 
to keep some affinity while moving threads and make balancing more fair. 
I did number of tests running 4, 8, 9 and 16 CPU-bound threads on 8 
CPUs. With 4, 8 and 16 threads everything is stationary as it should. 
With 9 threads I see regular and random load move between all 8 CPUs. 
Measurements on 5 minutes run show deviation of only about 5 seconds. It 
is the same deviation as I see caused by only scheduling of 16 threads 
on 8 cores without any balancing needed at all. So I believe this code 
works as it should.


Here is the patch: http://people.freebsd.org/~mav/sched.htt40.patch

I plan this to be a final patch of this series (more to come :)) and if 
there will be no problems or objections, I am going to commit it (except 
some debugging KTRs) in about ten days. So now it's a good time for 
reviews and testing. :)


--
Alexander Motin
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: [RFT][patch] Scheduling for HTT and not only

2012-02-17 Thread Alexander Motin

On 17.02.2012 18:53, Arnaud Lacombe wrote:

On Fri, Feb 17, 2012 at 11:29 AM, Alexander Motinm...@freebsd.org  wrote:

On 02/15/12 21:54, Jeff Roberson wrote:

On Wed, 15 Feb 2012, Alexander Motin wrote:

I've decided to stop those cache black magic practices and focus on
things that really exist in this world -- SMT and CPU load. I've
dropped most of cache related things from the patch and made the rest
of things more strict and predictable:
http://people.freebsd.org/~mav/sched.htt34.patch


This looks great. I think there is value in considering the other
approach further but I would like to do this part first. It would be
nice to also add priority as a greater influence in the load balancing
as well.


I haven't got good idea yet about balancing priorities, but I've rewritten
balancer itself. As soon as sched_lowest() / sched_highest() are more
intelligent now, they allowed to remove topology traversing from the
balancer itself. That should fix double-swapping problem, allow to keep some
affinity while moving threads and make balancing more fair. I did number of
tests running 4, 8, 9 and 16 CPU-bound threads on 8 CPUs. With 4, 8 and 16
threads everything is stationary as it should. With 9 threads I see regular
and random load move between all 8 CPUs. Measurements on 5 minutes run show
deviation of only about 5 seconds. It is the same deviation as I see caused
by only scheduling of 16 threads on 8 cores without any balancing needed at
all. So I believe this code works as it should.

Here is the patch: http://people.freebsd.org/~mav/sched.htt40.patch

I plan this to be a final patch of this series (more to come :)) and if
there will be no problems or objections, I am going to commit it (except
some debugging KTRs) in about ten days. So now it's a good time for reviews
and testing. :)


is there a place where all the patches are available ?


All my scheduler patches are cumulative, so all you need is only the 
last mentioned here sched.htt40.patch.


But in some cases, especially for multi-socket systems, to let it show 
its best, you may want to apply additional patch from avg@ to better 
detect CPU topology:

https://gitorious.org/~avg/freebsd/avgbsd/commit/6bca4a2e4854ea3fc275946a023db65c483cb9dd


I intend to run
some tests on a 1x2x2 (atom D510), 1x4x1 (core-2 quad), and eventually
a 2x8x2 platforms, against r231573. Results should hopefully be
available by the end of the week-end/middle of next week[0].

[0]: the D510 will likely be testing a couple of Linux kernel over the
week-end, and a FreeBSD run takes about 2.5 days to complete.


--
Alexander Motin
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: [RFT][patch] Scheduling for HTT and not only

2012-02-17 Thread Arnaud Lacombe
Hi,

On Fri, Feb 17, 2012 at 11:29 AM, Alexander Motin m...@freebsd.org wrote:
 On 02/15/12 21:54, Jeff Roberson wrote:

 On Wed, 15 Feb 2012, Alexander Motin wrote:

 I've decided to stop those cache black magic practices and focus on
 things that really exist in this world -- SMT and CPU load. I've
 dropped most of cache related things from the patch and made the rest
 of things more strict and predictable:
 http://people.freebsd.org/~mav/sched.htt34.patch


 This looks great. I think there is value in considering the other
 approach further but I would like to do this part first. It would be
 nice to also add priority as a greater influence in the load balancing
 as well.


 I haven't got good idea yet about balancing priorities, but I've rewritten
 balancer itself. As soon as sched_lowest() / sched_highest() are more
 intelligent now, they allowed to remove topology traversing from the
 balancer itself. That should fix double-swapping problem, allow to keep some
 affinity while moving threads and make balancing more fair. I did number of
 tests running 4, 8, 9 and 16 CPU-bound threads on 8 CPUs. With 4, 8 and 16
 threads everything is stationary as it should. With 9 threads I see regular
 and random load move between all 8 CPUs. Measurements on 5 minutes run show
 deviation of only about 5 seconds. It is the same deviation as I see caused
 by only scheduling of 16 threads on 8 cores without any balancing needed at
 all. So I believe this code works as it should.

 Here is the patch: http://people.freebsd.org/~mav/sched.htt40.patch

 I plan this to be a final patch of this series (more to come :)) and if
 there will be no problems or objections, I am going to commit it (except
 some debugging KTRs) in about ten days. So now it's a good time for reviews
 and testing. :)

is there a place where all the patches are available ? I intend to run
some tests on a 1x2x2 (atom D510), 1x4x1 (core-2 quad), and eventually
a 2x8x2 platforms, against r231573. Results should hopefully be
available by the end of the week-end/middle of next week[0].

 - Arnaud

[0]: the D510 will likely be testing a couple of Linux kernel over the
week-end, and a FreeBSD run takes about 2.5 days to complete.


 --
 Alexander Motin
 ___
 freebsd-hack...@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
 To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


devd based AUTOMOUNTER

2012-02-17 Thread vermaden
Hi,

I have finally made some effort on writing flexible yet very simple automounter 
for FreeBSD desktop.

Feel free to submit me BUG reports ;)

It currently supports these file formats:
-- NTFS(rw) requires [port]sysutils/fusefs-ntfs[/port]
-- FAT/FAT32
-- exFAT requires [port]sysutils/fusefs-exfat[/port]
-- EXT2
-- EXT3
-- EXT4 requires [port]sysutils/fusefs-ext4fuse[/port]
-- UFS (DOH!)

It keeps state of the mounted devices at /var/run/automount.state and logs all 
activities to /var/log/automount.log file.

The place for the script is at /usr/local/sbin/automount.sh executable.

The only additional configuration it requires are those lines at the end of 
/etc/devd.conf file along with restarting /etc/rc.d/devd daemon.

notify 200 {
  match system DEVFS;
  match type CREATE;
  match cdev (da|mmcsd)[0-9]+;
  action /usr/local/sbin/automount.sh $cdev attach;
};

notify 200 {
  match system DEVFS;
  match type DESTROY;
  match cdev (da|mmcsd)[0-9]+;
  action /usr/local/sbin/automount.sh $cdev detach;
};

The /usr/local/sbin/automount.sh executable is here:

#! /bin/sh

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
LOG=/var/log/automount.log
STATE=/var/run/automount.state
DATEFMT=%Y-%m-%d %H:%M:%S

__create_mount_point() { # /* 1=DEV */
  MNT=/mnt/$( basename ${1} )
  mkdir -p ${MNT}
}

__state_lock() {
  while [ -f ${STATE}.lock ]; do sleep 0.5; done
  : ${STATE}.lock
}

__state_unlock() {
  rm ${STATE}.lock
}

__state_add() { # /* 1=DEV 2=PROVIDER 3=MNT */
  __state_lock
  echo ${1} ${2} ${3}  ${STATE}
  __state_unlock
}

__state_remove() { # /* 1=MNT 2=STATE 3=LINE */
  LINE=$( grep -n -E ${1}$ ${2} | cut -d : -f 1 )
  sed -i '' ${3}d ${2}
}

__log() { # /* @=MESSAGE */
  echo $( date +${DATEFMT} ) ${@}  ${LOG}
}

case ${2} in
  (attach)
for I in /dev/${1}*
do
  case $( file -L -s ${I} ) in
(*NTFS*)
  __create_mount_point ${I}
  ntfs-3g ${I} ${MNT} # /* sysutils/fusefs-ntfs */
  __log ${I}:mount (ntfs)
  ;;
(*FAT*)
  __create_mount_point ${I}
  fsck_msdosfs -y ${I}
  mount_msdosfs -o large -o longnames -l -L pl_PL.ISO8859-2 -D cp852 
${I} ${MNT}
  __log ${I}:mount (fat)
  ;;
(*ext2*)
  __create_mount_point ${I}
  fsck.ext2 -y ${I}
  mount -t ext2fs ${I} ${MNT}
  __log ${I}:mount (ext2)
  ;;
(*ext3*)
  __create_mount_point ${I}
  fsck.ext3 -y ${I}
  mount -t ext2fs ${I} ${MNT}
  __log ${I}:mount (ext3)
  ;;
(*ext4*)
  __create_mount_point ${I}
  fsck.ext4 -y ${I}
  ext4fuse ${I} ${MNT} # /* sysutils/fusefs-ext4fuse */
  __log ${I}:mount (ext4)
  ;;
(*Unix\ Fast\ File*)
  __create_mount_point ${I}
  fsck_ufs -y ${I}
  mount ${I} ${MNT}
  __log ${I}:mount (ufs)
  ;;
(*)
  case $( dd  ${O} count=1 | strings | head -1 ) in
(EXFAT)
  __create_mount_point ${I}
  mount.exfat ${I} ${MNT} # /* sysutils/fusefs-exfat */
  __log ${I}:mount (ufs)
  ;;
(*) continue ;;
  esac
  ;;
  esac
  __state_add ${I} $( mount | grep  ${MNT}  | awk '{printf $1}' ) ${MNT}
done
;;

  (detach)
MOUNTED=$( mount )
__state_lock
while read DEV PROVIDER MNT
do
  TARGET=$( echo ${MOUNTED} | grep -E ^${PROVIDER}  | awk '{print $3}' )
  [ -z ${TARGET} ]  {
__state_remove ${MNT} ${STATE} ${LINE}
continue
  }
  umount -f ${TARGET} 
  unset TARGET
  __state_remove ${MNT} ${STATE} ${LINE}
  __log ${DEV}:umount
done  ${STATE}
__state_unlock
__log /dev/${1}:detach
;;

esac


PS. Below are links for 'mirror' threads.
http://forums.freebsd.org/showthread.php?t=29895
http://daemonforums.org/showthread.php?t=6838

Regards,
vermaden
























---
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: devd based AUTOMOUNTER

2012-02-17 Thread matt
On 02/17/12 09:49, vermaden wrote:
 Hi,

 I have finally made some effort on writing flexible yet very simple 
 automounter for FreeBSD desktop.

 Feel free to submit me BUG reports ;)

 It currently supports these file formats:
 -- NTFS(rw) requires [port]sysutils/fusefs-ntfs[/port]
 -- FAT/FAT32
 -- exFAT requires [port]sysutils/fusefs-exfat[/port]
 -- EXT2
 -- EXT3
 -- EXT4 requires [port]sysutils/fusefs-ext4fuse[/port]
 -- UFS (DOH!)

 It keeps state of the mounted devices at /var/run/automount.state and logs 
 all activities to /var/log/automount.log file.

 The place for the script is at /usr/local/sbin/automount.sh executable.

 The only additional configuration it requires are those lines at the end of 
 /etc/devd.conf file along with restarting /etc/rc.d/devd daemon.

 notify 200 {
   match system DEVFS;
   match type CREATE;
   match cdev (da|mmcsd)[0-9]+;
   action /usr/local/sbin/automount.sh $cdev attach;
 };

 notify 200 {
   match system DEVFS;
   match type DESTROY;
   match cdev (da|mmcsd)[0-9]+;
   action /usr/local/sbin/automount.sh $cdev detach;
 };

 The /usr/local/sbin/automount.sh executable is here:

 #! /bin/sh

 PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
 LOG=/var/log/automount.log
 STATE=/var/run/automount.state
 DATEFMT=%Y-%m-%d %H:%M:%S

 __create_mount_point() { # /* 1=DEV */
   MNT=/mnt/$( basename ${1} )
   mkdir -p ${MNT}
 }

 __state_lock() {
   while [ -f ${STATE}.lock ]; do sleep 0.5; done
   : ${STATE}.lock
 }

 __state_unlock() {
   rm ${STATE}.lock
 }

 __state_add() { # /* 1=DEV 2=PROVIDER 3=MNT */
   __state_lock
   echo ${1} ${2} ${3}  ${STATE}
   __state_unlock
 }

 __state_remove() { # /* 1=MNT 2=STATE 3=LINE */
   LINE=$( grep -n -E ${1}$ ${2} | cut -d : -f 1 )
   sed -i '' ${3}d ${2}
 }

 __log() { # /* @=MESSAGE */
   echo $( date +${DATEFMT} ) ${@}  ${LOG}
 }

 case ${2} in
   (attach)
 for I in /dev/${1}*
 do
   case $( file -L -s ${I} ) in
 (*NTFS*)
   __create_mount_point ${I}
   ntfs-3g ${I} ${MNT} # /* sysutils/fusefs-ntfs */
   __log ${I}:mount (ntfs)
   ;;
 (*FAT*)
   __create_mount_point ${I}
   fsck_msdosfs -y ${I}
   mount_msdosfs -o large -o longnames -l -L pl_PL.ISO8859-2 -D cp852 
 ${I} ${MNT}
   __log ${I}:mount (fat)
   ;;
 (*ext2*)
   __create_mount_point ${I}
   fsck.ext2 -y ${I}
   mount -t ext2fs ${I} ${MNT}
   __log ${I}:mount (ext2)
   ;;
 (*ext3*)
   __create_mount_point ${I}
   fsck.ext3 -y ${I}
   mount -t ext2fs ${I} ${MNT}
   __log ${I}:mount (ext3)
   ;;
 (*ext4*)
   __create_mount_point ${I}
   fsck.ext4 -y ${I}
   ext4fuse ${I} ${MNT} # /* sysutils/fusefs-ext4fuse */
   __log ${I}:mount (ext4)
   ;;
 (*Unix\ Fast\ File*)
   __create_mount_point ${I}
   fsck_ufs -y ${I}
   mount ${I} ${MNT}
   __log ${I}:mount (ufs)
   ;;
 (*)
   case $( dd  ${O} count=1 | strings | head -1 ) in
 (EXFAT)
   __create_mount_point ${I}
   mount.exfat ${I} ${MNT} # /* sysutils/fusefs-exfat */
   __log ${I}:mount (ufs)
   ;;
 (*) continue ;;
   esac
   ;;
   esac
   __state_add ${I} $( mount | grep  ${MNT}  | awk '{printf $1}' ) ${MNT}
 done
 ;;

   (detach)
 MOUNTED=$( mount )
 __state_lock
 while read DEV PROVIDER MNT
 do
   TARGET=$( echo ${MOUNTED} | grep -E ^${PROVIDER}  | awk '{print 
 $3}' )
   [ -z ${TARGET} ]  {
 __state_remove ${MNT} ${STATE} ${LINE}
 continue
   }
   umount -f ${TARGET} 
   unset TARGET
   __state_remove ${MNT} ${STATE} ${LINE}
   __log ${DEV}:umount
 done  ${STATE}
 __state_unlock
 __log /dev/${1}:detach
 ;;

 esac


 PS. Below are links for 'mirror' threads.
 http://forums.freebsd.org/showthread.php?t=29895
 http://daemonforums.org/showthread.php?t=6838

 Regards,
 vermaden
























 ---
 ___
 freebsd-hack...@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
 To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org
Some things to consider/test:

How do I set custom flags, like nosuid,noatime,nodev,noexec,async (or
sync) for mounts?
What if make a usb drive with an illegal name, existing name or other
dangerous values?
Can I use the automounter to either mount over another mount to
impersonate it, or can I overwrite arbitrary files or directories?

Some of these above things don't work on Linux with udev (i.e. gnome-vfs
automount gets some fairly generous flags automatically)
I didn't get a chance to test some of the naming things on Linux either,
as many drive formatting programs validate the name.

Something to 

Re: devd based AUTOMOUNTER

2012-02-17 Thread vermaden
I already made some changes for the 'better' ...

Here is the latest version:

#! /bin/sh

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
LOG=/var/log/automount.log
STATE=/var/run/automount.state
DATEFMT=%Y-%m-%d %H:%M:%S

__create_mount_point() { # /* 1=DEV */
  MNT=/mnt/$( basename ${1} )
  mkdir -p ${MNT}
}

__state_lock() {
  while [ -f ${STATE}.lock ]; do sleep 0.5; done
  : ${STATE}.lock
}

__state_unlock() {
  rm ${STATE}.lock
}

__state_add() { # /* 1=DEV 2=PROVIDER 3=MNT */
  __state_lock
  grep -E ${3}$ ${STATE} 1 /dev/null 2 /dev/null  {
__log ${1}:duplicated '${STATE}'
return 1
  }
  echo ${1} ${2} ${3}  ${STATE}
  __state_unlock
}

__state_remove() { # /* 1=MNT 2=STATE 3=LINE */
  BSMNT=$( echo ${1} | sed 's/\//\\\//g' )
  sed -i '' /${BSMNT}\$/d ${2}
}

__log() { # /* @=MESSAGE */
  echo $( date +${DATEFMT} ) ${@}  ${LOG}
}

case ${2} in
  (attach)
for I in /dev/${1}*
do
  case $( file -L -s ${I} ) in
(*NTFS*)
  __create_mount_point ${I}
  ntfs-3g ${I} ${MNT} # /* sysutils/fusefs-ntfs */
  __log ${I}:mount (ntfs)
  ;;
(*FAT*)
  __create_mount_point ${I}
  fsck_msdosfs -y ${I}
  mount_msdosfs -o large -o longnames -l -L pl_PL.ISO8859-2 -D cp852 
${I} ${MNT}
  __log ${I}:mount (fat)
  ;;
(*ext2*)
  __create_mount_point ${I}
  fsck.ext2 -y ${I}
  mount -t ext2fs ${I} ${MNT}
  __log ${I}:mount (ext2)
  ;;
(*ext3*)
  __create_mount_point ${I}
  fsck.ext3 -y ${I}
  mount -t ext2fs ${I} ${MNT}
  __log ${I}:mount (ext3)
  ;;
(*ext4*)
  __create_mount_point ${I}
  fsck.ext4 -y ${I}
  ext4fuse ${I} ${MNT} # /* sysutils/fusefs-ext4fuse */
  __log ${I}:mount (ext4)
  ;;
(*Unix\ Fast\ File*)
  __create_mount_point ${I}
  fsck_ufs -y ${I}
  mount ${I} ${MNT}
  __log ${I}:mount (ufs)
  ;;
(*)
  case $( dd  ${O} count=1 | strings | head -1 ) in
(EXFAT)
  __create_mount_point ${I}
  mount.exfat ${I} ${MNT} # /* sysutils/fusefs-exfat */
  __log ${I}:mount (ufs)
  ;;
(*) continue ;;
  esac
  ;;
  esac
  __state_add ${I} $( mount | grep  ${MNT}  | awk '{printf $1}' ) ${MNT} 
|| continue
done
;;

  (detach)
__state_lock
grep ${1} ${STATE} \
  | while read DEV PROVIDER MNT
do
  TARGET=$( mount | grep -E ^${PROVIDER}  | awk '{print $3}' )
  [ -z ${TARGET} ]  {
__state_remove ${MNT} ${STATE} ${LINE}
continue
  }
  umount -f ${TARGET} 
  unset TARGET
  __state_remove ${MNT} ${STATE} ${LINE}
  __log ${DEV}:umount
done
__state_unlock
__log /dev/${1}:detach
;;

esac



I have made tests with 3 different USB drives, with different and same 
failesystems, connecting them all at once, disconnecting all at once, random 
connect, disconnect etc.

Currently it seems to work ok but suggestions are very welcome.


 Some things to consider/test:
 
 How do I set custom flags, like nosuid,noatime,nodev,noexec,async (or
 sync) for mounts?
Currently You can add these options to filesystem specific mount command, but 
its definitely possible.

 What if make a usb drive with an illegal name, existing name or other 
 dangerous values?
The filesystem label is not used at all, I just use device names, which are 
reported by FreeBSD, so quite bulletproof here and then create appreciate 
/mnt/da0s1 directories.

 Can I use the automounter to either mount over another mount to
 impersonate it, or can I overwrite arbitrary files or directories?
I have done everything to check that and to omit that, if not, then submit a 
BUG ;)

Thanks for suggestions Matt.

Regards,
vermaden


-- 








































...
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: devd based AUTOMOUNTER

2012-02-17 Thread vermaden
... even newer version, seems to have all 'problems' fixed now ;)

#! /bin/sh

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
LOG=/var/log/automount.log
STATE=/var/run/automount.state
DATEFMT=%Y-%m-%d %H:%M:%S

__create_mount_point() { # /* 1=DEV */
  MNT=/mnt/$( basename ${1} )
  mkdir -p ${MNT}
}

__state_lock() {
  while [ -f ${STATE}.lock ]; do sleep 0.5; done
  : ${STATE}.lock
}

__state_unlock() {
  rm ${STATE}.lock
}

__state_add() { # /* 1=DEV 2=PROVIDER 3=MNT */
  __state_lock
  grep -E ${3} ${STATE} 1 /dev/null 2 /dev/null  {
__log ${1}:duplicated '${STATE}'
return 1
  }
  echo ${1} ${2} ${3}  ${STATE}
  __state_unlock
}

__state_remove() { # /* 1=MNT 2=STATE 3=LINE */
  BSMNT=$( echo ${1} | sed 's/\//\\\//g' )
  sed -i '' /${BSMNT}\$/d ${2}
}

__log() { # /* @=MESSAGE */
  echo $( date +${DATEFMT} ) ${@}  ${LOG}
}

case ${2} in
  (attach)
for I in /dev/${1}*
do
  case $( file -L -s ${I} ) in
(*NTFS*)
  __create_mount_point ${I}
  ntfs-3g ${I} ${MNT} # /* sysutils/fusefs-ntfs */
  __log ${I}:mount (ntfs)
  ;;
(*FAT*)
  __create_mount_point ${I}
  fsck_msdosfs -y ${I}
  mount_msdosfs -o large -l -L pl_PL.ISO8859-2 -D cp852 ${I} ${MNT}
  __log ${I}:mount (fat)
  ;;
(*ext2*)
  __create_mount_point ${I}
  fsck.ext2 -y ${I}
  mount -t ext2fs ${I} ${MNT}
  __log ${I}:mount (ext2)
  ;;
(*ext3*)
  __create_mount_point ${I}
  fsck.ext3 -y ${I}
  mount -t ext2fs ${I} ${MNT}
  __log ${I}:mount (ext3)
  ;;
(*ext4*)
  __create_mount_point ${I}
  fsck.ext4 -y ${I}
  ext4fuse ${I} ${MNT} # /* sysutils/fusefs-ext4fuse */
  __log ${I}:mount (ext4)
  ;;
(*Unix\ Fast\ File*)
  __create_mount_point ${I}
  fsck_ufs -y ${I}
  mount ${I} ${MNT}
  __log ${I}:mount (ufs)
  ;;
(*)
  case $( dd  ${O} count=1 | strings | head -1 ) in
(EXFAT)
  __create_mount_point ${I}
  mount.exfat ${I} ${MNT} # /* sysutils/fusefs-exfat */
  __log ${I}:mount (ufs)
  ;;
(*) continue ;;
  esac
  ;;
  esac
  __state_add ${I} $( mount | grep -m 1  ${MNT}  | awk '{printf $1}' ) \
${MNT} || continue
done
;;

  (detach)
MOUNT=$( mount )
__state_lock
grep ${1} ${STATE} \
  | while read DEV PROVIDER MNT
do
  TARGET=$( echo ${MOUNT} | grep -E ^${PROVIDER}  | awk '{print 
$3}' )
  [ -z ${TARGET} ]  {
__state_remove ${MNT} ${STATE} ${LINE}
continue
  }
  umount -f ${TARGET} 
  unset TARGET
  __state_remove ${MNT} ${STATE} ${LINE}
  __log ${DEV}:umount
done
__state_unlock
__log /dev/${1}:detach
;;

esac

___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: devd based AUTOMOUNTER

2012-02-17 Thread vermaden
Latest version with additional checks for NTFS and FAT32, to be precise,
for NTFS filesystem with label FAT and for FAT filesystem with label NTFS ;)

#! /bin/sh

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
LOG=/var/log/automount.log
STATE=/var/run/automount.state
DATEFMT=%Y-%m-%d %H:%M:%S

__create_mount_point() { # /* 1=DEV */
  MNT=/mnt/$( basename ${1} )
  mkdir -p ${MNT}
}

__state_lock() {
  while [ -f ${STATE}.lock ]; do sleep 0.5; done
  : ${STATE}.lock
}

__state_unlock() {
  rm ${STATE}.lock
}

__state_add() { # /* 1=DEV 2=PROVIDER 3=MNT */
  __state_lock
  grep -E ${3} ${STATE} 1 /dev/null 2 /dev/null  {
__log ${1}:duplicated '${STATE}'
return 1
  }
  echo ${1} ${2} ${3}  ${STATE}
  __state_unlock
}

__state_remove() { # /* 1=MNT 2=STATE 3=LINE */
  BSMNT=$( echo ${1} | sed 's/\//\\\//g' )
  sed -i '' /${BSMNT}\$/d ${2}
}

__log() { # /* @=MESSAGE */
  echo $( date +${DATEFMT} ) ${@}  ${LOG}
}

case ${2} in
  (attach)
for I in /dev/${1}*
do
  case $( file -L -s ${I} | sed -E 's/label:\ \.*\//g' ) in
(*NTFS*)
  dd  ${I} count=1 2 /dev/null \
| strings \
| head -1 \
| grep -q NTFS  {
  __create_mount_point ${I}
  ntfs-3g ${I} ${MNT} # /* sysutils/fusefs-ntfs */
  __log ${I}:mount (ntfs)
  }
  ;;
(*FAT*)
  dd  ${I} count=1 2 /dev/null \
| strings \
| grep -q FAT32  {
  __create_mount_point ${I}
  fsck_msdosfs -y ${I}
  mount_msdosfs -o large -l -L pl_PL.ISO8859-2 -D cp852 ${I} ${MNT}
  __log ${I}:mount (fat)
  }
  ;;
(*ext2*)
  __create_mount_point ${I}
  fsck.ext2 -y ${I}
  mount -t ext2fs ${I} ${MNT}
  __log ${I}:mount (ext2)
  ;;
(*ext3*)
  __create_mount_point ${I}
  fsck.ext3 -y ${I}
  mount -t ext2fs ${I} ${MNT}
  __log ${I}:mount (ext3)
  ;;
(*ext4*)
  __create_mount_point ${I}
  fsck.ext4 -y ${I}
  ext4fuse ${I} ${MNT} # /* sysutils/fusefs-ext4fuse */
  __log ${I}:mount (ext4)
  ;;
(*Unix\ Fast\ File*)
  __create_mount_point ${I}
  fsck_ufs -y ${I}
  mount ${I} ${MNT}
  __log ${I}:mount (ufs)
  ;;
(*)
  case $( dd  ${I} count=1 2 /dev/null | strings | head -1 ) in
(EXFAT)
  __create_mount_point ${I}
  mount.exfat ${I} ${MNT} # /* sysutils/fusefs-exfat */
  __log ${I}:mount (ufs)
  ;;
(*) continue ;;
  esac
  ;;
  esac
  __state_add ${I} $( mount | grep -m 1  ${MNT}  | awk '{printf $1}' ) \
${MNT} || continue
done
;;

  (detach)
MOUNT=$( mount )
__state_lock
grep ${1} ${STATE} \
  | while read DEV PROVIDER MNT
do
  TARGET=$( echo ${MOUNT} | grep -E ^${PROVIDER}  | awk '{print 
$3}' )
  [ -z ${TARGET} ]  {
__state_remove ${MNT} ${STATE} ${LINE}
continue
  }
  umount -f ${TARGET} 
  unset TARGET
  __state_remove ${MNT} ${STATE} ${LINE}
  __log ${DEV}:umount
done
__state_unlock
__log /dev/${1}:detach
;;

esac


___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Last call: removing the INT_MAX limit on max i/o size

2012-02-17 Thread Konstantin Belousov
This is a notification to allow you to comment on the patch before the
commit.

I will commit the latest version of the patch to remove the limitation
of the maximal i/o size for read/write syscalls to INT_MAX in the
beginning of the next week.

The change is available at
http://people.freebsd.org/~kib/misc/uio_resid.10.patch
various versions of it were discussed with Bruce Evance and David Schultz.

Patch does not enable SSIZE_MAX-sized i/o by default, hiding this under
debug.iosize_max_clamp sysctl. Effectively, the patch becomes the pass
to change various ints into ssize_t.



pgpmSkr7UMrvo.pgp
Description: PGP signature