Commit e3a2c92a authored by Nathan Scott's avatar Nathan Scott

Merge bk://linux.bkbits.net/linux-2.5

into lips.borg.umn.edu:/export/music/bkroot/xfs-linux-2.6
parents 2b83a8d6 6e0c654f
...@@ -126,6 +126,7 @@ xfs-$(CONFIG_XFS_TRACE) += xfs_dir2_trace.o ...@@ -126,6 +126,7 @@ xfs-$(CONFIG_XFS_TRACE) += xfs_dir2_trace.o
# Objects in linux-2.6/ # Objects in linux-2.6/
xfs-y += $(addprefix linux-2.6/, \ xfs-y += $(addprefix linux-2.6/, \
kmem.o \
xfs_aops.o \ xfs_aops.o \
xfs_buf.o \ xfs_buf.o \
xfs_file.o \ xfs_file.o \
......
/*
* Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it would be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* Further, this software is distributed without any warranty that it is
* free of the rightful claim of any third person regarding infringement
* or the like. Any license provided herein, whether implied or
* otherwise, applies only to this software file. Patent licenses, if
* any, provided herein do not apply to combinations of this program with
* other software, or any other product whatsoever.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write the Free Software Foundation, Inc., 59
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
*
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
* Mountain View, CA 94043, or:
*
* http://www.sgi.com
*
* For further information regarding this notice, see:
*
* http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
*/
#include <linux/sched.h>
#include <linux/mm.h>
#include <linux/vmalloc.h>
#include <linux/highmem.h>
#include <linux/swap.h>
#include "time.h"
#include "kmem.h"
#define MAX_VMALLOCS 6
#define MAX_SLAB_SIZE 0x20000
void *
kmem_alloc(size_t size, int flags)
{
int retries = 0, lflags = kmem_flags_convert(flags);
void *ptr;
do {
if (size < MAX_SLAB_SIZE || retries > MAX_VMALLOCS)
ptr = kmalloc(size, lflags);
else
ptr = __vmalloc(size, lflags, PAGE_KERNEL);
if (ptr || (flags & (KM_MAYFAIL|KM_NOSLEEP)))
return ptr;
if (!(++retries % 100))
printk(KERN_ERR "possible deadlock in %s (mode:0x%x)\n",
__FUNCTION__, lflags);
} while (1);
}
void *
kmem_zalloc(size_t size, int flags)
{
void *ptr;
ptr = kmem_alloc(size, flags);
if (ptr)
memset((char *)ptr, 0, (int)size);
return ptr;
}
void
kmem_free(void *ptr, size_t size)
{
if (((unsigned long)ptr < VMALLOC_START) ||
((unsigned long)ptr >= VMALLOC_END)) {
kfree(ptr);
} else {
vfree(ptr);
}
}
void *
kmem_realloc(void *ptr, size_t newsize, size_t oldsize, int flags)
{
void *new;
new = kmem_alloc(newsize, flags);
if (ptr) {
if (new)
memcpy(new, ptr,
((oldsize < newsize) ? oldsize : newsize));
kmem_free(ptr, oldsize);
}
return new;
}
void *
kmem_zone_alloc(kmem_zone_t *zone, int flags)
{
int retries = 0, lflags = kmem_flags_convert(flags);
void *ptr;
do {
ptr = kmem_cache_alloc(zone, lflags);
if (ptr || (flags & (KM_MAYFAIL|KM_NOSLEEP)))
return ptr;
if (!(++retries % 100))
printk(KERN_ERR "possible deadlock in %s (mode:0x%x)\n",
__FUNCTION__, lflags);
} while (1);
}
void *
kmem_zone_zalloc(kmem_zone_t *zone, int flags)
{
void *ptr;
ptr = kmem_zone_alloc(zone, flags);
if (ptr)
memset((char *)ptr, 0, kmem_cache_size(zone));
return ptr;
}
/* /*
* Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as * under the terms of version 2 of the GNU General Public License as
...@@ -32,32 +32,34 @@ ...@@ -32,32 +32,34 @@
#ifndef __XFS_SUPPORT_KMEM_H__ #ifndef __XFS_SUPPORT_KMEM_H__
#define __XFS_SUPPORT_KMEM_H__ #define __XFS_SUPPORT_KMEM_H__
#include <linux/mm.h>
#include <linux/highmem.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/vmalloc.h> #include <linux/sched.h>
#include <linux/mm.h>
/*
* Cutoff point to use vmalloc instead of kmalloc.
*/
#define MAX_SLAB_SIZE 0x20000
/* /*
* XFS uses slightly different names for these due to the * memory management routines
* IRIX heritage.
*/ */
#define kmem_zone kmem_cache_s
#define kmem_zone_t kmem_cache_t
#define KM_SLEEP 0x0001 #define KM_SLEEP 0x0001
#define KM_NOSLEEP 0x0002 #define KM_NOSLEEP 0x0002
#define KM_NOFS 0x0004 #define KM_NOFS 0x0004
#define KM_MAYFAIL 0x0005 #define KM_MAYFAIL 0x0008
#define kmem_zone kmem_cache_s
#define kmem_zone_t kmem_cache_t
typedef unsigned long xfs_pflags_t; typedef unsigned long xfs_pflags_t;
#define PFLAGS_TEST_NOIO() (current->flags & PF_NOIO)
#define PFLAGS_TEST_FSTRANS() (current->flags & PF_FSTRANS) #define PFLAGS_TEST_FSTRANS() (current->flags & PF_FSTRANS)
#define PFLAGS_SET_NOIO() do { \
current->flags |= PF_NOIO; \
} while (0)
#define PFLAGS_CLEAR_NOIO() do { \
current->flags &= ~PF_NOIO; \
} while (0)
/* these could be nested, so we save state */ /* these could be nested, so we save state */
#define PFLAGS_SET_FSTRANS(STATEP) do { \ #define PFLAGS_SET_FSTRANS(STATEP) do { \
*(STATEP) = current->flags; \ *(STATEP) = current->flags; \
...@@ -79,12 +81,11 @@ typedef unsigned long xfs_pflags_t; ...@@ -79,12 +81,11 @@ typedef unsigned long xfs_pflags_t;
*(NSTATEP) = *(OSTATEP); \ *(NSTATEP) = *(OSTATEP); \
} while (0) } while (0)
static __inline unsigned int static __inline unsigned int kmem_flags_convert(int flags)
kmem_flags_convert(int flags)
{ {
int lflags; int lflags;
#if DEBUG #ifdef DEBUG
if (unlikely(flags & ~(KM_SLEEP|KM_NOSLEEP|KM_NOFS|KM_MAYFAIL))) { if (unlikely(flags & ~(KM_SLEEP|KM_NOSLEEP|KM_NOFS|KM_MAYFAIL))) {
printk(KERN_WARNING printk(KERN_WARNING
"XFS: memory allocation with wrong flags (%x)\n", flags); "XFS: memory allocation with wrong flags (%x)\n", flags);
...@@ -100,83 +101,44 @@ kmem_flags_convert(int flags) ...@@ -100,83 +101,44 @@ kmem_flags_convert(int flags)
/* avoid recusive callbacks to filesystem during transactions */ /* avoid recusive callbacks to filesystem during transactions */
if (PFLAGS_TEST_FSTRANS() || (flags & KM_NOFS)) if (PFLAGS_TEST_FSTRANS() || (flags & KM_NOFS))
lflags &= ~__GFP_FS; lflags &= ~__GFP_FS;
if (!(flags & KM_MAYFAIL))
lflags |= __GFP_NOFAIL;
} }
return lflags; return lflags;
} }
static __inline void *
kmem_alloc(size_t size, int flags)
{
if (unlikely(MAX_SLAB_SIZE < size))
/* Avoid doing filesystem sensitive stuff to get this */
return __vmalloc(size, kmem_flags_convert(flags), PAGE_KERNEL);
return kmalloc(size, kmem_flags_convert(flags));
}
static __inline void *
kmem_zalloc(size_t size, int flags)
{
void *ptr = kmem_alloc(size, flags);
if (likely(ptr != NULL))
memset(ptr, 0, size);
return ptr;
}
static __inline void
kmem_free(void *ptr, size_t size)
{
if (unlikely((unsigned long)ptr < VMALLOC_START ||
(unsigned long)ptr >= VMALLOC_END))
kfree(ptr);
else
vfree(ptr);
}
static __inline void *
kmem_realloc(void *ptr, size_t newsize, size_t oldsize, int flags)
{
void *new = kmem_alloc(newsize, flags);
if (likely(ptr != NULL)) {
if (likely(new != NULL))
memcpy(new, ptr, min(oldsize, newsize));
kmem_free(ptr, oldsize);
}
return new;
}
static __inline kmem_zone_t * static __inline kmem_zone_t *
kmem_zone_init(int size, char *zone_name) kmem_zone_init(int size, char *zone_name)
{ {
return kmem_cache_create(zone_name, size, 0, 0, NULL, NULL); return kmem_cache_create(zone_name, size, 0, 0, NULL, NULL);
} }
static __inline void * static __inline void
kmem_zone_alloc(kmem_zone_t *zone, int flags) kmem_zone_free(kmem_zone_t *zone, void *ptr)
{ {
return kmem_cache_alloc(zone, kmem_flags_convert(flags)); kmem_cache_free(zone, ptr);
} }
static __inline void * static __inline void
kmem_zone_zalloc(kmem_zone_t *zone, int flags) kmem_zone_destroy(kmem_zone_t *zone)
{ {
void *ptr = kmem_zone_alloc(zone, flags); if (zone && kmem_cache_destroy(zone))
if (likely(ptr != NULL)) BUG();
memset(ptr, 0, kmem_cache_size(zone));
return ptr;
} }
static __inline void static __inline int
kmem_zone_free(kmem_zone_t *zone, void *ptr) kmem_zone_shrink(kmem_zone_t *zone)
{ {
kmem_cache_free(zone, ptr); return kmem_cache_shrink(zone);
} }
extern void *kmem_zone_zalloc(kmem_zone_t *, int);
extern void *kmem_zone_alloc(kmem_zone_t *, int);
extern void *kmem_alloc(size_t, int);
extern void *kmem_realloc(void *, size_t, size_t, int);
extern void *kmem_zalloc(size_t, int);
extern void kmem_free(void *, size_t);
typedef struct shrinker *kmem_shaker_t; typedef struct shrinker *kmem_shaker_t;
typedef int (*kmem_shake_func_t)(int, unsigned int); typedef int (*kmem_shake_func_t)(int, unsigned int);
......
...@@ -172,28 +172,15 @@ xfs_map_blocks( ...@@ -172,28 +172,15 @@ xfs_map_blocks(
struct inode *inode, struct inode *inode,
loff_t offset, loff_t offset,
ssize_t count, ssize_t count,
xfs_iomap_t *iomapp, xfs_iomap_t *mapp,
int flags) int flags)
{ {
vnode_t *vp = LINVFS_GET_VP(inode); vnode_t *vp = LINVFS_GET_VP(inode);
int error, niomaps = 1; int error, nmaps = 1;
if (((flags & (BMAPI_DIRECT|BMAPI_SYNC)) == BMAPI_DIRECT) && VOP_BMAP(vp, offset, count, flags, mapp, &nmaps, error);
(offset >= i_size_read(inode))) if (!error && (flags & (BMAPI_WRITE|BMAPI_ALLOCATE)))
count = max_t(ssize_t, count, XFS_WRITE_IO_LOG);
retry:
VOP_BMAP(vp, offset, count, flags, iomapp, &niomaps, error);
if ((error == EAGAIN) || (error == EIO))
return -error;
if (unlikely((flags & (BMAPI_WRITE|BMAPI_DIRECT)) ==
(BMAPI_WRITE|BMAPI_DIRECT) && niomaps &&
(iomapp->iomap_flags & IOMAP_DELAY))) {
flags = BMAPI_ALLOCATE;
goto retry;
}
if (flags & (BMAPI_WRITE|BMAPI_ALLOCATE)) {
VMODIFY(vp); VMODIFY(vp);
}
return -error; return -error;
} }
...@@ -288,7 +275,7 @@ xfs_probe_unwritten_page( ...@@ -288,7 +275,7 @@ xfs_probe_unwritten_page(
*fsbs = 0; *fsbs = 0;
bh = head = page_buffers(page); bh = head = page_buffers(page);
do { do {
if (!buffer_unwritten(bh)) if (!buffer_unwritten(bh) || !buffer_uptodate(bh))
break; break;
if (!xfs_offset_to_map(page, iomapp, p_offset)) if (!xfs_offset_to_map(page, iomapp, p_offset))
break; break;
...@@ -681,13 +668,12 @@ xfs_cluster_write( ...@@ -681,13 +668,12 @@ xfs_cluster_write(
xfs_iomap_t *iomapp, xfs_iomap_t *iomapp,
struct writeback_control *wbc, struct writeback_control *wbc,
int startio, int startio,
int all_bh) int all_bh,
pgoff_t tlast)
{ {
pgoff_t tlast;
struct page *page; struct page *page;
tlast = (iomapp->iomap_offset + iomapp->iomap_bsize) >> PAGE_CACHE_SHIFT; for (; tindex <= tlast; tindex++) {
for (; tindex < tlast; tindex++) {
page = xfs_probe_delalloc_page(inode, tindex); page = xfs_probe_delalloc_page(inode, tindex);
if (!page) if (!page)
break; break;
...@@ -725,17 +711,20 @@ xfs_page_state_convert( ...@@ -725,17 +711,20 @@ xfs_page_state_convert(
{ {
struct buffer_head *bh_arr[MAX_BUF_PER_PAGE], *bh, *head; struct buffer_head *bh_arr[MAX_BUF_PER_PAGE], *bh, *head;
xfs_iomap_t *iomp, iomap; xfs_iomap_t *iomp, iomap;
unsigned long p_offset = 0;
pgoff_t end_index;
loff_t offset; loff_t offset;
unsigned long long end_offset; unsigned long p_offset = 0;
__uint64_t end_offset;
pgoff_t end_index, last_index, tlast;
int len, err, i, cnt = 0, uptodate = 1; int len, err, i, cnt = 0, uptodate = 1;
int flags = startio ? 0 : BMAPI_TRYLOCK; int flags = startio ? 0 : BMAPI_TRYLOCK;
int page_dirty = 1; int page_dirty = 1;
int delalloc = 0;
/* Are we off the end of the file ? */ /* Are we off the end of the file ? */
end_index = i_size_read(inode) >> PAGE_CACHE_SHIFT; offset = i_size_read(inode);
end_index = offset >> PAGE_CACHE_SHIFT;
last_index = (offset - 1) >> PAGE_CACHE_SHIFT;
if (page->index >= end_index) { if (page->index >= end_index) {
if ((page->index >= end_index + 1) || if ((page->index >= end_index + 1) ||
!(i_size_read(inode) & (PAGE_CACHE_SIZE - 1))) { !(i_size_read(inode) & (PAGE_CACHE_SIZE - 1))) {
...@@ -769,6 +758,8 @@ xfs_page_state_convert( ...@@ -769,6 +758,8 @@ xfs_page_state_convert(
* extent state conversion transaction on completion. * extent state conversion transaction on completion.
*/ */
if (buffer_unwritten(bh)) { if (buffer_unwritten(bh)) {
if (!startio)
continue;
if (!iomp) { if (!iomp) {
err = xfs_map_blocks(inode, offset, len, &iomap, err = xfs_map_blocks(inode, offset, len, &iomap,
BMAPI_READ|BMAPI_IGNSTATE); BMAPI_READ|BMAPI_IGNSTATE);
...@@ -778,7 +769,7 @@ xfs_page_state_convert( ...@@ -778,7 +769,7 @@ xfs_page_state_convert(
iomp = xfs_offset_to_map(page, &iomap, iomp = xfs_offset_to_map(page, &iomap,
p_offset); p_offset);
} }
if (iomp && startio) { if (iomp) {
if (!bh->b_end_io) { if (!bh->b_end_io) {
err = xfs_map_unwritten(inode, page, err = xfs_map_unwritten(inode, page,
head, bh, p_offset, head, bh, p_offset,
...@@ -787,7 +778,10 @@ xfs_page_state_convert( ...@@ -787,7 +778,10 @@ xfs_page_state_convert(
if (err) { if (err) {
goto error; goto error;
} }
} else {
set_bit(BH_Lock, &bh->b_state);
} }
BUG_ON(!buffer_locked(bh));
bh_arr[cnt++] = bh; bh_arr[cnt++] = bh;
page_dirty = 0; page_dirty = 0;
} }
...@@ -797,6 +791,7 @@ xfs_page_state_convert( ...@@ -797,6 +791,7 @@ xfs_page_state_convert(
*/ */
} else if (buffer_delay(bh)) { } else if (buffer_delay(bh)) {
if (!iomp) { if (!iomp) {
delalloc = 1;
err = xfs_map_blocks(inode, offset, len, &iomap, err = xfs_map_blocks(inode, offset, len, &iomap,
BMAPI_ALLOCATE | flags); BMAPI_ALLOCATE | flags);
if (err) { if (err) {
...@@ -871,8 +866,12 @@ xfs_page_state_convert( ...@@ -871,8 +866,12 @@ xfs_page_state_convert(
xfs_submit_page(page, bh_arr, cnt); xfs_submit_page(page, bh_arr, cnt);
if (iomp) { if (iomp) {
tlast = (iomp->iomap_offset + iomp->iomap_bsize - 1) >>
PAGE_CACHE_SHIFT;
if (delalloc && (tlast > last_index))
tlast = last_index;
xfs_cluster_write(inode, page->index + 1, iomp, wbc, xfs_cluster_write(inode, page->index + 1, iomp, wbc,
startio, unmapped); startio, unmapped, tlast);
} }
return page_dirty; return page_dirty;
......
...@@ -65,7 +65,8 @@ ...@@ -65,7 +65,8 @@
*/ */
STATIC kmem_cache_t *pagebuf_cache; STATIC kmem_cache_t *pagebuf_cache;
STATIC void pagebuf_daemon_wakeup(void); STATIC kmem_shaker_t pagebuf_shake;
STATIC int pagebuf_daemon_wakeup(int, unsigned int);
STATIC void pagebuf_delwri_queue(xfs_buf_t *, int); STATIC void pagebuf_delwri_queue(xfs_buf_t *, int);
STATIC struct workqueue_struct *pagebuf_logio_workqueue; STATIC struct workqueue_struct *pagebuf_logio_workqueue;
STATIC struct workqueue_struct *pagebuf_dataio_workqueue; STATIC struct workqueue_struct *pagebuf_dataio_workqueue;
...@@ -384,13 +385,13 @@ _pagebuf_lookup_pages( ...@@ -384,13 +385,13 @@ _pagebuf_lookup_pages(
* But until all the XFS lowlevel code is revamped to * But until all the XFS lowlevel code is revamped to
* handle buffer allocation failures we can't do much. * handle buffer allocation failures we can't do much.
*/ */
if (!(++retries % 100)) { if (!(++retries % 100))
printk(KERN_ERR "possibly deadlocking in %s\n", printk(KERN_ERR
__FUNCTION__); "possible deadlock in %s (mode:0x%x)\n",
} __FUNCTION__, gfp_mask);
XFS_STATS_INC(pb_page_retries); XFS_STATS_INC(pb_page_retries);
pagebuf_daemon_wakeup(); pagebuf_daemon_wakeup(0, gfp_mask);
set_current_state(TASK_UNINTERRUPTIBLE); set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout(10); schedule_timeout(10);
goto retry; goto retry;
...@@ -1566,11 +1567,20 @@ void ...@@ -1566,11 +1567,20 @@ void
pagebuf_delwri_dequeue( pagebuf_delwri_dequeue(
xfs_buf_t *pb) xfs_buf_t *pb)
{ {
PB_TRACE(pb, "delwri_uq", 0); int dequeued = 0;
spin_lock(&pbd_delwrite_lock); spin_lock(&pbd_delwrite_lock);
if ((pb->pb_flags & PBF_DELWRI) && !list_empty(&pb->pb_list)) {
list_del_init(&pb->pb_list); list_del_init(&pb->pb_list);
dequeued = 1;
}
pb->pb_flags &= ~PBF_DELWRI; pb->pb_flags &= ~PBF_DELWRI;
spin_unlock(&pbd_delwrite_lock); spin_unlock(&pbd_delwrite_lock);
if (dequeued)
pagebuf_rele(pb);
PB_TRACE(pb, "delwri_dq", (long)dequeued);
} }
STATIC void STATIC void
...@@ -1586,12 +1596,16 @@ STATIC struct task_struct *pagebuf_daemon_task; ...@@ -1586,12 +1596,16 @@ STATIC struct task_struct *pagebuf_daemon_task;
STATIC int pagebuf_daemon_active; STATIC int pagebuf_daemon_active;
STATIC int force_flush; STATIC int force_flush;
STATIC void
pagebuf_daemon_wakeup(void) STATIC int
pagebuf_daemon_wakeup(
int priority,
unsigned int mask)
{ {
force_flush = 1; force_flush = 1;
barrier(); barrier();
wake_up_process(pagebuf_daemon_task); wake_up_process(pagebuf_daemon_task);
return 0;
} }
STATIC int STATIC int
...@@ -1775,21 +1789,28 @@ pagebuf_init(void) ...@@ -1775,21 +1789,28 @@ pagebuf_init(void)
pagebuf_cache = kmem_cache_create("xfs_buf_t", sizeof(xfs_buf_t), 0, pagebuf_cache = kmem_cache_create("xfs_buf_t", sizeof(xfs_buf_t), 0,
SLAB_HWCACHE_ALIGN, NULL, NULL); SLAB_HWCACHE_ALIGN, NULL, NULL);
if (pagebuf_cache == NULL) { if (pagebuf_cache == NULL) {
printk("pagebuf: couldn't init pagebuf cache\n"); printk("XFS: couldn't init xfs_buf_t cache\n");
pagebuf_terminate(); pagebuf_terminate();
return -ENOMEM; return -ENOMEM;
} }
for (i = 0; i < NHASH; i++) {
spin_lock_init(&pbhash[i].pb_hash_lock);
INIT_LIST_HEAD(&pbhash[i].pb_hash);
}
#ifdef PAGEBUF_TRACE #ifdef PAGEBUF_TRACE
pagebuf_trace_buf = ktrace_alloc(PAGEBUF_TRACE_SIZE, KM_SLEEP); pagebuf_trace_buf = ktrace_alloc(PAGEBUF_TRACE_SIZE, KM_SLEEP);
#endif #endif
pagebuf_daemon_start(); pagebuf_daemon_start();
pagebuf_shake = kmem_shake_register(pagebuf_daemon_wakeup);
if (pagebuf_shake == NULL) {
pagebuf_terminate();
return -ENOMEM;
}
for (i = 0; i < NHASH; i++) {
spin_lock_init(&pbhash[i].pb_hash_lock);
INIT_LIST_HEAD(&pbhash[i].pb_hash);
}
return 0; return 0;
} }
...@@ -1808,5 +1829,6 @@ pagebuf_terminate(void) ...@@ -1808,5 +1829,6 @@ pagebuf_terminate(void)
ktrace_free(pagebuf_trace_buf); ktrace_free(pagebuf_trace_buf);
#endif #endif
kmem_cache_destroy(pagebuf_cache); kmem_zone_destroy(pagebuf_cache);
kmem_shake_deregister(pagebuf_shake);
} }
...@@ -347,27 +347,15 @@ extern void pagebuf_trace( ...@@ -347,27 +347,15 @@ extern void pagebuf_trace(
#define XFS_BUF_ISSTALE(x) ((x)->pb_flags & XFS_B_STALE) #define XFS_BUF_ISSTALE(x) ((x)->pb_flags & XFS_B_STALE)
#define XFS_BUF_SUPER_STALE(x) do { \ #define XFS_BUF_SUPER_STALE(x) do { \
XFS_BUF_STALE(x); \ XFS_BUF_STALE(x); \
xfs_buf_undelay(x); \ pagebuf_delwri_dequeue(x); \
XFS_BUF_DONE(x); \ XFS_BUF_DONE(x); \
} while (0) } while (0)
#define XFS_BUF_MANAGE PBF_FS_MANAGED #define XFS_BUF_MANAGE PBF_FS_MANAGED
#define XFS_BUF_UNMANAGE(x) ((x)->pb_flags &= ~PBF_FS_MANAGED) #define XFS_BUF_UNMANAGE(x) ((x)->pb_flags &= ~PBF_FS_MANAGED)
static inline void xfs_buf_undelay(xfs_buf_t *pb)
{
if (pb->pb_flags & PBF_DELWRI) {
if (pb->pb_list.next != &pb->pb_list) {
pagebuf_delwri_dequeue(pb);
pagebuf_rele(pb);
} else {
pb->pb_flags &= ~PBF_DELWRI;
}
}
}
#define XFS_BUF_DELAYWRITE(x) ((x)->pb_flags |= PBF_DELWRI) #define XFS_BUF_DELAYWRITE(x) ((x)->pb_flags |= PBF_DELWRI)
#define XFS_BUF_UNDELAYWRITE(x) xfs_buf_undelay(x) #define XFS_BUF_UNDELAYWRITE(x) pagebuf_delwri_dequeue(x)
#define XFS_BUF_ISDELAYWRITE(x) ((x)->pb_flags & PBF_DELWRI) #define XFS_BUF_ISDELAYWRITE(x) ((x)->pb_flags & PBF_DELWRI)
#define XFS_BUF_ERROR(x,no) pagebuf_ioerror(x,no) #define XFS_BUF_ERROR(x,no) pagebuf_ioerror(x,no)
...@@ -500,7 +488,7 @@ static inline int xfs_bawrite(void *mp, xfs_buf_t *bp) ...@@ -500,7 +488,7 @@ static inline int xfs_bawrite(void *mp, xfs_buf_t *bp)
{ {
bp->pb_fspriv3 = mp; bp->pb_fspriv3 = mp;
bp->pb_strat = xfs_bdstrat_cb; bp->pb_strat = xfs_bdstrat_cb;
xfs_buf_undelay(bp); pagebuf_delwri_dequeue(bp);
return pagebuf_iostart(bp, PBF_WRITE | PBF_ASYNC | _PBF_RUN_QUEUES); return pagebuf_iostart(bp, PBF_WRITE | PBF_ASYNC | _PBF_RUN_QUEUES);
} }
...@@ -540,7 +528,7 @@ static inline int XFS_bwrite(xfs_buf_t *pb) ...@@ -540,7 +528,7 @@ static inline int XFS_bwrite(xfs_buf_t *pb)
if (!iowait) if (!iowait)
pb->pb_flags |= _PBF_RUN_QUEUES; pb->pb_flags |= _PBF_RUN_QUEUES;
xfs_buf_undelay(pb); pagebuf_delwri_dequeue(pb);
pagebuf_iostrategy(pb); pagebuf_iostrategy(pb);
if (iowait) { if (iowait) {
error = pagebuf_iowait(pb); error = pagebuf_iowait(pb);
......
/* /*
* Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as * under the terms of version 2 of the GNU General Public License as
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
#include "xfs_rw.h" #include "xfs_rw.h"
#include <linux/dcache.h> #include <linux/dcache.h>
#include <linux/smp_lock.h>
static struct vm_operations_struct linvfs_file_vm_ops; static struct vm_operations_struct linvfs_file_vm_ops;
...@@ -440,9 +441,10 @@ linvfs_ioctl( ...@@ -440,9 +441,10 @@ linvfs_ioctl(
int error; int error;
vnode_t *vp = LINVFS_GET_VP(inode); vnode_t *vp = LINVFS_GET_VP(inode);
ASSERT(vp); unlock_kernel();
VOP_IOCTL(vp, inode, filp, 0, cmd, arg, error); VOP_IOCTL(vp, inode, filp, 0, cmd, arg, error);
VMODIFY(vp); VMODIFY(vp);
lock_kernel();
/* NOTE: some of the ioctl's return positive #'s as a /* NOTE: some of the ioctl's return positive #'s as a
* byte count indicating success, such as * byte count indicating success, such as
...@@ -463,9 +465,11 @@ linvfs_ioctl_invis( ...@@ -463,9 +465,11 @@ linvfs_ioctl_invis(
int error; int error;
vnode_t *vp = LINVFS_GET_VP(inode); vnode_t *vp = LINVFS_GET_VP(inode);
unlock_kernel();
ASSERT(vp); ASSERT(vp);
VOP_IOCTL(vp, inode, filp, IO_INVIS, cmd, arg, error); VOP_IOCTL(vp, inode, filp, IO_INVIS, cmd, arg, error);
VMODIFY(vp); VMODIFY(vp);
lock_kernel();
/* NOTE: some of the ioctl's return positive #'s as a /* NOTE: some of the ioctl's return positive #'s as a
* byte count indicating success, such as * byte count indicating success, such as
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
* Stub for no-op vnode operations that return error status. * Stub for no-op vnode operations that return error status.
*/ */
int int
fs_noerr() fs_noerr(void)
{ {
return 0; return 0;
} }
...@@ -45,7 +45,7 @@ fs_noerr() ...@@ -45,7 +45,7 @@ fs_noerr()
* Operation unsupported under this file system. * Operation unsupported under this file system.
*/ */
int int
fs_nosys() fs_nosys(void)
{ {
return ENOSYS; return ENOSYS;
} }
...@@ -55,7 +55,7 @@ fs_nosys() ...@@ -55,7 +55,7 @@ fs_nosys()
*/ */
/* ARGSUSED */ /* ARGSUSED */
void void
fs_noval() fs_noval(void)
{ {
} }
......
...@@ -76,7 +76,8 @@ ...@@ -76,7 +76,8 @@
STATIC struct quotactl_ops linvfs_qops; STATIC struct quotactl_ops linvfs_qops;
STATIC struct super_operations linvfs_sops; STATIC struct super_operations linvfs_sops;
STATIC struct export_operations linvfs_export_ops; STATIC struct export_operations linvfs_export_ops;
STATIC kmem_cache_t * linvfs_inode_cachep; STATIC kmem_zone_t *linvfs_inode_zone;
STATIC kmem_shaker_t xfs_inode_shaker;
STATIC struct xfs_mount_args * STATIC struct xfs_mount_args *
xfs_args_allocate( xfs_args_allocate(
...@@ -289,7 +290,7 @@ linvfs_alloc_inode( ...@@ -289,7 +290,7 @@ linvfs_alloc_inode(
{ {
vnode_t *vp; vnode_t *vp;
vp = (vnode_t *)kmem_cache_alloc(linvfs_inode_cachep, vp = (vnode_t *)kmem_cache_alloc(linvfs_inode_zone,
kmem_flags_convert(KM_SLEEP)); kmem_flags_convert(KM_SLEEP));
if (!vp) if (!vp)
return NULL; return NULL;
...@@ -300,7 +301,20 @@ STATIC void ...@@ -300,7 +301,20 @@ STATIC void
linvfs_destroy_inode( linvfs_destroy_inode(
struct inode *inode) struct inode *inode)
{ {
kmem_cache_free(linvfs_inode_cachep, LINVFS_GET_VP(inode)); kmem_cache_free(linvfs_inode_zone, LINVFS_GET_VP(inode));
}
int
xfs_inode_shake(
int priority,
unsigned int gfp_mask)
{
int pages;
pages = kmem_zone_shrink(linvfs_inode_zone);
pages += kmem_zone_shrink(xfs_inode_zone);
return pages;
} }
STATIC void STATIC void
...@@ -319,12 +333,12 @@ init_once( ...@@ -319,12 +333,12 @@ init_once(
STATIC int STATIC int
init_inodecache( void ) init_inodecache( void )
{ {
linvfs_inode_cachep = kmem_cache_create("linvfs_icache", linvfs_inode_zone = kmem_cache_create("linvfs_icache",
sizeof(vnode_t), 0, sizeof(vnode_t), 0,
SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT, SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT,
init_once, NULL); init_once, NULL);
if (linvfs_inode_cachep == NULL) if (linvfs_inode_zone == NULL)
return -ENOMEM; return -ENOMEM;
return 0; return 0;
} }
...@@ -332,7 +346,7 @@ init_inodecache( void ) ...@@ -332,7 +346,7 @@ init_inodecache( void )
STATIC void STATIC void
destroy_inodecache( void ) destroy_inodecache( void )
{ {
if (kmem_cache_destroy(linvfs_inode_cachep)) if (kmem_cache_destroy(linvfs_inode_zone))
printk(KERN_WARNING "%s: cache still in use!\n", __FUNCTION__); printk(KERN_WARNING "%s: cache still in use!\n", __FUNCTION__);
} }
...@@ -835,15 +849,24 @@ init_xfs_fs( void ) ...@@ -835,15 +849,24 @@ init_xfs_fs( void )
vn_init(); vn_init();
xfs_init(); xfs_init();
uuid_init(); uuid_init();
vfs_initdmapi();
vfs_initquota(); vfs_initquota();
xfs_inode_shaker = kmem_shake_register(xfs_inode_shake);
if (!xfs_inode_shaker) {
error = -ENOMEM;
goto undo_shaker;
}
error = register_filesystem(&xfs_fs_type); error = register_filesystem(&xfs_fs_type);
if (error) if (error)
goto undo_register; goto undo_register;
XFS_DM_INIT(&xfs_fs_type);
return 0; return 0;
undo_register: undo_register:
kmem_shake_deregister(xfs_inode_shaker);
undo_shaker:
pagebuf_terminate(); pagebuf_terminate();
undo_pagebuf: undo_pagebuf:
...@@ -857,8 +880,9 @@ STATIC void __exit ...@@ -857,8 +880,9 @@ STATIC void __exit
exit_xfs_fs( void ) exit_xfs_fs( void )
{ {
vfs_exitquota(); vfs_exitquota();
vfs_exitdmapi(); XFS_DM_EXIT(&xfs_fs_type);
unregister_filesystem(&xfs_fs_type); unregister_filesystem(&xfs_fs_type);
kmem_shake_deregister(xfs_inode_shaker);
xfs_cleanup(); xfs_cleanup();
pagebuf_terminate(); pagebuf_terminate();
destroy_inodecache(); destroy_inodecache();
......
/* /*
* Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as * under the terms of version 2 of the GNU General Public License as
...@@ -92,6 +92,12 @@ extern void xfs_qm_exit(void); ...@@ -92,6 +92,12 @@ extern void xfs_qm_exit(void);
# define XFS_TRACE_STRING # define XFS_TRACE_STRING
#endif #endif
#ifdef CONFIG_XFS_DMAPI
# define XFS_DMAPI_STRING "dmapi support, "
#else
# define XFS_DMAPI_STRING
#endif
#ifdef DEBUG #ifdef DEBUG
# define XFS_DBG_STRING "debug" # define XFS_DBG_STRING "debug"
#else #else
...@@ -103,6 +109,7 @@ extern void xfs_qm_exit(void); ...@@ -103,6 +109,7 @@ extern void xfs_qm_exit(void);
XFS_REALTIME_STRING \ XFS_REALTIME_STRING \
XFS_BIGFS_STRING \ XFS_BIGFS_STRING \
XFS_TRACE_STRING \ XFS_TRACE_STRING \
XFS_DMAPI_STRING \
XFS_DBG_STRING /* DBG must be last */ XFS_DBG_STRING /* DBG must be last */
#define LINVFS_GET_VFS(s) \ #define LINVFS_GET_VFS(s) \
......
...@@ -35,5 +35,6 @@ ...@@ -35,5 +35,6 @@
#include <linux-2.6/xfs_linux.h> #include <linux-2.6/xfs_linux.h>
#include <xfs_fs.h> #include <xfs_fs.h>
#include <xfs_macros.h>
#endif /* __XFS_H__ */ #endif /* __XFS_H__ */
...@@ -231,8 +231,6 @@ xfs_acl_vget( ...@@ -231,8 +231,6 @@ xfs_acl_vget(
int flags = 0; int flags = 0;
VN_HOLD(vp); VN_HOLD(vp);
if ((error = _MAC_VACCESS(vp, NULL, VREAD)))
goto out;
if(size) { if(size) {
if (!(_ACL_ALLOC(xfs_acl))) { if (!(_ACL_ALLOC(xfs_acl))) {
error = ENOMEM; error = ENOMEM;
...@@ -395,8 +393,6 @@ xfs_acl_allow_set( ...@@ -395,8 +393,6 @@ xfs_acl_allow_set(
return ENOTDIR; return ENOTDIR;
if (vp->v_vfsp->vfs_flag & VFS_RDONLY) if (vp->v_vfsp->vfs_flag & VFS_RDONLY)
return EROFS; return EROFS;
if ((error = _MAC_VACCESS(vp, NULL, VWRITE)))
return error;
va.va_mask = XFS_AT_UID; va.va_mask = XFS_AT_UID;
VOP_GETATTR(vp, &va, 0, NULL, error); VOP_GETATTR(vp, &va, 0, NULL, error);
if (error) if (error)
......
/* /*
* Copyright (c) 2001-2003 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2001-2004 Silicon Graphics, Inc. All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as * under the terms of version 2 of the GNU General Public License as
...@@ -61,14 +61,17 @@ typedef struct xfs_acl { ...@@ -61,14 +61,17 @@ typedef struct xfs_acl {
#define SGI_ACL_DEFAULT_SIZE (sizeof(SGI_ACL_DEFAULT)-1) #define SGI_ACL_DEFAULT_SIZE (sizeof(SGI_ACL_DEFAULT)-1)
#ifdef __KERNEL__
#ifdef CONFIG_XFS_POSIX_ACL #ifdef CONFIG_XFS_POSIX_ACL
struct vattr; struct vattr;
struct vnode; struct vnode;
struct xfs_inode; struct xfs_inode;
extern struct kmem_zone *xfs_acl_zone;
#define xfs_acl_zone_init(zone, name) \
(zone) = kmem_zone_init(sizeof(xfs_acl_t), name)
#define xfs_acl_zone_destroy(zone) kmem_cache_destroy(zone)
extern int xfs_acl_inherit(struct vnode *, struct vattr *, xfs_acl_t *); extern int xfs_acl_inherit(struct vnode *, struct vattr *, xfs_acl_t *);
extern int xfs_acl_iaccess(struct xfs_inode *, mode_t, cred_t *); extern int xfs_acl_iaccess(struct xfs_inode *, mode_t, cred_t *);
extern int xfs_acl_get(struct vnode *, xfs_acl_t *, xfs_acl_t *); extern int xfs_acl_get(struct vnode *, xfs_acl_t *, xfs_acl_t *);
...@@ -80,17 +83,10 @@ extern int xfs_acl_vset(struct vnode *, void *, size_t, int); ...@@ -80,17 +83,10 @@ extern int xfs_acl_vset(struct vnode *, void *, size_t, int);
extern int xfs_acl_vget(struct vnode *, void *, size_t, int); extern int xfs_acl_vget(struct vnode *, void *, size_t, int);
extern int xfs_acl_vremove(struct vnode *vp, int); extern int xfs_acl_vremove(struct vnode *vp, int);
extern struct kmem_zone *xfs_acl_zone;
#define _ACL_TYPE_ACCESS 1 #define _ACL_TYPE_ACCESS 1
#define _ACL_TYPE_DEFAULT 2 #define _ACL_TYPE_DEFAULT 2
#define _ACL_PERM_INVALID(perm) ((perm) & ~(ACL_READ|ACL_WRITE|ACL_EXECUTE)) #define _ACL_PERM_INVALID(perm) ((perm) & ~(ACL_READ|ACL_WRITE|ACL_EXECUTE))
#define _ACL_DECL(a) xfs_acl_t *(a) = NULL
#define _ACL_ALLOC(a) ((a) = kmem_zone_alloc(xfs_acl_zone, KM_SLEEP))
#define _ACL_FREE(a) ((a)? kmem_zone_free(xfs_acl_zone, (a)) : 0)
#define _ACL_ZONE_INIT(z,name) ((z) = kmem_zone_init(sizeof(xfs_acl_t), name))
#define _ACL_ZONE_DESTROY(z) (kmem_cache_destroy(z))
#define _ACL_INHERIT(c,v,d) (xfs_acl_inherit(c,v,d)) #define _ACL_INHERIT(c,v,d) (xfs_acl_inherit(c,v,d))
#define _ACL_GET_ACCESS(pv,pa) (xfs_acl_vtoacl(pv,pa,NULL) == 0) #define _ACL_GET_ACCESS(pv,pa) (xfs_acl_vtoacl(pv,pa,NULL) == 0)
#define _ACL_GET_DEFAULT(pv,pd) (xfs_acl_vtoacl(pv,NULL,pd) == 0) #define _ACL_GET_DEFAULT(pv,pd) (xfs_acl_vtoacl(pv,NULL,pd) == 0)
...@@ -98,17 +94,19 @@ extern struct kmem_zone *xfs_acl_zone; ...@@ -98,17 +94,19 @@ extern struct kmem_zone *xfs_acl_zone;
#define _ACL_DEFAULT_EXISTS xfs_acl_vhasacl_default #define _ACL_DEFAULT_EXISTS xfs_acl_vhasacl_default
#define _ACL_XFS_IACCESS(i,m,c) (XFS_IFORK_Q(i) ? xfs_acl_iaccess(i,m,c) : -1) #define _ACL_XFS_IACCESS(i,m,c) (XFS_IFORK_Q(i) ? xfs_acl_iaccess(i,m,c) : -1)
#define _ACL_ALLOC(a) ((a) = kmem_zone_alloc(xfs_acl_zone, KM_SLEEP))
#define _ACL_FREE(a) ((a)? kmem_zone_free(xfs_acl_zone, (a)) : 0)
#else #else
#define xfs_acl_zone_init(zone,name)
#define xfs_acl_zone_destroy(zone)
#define xfs_acl_vset(v,p,sz,t) (-EOPNOTSUPP) #define xfs_acl_vset(v,p,sz,t) (-EOPNOTSUPP)
#define xfs_acl_vget(v,p,sz,t) (-EOPNOTSUPP) #define xfs_acl_vget(v,p,sz,t) (-EOPNOTSUPP)
#define xfs_acl_vremove(v,t) (-EOPNOTSUPP) #define xfs_acl_vremove(v,t) (-EOPNOTSUPP)
#define xfs_acl_vhasacl_access(v) (0) #define xfs_acl_vhasacl_access(v) (0)
#define xfs_acl_vhasacl_default(v) (0) #define xfs_acl_vhasacl_default(v) (0)
#define _ACL_DECL(a) ((void)0)
#define _ACL_ALLOC(a) (1) /* successfully allocate nothing */ #define _ACL_ALLOC(a) (1) /* successfully allocate nothing */
#define _ACL_FREE(a) ((void)0) #define _ACL_FREE(a) ((void)0)
#define _ACL_ZONE_INIT(z,name) ((void)0)
#define _ACL_ZONE_DESTROY(z) ((void)0)
#define _ACL_INHERIT(c,v,d) (0) #define _ACL_INHERIT(c,v,d) (0)
#define _ACL_GET_ACCESS(pv,pa) (0) #define _ACL_GET_ACCESS(pv,pa) (0)
#define _ACL_GET_DEFAULT(pv,pd) (0) #define _ACL_GET_DEFAULT(pv,pd) (0)
...@@ -117,6 +115,4 @@ extern struct kmem_zone *xfs_acl_zone; ...@@ -117,6 +115,4 @@ extern struct kmem_zone *xfs_acl_zone;
#define _ACL_XFS_IACCESS(i,m,c) (-1) #define _ACL_XFS_IACCESS(i,m,c) (-1)
#endif #endif
#endif /* __KERNEL__ */
#endif /* __XFS_ACL_H__ */ #endif /* __XFS_ACL_H__ */
...@@ -157,11 +157,11 @@ ...@@ -157,11 +157,11 @@
/* does not return a value */ /* does not return a value */
#define INT_MOD_EXPR(reference,arch,code) \ #define INT_MOD_EXPR(reference,arch,code) \
(void)(((arch) == ARCH_NOCONVERT) \ (((arch) == ARCH_NOCONVERT) \
? \ ? \
((reference) code) \ (void)((reference) code) \
: \ : \
( \ (void)( \
(reference) = INT_GET((reference),arch) , \ (reference) = INT_GET((reference),arch) , \
((reference) code), \ ((reference) code), \
INT_SET(reference, arch, reference) \ INT_SET(reference, arch, reference) \
...@@ -187,10 +187,10 @@ ...@@ -187,10 +187,10 @@
/* does not return a value */ /* does not return a value */
#define INT_COPY(dst,src,arch) \ #define INT_COPY(dst,src,arch) \
(void)( \ ( \
((sizeof(dst) == sizeof(src)) || ((arch) == ARCH_NOCONVERT)) \ ((sizeof(dst) == sizeof(src)) || ((arch) == ARCH_NOCONVERT)) \
? \ ? \
((dst) = (src)) \ (void)((dst) = (src)) \
: \ : \
INT_SET(dst, arch, INT_GET(src, arch)) \ INT_SET(dst, arch, INT_GET(src, arch)) \
) )
......
/* /*
* Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as * under the terms of version 2 of the GNU General Public License as
...@@ -2149,8 +2149,8 @@ xfs_attr_rmtval_remove(xfs_da_args_t *args) ...@@ -2149,8 +2149,8 @@ xfs_attr_rmtval_remove(xfs_da_args_t *args)
/* /*
* If the "remote" value is in the cache, remove it. * If the "remote" value is in the cache, remove it.
*/ */
/* bp = incore(mp->m_dev, dblkno, blkcnt, 1); */ bp = xfs_incore(mp->m_ddev_targp, dblkno, blkcnt,
bp = xfs_incore(mp->m_ddev_targp, dblkno, blkcnt, 1); XFS_INCORE_TRYLOCK);
if (bp) { if (bp) {
XFS_BUF_STALE(bp); XFS_BUF_STALE(bp);
XFS_BUF_UNDELAYWRITE(bp); XFS_BUF_UNDELAYWRITE(bp);
......
/* /*
* Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as * under the terms of version 2 of the GNU General Public License as
...@@ -154,14 +154,17 @@ int ...@@ -154,14 +154,17 @@ int
xfs_lowbit64( xfs_lowbit64(
__uint64_t v) __uint64_t v)
{ {
int n; __uint32_t w = (__uint32_t)v;
n = ffs((unsigned)v); int n = 0;
if (n <= 0) {
n = ffs(v >> 32); if (w) { /* lower bits */
if (n >= 0) n = ffs(w);
n+=32; } else { /* upper bits */
w = (__uint32_t)(v >> 32);
if (w && (n = ffs(w)))
n += 32;
} }
return (n <= 0) ? n : n-1; return n - 1;
} }
/* /*
...@@ -171,10 +174,11 @@ int ...@@ -171,10 +174,11 @@ int
xfs_highbit64( xfs_highbit64(
__uint64_t v) __uint64_t v)
{ {
__uint32_t h = v >> 32; __uint32_t h = (__uint32_t)(v >> 32);
if (h) if (h)
return xfs_highbit32(h) + 32; return xfs_highbit32(h) + 32;
return xfs_highbit32((__u32)v); return xfs_highbit32((__uint32_t)v);
} }
......
/* /*
* Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as * under the terms of version 2 of the GNU General Public License as
...@@ -199,7 +199,14 @@ typedef enum { ...@@ -199,7 +199,14 @@ typedef enum {
extern struct bhv_vfsops xfs_dmops; extern struct bhv_vfsops xfs_dmops;
extern int dmapi_init(void); #ifdef CONFIG_XFS_DMAPI
extern void dmapi_uninit(void); void xfs_dm_init(struct file_system_type *);
void xfs_dm_exit(struct file_system_type *);
#define XFS_DM_INIT(fstype) xfs_dm_init(fstype)
#define XFS_DM_EXIT(fstype) xfs_dm_exit(fstype)
#else
#define XFS_DM_INIT(fstype)
#define XFS_DM_EXIT(fstype)
#endif
#endif /* __XFS_DMAPI_H__ */ #endif /* __XFS_DMAPI_H__ */
...@@ -1140,8 +1140,7 @@ xfs_ialloc( ...@@ -1140,8 +1140,7 @@ xfs_ialloc(
* Call the space management code to pick * Call the space management code to pick
* the on-disk inode to be allocated. * the on-disk inode to be allocated.
*/ */
ASSERT(pip != NULL); error = xfs_dialloc(tp, pip->i_ino, mode, okalloc,
error = xfs_dialloc(tp, pip ? pip->i_ino : 0, mode, okalloc,
ialloc_context, call_again, &ino); ialloc_context, call_again, &ino);
if (error != 0) { if (error != 0) {
return error; return error;
...@@ -3696,12 +3695,6 @@ xfs_iaccess( ...@@ -3696,12 +3695,6 @@ xfs_iaccess(
mode_t orgmode = mode; mode_t orgmode = mode;
struct inode *inode = LINVFS_GET_IP(XFS_ITOV(ip)); struct inode *inode = LINVFS_GET_IP(XFS_ITOV(ip));
/*
* Verify that the MAC policy allows the requested access.
*/
if ((error = _MAC_XFS_IACCESS(ip, mode, cr)))
return XFS_ERROR(error);
if (mode & S_IWUSR) { if (mode & S_IWUSR) {
umode_t imode = inode->i_mode; umode_t imode = inode->i_mode;
......
...@@ -459,8 +459,8 @@ xfs_inode_t *xfs_bhvtoi(struct bhv_desc *bhvp); ...@@ -459,8 +459,8 @@ xfs_inode_t *xfs_bhvtoi(struct bhv_desc *bhvp);
* directory, group of new file is set to that of the parent, and * directory, group of new file is set to that of the parent, and
* new subdirectory gets S_ISGID bit from parent. * new subdirectory gets S_ISGID bit from parent.
*/ */
#define XFS_INHERIT_GID(pip, vfsp) ((pip) != NULL && \ #define XFS_INHERIT_GID(pip, vfsp) \
(((vfsp)->vfs_flag & VFS_GRPID) || ((pip)->i_d.di_mode & S_ISGID))) (((vfsp)->vfs_flag & VFS_GRPID) || ((pip)->i_d.di_mode & S_ISGID))
/* /*
* xfs_iget.c prototypes. * xfs_iget.c prototypes.
......
/* /*
* Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as * under the terms of version 2 of the GNU General Public License as
...@@ -424,10 +424,6 @@ typedef struct xfs_mount { ...@@ -424,10 +424,6 @@ typedef struct xfs_mount {
*/ */
#define XFS_READIO_LOG_LARGE 16 #define XFS_READIO_LOG_LARGE 16
#define XFS_WRITEIO_LOG_LARGE 16 #define XFS_WRITEIO_LOG_LARGE 16
/*
* Default allocation size
*/
#define XFS_WRITE_IO_LOG 16
/* /*
* Max and min values for UIO and mount-option defined I/O sizes; * Max and min values for UIO and mount-option defined I/O sizes;
......
/* /*
* Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as * under the terms of version 2 of the GNU General Public License as
...@@ -100,7 +100,9 @@ STATIC int ...@@ -100,7 +100,9 @@ STATIC int
xfs_lowbit32( xfs_lowbit32(
__uint32_t v) __uint32_t v)
{ {
return ffs(v)-1; if (v)
return ffs(v) - 1;
return -1;
} }
/* /*
......
...@@ -118,7 +118,7 @@ xfs_init(void) ...@@ -118,7 +118,7 @@ xfs_init(void)
xfs_ili_zone = kmem_zone_init(sizeof(xfs_inode_log_item_t), "xfs_ili"); xfs_ili_zone = kmem_zone_init(sizeof(xfs_inode_log_item_t), "xfs_ili");
xfs_chashlist_zone = kmem_zone_init(sizeof(xfs_chashlist_t), xfs_chashlist_zone = kmem_zone_init(sizeof(xfs_chashlist_t),
"xfs_chashlist"); "xfs_chashlist");
_ACL_ZONE_INIT(xfs_acl_zone, "xfs_acl"); xfs_acl_zone_init(xfs_acl_zone, "xfs_acl");
/* /*
* Allocate global trace buffers. * Allocate global trace buffers.
...@@ -170,6 +170,7 @@ xfs_cleanup(void) ...@@ -170,6 +170,7 @@ xfs_cleanup(void)
xfs_cleanup_procfs(); xfs_cleanup_procfs();
xfs_sysctl_unregister(); xfs_sysctl_unregister();
xfs_refcache_destroy(); xfs_refcache_destroy();
xfs_acl_zone_destroy(xfs_acl_zone);
#ifdef XFS_DIR2_TRACE #ifdef XFS_DIR2_TRACE
ktrace_free(xfs_dir2_trace_buf); ktrace_free(xfs_dir2_trace_buf);
...@@ -202,7 +203,6 @@ xfs_cleanup(void) ...@@ -202,7 +203,6 @@ xfs_cleanup(void)
kmem_cache_destroy(xfs_ifork_zone); kmem_cache_destroy(xfs_ifork_zone);
kmem_cache_destroy(xfs_ili_zone); kmem_cache_destroy(xfs_ili_zone);
kmem_cache_destroy(xfs_chashlist_zone); kmem_cache_destroy(xfs_chashlist_zone);
_ACL_ZONE_DESTROY(xfs_acl_zone);
} }
/* /*
......
...@@ -411,11 +411,6 @@ xfs_setattr( ...@@ -411,11 +411,6 @@ xfs_setattr(
xfs_ilock(ip, lock_flags); xfs_ilock(ip, lock_flags);
if (_MAC_XFS_IACCESS(ip, MACWRITE, credp)) {
code = XFS_ERROR(EACCES);
goto error_return;
}
/* boolean: are we the file owner? */ /* boolean: are we the file owner? */
file_owner = (current_fsuid(credp) == ip->i_d.di_uid); file_owner = (current_fsuid(credp) == ip->i_d.di_uid);
...@@ -2446,11 +2441,6 @@ xfs_remove( ...@@ -2446,11 +2441,6 @@ xfs_remove(
xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
} }
if ((error = _MAC_XFS_IACCESS(ip, MACWRITE, credp))) {
REMOVE_DEBUG_TRACE(__LINE__);
goto error_return;
}
/* /*
* Entry must exist since we did a lookup in xfs_lock_dir_and_entry. * Entry must exist since we did a lookup in xfs_lock_dir_and_entry.
*/ */
...@@ -2536,8 +2526,6 @@ xfs_remove( ...@@ -2536,8 +2526,6 @@ xfs_remove(
error1: error1:
xfs_bmap_cancel(&free_list); xfs_bmap_cancel(&free_list);
cancel_flags |= XFS_TRANS_ABORT; cancel_flags |= XFS_TRANS_ABORT;
error_return:
xfs_trans_cancel(tp, cancel_flags); xfs_trans_cancel(tp, cancel_flags);
goto std_return; goto std_return;
...@@ -3105,10 +3093,6 @@ xfs_rmdir( ...@@ -3105,10 +3093,6 @@ xfs_rmdir(
ITRACE(cdp); ITRACE(cdp);
xfs_trans_ijoin(tp, cdp, XFS_ILOCK_EXCL); xfs_trans_ijoin(tp, cdp, XFS_ILOCK_EXCL);
if ((error = _MAC_XFS_IACCESS(cdp, MACWRITE, credp))) {
goto error_return;
}
ASSERT(cdp->i_d.di_nlink >= 2); ASSERT(cdp->i_d.di_nlink >= 2);
if (cdp->i_d.di_nlink != 2) { if (cdp->i_d.di_nlink != 2) {
error = XFS_ERROR(ENOTEMPTY); error = XFS_ERROR(ENOTEMPTY);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment