~ubuntu-branches/ubuntu/edgy/xfsprogs/edgy

« back to all changes in this revision

Viewing changes to libxfs/xfs_rtalloc.c

  • Committer: Bazaar Package Importer
  • Author(s): Nathan Scott
  • Date: 2004-07-28 21:11:38 UTC
  • Revision ID: james.westby@ubuntu.com-20040728211138-0v4pdnunnp7na5lm
Tags: 2.6.20-1
* New upstream release.
* Fix xfs_io segfault on non-XFS files.  (closes: #260470)
* Fix packaging botch, deleted files included.  (closes: #260491)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
3
 
 * 
 
2
 * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
 
3
 *
4
4
 * This program is free software; you can redistribute it and/or modify it
5
5
 * under the terms of version 2 of the GNU General Public License as
6
6
 * published by the Free Software Foundation.
7
 
 * 
 
7
 *
8
8
 * This program is distributed in the hope that it would be useful, but
9
9
 * WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 
 * 
 
11
 *
12
12
 * Further, this software is distributed without any warranty that it is
13
13
 * free of the rightful claim of any third person regarding infringement
14
14
 * or the like.  Any license provided herein, whether implied or
15
15
 * otherwise, applies only to this software file.  Patent licenses, if
16
16
 * any, provided herein do not apply to combinations of this program with
17
17
 * other software, or any other product whatsoever.
18
 
 * 
 
18
 *
19
19
 * You should have received a copy of the GNU General Public License along
20
20
 * with this program; if not, write the Free Software Foundation, Inc., 59
21
21
 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22
 
 * 
 
22
 *
23
23
 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24
24
 * Mountain View, CA  94043, or:
25
 
 * 
26
 
 * http://www.sgi.com 
27
 
 * 
28
 
 * For further information regarding this notice, see: 
29
 
 * 
 
25
 *
 
26
 * http://www.sgi.com
 
27
 *
 
28
 * For further information regarding this notice, see:
 
29
 *
30
30
 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31
31
 */
32
32
 
33
33
/*
34
34
 * Free realtime space allocation for XFS.
35
35
 */
 
36
 
36
37
#include <xfs.h>
37
38
 
 
39
extern int xfs_lowbit32(__uint32_t);
38
40
 
39
41
/*
40
42
 * Get a buffer for the bitmap or summary file block specified.
46
48
        xfs_trans_t     *tp,            /* transaction pointer */
47
49
        xfs_rtblock_t   block,          /* block number in bitmap or summary */
48
50
        int             issum,          /* is summary not bitmap */
49
 
        xfs_buf_t               **bpp)          /* output: buffer for the block */
 
51
        xfs_buf_t       **bpp)          /* output: buffer for the block */
50
52
{
51
 
        xfs_buf_t               *bp;            /* block buffer, result */
52
 
        xfs_daddr_t             d;              /* disk addr of block */
 
53
        xfs_buf_t       *bp;            /* block buffer, result */
 
54
        xfs_daddr_t     d;              /* disk addr of block */
53
55
        int             error;          /* error value */
54
56
        xfs_fsblock_t   fsb;            /* fs block number for block */
55
57
        xfs_inode_t     *ip;            /* bitmap or summary inode */
96
98
        xfs_rtword_t    *b;             /* current word in buffer */
97
99
        int             bit;            /* bit number in the word */
98
100
        xfs_rtblock_t   block;          /* bitmap block number */
99
 
        xfs_buf_t               *bp;            /* buf for the block */
 
101
        xfs_buf_t       *bp;            /* buf for the block */
100
102
        xfs_rtword_t    *bufp;          /* starting word in buffer */
101
103
        int             error;          /* error value */
102
104
        xfs_rtblock_t   firstbit;       /* first useful bit in the word */
271
273
        xfs_rtword_t    *b;             /* current word in buffer */
272
274
        int             bit;            /* bit number in the word */
273
275
        xfs_rtblock_t   block;          /* bitmap block number */
274
 
        xfs_buf_t               *bp;            /* buf for the block */
 
276
        xfs_buf_t       *bp;            /* buf for the block */
275
277
        xfs_rtword_t    *bufp;          /* starting word in buffer */
276
278
        int             error;          /* error value */
277
279
        xfs_rtblock_t   i;              /* current bit number rel. to start */
436
438
        xfs_trans_t     *tp,            /* transaction pointer */
437
439
        xfs_rtblock_t   start,          /* starting block to free */
438
440
        xfs_extlen_t    len,            /* length to free */
439
 
        xfs_buf_t               **rbpp,         /* in/out: summary block buffer */
 
441
        xfs_buf_t       **rbpp,         /* in/out: summary block buffer */
440
442
        xfs_fsblock_t   *rsb)           /* in/out: summary block number */
441
443
{
442
444
        xfs_rtblock_t   end;            /* end of the freed extent */
670
672
        int             log,            /* log2 of extent size */
671
673
        xfs_rtblock_t   bbno,           /* bitmap block number */
672
674
        int             delta,          /* change to make to summary info */
673
 
        xfs_buf_t               **rbpp,         /* in/out: summary block buffer */
 
675
        xfs_buf_t       **rbpp,         /* in/out: summary block buffer */
674
676
        xfs_fsblock_t   *rsb)           /* in/out: summary block number */
675
677
{
676
 
        xfs_buf_t               *bp;            /* buffer for the summary block */
 
678
        xfs_buf_t       *bp;            /* buffer for the summary block */
677
679
        int             error;          /* error value */
678
680
        xfs_fsblock_t   sb;             /* summary fsblock */
679
681
        int             so;             /* index into the summary file */
724
726
}
725
727
 
726
728
/*
727
 
 * Free an extent in the realtime subvolume.  Length is expressed in 
 
729
 * Free an extent in the realtime subvolume.  Length is expressed in
728
730
 * realtime extents, as is the block number.
729
731
 */
730
732
int                                     /* error */
737
739
        xfs_inode_t     *ip;            /* bitmap file inode */
738
740
        xfs_mount_t     *mp;            /* file system mount structure */
739
741
        xfs_fsblock_t   sb;             /* summary file block number */
740
 
        xfs_buf_t               *sumbp;         /* summary file block buffer */
 
742
        xfs_buf_t       *sumbp;         /* summary file block buffer */
741
743
 
742
744
        mp = tp->t_mountp;
743
745
        /*
786
788
        }
787
789
        return 0;
788
790
}
789
 
 
790
 
/*
791
 
 * Initialize realtime fields in the mount structure.
792
 
 */
793
 
int                             /* error */
794
 
xfs_rtmount_init(
795
 
        xfs_mount_t     *mp)    /* file system mount structure */
796
 
{
797
 
        xfs_buf_t       *bp;    /* buffer for last block of subvolume */
798
 
        xfs_daddr_t     d;      /* address of last block of subvolume */
799
 
        int             error;  /* error return value */
800
 
        xfs_sb_t        *sbp;   /* filesystem superblock copy in mount */
801
 
 
802
 
        sbp = &mp->m_sb;
803
 
        if (sbp->sb_rblocks == 0)
804
 
                return 0;
805
 
        if (!mp->m_rtdev) {
806
 
                printk(KERN_WARNING
807
 
                "XFS: This FS has an RT subvol - specify -o rtdev on mount\n");
808
 
                return XFS_ERROR(ENODEV);
809
 
        }
810
 
        mp->m_rsumlevels = sbp->sb_rextslog + 1;
811
 
        mp->m_rsumsize =
812
 
                (uint)sizeof(xfs_suminfo_t) * mp->m_rsumlevels *
813
 
                sbp->sb_rbmblocks;
814
 
        mp->m_rsumsize = roundup(mp->m_rsumsize, sbp->sb_blocksize);
815
 
        mp->m_rbmip = mp->m_rsumip = NULL;
816
 
        /*
817
 
         * Check that the realtime section is an ok size.
818
 
         */
819
 
        d = (xfs_daddr_t)XFS_FSB_TO_BB(mp, mp->m_sb.sb_rblocks);
820
 
        if (XFS_BB_TO_FSB(mp, d) != mp->m_sb.sb_rblocks) {
821
 
                printk(KERN_WARNING "XFS: RT mount - %llu != %llu\n",
822
 
                        (unsigned long long) XFS_BB_TO_FSB(mp, d),
823
 
                        (unsigned long long) mp->m_sb.sb_rblocks);
824
 
                return XFS_ERROR(E2BIG);
825
 
        }
826
 
        error = xfs_read_buf(mp, m_rtdev_targp(mp), d - 1, 1, 0, &bp);
827
 
        if (error) {
828
 
                printk(KERN_WARNING
829
 
                        "XFS: RT mount - xfs_read_buf returned %d\n", error);
830
 
                if (error == ENOSPC)
831
 
                        return XFS_ERROR(E2BIG);
832
 
                return error;
833
 
        }
834
 
        xfs_buf_relse(bp);
835
 
        return 0;
836
 
}