sched: make early bootup sched_clock() use safer

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=6892b75e60557a48c01d57ba320419a9e2ce9846
Commit: 6892b75e60557a48c01d57ba320419a9e2ce9846
Parent: bfa274e2436fc7ef72ef51c878083647f1cfd429
Author: Ingo Molnar [EMAIL PROTECTED]
AuthorDate: Wed Feb 13 14:02:36 2008 +0100
Committer:  Ingo Molnar [EMAIL PROTECTED]
CommitDate: Mon Feb 25 16:34:16 2008 +0100

sched: make early bootup sched_clock() use safer

do not call sched_clock() too early. Not only might rq-idle
not be set up - but pure per-cpu data might not be accessible
either.

this solves an ia64 early bootup hang with CONFIG_PRINTK_TIME=y.

Tested-by: Tony Luck [EMAIL PROTECTED]
Acked-by: Tony Luck [EMAIL PROTECTED]
Acked-by: David S. Miller [EMAIL PROTECTED]
Signed-off-by: Ingo Molnar [EMAIL PROTECTED]
---
 kernel/sched.c |   14 ++
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/kernel/sched.c b/kernel/sched.c
index b387a8d..7286ccb 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -668,6 +668,8 @@ const_debug unsigned int sysctl_sched_nr_migrate = 32;
  */
 unsigned int sysctl_sched_rt_period = 100;
 
+static __read_mostly int scheduler_running;
+
 /*
  * part of the period that we allow rt tasks to run in us.
  * default: 0.95s
@@ -689,14 +691,16 @@ unsigned long long cpu_clock(int cpu)
unsigned long flags;
struct rq *rq;
 
-   local_irq_save(flags);
-   rq = cpu_rq(cpu);
/*
 * Only call sched_clock() if the scheduler has already been
 * initialized (some code might call cpu_clock() very early):
 */
-   if (rq-idle)
-   update_rq_clock(rq);
+   if (unlikely(!scheduler_running))
+   return 0;
+
+   local_irq_save(flags);
+   rq = cpu_rq(cpu);
+   update_rq_clock(rq);
now = rq-clock;
local_irq_restore(flags);
 
@@ -7284,6 +7288,8 @@ void __init sched_init(void)
 * During early bootup we pretend to be a normal task:
 */
current-sched_class = fair_sched_class;
+
+   scheduler_running = 1;
 }
 
 #ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


printk: fix possible printk overrun

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=cf3680b90c7842cf91ed857ac4528f4e057da366
Commit: cf3680b90c7842cf91ed857ac4528f4e057da366
Parent: bfa274e2436fc7ef72ef51c878083647f1cfd429
Author: Tejun Heo [EMAIL PROTECTED]
AuthorDate: Thu Feb 14 10:32:07 2008 +0900
Committer:  Linus Torvalds [EMAIL PROTECTED]
CommitDate: Tue Feb 26 07:42:37 2008 -0800

printk: fix possible printk overrun

printk recursion detection prepends message to printk_buf and offsets
printk_buf when actual message is printed but it forgets to trim buffer
length accordingly. This can result in overrun in extreme cases. Fix it.

[ [EMAIL PROTECTED]:

  bug was introduced by me via:

   commit 32a76006683f7b28ae3cc491da37716e002f198e
   Author: Ingo Molnar [EMAIL PROTECTED]
   Date:   Fri Jan 25 21:07:58 2008 +0100

   printk: make printk more robust by not allowing recursion
]

Signed-off-by: Tejun Heo [EMAIL PROTECTED]
Signed-off-by: Ingo Molnar [EMAIL PROTECTED]
Signed-off-by: Linus Torvalds [EMAIL PROTECTED]
---
 kernel/printk.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/kernel/printk.c b/kernel/printk.c
index bee3610..9adc2a4 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -666,7 +666,7 @@ asmlinkage int vprintk(const char *fmt, va_list args)
}
/* Emit the output into the temporary buffer */
printed_len += vscnprintf(printk_buf + printed_len,
- sizeof(printk_buf), fmt, args);
+ sizeof(printk_buf) - printed_len, fmt, args);
 
/*
 * Copy the output into log_buf.  If the caller didn't provide
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


sched: remove duplicate code from sched_fair.c

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=70eee74b70c1a8485ec5f2bafa13dbc66fab6e02
Commit: 70eee74b70c1a8485ec5f2bafa13dbc66fab6e02
Parent: 6892b75e60557a48c01d57ba320419a9e2ce9846
Author: Balbir Singh [EMAIL PROTECTED]
AuthorDate: Fri Feb 22 13:25:53 2008 +0530
Committer:  Ingo Molnar [EMAIL PROTECTED]
CommitDate: Mon Feb 25 16:34:17 2008 +0100

sched: remove duplicate code from sched_fair.c

pick_task_entity() duplicates existing code. This functionality can be
easily obtained using rb_last(). Avoid code duplication by using rb_last().

Signed-off-by: Balbir Singh [EMAIL PROTECTED]
Signed-off-by: Ingo Molnar [EMAIL PROTECTED]
---
 kernel/sched_fair.c |   15 ++-
 1 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c
index 6c091d6..7abad50 100644
--- a/kernel/sched_fair.c
+++ b/kernel/sched_fair.c
@@ -202,16 +202,13 @@ static struct sched_entity *__pick_next_entity(struct 
cfs_rq *cfs_rq)
 
 static inline struct sched_entity *__pick_last_entity(struct cfs_rq *cfs_rq)
 {
-   struct rb_node **link = cfs_rq-tasks_timeline.rb_node;
-   struct sched_entity *se = NULL;
-   struct rb_node *parent;
-
-   while (*link) {
-   parent = *link;
-   se = rb_entry(parent, struct sched_entity, run_node);
-   link = parent-rb_right;
-   }
+   struct rb_node *last;
+   struct sched_entity *se;
 
+   last = rb_last(cfs_rq-tasks_timeline);
+   if (!last)
+   return NULL;
+   se = rb_entry(last, struct sched_entity, run_node);
return se;
 }
 
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


sched: clean up __pick_last_entity() a bit

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=7eee3e677d6e2e9007afcd7d79b0715525aa552e
Commit: 7eee3e677d6e2e9007afcd7d79b0715525aa552e
Parent: 70eee74b70c1a8485ec5f2bafa13dbc66fab6e02
Author: Ingo Molnar [EMAIL PROTECTED]
AuthorDate: Fri Feb 22 10:32:21 2008 +0100
Committer:  Ingo Molnar [EMAIL PROTECTED]
CommitDate: Mon Feb 25 16:34:17 2008 +0100

sched: clean up __pick_last_entity() a bit

Signed-off-by: Ingo Molnar [EMAIL PROTECTED]
---
 kernel/sched_fair.c |8 +++-
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c
index 7abad50..c8e6492 100644
--- a/kernel/sched_fair.c
+++ b/kernel/sched_fair.c
@@ -202,14 +202,12 @@ static struct sched_entity *__pick_next_entity(struct 
cfs_rq *cfs_rq)
 
 static inline struct sched_entity *__pick_last_entity(struct cfs_rq *cfs_rq)
 {
-   struct rb_node *last;
-   struct sched_entity *se;
+   struct rb_node *last = rb_last(cfs_rq-tasks_timeline);
 
-   last = rb_last(cfs_rq-tasks_timeline);
if (!last)
return NULL;
-   se = rb_entry(last, struct sched_entity, run_node);
-   return se;
+
+   return rb_entry(last, struct sched_entity, run_node);
 }
 
 /**
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


sched: fix signedness warnings in sched.c

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=67ca7bde2e9d3516b5ae0188330ad1059ac03f38
Commit: 67ca7bde2e9d3516b5ae0188330ad1059ac03f38
Parent: 7eee3e677d6e2e9007afcd7d79b0715525aa552e
Author: Harvey Harrison [EMAIL PROTECTED]
AuthorDate: Fri Feb 15 09:56:36 2008 -0800
Committer:  Ingo Molnar [EMAIL PROTECTED]
CommitDate: Mon Feb 25 16:34:17 2008 +0100

sched: fix signedness warnings in sched.c

Unsigned long values are always assigned to switch_count,
make it unsigned long.

kernel/sched.c:3897:15: warning: incorrect type in assignment (different 
signedness)
kernel/sched.c:3897:15:expected long *switch_count
kernel/sched.c:3897:15:got unsigned long *noident
kernel/sched.c:3921:16: warning: incorrect type in assignment (different 
signedness)
kernel/sched.c:3921:16:expected long *switch_count
kernel/sched.c:3921:16:got unsigned long *noident

Signed-off-by: Harvey Harrison [EMAIL PROTECTED]
Signed-off-by: Ingo Molnar [EMAIL PROTECTED]
---
 kernel/sched.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/kernel/sched.c b/kernel/sched.c
index 7286ccb..f06950c 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -3889,7 +3889,7 @@ pick_next_task(struct rq *rq, struct task_struct *prev)
 asmlinkage void __sched schedule(void)
 {
struct task_struct *prev, *next;
-   long *switch_count;
+   unsigned long *switch_count;
struct rq *rq;
int cpu;
 
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


sched: add declaration of sched_tail to sched.h

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=2d07b255c7b8a9723010e5c74778e058dc05162e
Commit: 2d07b255c7b8a9723010e5c74778e058dc05162e
Parent: 67ca7bde2e9d3516b5ae0188330ad1059ac03f38
Author: Harvey Harrison [EMAIL PROTECTED]
AuthorDate: Fri Feb 15 09:56:34 2008 -0800
Committer:  Ingo Molnar [EMAIL PROTECTED]
CommitDate: Mon Feb 25 16:34:17 2008 +0100

sched: add declaration of sched_tail to sched.h

Avoids sparse warnings:
kernel/sched.c:2170:17: warning: symbol 'schedule_tail' was not declared. 
Should it be static?

Avoids the need for an external declaration in arch/um/process.c

Signed-off-by: Harvey Harrison [EMAIL PROTECTED]
Signed-off-by: Ingo Molnar [EMAIL PROTECTED]
---
 arch/um/kernel/process.c |2 --
 include/linux/sched.h|1 +
 2 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
index fc50d2f..e8cb9ff 100644
--- a/arch/um/kernel/process.c
+++ b/arch/um/kernel/process.c
@@ -128,8 +128,6 @@ void *get_current(void)
return current;
 }
 
-extern void schedule_tail(struct task_struct *prev);
-
 /*
  * This is called magically, by its address being stuffed in a jmp_buf
  * and being longjmp-d to.
diff --git a/include/linux/sched.h b/include/linux/sched.h
index e217d18..9c17e82 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -242,6 +242,7 @@ struct task_struct;
 
 extern void sched_init(void);
 extern void sched_init_smp(void);
+extern asmlinkage void schedule_tail(struct task_struct *prev);
 extern void init_idle(struct task_struct *idle, int cpu);
 extern void init_idle_bootup_task(struct task_struct *idle);
 
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


latencytop: fix kernel panic while reading latency proc file

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=ae0027869db7d28563cd783865fab04ffd18419c
Commit: ae0027869db7d28563cd783865fab04ffd18419c
Parent: 2d07b255c7b8a9723010e5c74778e058dc05162e
Author: Hiroshi Shimamoto [EMAIL PROTECTED]
AuthorDate: Thu Feb 14 10:26:24 2008 -0800
Committer:  Ingo Molnar [EMAIL PROTECTED]
CommitDate: Mon Feb 25 16:34:17 2008 +0100

latencytop: fix kernel panic while reading latency proc file

Reading /proc/pid/latency or /proc/pid/task/tid/latency could cause
NULL pointer dereference.

In lstats_open(), get_proc_task() can return NULL, in which case the kernel
will oops at lstats_show_proc() because m-private is NULL.

When get_proc_task() returns NULL, the kernel should return -ENOENT.

This can be reproduced by the following script.
while :
do
date
bash -c 'ls  ls.$$' 
pid=$!
cat /proc/$pid/latency 
cat /proc/$pid/latency 
cat /proc/$pid/latency 
cat /proc/$pid/latency
done

Signed-off-by: Hiroshi Shimamoto [EMAIL PROTECTED]
Signed-off-by: Ingo Molnar [EMAIL PROTECTED]
---
 fs/proc/base.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/fs/proc/base.c b/fs/proc/base.c
index 96ee899..989e307 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -350,6 +350,8 @@ static int lstats_open(struct inode *inode, struct file 
*file)
struct seq_file *m;
struct task_struct *task = get_proc_task(inode);
 
+   if (!task)
+   return -ENOENT;
ret = single_open(file, lstats_show_proc, NULL);
if (!ret) {
m = file-private_data;
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


latencytop: fix memory leak on latency proc file

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=d6643d12cb0885d06a1491b16c1476abcbd53d40
Commit: d6643d12cb0885d06a1491b16c1476abcbd53d40
Parent: ae0027869db7d28563cd783865fab04ffd18419c
Author: Hiroshi Shimamoto [EMAIL PROTECTED]
AuthorDate: Thu Feb 14 10:27:00 2008 -0800
Committer:  Ingo Molnar [EMAIL PROTECTED]
CommitDate: Mon Feb 25 16:34:17 2008 +0100

latencytop: fix memory leak on latency proc file

At lstats_open(), calling get_proc_task() gets task struct, but it never 
put.
put_task_struct() should be called when releasing.

Signed-off-by: Hiroshi Shimamoto [EMAIL PROTECTED]
Signed-off-by: Ingo Molnar [EMAIL PROTECTED]
---
 fs/proc/base.c |   11 ++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/fs/proc/base.c b/fs/proc/base.c
index 989e307..85e06e4 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -360,6 +360,15 @@ static int lstats_open(struct inode *inode, struct file 
*file)
return ret;
 }
 
+static int lstats_release(struct inode *inode, struct file *file)
+{
+   struct seq_file *m = file-private_data;
+   struct task_struct *task = m-private;
+
+   put_task_struct(task);
+   return single_release(inode, file);
+}
+
 static ssize_t lstats_write(struct file *file, const char __user *buf,
size_t count, loff_t *offs)
 {
@@ -378,7 +387,7 @@ static const struct file_operations proc_lstats_operations 
= {
.read   = seq_read,
.write  = lstats_write,
.llseek = seq_lseek,
-   .release= single_release,
+   .release= lstats_release,
 };
 
 #endif
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


latencytop: change /proc task_struct access method

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=13d77c37cab2bb906022309e1e7182c327e49916
Commit: 13d77c37cab2bb906022309e1e7182c327e49916
Parent: d6643d12cb0885d06a1491b16c1476abcbd53d40
Author: Hiroshi Shimamoto [EMAIL PROTECTED]
AuthorDate: Wed Feb 20 16:53:29 2008 -0800
Committer:  Ingo Molnar [EMAIL PROTECTED]
CommitDate: Mon Feb 25 16:34:18 2008 +0100

latencytop: change /proc task_struct access method

Change getting task_struct by get_proc_task() at read or write time,
and returns -ESRCH if get_proc_task() returns NULL.
This is same behavior as other /proc files.

Signed-off-by: Hiroshi Shimamoto [EMAIL PROTECTED]
Signed-off-by: Ingo Molnar [EMAIL PROTECTED]
---
 fs/proc/base.c |   40 
 1 files changed, 12 insertions(+), 28 deletions(-)

diff --git a/fs/proc/base.c b/fs/proc/base.c
index 85e06e4..91a1bd6 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -314,9 +314,12 @@ static int proc_pid_schedstat(struct task_struct *task, 
char *buffer)
 static int lstats_show_proc(struct seq_file *m, void *v)
 {
int i;
-   struct task_struct *task = m-private;
-   seq_puts(m, Latency Top version : v0.1\n);
+   struct inode *inode = m-private;
+   struct task_struct *task = get_proc_task(inode);
 
+   if (!task)
+   return -ESRCH;
+   seq_puts(m, Latency Top version : v0.1\n);
for (i = 0; i  32; i++) {
if (task-latency_record[i].backtrace[0]) {
int q;
@@ -341,43 +344,24 @@ static int lstats_show_proc(struct seq_file *m, void *v)
}
 
}
+   put_task_struct(task);
return 0;
 }
 
 static int lstats_open(struct inode *inode, struct file *file)
 {
-   int ret;
-   struct seq_file *m;
-   struct task_struct *task = get_proc_task(inode);
-
-   if (!task)
-   return -ENOENT;
-   ret = single_open(file, lstats_show_proc, NULL);
-   if (!ret) {
-   m = file-private_data;
-   m-private = task;
-   }
-   return ret;
-}
-
-static int lstats_release(struct inode *inode, struct file *file)
-{
-   struct seq_file *m = file-private_data;
-   struct task_struct *task = m-private;
-
-   put_task_struct(task);
-   return single_release(inode, file);
+   return single_open(file, lstats_show_proc, inode);
 }
 
 static ssize_t lstats_write(struct file *file, const char __user *buf,
size_t count, loff_t *offs)
 {
-   struct seq_file *m;
-   struct task_struct *task;
+   struct task_struct *task = get_proc_task(file-f_dentry-d_inode);
 
-   m = file-private_data;
-   task = m-private;
+   if (!task)
+   return -ESRCH;
clear_all_latency_tracing(task);
+   put_task_struct(task);
 
return count;
 }
@@ -387,7 +371,7 @@ static const struct file_operations proc_lstats_operations 
= {
.read   = seq_read,
.write  = lstats_write,
.llseek = seq_lseek,
-   .release= lstats_release,
+   .release= single_release,
 };
 
 #endif
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


x86: make DEBUG_PAGEALLOC and CPA more robust

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=92cb54a37a42a41cfb2ef7f1478bfa4395198258
Commit: 92cb54a37a42a41cfb2ef7f1478bfa4395198258
Parent: 1ce70c4fac3c3954bd48c035f448793867592bc0
Author: Ingo Molnar [EMAIL PROTECTED]
AuthorDate: Wed Feb 13 14:37:52 2008 +0100
Committer:  Ingo Molnar [EMAIL PROTECTED]
CommitDate: Tue Feb 26 12:55:50 2008 +0100

x86: make DEBUG_PAGEALLOC and CPA more robust

Use PF_MEMALLOC to prevent recursive calls in the DBEUG_PAGEALLOC
case. This makes the code simpler and more robust against allocation
failures.

This fixes the following fallback to non-mmconfig:

   http://lkml.org/lkml/2008/2/20/551
   http://bugzilla.kernel.org/show_bug.cgi?id=10083

Also, for DEBUG_PAGEALLOC=n reduce the pool size to one page.

Signed-off-by: Ingo Molnar [EMAIL PROTECTED]
Signed-off-by: Thomas Gleixner [EMAIL PROTECTED]
---
 arch/x86/mm/pageattr.c |   84 +---
 1 files changed, 51 insertions(+), 33 deletions(-)

diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
index 464d8fc..14e48b5 100644
--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -44,6 +44,12 @@ static inline unsigned long highmap_end_pfn(void)
 
 #endif
 
+#ifdef CONFIG_DEBUG_PAGEALLOC
+# define debug_pagealloc 1
+#else
+# define debug_pagealloc 0
+#endif
+
 static inline int
 within(unsigned long addr, unsigned long start, unsigned long end)
 {
@@ -355,45 +361,48 @@ out_unlock:
 
 static LIST_HEAD(page_pool);
 static unsigned long pool_size, pool_pages, pool_low;
-static unsigned long pool_used, pool_failed, pool_refill;
+static unsigned long pool_used, pool_failed;
 
-static void cpa_fill_pool(void)
+static void cpa_fill_pool(struct page **ret)
 {
-   struct page *p;
gfp_t gfp = GFP_KERNEL;
+   unsigned long flags;
+   struct page *p;
 
-   /* Do not allocate from interrupt context */
-   if (in_irq() || irqs_disabled())
-   return;
/*
-* Check unlocked. I does not matter when we have one more
-* page in the pool. The bit lock avoids recursive pool
-* allocations:
+* Avoid recursion (on debug-pagealloc) and also signal
+* our priority to get to these pagetables:
 */
-   if (pool_pages = pool_size || test_and_set_bit_lock(0, pool_refill))
+   if (current-flags  PF_MEMALLOC)
return;
+   current-flags |= PF_MEMALLOC;
 
-#ifdef CONFIG_DEBUG_PAGEALLOC
/*
-* We could do:
-* gfp = in_atomic() ? GFP_ATOMIC : GFP_KERNEL;
-* but this fails on !PREEMPT kernels
+* Allocate atomically from atomic contexts:
 */
-   gfp =  GFP_ATOMIC | __GFP_NORETRY | __GFP_NOWARN;
-#endif
+   if (in_atomic() || irqs_disabled() || debug_pagealloc)
+   gfp =  GFP_ATOMIC | __GFP_NORETRY | __GFP_NOWARN;
 
-   while (pool_pages  pool_size) {
+   while (pool_pages  pool_size || (ret  !*ret)) {
p = alloc_pages(gfp, 0);
if (!p) {
pool_failed++;
break;
}
-   spin_lock_irq(pgd_lock);
+   /*
+* If the call site needs a page right now, provide it:
+*/
+   if (ret  !*ret) {
+   *ret = p;
+   continue;
+   }
+   spin_lock_irqsave(pgd_lock, flags);
list_add(p-lru, page_pool);
pool_pages++;
-   spin_unlock_irq(pgd_lock);
+   spin_unlock_irqrestore(pgd_lock, flags);
}
-   clear_bit_unlock(0, pool_refill);
+
+   current-flags = ~PF_MEMALLOC;
 }
 
 #define SHIFT_MB   (20 - PAGE_SHIFT)
@@ -414,11 +423,15 @@ void __init cpa_init(void)
 * GiB. Shift MiB to Gib and multiply the result by
 * POOL_PAGES_PER_GB:
 */
-   gb = ((si.totalram  SHIFT_MB) + ROUND_MB_GB)  SHIFT_MB_GB;
-   pool_size = POOL_PAGES_PER_GB * gb;
+   if (debug_pagealloc) {
+   gb = ((si.totalram  SHIFT_MB) + ROUND_MB_GB)  SHIFT_MB_GB;
+   pool_size = POOL_PAGES_PER_GB * gb;
+   } else {
+   pool_size = 1;
+   }
pool_low = pool_size;
 
-   cpa_fill_pool();
+   cpa_fill_pool(NULL);
printk(KERN_DEBUG
   CPA: page pool initialized %lu of %lu pages preallocated\n,
   pool_pages, pool_size);
@@ -440,16 +453,20 @@ static int split_large_page(pte_t *kpte, unsigned long 
address)
spin_lock_irqsave(pgd_lock, flags);
if (list_empty(page_pool)) {
spin_unlock_irqrestore(pgd_lock, flags);
-   return -ENOMEM;
+   base = NULL;
+   cpa_fill_pool(base);
+   if (!base)
+   return -ENOMEM;
+   

x86: hpet fix docbook comment

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=b02a7f22f39f02fdf5a1380ff700293639db4490
Commit: b02a7f22f39f02fdf5a1380ff700293639db4490
Parent: 92cb54a37a42a41cfb2ef7f1478bfa4395198258
Author: Pavel Machek [EMAIL PROTECTED]
AuthorDate: Tue Feb 5 00:48:13 2008 +0100
Committer:  Ingo Molnar [EMAIL PROTECTED]
CommitDate: Tue Feb 26 12:55:50 2008 +0100

x86: hpet fix docbook comment

Signed-off-by: Pavel Machek [EMAIL PROTECTED]
Signed-off-by: Ingo Molnar [EMAIL PROTECTED]
Signed-off-by: Thomas Gleixner [EMAIL PROTECTED]
---
 arch/x86/kernel/hpet.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c
index 429d084..235fd6c 100644
--- a/arch/x86/kernel/hpet.c
+++ b/arch/x86/kernel/hpet.c
@@ -368,8 +368,8 @@ static int hpet_clocksource_register(void)
return 0;
 }
 
-/*
- * Try to setup the HPET timer
+/**
+ * hpet_enable - Try to setup the HPET timer. Returns 1 on success.
  */
 int __init hpet_enable(void)
 {
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


x86: do not promote TM3x00/TM5x00 to i686-class

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=a7ef94e6889186848573a10c5bdb8271405f44de
Commit: a7ef94e6889186848573a10c5bdb8271405f44de
Parent: b02a7f22f39f02fdf5a1380ff700293639db4490
Author: H. Peter Anvin [EMAIL PROTECTED]
AuthorDate: Thu Feb 14 14:51:00 2008 -0800
Committer:  Ingo Molnar [EMAIL PROTECTED]
CommitDate: Tue Feb 26 12:55:50 2008 +0100

x86: do not promote TM3x00/TM5x00 to i686-class

We have been promoting Transmeta TM3x00/TM5x00 chips to i686-class
based on the notion that they contain all the user-space visible
features of an i686-class chip.  However, this is not actually true:
they lack the EA-taking long NOPs (0F 1F /0).  Since this is a
userspace-visible incompatibility, downgrade these CPUs to the
manufacturer-defined i586 level.

Signed-off-by: H. Peter Anvin [EMAIL PROTECTED]
Signed-off-by: Ingo Molnar [EMAIL PROTECTED]
Signed-off-by: Thomas Gleixner [EMAIL PROTECTED]
---
 arch/x86/kernel/cpu/transmeta.c |7 ---
 1 files changed, 0 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kernel/cpu/transmeta.c b/arch/x86/kernel/cpu/transmeta.c
index 200fb3f..e8b422c 100644
--- a/arch/x86/kernel/cpu/transmeta.c
+++ b/arch/x86/kernel/cpu/transmeta.c
@@ -76,13 +76,6 @@ static void __cpuinit init_transmeta(struct cpuinfo_x86 *c)
/* All Transmeta CPUs have a constant TSC */
set_bit(X86_FEATURE_CONSTANT_TSC, c-x86_capability);

-   /* If we can run i686 user-space code, call us an i686 */
-#define USER686 ((1  X86_FEATURE_TSC)|\
-(1  X86_FEATURE_CX8)|\
-(1  X86_FEATURE_CMOV))
-if (c-x86 == 5  (c-x86_capability[0]  USER686) == USER686)
-   c-x86 = 6;
-
 #ifdef CONFIG_SYSCTL
/* randomize_va_space slows us down enormously;
   it probably triggers retranslation of x86-native bytecode */
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


x86: require family = 6 if we are using P6 NOPs

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=7343b3b3a627eb30e24e921f004f659c8ebb91c5
Commit: 7343b3b3a627eb30e24e921f004f659c8ebb91c5
Parent: a7ef94e6889186848573a10c5bdb8271405f44de
Author: H. Peter Anvin [EMAIL PROTECTED]
AuthorDate: Thu Feb 14 14:52:05 2008 -0800
Committer:  Ingo Molnar [EMAIL PROTECTED]
CommitDate: Tue Feb 26 12:55:51 2008 +0100

x86: require family = 6 if we are using P6 NOPs

The P6 family of NOPs are only available on family = 6 or above, so
enforce that in the boot code.

Signed-off-by: H. Peter Anvin [EMAIL PROTECTED]
Signed-off-by: Ingo Molnar [EMAIL PROTECTED]
Signed-off-by: Thomas Gleixner [EMAIL PROTECTED]
---
 arch/x86/Kconfig.cpu   |5 +
 include/asm-x86/nops.h |4 +---
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
index e09a6b7..86fd2a0 100644
--- a/arch/x86/Kconfig.cpu
+++ b/arch/x86/Kconfig.cpu
@@ -377,6 +377,10 @@ config X86_OOSTORE
def_bool y
depends on (MWINCHIP3D || MWINCHIP2 || MWINCHIPC6)  MTRR
 
+config X86_P6_NOP
+   def_bool y
+   depends on (M686 || MPENTIUMII || MPENTIUMIII || MPENTIUMM || MCORE2 || 
PENTIUM4)
+
 config X86_TSC
def_bool y
depends on ((MWINCHIP3D || MWINCHIP2 || MCRUSOE || MEFFICEON || 
MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII 
|| M686 || M586MMX || M586TSC || MK8 || MVIAC3_2 || MVIAC7 || MGEODEGX1 || 
MGEODE_LX || MCORE2)  !X86_NUMAQ) || X86_64
@@ -390,6 +394,7 @@ config X86_CMOV
 config X86_MINIMUM_CPU_FAMILY
int
default 64 if X86_64
+   default 6 if X86_32  X86_P6_NOP
default 4 if X86_32  (X86_XADD || X86_CMPXCHG || X86_BSWAP || 
X86_WP_WORKS_OK)
default 3
 
diff --git a/include/asm-x86/nops.h b/include/asm-x86/nops.h
index fec025c..c52b334 100644
--- a/include/asm-x86/nops.h
+++ b/include/asm-x86/nops.h
@@ -63,9 +63,7 @@
 #define ASM_NOP6 K7_NOP6
 #define ASM_NOP7 K7_NOP7
 #define ASM_NOP8 K7_NOP8
-#elif defined(CONFIG_M686) || defined(CONFIG_MPENTIUMII) || \
-  defined(CONFIG_MPENTIUMIII) || defined(CONFIG_MPENTIUMM) || \
-  defined(CONFIG_MCORE2) || defined(CONFIG_PENTIUM4)
+#elif defined(CONFIG_X86_P6_NOP)
 #define ASM_NOP1 P6_NOP1
 #define ASM_NOP2 P6_NOP2
 #define ASM_NOP3 P6_NOP3
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


x86: don't use P6_NOPs if compiling with CONFIG_X86_GENERIC

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=959b3be64cab9160cd74532a49b89cdd918d38e9
Commit: 959b3be64cab9160cd74532a49b89cdd918d38e9
Parent: 7343b3b3a627eb30e24e921f004f659c8ebb91c5
Author: H. Peter Anvin [EMAIL PROTECTED]
AuthorDate: Thu Feb 14 14:56:45 2008 -0800
Committer:  Ingo Molnar [EMAIL PROTECTED]
CommitDate: Tue Feb 26 12:55:51 2008 +0100

x86: don't use P6_NOPs if compiling with CONFIG_X86_GENERIC

P6_NOPs are definitely not supported on some VIA CPUs, and possibly
(unverified) on AMD K7s.  It is also the only thing that prevents a
686 kernel from running on Transmeta TM3x00/5x00 (Crusoe) series.

The performance benefit over generic NOPs is very small, so when
building for generic consumption, avoid using them.

Signed-off-by: H. Peter Anvin [EMAIL PROTECTED]
Signed-off-by: Ingo Molnar [EMAIL PROTECTED]
Signed-off-by: Thomas Gleixner [EMAIL PROTECTED]
---
 arch/x86/Kconfig.cpu |   11 ++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
index 86fd2a0..6d50064 100644
--- a/arch/x86/Kconfig.cpu
+++ b/arch/x86/Kconfig.cpu
@@ -377,9 +377,18 @@ config X86_OOSTORE
def_bool y
depends on (MWINCHIP3D || MWINCHIP2 || MWINCHIPC6)  MTRR
 
+#
+# P6_NOPs are a relatively minor optimization that require a family =
+# 6 processor, except that it is broken on certain VIA chips.
+# Furthermore, AMD chips prefer a totally different sequence of NOPs
+# (which work on all CPUs).  As a result, disallow these if we're
+# compiling X86_GENERIC but not X86_64 (these NOPs do work on all
+# x86-64 capable chips); the list of processors in the right-hand clause
+# are the cores that benefit from this optimization.
+#
 config X86_P6_NOP
def_bool y
-   depends on (M686 || MPENTIUMII || MPENTIUMIII || MPENTIUMM || MCORE2 || 
PENTIUM4)
+   depends on (X86_64 || !X86_GENERIC)  (M686 || MPENTIUMII || 
MPENTIUMIII || MPENTIUMM || MCORE2 || PENTIUM4)
 
 config X86_TSC
def_bool y
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


x86: add comments for NOPs

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=4cd20952d74323df06e438c0c3273b5be89d6bfd
Commit: 4cd20952d74323df06e438c0c3273b5be89d6bfd
Parent: 959b3be64cab9160cd74532a49b89cdd918d38e9
Author: H. Peter Anvin [EMAIL PROTECTED]
AuthorDate: Mon Feb 18 23:24:33 2008 -0800
Committer:  Ingo Molnar [EMAIL PROTECTED]
CommitDate: Tue Feb 26 12:55:51 2008 +0100

x86: add comments for NOPs

Add comments describing the various NOP sequences.

Signed-off-by: H. Peter Anvin [EMAIL PROTECTED]
Signed-off-by: Ingo Molnar [EMAIL PROTECTED]
Signed-off-by: Thomas Gleixner [EMAIL PROTECTED]
---
 include/asm-x86/nops.h |   62 ++-
 1 files changed, 45 insertions(+), 17 deletions(-)

diff --git a/include/asm-x86/nops.h b/include/asm-x86/nops.h
index c52b334..e3b2bce 100644
--- a/include/asm-x86/nops.h
+++ b/include/asm-x86/nops.h
@@ -3,17 +3,29 @@
 
 /* Define nops for use with alternative() */
 
-/* generic versions from gas */
-#define GENERIC_NOP1   .byte 0x90\n
-#define GENERIC_NOP2   .byte 0x89,0xf6\n
-#define GENERIC_NOP3.byte 0x8d,0x76,0x00\n
-#define GENERIC_NOP4.byte 0x8d,0x74,0x26,0x00\n
-#define GENERIC_NOP5GENERIC_NOP1 GENERIC_NOP4
-#define GENERIC_NOP6   .byte 0x8d,0xb6,0x00,0x00,0x00,0x00\n
-#define GENERIC_NOP7   .byte 0x8d,0xb4,0x26,0x00,0x00,0x00,0x00\n
-#define GENERIC_NOP8   GENERIC_NOP1 GENERIC_NOP7
+/* generic versions from gas
+   1: nop
+   2: movl %esi,%esi
+   3: leal 0x00(%esi),%esi
+   4: leal 0x00(,%esi,1),%esi
+   6: leal 0x(%esi),%esi
+   7: leal 0x(,%esi,1),%esi
+*/
+#define GENERIC_NOP1 .byte 0x90\n
+#define GENERIC_NOP2 .byte 0x89,0xf6\n
+#define GENERIC_NOP3 .byte 0x8d,0x76,0x00\n
+#define GENERIC_NOP4 .byte 0x8d,0x74,0x26,0x00\n
+#define GENERIC_NOP5 GENERIC_NOP1 GENERIC_NOP4
+#define GENERIC_NOP6 .byte 0x8d,0xb6,0x00,0x00,0x00,0x00\n
+#define GENERIC_NOP7 .byte 0x8d,0xb4,0x26,0x00,0x00,0x00,0x00\n
+#define GENERIC_NOP8 GENERIC_NOP1 GENERIC_NOP7
 
-/* Opteron 64bit nops */
+/* Opteron 64bit nops
+   1: nop
+   2: osp nop
+   3: osp osp nop
+   4: osp osp osp nop
+*/
 #define K8_NOP1 GENERIC_NOP1
 #define K8_NOP2.byte 0x66,0x90\n
 #define K8_NOP3.byte 0x66,0x66,0x90\n
@@ -23,19 +35,35 @@
 #define K8_NOP7K8_NOP4 K8_NOP3
 #define K8_NOP8K8_NOP4 K8_NOP4
 
-/* K7 nops */
-/* uses eax dependencies (arbitary choice) */
-#define K7_NOP1  GENERIC_NOP1
+/* K7 nops
+   uses eax dependencies (arbitary choice)
+   1: nop
+   2: movl %eax,%eax
+   3: leal (,%eax,1),%eax
+   4: leal 0x00(,%eax,1),%eax
+   6: leal 0x(%eax),%eax
+   7: leal 0x(,%eax,1),%eax
+*/
+#define K7_NOP1GENERIC_NOP1
 #define K7_NOP2.byte 0x8b,0xc0\n
 #define K7_NOP3.byte 0x8d,0x04,0x20\n
 #define K7_NOP4.byte 0x8d,0x44,0x20,0x00\n
 #define K7_NOP5K7_NOP4 ASM_NOP1
 #define K7_NOP6.byte 0x8d,0x80,0,0,0,0\n
-#define K7_NOP7.byte 0x8D,0x04,0x05,0,0,0,0\n
-#define K7_NOP8K7_NOP7 ASM_NOP1
+#define K7_NOP7.byte 0x8D,0x04,0x05,0,0,0,0\n
+#define K7_NOP8K7_NOP7 ASM_NOP1
 
-/* P6 nops */
-/* uses eax dependencies (Intel-recommended choice) */
+/* P6 nops
+   uses eax dependencies (Intel-recommended choice)
+   1: nop
+   2: osp nop
+   3: nopl (%eax)
+   4: nopl 0x00(%eax)
+   5: nopl 0x00(%eax,%eax,1)
+   6: osp nopl 0x00(%eax,%eax,1)
+   7: nopl 0x(%eax)
+   8: nopl 0x(%eax,%eax,1)
+*/
 #define P6_NOP1GENERIC_NOP1
 #define P6_NOP2.byte 0x66,0x90\n
 #define P6_NOP3.byte 0x0f,0x1f,0x00\n
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


x86: rename KERNEL_TEXT_SIZE = KERNEL_IMAGE_SIZE

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=d4afe414189b098d56bcd24280c018aa2ac9a990
Commit: d4afe414189b098d56bcd24280c018aa2ac9a990
Parent: 88f3aec7afd9ae3e6f6d221801996b69aad1e3a4
Author: Ingo Molnar [EMAIL PROTECTED]
AuthorDate: Thu Feb 21 13:39:30 2008 +0100
Committer:  Ingo Molnar [EMAIL PROTECTED]
CommitDate: Tue Feb 26 12:55:56 2008 +0100

x86: rename KERNEL_TEXT_SIZE = KERNEL_IMAGE_SIZE

The KERNEL_TEXT_SIZE constant was mis-named, as we not only map the kernel
text but data, bss and init sections as well.

That name led me on the wrong path with the KERNEL_TEXT_SIZE regression,
because i knew how big of _text_ my images have and i knew about the 40 MB
text limit so i wrongly thought to be on the safe side of the 40 MB limit
with my 29 MB of text, while the total image size was slightly above 40 MB.

Signed-off-by: Ingo Molnar [EMAIL PROTECTED]
---
 arch/x86/kernel/head_64.S |2 +-
 include/asm-x86/page_64.h |4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
index b037b15..a007454 100644
--- a/arch/x86/kernel/head_64.S
+++ b/arch/x86/kernel/head_64.S
@@ -393,7 +393,7 @@ NEXT_PAGE(level2_kernel_pgt)
 *  too.)
 */
PMDS(0, __PAGE_KERNEL_LARGE_EXEC|_PAGE_GLOBAL,
-   KERNEL_TEXT_SIZE/PMD_SIZE)
+   KERNEL_IMAGE_SIZE/PMD_SIZE)
 
 NEXT_PAGE(level2_spare_pgt)
.fill   512, 8, 0
diff --git a/include/asm-x86/page_64.h b/include/asm-x86/page_64.h
index 3e2e3ca..1435460 100644
--- a/include/asm-x86/page_64.h
+++ b/include/asm-x86/page_64.h
@@ -51,8 +51,8 @@
  * Kernel image size is limited to 128 MB (see level2_kernel_pgt in
  * arch/x86/kernel/head_64.S), and it is mapped here:
  */
-#define KERNEL_TEXT_SIZE   (128*1024*1024)
-#define KERNEL_TEXT_START  _AC(0x8000, UL)
+#define KERNEL_IMAGE_SIZE  (128*1024*1024)
+#define KERNEL_IMAGE_START _AC(0x8000, UL)
 
 #ifndef __ASSEMBLY__
 void clear_page(void *page);
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


x86: fix vsyscall wreckage

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=ce28b9864b853803320c3f1d8de1b81aa4120b14
Commit: ce28b9864b853803320c3f1d8de1b81aa4120b14
Parent: d4afe414189b098d56bcd24280c018aa2ac9a990
Author: Thomas Gleixner [EMAIL PROTECTED]
AuthorDate: Wed Feb 20 23:57:30 2008 +0100
Committer:  Ingo Molnar [EMAIL PROTECTED]
CommitDate: Tue Feb 26 12:55:57 2008 +0100

x86: fix vsyscall wreckage

based on a report from Arne Georg Gleditsch about user-space apps
misbehaving after toggling /proc/sys/kernel/vsyscall64, a review
of the code revealed that the NOP patching done there is
fundamentally unsafe for a number of reasons:

1) the patching code runs without synchronizing other CPUs

2) it inserts NOPs even if there is no clock source which provides vread

3) when the clock source changes to one without vread we run in
   exactly the same problem as in #2

4) if nobody toggles the proc entry from 1 to 0 and to 1 again, then
   the syscall is not patched out

as a result it is possible to break user-space via this patching.
The only safe thing for now is to remove the patching.

This code was broken since v2.6.21.

Reported-by: Arne Georg Gleditsch [EMAIL PROTECTED]
Signed-off-by: Thomas Gleixner [EMAIL PROTECTED]
Signed-off-by: Ingo Molnar [EMAIL PROTECTED]
---
 arch/x86/kernel/vsyscall_64.c |   52 ++--
 1 files changed, 3 insertions(+), 49 deletions(-)

diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
index 3f82427..b6be812 100644
--- a/arch/x86/kernel/vsyscall_64.c
+++ b/arch/x86/kernel/vsyscall_64.c
@@ -44,11 +44,6 @@
 
 #define __vsyscall(nr) __attribute__ ((unused,__section__(.vsyscall_ #nr)))
 #define __syscall_clobber r11,cx,memory
-#define __pa_vsymbol(x)\
-   ({unsigned long v;  \
-   extern char __vsyscall_0;   \
- asm( : =r (v) : 0 (x)); \
- ((v - VSYSCALL_START) + __pa_symbol(__vsyscall_0)); })
 
 /*
  * vsyscall_gtod_data contains data that is :
@@ -102,7 +97,7 @@ static __always_inline void do_get_tz(struct timezone * tz)
 static __always_inline int gettimeofday(struct timeval *tv, struct timezone 
*tz)
 {
int ret;
-   asm volatile(vsysc2: syscall
+   asm volatile(syscall
: =a (ret)
: 0 (__NR_gettimeofday),D (tv),S (tz)
: __syscall_clobber );
@@ -112,7 +107,7 @@ static __always_inline int gettimeofday(struct timeval *tv, 
struct timezone *tz)
 static __always_inline long time_syscall(long *t)
 {
long secs;
-   asm volatile(vsysc1: syscall
+   asm volatile(syscall
: =a (secs)
: 0 (__NR_time),D (t) : __syscall_clobber);
return secs;
@@ -227,50 +222,10 @@ long __vsyscall(3) venosys_1(void)
 }
 
 #ifdef CONFIG_SYSCTL
-
-#define SYSCALL 0x050f
-#define NOP20x9090
-
-/*
- * NOP out syscall in vsyscall page when not needed.
- */
-static int vsyscall_sysctl_change(ctl_table *ctl, int write, struct file * 
filp,
-void __user *buffer, size_t *lenp, loff_t *ppos)
-{
-   extern u16 vsysc1, vsysc2;
-   u16 __iomem *map1;
-   u16 __iomem *map2;
-   int ret = proc_dointvec(ctl, write, filp, buffer, lenp, ppos);
-   if (!write)
-   return ret;
-   /* gcc has some trouble with __va(__pa()), so just do it this
-  way. */
-   map1 = ioremap(__pa_vsymbol(vsysc1), 2);
-   if (!map1)
-   return -ENOMEM;
-   map2 = ioremap(__pa_vsymbol(vsysc2), 2);
-   if (!map2) {
-   ret = -ENOMEM;
-   goto out;
-   }
-   if (!vsyscall_gtod_data.sysctl_enabled) {
-   writew(SYSCALL, map1);
-   writew(SYSCALL, map2);
-   } else {
-   writew(NOP2, map1);
-   writew(NOP2, map2);
-   }
-   iounmap(map2);
-out:
-   iounmap(map1);
-   return ret;
-}
-
 static ctl_table kernel_table2[] = {
{ .procname = vsyscall64,
  .data = vsyscall_gtod_data.sysctl_enabled, .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = vsyscall_sysctl_change },
+ .mode = 0644 },
{}
 };
 
@@ -279,7 +234,6 @@ static ctl_table kernel_root_table2[] = {
  .child = kernel_table2 },
{}
 };
-
 #endif
 
 /* Assume __initcall executes before all user space. Hopefully kmod
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


x86: fix execve with -fstack-protect

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=5d119b2c9a490e2d647eae134211b32a18a04c7d
Commit: 5d119b2c9a490e2d647eae134211b32a18a04c7d
Parent: ce28b9864b853803320c3f1d8de1b81aa4120b14
Author: Ingo Molnar [EMAIL PROTECTED]
AuthorDate: Tue Feb 26 12:55:57 2008 +0100
Committer:  Ingo Molnar [EMAIL PROTECTED]
CommitDate: Tue Feb 26 12:55:57 2008 +0100

x86: fix execve with -fstack-protect

pointed out by [EMAIL PROTECTED]:

 what happens here is that gcc treats the argument area as owned by the
 callee, not the caller and is allowed to do certain tricks. for ssp it
 will make a copy of the struct passed by value into the local variable
 area and pass *its* address down, and it won't copy it back into the
 original instance stored in the argument area.

 so once sys_execve returns, the pt_regs passed by value hasn't at all
 changed and its default content will cause a nice double fault (FWIW,
 this part took me the longest to debug, being down with cold didn't
 help it either ;).

To fix this we pass in pt_regs by pointer.

Signed-off-by: Ingo Molnar [EMAIL PROTECTED]
Signed-off-by: Thomas Gleixner [EMAIL PROTECTED]
---
 arch/x86/kernel/entry_64.S   |6 --
 arch/x86/kernel/process_64.c |6 +++---
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 2ad9a1b..c20c9e7 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -453,6 +453,7 @@ ENTRY(stub_execve)
CFI_REGISTER rip, r11
SAVE_REST
FIXUP_TOP_OF_STACK %r11
+   movq %rsp, %rcx
call sys_execve
RESTORE_TOP_OF_STACK %r11
movq %rax,RAX(%rsp)
@@ -1036,15 +1037,16 @@ ENDPROC(child_rip)
  * rdi: name, rsi: argv, rdx: envp
  *
  * We want to fallback into:
- * extern long sys_execve(char *name, char **argv,char **envp, struct 
pt_regs regs)
+ * extern long sys_execve(char *name, char **argv,char **envp, struct 
pt_regs *regs)
  *
  * do_sys_execve asm fallback arguments:
- * rdi: name, rsi: argv, rdx: envp, fake frame on the stack
+ * rdi: name, rsi: argv, rdx: envp, rcx: fake frame on the stack
  */
 ENTRY(kernel_execve)
CFI_STARTPROC
FAKE_STACK_FRAME $0
SAVE_ALL
+   movq %rsp,%rcx
call sys_execve
movq %rax, RAX(%rsp)
RESTORE_REST
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index b0cc8f0..43f2877 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -730,16 +730,16 @@ __switch_to(struct task_struct *prev_p, struct 
task_struct *next_p)
  */
 asmlinkage
 long sys_execve(char __user *name, char __user * __user *argv,
-   char __user * __user *envp, struct pt_regs regs)
+   char __user * __user *envp, struct pt_regs *regs)
 {
long error;
char * filename;
 
filename = getname(name);
error = PTR_ERR(filename);
-   if (IS_ERR(filename)) 
+   if (IS_ERR(filename))
return error;
-   error = do_execve(filename, argv, envp, regs); 
+   error = do_execve(filename, argv, envp, regs);
putname(filename);
return error;
 }
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


x86: don't print a warning when MTRR are blank and running in KVM

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=4147c8747eace9058c606b35e700060297edaf91
Commit: 4147c8747eace9058c606b35e700060297edaf91
Parent: 5d119b2c9a490e2d647eae134211b32a18a04c7d
Author: Joerg Roedel [EMAIL PROTECTED]
AuthorDate: Thu Feb 21 15:50:14 2008 +0100
Committer:  Ingo Molnar [EMAIL PROTECTED]
CommitDate: Tue Feb 26 12:55:57 2008 +0100

x86: don't print a warning when MTRR are blank and running in KVM

Inside a KVM virtual machine the MTRRs are usually blank. This confuses 
Linux
and causes a warning message at boot. This patch removes that warning 
message
when running Linux as a KVM guest.

Signed-off-by: Joerg Roedel [EMAIL PROTECTED]
Signed-off-by: Ingo Molnar [EMAIL PROTECTED]
---
 arch/x86/kernel/cpu/mtrr/main.c |8 ++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
index c8fda3e..be83336 100644
--- a/arch/x86/kernel/cpu/mtrr/main.c
+++ b/arch/x86/kernel/cpu/mtrr/main.c
@@ -43,6 +43,7 @@
 #include asm/uaccess.h
 #include asm/processor.h
 #include asm/msr.h
+#include asm/kvm_para.h
 #include mtrr.h
 
 u32 num_var_ranges = 0;
@@ -689,8 +690,11 @@ int __init mtrr_trim_uncached_memory(unsigned long end_pfn)
 
/* kvm/qemu doesn't have mtrr set right, don't trim them all */
if (!highest_pfn) {
-   printk(KERN_WARNING WARNING: strange, CPU MTRRs all blank?\n);
-   WARN_ON(1);
+   if (!kvm_para_available()) {
+   printk(KERN_WARNING
+   WARNING: strange, CPU MTRRs all blank?\n);
+   WARN_ON(1);
+   }
return 0;
}
 
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


x86: don't save unreliable stack trace entries

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=1650743cdc0db73478f72c57544ce79ea8f3dda6
Commit: 1650743cdc0db73478f72c57544ce79ea8f3dda6
Parent: ed2b7e2b1d1ae201afe8fbd111632074b7b53ed4
Author: Vegard Nossum [EMAIL PROTECTED]
AuthorDate: Fri Feb 22 19:23:58 2008 +0100
Committer:  Ingo Molnar [EMAIL PROTECTED]
CommitDate: Tue Feb 26 12:55:58 2008 +0100

x86: don't save unreliable stack trace entries

Currently, there is no way for print_stack_trace() to determine whether
a given stack trace entry was deemed reliable or not, simply because
save_stack_trace() does not record this information. (Perhaps needless
to say, this makes the saved stack traces A LOT harder to read, and
probably with no other benefits, since debugging features that use
save_stack_trace() most likely also require frame pointers, etc.)

This patch reverts to the old behaviour of only recording the reliable trace
entries for saved stack traces.

Signed-off-by: Vegard Nossum [EMAIL PROTECTED]
Acked-by: Arjan van de Ven [EMAIL PROTECTED]
Signed-off-by: Ingo Molnar [EMAIL PROTECTED]
---
 arch/x86/kernel/stacktrace.c |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/stacktrace.c b/arch/x86/kernel/stacktrace.c
index 02f0f61..c28c342 100644
--- a/arch/x86/kernel/stacktrace.c
+++ b/arch/x86/kernel/stacktrace.c
@@ -25,6 +25,8 @@ static int save_stack_stack(void *data, char *name)
 static void save_stack_address(void *data, unsigned long addr, int reliable)
 {
struct stack_trace *trace = data;
+   if (!reliable)
+   return;
if (trace-skip  0) {
trace-skip--;
return;
@@ -37,6 +39,8 @@ static void
 save_stack_address_nosched(void *data, unsigned long addr, int reliable)
 {
struct stack_trace *trace = (struct stack_trace *)data;
+   if (!reliable)
+   return;
if (in_sched_functions(addr))
return;
if (trace-skip  0) {
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


x86: make c_idle.work have a static address.

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=2b775a27c0d9fdf8078d5b31e1e27411e5bf2a91
Commit: 2b775a27c0d9fdf8078d5b31e1e27411e5bf2a91
Parent: 1650743cdc0db73478f72c57544ce79ea8f3dda6
Author: Glauber Costa [EMAIL PROTECTED]
AuthorDate: Fri Feb 22 12:09:29 2008 -0300
Committer:  Ingo Molnar [EMAIL PROTECTED]
CommitDate: Tue Feb 26 12:56:02 2008 +0100

x86: make c_idle.work have a static address.

Currently, c_idle is declared in the stack, and thus, have no static 
address.

Peter Zijlstra points out this simple solution, in which c_idle.work
is initializated separatedly. Note that the INIT_WORK macro has a static
declaration of a key inside.

Signed-off-by: Glauber Costa [EMAIL PROTECTED]
Acked-by: Peter Zijlstra [EMAIL PROTECTED]
Signed-off-by: Ingo Molnar [EMAIL PROTECTED]
---
 arch/x86/kernel/smpboot_64.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/smpboot_64.c b/arch/x86/kernel/smpboot_64.c
index d53bd6f..0880f2c 100644
--- a/arch/x86/kernel/smpboot_64.c
+++ b/arch/x86/kernel/smpboot_64.c
@@ -554,10 +554,10 @@ static int __cpuinit do_boot_cpu(int cpu, int apicid)
int timeout;
unsigned long start_rip;
struct create_idle c_idle = {
-   .work = __WORK_INITIALIZER(c_idle.work, do_fork_idle),
.cpu = cpu,
.done = COMPLETION_INITIALIZER_ONSTACK(c_idle.done),
};
+   INIT_WORK(c_idle.work, do_fork_idle);
 
/* allocate memory for gdts of secondary cpus. Hotplug is considered */
if (!cpu_gdt_descr[cpu].address 
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


x86: fix build on non-C locales.

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=03994f01e8b72b3d01fd3d09d1cc7c9f421a727c
Commit: 03994f01e8b72b3d01fd3d09d1cc7c9f421a727c
Parent: 2b775a27c0d9fdf8078d5b31e1e27411e5bf2a91
Author: Priit Laes [EMAIL PROTECTED]
AuthorDate: Sun Feb 24 18:36:05 2008 +0200
Committer:  Ingo Molnar [EMAIL PROTECTED]
CommitDate: Tue Feb 26 12:56:02 2008 +0100

x86: fix build on non-C locales.

For some locales regex range [a-zA-Z] does not work as it is supposed to.
so we have to use [:alnum:] and [:xdigit:] to make it work as intended.

[1] http://en.wikipedia.org/wiki/Estonian_alphabet

Signed-off-by: Ingo Molnar [EMAIL PROTECTED]
---
 arch/x86/vdso/Makefile |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
index f385a4b..b8bd0c4 100644
--- a/arch/x86/vdso/Makefile
+++ b/arch/x86/vdso/Makefile
@@ -48,7 +48,7 @@ obj-$(VDSO64-y)   += vdso-syms.lds
 # Match symbols in the DSO that look like VDSO*; produce a file of constants.
 #
 sed-vdsosym := -e 's/^00*/0/' \
-   -e 's/^\([0-9a-fA-F]*\) . \(VDSO[a-zA-Z0-9_]*\)$$/\2 = 0x\1;/p'
+   -e 's/^\([[:xdigit:]]*\) . \(VDSO[[:alnum:]_]*\)$$/\2 = 0x\1;/p'
 quiet_cmd_vdsosym = VDSOSYM $@
   cmd_vdsosym = $(NM) $ | sed -n $(sed-vdsosym) | LC_ALL=C sort  $@
 
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


x86: fix boot failure on 486 due to TSC breakage

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=12c247a6719987aad65f83158d2bb3e73c75c1f5
Commit: 12c247a6719987aad65f83158d2bb3e73c75c1f5
Parent: 03994f01e8b72b3d01fd3d09d1cc7c9f421a727c
Author: Mikael Pettersson [EMAIL PROTECTED]
AuthorDate: Sun Feb 24 18:27:03 2008 +0100
Committer:  Ingo Molnar [EMAIL PROTECTED]
CommitDate: Tue Feb 26 12:56:04 2008 +0100

x86: fix boot failure on 486 due to TSC breakage

  Diffing dmesg between git7 and git8 doesn't sched any light since
  git8 also removed the printouts of the x86 caps as they were being
  initialised and updated. I'm currently adding those printouts back
  in the hope of seeing where and when the caps get broken.

That turned out to be very illuminating:

 --- dmesg-2.6.24-git7  2008-02-24 18:01:25.295851000 +0100
 +++ dmesg-2.6.24-git8  2008-02-24 18:01:25.530358000 +0100
 ...
 CPU: After generic identify, caps: 0003    
   

 CPU: After all inits, caps: 0003     
  
+CPU: After applying cleared_cpu_caps, caps: 0013   
    

Notice how the TSC cap bit goes from Off to On.

(The first two lines are printout loops from -git7 forward-ported
to -git8, the third line is the same printout loop added just after
the xor-with-cleared_cpu_caps[] loop.)

Here's how the breakage occurs:
1. arch/x86/kernel/tsc_32.c:tsc_init() sees !cpu_has_tsc,
   so bails and calls setup_clear_cpu_cap(X86_FEATURE_TSC).
2. include/asm-x86/cpufeature.h:setup_clear_cpu_cap(bit) clears
   the bit in boot_cpu_data and sets it in cleared_cpu_caps
3. arch/x86/kernel/cpu/common.c:identify_cpu() XORs all caps
   in with cleared_cpu_caps
   HOWEVER, at this point c-x86_capability correctly has TSC
   Off, cleared_cpu_caps has TSC On, so the XOR incorrectly
   sets TSC to On in c-x86_capability, with disastrous results.

The real bug is that clearing bits with XOR only works if the
bits are known to be 1 prior to the XOR, and that's not true here.

A simple fix is to convert the XOR to AND-NOT instead. The following
patch does that, and allows my 486 to boot 2.6.25-rc kernels again.

[ [EMAIL PROTECTED]: fixed a similar bug in setup_64.c as well. ]

The breakage was introduced via commit 7d851c8d3db0.

Signed-off-by: Mikael Pettersson [EMAIL PROTECTED]
Signed-off-by: Ingo Molnar [EMAIL PROTECTED]
---
 arch/x86/kernel/cpu/common.c |2 +-
 arch/x86/kernel/setup_64.c   |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index f86a3c4..a38aafa 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -504,7 +504,7 @@ void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
 
/* Clear all flags overriden by options */
for (i = 0; i  NCAPINTS; i++)
-   c-x86_capability[i] ^= cleared_cpu_caps[i];
+   c-x86_capability[i] = ~cleared_cpu_caps[i];
 
/* Init Machine Check Exception if available. */
mcheck_init(c);
diff --git a/arch/x86/kernel/setup_64.c b/arch/x86/kernel/setup_64.c
index 6fd804f..7637dc9 100644
--- a/arch/x86/kernel/setup_64.c
+++ b/arch/x86/kernel/setup_64.c
@@ -1021,7 +1021,7 @@ void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
 
/* Clear all flags overriden by options */
for (i = 0; i  NCAPINTS; i++)
-   c-x86_capability[i] ^= cleared_cpu_caps[i];
+   c-x86_capability[i] = ~cleared_cpu_caps[i];
 
 #ifdef CONFIG_X86_MCE
mcheck_init(c);
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


x86: no robust/pi futex for real i386 CPUs

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=f18edc95a37a901ffcbe91f5e05105f916a04fae
Commit: f18edc95a37a901ffcbe91f5e05105f916a04fae
Parent: 12c247a6719987aad65f83158d2bb3e73c75c1f5
Author: Thomas Gleixner [EMAIL PROTECTED]
AuthorDate: Sat Feb 16 14:05:01 2008 +0100
Committer:  Ingo Molnar [EMAIL PROTECTED]
CommitDate: Tue Feb 26 12:56:06 2008 +0100

x86: no robust/pi futex for real i386 CPUs

Real i386 CPUs do not have cmpxchg instructions. Catch it before
crashing on an invalid opcode.

Signed-off-by: Ingo Molnar [EMAIL PROTECTED]
Signed-off-by: Thomas Gleixner [EMAIL PROTECTED]
---
 include/asm-x86/futex.h |7 +++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/include/asm-x86/futex.h b/include/asm-x86/futex.h
index cd9f894..c9952ea 100644
--- a/include/asm-x86/futex.h
+++ b/include/asm-x86/futex.h
@@ -102,6 +102,13 @@ futex_atomic_op_inuser(int encoded_op, int __user *uaddr)
 static inline int
 futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval)
 {
+
+#if defined(CONFIG_X86_32)  !defined(CONFIG_X86_BSWAP)
+   /* Real i386 machines have no cmpxchg instruction */
+   if (boot_cpu_data.x86 == 3)
+   return -ENOSYS;
+#endif
+
if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int)))
return -EFAULT;
 
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


firewire: fw-sbp2: unsigned int vs. unsigned

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=05cca7381429e12d66c5b5c8b5c5848055b88bf7
Commit: 05cca7381429e12d66c5b5c8b5c5848055b88bf7
Parent: 19af35546de68c872dcb687613e0902a602cb20e
Author: Stefan Richter [EMAIL PROTECTED]
AuthorDate: Sat Jan 26 17:42:45 2008 +0100
Committer:  Stefan Richter [EMAIL PROTECTED]
CommitDate: Sat Feb 16 15:40:32 2008 +0100

firewire: fw-sbp2: unsigned int vs. unsigned

Standardize on unsigned int style.
Sort some struct members thematically.

Signed-off-by: Stefan Richter [EMAIL PROTECTED]
---
 drivers/firewire/fw-sbp2.c |   14 ++
 1 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/firewire/fw-sbp2.c b/drivers/firewire/fw-sbp2.c
index 19ece9b..f2a9a33 100644
--- a/drivers/firewire/fw-sbp2.c
+++ b/drivers/firewire/fw-sbp2.c
@@ -141,15 +141,13 @@ struct sbp2_logical_unit {
 struct sbp2_target {
struct kref kref;
struct fw_unit *unit;
+   struct list_head lu_list;
 
u64 management_agent_address;
int directory_id;
int node_id;
int address_high;
-
-   unsigned workarounds;
-   struct list_head lu_list;
-
+   unsigned int workarounds;
unsigned int mgt_orb_timeout;
 };
 
@@ -160,7 +158,7 @@ struct sbp2_target {
  */
 #define SBP2_MIN_LOGIN_ORB_TIMEOUT 5000U   /* Timeout in ms */
 #define SBP2_MAX_LOGIN_ORB_TIMEOUT 4U  /* Timeout in ms */
-#define SBP2_ORB_TIMEOUT   2000/* Timeout in ms */
+#define SBP2_ORB_TIMEOUT   2000U   /* Timeout in ms */
 #define SBP2_ORB_NULL  0x8000
 #define SBP2_MAX_SG_ELEMENT_LENGTH 0xf000
 
@@ -297,7 +295,7 @@ struct sbp2_command_orb {
 static const struct {
u32 firmware_revision;
u32 model;
-   unsigned workarounds;
+   unsigned int workarounds;
 } sbp2_workarounds_table[] = {
/* DViCO Momobay CX-1 with TSB42AA9 bridge */ {
.firmware_revision  = 0x002800,
@@ -836,7 +834,7 @@ static void sbp2_init_workarounds(struct sbp2_target *tgt, 
u32 model,
  u32 firmware_revision)
 {
int i;
-   unsigned w = sbp2_param_workarounds;
+   unsigned int w = sbp2_param_workarounds;
 
if (w)
fw_notify(Please notify [EMAIL PROTECTED] 
@@ -1197,7 +1195,7 @@ static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, 
scsi_done_fn_t done)
struct sbp2_logical_unit *lu = cmd-device-hostdata;
struct fw_device *device = fw_device(lu-tgt-unit-device.parent);
struct sbp2_command_orb *orb;
-   unsigned max_payload;
+   unsigned int max_payload;
int retval = SCSI_MLQUEUE_HOST_BUSY;
 
/*
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


firewire: fw-sbp2: fix logout before login retry

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=1b9c12ba2fdf802a23630f70eddb0e821296634e
Commit: 1b9c12ba2fdf802a23630f70eddb0e821296634e
Parent: 05cca7381429e12d66c5b5c8b5c5848055b88bf7
Author: Stefan Richter [EMAIL PROTECTED]
AuthorDate: Sat Jan 26 17:43:23 2008 +0100
Committer:  Stefan Richter [EMAIL PROTECTED]
CommitDate: Sat Feb 16 15:40:32 2008 +0100

firewire: fw-sbp2: fix logout before login retry

This fixes a can't recognize device kind of bug.

If the SCSI INQUIRY failed and hence __scsi_add_device failed due to a
bus reset, we tried a logout and then waited for the already scheduled
login work to happen.  So far so good, but the generation used for the
logout was outdated, hence the logout never reached the target.  The
target might therefore deny the subsequent relogin attempt, which would
also leave the target inaccessible.

Therefore fetch a fresh device-generation for the logout.  Use memory
barriers to prevent our plan being foiled by compiler or hardware
optimizations.

Signed-off-by: Stefan Richter [EMAIL PROTECTED]
---
 drivers/firewire/fw-sbp2.c |6 +-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/drivers/firewire/fw-sbp2.c b/drivers/firewire/fw-sbp2.c
index f2a9a33..a15e3c7 100644
--- a/drivers/firewire/fw-sbp2.c
+++ b/drivers/firewire/fw-sbp2.c
@@ -716,7 +716,11 @@ static void sbp2_login(struct work_struct *work)
sdev = __scsi_add_device(shost, 0, 0,
 scsilun_to_int(eight_bytes_lun), lu);
if (IS_ERR(sdev)) {
-   sbp2_send_management_orb(lu, node_id, generation,
+   smp_rmb(); /* generation may have changed */
+   generation = device-generation;
+   smp_rmb(); /* node_id must not be older than generation */
+
+   sbp2_send_management_orb(lu, device-node_id, generation,
SBP2_LOGOUT_REQUEST, lu-login_id, NULL);
/*
 * Set this back to sbp2_login so we fall back and
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


firewire: fix kobject_add failed for fw* with -EEXIST

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=96b19062e741b715cf399312c30e0672d8889569
Commit: 96b19062e741b715cf399312c30e0672d8889569
Parent: 1b9c12ba2fdf802a23630f70eddb0e821296634e
Author: Stefan Richter [EMAIL PROTECTED]
AuthorDate: Sat Feb 2 15:01:09 2008 +0100
Committer:  Stefan Richter [EMAIL PROTECTED]
CommitDate: Sat Feb 16 15:40:33 2008 +0100

firewire: fix kobject_add failed for fw* with -EEXIST

There is a race between shutdown and creation of devices:  fw-core may
attempt to add a device with the same name of an already existing
device.  http://bugzilla.kernel.org/show_bug.cgi?id=9828

Impact of the bug:  Happens rarely (when shutdown of a device coincides
with creation of another), forces the user to unplug and replug the new
device to get it working.

The fix is obvious:  Free the minor number *after* instead of *before*
device_unregister().  This requires to take an additional reference of
the fw_device as long as the IDR tree points to it.

And while we are at it, we fix an additional race condition:
fw_device_op_open() took its reference of the fw_device a little bit too
late, hence was in danger to access an already invalid fw_device.

Signed-off-by: Stefan Richter [EMAIL PROTECTED]
---
 drivers/firewire/fw-cdev.c   |8 +---
 drivers/firewire/fw-device.c |   20 ++--
 drivers/firewire/fw-device.h |2 +-
 3 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/drivers/firewire/fw-cdev.c b/drivers/firewire/fw-cdev.c
index 7e73cba..44ccee2 100644
--- a/drivers/firewire/fw-cdev.c
+++ b/drivers/firewire/fw-cdev.c
@@ -109,15 +109,17 @@ static int fw_device_op_open(struct inode *inode, struct 
file *file)
struct client *client;
unsigned long flags;
 
-   device = fw_device_from_devt(inode-i_rdev);
+   device = fw_device_get_by_devt(inode-i_rdev);
if (device == NULL)
return -ENODEV;
 
client = kzalloc(sizeof(*client), GFP_KERNEL);
-   if (client == NULL)
+   if (client == NULL) {
+   fw_device_put(device);
return -ENOMEM;
+   }
 
-   client-device = fw_device_get(device);
+   client-device = device;
INIT_LIST_HEAD(client-event_list);
INIT_LIST_HEAD(client-resource_list);
spin_lock_init(client-lock);
diff --git a/drivers/firewire/fw-device.c b/drivers/firewire/fw-device.c
index de9066e..c04c288 100644
--- a/drivers/firewire/fw-device.c
+++ b/drivers/firewire/fw-device.c
@@ -610,12 +610,14 @@ static DECLARE_RWSEM(idr_rwsem);
 static DEFINE_IDR(fw_device_idr);
 int fw_cdev_major;
 
-struct fw_device *fw_device_from_devt(dev_t devt)
+struct fw_device *fw_device_get_by_devt(dev_t devt)
 {
struct fw_device *device;
 
down_read(idr_rwsem);
device = idr_find(fw_device_idr, MINOR(devt));
+   if (device)
+   fw_device_get(device);
up_read(idr_rwsem);
 
return device;
@@ -627,13 +629,14 @@ static void fw_device_shutdown(struct work_struct *work)
container_of(work, struct fw_device, work.work);
int minor = MINOR(device-device.devt);
 
-   down_write(idr_rwsem);
-   idr_remove(fw_device_idr, minor);
-   up_write(idr_rwsem);
-
fw_device_cdev_remove(device);
device_for_each_child(device-device, NULL, shutdown_unit);
device_unregister(device-device);
+
+   down_write(idr_rwsem);
+   idr_remove(fw_device_idr, minor);
+   up_write(idr_rwsem);
+   fw_device_put(device);
 }
 
 static struct device_type fw_device_type = {
@@ -682,10 +685,13 @@ static void fw_device_init(struct work_struct *work)
}
 
err = -ENOMEM;
+
+   fw_device_get(device);
down_write(idr_rwsem);
if (idr_pre_get(fw_device_idr, GFP_KERNEL))
err = idr_get_new(fw_device_idr, device, minor);
up_write(idr_rwsem);
+
if (err  0)
goto error;
 
@@ -741,7 +747,9 @@ static void fw_device_init(struct work_struct *work)
idr_remove(fw_device_idr, minor);
up_write(idr_rwsem);
  error:
-   put_device(device-device);
+   fw_device_put(device);  /* fw_device_idr's reference */
+
+   put_device(device-device);/* our reference */
 }
 
 static int update_unit(struct device *dev, void *data)
diff --git a/drivers/firewire/fw-device.h b/drivers/firewire/fw-device.h
index 0854fe2..43808c0 100644
--- a/drivers/firewire/fw-device.h
+++ b/drivers/firewire/fw-device.h
@@ -77,13 +77,13 @@ fw_device_is_shutdown(struct fw_device *device)
 }
 
 struct fw_device *fw_device_get(struct fw_device *device);
+struct fw_device *fw_device_get_by_devt(dev_t devt);
 void fw_device_put(struct fw_device *device);
 int fw_device_enable_phys_dma(struct fw_device *device);
 
 void fw_device_cdev_update(struct fw_device *device);
 void 

firewire: log GUID of new devices

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=fa6e697b85d705d37b3b03829095c22bcbe95ab6
Commit: fa6e697b85d705d37b3b03829095c22bcbe95ab6
Parent: be6f48b0174584c9c415012ca14803c7e941e27e
Author: Stefan Richter [EMAIL PROTECTED]
AuthorDate: Sun Feb 3 23:03:00 2008 +0100
Committer:  Stefan Richter [EMAIL PROTECTED]
CommitDate: Sat Feb 16 15:40:34 2008 +0100

firewire: log GUID of new devices

This should help to interpret user reports.  E.g. one can look up the
vendor OUI (first three bytes of the GUID) and thus tell what is what.

Also simplifies the math in the GUID sysfs attribute.

Signed-off-by: Stefan Richter [EMAIL PROTECTED]
Signed-off-by: Jarod Wilson [EMAIL PROTECTED]
---
 drivers/firewire/fw-device.c |   28 +---
 1 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/drivers/firewire/fw-device.c b/drivers/firewire/fw-device.c
index c04c288..2ab13e0 100644
--- a/drivers/firewire/fw-device.c
+++ b/drivers/firewire/fw-device.c
@@ -358,12 +358,9 @@ static ssize_t
 guid_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
struct fw_device *device = fw_device(dev);
-   u64 guid;
 
-   guid = ((u64)device-config_rom[3]  32) | device-config_rom[4];
-
-   return snprintf(buf, PAGE_SIZE, 0x%016llx\n,
-   (unsigned long long)guid);
+   return snprintf(buf, PAGE_SIZE, 0x%08x%08x\n,
+   device-config_rom[3], device-config_rom[4]);
 }
 
 static struct device_attribute fw_device_attributes[] = {
@@ -723,13 +720,22 @@ static void fw_device_init(struct work_struct *work)
 */
if (atomic_cmpxchg(device-state,
FW_DEVICE_INITIALIZING,
-   FW_DEVICE_RUNNING) == FW_DEVICE_SHUTDOWN)
+   FW_DEVICE_RUNNING) == FW_DEVICE_SHUTDOWN) {
fw_device_shutdown(device-work.work);
-   else
-   fw_notify(created new fw device %s 
- (%d config rom retries, S%d00)\n,
- device-device.bus_id, device-config_rom_retries,
- 1  device-max_speed);
+   } else {
+   if (device-config_rom_retries)
+   fw_notify(created device %s: GUID %08x%08x, S%d00, 
+ %d config ROM retries\n,
+ device-device.bus_id,
+ device-config_rom[3], device-config_rom[4],
+ 1  device-max_speed,
+ device-config_rom_retries);
+   else
+   fw_notify(created device %s: GUID %08x%08x, S%d00\n,
+ device-device.bus_id,
+ device-config_rom[3], device-config_rom[4],
+ 1  device-max_speed);
+   }
 
/*
 * Reschedule the IRM work if we just finished reading the
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


firewire: fw-sbp2: add INQUIRY delay workaround

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=9220f1946209a5b3335ea2d28f8462695885791b
Commit: 9220f1946209a5b3335ea2d28f8462695885791b
Parent: fa6e697b85d705d37b3b03829095c22bcbe95ab6
Author: Stefan Richter [EMAIL PROTECTED]
AuthorDate: Sun Feb 3 23:04:38 2008 +0100
Committer:  Stefan Richter [EMAIL PROTECTED]
CommitDate: Sat Feb 16 15:40:34 2008 +0100

firewire: fw-sbp2: add INQUIRY delay workaround

Several different SBP-2 bridges accept a login early while the IDE
device is still powering up.  They are therefore unable to respond to
SCSI INQUIRY immediately, and the SCSI core has to retry the INQUIRY.
One of these retries is typically successful, and all is well.

But in case of Momobay FX-3A, the INQUIRY retries tend to fail entirely.
This can usually be avoided by waiting a little while after login before
letting the SCSI core send the INQUIRY.  The old sbp2 driver handles
this more gracefully for as yet unknown reasons (perhaps because it
waits for fetch agent resets to complete, unlike fw-sbp2 which quickly
proceeds after requesting the agent reset).  Therefore the workaround is
not as much necessary for sbp2.

Signed-off-by: Stefan Richter [EMAIL PROTECTED]
Signed-off-by: Jarod Wilson [EMAIL PROTECTED]
---
 drivers/firewire/fw-sbp2.c |   15 +++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/drivers/firewire/fw-sbp2.c b/drivers/firewire/fw-sbp2.c
index 72fddf5..4a118fb 100644
--- a/drivers/firewire/fw-sbp2.c
+++ b/drivers/firewire/fw-sbp2.c
@@ -32,6 +32,7 @@
 #include linux/module.h
 #include linux/moduleparam.h
 #include linux/mod_devicetable.h
+#include linux/delay.h
 #include linux/device.h
 #include linux/scatterlist.h
 #include linux/dma-mapping.h
@@ -82,6 +83,9 @@ MODULE_PARM_DESC(exclusive_login, Exclusive login to sbp2 
device 
  *   Avoids access beyond actual disk limits on devices with an off-by-one bug.
  *   Don't use this with devices which don't have this bug.
  *
+ * - delay inquiry
+ *   Wait extra SBP2_INQUIRY_DELAY seconds after login before SCSI inquiry.
+ *
  * - override internal blacklist
  *   Instead of adding to the built-in blacklist, use only the workarounds
  *   specified in the module load parameter.
@@ -91,6 +95,8 @@ MODULE_PARM_DESC(exclusive_login, Exclusive login to sbp2 
device 
 #define SBP2_WORKAROUND_INQUIRY_36 0x2
 #define SBP2_WORKAROUND_MODE_SENSE_8   0x4
 #define SBP2_WORKAROUND_FIX_CAPACITY   0x8
+#define SBP2_WORKAROUND_DELAY_INQUIRY  0x10
+#define SBP2_INQUIRY_DELAY 12
 #define SBP2_WORKAROUND_OVERRIDE   0x100
 
 static int sbp2_param_workarounds;
@@ -100,6 +106,7 @@ MODULE_PARM_DESC(workarounds, Work around device bugs 
(default = 0
, 36 byte inquiry = __stringify(SBP2_WORKAROUND_INQUIRY_36)
, skip mode page 8 =__stringify(SBP2_WORKAROUND_MODE_SENSE_8)
, fix capacity =__stringify(SBP2_WORKAROUND_FIX_CAPACITY)
+   , delay inquiry =   __stringify(SBP2_WORKAROUND_DELAY_INQUIRY)
, override internal blacklist =  __stringify(SBP2_WORKAROUND_OVERRIDE)
, or a combination));
 
@@ -303,6 +310,11 @@ static const struct {
.workarounds= SBP2_WORKAROUND_INQUIRY_36 |
  SBP2_WORKAROUND_MODE_SENSE_8,
},
+   /* DViCO Momobay FX-3A with TSB42AA9A bridge */ {
+   .firmware_revision  = 0x002800,
+   .model  = 0x00,
+   .workarounds= SBP2_WORKAROUND_DELAY_INQUIRY,
+   },
/* Initio bridges, actually only needed for some older ones */ {
.firmware_revision  = 0x000200,
.model  = ~0,
@@ -712,6 +724,9 @@ static void sbp2_login(struct work_struct *work)
PREPARE_DELAYED_WORK(lu-work, sbp2_reconnect);
sbp2_agent_reset(lu);
 
+   if (lu-tgt-workarounds  SBP2_WORKAROUND_DELAY_INQUIRY)
+   ssleep(SBP2_INQUIRY_DELAY);
+
memset(eight_bytes_lun, 0, sizeof(eight_bytes_lun));
eight_bytes_lun.scsi_lun[0] = (lu-lun  8)  0xff;
eight_bytes_lun.scsi_lun[1] = lu-lun  0xff;
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


ieee1394: sbp2: add INQUIRY delay workaround

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=d94a983526cb868658c958ab689410dc1c6a31f3
Commit: d94a983526cb868658c958ab689410dc1c6a31f3
Parent: 9220f1946209a5b3335ea2d28f8462695885791b
Author: Stefan Richter [EMAIL PROTECTED]
AuthorDate: Sun Feb 3 23:07:44 2008 +0100
Committer:  Stefan Richter [EMAIL PROTECTED]
CommitDate: Sat Feb 16 15:40:34 2008 +0100

ieee1394: sbp2: add INQUIRY delay workaround

Add the same workaround as found in fw-sbp2 for feature parity and
compatibility of the workarounds module parameter.

Signed-off-by: Stefan Richter [EMAIL PROTECTED]
Signed-off-by: Jarod Wilson [EMAIL PROTECTED]
---
 drivers/ieee1394/sbp2.c |   12 
 drivers/ieee1394/sbp2.h |2 ++
 2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c
index 28e155a..accb2ad 100644
--- a/drivers/ieee1394/sbp2.c
+++ b/drivers/ieee1394/sbp2.c
@@ -183,6 +183,9 @@ MODULE_PARM_DESC(exclusive_login, Exclusive login to sbp2 
device 
  *   Avoids access beyond actual disk limits on devices with an off-by-one bug.
  *   Don't use this with devices which don't have this bug.
  *
+ * - delay inquiry
+ *   Wait extra SBP2_INQUIRY_DELAY seconds after login before SCSI inquiry.
+ *
  * - override internal blacklist
  *   Instead of adding to the built-in blacklist, use only the workarounds
  *   specified in the module load parameter.
@@ -195,6 +198,7 @@ MODULE_PARM_DESC(workarounds, Work around device bugs 
(default = 0
, 36 byte inquiry = __stringify(SBP2_WORKAROUND_INQUIRY_36)
, skip mode page 8 =__stringify(SBP2_WORKAROUND_MODE_SENSE_8)
, fix capacity =__stringify(SBP2_WORKAROUND_FIX_CAPACITY)
+   , delay inquiry =   __stringify(SBP2_WORKAROUND_DELAY_INQUIRY)
, override internal blacklist =  __stringify(SBP2_WORKAROUND_OVERRIDE)
, or a combination));
 
@@ -357,6 +361,11 @@ static const struct {
.workarounds= SBP2_WORKAROUND_INQUIRY_36 |
  SBP2_WORKAROUND_MODE_SENSE_8,
},
+   /* DViCO Momobay FX-3A with TSB42AA9A bridge */ {
+   .firmware_revision  = 0x002800,
+   .model_id   = 0x00,
+   .workarounds= SBP2_WORKAROUND_DELAY_INQUIRY,
+   },
/* Initio bridges, actually only needed for some older ones */ {
.firmware_revision  = 0x000200,
.model_id   = SBP2_ROM_VALUE_WILDCARD,
@@ -914,6 +923,9 @@ static int sbp2_start_device(struct sbp2_lu *lu)
sbp2_agent_reset(lu, 1);
sbp2_max_speed_and_size(lu);
 
+   if (lu-workarounds  SBP2_WORKAROUND_DELAY_INQUIRY)
+   ssleep(SBP2_INQUIRY_DELAY);
+
error = scsi_add_device(lu-shost, 0, lu-ud-id, 0);
if (error) {
SBP2_ERR(scsi_add_device failed);
diff --git a/drivers/ieee1394/sbp2.h b/drivers/ieee1394/sbp2.h
index d2ecb0d..80d8e09 100644
--- a/drivers/ieee1394/sbp2.h
+++ b/drivers/ieee1394/sbp2.h
@@ -343,6 +343,8 @@ enum sbp2lu_state_types {
 #define SBP2_WORKAROUND_INQUIRY_36 0x2
 #define SBP2_WORKAROUND_MODE_SENSE_8   0x4
 #define SBP2_WORKAROUND_FIX_CAPACITY   0x8
+#define SBP2_WORKAROUND_DELAY_INQUIRY  0x10
+#define SBP2_INQUIRY_DELAY 12
 #define SBP2_WORKAROUND_OVERRIDE   0x100
 
 #endif /* SBP2_H */
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


firewire: fw-sbp2: don't add scsi_device twice

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=0fa6dfdb0a2768541e998a5dab10b368de56c60a
Commit: 0fa6dfdb0a2768541e998a5dab10b368de56c60a
Parent: 48f18c761c001a66ef1928b42799c717368b1d64
Author: Stefan Richter [EMAIL PROTECTED]
AuthorDate: Sun Feb 3 23:10:47 2008 +0100
Committer:  Stefan Richter [EMAIL PROTECTED]
CommitDate: Sat Feb 16 15:40:35 2008 +0100

firewire: fw-sbp2: don't add scsi_device twice

When a reconnect failed but re-login succeeded, __scsi_add_device was
called again.

In those cases, __scsi_add_device succeeded and returned the pointer to
the existing scsi_device.  fw-sbp2 then continued orderly, except that
it missed to call sbp2_cancel_orbs.  SCSI core would call fw-sbp2's
eh_abort_handler eventually if there had been an outstanding command.

This patch avoids the needless lookups and temporary allocations in SCSI
core and I/O stall and timeout until eh_abort_handler hits.

Also, __scsi_add_device tolerating calls for devices which already exist
is undocumented behavior on which we shouldn't rely.

Signed-off-by: Stefan Richter [EMAIL PROTECTED]
Signed-off-by: Jarod Wilson [EMAIL PROTECTED]
---
 drivers/firewire/fw-sbp2.c |6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/drivers/firewire/fw-sbp2.c b/drivers/firewire/fw-sbp2.c
index 077f1c0..914170b 100644
--- a/drivers/firewire/fw-sbp2.c
+++ b/drivers/firewire/fw-sbp2.c
@@ -741,6 +741,12 @@ static void sbp2_login(struct work_struct *work)
PREPARE_DELAYED_WORK(lu-work, sbp2_reconnect);
sbp2_agent_reset(lu);
 
+   /* This was a re-login. */
+   if (lu-sdev) {
+   sbp2_cancel_orbs(lu);
+   goto out;
+   }
+
if (lu-tgt-workarounds  SBP2_WORKAROUND_DELAY_INQUIRY)
ssleep(SBP2_INQUIRY_DELAY);
 
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


firewire: fw-sbp2: logout and login after failed reconnect

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=ce896d95cc7886ae05859c5b409a7b2f3b606ec1
Commit: ce896d95cc7886ae05859c5b409a7b2f3b606ec1
Parent: 0fa6dfdb0a2768541e998a5dab10b368de56c60a
Author: Stefan Richter [EMAIL PROTECTED]
AuthorDate: Sun Feb 3 23:11:39 2008 +0100
Committer:  Stefan Richter [EMAIL PROTECTED]
CommitDate: Sat Feb 16 15:40:35 2008 +0100

firewire: fw-sbp2: logout and login after failed reconnect

If fw-sbp2 was too late with requesting the reconnect, the target would
reject this.  In this case, log out before attempting the reconnect.
Else several firmwares will deny the re-login because they somehow
didn't invalidate the old login.

Also, don't retry reconnects in this situation.  The retries won't
succeed either.

These changes improve chances for successful re-login and shorten the
period during which the logical unit is inaccessible.

Signed-off-by: Stefan Richter [EMAIL PROTECTED]
Signed-off-by: Jarod Wilson [EMAIL PROTECTED]
---
 drivers/firewire/fw-sbp2.c |   17 +++--
 1 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/firewire/fw-sbp2.c b/drivers/firewire/fw-sbp2.c
index 914170b..80ab651 100644
--- a/drivers/firewire/fw-sbp2.c
+++ b/drivers/firewire/fw-sbp2.c
@@ -710,6 +710,11 @@ static void sbp2_login(struct work_struct *work)
node_id   = device-node_id;
local_node_id = device-card-node_id;
 
+   /* If this is a re-login attempt, log out, or we might be rejected. */
+   if (lu-sdev)
+   sbp2_send_management_orb(lu, device-node_id, generation,
+   SBP2_LOGOUT_REQUEST, lu-login_id, NULL);
+
if (sbp2_send_management_orb(lu, node_id, generation,
SBP2_LOGIN_REQUEST, lu-lun, response)  0) {
if (lu-retries++  5)
@@ -997,9 +1002,17 @@ static void sbp2_reconnect(struct work_struct *work)
if (sbp2_send_management_orb(lu, node_id, generation,
 SBP2_RECONNECT_REQUEST,
 lu-login_id, NULL)  0) {
-   if (lu-retries++ = 5) {
+   /*
+* If reconnect was impossible even though we are in the
+* current generation, fall back and try to log in again.
+*
+* We could check for Function rejected status, but
+* looking at the bus generation as simpler and more general.
+*/
+   smp_rmb(); /* get current card generation */
+   if (generation == device-card-generation ||
+   lu-retries++ = 5) {
fw_error(%s: failed to reconnect\n, tgt-bus_id);
-   /* Fall back and try to log in again. */
lu-retries = 0;
PREPARE_DELAYED_WORK(lu-work, sbp2_login);
}
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


firewire: fw-sbp2: sort includes

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=7bb6bf7c8ba0b4ccfecaa00d6faea51b0bd42c8c
Commit: 7bb6bf7c8ba0b4ccfecaa00d6faea51b0bd42c8c
Parent: ce896d95cc7886ae05859c5b409a7b2f3b606ec1
Author: Stefan Richter [EMAIL PROTECTED]
AuthorDate: Sun Feb 3 23:12:17 2008 +0100
Committer:  Stefan Richter [EMAIL PROTECTED]
CommitDate: Sat Feb 16 15:40:35 2008 +0100

firewire: fw-sbp2: sort includes

Signed-off-by: Stefan Richter [EMAIL PROTECTED]
---
 drivers/firewire/fw-sbp2.c |   14 +++---
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/firewire/fw-sbp2.c b/drivers/firewire/fw-sbp2.c
index 80ab651..323b03b 100644
--- a/drivers/firewire/fw-sbp2.c
+++ b/drivers/firewire/fw-sbp2.c
@@ -28,15 +28,15 @@
  * and many others.
  */
 
+#include linux/blkdev.h
+#include linux/delay.h
+#include linux/device.h
+#include linux/dma-mapping.h
 #include linux/kernel.h
+#include linux/mod_devicetable.h
 #include linux/module.h
 #include linux/moduleparam.h
-#include linux/mod_devicetable.h
-#include linux/delay.h
-#include linux/device.h
 #include linux/scatterlist.h
-#include linux/dma-mapping.h
-#include linux/blkdev.h
 #include linux/string.h
 #include linux/stringify.h
 #include linux/timer.h
@@ -48,9 +48,9 @@
 #include scsi/scsi_device.h
 #include scsi/scsi_host.h
 
-#include fw-transaction.h
-#include fw-topology.h
 #include fw-device.h
+#include fw-topology.h
+#include fw-transaction.h
 
 /*
  * So far only bridges from Oxford Semiconductor are known to support
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


firewire: fw-sbp2: enforce a retry of __scsi_add_device if bus generation changed

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=e80de3704ac30ddb7f9a12447a2ecee32ccd7880
Commit: e80de3704ac30ddb7f9a12447a2ecee32ccd7880
Parent: 7bb6bf7c8ba0b4ccfecaa00d6faea51b0bd42c8c
Author: Stefan Richter [EMAIL PROTECTED]
AuthorDate: Fri Feb 15 21:29:02 2008 +0100
Committer:  Stefan Richter [EMAIL PROTECTED]
CommitDate: Sat Feb 16 15:40:35 2008 +0100

firewire: fw-sbp2: enforce a retry of __scsi_add_device if bus generation 
changed

fw-sbp2 is unable to reconnect while performing __scsi_add_device
because there is only a single workqueue thread context available for
both at the moment.  This should be fixed eventually.

An actual failure of __scsi_add_device is easy to handle, but an
incomplete execution of __scsi_add_device with an sdev returned would
remain undetected and leave the SBP-2 target unusable.

Therefore we use a workaround:  If there was a bus reset during
__scsi_add_device (i.e. during the SCSI probe), we remove the new sdev
immediately, log out, and attempt login and SCSI probe again.

Tested-by: Jarod Wilson [EMAIL PROTECTED] (earlier version)
Signed-off-by: Stefan Richter [EMAIL PROTECTED]
---
 drivers/firewire/fw-sbp2.c |   49 +++
 1 files changed, 35 insertions(+), 14 deletions(-)

diff --git a/drivers/firewire/fw-sbp2.c b/drivers/firewire/fw-sbp2.c
index 323b03b..6d10934 100644
--- a/drivers/firewire/fw-sbp2.c
+++ b/drivers/firewire/fw-sbp2.c
@@ -762,22 +762,43 @@ static void sbp2_login(struct work_struct *work)
 
sdev = __scsi_add_device(shost, 0, 0,
 scsilun_to_int(eight_bytes_lun), lu);
-   if (IS_ERR(sdev)) {
-   smp_rmb(); /* generation may have changed */
-   generation = device-generation;
-   smp_rmb(); /* node_id must not be older than generation */
+   /*
+* FIXME:  We are unable to perform reconnects while in sbp2_login().
+* Therefore __scsi_add_device() will get into trouble if a bus reset
+* happens in parallel.  It will either fail or leave us with an
+* unusable sdev.  As a workaround we check for this and retry the
+* whole login and SCSI probing.
+*/
 
-   sbp2_send_management_orb(lu, device-node_id, generation,
-   SBP2_LOGOUT_REQUEST, lu-login_id, NULL);
-   /*
-* Set this back to sbp2_login so we fall back and
-* retry login on bus reset.
-*/
-   PREPARE_DELAYED_WORK(lu-work, sbp2_login);
-   } else {
-   lu-sdev = sdev;
-   scsi_device_put(sdev);
+   /* Reported error during __scsi_add_device() */
+   if (IS_ERR(sdev))
+   goto out_logout_login;
+
+   scsi_device_put(sdev);
+
+   /* Unreported error during __scsi_add_device() */
+   smp_rmb(); /* get current card generation */
+   if (generation != device-card-generation) {
+   scsi_remove_device(sdev);
+   goto out_logout_login;
}
+
+   /* No error during __scsi_add_device() */
+   lu-sdev = sdev;
+   goto out;
+
+ out_logout_login:
+   smp_rmb(); /* generation may have changed */
+   generation = device-generation;
+   smp_rmb(); /* node_id must not be older than generation */
+
+   sbp2_send_management_orb(lu, device-node_id, generation,
+SBP2_LOGOUT_REQUEST, lu-login_id, NULL);
+   /*
+* If a bus reset happened, sbp2_update will have requeued
+* lu-work already.  Reset the work from reconnect to login.
+*/
+   PREPARE_DELAYED_WORK(lu-work, sbp2_login);
  out:
sbp2_target_put(tgt);
 }
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


firewire: fw-sbp2: (try to) avoid I/O errors during reconnect

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=2e2705bdcb959372d54bf7f79dd9a555ec2adfb4
Commit: 2e2705bdcb959372d54bf7f79dd9a555ec2adfb4
Parent: e80de3704ac30ddb7f9a12447a2ecee32ccd7880
Author: Stefan Richter [EMAIL PROTECTED]
AuthorDate: Sat Feb 16 16:37:28 2008 +0100
Committer:  Stefan Richter [EMAIL PROTECTED]
CommitDate: Tue Feb 19 19:57:23 2008 +0100

firewire: fw-sbp2: (try to) avoid I/O errors during reconnect

While fw-sbp2 takes the necessary time to reconnect to a logical unit
after bus reset, the SCSI core keeps sending new commands.  They are all
immediately completed with host busy status, and application clients or
filesystems will break quickly.  The SCSI device might even be taken
offline:  http://bugzilla.kernel.org/show_bug.cgi?id=9734

The only remedy seems to be to block the SCSI device until reconnect.
Alas the SCSI core has no useful API to block only one logical unit i.e.
the scsi_device, therefore we block the entire Scsi_Host.  This
currently corresponds to an SBP-2 target.  In case of targets with
multiple logical units, we need to satisfy the dependencies between
logical units by carefully tracking the blocking state of the target and
its units.  We block all logical units of a target as soon as one of
them needs to be blocked, and keep them blocked until all of them are
ready to be unblocked.

Furthermore, as the history of the old sbp2 driver has shown, the
scsi_block_requests() API is a minefield with high potential of
deadlocks.  We therefore take extra measures to keep logical units
unblocked during __scsi_add_device() and during shutdown.

This avoids I/O errors during reconnect in many but alas not in all
cases.  There may still be errors after a re-login had to be performed.
Also, some bridges have been seen to cease fetching management ORBs if
I/O went on up until a bus reset.  In these cases, all management ORBs
time out after mgt_orb_timeout.  The old sbp2 driver is less vulnerable
or maybe not vulnerable to this, for as yet unknown reasons.

Signed-off-by: Stefan Richter [EMAIL PROTECTED]
---
 drivers/firewire/fw-sbp2.c |  126 ++--
 1 files changed, 122 insertions(+), 4 deletions(-)

diff --git a/drivers/firewire/fw-sbp2.c b/drivers/firewire/fw-sbp2.c
index 6d10934..ea4811c 100644
--- a/drivers/firewire/fw-sbp2.c
+++ b/drivers/firewire/fw-sbp2.c
@@ -139,6 +139,7 @@ struct sbp2_logical_unit {
int generation;
int retries;
struct delayed_work work;
+   bool blocked;
 };
 
 /*
@@ -157,6 +158,9 @@ struct sbp2_target {
int address_high;
unsigned int workarounds;
unsigned int mgt_orb_timeout;
+
+   int dont_block; /* counter for each logical unit */
+   int blocked;/* ditto */
 };
 
 /*
@@ -646,6 +650,107 @@ static void sbp2_agent_reset_no_wait(struct 
sbp2_logical_unit *lu)
z, sizeof(z), complete_agent_reset_write_no_wait, t);
 }
 
+static void sbp2_set_generation(struct sbp2_logical_unit *lu, int generation)
+{
+   struct fw_card *card = fw_device(lu-tgt-unit-device.parent)-card;
+   unsigned long flags;
+
+   /* serialize with comparisons of lu-generation and card-generation */
+   spin_lock_irqsave(card-lock, flags);
+   lu-generation = generation;
+   spin_unlock_irqrestore(card-lock, flags);
+}
+
+static inline void sbp2_allow_block(struct sbp2_logical_unit *lu)
+{
+   /*
+* We may access dont_block without taking card-lock here:
+* All callers of sbp2_allow_block() and all callers of sbp2_unblock()
+* are currently serialized against each other.
+* And a wrong result in sbp2_conditionally_block()'s access of
+* dont_block is rather harmless, it simply misses its first chance.
+*/
+   --lu-tgt-dont_block;
+}
+
+/*
+ * Blocks lu-tgt if all of the following conditions are met:
+ *   - Login, INQUIRY, and high-level SCSI setup of all of the target's
+ * logical units have been finished (indicated by dont_block == 0).
+ *   - lu-generation is stale.
+ *
+ * Note, scsi_block_requests() must be called while holding card-lock,
+ * otherwise it might foil sbp2_[conditionally_]unblock()'s attempt to
+ * unblock the target.
+ */
+static void sbp2_conditionally_block(struct sbp2_logical_unit *lu)
+{
+   struct sbp2_target *tgt = lu-tgt;
+   struct fw_card *card = fw_device(tgt-unit-device.parent)-card;
+   struct Scsi_Host *shost =
+   container_of((void *)tgt, struct Scsi_Host, hostdata[0]);
+   unsigned long flags;
+
+   spin_lock_irqsave(card-lock, flags);
+   if (!tgt-dont_block  !lu-blocked 
+   lu-generation != card-generation) {
+   lu-blocked = true;
+   if (++tgt-blocked == 1) {
+   

firewire: fw-sbp2: fix NULL pointer deref. in slave_alloc

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=5513c5f6f9bd8c8ad3727130910fa288c62526a7
Commit: 5513c5f6f9bd8c8ad3727130910fa288c62526a7
Parent: 2e2705bdcb959372d54bf7f79dd9a555ec2adfb4
Author: Stefan Richter [EMAIL PROTECTED]
AuthorDate: Sun Feb 17 14:56:19 2008 +0100
Committer:  Stefan Richter [EMAIL PROTECTED]
CommitDate: Tue Feb 19 19:57:23 2008 +0100

firewire: fw-sbp2: fix NULL pointer deref. in slave_alloc

Fix a kernel bug when running rescan-scsi-bus while a FireWire disk is
connected:  http://bugzilla.kernel.org/show_bug.cgi?id=10008

Signed-off-by: Stefan Richter [EMAIL PROTECTED]
---
 drivers/firewire/fw-sbp2.c |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/firewire/fw-sbp2.c b/drivers/firewire/fw-sbp2.c
index ea4811c..60ebcb5 100644
--- a/drivers/firewire/fw-sbp2.c
+++ b/drivers/firewire/fw-sbp2.c
@@ -1473,6 +1473,10 @@ static int sbp2_scsi_slave_alloc(struct scsi_device 
*sdev)
 {
struct sbp2_logical_unit *lu = sdev-hostdata;
 
+   /* (Re-)Adding logical units via the SCSI stack is not supported. */
+   if (!lu)
+   return -ENOSYS;
+
sdev-allow_restart = 1;
 
/*
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


firewire: fw-sbp2: fix NULL pointer deref. in scsi_remove_device

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=33f1c6c3529f5f279e2e98e5cca0c5bac152153b
Commit: 33f1c6c3529f5f279e2e98e5cca0c5bac152153b
Parent: 5513c5f6f9bd8c8ad3727130910fa288c62526a7
Author: Stefan Richter [EMAIL PROTECTED]
AuthorDate: Tue Feb 19 09:05:49 2008 +0100
Committer:  Stefan Richter [EMAIL PROTECTED]
CommitDate: Tue Feb 19 19:57:23 2008 +0100

firewire: fw-sbp2: fix NULL pointer deref. in scsi_remove_device

Fix a kernel bug when unplugging an SBP-2 device after having its
scsi_device already removed via the delete sysfs attribute.

Signed-off-by: Stefan Richter [EMAIL PROTECTED]
---
 drivers/firewire/fw-sbp2.c |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/firewire/fw-sbp2.c b/drivers/firewire/fw-sbp2.c
index 60ebcb5..5259491 100644
--- a/drivers/firewire/fw-sbp2.c
+++ b/drivers/firewire/fw-sbp2.c
@@ -762,9 +762,10 @@ static void sbp2_release_target(struct kref *kref)
sbp2_unblock(tgt);
 
list_for_each_entry_safe(lu, next, tgt-lu_list, link) {
-   if (lu-sdev)
+   if (lu-sdev) {
scsi_remove_device(lu-sdev);
-
+   scsi_device_put(lu-sdev);
+   }
sbp2_send_management_orb(lu, tgt-node_id, lu-generation,
SBP2_LOGOUT_REQUEST, lu-login_id, NULL);
 
@@ -886,12 +887,11 @@ static void sbp2_login(struct work_struct *work)
if (IS_ERR(sdev))
goto out_logout_login;
 
-   scsi_device_put(sdev);
-
/* Unreported error during __scsi_add_device() */
smp_rmb(); /* get current card generation */
if (generation != device-card-generation) {
scsi_remove_device(sdev);
+   scsi_device_put(sdev);
goto out_logout_login;
}
 
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


ieee1394: sbp2: fix rescan-scsi-bus

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=ef774c16a744f130f27c654bf9c4806e767fc773
Commit: ef774c16a744f130f27c654bf9c4806e767fc773
Parent: 33f1c6c3529f5f279e2e98e5cca0c5bac152153b
Author: Stefan Richter [EMAIL PROTECTED]
AuthorDate: Sun Feb 17 14:57:10 2008 +0100
Committer:  Stefan Richter [EMAIL PROTECTED]
CommitDate: Tue Feb 19 19:57:24 2008 +0100

ieee1394: sbp2: fix rescan-scsi-bus

rescan-scsi-bus used to add SBP-2 targets which weren't there.

Signed-off-by: Stefan Richter [EMAIL PROTECTED]
---
 drivers/ieee1394/sbp2.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c
index accb2ad..9e2b196 100644
--- a/drivers/ieee1394/sbp2.c
+++ b/drivers/ieee1394/sbp2.c
@@ -1974,6 +1974,9 @@ static int sbp2scsi_slave_alloc(struct scsi_device *sdev)
 {
struct sbp2_lu *lu = (struct sbp2_lu *)sdev-host-hostdata[0];
 
+   if (sdev-lun != 0 || sdev-id != lu-ud-id || sdev-channel != 0)
+   return -ENODEV;
+
lu-sdev = sdev;
sdev-allow_restart = 1;
 
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


firewire: fix NULL pointer deref. and resource leak

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=fae603121428ba83b7343c88e68a7144525ab3eb
Commit: fae603121428ba83b7343c88e68a7144525ab3eb
Parent: 09d7328e62e3b4cefe4bf3acb54f62a7ae5c
Author: Stefan Richter [EMAIL PROTECTED]
AuthorDate: Wed Feb 20 21:10:06 2008 +0100
Committer:  Stefan Richter [EMAIL PROTECTED]
CommitDate: Thu Feb 21 19:05:56 2008 +0100

firewire: fix NULL pointer deref. and resource leak

By supplying ioctl()s in the wrong order, a userspace client was able to
trigger NULL pointer dereferences.  Furthermore, by calling
ioctl_create_iso_context more than once, new contexts could be created
without ever freeing the previously created contexts.

Thanks to Anders Blomdell for the report.

Signed-off-by: Stefan Richter [EMAIL PROTECTED]
---
 drivers/firewire/fw-cdev.c |9 +++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/firewire/fw-cdev.c b/drivers/firewire/fw-cdev.c
index 44ccee2..46bc197 100644
--- a/drivers/firewire/fw-cdev.c
+++ b/drivers/firewire/fw-cdev.c
@@ -646,6 +646,10 @@ static int ioctl_create_iso_context(struct client *client, 
void *buffer)
struct fw_cdev_create_iso_context *request = buffer;
struct fw_iso_context *context;
 
+   /* We only support one context at this time. */
+   if (client-iso_context != NULL)
+   return -EBUSY;
+
if (request-channel  63)
return -EINVAL;
 
@@ -792,8 +796,9 @@ static int ioctl_start_iso(struct client *client, void 
*buffer)
 {
struct fw_cdev_start_iso *request = buffer;
 
-   if (request-handle != 0)
+   if (client-iso_context == NULL || request-handle != 0)
return -EINVAL;
+
if (client-iso_context-type == FW_ISO_CONTEXT_RECEIVE) {
if (request-tags == 0 || request-tags  15)
return -EINVAL;
@@ -810,7 +815,7 @@ static int ioctl_stop_iso(struct client *client, void 
*buffer)
 {
struct fw_cdev_stop_iso *request = buffer;
 
-   if (request-handle != 0)
+   if (client-iso_context == NULL || request-handle != 0)
return -EINVAL;
 
return fw_iso_context_stop(client-iso_context);
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


lockdep: increase MAX_LOCK_DEPTH

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=bdb9441e9c325d50b5ae17f7d3205d65b8ed2e5f
Commit: bdb9441e9c325d50b5ae17f7d3205d65b8ed2e5f
Parent: bfa274e2436fc7ef72ef51c878083647f1cfd429
Author: Peter Zijlstra [EMAIL PROTECTED]
AuthorDate: Mon Feb 25 23:02:48 2008 +0100
Committer:  Peter Zijlstra [EMAIL PROTECTED]
CommitDate: Mon Feb 25 23:02:48 2008 +0100

lockdep: increase MAX_LOCK_DEPTH

Some code paths exceed the current max lock depth (XFS), so increase
this limit a bit. I looked at making this a dynamic allocated array,
but we should not advocate insane lock depths, so stay with this as
long as it works...

Signed-off-by: Peter Zijlstra [EMAIL PROTECTED]
Signed-off-by: Ingo Molnar [EMAIL PROTECTED]
---
 include/linux/sched.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index e217d18..e3ea124 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1189,7 +1189,7 @@ struct task_struct {
int softirq_context;
 #endif
 #ifdef CONFIG_LOCKDEP
-# define MAX_LOCK_DEPTH 30UL
+# define MAX_LOCK_DEPTH 48UL
u64 curr_chain_key;
int lockdep_depth;
struct held_lock held_locks[MAX_LOCK_DEPTH];
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Subject: lockdep: include all lock classes in all_lock_classes

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=1481197b50114d7212d659d41cb97f31a8934883
Commit: 1481197b50114d7212d659d41cb97f31a8934883
Parent: bdb9441e9c325d50b5ae17f7d3205d65b8ed2e5f
Author: Dale Farnsworth [EMAIL PROTECTED]
AuthorDate: Mon Feb 25 23:03:02 2008 +0100
Committer:  Peter Zijlstra [EMAIL PROTECTED]
CommitDate: Mon Feb 25 23:03:02 2008 +0100

Subject: lockdep: include all lock classes in all_lock_classes
Add each lock class to the all_lock_classes list when it is
first registered.

Previously, lock classes were added to all_lock_classes when
the lock class was first used.  Since one of the uses of the
list is to find unused locks, this didn't work well.

Signed-off-by: Dale Farnsworth [EMAIL PROTECTED]
Signed-off-by: Peter Zijlstra [EMAIL PROTECTED]
Signed-off-by: Ingo Molnar [EMAIL PROTECTED]
---
 kernel/lockdep.c |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index 3574379..81a4e4a 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -779,6 +779,10 @@ register_lock_class(struct lockdep_map *lock, unsigned int 
subclass, int force)
 * parallel walking of the hash-list safe:
 */
list_add_tail_rcu(class-hash_entry, hash_head);
+   /*
+* Add it to the global list of classes:
+*/
+   list_add_tail_rcu(class-lock_entry, all_lock_classes);
 
if (verbose(class)) {
graph_unlock();
@@ -2282,10 +2286,6 @@ static int mark_lock(struct task_struct *curr, struct 
held_lock *this,
return 0;
break;
case LOCK_USED:
-   /*
-* Add it to the global list of classes:
-*/
-   list_add_tail_rcu(this-class-lock_entry, all_lock_classes);
debug_atomic_dec(nr_unused_locks);
break;
default:
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


make atapi_dmadir static

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=c5c61bda5ecceaa0f16d326cd2c2147468a4c443
Commit: c5c61bda5ecceaa0f16d326cd2c2147468a4c443
Parent: bfa274e2436fc7ef72ef51c878083647f1cfd429
Author: Adrian Bunk [EMAIL PROTECTED]
AuthorDate: Mon Feb 25 02:07:25 2008 +0200
Committer:  Jeff Garzik [EMAIL PROTECTED]
CommitDate: Mon Feb 25 17:29:35 2008 -0500

make atapi_dmadir static

atapi_dmadir can now become static.

Signed-off-by: Adrian Bunk [EMAIL PROTECTED]
Signed-off-by: Jeff Garzik [EMAIL PROTECTED]
---
 drivers/ata/libata-core.c |2 +-
 drivers/ata/libata.h  |1 -
 2 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index fbc2435..b57fad3 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -113,7 +113,7 @@ int atapi_enabled = 1;
 module_param(atapi_enabled, int, 0444);
 MODULE_PARM_DESC(atapi_enabled, Enable discovery of ATAPI devices (0=off, 
1=on));
 
-int atapi_dmadir = 0;
+static int atapi_dmadir = 0;
 module_param(atapi_dmadir, int, 0444);
 MODULE_PARM_DESC(atapi_dmadir, Enable ATAPI DMADIR bridge support (0=off, 
1=on));
 
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
index 6036ded..aa884f7 100644
--- a/drivers/ata/libata.h
+++ b/drivers/ata/libata.h
@@ -56,7 +56,6 @@ enum {
 extern unsigned int ata_print_id;
 extern struct workqueue_struct *ata_aux_wq;
 extern int atapi_enabled;
-extern int atapi_dmadir;
 extern int atapi_passthru16;
 extern int libata_fua;
 extern int libata_noacpi;
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Revert power_state: get rid of write-only variable in SATA

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=72ad6ec48989d4b5477128e739b960be11155036
Commit: 72ad6ec48989d4b5477128e739b960be11155036
Parent: c5c61bda5ecceaa0f16d326cd2c2147468a4c443
Author: Jeff Garzik [EMAIL PROTECTED]
AuthorDate: Mon Feb 25 17:31:10 2008 -0500
Committer:  Jeff Garzik [EMAIL PROTECTED]
CommitDate: Mon Feb 25 17:31:10 2008 -0500

Revert power_state: get rid of write-only variable in SATA

This reverts commit 559bbe6cbd0d8c68d40076a5f7dc98e3bf5864b2.

Michael S. Tsirkin reports that this changes breaks suspend/resume.

Signed-off-by: Jeff Garzik [EMAIL PROTECTED]
---
 drivers/ata/libata-core.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index b57fad3..4fbcce7 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -6567,6 +6567,8 @@ int ata_host_suspend(struct ata_host *host, pm_message_t 
mesg)
ata_lpm_enable(host);
 
rc = ata_host_request_pm(host, mesg, 0, ATA_EHI_QUIET, 1);
+   if (rc == 0)
+   host-dev-power.power_state = mesg;
return rc;
 }
 
@@ -6585,6 +6587,7 @@ void ata_host_resume(struct ata_host *host)
 {
ata_host_request_pm(host, PMSG_ON, ATA_EH_SOFTRESET,
ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET, 0);
+   host-dev-power.power_state = PMSG_ON;
 
/* reenable link pm */
ata_lpm_disable(host);
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Remove incorrect BKL comments in ext4

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=642be6ec218b956fbae88304449720f76ba0d578
Commit: 642be6ec218b956fbae88304449720f76ba0d578
Parent: bfa274e2436fc7ef72ef51c878083647f1cfd429
Author: Andi Kleen [EMAIL PROTECTED]
AuthorDate: Mon Feb 25 17:20:46 2008 -0500
Committer:  Theodore Ts'o [EMAIL PROTECTED]
CommitDate: Mon Feb 25 17:20:46 2008 -0500

Remove incorrect BKL comments in ext4

Signed-off-by: Andi Kleen [EMAIL PROTECTED]
Signed-off-by: Theodore Ts'o [EMAIL PROTECTED]
---
 fs/ext4/dir.c   |2 +-
 fs/ext4/inode.c |1 -
 2 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c
index 33888bb..2c23bad 100644
--- a/fs/ext4/dir.c
+++ b/fs/ext4/dir.c
@@ -46,7 +46,7 @@ const struct file_operations ext4_dir_operations = {
 #ifdef CONFIG_COMPAT
.compat_ioctl   = ext4_compat_ioctl,
 #endif
-   .fsync  = ext4_sync_file,   /* BKL held */
+   .fsync  = ext4_sync_file,
.release= ext4_release_dir,
 };
 
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 7dd9b50..d3c6f58 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -768,7 +768,6 @@ err_out:
  *
  * `handle' can be NULL if create == 0.
  *
- * The BKL may not be held on entry here.  Be sure to take it early.
  * return  0, # of blocks mapped or allocated.
  * return = 0, if plain lookup failed.
  * return  0, error case.
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


ext4: Fix locking hierarchy violation in ext4_fallocate()

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=55bd725aa3a83b3935988f37275b5a80e10d4169
Commit: 55bd725aa3a83b3935988f37275b5a80e10d4169
Parent: 642be6ec218b956fbae88304449720f76ba0d578
Author: Aneesh Kumar K.V [EMAIL PROTECTED]
AuthorDate: Fri Feb 15 12:47:21 2008 -0500
Committer:  Theodore Ts'o [EMAIL PROTECTED]
CommitDate: Fri Feb 15 12:47:21 2008 -0500

ext4: Fix locking hierarchy violation in ext4_fallocate()

ext4_fallocate() was trying to acquire i_data_sem outside of
jbd2_start_transaction/jbd2_journal_stop, which violates ext4's locking
hierarchy.  So we take i_mutex to prevent writes and truncates during
the complete fallocate operation, and use ext4_get_block_wrap() which
acquires and releases i_data_sem for each block allocation.

Signed-off-by: Aneesh Kumar K.V [EMAIL PROTECTED]
Signed-off-by: Mingming Cao [EMAIL PROTECTED]
Signed-off-by: Theodore Ts'o [EMAIL PROTECTED]
---
 fs/ext4/extents.c |   10 +++---
 1 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index bc7081f..e856f66 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -2623,7 +2623,7 @@ long ext4_fallocate(struct inode *inode, int mode, loff_t 
offset, loff_t len)
 * modify 1 super block, 1 block bitmap and 1 group descriptor.
 */
credits = EXT4_DATA_TRANS_BLOCKS(inode-i_sb) + 3;
-   down_write((EXT4_I(inode)-i_data_sem));
+   mutex_lock(inode-i_mutex);
 retry:
while (ret = 0  ret  max_blocks) {
block = block + ret;
@@ -2634,7 +2634,7 @@ retry:
break;
}
 
-   ret = ext4_ext_get_blocks(handle, inode, block,
+   ret = ext4_get_blocks_wrap(handle, inode, block,
  max_blocks, map_bh,
  EXT4_CREATE_UNINITIALIZED_EXT, 0);
WARN_ON(ret = 0);
@@ -2680,7 +2680,6 @@ retry:
if (ret == -ENOSPC  ext4_should_retry_alloc(inode-i_sb, retries))
goto retry;
 
-   up_write((EXT4_I(inode)-i_data_sem));
/*
 * Time to update the file size.
 * Update only when preallocation was requested beyond the file size.
@@ -2692,21 +2691,18 @@ retry:
 * if no error, we assume preallocation succeeded
 * completely
 */
-   mutex_lock(inode-i_mutex);
i_size_write(inode, offset + len);
EXT4_I(inode)-i_disksize = i_size_read(inode);
-   mutex_unlock(inode-i_mutex);
} else if (ret  0  nblocks) {
/* Handle partial allocation scenario */
loff_t newsize;
 
-   mutex_lock(inode-i_mutex);
newsize  = (nblocks  blkbits) + i_size_read(inode);
i_size_write(inode, EXT4_BLOCK_ALIGN(newsize, blkbits));
EXT4_I(inode)-i_disksize = i_size_read(inode);
-   mutex_unlock(inode-i_mutex);
}
}
 
+   mutex_unlock(inode-i_mutex);
return ret  0 ? ret2 : ret;
 }
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


ext4: Fix kernel BUG at fs/ext4/mballoc.c:910!

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=b73fce69ecb091a178ef9286027c370a63eb25aa
Commit: b73fce69ecb091a178ef9286027c370a63eb25aa
Parent: 55bd725aa3a83b3935988f37275b5a80e10d4169
Author: Valerie Clement [EMAIL PROTECTED]
AuthorDate: Fri Feb 15 13:48:51 2008 -0500
Committer:  Theodore Ts'o [EMAIL PROTECTED]
CommitDate: Fri Feb 15 13:48:51 2008 -0500

ext4: Fix kernel BUG at fs/ext4/mballoc.c:910!

With the flex_bg feature enabled, a large file creation oopses the
kernel.   The BUG_ON is:
BUG_ON(len = EXT4_BLOCKS_PER_GROUP(sb));

As the allocation of the bitmaps and the inode table can be done
outside the block group with flex_bg, this allows to allocate up to
EXT4_BLOCKS_PER_GROUP blocks in a group.

This patch fixes the oops.

Signed-off-by: Valerie Clement [EMAIL PROTECTED]
Signed-off-by: Mingming Cao [EMAIL PROTECTED]
Signed-off-by: Theodore Ts'o [EMAIL PROTECTED]
---
 fs/ext4/mballoc.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index dd0fcfc..2121184 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -906,7 +906,7 @@ static void ext4_mb_mark_free_simple(struct super_block *sb,
unsigned short chunk;
unsigned short border;
 
-   BUG_ON(len = EXT4_BLOCKS_PER_GROUP(sb));
+   BUG_ON(len  EXT4_BLOCKS_PER_GROUP(sb));
 
border = 2  sb-s_blocksize_bits;
 
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


ext4: Don't leave behind a half-created inode if ext4_mkdir() fails

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=4cdeed861b5f797b3fa661eb331a6bd6ad669c6a
Commit: 4cdeed861b5f797b3fa661eb331a6bd6ad669c6a
Parent: b73fce69ecb091a178ef9286027c370a63eb25aa
Author: Aneesh Kumar K.V [EMAIL PROTECTED]
AuthorDate: Fri Feb 22 06:17:31 2008 -0500
Committer:  Theodore Ts'o [EMAIL PROTECTED]
CommitDate: Fri Feb 22 06:17:31 2008 -0500

ext4: Don't leave behind a half-created inode if ext4_mkdir() fails

If ext4_mkdir() fails to allocate the initial block for the directory,
don't leave behind a half-created directory inode with the link count
left at one.  This was caused by an inappropriate call to ext4_dec_count().

Signed-off-by: Aneesh Kumar K.V [EMAIL PROTECTED]
Signed-off-by: Mingming Cao [EMAIL PROTECTED]
Signed-off-by: Theodore Ts'o [EMAIL PROTECTED]
---
 fs/ext4/namei.c |   11 ---
 1 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index a9347fb..fffd080 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -1804,12 +1804,8 @@ retry:
inode-i_fop = ext4_dir_operations;
inode-i_size = EXT4_I(inode)-i_disksize = inode-i_sb-s_blocksize;
dir_block = ext4_bread (handle, inode, 0, 1, err);
-   if (!dir_block) {
-   ext4_dec_count(handle, inode); /* is this nlink == 0? */
-   ext4_mark_inode_dirty(handle, inode);
-   iput (inode);
-   goto out_stop;
-   }
+   if (!dir_block)
+   goto out_clear_inode;
BUFFER_TRACE(dir_block, get_write_access);
ext4_journal_get_write_access(handle, dir_block);
de = (struct ext4_dir_entry_2 *) dir_block-b_data;
@@ -1832,7 +1828,8 @@ retry:
ext4_mark_inode_dirty(handle, inode);
err = ext4_add_entry (handle, dentry, inode);
if (err) {
-   inode-i_nlink = 0;
+out_clear_inode:
+   clear_nlink(inode);
ext4_mark_inode_dirty(handle, inode);
iput (inode);
goto out_stop;
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


ext4: Fix memory and buffer head leak in callers to ext4_ext_find_extent()

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=b35905c16ad6428551eb9e49525011bd2700cf56
Commit: b35905c16ad6428551eb9e49525011bd2700cf56
Parent: 4cdeed861b5f797b3fa661eb331a6bd6ad669c6a
Author: Aneesh Kumar K.V [EMAIL PROTECTED]
AuthorDate: Mon Feb 25 16:54:37 2008 -0500
Committer:  Theodore Ts'o [EMAIL PROTECTED]
CommitDate: Mon Feb 25 16:54:37 2008 -0500

ext4: Fix memory and buffer head leak in callers to ext4_ext_find_extent()

The path variable returned via ext4_ext_find_extent is a kmalloc
variable and needs to be freeded.  It also contains a reference to
buffer_head which needs to be dropped.

Signed-off-by: Aneesh Kumar K.V [EMAIL PROTECTED]
Signed-off-by: Mingming Cao [EMAIL PROTECTED]
Signed-off-by: Theodore Ts'o [EMAIL PROTECTED]
---
 fs/ext4/extents.c   |6 +++---
 fs/ext4/migrate.c   |5 +
 include/linux/ext4_fs_extents.h |1 +
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index e856f66..995ac16 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -349,7 +349,7 @@ static void ext4_ext_show_leaf(struct inode *inode, struct 
ext4_ext_path *path)
 #define ext4_ext_show_leaf(inode,path)
 #endif
 
-static void ext4_ext_drop_refs(struct ext4_ext_path *path)
+void ext4_ext_drop_refs(struct ext4_ext_path *path)
 {
int depth = path-p_depth;
int i;
@@ -2200,10 +2200,10 @@ static int ext4_ext_convert_to_initialized(handle_t 
*handle,
newdepth = ext_depth(inode);
if (newdepth != depth) {
depth = newdepth;
-   path = ext4_ext_find_extent(inode, iblock, NULL);
+   ext4_ext_drop_refs(path);
+   path = ext4_ext_find_extent(inode, iblock, path);
if (IS_ERR(path)) {
err = PTR_ERR(path);
-   path = NULL;
goto out;
}
eh = path[depth].p_hdr;
diff --git a/fs/ext4/migrate.c b/fs/ext4/migrate.c
index 8c6c685..5c1e27d 100644
--- a/fs/ext4/migrate.c
+++ b/fs/ext4/migrate.c
@@ -43,6 +43,7 @@ static int finish_range(handle_t *handle, struct inode *inode,
 
if (IS_ERR(path)) {
retval = PTR_ERR(path);
+   path = NULL;
goto err_out;
}
 
@@ -74,6 +75,10 @@ static int finish_range(handle_t *handle, struct inode 
*inode,
}
retval = ext4_ext_insert_extent(handle, inode, path, newext);
 err_out:
+   if (path) {
+   ext4_ext_drop_refs(path);
+   kfree(path);
+   }
lb-first_pblock = 0;
return retval;
 }
diff --git a/include/linux/ext4_fs_extents.h b/include/linux/ext4_fs_extents.h
index 697da4b..1285c58 100644
--- a/include/linux/ext4_fs_extents.h
+++ b/include/linux/ext4_fs_extents.h
@@ -227,5 +227,6 @@ extern int ext4_ext_search_left(struct inode *, struct 
ext4_ext_path *,
ext4_lblk_t *, ext4_fsblk_t *);
 extern int ext4_ext_search_right(struct inode *, struct ext4_ext_path *,
ext4_lblk_t *, ext4_fsblk_t *);
+extern void ext4_ext_drop_refs(struct ext4_ext_path *);
 #endif /* _LINUX_EXT4_EXTENTS */
 
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


ext4: Get journal write access before modifying the extent tree

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=9df5643ad135c7f8c02d3b69020de4ec910f9fc0
Commit: 9df5643ad135c7f8c02d3b69020de4ec910f9fc0
Parent: b35905c16ad6428551eb9e49525011bd2700cf56
Author: Aneesh Kumar K.V [EMAIL PROTECTED]
AuthorDate: Fri Feb 22 06:17:31 2008 -0500
Committer:  Theodore Ts'o [EMAIL PROTECTED]
CommitDate: Fri Feb 22 06:17:31 2008 -0500

ext4: Get journal write access before modifying the extent tree

When the user was writing into an unitialized extent,
ext4_ext_convert_to_initialize() was not requesting journal write access
before it started to modify the extent tree.   Fix this oversight.

Signed-off-by: Aneesh Kumar K.V [EMAIL PROTECTED]
Signed-off-by: Mingming Cao [EMAIL PROTECTED]
Signed-off-by: Theodore Ts'o [EMAIL PROTECTED]
---
 fs/ext4/extents.c |   11 ---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 995ac16..c4d6f19 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -2168,6 +2168,10 @@ static int ext4_ext_convert_to_initialized(handle_t 
*handle,
newblock = iblock - ee_block + ext_pblock(ex);
ex2 = ex;
 
+   err = ext4_ext_get_access(handle, inode, path + depth);
+   if (err)
+   goto out;
+
/* ex1: ee_block to iblock - 1 : uninitialized */
if (iblock  ee_block) {
ex1 = ex;
@@ -2210,6 +2214,10 @@ static int ext4_ext_convert_to_initialized(handle_t 
*handle,
ex = path[depth].p_ext;
if (ex2 != newex)
ex2 = ex;
+
+   err = ext4_ext_get_access(handle, inode, path + depth);
+   if (err)
+   goto out;
}
allocated = max_blocks;
}
@@ -2230,9 +2238,6 @@ static int ext4_ext_convert_to_initialized(handle_t 
*handle,
ex2-ee_len = cpu_to_le16(allocated);
if (ex2 != ex)
goto insert;
-   err = ext4_ext_get_access(handle, inode, path + depth);
-   if (err)
-   goto out;
/*
 * New (initialized) extent starts from the first block
 * in the current extent. i.e., ex2 == ex
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


ext4: Don't claim block from group which has corrupt bitmap

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=e56eb6590693a5a340e8f596db2768a6e1b9e236
Commit: e56eb6590693a5a340e8f596db2768a6e1b9e236
Parent: 9df5643ad135c7f8c02d3b69020de4ec910f9fc0
Author: Aneesh Kumar K.V [EMAIL PROTECTED]
AuthorDate: Fri Feb 15 13:48:21 2008 -0500
Committer:  Theodore Ts'o [EMAIL PROTECTED]
CommitDate: Fri Feb 15 13:48:21 2008 -0500

ext4: Don't claim block from group which has corrupt bitmap

In ext4_mb_complex_scan_group, if the extent length of the newly
found extentet is greater than than the total free blocks counted
in group info, break without claiming the block.

Document different ext4_error usage, explaining the state with which we
continue if we mount with errors=continue

Signed-off-by: Aneesh Kumar K.V [EMAIL PROTECTED]
Signed-off-by: Mingming Cao [EMAIL PROTECTED]
Signed-off-by: Theodore Ts'o [EMAIL PROTECTED]
---
 fs/ext4/mballoc.c |   16 +++-
 1 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 2121184..6968c53 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -967,6 +967,10 @@ static void ext4_mb_generate_buddy(struct super_block *sb,
ext4_error(sb, __FUNCTION__,
EXT4-fs: group %lu: %u blocks in bitmap, %u in gd\n,
group, free, grp-bb_free);
+   /*
+* If we intent to continue, we consider group descritor
+* corrupt and update bb_free using bitmap value
+*/
grp-bb_free = free;
}
 
@@ -1822,7 +1826,7 @@ static void ext4_mb_complex_scan_group(struct 
ext4_allocation_context *ac,
EXT4_BLOCKS_PER_GROUP(sb), i);
if (i = EXT4_BLOCKS_PER_GROUP(sb)) {
/*
-* IF we corrupt the bitmap  we won't find any
+* IF we have corrupt bitmap, we won't find any
 * free blocks even though group info says we
 * we have free blocks
 */
@@ -1838,6 +1842,12 @@ static void ext4_mb_complex_scan_group(struct 
ext4_allocation_context *ac,
ext4_error(sb, __FUNCTION__, %d free blocks as per 
group info. But got %d blocks\n,
free, ex.fe_len);
+   /*
+* The number of free blocks differs. This mostly
+* indicate that the bitmap is corrupt. So exit
+* without claiming the space.
+*/
+   break;
}
 
ext4_mb_measure_extent(ac, ex, e4b);
@@ -3771,6 +3781,10 @@ static int ext4_mb_release_inode_pa(struct ext4_buddy 
*e4b,
(unsigned long) pa-pa_len);
ext4_error(sb, __FUNCTION__, free %u, pa_free %u\n,
free, pa-pa_free);
+   /*
+* pa is already deleted so we use the value obtained
+* from the bitmap and continue.
+*/
}
atomic_add(free, sbi-s_mb_discarded);
if (ac)
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


ext4: modify block allocation algorithm for the last group

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=74d3487fc8aa58cec16dff7239dea1ca59bdab0e
Commit: 74d3487fc8aa58cec16dff7239dea1ca59bdab0e
Parent: e56eb6590693a5a340e8f596db2768a6e1b9e236
Author: Valerie Clement [EMAIL PROTECTED]
AuthorDate: Fri Feb 15 13:43:07 2008 -0500
Committer:  Theodore Ts'o [EMAIL PROTECTED]
CommitDate: Fri Feb 15 13:43:07 2008 -0500

ext4: modify block allocation algorithm for the last group

When a directory inode is allocated in the last group and the last group
contains less than s_blocks_per_group blocks, the initial block allocated
for the directory is not always allocated in the same group as the
directory inode, but in one of the first groups of the filesystem (group 1
for example).
Depending on the current process's pid, ext4_find_near() and
ext4_ext_find_goal() can return a block number greater than the maximum
blocks count in the filesystem and in that case the block will be not
allocated in the same group as the inode.

The following patch fixes the problem.

Should the modification also be done in ext2/3 code?

Signed-off-by: Valerie Clement [EMAIL PROTECTED]
Signed-off-by: Mingming Cao [EMAIL PROTECTED]
Signed-off-by: Theodore Ts'o [EMAIL PROTECTED]
---
 fs/ext4/extents.c |8 +++-
 fs/ext4/inode.c   |8 +++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index c4d6f19..8a59f7b 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -148,6 +148,7 @@ static ext4_fsblk_t ext4_ext_find_goal(struct inode *inode,
 {
struct ext4_inode_info *ei = EXT4_I(inode);
ext4_fsblk_t bg_start;
+   ext4_fsblk_t last_block;
ext4_grpblk_t colour;
int depth;
 
@@ -169,8 +170,13 @@ static ext4_fsblk_t ext4_ext_find_goal(struct inode *inode,
/* OK. use inode's group */
bg_start = (ei-i_block_group * EXT4_BLOCKS_PER_GROUP(inode-i_sb)) +
le32_to_cpu(EXT4_SB(inode-i_sb)-s_es-s_first_data_block);
-   colour = (current-pid % 16) *
+   last_block = ext4_blocks_count(EXT4_SB(inode-i_sb)-s_es) - 1;
+
+   if (bg_start + EXT4_BLOCKS_PER_GROUP(inode-i_sb) = last_block)
+   colour = (current-pid % 16) *
(EXT4_BLOCKS_PER_GROUP(inode-i_sb) / 16);
+   else
+   colour = (current-pid % 16) * ((last_block - bg_start) / 16);
return bg_start + colour + block;
 }
 
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index d3c6f58..34f3eb6 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -403,6 +403,7 @@ static ext4_fsblk_t ext4_find_near(struct inode *inode, 
Indirect *ind)
__le32 *start = ind-bh ? (__le32*) ind-bh-b_data : ei-i_data;
__le32 *p;
ext4_fsblk_t bg_start;
+   ext4_fsblk_t last_block;
ext4_grpblk_t colour;
 
/* Try to find previous block */
@@ -420,8 +421,13 @@ static ext4_fsblk_t ext4_find_near(struct inode *inode, 
Indirect *ind)
 * into the same cylinder group then.
 */
bg_start = ext4_group_first_block_no(inode-i_sb, ei-i_block_group);
-   colour = (current-pid % 16) *
+   last_block = ext4_blocks_count(EXT4_SB(inode-i_sb)-s_es) - 1;
+
+   if (bg_start + EXT4_BLOCKS_PER_GROUP(inode-i_sb) = last_block)
+   colour = (current-pid % 16) *
(EXT4_BLOCKS_PER_GROUP(inode-i_sb) / 16);
+   else
+   colour = (current-pid % 16) * ((last_block - bg_start) / 16);
return bg_start + colour;
 }
 
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


ext4: Don't use ext4_dec_count() if not needed

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=825f1481ead4ce40671089bae7412ac3519e8caa
Commit: 825f1481ead4ce40671089bae7412ac3519e8caa
Parent: 74d3487fc8aa58cec16dff7239dea1ca59bdab0e
Author: Theodore Ts'o [EMAIL PROTECTED]
AuthorDate: Fri Feb 15 15:00:38 2008 -0500
Committer:  Theodore Ts'o [EMAIL PROTECTED]
CommitDate: Fri Feb 15 15:00:38 2008 -0500

ext4: Don't use ext4_dec_count() if not needed

The ext4_dec_count() function is only needed when dropping the i_nlink
count on inodes which are (or which could be) directories.  If we
*know* that the inode in question can't possibly be a directory, use
drop_nlink or clear_nlink() if we know i_nlink is 1.

Signed-off-by: Theodore Ts'o [EMAIL PROTECTED]
---
 fs/ext4/namei.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index fffd080..5a79c6b 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -2161,7 +2161,7 @@ static int ext4_unlink(struct inode * dir, struct dentry 
*dentry)
dir-i_ctime = dir-i_mtime = ext4_current_time(dir);
ext4_update_dx_flag(dir);
ext4_mark_inode_dirty(handle, dir);
-   ext4_dec_count(handle, inode);
+   drop_nlink(inode);
if (!inode-i_nlink)
ext4_orphan_add(handle, inode);
inode-i_ctime = ext4_current_time(inode);
@@ -2211,7 +2211,7 @@ retry:
err = __page_symlink(inode, symname, l,
mapping_gfp_mask(inode-i_mapping)  ~__GFP_FS);
if (err) {
-   ext4_dec_count(handle, inode);
+   clear_nlink(inode);
ext4_mark_inode_dirty(handle, inode);
iput (inode);
goto out_stop;
@@ -2404,7 +2404,7 @@ static int ext4_rename (struct inode * old_dir, struct 
dentry *old_dentry,
ext4_dec_count(handle, old_dir);
if (new_inode) {
/* checked empty_dir above, can't have another parent,
-* ext3_dec_count() won't work for many-linked dirs */
+* ext4_dec_count() won't work for many-linked dirs */
new_inode-i_nlink = 0;
} else {
ext4_inc_count(handle, new_dir);
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


ext4: Fix BUG when writing to an unitialized extent

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=f5ab0d1f8f7df937778c60c3da6f4ef939a54a7b
Commit: f5ab0d1f8f7df937778c60c3da6f4ef939a54a7b
Parent: 825f1481ead4ce40671089bae7412ac3519e8caa
Author: Mingming Cao [EMAIL PROTECTED]
AuthorDate: Mon Feb 25 15:29:55 2008 -0500
Committer:  Theodore Ts'o [EMAIL PROTECTED]
CommitDate: Mon Feb 25 15:29:55 2008 -0500

ext4: Fix BUG when writing to an unitialized extent

This patch fixes a bug when writing to preallocated but uninitialized
blocks, which resulted in a BUG in fs/buffer.c saying that the buffer
is not mapped.

When writing to a file, ext4_get_block_wrap() is called with create=1 in
order to request that blocks be allocated if necessary.  It currently
calls ext4_get_blocks() with create=0 in order to do a lookup first.  If
the inode contains an unitialized data block, the buffer head is left
unampped, which ext4_get_blocks_wrap() returns, causing the BUG.

We fix this by checking to see if the buffer head is unmapped, and if
so, we make sure the the buffer head is mapped by calling
ext4_ext_get_blocks with create=1.

Signed-off-by: Mingming Cao [EMAIL PROTECTED]
Signed-off-by: Theodore Ts'o [EMAIL PROTECTED]
---
 fs/ext4/extents.c |   13 +
 fs/ext4/inode.c   |   47 ---
 2 files changed, 57 insertions(+), 3 deletions(-)

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 8a59f7b..bcf5d04 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -2287,9 +2287,22 @@ out:
 }
 
 /*
+ * Block allocation/map/preallocation routine for extents based files
+ *
+ *
  * Need to be called with
  * down_read(EXT4_I(inode)-i_data_sem) if not allocating file system block
  * (ie, create is zero). Otherwise down_write(EXT4_I(inode)-i_data_sem)
+ *
+ * return  0, number of of blocks already mapped/allocated
+ *  if create == 0 and these are pre-allocated blocks
+ * buffer head is unmapped
+ *  otherwise blocks are mapped
+ *
+ * return = 0, if plain look up failed (blocks have not been allocated)
+ *  buffer head is unmapped
+ *
+ * return  0, error case.
  */
 int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,
ext4_lblk_t iblock,
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 34f3eb6..945cbf6 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -908,11 +908,38 @@ out:
  */
 #define DIO_CREDITS 25
 
+
+/*
+ *
+ *
+ * ext4_ext4 get_block() wrapper function
+ * It will do a look up first, and returns if the blocks already mapped.
+ * Otherwise it takes the write lock of the i_data_sem and allocate blocks
+ * and store the allocated blocks in the result buffer head and mark it
+ * mapped.
+ *
+ * If file type is extents based, it will call ext4_ext_get_blocks(),
+ * Otherwise, call with ext4_get_blocks_handle() to handle indirect mapping
+ * based files
+ *
+ * On success, it returns the number of blocks being mapped or allocate.
+ * if create==0 and the blocks are pre-allocated and uninitialized block,
+ * the result buffer head is unmapped. If the create ==1, it will make sure
+ * the buffer head is mapped.
+ *
+ * It returns 0 if plain look up failed (blocks have not been allocated), in
+ * that casem, buffer head is unmapped
+ *
+ * It returns the error in case of allocation failure.
+ */
 int ext4_get_blocks_wrap(handle_t *handle, struct inode *inode, sector_t block,
unsigned long max_blocks, struct buffer_head *bh,
int create, int extend_disksize)
 {
int retval;
+
+   clear_buffer_mapped(bh);
+
/*
 * Try to see if we can get  the block without requesting
 * for new file system block.
@@ -926,12 +953,26 @@ int ext4_get_blocks_wrap(handle_t *handle, struct inode 
*inode, sector_t block,
inode, block, max_blocks, bh, 0, 0);
}
up_read((EXT4_I(inode)-i_data_sem));
-   if (!create || (retval  0))
+
+   /* If it is only a block(s) look up */
+   if (!create)
+   return retval;
+
+   /*
+* Returns if the blocks have already allocated
+*
+* Note that if blocks have been preallocated
+* ext4_ext_get_block() returns th create = 0
+* with buffer head unmapped.
+*/
+   if (retval  0  buffer_mapped(bh))
return retval;
 
/*
-* We need to allocate new blocks which will result
-* in i_data update
+* New blocks allocate and/or writing to uninitialized extent
+* will possibly result in updating i_data, so we take
+* the write lock of i_data_sem, and call get_blocks()
+* with create == 1 flag.
 */
down_write((EXT4_I(inode)-i_data_sem));
/*
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the 

ext4: set EXT4_EXTENTS_FL only for directory and regular files

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=42bf0383d1e09dd1b38f3debb13a76b2f87634b3
Commit: 42bf0383d1e09dd1b38f3debb13a76b2f87634b3
Parent: 2c98615d3b64ce7888cd46cc668023f456daf287
Author: Aneesh Kumar K.V [EMAIL PROTECTED]
AuthorDate: Mon Feb 25 16:38:03 2008 -0500
Committer:  Theodore Ts'o [EMAIL PROTECTED]
CommitDate: Mon Feb 25 16:38:03 2008 -0500

ext4: set EXT4_EXTENTS_FL only for directory and regular files

In addition, don't inherit EXT4_EXTENTS_FL from parent directory.
If we have a directory with extent flag set and later mount the file
system with -o noextents, the files created in that directory will also
have extent flag set but we would not have called ext4_ext_tree_init for
them. This will cause error later when we are verifying the extent header

Signed-off-by: Aneesh Kumar K.V [EMAIL PROTECTED]
Acked-off-by: Eric Sandeen [EMAIL PROTECTED]
Signed-off-by: Mingming Cao [EMAIL PROTECTED]
Signed-off-by: Theodore Ts'o [EMAIL PROTECTED]
---
 fs/ext4/ialloc.c |   22 +++---
 fs/ext4/namei.c  |1 -
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index da18a74..8036b9b 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -702,7 +702,12 @@ got:
ei-i_dir_start_lookup = 0;
ei-i_disksize = 0;
 
-   ei-i_flags = EXT4_I(dir)-i_flags  ~EXT4_INDEX_FL;
+   /*
+* Don't inherit extent flag from directory. We set extent flag on
+* newly created directory and file only if -o extent mount option is
+* specified
+*/
+   ei-i_flags = EXT4_I(dir)-i_flags  ~(EXT4_INDEX_FL|EXT4_EXTENTS_FL);
if (S_ISLNK(mode))
ei-i_flags = ~(EXT4_IMMUTABLE_FL|EXT4_APPEND_FL);
/* dirsync only applies to directories */
@@ -745,12 +750,15 @@ got:
goto fail_free_drop;
}
if (test_opt(sb, EXTENTS)) {
-   EXT4_I(inode)-i_flags |= EXT4_EXTENTS_FL;
-   ext4_ext_tree_init(handle, inode);
-   err = ext4_update_incompat_feature(handle, sb,
-   EXT4_FEATURE_INCOMPAT_EXTENTS);
-   if (err)
-   goto fail;
+   /* set extent flag only for directory and file */
+   if (S_ISDIR(mode) || S_ISREG(mode)) {
+   EXT4_I(inode)-i_flags |= EXT4_EXTENTS_FL;
+   ext4_ext_tree_init(handle, inode);
+   err = ext4_update_incompat_feature(handle, sb,
+   EXT4_FEATURE_INCOMPAT_EXTENTS);
+   if (err)
+   goto fail;
+   }
}
 
ext4_debug(allocating inode %lu\n, inode-i_ino);
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 5a79c6b..28aa2ed 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -2220,7 +2220,6 @@ retry:
inode-i_op = ext4_fast_symlink_inode_operations;
memcpy((char*)EXT4_I(inode)-i_data,symname,l);
inode-i_size = l-1;
-   EXT4_I(inode)-i_flags = ~EXT4_EXTENTS_FL;
}
EXT4_I(inode)-i_disksize = inode-i_size;
err = ext4_add_nondir(handle, dentry, inode);
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


ext4: ext4_find_next_zero_bit needs an aligned address on some arch

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=ffad0a44b7216d0f079dcf95a351082099d1e5fb
Commit: ffad0a44b7216d0f079dcf95a351082099d1e5fb
Parent: 42bf0383d1e09dd1b38f3debb13a76b2f87634b3
Author: Aneesh Kumar K.V [EMAIL PROTECTED]
AuthorDate: Sat Feb 23 01:38:34 2008 -0500
Committer:  Theodore Ts'o [EMAIL PROTECTED]
CommitDate: Sat Feb 23 01:38:34 2008 -0500

ext4: ext4_find_next_zero_bit needs an aligned address on some arch

ext4_find_next_zero_bit and ext4_find_next_bit needs a long aligned
address on x8_64. Add mb_find_next_zero_bit and mb_find_next_bit
and use them in the mballoc.

Fix: https://bugzilla.redhat.com/show_bug.cgi?id=433286

Eric Sandeen debugged the problem and suggested the fix.

Signed-off-by: Aneesh Kumar K.V [EMAIL PROTECTED]
Acked-by:  Eric Sandeen [EMAIL PROTECTED]
Signed-off-by: Mingming Cao [EMAIL PROTECTED]
Signed-off-by: Theodore Ts'o [EMAIL PROTECTED]
---
 fs/ext4/mballoc.c |   62 ++--
 1 files changed, 40 insertions(+), 22 deletions(-)

diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 6968c53..ef97f19 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -627,21 +627,19 @@ static ext4_fsblk_t ext4_grp_offs_to_block(struct 
super_block *sb,
return block;
 }
 
+static inline void *mb_correct_addr_and_bit(int *bit, void *addr)
+{
 #if BITS_PER_LONG == 64
-#define mb_correct_addr_and_bit(bit, addr) \
-{  \
-   bit += ((unsigned long) addr  7UL)  3;   \
-   addr = (void *) ((unsigned long) addr  ~7UL);  \
-}
+   *bit += ((unsigned long) addr  7UL)  3;
+   addr = (void *) ((unsigned long) addr  ~7UL);
 #elif BITS_PER_LONG == 32
-#define mb_correct_addr_and_bit(bit, addr) \
-{  \
-   bit += ((unsigned long) addr  3UL)  3;   \
-   addr = (void *) ((unsigned long) addr  ~3UL);  \
-}
+   *bit += ((unsigned long) addr  3UL)  3;
+   addr = (void *) ((unsigned long) addr  ~3UL);
 #else
 #error how many bits you are?!
 #endif
+   return addr;
+}
 
 static inline int mb_test_bit(int bit, void *addr)
 {
@@ -649,34 +647,54 @@ static inline int mb_test_bit(int bit, void *addr)
 * ext4_test_bit on architecture like powerpc
 * needs unsigned long aligned address
 */
-   mb_correct_addr_and_bit(bit, addr);
+   addr = mb_correct_addr_and_bit(bit, addr);
return ext4_test_bit(bit, addr);
 }
 
 static inline void mb_set_bit(int bit, void *addr)
 {
-   mb_correct_addr_and_bit(bit, addr);
+   addr = mb_correct_addr_and_bit(bit, addr);
ext4_set_bit(bit, addr);
 }
 
 static inline void mb_set_bit_atomic(spinlock_t *lock, int bit, void *addr)
 {
-   mb_correct_addr_and_bit(bit, addr);
+   addr = mb_correct_addr_and_bit(bit, addr);
ext4_set_bit_atomic(lock, bit, addr);
 }
 
 static inline void mb_clear_bit(int bit, void *addr)
 {
-   mb_correct_addr_and_bit(bit, addr);
+   addr = mb_correct_addr_and_bit(bit, addr);
ext4_clear_bit(bit, addr);
 }
 
 static inline void mb_clear_bit_atomic(spinlock_t *lock, int bit, void *addr)
 {
-   mb_correct_addr_and_bit(bit, addr);
+   addr = mb_correct_addr_and_bit(bit, addr);
ext4_clear_bit_atomic(lock, bit, addr);
 }
 
+static inline int mb_find_next_zero_bit(void *addr, int max, int start)
+{
+   int fix = 0;
+   addr = mb_correct_addr_and_bit(fix, addr);
+   max += fix;
+   start += fix;
+
+   return ext4_find_next_zero_bit(addr, max, start) - fix;
+}
+
+static inline int mb_find_next_bit(void *addr, int max, int start)
+{
+   int fix = 0;
+   addr = mb_correct_addr_and_bit(fix, addr);
+   max += fix;
+   start += fix;
+
+   return ext4_find_next_bit(addr, max, start) - fix;
+}
+
 static void *mb_find_buddy(struct ext4_buddy *e4b, int order, int *max)
 {
char *bb;
@@ -946,12 +964,12 @@ static void ext4_mb_generate_buddy(struct super_block *sb,
 
/* initialize buddy from bitmap which is aggregation
 * of on-disk bitmap and preallocations */
-   i = ext4_find_next_zero_bit(bitmap, max, 0);
+   i = mb_find_next_zero_bit(bitmap, max, 0);
grp-bb_first_free = i;
while (i  max) {
fragments++;
first = i;
-   i = ext4_find_next_bit(bitmap, max, i);
+   i = mb_find_next_bit(bitmap, max, i);
len = i - first;
free += len;
if (len  1)
@@ -959,7 +977,7 @@ static void ext4_mb_generate_buddy(struct super_block *sb,
else
grp-bb_counters[0]++;
if (i  max)
-   i = ext4_find_next_zero_bit(bitmap, max, i);
+   i = mb_find_next_zero_bit(bitmap, max, i);
 

ext4: add missing ext4_journal_stop()

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=5606bf5d0cbfbc3dfa78793a3793c43dd045fb1b
Commit: 5606bf5d0cbfbc3dfa78793a3793c43dd045fb1b
Parent: ffad0a44b7216d0f079dcf95a351082099d1e5fb
Author: Akinobu Mita [EMAIL PROTECTED]
AuthorDate: Mon Feb 25 15:37:42 2008 -0500
Committer:  Theodore Ts'o [EMAIL PROTECTED]
CommitDate: Mon Feb 25 15:37:42 2008 -0500

ext4: add missing ext4_journal_stop()

Add missing ext4_journal_stop() in error handling.

Signed-off-by: Akinobu Mita [EMAIL PROTECTED]
Signed-off-by: Theodore Ts'o [EMAIL PROTECTED]
Cc: Stephen Tweedie [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Cc: Andrew Morton [EMAIL PROTECTED]
Cc: Mingming Cao [EMAIL PROTECTED]
---
 fs/ext4/resize.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
index 9477a2b..e29efa0 100644
--- a/fs/ext4/resize.c
+++ b/fs/ext4/resize.c
@@ -1037,6 +1037,7 @@ int ext4_group_extend(struct super_block *sb, struct 
ext4_super_block *es,
ext4_warning(sb, __FUNCTION__,
 multiple resizers run on filesystem!);
unlock_super(sb);
+   ext4_journal_stop(handle);
err = -EBUSY;
goto exit_put;
}
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Remove empty file fs/xfs/Makefile-linux-2.6.

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=6e5e93424dc66542c548dfaa3bfebe30d46d50dd
Commit: 6e5e93424dc66542c548dfaa3bfebe30d46d50dd
Parent: c58310bf4933986513020fa90b4190c7492995ae
Author: Lachlan McIlroy [EMAIL PROTECTED]
AuthorDate: Fri Feb 22 15:36:19 2008 +1100
Committer:  Lachlan McIlroy [EMAIL PROTECTED]
CommitDate: Fri Feb 22 15:39:10 2008 +1100

Remove empty file fs/xfs/Makefile-linux-2.6.
---
 0 files changed, 0 insertions(+), 0 deletions(-)

diff --git a/fs/xfs/Makefile-linux-2.6 b/fs/xfs/Makefile-linux-2.6
deleted file mode 100644
index e69de29..000
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[XFS] Undo bit ops cleanup mod due to regression on 32-bit powermac

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=db69c915e67705daac25cad06d816c09be634de0
Commit: db69c915e67705daac25cad06d816c09be634de0
Parent: 91e229bbad6524aabaac8717b2f559283670c37a
Author: Lachlan McIlroy [EMAIL PROTECTED]
AuthorDate: Tue Feb 26 17:00:14 2008 +1100
Committer:  Lachlan McIlroy [EMAIL PROTECTED]
CommitDate: Tue Feb 26 17:05:37 2008 +1100

[XFS] Undo bit ops cleanup mod due to regression on 32-bit powermac
platform.

SGI-PV: 974005
SGI-Modid: xfs-linux-melb:xfs-kern:30558a

Signed-off-by: Lachlan McIlroy [EMAIL PROTECTED]
---
 fs/xfs/xfs_bit.h |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/xfs/xfs_bit.h b/fs/xfs/xfs_bit.h
index 325a007..0f9fc9a 100644
--- a/fs/xfs/xfs_bit.h
+++ b/fs/xfs/xfs_bit.h
@@ -61,15 +61,15 @@ static inline int xfs_highbit64(__uint64_t v)
 /* Get low bit set out of 32-bit argument, -1 if none set */
 static inline int xfs_lowbit32(__uint32_t v)
 {
-   __uint32_t t = v;
-   return (t) ? find_first_bit((unsigned long *)t, 32) : -1;
+   unsigned long   t = v;
+   return (v) ? find_first_bit(t, 32) : -1;
 }
 
 /* Get low bit set out of 64-bit argument, -1 if none set */
 static inline int xfs_lowbit64(__uint64_t v)
 {
-   __uint64_t t = v;
-   return (t) ? find_first_bit((unsigned long *)t, 64) : -1;
+   unsigned long   t = v;
+   return (v) ? find_first_bit(t, 64) : -1;
 }
 
 /* Return whether bitmap is empty (1 == empty) */
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[XFS] Undo bit ops cleanup mod due to regression on 32-bit powermac

2008-02-26 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=ef8ece55d9b6825c28a5c1a4bd89b94040cb7b32
Commit: ef8ece55d9b6825c28a5c1a4bd89b94040cb7b32
Parent: db69c915e67705daac25cad06d816c09be634de0
Author: Lachlan McIlroy [EMAIL PROTECTED]
AuthorDate: Tue Feb 26 17:00:22 2008 +1100
Committer:  Lachlan McIlroy [EMAIL PROTECTED]
CommitDate: Tue Feb 26 17:05:44 2008 +1100

[XFS] Undo bit ops cleanup mod due to regression on 32-bit powermac
platform.

SGI-PV: 971186
SGI-Modid: xfs-linux-melb:xfs-kern:30559a

Signed-off-by: Lachlan McIlroy [EMAIL PROTECTED]
---
 fs/xfs/xfs_bit.c |  103 ++
 fs/xfs/xfs_bit.h |   27 ++---
 fs/xfs/xfs_rtalloc.c |   19 ++---
 3 files changed, 120 insertions(+), 29 deletions(-)

diff --git a/fs/xfs/xfs_bit.c b/fs/xfs/xfs_bit.c
index 4822884..fab0b6d 100644
--- a/fs/xfs/xfs_bit.c
+++ b/fs/xfs/xfs_bit.c
@@ -25,6 +25,109 @@
  * XFS bit manipulation routines, used in non-realtime code.
  */
 
+#ifndef HAVE_ARCH_HIGHBIT
+/*
+ * Index of high bit number in byte, -1 for none set, 0..7 otherwise.
+ */
+static const char xfs_highbit[256] = {
+   -1, 0, 1, 1, 2, 2, 2, 2,/* 00 .. 07 */
+   3, 3, 3, 3, 3, 3, 3, 3, /* 08 .. 0f */
+   4, 4, 4, 4, 4, 4, 4, 4, /* 10 .. 17 */
+   4, 4, 4, 4, 4, 4, 4, 4, /* 18 .. 1f */
+   5, 5, 5, 5, 5, 5, 5, 5, /* 20 .. 27 */
+   5, 5, 5, 5, 5, 5, 5, 5, /* 28 .. 2f */
+   5, 5, 5, 5, 5, 5, 5, 5, /* 30 .. 37 */
+   5, 5, 5, 5, 5, 5, 5, 5, /* 38 .. 3f */
+   6, 6, 6, 6, 6, 6, 6, 6, /* 40 .. 47 */
+   6, 6, 6, 6, 6, 6, 6, 6, /* 48 .. 4f */
+   6, 6, 6, 6, 6, 6, 6, 6, /* 50 .. 57 */
+   6, 6, 6, 6, 6, 6, 6, 6, /* 58 .. 5f */
+   6, 6, 6, 6, 6, 6, 6, 6, /* 60 .. 67 */
+   6, 6, 6, 6, 6, 6, 6, 6, /* 68 .. 6f */
+   6, 6, 6, 6, 6, 6, 6, 6, /* 70 .. 77 */
+   6, 6, 6, 6, 6, 6, 6, 6, /* 78 .. 7f */
+   7, 7, 7, 7, 7, 7, 7, 7, /* 80 .. 87 */
+   7, 7, 7, 7, 7, 7, 7, 7, /* 88 .. 8f */
+   7, 7, 7, 7, 7, 7, 7, 7, /* 90 .. 97 */
+   7, 7, 7, 7, 7, 7, 7, 7, /* 98 .. 9f */
+   7, 7, 7, 7, 7, 7, 7, 7, /* a0 .. a7 */
+   7, 7, 7, 7, 7, 7, 7, 7, /* a8 .. af */
+   7, 7, 7, 7, 7, 7, 7, 7, /* b0 .. b7 */
+   7, 7, 7, 7, 7, 7, 7, 7, /* b8 .. bf */
+   7, 7, 7, 7, 7, 7, 7, 7, /* c0 .. c7 */
+   7, 7, 7, 7, 7, 7, 7, 7, /* c8 .. cf */
+   7, 7, 7, 7, 7, 7, 7, 7, /* d0 .. d7 */
+   7, 7, 7, 7, 7, 7, 7, 7, /* d8 .. df */
+   7, 7, 7, 7, 7, 7, 7, 7, /* e0 .. e7 */
+   7, 7, 7, 7, 7, 7, 7, 7, /* e8 .. ef */
+   7, 7, 7, 7, 7, 7, 7, 7, /* f0 .. f7 */
+   7, 7, 7, 7, 7, 7, 7, 7, /* f8 .. ff */
+};
+#endif
+
+/*
+ * xfs_highbit32: get high bit set out of 32-bit argument, -1 if none set.
+ */
+inline int
+xfs_highbit32(
+   __uint32_t  v)
+{
+#ifdef HAVE_ARCH_HIGHBIT
+   return highbit32(v);
+#else
+   int i;
+
+   if (v  0x)
+   if (v  0xff00)
+   i = 24;
+   else
+   i = 16;
+   else if (v  0x)
+   if (v  0xff00)
+   i = 8;
+   else
+   i = 0;
+   else
+   return -1;
+   return i + xfs_highbit[(v  i)  0xff];
+#endif
+}
+
+/*
+ * xfs_lowbit64: get low bit set out of 64-bit argument, -1 if none set.
+ */
+int
+xfs_lowbit64(
+   __uint64_t  v)
+{
+   __uint32_t  w = (__uint32_t)v;
+   int n = 0;
+
+   if (w) {/* lower bits */
+   n = ffs(w);
+   } else {/* upper bits */
+   w = (__uint32_t)(v  32);
+   if (w  (n = ffs(w)))
+   n += 32;
+   }
+   return n - 1;
+}
+
+/*
+ * xfs_highbit64: get high bit set out of 64-bit argument, -1 if none set.
+ */
+int
+xfs_highbit64(
+   __uint64_t  v)
+{
+   __uint32_t  h = (__uint32_t)(v  32);
+
+   if (h)
+   return xfs_highbit32(h) + 32;
+   return xfs_highbit32((__uint32_t)v);
+}
+
+
 /*
  * Return whether bitmap is empty.
  * Size is number of words in the bitmap, which is padded to word boundary
diff --git a/fs/xfs/xfs_bit.h b/fs/xfs/xfs_bit.h
index 0f9fc9a..082641a 100644
--- a/fs/xfs/xfs_bit.h
+++ b/fs/xfs/xfs_bit.h
@@ -47,30 +47,13 @@ static inline __uint64_t xfs_mask64lo(int n)
 }
 
 /* Get high bit set out of 32-bit