xfs
[Top] [All Lists]

fsr patch

To: linux-xfs@xxxxxxxxxxx
Subject: fsr patch
From: William L Jones <jones@xxxxxxxxxxxxxxxxxx>
Date: Mon, 24 Jul 2000 23:44:07 -0500 (CDT)
Cc: jones@xxxxxxxxxxxxxxxxxxx
Sender: owner-linux-xfs@xxxxxxxxxxx
Their is a shar file at the end this message.  Extract and run it and it will 
create two
directories fsr and linux.

The linux directory contains the following files:
    
    xfs_dfrag.c.patch - add call to linux fget to get file entry given a fd and
                        LINVFS_GET_VP to go from file entry to vnode.  
                        Change code to do the required fput on file entries
                        before exiting.
                        Moved some error checks so that their is always a CELL 
start/end pair
                        for all errors cases.
    xfs_dfrag.h.patch - add swapext ioctl for fsr.
    xfs_ioctl.c.patch - add swapext ioctl for fsr.

The fsr direcotry contsint the following files:

    Makefile.patch    - Patch to the fsr Makefile.
    fsr_xfs.c.patch   - Patch to fsr_xfs.c.
    syssgi.h          - New include file that fsr_xfs.c use for to emulate the
                        syssgi system call.
    syssgi.c          _ syssgi emulation subroutine.

A patched copy of linux/fs/xfs/xfs_dfrag.h should be copied to the 
cmd/xfs/include 
directory.

Their still a little more work that needs to be done in fsr_xfs.c to take care 
of
the case were xfs_fsr is handed a file/directory.

The support for the xfs real time file system will have to wait until its
ported to linux.

fsr_xfs seem to work in its current state.  If anyone at sgi has a test sweet
for fsr please run them against these mods. 

Bill Jones
                        


#!/bin/sh
# This is a shell archive (produced by GNU sharutils 4.2).
# To extract the files from this archive, save it to some FILE, remove
# everything before the `!/bin/sh' line above, then type `sh FILE'.
#
# Made on 2000-07-24 23:08 CDT by <root@xxxxxxxxxxxxxxxxxxxxxxxxx>.
# Source directory was `/root/mods'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
#
# This shar contains:
# length mode       name
# ------ ---------- ------------------------------------------
#   1111 -rw-r--r-- fsr/syssgi.c
#    256 -rw-r--r-- fsr/syssgi.h
#    437 -rw-r--r-- fsr/Makefile.patch
#  12816 -rw-r--r-- fsr/fsr_xfs.c.patch
#   5500 -rw-r--r-- linux/xfs_dfrag.c.patch
#    273 -rw-r--r-- linux/xfs_dfrag.h.patch
#    638 -rw-r--r-- linux/xfs_ioctl.c.patch
#
save_IFS="${IFS}"
IFS="${IFS}:"
gettext_dir=FAILED
locale_dir=FAILED
first_param="$1"
for dir in $PATH
do
  if test "$gettext_dir" = FAILED && test -f $dir/gettext \
     && ($dir/gettext --version >/dev/null 2>&1)
  then
    set `$dir/gettext --version 2>&1`
    if test "$3" = GNU
    then
      gettext_dir=$dir
    fi
  fi
  if test "$locale_dir" = FAILED && test -f $dir/shar \
     && ($dir/shar --print-text-domain-dir >/dev/null 2>&1)
  then
    locale_dir=`$dir/shar --print-text-domain-dir`
  fi
done
IFS="$save_IFS"
if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED
then
  echo=echo
else
  TEXTDOMAINDIR=$locale_dir
  export TEXTDOMAINDIR
  TEXTDOMAIN=sharutils
  export TEXTDOMAIN
  echo="$gettext_dir/gettext -s"
fi
if mkdir _sh09377; then
  $echo 'x -' 'creating lock directory'
else
  $echo 'failed to create lock directory'
  exit 1
fi
# ============= fsr/syssgi.c ==============
if test ! -d 'fsr'; then
  $echo 'x -' 'creating directory' 'fsr'
  mkdir 'fsr'
fi
if test -f 'fsr/syssgi.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'fsr/syssgi.c' '(file already exists)'
else
  $echo 'x -' extracting 'fsr/syssgi.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'fsr/syssgi.c' &&
#include <libxfs.h>
#include <xfs_dfrag.h>
#include <sys/types.h>
#include <stdarg.h>
#include <sys/ioctl.h>
X
#include "syssgi.h"
X
X
int 
syssgi(int func,  ...)
{
X       va_list ap;
X        int fd;
X        int subtype;
X       xfs_fsop_geom_t *geom;
X       xfs_fsop_bulkreq_t bulkreq;
X       xfs_swapext_t   *sx;
X       
X
X       va_start(ap, func);
X
X       switch (func) {
X               case SGI_XFS_FSOPERATIONS:
X                       fd = va_arg(ap, int);
X                       subtype = va_arg(ap, int);
X                       switch (subtype) {
X                               case XFS_FS_GEOMETRY:
X                                       (void)va_arg(ap, char *);
X                                       geom = (xfs_fsop_geom_t *)va_arg(ap, 
char *);
X                                       return ioctl(fd, XFS_IOC_FSGEOMETRY, 
geom);
X                       }
X                       break;
X
X               case SGI_FS_BULKSTAT_SINGLE:
X               case SGI_FS_BULKSTAT:
X                       fd = va_arg(ap, int);
X                       bulkreq.lastip = (INO64_T *)va_arg(ap, INO64_T *);
X                       bulkreq.icount = (int)va_arg(ap, int);
X                       bulkreq.ubuffer = (char *)va_arg(ap, char *);
X                       bulkreq.ocount =  (size_t *)va_arg(ap, size_t *);
X                       return ioctl(fd, func, &bulkreq);
X
X               case SGI_FS_SWAPEXT:
X                       sx = va_arg(ap, xfs_swapext_t *);
X                       fd = sx->sx_fdtarget;
X                       return ioctl(fd, SGI_FS_SWAPEXT,  sx);
X       }
X       return -1;
}
SHAR_EOF
  chmod 0644 'fsr/syssgi.c' ||
  $echo 'restore of' 'fsr/syssgi.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'fsr/syssgi.c:' 'MD5 check failed'
57308340e09204b4f18ca2d736259dc0  fsr/syssgi.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'fsr/syssgi.c'`"
    test 1111 -eq "$shar_count" ||
    $echo 'fsr/syssgi.c:' 'original size' '1111,' 'current size' "$shar_count!"
  fi
fi
# ============= fsr/syssgi.h ==============
if test -f 'fsr/syssgi.h' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'fsr/syssgi.h' '(file already exists)'
else
  $echo 'x -' extracting 'fsr/syssgi.h' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'fsr/syssgi.h' &&
X
int syssgi(int, ...);
X
#include <libxfs.h>
X
X
#define SGI_FS_BULKSTAT         XFS_IOC_FSBULKSTAT
#define SGI_FS_BULKSTAT_SINGLE  XFS_IOC_FSBULKSTAT_SINGLE
#define SGI_XFS_FSOPERATIONS    999
#define SGI_FS_SWAPEXT          XFS_IOC_SWAPEXT
X
#define INO64_T __s64
X
SHAR_EOF
  chmod 0644 'fsr/syssgi.h' ||
  $echo 'restore of' 'fsr/syssgi.h' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'fsr/syssgi.h:' 'MD5 check failed'
a85286de3bb951c5593291ead5a24906  fsr/syssgi.h
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'fsr/syssgi.h'`"
    test 256 -eq "$shar_count" ||
    $echo 'fsr/syssgi.h:' 'original size' '256,' 'current size' "$shar_count!"
  fi
fi
# ============= fsr/Makefile.patch ==============
if test -f 'fsr/Makefile.patch' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'fsr/Makefile.patch' '(file already exists)'
else
  $echo 'x -' extracting 'fsr/Makefile.patch' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'fsr/Makefile.patch' &&
*** Makefile.orig       Mon Jul 24 22:45:04 2000
--- Makefile    Mon Jul 24 22:45:17 2000
***************
*** 33,40 ****
X  TOPDIR = ..
X  include $(TOPDIR)/include/builddefs
X  
! CMDTARGET = fsr_xfs
! CFILES = fsr_xfs.c
X  LLDLIBS = $(LIBHANDLE)
X  
X  default: $(CMDTARGET)
--- 33,40 ----
X  TOPDIR = ..
X  include $(TOPDIR)/include/builddefs
X  
! CMDTARGET = fsr_xfs 
! CFILES = fsr_xfs.c syssgi.c
X  LLDLIBS = $(LIBHANDLE)
X  
X  default: $(CMDTARGET)
SHAR_EOF
  chmod 0644 'fsr/Makefile.patch' ||
  $echo 'restore of' 'fsr/Makefile.patch' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'fsr/Makefile.patch:' 'MD5 check failed'
7d5003b5636b5460fc5ae70093ed191c  fsr/Makefile.patch
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'fsr/Makefile.patch'`"
    test 437 -eq "$shar_count" ||
    $echo 'fsr/Makefile.patch:' 'original size' '437,' 'current size' 
"$shar_count!"
  fi
fi
# ============= fsr/fsr_xfs.c.patch ==============
if test -f 'fsr/fsr_xfs.c.patch' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'fsr/fsr_xfs.c.patch' '(file already exists)'
else
  $echo 'x -' extracting 'fsr/fsr_xfs.c.patch' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'fsr/fsr_xfs.c.patch' &&
*** fsr_xfs.c.orig      Mon Jul 24 22:43:02 2000
--- fsr_xfs.c   Mon Jul 24 22:44:54 2000
***************
*** 65,72 ****
--- 65,76 ----
X  #include <syslog.h>
X  #include <string.h>
X  #include <signal.h>
+ #include <sys/ioctl.h>
X  #include <sys/wait.h>
X  #include <sys/statvfs.h>
+ #include <xfs_dfrag.h>
+ 
+ #include "syssgi.h"
X  
X  int vflag;
X  int gflag;
***************
*** 88,93 ****
--- 92,99 ----
X  #undef O_DIRECT
X  #define O_DIRECT 0   /* TODO - remove this when direct IO done */
X  
+ #define MNTTYPE_XFS             "xfs"
+ 
X  #define SMBUFSZ              1024
X  #define ROOT         0
X  #define GRABSZ               64
***************
*** 105,127 ****
X  static char *progname;
X  static time_t endtime;
X  static time_t starttime;
! static ino64_t        leftoffino = 0;
X  static int   pagesize;
X  
X  void usage(int ret);
! static int  fsrfile(char *fname, ino64_t ino);
X  static int  fsrfile_common( char *fname, char *tname, char *mnt, 
X                              int fd, xfs_bstat_t *statp);
X  static int  packfile(char *fname, char *tname, int fd, 
X                       xfs_bstat_t *statp, int flag);
X  static void fsrdir(char *dirname);
! static int  fsrfs(char *mntdir, ino64_t ino, int targetrange);
X  static void initallfs(char *mtab);
X  static void fsrallfs(int howlong, char *leftofffile);
X  static void fsrall_cleanup(int timeout);
- #if 0 /* TODO - port to Linux */
X  static int  getnextents(int);
- #endif
X  int xfsrtextsize(int fd);
X  int xfs_getrt(int fd, struct statvfs64 *sfbp);
X  char * gettmpname(char *fname);
--- 111,131 ----
X  static char *progname;
X  static time_t endtime;
X  static time_t starttime;
! static INO64_T        leftoffino = 0;
X  static int   pagesize;
X  
X  void usage(int ret);
! static int  fsrfile(char *fname, INO64_T ino);
X  static int  fsrfile_common( char *fname, char *tname, char *mnt, 
X                              int fd, xfs_bstat_t *statp);
X  static int  packfile(char *fname, char *tname, int fd, 
X                       xfs_bstat_t *statp, int flag);
X  static void fsrdir(char *dirname);
! static int  fsrfs(char *mntdir, INO64_T ino, int targetrange);
X  static void initallfs(char *mtab);
X  static void fsrallfs(int howlong, char *leftofffile);
X  static void fsrall_cleanup(int timeout);
X  static int  getnextents(int);
X  int xfsrtextsize(int fd);
X  int xfs_getrt(int fd, struct statvfs64 *sfbp);
X  char * gettmpname(char *fname);
***************
*** 133,138 ****
--- 137,143 ----
X  static char * tmp_next(char *mnt);
X  static void tmp_close(char *mnt);
X  int xfs_getgeom(int , xfs_fsop_geom_t * );
+ static int getmntany (FILE *, struct mntent *, struct mntent *);
X  
X  xfs_fsop_geom_t fsgeom;      /* geometry of active mounted system */
X  
***************
*** 249,261 ****
X                               else
X                                       mntpref.mnt_fsname = argname;
X  
- #if 0 /* TODO - port to Linux */
X                               if ((getmntany(mtabp, &mntent, &mntpref) == 0) 
X                                    &&
X                                  (strcmp(mntent.mnt_type, MNTTYPE_XFS) == 0))
- #else
- ASSERT(0);
- #endif
X                               {
X                                       mntp = &mntent;
X                                       if (S_ISBLK(sb.st_mode)) {
--- 254,262 ----
***************
*** 325,333 ****
X       struct mntent *mp;
X       int mi;
X       char *cp;
- #if 0 /* TODO - port to Linux */
X       struct stat sb;
- #endif
X  
X       fp = setmntent(mtab, "r");
X       if (fp == NULL) {
--- 326,332 ----
***************
*** 348,361 ****
X       while (mp = getmntent(fp)) {
X               int rw = 0;
X  
! #if 0 /* TODO - port to Linux */
!               if (strcmp(mp->mnt_type, FSID_XFS) != 0 ||
X                   stat(mp->mnt_fsname, &sb) == -1 ||
X                   !S_ISBLK(sb.st_mode))
X                       continue;
- #else
- ASSERT(0);
- #endif
X  
X               cp = strtok(mp->mnt_opts,",");
X               do {
--- 347,356 ----
X       while (mp = getmntent(fp)) {
X               int rw = 0;
X  
!               if (strcmp(mp->mnt_type, MNTTYPE_XFS ) != 0 ||
X                   stat(mp->mnt_fsname, &sb) == -1 ||
X                   !S_ISBLK(sb.st_mode))
X                       continue;
X  
X               cp = strtok(mp->mnt_opts,",");
X               do {
***************
*** 420,426 ****
X       char buf[SMBUFSZ];
X       int mdonly = Mflag;
X       char *ptr;
!       ino64_t startino = 0;
X       fsdesc_t *fsp;
X       
X       fsrprintf("fsr_xfs -m %s -t %d -f %s ...\n", mtab, howlong, 
leftofffile);
--- 415,421 ----
X       char buf[SMBUFSZ];
X       int mdonly = Mflag;
X       char *ptr;
!       INO64_T startino = 0;
X       fsdesc_t *fsp;
X       
X       fsrprintf("fsr_xfs -m %s -t %d -f %s ...\n", mtab, howlong, 
leftofffile);
***************
*** 560,566 ****
X   * fsrfs -- reorganize a file system
X   */
X  static int
! fsrfs(char *mntdir, ino64_t startino, int targetrange)
X  {
X  
X       int     fsfd, fd;
--- 555,561 ----
X   * fsrfs -- reorganize a file system
X   */
X  static int
! fsrfs(char *mntdir, INO64_T startino, int targetrange)
X  {
X  
X       int     fsfd, fd;
***************
*** 571,579 ****
X       char    fname[64];
X       char    *tname;
X       jdm_fshandle_t  *fshandlep;
! #if 0   /* TODO - port to Linux */
!       ino64_t lastino = startino;
! #endif
X  
X       fsrprintf("%s startino=%lld\n", mntdir, startino);
X  
--- 566,572 ----
X       char    fname[64];
X       char    *tname;
X       jdm_fshandle_t  *fshandlep;
!       INO64_T lastino = startino;
X  
X       fsrprintf("%s startino=%lld\n", mntdir, startino);
X  
***************
*** 598,610 ****
X  
X       tmp_init(mntdir);
X  
! #if 0 /* TODO - port to Linux */
X       while (! syssgi( SGI_FS_BULKSTAT, fsfd, &lastino, 
X                        GRABSZ, &buf[0], &buflenout)) {
- #else
- ASSERT(0);
- {
- #endif
X               xfs_bstat_t *p;
X               xfs_bstat_t *endp;
X  
--- 591,599 ----
X  
X       tmp_init(mntdir);
X  
!       sync();
X       while (! syssgi( SGI_FS_BULKSTAT, fsfd, &lastino, 
X                        GRABSZ, &buf[0], &buflenout)) {
X               xfs_bstat_t *p;
X               xfs_bstat_t *endp;
X  
***************
*** 691,697 ****
X   * an open on the file and passes this all to fsrfile_common.
X   */
X  static int
! fsrfile(char *fname, ino64_t ino)
X  {
X       xfs_bstat_t     statbuf;
X       jdm_fshandle_t  *fshandlep;
--- 680,686 ----
X   * an open on the file and passes this all to fsrfile_common.
X   */
X  static int
! fsrfile(char *fname, INO64_T ino)
X  {
X       xfs_bstat_t     statbuf;
X       jdm_fshandle_t  *fshandlep;
***************
*** 719,725 ****
X               return -1;
X       }
X       
- #if 0 /* TODO - port to Linux */
X       if ((syssgi( SGI_FS_BULKSTAT_SINGLE, fsfd, &ino, &statbuf)) < 0) {
X               fsrprintf(
X                 "unable to get bstat on %s: %s\n",
--- 708,713 ----
***************
*** 727,735 ****
X               close(fsfd);
X               return -1;
X       }
- #else
- ASSERT(0);
- #endif
X               
X       fd = jdm_open( fshandlep, &statbuf, O_RDWR);
X       if (fd < 0) {
--- 715,720 ----
***************
*** 785,793 ****
X       int             pid;
X       int             error;
X       struct statvfs64 vfss;
- #if 0 /* TODO - port to Linux */
X       struct fsxattr  fsx;
- #endif
X       int             do_rt = 0;
X       unsigned long   bsize;
X  #ifdef HAVE_CAPBILITIES
--- 770,776 ----
***************
*** 852,860 ****
X               return 1;
X       }
X  
- #if 0 /* TODO - port to Linux */
X       /* Check realtime info */
!       if ((fcntl(fd, F_FSGETXATTR, &fsx)) < 0) {
X               fsrprintf("failed to get attrs: %s\n", fname);
X               return(-1);
X       }
--- 835,842 ----
X               return 1;
X       }
X  
X       /* Check realtime info */
!       if ((ioctl(fd, XFS_IOC_FSGETXATTR, &fsx)) < 0) {
X               fsrprintf("failed to get attrs: %s\n", fname);
X               return(-1);
X       }
***************
*** 870,876 ****
X               }
X               do_rt = 1;
X       }
- #endif
X  
X       if ((RealUid != ROOT) && (RealUid != statp->bs_uid)) {
X               fsrprintf("cannot open: %s: Permission denied\n", fname);
--- 852,857 ----
***************
*** 929,935 ****
X  static int
X  packfile(char *fname, char *tname, int fd, xfs_bstat_t *statp, int do_rt)
X  {
- #if 0 /* TODO - port to Linux - plenty to do here */
X       int             tfd;
X       int             srval;
X       int             nextents, extent, cur_nextents, new_nextents;
--- 910,915 ----
***************
*** 937,943 ****
X       unsigned        dio_min;
X       struct dioattr  dio;
X       static xfs_swapext_t   sx;
!       struct flock64  space;
X       off64_t         cnt, pos;
X       void            *fbuf;
X       int             ct, wc, wc_b4;
--- 917,923 ----
X       unsigned        dio_min;
X       struct dioattr  dio;
X       static xfs_swapext_t   sx;
!       struct xfs_flock64  space;
X       off64_t         cnt, pos;
X       void            *fbuf;
X       int             ct, wc, wc_b4;
***************
*** 970,982 ****
X       }
X       unlink(tname);
X  
X       /* Setup direct I/O */
X       if((fcntl(tfd, F_SETFL, FDIRECT)) < 0 ) {
X               fsrprintf("could not set FDIRECT on tmp: %s:\n", tname);
X               close(tfd);
X               return -1;
X       }
!       if( (fcntl(tfd, F_DIOINFO, &dio)) < 0 ) {
X               fsrprintf("could not get I/O info on tmp: %s\n", tname);
X               close(tfd);
X               return -1;
--- 950,964 ----
X       }
X       unlink(tname);
X  
+ #if  0
X       /* Setup direct I/O */
X       if((fcntl(tfd, F_SETFL, FDIRECT)) < 0 ) {
X               fsrprintf("could not set FDIRECT on tmp: %s:\n", tname);
X               close(tfd);
X               return -1;
X       }
! #endif
!       if( (ioctl(tfd, XFS_IOC_DIOINFO, &dio)) < 0 ) {
X               fsrprintf("could not get I/O info on tmp: %s\n", tname);
X               close(tfd);
X               return -1;
***************
*** 992,998 ****
X                       return -1;
X               }
X  
!               if (fcntl( tfd, F_FSSETXATTR, &tfsx) < 0) {
X                       fsrprintf("could not set rt on tmp: %s\n", tname);
X                       close(tfd);
X                       return -1;
--- 974,980 ----
X                       return -1;
X               }
X  
!               if (ioctl( tfd,  XFS_IOC_FSSETXATTR, &tfsx) < 0) {
X                       fsrprintf("could not set rt on tmp: %s\n", tname);
X                       close(tfd);
X                       return -1;
***************
*** 1028,1034 ****
X                       space.l_whence = 0;
X                       space.l_start = pos;
X                       space.l_len = outmap[extent].bmv_length;
!                       if (fcntl(tfd, F_UNRESVSP64, &space) < 0) {
X                               fsrprintf("could not trunc tmp %s\n", 
X                                          tname);
X                       }
--- 1010,1016 ----
X                       space.l_whence = 0;
X                       space.l_start = pos;
X                       space.l_len = outmap[extent].bmv_length;
!                       if (ioctl(tfd, XFS_IOC_UNRESVSP64, &space) < 0) {
X                               fsrprintf("could not trunc tmp %s\n", 
X                                          tname);
X                       }
***************
*** 1044,1050 ****
X               space.l_start = 0;
X               space.l_len = outmap[extent].bmv_length;
X  
!               if (fcntl(tfd, F_RESVSP64, &space) < 0) {
X                       fsrprintf("could not pre-alloc tmp space: %s\n",
X                                 tname);
X                       close(tfd);
--- 1026,1032 ----
X               space.l_start = 0;
X               space.l_len = outmap[extent].bmv_length;
X  
!               if (ioctl(tfd, XFS_IOC_RESVSP64, &space) < 0) {
X                       fsrprintf("could not pre-alloc tmp space: %s\n",
X                                 tname);
X                       close(tfd);
***************
*** 1109,1114 ****
--- 1091,1097 ----
X               }
X       }
X       ftruncate64(tfd, statp->bs_size);
+       fsync(tfd);
X  
X       free(fbuf);
X  
***************
*** 1158,1166 ****
X                         (new_nextents <= nextents ? "DONE" : "    " ),
X                         fname);
X       close(tfd);
- #else
- ASSERT(0);
- #endif
X       return 0;
X  }
X  
--- 1141,1146 ----
***************
*** 1273,1287 ****
X       *cur_nextents = 0;
X  
X       do {
! #if 0 /* TODO - port to Linux */
!               if (fcntl(fd, F_GETBMAP, map) < 0) {
X                       fsrprintf("failed reading extents: inode %lld",
X                                sin->bs_ino);
X                       exit(1);
X               }
- #else
- ASSERT(0);
- #endif
X  
X               /* Concatenate extents together and replicate holes into
X                * the output map.
--- 1253,1263 ----
X       *cur_nextents = 0;
X  
X       do {
!               if (ioctl(fd, XFS_IOC_GETBMAP, map) < 0) {
X                       fsrprintf("failed reading extents: inode %lld",
X                                sin->bs_ino);
X                       exit(1);
X               }
X  
X               /* Concatenate extents together and replicate holes into
X                * the output map.
***************
*** 1312,1319 ****
X  /*
X   * Read the block map and return the number of extents.
X   */
! #if 0 /* TODO - port to Linux */
! int 
X  getnextents(int fd)
X  {
X       int             nextents;
--- 1288,1294 ----
X  /*
X   * Read the block map and return the number of extents.
X   */
! static int 
X  getnextents(int fd)
X  {
X       int             nextents;
***************
*** 1328,1334 ****
X       nextents = 0;
X  
X       do {
!               if (fcntl(fd, F_GETBMAP, map) < 0) {
X                       fsrprintf("failed reading extents");
X                       exit(1);
X               }
--- 1303,1309 ----
X       nextents = 0;
X  
X       do {
!               if (ioctl(fd,XFS_IOC_GETBMAP, map) < 0) {
X                       fsrprintf("failed reading extents");
X                       exit(1);
X               }
***************
*** 1337,1343 ****
X       } while (map[0].bmv_entries == (MAPSIZE-1));
X       return(nextents);
X  }
- #endif
X  
X  /*
X   * Get the fs geometry
--- 1312,1317 ----
***************
*** 1345,1351 ****
X  int
X  xfs_getgeom(int fd, xfs_fsop_geom_t * fsgeom)
X  {
- #if 0 /* TODO - port to Linux */
X       if (syssgi(SGI_XFS_FSOPERATIONS, 
X                  fd, 
X                  XFS_FS_GEOMETRY, 
--- 1319,1324 ----
***************
*** 1353,1361 ****
X                  fsgeom) < 0) {
X               return -1;
X       }
- #else
- ASSERT(0);
- #endif
X       return 0;
X  }
X  
--- 1326,1331 ----
***************
*** 1408,1413 ****
--- 1378,1404 ----
X       va_end(ap);
X       return 0;
X  }
+ 
+ /*
+  * emulate getmntany
+  */
+ static int
+ getmntany (FILE *filep, struct mntent *mp, struct mntent *mpref)
+ {
+         int match = 0;
+         struct mntent *t;
+ 
+         while (!match && (t = getmntent(filep)) != 0) {
+                 if (mpref->mnt_fsname != NULL &&
+                   strcmp(mpref->mnt_fsname, t->mnt_fsname) != 0)  continue;
+                 if (mpref->mnt_dir != NULL &&
+                     strcmp(mpref->mnt_dir, t->mnt_dir) != 0)  continue;
+                 match++;
+         }
+         if (match) *mp = *t;
+         return !match;
+ }
+ 
X  
X  /*
X   * Initialize a directory for tmp file use.  This is used
SHAR_EOF
  chmod 0644 'fsr/fsr_xfs.c.patch' ||
  $echo 'restore of' 'fsr/fsr_xfs.c.patch' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'fsr/fsr_xfs.c.patch:' 'MD5 check failed'
758211f974fbed2e02069ff82e8e4f14  fsr/fsr_xfs.c.patch
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'fsr/fsr_xfs.c.patch'`"
    test 12816 -eq "$shar_count" ||
    $echo 'fsr/fsr_xfs.c.patch:' 'original size' '12816,' 'current size' 
"$shar_count!"
  fi
fi
# ============= linux/xfs_dfrag.c.patch ==============
if test ! -d 'linux'; then
  $echo 'x -' 'creating directory' 'linux'
  mkdir 'linux'
fi
if test -f 'linux/xfs_dfrag.c.patch' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'linux/xfs_dfrag.c.patch' '(file already exists)'
else
  $echo 'x -' extracting 'linux/xfs_dfrag.c.patch' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'linux/xfs_dfrag.c.patch' &&
*** xfs_dfrag.c.orig    Sat Jul 22 22:36:05 2000
--- xfs_dfrag.c Sat Jul 22 22:37:57 2000
***************
*** 33,38 ****
--- 33,39 ----
X  
X  #include <xfs_os_defs.h>
X  #include <linux/xfs_cred.h>
+ #include <linux/file.h>
X  
X  #include <sys/param.h>
X  #include "xfs_buf.h"
***************
*** 43,49 ****
X  #include <sys/vnode.h>
X  
X  #include <sys/kabi.h>
- #include <ksys/vfile.h>
X  #include <ksys/cell_config.h>
X  #include <sys/vfs.h>
X  #include <sys/uuid.h>
--- 44,49 ----
***************
*** 78,84 ****
X  #include "xfs_rw.h"
X  
X  extern void xfs_lock_inodes (xfs_inode_t **, int, int, uint);
- extern int getf(int, struct vfile **);
X  extern int xfs_bmap_count_blocks( xfs_trans_t *, xfs_inode_t *, int, int *); 
X  
X  /*
--- 78,83 ----
***************
*** 93,99 ****
X       xfs_trans_t     *tp;
X       xfs_mount_t     *mp;
X       xfs_bstat_t     *sbp;
!       struct vfile    *fp, *tfp;
X       vnode_t         *vp, *tvp;
X          bhv_desc_t      *bdp, *tbdp;
X          vn_bhv_head_t   *bhp, *tbhp;
--- 92,98 ----
X       xfs_trans_t     *tp;
X       xfs_mount_t     *mp;
X       xfs_bstat_t     *sbp;
!       struct file     *fp = NULL, *tfp = NULL;
X       vnode_t         *vp, *tvp;
X          bhv_desc_t      *bdp, *tbdp;
X          vn_bhv_head_t   *bhp, *tbhp;
***************
*** 104,169 ****
X       __uint64_t      tmp;
X       __uint64_t      cxfs_val;
X       int             aforkblks = 0;
X  
X       if (copyin(sxp, &sx, sizeof sx))
X               return XFS_ERROR(EFAULT);
X  
X       /* Pull information for the target fd */
!       if (error = getf(sx.sx_fdtarget, &fp))
!               return XFS_ERROR(error);
! 
!       if (!VF_IS_VNODE(fp) || VF_TO_VNODE(fp)->v_type != VREG)
!               return XFS_ERROR(EINVAL);
X  
-       vp = VF_TO_VNODE(fp);
X       bhp = VN_BHV_HEAD(vp);
X       VN_BHV_READ_LOCK(bhp);
X       bdp = vn_bhv_lookup(bhp, &xfs_vnodeops);
X       if (bdp == NULL) {
X               VN_BHV_READ_UNLOCK(bhp);
!               return XFS_ERROR(EBADF);
X       } else {
X               ip = XFS_BHVTOI(bdp);
X               VN_BHV_READ_UNLOCK(bhp);
X       }
X  
!       /* Pull information for the tmp fd */
!       if (error = getf(sx.sx_fdtmp, &tfp))
!               return XFS_ERROR(error);
! 
!       if (!VF_IS_VNODE(tfp) || VF_TO_VNODE(tfp)->v_type != VREG)
!               return XFS_ERROR(EINVAL);
X  
-       tvp = VF_TO_VNODE(tfp);
X       tbhp = VN_BHV_HEAD(tvp);
X       VN_BHV_READ_LOCK(tbhp);
X       tbdp = vn_bhv_lookup(tbhp, &xfs_vnodeops);
X       if (tbdp == NULL) {
X               VN_BHV_READ_UNLOCK(tbhp);
!               return XFS_ERROR(EBADF);
X       } else {
X               tip = XFS_BHVTOI(tbdp);
X               VN_BHV_READ_UNLOCK(tbhp);
X       }
X  
X       if (ip->i_ino == tip->i_ino) {
!               return XFS_ERROR(EINVAL);
X       }
X  
X       mp = ip->i_mount;
X  
X       sbp = &sx.sx_stat;
X  
!       if (XFS_FORCED_SHUTDOWN(mp))
!               return XFS_ERROR(EIO);
! 
!       CELL_ONLY(cxfs_val = cfs_start_defrag(vp));
X  
X       /* quit if either is the swap file */
!       if (vp->v_flag & VISSWAP && vp->v_type == VREG)
!               return XFS_ERROR(EACCES);
!       if (tvp->v_flag & VISSWAP && tvp->v_type == VREG)
!               return XFS_ERROR(EACCES);
X  
X       /* Lock in i_ino order */
X       if (ip->i_ino < tip->i_ino) {
--- 103,176 ----
X       __uint64_t      tmp;
X       __uint64_t      cxfs_val;
X       int             aforkblks = 0;
+       int             locked = 0;
X  
X       if (copyin(sxp, &sx, sizeof sx))
X               return XFS_ERROR(EFAULT);
X  
X       /* Pull information for the target fd */
!       if (((fp = fget((int)sx.sx_fdtarget)) == NULL) ||
!             ((vp = LINVFS_GET_VP(fp->f_dentry->d_inode)) == NULL))  {
!                 error = XFS_ERROR(EINVAL);
!                 goto error0;
!         }
X  
X       bhp = VN_BHV_HEAD(vp);
X       VN_BHV_READ_LOCK(bhp);
X       bdp = vn_bhv_lookup(bhp, &xfs_vnodeops);
X       if (bdp == NULL) {
X               VN_BHV_READ_UNLOCK(bhp);
!               error = XFS_ERROR(EBADF);
!                 goto error0;
X       } else {
X               ip = XFS_BHVTOI(bdp);
X               VN_BHV_READ_UNLOCK(bhp);
X       }
X  
!         if (((tfp = fget((int)sx.sx_fdtmp)) == NULL) ||
!             ((tvp = LINVFS_GET_VP(tfp->f_dentry->d_inode)) == NULL)) {
!                 error = XFS_ERROR(EINVAL);
!                 goto error0;
!         }
X  
X       tbhp = VN_BHV_HEAD(tvp);
X       VN_BHV_READ_LOCK(tbhp);
X       tbdp = vn_bhv_lookup(tbhp, &xfs_vnodeops);
X       if (tbdp == NULL) {
X               VN_BHV_READ_UNLOCK(tbhp);
!               error = XFS_ERROR(EBADF);
!                 goto error0;
X       } else {
X               tip = XFS_BHVTOI(tbdp);
X               VN_BHV_READ_UNLOCK(tbhp);
X       }
X  
X       if (ip->i_ino == tip->i_ino) {
!               error =  XFS_ERROR(EINVAL);
!                 goto error0;
X       }
X  
X       mp = ip->i_mount;
X  
X       sbp = &sx.sx_stat;
X  
!       if (XFS_FORCED_SHUTDOWN(mp)) {
!               error =  XFS_ERROR(EIO);
!                 goto error0;
!       }
X  
X       /* quit if either is the swap file */
!       if (vp->v_flag & VISSWAP && vp->v_type == VREG) {
!               error = XFS_ERROR(EACCES);
!                 goto error0;
!       }
!       if (tvp->v_flag & VISSWAP && tvp->v_type == VREG) {
!               error = XFS_ERROR(EACCES);
!                 goto error0;
!       }
! 
!       locked = 1;
!       CELL_ONLY(cxfs_val = cfs_start_defrag(vp));
X  
X       /* Lock in i_ino order */
X       if (ip->i_ino < tip->i_ino) {
***************
*** 389,399 ****
X          error = xfs_trans_commit(tp, XFS_TRANS_SWAPEXT, NULL);
X  
X       CELL_ONLY(cfs_end_defrag(vp, cxfs_val));
X       return error;
X  
X   error0:
!       CELL_ONLY(cfs_end_defrag(vp, cxfs_val));
!       xfs_iunlock(ip,  lock_flags);
!       xfs_iunlock(tip, lock_flags);
X       return error;
X  }
--- 396,416 ----
X          error = xfs_trans_commit(tp, XFS_TRANS_SWAPEXT, NULL);
X  
X       CELL_ONLY(cfs_end_defrag(vp, cxfs_val));
+ 
+         fput(fp);
+         fput(tfp);
+ 
X       return error;
X  
X   error0:
!       if (locked) {
!               CELL_ONLY(cfs_end_defrag(vp, cxfs_val));
!               xfs_iunlock(ip,  lock_flags);
!               xfs_iunlock(tip, lock_flags);
!       }
! 
!         if (fp != NULL) fput(fp);
!         if (tfp != NULL) fput(tfp);
! 
X       return error;
X  }
SHAR_EOF
  chmod 0644 'linux/xfs_dfrag.c.patch' ||
  $echo 'restore of' 'linux/xfs_dfrag.c.patch' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'linux/xfs_dfrag.c.patch:' 'MD5 check failed'
4a412b880c506622c1f8b3b54193e3ad  linux/xfs_dfrag.c.patch
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'linux/xfs_dfrag.c.patch'`"
    test 5500 -eq "$shar_count" ||
    $echo 'linux/xfs_dfrag.c.patch:' 'original size' '5500,' 'current size' 
"$shar_count!"
  fi
fi
# ============= linux/xfs_dfrag.h.patch ==============
if test -f 'linux/xfs_dfrag.h.patch' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'linux/xfs_dfrag.h.patch' '(file already exists)'
else
  $echo 'x -' extracting 'linux/xfs_dfrag.h.patch' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'linux/xfs_dfrag.h.patch' &&
*** xfs_dfrag.h.orig    Sat Jul 22 22:40:07 2000
--- xfs_dfrag.h Sat Jul 22 22:41:27 2000
***************
*** 54,59 ****
--- 54,61 ----
X   */
X  #define XFS_SX_VERSION               0
X  
+ #define XFS_IOC_SWAPEXT              _IOWR('X', 109, struct xfs_swapext)
+ 
X  
X  #ifdef _KERNEL
X  /*
SHAR_EOF
  chmod 0644 'linux/xfs_dfrag.h.patch' ||
  $echo 'restore of' 'linux/xfs_dfrag.h.patch' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'linux/xfs_dfrag.h.patch:' 'MD5 check failed'
10a4282d468178d974c4391e48b5f090  linux/xfs_dfrag.h.patch
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'linux/xfs_dfrag.h.patch'`"
    test 273 -eq "$shar_count" ||
    $echo 'linux/xfs_dfrag.h.patch:' 'original size' '273,' 'current size' 
"$shar_count!"
  fi
fi
# ============= linux/xfs_ioctl.c.patch ==============
if test -f 'linux/xfs_ioctl.c.patch' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'linux/xfs_ioctl.c.patch' '(file already exists)'
else
  $echo 'x -' extracting 'linux/xfs_ioctl.c.patch' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'linux/xfs_ioctl.c.patch' &&
*** xfs_ioctl.c.orig    Sat Jul 22 22:42:01 2000
--- xfs_ioctl.c Sat Jul 22 22:47:37 2000
***************
*** 75,80 ****
--- 75,81 ----
X  #include <xfs_iops.h>
X  #include <linux/dmapi_kern.h>
X  #include <xfs_dmapi.h>
+ #include <xfs_dfrag.h>
X  
X  #include <linux/smp_lock.h>
X  
***************
*** 1064,1069 ****
--- 1065,1080 ----
X       case XFS_IOC_READLINK_BY_HANDLE: {
X  
X               return xfs_readlink_by_handle(cmd, arg, filp, inode, vfsp, mp);
+       }
+ 
+       case XFS_IOC_SWAPEXT: {
+ 
+                 error = xfs_swapext((struct xfs_swapext *)arg);
+ 
+               if (error)
+                       return -error;
+               return error;
+ 
X       }
X  
X       case XFS_IOC_GETFSUUID: {
SHAR_EOF
  chmod 0644 'linux/xfs_ioctl.c.patch' ||
  $echo 'restore of' 'linux/xfs_ioctl.c.patch' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'linux/xfs_ioctl.c.patch:' 'MD5 check failed'
0d41d5ffb1807f0d044690006471a6b6  linux/xfs_ioctl.c.patch
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'linux/xfs_ioctl.c.patch'`"
    test 638 -eq "$shar_count" ||
    $echo 'linux/xfs_ioctl.c.patch:' 'original size' '638,' 'current size' 
"$shar_count!"
  fi
fi
rm -fr _sh09377
exit 0

<Prev in Thread] Current Thread [Next in Thread>
  • fsr patch, William L Jones <=