Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 190938
b: refs/heads/master
c: ba2e1c5
h: refs/heads/master
v: v3
  • Loading branch information
Linus Torvalds committed May 17, 2010
1 parent 4958a11 commit e77d9ee
Show file tree
Hide file tree
Showing 33 changed files with 132 additions and 92 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 92183b346f02773dae09182c65f16b013f295d80
refs/heads/master: ba2e1c5f25a99dec3873745031ad23ce3fd79bff
4 changes: 2 additions & 2 deletions trunk/arch/alpha/include/asm/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#define ATOMIC_INIT(i) ( (atomic_t) { (i) } )
#define ATOMIC64_INIT(i) ( (atomic64_t) { (i) } )

#define atomic_read(v) ((v)->counter + 0)
#define atomic64_read(v) ((v)->counter + 0)
#define atomic_read(v) (*(volatile int *)&(v)->counter)
#define atomic64_read(v) (*(volatile long *)&(v)->counter)

#define atomic_set(v,i) ((v)->counter = (i))
#define atomic64_set(v,i) ((v)->counter = (i))
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/arm/include/asm/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* strex/ldrex monitor on some implementations. The reason we can use it for
* atomic_set() is the clrex or dummy strex done on every exception return.
*/
#define atomic_read(v) ((v)->counter)
#define atomic_read(v) (*(volatile int *)&(v)->counter)
#define atomic_set(v,i) (((v)->counter) = (i))

#if __LINUX_ARM_ARCH__ >= 6
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/avr32/include/asm/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#define ATOMIC_INIT(i) { (i) }

#define atomic_read(v) ((v)->counter)
#define atomic_read(v) (*(volatile int *)&(v)->counter)
#define atomic_set(v, i) (((v)->counter) = i)

/*
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/cris/include/asm/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#define ATOMIC_INIT(i) { (i) }

#define atomic_read(v) ((v)->counter)
#define atomic_read(v) (*(volatile int *)&(v)->counter)
#define atomic_set(v,i) (((v)->counter) = (i))

/* These should be written in asm but we do it in C for now. */
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/frv/include/asm/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#define smp_mb__after_atomic_inc() barrier()

#define ATOMIC_INIT(i) { (i) }
#define atomic_read(v) ((v)->counter)
#define atomic_read(v) (*(volatile int *)&(v)->counter)
#define atomic_set(v, i) (((v)->counter) = (i))

#ifndef CONFIG_FRV_OUTOFLINE_ATOMIC_OPS
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/h8300/include/asm/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#define ATOMIC_INIT(i) { (i) }

#define atomic_read(v) ((v)->counter)
#define atomic_read(v) (*(volatile int *)&(v)->counter)
#define atomic_set(v, i) (((v)->counter) = i)

#include <asm/system.h>
Expand Down
4 changes: 2 additions & 2 deletions trunk/arch/ia64/include/asm/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
#define ATOMIC_INIT(i) ((atomic_t) { (i) })
#define ATOMIC64_INIT(i) ((atomic64_t) { (i) })

#define atomic_read(v) ((v)->counter)
#define atomic64_read(v) ((v)->counter)
#define atomic_read(v) (*(volatile int *)&(v)->counter)
#define atomic64_read(v) (*(volatile long *)&(v)->counter)

#define atomic_set(v,i) (((v)->counter) = (i))
#define atomic64_set(v,i) (((v)->counter) = (i))
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/m32r/include/asm/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*
* Atomically reads the value of @v.
*/
#define atomic_read(v) ((v)->counter)
#define atomic_read(v) (*(volatile int *)&(v)->counter)

/**
* atomic_set - set atomic variable
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/m68k/include/asm/atomic_mm.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#define ATOMIC_INIT(i) { (i) }

#define atomic_read(v) ((v)->counter)
#define atomic_read(v) (*(volatile int *)&(v)->counter)
#define atomic_set(v, i) (((v)->counter) = i)

static inline void atomic_add(int i, atomic_t *v)
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/m68k/include/asm/atomic_no.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#define ATOMIC_INIT(i) { (i) }

#define atomic_read(v) ((v)->counter)
#define atomic_read(v) (*(volatile int *)&(v)->counter)
#define atomic_set(v, i) (((v)->counter) = i)

static __inline__ void atomic_add(int i, atomic_t *v)
Expand Down
4 changes: 2 additions & 2 deletions trunk/arch/mips/include/asm/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*
* Atomically reads the value of @v.
*/
#define atomic_read(v) ((v)->counter)
#define atomic_read(v) (*(volatile int *)&(v)->counter)

/*
* atomic_set - set atomic variable
Expand Down Expand Up @@ -410,7 +410,7 @@ static __inline__ int atomic_add_unless(atomic_t *v, int a, int u)
* @v: pointer of type atomic64_t
*
*/
#define atomic64_read(v) ((v)->counter)
#define atomic64_read(v) (*(volatile long *)&(v)->counter)

/*
* atomic64_set - set atomic variable
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/mn10300/include/asm/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* Atomically reads the value of @v. Note that the guaranteed
* useful range of an atomic_t is only 24 bits.
*/
#define atomic_read(v) ((v)->counter)
#define atomic_read(v) (*(volatile int *)&(v)->counter)

/**
* atomic_set - set atomic variable
Expand Down
4 changes: 2 additions & 2 deletions trunk/arch/parisc/include/asm/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ static __inline__ void atomic_set(atomic_t *v, int i)

static __inline__ int atomic_read(const atomic_t *v)
{
return v->counter;
return (*(volatile int *)&(v)->counter);
}

/* exported interface */
Expand Down Expand Up @@ -286,7 +286,7 @@ atomic64_set(atomic64_t *v, s64 i)
static __inline__ s64
atomic64_read(const atomic64_t *v)
{
return v->counter;
return (*(volatile long *)&(v)->counter);
}

#define atomic64_add(i,v) ((void)(__atomic64_add_return( ((s64)(i)),(v))))
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/sh/include/asm/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

#define ATOMIC_INIT(i) ( (atomic_t) { (i) } )

#define atomic_read(v) ((v)->counter)
#define atomic_read(v) (*(volatile int *)&(v)->counter)
#define atomic_set(v,i) ((v)->counter = (i))

#if defined(CONFIG_GUSA_RB)
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/sparc/include/asm/atomic_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extern int atomic_cmpxchg(atomic_t *, int, int);
extern int atomic_add_unless(atomic_t *, int, int);
extern void atomic_set(atomic_t *, int);

#define atomic_read(v) ((v)->counter)
#define atomic_read(v) (*(volatile int *)&(v)->counter)

#define atomic_add(i, v) ((void)__atomic_add_return( (int)(i), (v)))
#define atomic_sub(i, v) ((void)__atomic_add_return(-(int)(i), (v)))
Expand Down
4 changes: 2 additions & 2 deletions trunk/arch/sparc/include/asm/atomic_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
#define ATOMIC_INIT(i) { (i) }
#define ATOMIC64_INIT(i) { (i) }

#define atomic_read(v) ((v)->counter)
#define atomic64_read(v) ((v)->counter)
#define atomic_read(v) (*(volatile int *)&(v)->counter)
#define atomic64_read(v) (*(volatile long *)&(v)->counter)

#define atomic_set(v, i) (((v)->counter) = i)
#define atomic64_set(v, i) (((v)->counter) = i)
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/x86/include/asm/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/
static inline int atomic_read(const atomic_t *v)
{
return v->counter;
return (*(volatile int *)&(v)->counter);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/x86/include/asm/atomic64_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
static inline long atomic64_read(const atomic64_t *v)
{
return v->counter;
return (*(volatile long *)&(v)->counter);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/xtensa/include/asm/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
*
* Atomically reads the value of @v.
*/
#define atomic_read(v) ((v)->counter)
#define atomic_read(v) (*(volatile int *)&(v)->counter)

/**
* atomic_set - set atomic variable
Expand Down
6 changes: 6 additions & 0 deletions trunk/fs/logfs/dev_bdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,13 +303,19 @@ static void bdev_put_device(struct super_block *sb)
close_bdev_exclusive(logfs_super(sb)->s_bdev, FMODE_READ|FMODE_WRITE);
}

static int bdev_can_write_buf(struct super_block *sb, u64 ofs)
{
return 0;
}

static const struct logfs_device_ops bd_devops = {
.find_first_sb = bdev_find_first_sb,
.find_last_sb = bdev_find_last_sb,
.write_sb = bdev_write_sb,
.readpage = bdev_readpage,
.writeseg = bdev_writeseg,
.erase = bdev_erase,
.can_write_buf = bdev_can_write_buf,
.sync = bdev_sync,
.put_device = bdev_put_device,
};
Expand Down
26 changes: 25 additions & 1 deletion trunk/fs/logfs/dev_mtd.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <linux/completion.h>
#include <linux/mount.h>
#include <linux/sched.h>
#include <linux/slab.h>

#define PAGE_OFS(ofs) ((ofs) & (PAGE_SIZE-1))

Expand Down Expand Up @@ -126,7 +127,8 @@ static int mtd_readpage(void *_sb, struct page *page)

err = mtd_read(sb, page->index << PAGE_SHIFT, PAGE_SIZE,
page_address(page));
if (err == -EUCLEAN) {
if (err == -EUCLEAN || err == -EBADMSG) {
/* -EBADMSG happens regularly on power failures */
err = 0;
/* FIXME: force GC this segment */
}
Expand Down Expand Up @@ -233,12 +235,32 @@ static void mtd_put_device(struct super_block *sb)
put_mtd_device(logfs_super(sb)->s_mtd);
}

static int mtd_can_write_buf(struct super_block *sb, u64 ofs)
{
struct logfs_super *super = logfs_super(sb);
void *buf;
int err;

buf = kmalloc(super->s_writesize, GFP_KERNEL);
if (!buf)
return -ENOMEM;
err = mtd_read(sb, ofs, super->s_writesize, buf);
if (err)
goto out;
if (memchr_inv(buf, 0xff, super->s_writesize))
err = -EIO;
kfree(buf);
out:
return err;
}

static const struct logfs_device_ops mtd_devops = {
.find_first_sb = mtd_find_first_sb,
.find_last_sb = mtd_find_last_sb,
.readpage = mtd_readpage,
.writeseg = mtd_writeseg,
.erase = mtd_erase,
.can_write_buf = mtd_can_write_buf,
.sync = mtd_sync,
.put_device = mtd_put_device,
};
Expand All @@ -250,5 +272,7 @@ int logfs_get_sb_mtd(struct file_system_type *type, int flags,
const struct logfs_device_ops *devops = &mtd_devops;

mtd = get_mtd_device(NULL, mtdnr);
if (IS_ERR(mtd))
return PTR_ERR(mtd);
return logfs_get_sb_device(type, flags, mtd, NULL, devops, mnt);
}
16 changes: 12 additions & 4 deletions trunk/fs/logfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,17 @@ static int logfs_writepage(struct page *page, struct writeback_control *wbc)

static void logfs_invalidatepage(struct page *page, unsigned long offset)
{
move_page_to_btree(page);
struct logfs_block *block = logfs_block(page);

if (block->reserved_bytes) {
struct super_block *sb = page->mapping->host->i_sb;
struct logfs_super *super = logfs_super(sb);

super->s_dirty_pages -= block->reserved_bytes;
block->ops->free_block(sb, block);
BUG_ON(bitmap_weight(block->alias_map, LOGFS_BLOCK_FACTOR));
} else
move_page_to_btree(page);
BUG_ON(PagePrivate(page) || page->private);
}

Expand Down Expand Up @@ -212,10 +222,8 @@ int logfs_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
int logfs_fsync(struct file *file, struct dentry *dentry, int datasync)
{
struct super_block *sb = dentry->d_inode->i_sb;
struct logfs_super *super = logfs_super(sb);

/* FIXME: write anchor */
super->s_devops->sync(sb);
logfs_write_anchor(sb);
return 0;
}

Expand Down
49 changes: 21 additions & 28 deletions trunk/fs/logfs/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ static void logfs_cleanse_block(struct super_block *sb, u64 ofs, u64 ino,
logfs_safe_iput(inode, cookie);
}

static u32 logfs_gc_segment(struct super_block *sb, u32 segno, u8 dist)
static u32 logfs_gc_segment(struct super_block *sb, u32 segno)
{
struct logfs_super *super = logfs_super(sb);
struct logfs_segment_header sh;
Expand Down Expand Up @@ -401,7 +401,7 @@ static int __logfs_gc_once(struct super_block *sb, struct gc_candidate *cand)
segno, (u64)segno << super->s_segshift,
dist, no_free_segments(sb), valid,
super->s_free_bytes);
cleaned = logfs_gc_segment(sb, segno, dist);
cleaned = logfs_gc_segment(sb, segno);
log_gc("GC segment #%02x complete - now %x valid\n", segno,
valid - cleaned);
BUG_ON(cleaned != valid);
Expand Down Expand Up @@ -632,38 +632,31 @@ static int check_area(struct super_block *sb, int i)
{
struct logfs_super *super = logfs_super(sb);
struct logfs_area *area = super->s_area[i];
struct logfs_object_header oh;
gc_level_t gc_level;
u32 cleaned, valid, ec;
u32 segno = area->a_segno;
u32 ofs = area->a_used_bytes;
__be32 crc;
int err;
u64 ofs = dev_ofs(sb, area->a_segno, area->a_written_bytes);

if (!area->a_is_open)
return 0;

for (ofs = area->a_used_bytes;
ofs <= super->s_segsize - sizeof(oh);
ofs += (u32)be16_to_cpu(oh.len) + sizeof(oh)) {
err = wbuf_read(sb, dev_ofs(sb, segno, ofs), sizeof(oh), &oh);
if (err)
return err;

if (!memchr_inv(&oh, 0xff, sizeof(oh)))
break;
if (super->s_devops->can_write_buf(sb, ofs) == 0)
return 0;

crc = logfs_crc32(&oh, sizeof(oh) - 4, 4);
if (crc != oh.crc) {
printk(KERN_INFO "interrupted header at %llx\n",
dev_ofs(sb, segno, ofs));
return 0;
}
}
if (ofs != area->a_used_bytes) {
printk(KERN_INFO "%x bytes unaccounted data found at %llx\n",
ofs - area->a_used_bytes,
dev_ofs(sb, segno, area->a_used_bytes));
area->a_used_bytes = ofs;
}
printk(KERN_INFO"LogFS: Possibly incomplete write at %llx\n", ofs);
/*
* The device cannot write back the write buffer. Most likely the
* wbuf was already written out and the system crashed at some point
* before the journal commit happened. In that case we wouldn't have
* to do anything. But if the crash happened before the wbuf was
* written out correctly, we must GC this segment. So assume the
* worst and always do the GC run.
*/
area->a_is_open = 0;
valid = logfs_valid_bytes(sb, segno, &ec, &gc_level);
cleaned = logfs_gc_segment(sb, segno);
if (cleaned != valid)
return -EIO;
return 0;
}

Expand Down
Loading

0 comments on commit e77d9ee

Please sign in to comment.