* Re: [RFC PATCH 0/3] restartable sequences: fast user-space percpu critical sections
From: Andy Lutomirski @ 2015-06-27 16:25 UTC (permalink / raw)
To: Paul Turner
Cc: Mathieu Desnoyers, Peter Zijlstra, Paul E. McKenney,
Andrew Hunter, Andi Kleen, Lai Jiangshan, linux-api, LKML,
rostedt, Josh Triplett, Ingo Molnar, Andrew Morton,
Linus Torvalds, Chris Lameter
In-Reply-To: <CAPM31RJwFJXjxLnwFMCBE1=wVXyU06ttrT-_fNr1rb=+ewxVrg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
Let me try to summarize some of the approaches with their pros and cons:
--- percpu segment ---
This is probably the simplest and might make sense regardless.
cmpxchg can be used to do an atomic push onto a linked list. I think
that unlocked cmpxchg16b can be used to get an atomic pop. (You'd
have the list head pointer next to an auxiliary pointer to the second
element in the list, perhaps.)
You can also use this for limited forms of speculative locking.
Aborting cleanly if your lock is stolen might require the kernel's
help, though (you're now on the wrong cpu, so you can't atomically
poke the lock variable any more).
The ABI is straightforward, and the only limitation on multiple users
in the same process is that they need to coordinate their offsets into
the percpu segment.
--- vdso-provided atomic ops ---
This could be quite flexible. The upside is that the ABI would be
straightforward (call a function with clearly-specified behavior).
The downside is that implementing it well might require percpu
segments and a certain amount of coordination, and it requires a
function call.
One nice thing about doing it in the vdso is that we can change the
implementation down the road.
--- kernel preemption hooks ---
I'm defining a preemption hook as an action taken by the kernel when a
user task is preempted during a critical section.
As an upside, we get extremely efficient, almost arbitrary percpu
operations. We don't need to worry about memory ordering at all,
because the whole sequence aborts if anything else might run on the
same cpu. Push and pop are both easy.
One con is that actually defining where the critical section is might
be nasty. If there's a single IP range, then two libraries could
fight over it. We could have a variable somewhere that you write to
arm the critical section, but that's a bit slower.
Another con is that you can't single-step through this type of
critical section. It will be preempted every time.
--- kernel migration hooks ---
I'm not sure either Paul or Mattieu discussed this, but another option
would be to have some special handling if a task is migrated during a
critical section or to allow a task to prevent migration entirely
during a critical section. From the user's point of view, this is
weaker than preemption hooks: it's possible to start your critical
section, be preempted, and have another thread enter its own critical
section, then get rescheduled on the same cpu without aborting. Users
would have to use local atomics (like cmpxchg) to make it useful.
As a major advantage, single-stepping still works.
This shares the coordination downside with preemption hooks (users
have to tell the kernel about their critical sections somehow).
Push can certainly be implemented using cmpxchg. The gs prefix isn't
even needed. Pop might be harder to implement directly without
resorting to cmpxchg16b or similar.
--- Unnamed trick ---
On entry to a critical section, try to take a per-cpu lock that stores
the holder's tid. This might require percpu segments.
If you get the lock, then start doing your thing. For example, you
could pop by reading head->next and writing it back to head.
If, however, you miss the lock, then you need to either wait or
forcibly abort the lock holder. You could do the latter by sending a
signal or possibly using a new syscall that atomically aborts the lock
holder and takes the lock. You don't need to wait, though -- all you
need to do is queue the signal and, if the lock holder is actually
running, wait for signal delivery to start.
Thoughts? I personally like the other options better than preemption
hooks. I prefer solutions that don't interfere with debugging.
--Andy
^ permalink raw reply
* [RFC v3 23/24] m68k/mac: Fix PRAM accessors
From: Finn Thain @ 2015-06-28 1:42 UTC (permalink / raw)
To: linux-kernel, linux-m68k, linuxppc-dev, Geert Uytterhoeven,
linux-api
In-Reply-To: <20150628014159.732792697@telegraphics.com.au>
[-- Attachment #1: mac68k-fix-pram-accessors --]
[-- Type: text/plain, Size: 3451 bytes --]
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
---
Tested on a PowerBook 520 and Quadra 650.
Changes since v2:
- Make use of the RTC_* macros from the previous patch and add a few more
besides.
---
arch/m68k/mac/misc.c | 39 +++++++++++++++++++++++++++++++++------
include/uapi/linux/pmu.h | 2 ++
2 files changed, 35 insertions(+), 6 deletions(-)
Index: linux/arch/m68k/mac/misc.c
===================================================================
--- linux.orig/arch/m68k/mac/misc.c 2015-06-28 11:41:54.000000000 +1000
+++ linux/arch/m68k/mac/misc.c 2015-06-28 11:41:55.000000000 +1000
@@ -119,19 +119,22 @@ static void pmu_write_time(long data)
static unsigned char pmu_pram_read_byte(int offset)
{
struct adb_request req;
- if (pmu_request(&req, NULL, 3, PMU_READ_NVRAM,
- (offset >> 8) & 0xFF, offset & 0xFF) < 0)
+
+ if (pmu_request(&req, NULL, 3, PMU_READ_XPRAM,
+ offset & 0xFF, 1) < 0)
return 0;
while (!req.complete)
pmu_poll();
- return req.reply[3];
+
+ return req.reply[1];
}
static void pmu_pram_write_byte(unsigned char data, int offset)
{
struct adb_request req;
- if (pmu_request(&req, NULL, 4, PMU_WRITE_NVRAM,
- (offset >> 8) & 0xFF, offset & 0xFF, data) < 0)
+
+ if (pmu_request(&req, NULL, 4, PMU_WRITE_XPRAM,
+ offset & 0xFF, 1, data) < 0)
return;
while (!req.complete)
pmu_poll();
@@ -257,6 +260,16 @@ static void via_rtc_send(__u8 data)
#define RTC_REG_WRITE_PROTECT 13
/*
+ * Inside Mac has no information about two-byte RTC commands but
+ * the MESS source code has the essentials.
+ */
+
+#define RTC_REG_XPRAM 14
+#define RTC_CMD_XPRAM_READ (RTC_CMD_READ(RTC_REG_XPRAM) << 8)
+#define RTC_CMD_XPRAM_WRITE (RTC_CMD_WRITE(RTC_REG_XPRAM) << 8)
+#define RTC_CMD_XPRAM_ARG(a) (((a & 0xE0) << 3) | ((a & 0x1F) << 2))
+
+/*
* Execute a VIA PRAM/RTC command. For read commands
* data should point to a one-byte buffer for the
* resulting data. For write commands it should point
@@ -303,11 +316,25 @@ static void via_rtc_command(int command,
static unsigned char via_pram_read_byte(int offset)
{
- return 0;
+ unsigned char temp;
+
+ via_rtc_command(RTC_CMD_XPRAM_READ | RTC_CMD_XPRAM_ARG(offset), &temp);
+
+ return temp;
}
static void via_pram_write_byte(unsigned char data, int offset)
{
+ unsigned char temp;
+
+ temp = 0x55;
+ via_rtc_command(RTC_CMD_WRITE(RTC_REG_WRITE_PROTECT), &temp);
+
+ temp = data;
+ via_rtc_command(RTC_CMD_XPRAM_WRITE | RTC_CMD_XPRAM_ARG(offset), &temp);
+
+ temp = 0x55 | RTC_FLG_WRITE_PROTECT;
+ via_rtc_command(RTC_CMD_WRITE(RTC_REG_WRITE_PROTECT), &temp);
}
/*
Index: linux/include/uapi/linux/pmu.h
===================================================================
--- linux.orig/include/uapi/linux/pmu.h 2015-06-28 11:41:27.000000000 +1000
+++ linux/include/uapi/linux/pmu.h 2015-06-28 11:41:55.000000000 +1000
@@ -18,7 +18,9 @@
#define PMU_POWER_CTRL 0x11 /* control power of some devices */
#define PMU_ADB_CMD 0x20 /* send ADB packet */
#define PMU_ADB_POLL_OFF 0x21 /* disable ADB auto-poll */
+#define PMU_WRITE_XPRAM 0x32 /* write eXtended Parameter RAM */
#define PMU_WRITE_NVRAM 0x33 /* write non-volatile RAM */
+#define PMU_READ_XPRAM 0x3a /* read eXtended Parameter RAM */
#define PMU_READ_NVRAM 0x3b /* read non-volatile RAM */
#define PMU_SET_RTC 0x30 /* set real-time clock */
#define PMU_READ_RTC 0x38 /* read real-time clock */
^ permalink raw reply
* Re: [RFC PATCH 0/3] restartable sequences: fast user-space percpu critical sections
From: Mathieu Desnoyers @ 2015-06-28 16:11 UTC (permalink / raw)
To: Andy Lutomirski
Cc: Paul Turner, Peter Zijlstra, Paul E. McKenney, Andrew Hunter,
Andi Kleen, Lai Jiangshan, linux-api, LKML, rostedt,
Josh Triplett, Ingo Molnar, Andrew Morton, Linus Torvalds,
Chris Lameter
In-Reply-To: <CALCETrVRE+6nM6DGa8ph84cX+CdRXh+qXyReU+jHgx9-+uCTyg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
----- On Jun 27, 2015, at 12:25 PM, Andy Lutomirski luto-kltTT9wpgjJwATOyAt5JVQ@public.gmane.org wrote:
> Let me try to summarize some of the approaches with their pros and cons:
>
I can try summarizing a desiderata that I gather from this
thread so far:
- *very fast* accesses for per-cpu push/pop, per-cpu lock
acquisition, and per-cpu counters,
- guaranteed progress (don't loop forever when single-stepped),
- critical section implementation flexibility:
- can be written only in assembly or also in C,
- provide a single building-block (e.g. cmpxchg) or allow
applications/libraries to do arbitrary critical sections,
- portability to non-x86 architectures,
- low-intrusiveness for injection into applications (no signal
handler, no segment selector used by pre-existing applications).
- can be used by either a single or many shared objects per process,
- don't disturb real-time scheduling,
- minimal slowdown of kernel scheduling execution.
More comments on each approach below:
> --- percpu segment ---
>
> This is probably the simplest and might make sense regardless.
> cmpxchg can be used to do an atomic push onto a linked list. I think
> that unlocked cmpxchg16b can be used to get an atomic pop. (You'd
> have the list head pointer next to an auxiliary pointer to the second
> element in the list, perhaps.)
Based on http://www.agner.org/optimize/instruction_tables.pdf
On Intel Haswell:
instruction latency (cycles)
cmpxchg: 8
lock cmpxchg: 19
cmpxchg16b: 15
cmpxchg16b does not appear to be particularly fast (twice the latency of
cmpxchg).
>
> You can also use this for limited forms of speculative locking.
> Aborting cleanly if your lock is stolen might require the kernel's
> help, though (you're now on the wrong cpu, so you can't atomically
> poke the lock variable any more).
>
> The ABI is straightforward, and the only limitation on multiple users
> in the same process is that they need to coordinate their offsets into
> the percpu segment.
One more downside about this approach: some applications already use
the gs segment (AFAIK the wine emulator uses it), so can be prohibitive
to use it from tracing code injected into pre-existing applications.
Another downside is that it is x86-specific.
>
> --- vdso-provided atomic ops ---
>
> This could be quite flexible. The upside is that the ABI would be
> straightforward (call a function with clearly-specified behavior).
Following same ref as above, the call/ret pair alone would cost
about 5 cycles.
> The downside is that implementing it well might require percpu
> segments and a certain amount of coordination, and it requires a
> function call.
Same downside as above about gs segment being already used by some
applications.
>
> One nice thing about doing it in the vdso is that we can change the
> implementation down the road.
Yes, this is clearly an advantage over letting applications inline
their cmpxchg on gs:.
Same downside as above about being x86-specific.
>
> --- kernel preemption hooks ---
>
> I'm defining a preemption hook as an action taken by the kernel when a
> user task is preempted during a critical section.
>
> As an upside, we get extremely efficient, almost arbitrary percpu
> operations. We don't need to worry about memory ordering at all,
> because the whole sequence aborts if anything else might run on the
> same cpu. Push and pop are both easy.
>
> One con is that actually defining where the critical section is might
> be nasty. If there's a single IP range, then two libraries could
> fight over it. We could have a variable somewhere that you write to
> arm the critical section, but that's a bit slower.
My current understanding is that we have two means to tell the kernel
"we are in a critical section": either through register content or
through a per-thread memory area. Paul's implementation uses the
instruction pointer, but it could perhaps use another reserved register
state, which might help us do the critical functions in C code rather
than assembly. It might be tricky to find a register that is guaranteed
not to be used though, hence the per-thread memory area.
The per-thread memory area has the advantage of allowing the critical
sections to be implemented in C code rather than assembly, but, as you
say, its downside is that we need at the very least to set/clear a TLS
flag (or have a nesting counter) surrounding the critical section. This
approach is quite similar to preempt_disable()/preempt_enable() in the
Linux kernel.
Another advantage of preempt migration hooks over migration hooks
is that the critical section can assume it has mutually exclusive
access, which is not the case for migration hooks, because it can
be preempted and continue execution afterward. This means what can
be achieved with e.g. "load+test+store" with preempt hook needs to
be performed with "cmpxchg" with migration hooks. This might not be
a huge issue for x86, but can become more expensive on other
architectures.
>
> Another con is that you can't single-step through this type of
> critical section. It will be preempted every time.
Could we simply make single-stepping skip over those critical
sections ? AFAIU the kernel should have all the information needed
to do that.
One more advantage: could be implemented for all architectures.
Then the part that is missing from this summary is how to handle
the "restart". Paul's approach moves execution to a restart ip,
which is fine since the entire critical section is written in
assembly. My approach uses page protection on the per-thread
virtual memory mapping to the per-cpu data (e.g. the lock) to
make the thread fault. My approach is more intrusive (requires
implementation of SIGSEGV handler in user-space), but allows
doing the critical sections in plain C.
>
> --- kernel migration hooks ---
>
> I'm not sure either Paul or Mattieu discussed this, but another option
> would be to have some special handling if a task is migrated during a
> critical section
I don't think we discussed this yet. See my point above about not
having exclusive access within the critical section. This can be
limiting, especially on architectures that don't provide per-cpu
atomic ops as efficient as x86 cmpxchg.
> or to allow a task to prevent migration entirely
> during a critical section.
Following past discussion with Peter Zijlstra, I understood that this
approach would receive a huge pushback from real-time people, since
letting user-space hold off migration for an arbitrary amount of time
destroys many nice real-time guarantees. However, since the kernel
also allows threads to pin themselves to specific cores explicitly,
I still don't get how preventing migration from userspace for an
arbitrary amount of time is different from setting CPU affinity.
> From the user's point of view, this is
> weaker than preemption hooks: it's possible to start your critical
> section, be preempted, and have another thread enter its own critical
> section, then get rescheduled on the same cpu without aborting. Users
> would have to use local atomics (like cmpxchg) to make it useful.
>
> As a major advantage, single-stepping still works.
>
> This shares the coordination downside with preemption hooks (users
> have to tell the kernel about their critical sections somehow).
>
> Push can certainly be implemented using cmpxchg. The gs prefix isn't
> even needed. Pop might be harder to implement directly without
> resorting to cmpxchg16b or similar.
>
> --- Unnamed trick ---
>
> On entry to a critical section, try to take a per-cpu lock that stores
> the holder's tid. This might require percpu segments.
>
> If you get the lock, then start doing your thing. For example, you
> could pop by reading head->next and writing it back to head.
>
> If, however, you miss the lock, then you need to either wait or
> forcibly abort the lock holder. You could do the latter by sending a
> signal or possibly using a new syscall that atomically aborts the lock
> holder and takes the lock. You don't need to wait, though -- all you
> need to do is queue the signal and, if the lock holder is actually
> running, wait for signal delivery to start.
Aborting the critical section can be tricky in the general case. See
my point above about critical sections written in assembly or C.
Would you require that c.s. are written in assembly for this ?
>
> Thoughts? I personally like the other options better than preemption
> hooks. I prefer solutions that don't interfere with debugging.
Would skipping over the critical section be doable/acceptable for the
single-stepping case ?
One more card we have is to design algorithms that have a restartable
fast-path, but their restart point go to a path that is guaranteed to
progress. For instance, lock-acquisition can be achieved in this way
using a "2-threads" Peterson's algorithm for each core where the variable
used for thread 1 is always guaranteed to have exclusive access (can be
restarted), but the 2nd thread variable is not restarted (guaranteed
progress), and updates to this variable can go through a lock-prefixed
cmpxchg. Basically, we can see this as a 2-class Peterson algorithm
(rather than 2 threads), where the first class has exclusive access,
and the 2nd class serializes many threads through an atomic instruction.
This approach should work well for locks, but I'm not sure it would
do for push/pop of a linked list.
Thoughts ?
Thanks,
Mathieu
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
^ permalink raw reply
* [PATCH] virtio_net: document VIRTIO_NET_CTRL_GUEST_OFFLOADS
From: Michael S. Tsirkin @ 2015-06-29 9:19 UTC (permalink / raw)
To: linux-kernel-u79uwXL29TY76Z2rM5mHXA
Cc: Yan Vugenfirer,
virtualization-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
linux-api-u79uwXL29TY76Z2rM5mHXA
Document VIRTIO_NET_CTRL_GUEST_OFFLOADS and the
relevant feature bits.
Will allow ethtool control of the offloads down the road.
Reported-by: Yan Vugenfirer <yan-8cRecHGSwSzQT0dZR+AlfA@public.gmane.org>
Signed-off-by: Michael S. Tsirkin <mst-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
include/uapi/linux/virtio_net.h | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/include/uapi/linux/virtio_net.h b/include/uapi/linux/virtio_net.h
index 7bbee79..ec32293 100644
--- a/include/uapi/linux/virtio_net.h
+++ b/include/uapi/linux/virtio_net.h
@@ -34,6 +34,7 @@
/* The feature bitmap for virtio net */
#define VIRTIO_NET_F_CSUM 0 /* Host handles pkts w/ partial csum */
#define VIRTIO_NET_F_GUEST_CSUM 1 /* Guest handles pkts w/ partial csum */
+#define VIRTIO_NET_F_CTRL_GUEST_OFFLOADS 2 /* Dynamic offload configuration. */
#define VIRTIO_NET_F_MAC 5 /* Host has given MAC address. */
#define VIRTIO_NET_F_GUEST_TSO4 7 /* Guest can handle TSOv4 in. */
#define VIRTIO_NET_F_GUEST_TSO6 8 /* Guest can handle TSOv6 in. */
@@ -226,4 +227,19 @@ struct virtio_net_ctrl_mq {
#define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN 1
#define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX 0x8000
+/*
+ * Control network offloads
+ *
+ * Reconfigures the network offloads that Guest can handle.
+ *
+ * Available with the VIRTIO_NET_F_CTRL_GUEST_OFFLOADS feature bit.
+ *
+ * Command data format matches the feature bit mask exactly.
+ *
+ * See VIRTIO_NET_F_GUEST_* for the list of offloads
+ * that can be enabled/disabled.
+ */
+#define VIRTIO_NET_CTRL_GUEST_OFFLOADS 5
+#define VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET 0
+
#endif /* _LINUX_VIRTIO_NET_H */
--
MST
^ permalink raw reply related
* Re: [PATCH] mm: fix status code move_pages() returns for zero page
From: Christoph Lameter @ 2015-06-29 14:50 UTC (permalink / raw)
To: Kirill A. Shutemov
Cc: Andrew Morton, linux-mm, linux-kernel, linux-api, Hugh Dickins
In-Reply-To: <1435141428-98266-1-git-send-email-kirill.shutemov@linux.intel.com>
On Wed, 24 Jun 2015, Kirill A. Shutemov wrote:
> Man page for move_pages(2) specifies that status code for zero page is
> supposed to be -EFAULT. Currently kernel return -ENOENT in this case.
>
> follow_page() can do it for us, if we would ask for FOLL_DUMP.
FOLL_DUMP also has the consequence that the upper layer page tables pages
are no longer allocated.
Otherwise this looks ok.
Reviewed-by: Christoph Lameter <cl@linux.com>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply
* [PATCH]: Mux n_gsm: Add a DLCI hangup state and callback
From: Gwenn Bourrée @ 2015-06-29 15:53 UTC (permalink / raw)
To: gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r, jslaby-AlSwsSmVLrQ
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-api-u79uwXL29TY76Z2rM5mHXA
Dear kernel tty maintainers,
Please review the following patch:
From 6e006bd522124d0e8a2f6075099a21f7051a426f Mon Sep 17 00:00:00 2001
From: Gwenn Bourree <gwenn.bourree@intel.com>
Date: Mon, 29 Jun 2015 17:26:01 +0200
Subject: [PATCH] Mux n_gsm: Add a DLCI hangup state and callback
Use of asynchronous hangup instead of vhangup.
Signed-off-by: Gwenn Bourree <gwenn.bourree@intel.com>
Signed-off-by: Gwenn Bourree <gwenn.bourree@intel.com>
Signed-off-by: Mustapha Ben Zoubeir <mustaphax.ben.zoubeir@intel.com>
Signed-off-by: Nicolas LOUIS <nicolasx.louis@intel.com>
Reviewed-by: Ravindran, Arun <arun.ravindran@intel.com
---
drivers/tty/n_gsm.c | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index d6e0ea0..762f555 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -135,6 +135,7 @@ struct gsm_dlci {
#define DLCI_OPENING 1 /* Sending SABM not seen UA */
#define DLCI_OPEN 2 /* SABM/UA complete */
#define DLCI_CLOSING 3 /* Sending DISC not seen UA/DM */
+#define DLCI_HANGUP 4 /*HANGUP received */
struct mutex mutex;
/* Link layer */
@@ -1530,7 +1531,8 @@ static void gsm_dlci_begin_open(struct gsm_dlci
*dlci)
static void gsm_dlci_begin_close(struct gsm_dlci *dlci)
{
struct gsm_mux *gsm = dlci->gsm;
- if (dlci->state == DLCI_CLOSED || dlci->state == DLCI_CLOSING)
+ if (dlci->state == DLCI_CLOSED || dlci->state == DLCI_CLOSING ||
+ dlci->state == DLCI_HANGUP)
return;
dlci->retries = gsm->n2;
dlci->state = DLCI_CLOSING;
@@ -1717,7 +1719,7 @@ static void gsm_dlci_release(struct gsm_dlci
*dlci)
gsm_destroy_network(dlci);
mutex_unlock(&dlci->mutex);
- tty_vhangup(tty);
+ tty_hangup(tty);
tty_port_tty_set(&dlci->port, NULL);
tty_kref_put(tty);
@@ -2339,6 +2341,26 @@ static void gsmld_flush_buffer(struct tty_struct
*tty)
}
/**
+ * gsmld_hangup - hangup the ldisc for this tty
+ * @tty: device
+ */
+
+static int gsmld_hangup(struct tty_struct *tty)
+{
+ struct gsm_mux *gsm = tty->disc_data;
+ int i;
+ struct gsm_dlci *dlci;
+
+ for (i = NUM_DLCI-1; i >= 0; i--) {
+ dlci = gsm->dlci[i];
+ if (dlci)
+ dlci->state = DLCI_HANGUP;
+ }
+
+ return 0;
+}
+
+/**
* gsmld_close - close the ldisc for this tty
* @tty: device
*
@@ -2836,6 +2858,7 @@ static struct tty_ldisc_ops tty_ldisc_packet = {
.name = "n_gsm",
.open = gsmld_open,
.close = gsmld_close,
+ .hangup = gsmld_hangup,
.flush_buffer = gsmld_flush_buffer,
.chars_in_buffer = gsmld_chars_in_buffer,
.read = gsmld_read,
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris,
92196 Meudon Cedex, France
Registration Number: 302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
^ permalink raw reply related
* [PATCH]: MUX n_gsm debug print improvements
From: Gwenn Bourrée @ 2015-06-29 15:54 UTC (permalink / raw)
To: gregkh, jslaby; +Cc: linux-api, linux-kernel
Dear kernel tty maintainers,
Please review the following patch:
From 0ac5da0a4653f43ce4b0761a2be8073185c549bb Mon Sep 17 00:00:00 2001
From: Gwenn Bourree <gwenn.bourree@intel.com>
Date: Mon, 29 Jun 2015 16:09:06 +0200
Subject: [PATCH] Add Debug define
Improve the debug print out and make be clearest
Signed-off-by: Gwenn Bourree <gwenn.bourree@intel.com>
Signed-off-by: Mustapha Ben Zoubeir <mustaphax.ben.zoubeir@intel.com>
Signed-off-by: Nicolas LOUIS <nicolasx.louis@intel.com>
Reviewed-by: Ravindran, Arun <arun.ravindran@intel.com
---
drivers/tty/n_gsm.c | 49
++++++++++++++++++++++++++++---------------------
1 file changed, 28 insertions(+), 21 deletions(-)
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index 382d3fc..d6e0ea0 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -66,17 +66,18 @@
static int debug;
module_param(debug, int, 0600);
-/* Defaults: these are from the specification */
+#define GSMDBG_VERBOSE_PACKET_REPORT(x) ((x) & 1)
+#define GSMDBG_FORCE_CARRIER(x) ((x) & 2)
+#define GSMDBG_DATA_FULL_REPORT(x) ((x) & 4)
+#define GSMDBG_DLCI_STREAM_REPORT(x) ((x) & 8)
+#define GSMDBG_DLCI_DATA_REPORT(x) ((x) & 16)
+#define GSMDBG_DATA_LEN_REPORT(x) ((x) & 32)
-#define T1 10 /* 100mS */
-#define T2 34 /* 333mS */
-#define N2 3 /* Retry 3 times */
+/* Defaults: these are from the specification */
-/* Use long timers for testing at low speed with debug on */
-#ifdef DEBUG_TIMING
-#define T1 100
-#define T2 200
-#endif
+#define T1 10 /* 100mS */
+#define T2 34 /* 333mS */
+#define N2 3 /* Retry 3 times */
/*
* Semi-arbitrary buffer size limits. 0710 is normally run with 32-64
byte
@@ -461,7 +462,7 @@ static u8 gsm_encode_modem(const struct gsm_dlci
*dlci)
static void gsm_print_packet(const char *hdr, int addr, int cr,
u8 control, const u8 *data, int dlen)
{
- if (!(debug & 1))
+ if (!GSMDBG_VERBOSE_PACKET_REPORT(debug))
return;
pr_info("%s %d) %c: ", hdr, addr, "RC"[cr]);
@@ -700,7 +701,7 @@ static void gsm_data_kick(struct gsm_mux *gsm)
len = msg->len + 2;
}
- if (debug & 4)
+ if (GSMDBG_DATA_FULL_REPORT(debug))
print_hex_dump_bytes("gsm_data_kick: ",
DUMP_PREFIX_OFFSET,
gsm->txframe, len);
@@ -1426,7 +1427,7 @@ static int gsm_control_wait(struct gsm_mux *gsm,
struct gsm_control *control)
static void gsm_dlci_close(struct gsm_dlci *dlci)
{
del_timer(&dlci->t1);
- if (debug & 8)
+ if (GSMDBG_DLCI_STREAM_REPORT(debug))
pr_debug("DLCI %d goes closed.\n", dlci->addr);
dlci->state = DLCI_CLOSED;
if (dlci->addr != 0) {
@@ -1453,7 +1454,7 @@ static void gsm_dlci_open(struct gsm_dlci *dlci)
del_timer(&dlci->t1);
/* This will let a tty open continue */
dlci->state = DLCI_OPEN;
- if (debug & 8)
+ if (GSMDBG_DLCI_STREAM_REPORT(debug))
pr_debug("DLCI %d goes open.\n", dlci->addr);
wake_up(&dlci->gsm->event);
}
@@ -1556,8 +1557,8 @@ static void gsm_dlci_data(struct gsm_dlci *dlci,
u8 *data, int clen)
unsigned int modem = 0;
int len = clen;
- if (debug & 16)
- pr_debug("%d bytes for tty\n", len);
+ if (GSMDBG_DLCI_DATA_REPORT(debug))
+ pr_debug("%s: %d bytes for tty\n", __func__, len);
switch (dlci->adaption) {
/* Unsupported types */
/* Packetised interruptible data */
@@ -1758,7 +1759,7 @@ static void gsm_queue(struct gsm_mux *gsm)
}
if (gsm->fcs != GOOD_FCS) {
gsm->bad_fcs++;
- if (debug & 4)
+ if (GSMDBG_DATA_FULL_REPORT(debug))
pr_debug("BAD FCS %02x\n", gsm->fcs);
return;
}
@@ -1922,6 +1923,7 @@ static void gsm0_receive(struct gsm_mux *gsm,
unsigned char c)
gsm->state = GSM_SEARCH;
break;
}
+ pr_debug("wait for GSM0_SOF, while got 0x%x\n", (u32)c);
break;
}
}
@@ -2209,9 +2211,12 @@ static int gsmld_output(struct gsm_mux *gsm, u8
*data, int len)
set_bit(TTY_DO_WRITE_WAKEUP, &gsm->tty->flags);
return -ENOSPC;
}
- if (debug & 4)
- print_hex_dump_bytes("gsmld_output: ", DUMP_PREFIX_OFFSET,
+ if (GSMDBG_DATA_FULL_REPORT(debug))
+ print_hex_dump_bytes(__func__, DUMP_PREFIX_OFFSET,
data, len);
+ else if (GSMDBG_DATA_LEN_REPORT(debug))
+ pr_debug("n_gsm: >> %d bytes\n", len);
+
gsm->tty->ops->write(gsm->tty, data, len);
return len;
}
@@ -2276,9 +2281,11 @@ static void gsmld_receive_buf(struct tty_struct
*tty, const unsigned char *cp,
int i;
char flags = TTY_NORMAL;
- if (debug & 4)
- print_hex_dump_bytes("gsmld_receive: ", DUMP_PREFIX_OFFSET,
+ if (GSMDBG_DATA_FULL_REPORT(debug))
+ print_hex_dump_bytes(__func__, DUMP_PREFIX_OFFSET,
cp, count);
+ else if (GSMDBG_DATA_LEN_REPORT(debug))
+ pr_debug("n_gsm: << %d bytes\n", count);
for (i = count, dp = cp, f = fp; i; i--, dp++) {
if (f)
@@ -2871,7 +2878,7 @@ static int gsm_carrier_raised(struct tty_port
*port)
/* Not yet open so no carrier info */
if (dlci->state != DLCI_OPEN)
return 0;
- if (debug & 2)
+ if (GSMDBG_FORCE_CARRIER(debug))
return 1;
return dlci->modem_rx & TIOCM_CD;
}
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris,
92196 Meudon Cedex, France
Registration Number: 302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
^ permalink raw reply related
* Re: [PATCH]: MUX n_gsm debug print improvements
From: Greg KH @ 2015-06-29 16:02 UTC (permalink / raw)
To: Gwenn Bourrée
Cc: jslaby-AlSwsSmVLrQ, linux-api-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1435593298.25711.4.camel@tldlab125>
On Mon, Jun 29, 2015 at 05:54:58PM +0200, Gwenn Bourrée wrote:
>
> Dear kernel tty maintainers,
>
> Please review the following patch:
>
> From 0ac5da0a4653f43ce4b0761a2be8073185c549bb Mon Sep 17 00:00:00 2001
> From: Gwenn Bourree <gwenn.bourree-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Date: Mon, 29 Jun 2015 16:09:06 +0200
> Subject: [PATCH] Add Debug define
>
> Improve the debug print out and make be clearest
>
> Signed-off-by: Gwenn Bourree <gwenn.bourree-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Signed-off-by: Mustapha Ben Zoubeir <mustaphax.ben.zoubeir-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Signed-off-by: Nicolas LOUIS <nicolasx.louis-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Reviewed-by: Ravindran, Arun <arun.ravindran-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
Any reason you didn't cc the linux-serial mailing list? And linux-api
only cares about external api changes, which I don't think you did here.
Also, what's with the odd format, I would have to hand-edit this in
order to apply it properly. Please fix it up and send it without the
"Dear..." lines, that's not needed at all, nor is the "From" lines.
thanks,
greg k-h
^ permalink raw reply
* Re: [PATCH]: MUX n_gsm debug print improvements
From: Greg KH @ 2015-06-29 16:04 UTC (permalink / raw)
To: Gwenn Bourrée
Cc: jslaby-AlSwsSmVLrQ, linux-api-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1435593298.25711.4.camel@tldlab125>
On Mon, Jun 29, 2015 at 05:54:58PM +0200, Gwenn Bourrée wrote:
>
> Dear kernel tty maintainers,
>
> Please review the following patch:
>
> From 0ac5da0a4653f43ce4b0761a2be8073185c549bb Mon Sep 17 00:00:00 2001
> From: Gwenn Bourree <gwenn.bourree-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Date: Mon, 29 Jun 2015 16:09:06 +0200
> Subject: [PATCH] Add Debug define
>
> Improve the debug print out and make be clearest
>
> Signed-off-by: Gwenn Bourree <gwenn.bourree-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Signed-off-by: Mustapha Ben Zoubeir <mustaphax.ben.zoubeir-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Signed-off-by: Nicolas LOUIS <nicolasx.louis-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Reviewed-by: Ravindran, Arun <arun.ravindran-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
>
> ---
> drivers/tty/n_gsm.c | 49
> ++++++++++++++++++++++++++++---------------------
> 1 file changed, 28 insertions(+), 21 deletions(-)
Also, your patch is line-wrapped and also base64 encoded, making it
impossible to edit, or apply. Please fix up your email client to use
the proper configuration, as I'm sure Intel has documentation for how to
do.
In fact, it has documentation for how to do all of this, why aren't you
following it?
thanks,
greg k-h
^ permalink raw reply
* Re: [PATCH]: Mux n_gsm: Add a DLCI hangup state and callback
From: Greg KH @ 2015-06-29 16:04 UTC (permalink / raw)
To: Gwenn Bourrée; +Cc: jslaby, linux-kernel, linux-api
In-Reply-To: <1435593236.25711.3.camel@tldlab125>
On Mon, Jun 29, 2015 at 05:53:56PM +0200, Gwenn Bourrée wrote:
>
> Dear kernel tty maintainers,
>
> Please review the following patch:
>
> From 6e006bd522124d0e8a2f6075099a21f7051a426f Mon Sep 17 00:00:00 2001
> From: Gwenn Bourree <gwenn.bourree@intel.com>
> Date: Mon, 29 Jun 2015 17:26:01 +0200
> Subject: [PATCH] Mux n_gsm: Add a DLCI hangup state and callback
>
> Use of asynchronous hangup instead of vhangup.
>
> Signed-off-by: Gwenn Bourree <gwenn.bourree@intel.com>
> Signed-off-by: Gwenn Bourree <gwenn.bourree@intel.com>
> Signed-off-by: Mustapha Ben Zoubeir <mustaphax.ben.zoubeir@intel.com>
> Signed-off-by: Nicolas LOUIS <nicolasx.louis@intel.com>
> Reviewed-by: Ravindran, Arun <arun.ravindran@intel.com
>
> ---
> drivers/tty/n_gsm.c | 27 +++++++++++++++++++++++++--
> 1 file changed, 25 insertions(+), 2 deletions(-)
Same comments on this one, but as you are wanting to send a series of
patches, send a series of patches, each one numbered properly, otherwise
I have no idea what order to apply them in.
greg k-h
^ permalink raw reply
* Re: [PATCH]: Mux n_gsm: Add a DLCI hangup state and callback
From: Marcel Holtmann @ 2015-06-29 16:06 UTC (permalink / raw)
To: Gwenn Bourrée
Cc: Greg Kroah-Hartman, Jiri Slaby, inux Kernel Mailing List,
linux-api-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1435593236.25711.3.camel@tldlab125>
Hi Gwenn,
> Please review the following patch:
>
> From 6e006bd522124d0e8a2f6075099a21f7051a426f Mon Sep 17 00:00:00 2001
> From: Gwenn Bourree <gwenn.bourree-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Date: Mon, 29 Jun 2015 17:26:01 +0200
> Subject: [PATCH] Mux n_gsm: Add a DLCI hangup state and callback
this is borked. Consider using git format-patch and git send-email.
>
> Use of asynchronous hangup instead of vhangup.
In general it is useful to have a bit more explanation in your patch on what it does, why it does it and how.
>
> Signed-off-by: Gwenn Bourree <gwenn.bourree-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Signed-off-by: Gwenn Bourree <gwenn.bourree-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
You do not need to have yourself twice here.
> Signed-off-by: Mustapha Ben Zoubeir <mustaphax.ben.zoubeir-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Signed-off-by: Nicolas LOUIS <nicolasx.louis-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Reviewed-by: Ravindran, Arun <arun.ravindran-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
Please make sure reviewed-by are correct. I would use first name last name <email>. And make sure to close the email with >
>
> ---
> drivers/tty/n_gsm.c | 27 +++++++++++++++++++++++++--
> 1 file changed, 25 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
> index d6e0ea0..762f555 100644
> --- a/drivers/tty/n_gsm.c
> +++ b/drivers/tty/n_gsm.c
> @@ -135,6 +135,7 @@ struct gsm_dlci {
> #define DLCI_OPENING 1 /* Sending SABM not seen UA */
> #define DLCI_OPEN 2 /* SABM/UA complete */
> #define DLCI_CLOSING 3 /* Sending DISC not seen UA/DM */
> +#define DLCI_HANGUP 4 /*HANGUP received */
Please follow coding style. The example of the comment is above.
> struct mutex mutex;
>
> /* Link layer */
> @@ -1530,7 +1531,8 @@ static void gsm_dlci_begin_open(struct gsm_dlci
> *dlci)
> static void gsm_dlci_begin_close(struct gsm_dlci *dlci)
> {
> struct gsm_mux *gsm = dlci->gsm;
> - if (dlci->state == DLCI_CLOSED || dlci->state == DLCI_CLOSING)
> + if (dlci->state == DLCI_CLOSED || dlci->state == DLCI_CLOSING ||
> + dlci->state == DLCI_HANGUP)
I am pretty sure this indentation is wrong. You can not tell the actual code block apart from the condition. So either align with the dlci->state above or use two tabs. Check what coding style is common in this code and choose the one used in similar multiline if conditions.
> return;
> dlci->retries = gsm->n2;
> dlci->state = DLCI_CLOSING;
> @@ -1717,7 +1719,7 @@ static void gsm_dlci_release(struct gsm_dlci
> *dlci)
> gsm_destroy_network(dlci);
> mutex_unlock(&dlci->mutex);
>
> - tty_vhangup(tty);
> + tty_hangup(tty);
>
> tty_port_tty_set(&dlci->port, NULL);
> tty_kref_put(tty);
> @@ -2339,6 +2341,26 @@ static void gsmld_flush_buffer(struct tty_struct
> *tty)
> }
>
> /**
> + * gsmld_hangup - hangup the ldisc for this tty
> + * @tty: device
> + */
> +
> +static int gsmld_hangup(struct tty_struct *tty)
> +{
> + struct gsm_mux *gsm = tty->disc_data;
> + int i;
> + struct gsm_dlci *dlci;
> +
> + for (i = NUM_DLCI-1; i >= 0; i--) {
> + dlci = gsm->dlci[i];
I would have moved the struct gsm_dlci declaration into the body of the for loop.
> + if (dlci)
> + dlci->state = DLCI_HANGUP;
> + }
> +
> + return 0;
> +}
> +
> +/**
> * gsmld_close - close the ldisc for this tty
> * @tty: device
> *
> @@ -2836,6 +2858,7 @@ static struct tty_ldisc_ops tty_ldisc_packet = {
> .name = "n_gsm",
> .open = gsmld_open,
> .close = gsmld_close,
> + .hangup = gsmld_hangup,
> .flush_buffer = gsmld_flush_buffer,
> .chars_in_buffer = gsmld_chars_in_buffer,
> .read = gsmld_read,
Regards
Marcel
^ permalink raw reply
* Re: [PATCH]: MUX n_gsm debug print improvements
From: Marcel Holtmann @ 2015-06-29 16:11 UTC (permalink / raw)
To: Gwenn Bourrée
Cc: gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r, jslaby-AlSwsSmVLrQ,
linux-api-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1435593298.25711.4.camel@tldlab125>
Hi Gwenn,
> Please review the following patch:
>
> From 0ac5da0a4653f43ce4b0761a2be8073185c549bb Mon Sep 17 00:00:00 2001
> From: Gwenn Bourree <gwenn.bourree-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Date: Mon, 29 Jun 2015 16:09:06 +0200
> Subject: [PATCH] Add Debug define
>
> Improve the debug print out and make be clearest
>
> Signed-off-by: Gwenn Bourree <gwenn.bourree-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Signed-off-by: Mustapha Ben Zoubeir <mustaphax.ben.zoubeir-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Signed-off-by: Nicolas LOUIS <nicolasx.louis-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Reviewed-by: Ravindran, Arun <arun.ravindran-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
>
> ---
> drivers/tty/n_gsm.c | 49
> ++++++++++++++++++++++++++++---------------------
> 1 file changed, 28 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
> index 382d3fc..d6e0ea0 100644
> --- a/drivers/tty/n_gsm.c
> +++ b/drivers/tty/n_gsm.c
> @@ -66,17 +66,18 @@
> static int debug;
> module_param(debug, int, 0600);
>
> -/* Defaults: these are from the specification */
> +#define GSMDBG_VERBOSE_PACKET_REPORT(x) ((x) & 1)
> +#define GSMDBG_FORCE_CARRIER(x) ((x) & 2)
> +#define GSMDBG_DATA_FULL_REPORT(x) ((x) & 4)
> +#define GSMDBG_DLCI_STREAM_REPORT(x) ((x) & 8)
> +#define GSMDBG_DLCI_DATA_REPORT(x) ((x) & 16)
> +#define GSMDBG_DATA_LEN_REPORT(x) ((x) & 32)
what is actually wrong with just using dynamic debug. That lets you easily switch on certain debug statements. I would actually remove all of this and rely completely on dynamic debug instead.
Anyway, there are also BIT(0), BIT(1) etc. choices that would be a lot clearer than 1, 2, 4 etc.
Regards
Marcel
^ permalink raw reply
* Re: [GIT PULL] User namespace related fixes for v4.2
From: Linus Torvalds @ 2015-06-29 16:43 UTC (permalink / raw)
To: Eric W. Biederman
Cc: Linux Containers, linux-fsdevel, Linux API, Andy Lutomirski,
Serge E. Hallyn, Richard Weinberger, Kenton Varda,
Michael Kerrisk-manpages, Stéphane Graber, Eric Windisch,
Greg Kroah-Hartman, Tejun Heo, Seth Forshee, Omar Sandoval,
Ivan Delalande
In-Reply-To: <87381eyz26.fsf@x220.int.ebiederm.org>
On Fri, Jun 26, 2015 at 1:50 PM, Eric W. Biederman
<ebiederm@xmission.com> wrote:
>
> Therefore this changeset marks for backporting the attribute enforcement
> that do not cause regressions in the existing userspace. Implements
> enforcement of nosuid and noexec. Then disables that enforcement of
> nosuid and nosexec and replaces that enforcment with a big fat warning.
> Userspace should be fixed before 4.2 ships so I do not expect these
> warnings to fire.
Eric, that is *not* how this works.
If people have old user-space binaries, we do not require them to be
updated. So it doesn't matter one whit if "Userspace should be fixed
before 4.2 ships", because it is entirely irrelevant if the upstream
project stops doing something, when users want to be able to upgrade
their kernels regardless of whether they've upgraded their system
apps.
I'm going to hold off on pulling this, because I feel you don't
understand the regression rules.
I suggest we instead just always set nosuid and noexec for /proc and
/sys mounts, and make this whole thing a complete non-issue.
Instead of this crazy "let's warn about it and plan on breaking old
existing setups". That's _wrong_. It's so fundamentally wrong that I
will not pull from people who do not understand this.
The reason we have that "no regression" rule is not so that we fix up
bugs. It's because peopel should always feel safe upgrading their
kernel, and basically _know_ that kernel developers consider it
unacceptable to break user space. It should be a warm fuzzy feeling -
the feeling that we try our best, and if we ever fail because we
missed something or really believed that it can't ever matter, we'll
jump on it and we won't be making any excuses for our bugs. Because
breaking user space is a bug.
Kernel developers who don't understand "it is unacceptable to break
user space" shouldn't be kernel developers.
Linus
^ permalink raw reply
* Re: [GIT PULL] User namespace related fixes for v4.2
From: Eric W. Biederman @ 2015-06-29 21:13 UTC (permalink / raw)
To: Linus Torvalds
Cc: Seth Forshee, Linux API, Linux Containers, Greg Kroah-Hartman,
Andy Lutomirski, Kenton Varda, Michael Kerrisk-manpages,
Richard Weinberger, linux-fsdevel-u79uwXL29TY76Z2rM5mHXA,
Tejun Heo, Ivan Delalande
In-Reply-To: <CA+55aFysKDXr2HEwNzm3z9QOw=E4ZeWcvYQ-xLhy5_k+rGbeRg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
Linus Torvalds <torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org> writes:
> On Fri, Jun 26, 2015 at 1:50 PM, Eric W. Biederman
> <ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org> wrote:
>>
>> Therefore this changeset marks for backporting the attribute enforcement
>> that do not cause regressions in the existing userspace. Implements
>> enforcement of nosuid and noexec. Then disables that enforcement of
>> nosuid and nosexec and replaces that enforcment with a big fat warning.
>> Userspace should be fixed before 4.2 ships so I do not expect these
>> warnings to fire.
>
> Eric, that is *not* how this works.
>
> If people have old user-space binaries, we do not require them to be
> updated. So it doesn't matter one whit if "Userspace should be fixed
> before 4.2 ships", because it is entirely irrelevant if the upstream
> project stops doing something, when users want to be able to upgrade
> their kernels regardless of whether they've upgraded their system
> apps.
>
> I'm going to hold off on pulling this, because I feel you don't
> understand the regression rules.
That is not the issue. What happen is I found myself between a rock and
a hard place and I did not possess sufficient creativity to code my way
out.
Fearing regressions I sought out people to test these changes, on the
applications most likely to care.
I reduced the change from breaking userspace to a warning that userspace
is being ludicriously stupid.
I worked with the applications to get their bugs fixed.
> I suggest we instead just always set nosuid and noexec for /proc and
> /sys mounts, and make this whole thing a complete non-issue.
Doing exactly as you suggest will be user visible (mount flags), and
without care is likely to break remount.
Can you live with the patch below and committing to never supporting
executables on proc and sysfs?
With that I can solve all of my concerns, without affecting the existing
userspace programs.
> Instead of this crazy "let's warn about it and plan on breaking old
> existing setups". That's _wrong_. It's so fundamentally wrong that I
> will not pull from people who do not understand this.
>
> The reason we have that "no regression" rule is not so that we fix up
> bugs. It's because peopel should always feel safe upgrading their
> kernel, and basically _know_ that kernel developers consider it
> unacceptable to break user space. It should be a warm fuzzy feeling -
> the feeling that we try our best, and if we ever fail because we
> missed something or really believed that it can't ever matter, we'll
> jump on it and we won't be making any excuses for our bugs. Because
> breaking user space is a bug.
>
> Kernel developers who don't understand "it is unacceptable to break
> user space" shouldn't be kernel developers.
It is not that I do not understand it is that I had a failure of
imagination. I have been agonizing about this issue since I have
encountered it trying to think of a better way.
Because of another failure of my imagination enabling user namespaces
has introduced a number of security regressions into the kernel, because
primarily I overlooked the effects of fine grained sharing in the mount
namespace and I have been working carefully and dilligent to get those
security regressions fixed. Because if the user namespace by it's
designed semantics opens up security holes it is a failure. Crap
happens and we occassionally over look things with the a greater amount
of code exposed to unprivileged users, but that is no excuse for doing
everything in my power to make user namespaces as safe to use as linux
without user namespaces.
Almost the entirety of my pull request is addressing that unfortunate
regression in security.
Until your comments suggested to me that it was acceptable to
permanently bar exectuables from proc and sysfs I did not see a way to
address this security hole (that does not currently appear exploitable),
but has been exploitable in the past, without breaking something.
Breaking two exectuables that will be unsafe to use at some point if I
did not get this fixed seemed the least damage I could do.
Hopefully you can live with permanently (and programatically) barring
exectuables from proc and sysfs and I can then move forward without
reworking things so I can fix this without breaking anything.
Eric
------------------- cut here --------------------
From: "Eric W. Biederman" <ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
Date: Mon, 29 Jun 2015 14:42:03 -0500
Subject: [PATCH] vfs: Commit to never having exectuables on proc and sysfs.
Add a new flag to file_system_type for filesystems that are never
exepected to support executables. Test that flag where MNT_NOEXEC is
tested today, so that user visible changes to mount flags are not
necessary. The only user visible effect will be that exectuables
will be treated as if the execute bit is cleared, as happens today
when the MNT_NOEXEC flag is set on a mount.
Set the new flag on proc and sysfs. As proc and sysfs do not implement
executables today there are no differences for userspace to notice.
The point of this exercise is that there are some applications that
due to oversites of their programmers do not set nosid and noexec when
they mount fresh copies of proc and sysfs today, and would become instant
security holes if we implemented exectubles especially suid executables
on proc and sysfs today.
With this change it becomes less necessary to vet each change to
proc and sysfs very carefully to ensure that executable files are
not implemented and to ensure that chattr can not create executable
files on proc and sysfs.
Signed-off-by: "Eric W. Biederman" <ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
---
fs/exec.c | 10 ++++++++--
fs/open.c | 2 +-
fs/proc/root.c | 2 +-
fs/sysfs/mount.c | 2 +-
include/linux/fs.h | 3 +++
kernel/sys.c | 3 +--
mm/mmap.c | 4 ++--
mm/nommu.c | 2 +-
security/security.c | 2 +-
9 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/fs/exec.c b/fs/exec.c
index 1977c2a553ac..1e063854571b 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -98,6 +98,12 @@ static inline void put_binfmt(struct linux_binfmt * fmt)
module_put(fmt->module);
}
+bool path_noexec(const struct path *path)
+{
+ return (path->mnt->mnt_flags & MNT_NOEXEC) ||
+ (path->mnt->mnt_sb->s_type->fs_flags & FS_NOEXEC);
+}
+
#ifdef CONFIG_USELIB
/*
* Note that a shared library must be both readable and executable due to
@@ -132,7 +138,7 @@ SYSCALL_DEFINE1(uselib, const char __user *, library)
goto exit;
error = -EACCES;
- if (file->f_path.mnt->mnt_flags & MNT_NOEXEC)
+ if (path_noexec(&file->f_path))
goto exit;
fsnotify_open(file);
@@ -777,7 +783,7 @@ static struct file *do_open_execat(int fd, struct filename *name, int flags)
if (!S_ISREG(file_inode(file)->i_mode))
goto exit;
- if (file->f_path.mnt->mnt_flags & MNT_NOEXEC)
+ if (path_noexec(&file->f_path))
goto exit;
err = deny_write_access(file);
diff --git a/fs/open.c b/fs/open.c
index e0250bdcc440..9fbdb1bae049 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -375,7 +375,7 @@ retry:
* with the "noexec" flag.
*/
res = -EACCES;
- if (path.mnt->mnt_flags & MNT_NOEXEC)
+ if (path_noexec(&path))
goto out_path_release;
}
diff --git a/fs/proc/root.c b/fs/proc/root.c
index b7fa4bfe896a..7e39312580d4 100644
--- a/fs/proc/root.c
+++ b/fs/proc/root.c
@@ -159,7 +159,7 @@ static struct file_system_type proc_fs_type = {
.name = "proc",
.mount = proc_mount,
.kill_sb = proc_kill_sb,
- .fs_flags = FS_USERNS_MOUNT,
+ .fs_flags = FS_NOEXEC | FS_USERNS_MOUNT,
};
void __init proc_root_init(void)
diff --git a/fs/sysfs/mount.c b/fs/sysfs/mount.c
index 8a49486bf30c..9cd8667feb94 100644
--- a/fs/sysfs/mount.c
+++ b/fs/sysfs/mount.c
@@ -58,7 +58,7 @@ static struct file_system_type sysfs_fs_type = {
.name = "sysfs",
.mount = sysfs_mount,
.kill_sb = sysfs_kill_sb,
- .fs_flags = FS_USERNS_MOUNT,
+ .fs_flags = FS_NOEXEC | FS_USERNS_MOUNT,
};
int __init sysfs_init(void)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index e351da4a934f..9e44c6d81bb2 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1916,6 +1916,7 @@ struct file_system_type {
#define FS_HAS_SUBTYPE 4
#define FS_USERNS_MOUNT 8 /* Can be mounted by userns root */
#define FS_USERNS_DEV_MOUNT 16 /* A userns mount does not imply MNT_NODEV */
+#define FS_NOEXEC 32 /* FS will not support executables */
#define FS_RENAME_DOES_D_MOVE 32768 /* FS will handle d_move() during rename() internally. */
struct dentry *(*mount) (struct file_system_type *, int,
const char *, void *);
@@ -3018,4 +3019,6 @@ static inline bool dir_relax(struct inode *inode)
return !IS_DEADDIR(inode);
}
+extern bool path_noexec(const struct path *path);
+
#endif /* _LINUX_FS_H */
diff --git a/kernel/sys.c b/kernel/sys.c
index 259fda25eb6b..fa2f2f671a5c 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1668,8 +1668,7 @@ static int prctl_set_mm_exe_file(struct mm_struct *mm, unsigned int fd)
* overall picture.
*/
err = -EACCES;
- if (!S_ISREG(inode->i_mode) ||
- exe.file->f_path.mnt->mnt_flags & MNT_NOEXEC)
+ if (!S_ISREG(inode->i_mode) || path_noexec(&exe.file->f_path))
goto exit;
err = inode_permission(inode, MAY_EXEC);
diff --git a/mm/mmap.c b/mm/mmap.c
index aa632ade2be7..f126923ce683 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1268,7 +1268,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
* mounted, in which case we dont add PROT_EXEC.)
*/
if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
- if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
+ if (!(file && path_noexec(&file->f_path)))
prot |= PROT_EXEC;
if (!(flags & MAP_FIXED))
@@ -1337,7 +1337,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
case MAP_PRIVATE:
if (!(file->f_mode & FMODE_READ))
return -EACCES;
- if (file->f_path.mnt->mnt_flags & MNT_NOEXEC) {
+ if (path_noexec(&file->f_path)) {
if (vm_flags & VM_EXEC)
return -EPERM;
vm_flags &= ~VM_MAYEXEC;
diff --git a/mm/nommu.c b/mm/nommu.c
index 05e7447d960b..5fdec8885256 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -1035,7 +1035,7 @@ static int validate_mmap_request(struct file *file,
/* handle executable mappings and implied executable
* mappings */
- if (file->f_path.mnt->mnt_flags & MNT_NOEXEC) {
+ if (path_noexec(&file->f_path)) {
if (prot & PROT_EXEC)
return -EPERM;
} else if ((prot & PROT_READ) && !(prot & PROT_EXEC)) {
diff --git a/security/security.c b/security/security.c
index 595fffab48b0..062f3c997fdc 100644
--- a/security/security.c
+++ b/security/security.c
@@ -776,7 +776,7 @@ static inline unsigned long mmap_prot(struct file *file, unsigned long prot)
* ditto if it's not on noexec mount, except that on !MMU we need
* NOMMU_MAP_EXEC (== VM_MAYEXEC) in this case
*/
- if (!(file->f_path.mnt->mnt_flags & MNT_NOEXEC)) {
+ if (!path_noexec(&file->f_path)) {
#ifndef CONFIG_MMU
if (file->f_op->mmap_capabilities) {
unsigned caps = file->f_op->mmap_capabilities(file);
--
2.2.1
^ permalink raw reply related
* [PATCH] hpsa: convert DEVICE_ATTR to RO|WO|RW and show methods must use scnprintf
From: Seymour, Shane M @ 2015-06-30 5:22 UTC (permalink / raw)
To: ISS StorageDev,
James Bottomley (JBottomley-O3H1v1f1dlM@public.gmane.org)
Cc: linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Changed DEVICE_ATTR macro usage to DEVICE_ATTR_RO|WO|RW.
This also forced some show/store function names to change.
Changed all show method sprint/snprintf usage to scnprintf per
Documentation/filesystems/sysfs.txt.
Signed-off-by: Shane Seymour <shane.seymour-VXdhtT5mjnY@public.gmane.org>
---
--- a/drivers/scsi/hpsa.c 2015-06-25 15:52:15.633031319 -0500
+++ b/drivers/scsi/hpsa.c 2015-06-29 17:28:24.628475369 -0500
@@ -376,7 +376,7 @@ static int check_for_busy(struct ctlr_in
}
static u32 lockup_detected(struct ctlr_info *h);
-static ssize_t host_show_lockup_detected(struct device *dev,
+static ssize_t lockup_detected_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
int ld;
@@ -386,10 +386,10 @@ static ssize_t host_show_lockup_detected
h = shost_to_hba(shost);
ld = lockup_detected(h);
- return sprintf(buf, "ld=%d\n", ld);
+ return scnprintf(buf, PAGE_SIZE, "ld=%d\n", ld);
}
-static ssize_t host_store_hp_ssd_smart_path_status(struct device *dev,
+static ssize_t hp_ssd_smart_path_status_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
@@ -413,7 +413,7 @@ static ssize_t host_store_hp_ssd_smart_p
return count;
}
-static ssize_t host_store_raid_offload_debug(struct device *dev,
+static ssize_t raid_offload_debug_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
@@ -438,7 +438,7 @@ static ssize_t host_store_raid_offload_d
return count;
}
-static ssize_t host_store_rescan(struct device *dev,
+static ssize_t rescan_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
@@ -449,7 +449,7 @@ static ssize_t host_store_rescan(struct
return count;
}
-static ssize_t host_show_firmware_revision(struct device *dev,
+static ssize_t firmware_revision_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct ctlr_info *h;
@@ -460,40 +460,40 @@ static ssize_t host_show_firmware_revisi
if (!h->hba_inquiry_data)
return 0;
fwrev = &h->hba_inquiry_data[32];
- return snprintf(buf, 20, "%c%c%c%c\n",
+ return scnprintf(buf, 20, "%c%c%c%c\n",
fwrev[0], fwrev[1], fwrev[2], fwrev[3]);
}
-static ssize_t host_show_commands_outstanding(struct device *dev,
+static ssize_t commands_outstanding_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct Scsi_Host *shost = class_to_shost(dev);
struct ctlr_info *h = shost_to_hba(shost);
- return snprintf(buf, 20, "%d\n",
+ return scnprintf(buf, 20, "%d\n",
atomic_read(&h->commands_outstanding));
}
-static ssize_t host_show_transport_mode(struct device *dev,
+static ssize_t transport_mode_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct ctlr_info *h;
struct Scsi_Host *shost = class_to_shost(dev);
h = shost_to_hba(shost);
- return snprintf(buf, 20, "%s\n",
+ return scnprintf(buf, 20, "%s\n",
h->transMethod & CFGTBL_Trans_Performant ?
"performant" : "simple");
}
-static ssize_t host_show_hp_ssd_smart_path_status(struct device *dev,
+static ssize_t hp_ssd_smart_path_status_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct ctlr_info *h;
struct Scsi_Host *shost = class_to_shost(dev);
h = shost_to_hba(shost);
- return snprintf(buf, 30, "HP SSD Smart Path %s\n",
+ return scnprintf(buf, 30, "HP SSD Smart Path %s\n",
(h->acciopath_status == 1) ? "enabled" : "disabled");
}
@@ -582,14 +582,14 @@ static int ctlr_needs_abort_tags_swizzle
ARRAY_SIZE(needs_abort_tags_swizzled), board_id);
}
-static ssize_t host_show_resettable(struct device *dev,
+static ssize_t resettable_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct ctlr_info *h;
struct Scsi_Host *shost = class_to_shost(dev);
h = shost_to_hba(shost);
- return snprintf(buf, 20, "%d\n", ctlr_is_resettable(h->board_id));
+ return scnprintf(buf, 20, "%d\n", ctlr_is_resettable(h->board_id));
}
static inline int is_logical_dev_addr_mode(unsigned char scsi3addr[])
@@ -631,7 +631,7 @@ static ssize_t raid_level_show(struct de
/* Is this even a logical drive? */
if (!is_logical_dev_addr_mode(hdev->scsi3addr)) {
spin_unlock_irqrestore(&h->lock, flags);
- l = snprintf(buf, PAGE_SIZE, "N/A\n");
+ l = scnprintf(buf, PAGE_SIZE, "N/A\n");
return l;
}
@@ -639,7 +639,7 @@ static ssize_t raid_level_show(struct de
spin_unlock_irqrestore(&h->lock, flags);
if (rlevel > RAID_UNKNOWN)
rlevel = RAID_UNKNOWN;
- l = snprintf(buf, PAGE_SIZE, "RAID %s\n", raid_label[rlevel]);
+ l = scnprintf(buf, PAGE_SIZE, "RAID %s\n", raid_label[rlevel]);
return l;
}
@@ -662,7 +662,7 @@ static ssize_t lunid_show(struct device
}
memcpy(lunid, hdev->scsi3addr, sizeof(lunid));
spin_unlock_irqrestore(&h->lock, flags);
- return snprintf(buf, 20, "0x%02x%02x%02x%02x%02x%02x%02x%02x\n",
+ return scnprintf(buf, 20, "0x%02x%02x%02x%02x%02x%02x%02x%02x\n",
lunid[0], lunid[1], lunid[2], lunid[3],
lunid[4], lunid[5], lunid[6], lunid[7]);
}
@@ -686,7 +686,7 @@ static ssize_t unique_id_show(struct dev
}
memcpy(sn, hdev->device_id, sizeof(sn));
spin_unlock_irqrestore(&h->lock, flags);
- return snprintf(buf, 16 * 2 + 2,
+ return scnprintf(buf, 16 * 2 + 2,
"%02X%02X%02X%02X%02X%02X%02X%02X"
"%02X%02X%02X%02X%02X%02X%02X%02X\n",
sn[0], sn[1], sn[2], sn[3],
@@ -695,7 +695,7 @@ static ssize_t unique_id_show(struct dev
sn[12], sn[13], sn[14], sn[15]);
}
-static ssize_t host_show_hp_ssd_smart_path_enabled(struct device *dev,
+static ssize_t hp_ssd_smart_path_enabled_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct ctlr_info *h;
@@ -714,30 +714,21 @@ static ssize_t host_show_hp_ssd_smart_pa
}
offload_enabled = hdev->offload_enabled;
spin_unlock_irqrestore(&h->lock, flags);
- return snprintf(buf, 20, "%d\n", offload_enabled);
+ return scnprintf(buf, 20, "%d\n", offload_enabled);
}
-static DEVICE_ATTR(raid_level, S_IRUGO, raid_level_show, NULL);
-static DEVICE_ATTR(lunid, S_IRUGO, lunid_show, NULL);
-static DEVICE_ATTR(unique_id, S_IRUGO, unique_id_show, NULL);
-static DEVICE_ATTR(rescan, S_IWUSR, NULL, host_store_rescan);
-static DEVICE_ATTR(hp_ssd_smart_path_enabled, S_IRUGO,
- host_show_hp_ssd_smart_path_enabled, NULL);
-static DEVICE_ATTR(hp_ssd_smart_path_status, S_IWUSR|S_IRUGO|S_IROTH,
- host_show_hp_ssd_smart_path_status,
- host_store_hp_ssd_smart_path_status);
-static DEVICE_ATTR(raid_offload_debug, S_IWUSR, NULL,
- host_store_raid_offload_debug);
-static DEVICE_ATTR(firmware_revision, S_IRUGO,
- host_show_firmware_revision, NULL);
-static DEVICE_ATTR(commands_outstanding, S_IRUGO,
- host_show_commands_outstanding, NULL);
-static DEVICE_ATTR(transport_mode, S_IRUGO,
- host_show_transport_mode, NULL);
-static DEVICE_ATTR(resettable, S_IRUGO,
- host_show_resettable, NULL);
-static DEVICE_ATTR(lockup_detected, S_IRUGO,
- host_show_lockup_detected, NULL);
+static DEVICE_ATTR_RO(raid_level);
+static DEVICE_ATTR_RO(lunid);
+static DEVICE_ATTR_RO(unique_id);
+static DEVICE_ATTR_WO(rescan);
+static DEVICE_ATTR_RO(hp_ssd_smart_path_enabled);
+static DEVICE_ATTR_RW(hp_ssd_smart_path_status);
+static DEVICE_ATTR_WO(raid_offload_debug);
+static DEVICE_ATTR_RO(firmware_revision);
+static DEVICE_ATTR_RO(commands_outstanding);
+static DEVICE_ATTR_RO(transport_mode);
+static DEVICE_ATTR_RO(resettable);
+static DEVICE_ATTR_RO(lockup_detected);
static struct device_attribute *hpsa_sdev_attrs[] = {
&dev_attr_raid_level,
^ permalink raw reply
* [PATCH RESEND] Btrfs: add autodefrag inode flag
From: Omar Sandoval @ 2015-06-30 16:32 UTC (permalink / raw)
To: linux-btrfs-u79uwXL29TY76Z2rM5mHXA,
linux-fsdevel-u79uwXL29TY76Z2rM5mHXA,
linux-api-u79uwXL29TY76Z2rM5mHXA
Cc: Omar Sandoval
In some cases, we may not want to enable automatic defragmentation for
the whole filesystem with the "autodefrag" mount option but we still
want to defragment specific files or directories. Add an inode flag
which allows us to do specify that.
Signed-off-by: Omar Sandoval <osandov-b10kYP2dOMg@public.gmane.org>
---
Resending this because I didn't send it to fsdevel or linux-api last
time and I'm adding a new user-facing inode flag.
fs/btrfs/ctree.h | 1 +
fs/btrfs/file.c | 18 ++++++++++--------
fs/btrfs/ioctl.c | 13 +++++++++++--
include/uapi/linux/fs.h | 1 +
4 files changed, 23 insertions(+), 10 deletions(-)
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 6f364e1d8d3d..e898bb2822ef 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2234,6 +2234,7 @@ do { \
#define BTRFS_INODE_NOATIME (1 << 9)
#define BTRFS_INODE_DIRSYNC (1 << 10)
#define BTRFS_INODE_COMPRESS (1 << 11)
+#define BTRFS_INODE_AUTODEFRAG (1 << 12)
#define BTRFS_INODE_ROOT_ITEM_INIT (1 << 31)
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index b072e17479aa..33bead79da7a 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -129,15 +129,17 @@ static int __btrfs_add_inode_defrag(struct inode *inode,
return 0;
}
-static inline int __need_auto_defrag(struct btrfs_root *root)
+static inline int __need_auto_defrag(struct btrfs_root *root,
+ struct inode *inode)
{
- if (!btrfs_test_opt(root, AUTO_DEFRAG))
- return 0;
-
if (btrfs_fs_closing(root->fs_info))
return 0;
- return 1;
+ if (btrfs_test_opt(root, AUTO_DEFRAG))
+ return 1;
+ if (BTRFS_I(inode)->flags & BTRFS_INODE_AUTODEFRAG)
+ return 1;
+ return 0;
}
/*
@@ -152,7 +154,7 @@ int btrfs_add_inode_defrag(struct btrfs_trans_handle *trans,
u64 transid;
int ret;
- if (!__need_auto_defrag(root))
+ if (!__need_auto_defrag(root, inode))
return 0;
if (test_bit(BTRFS_INODE_IN_DEFRAG, &BTRFS_I(inode)->runtime_flags))
@@ -199,7 +201,7 @@ static void btrfs_requeue_inode_defrag(struct inode *inode,
struct btrfs_root *root = BTRFS_I(inode)->root;
int ret;
- if (!__need_auto_defrag(root))
+ if (!__need_auto_defrag(root, inode))
goto out;
/*
@@ -372,7 +374,7 @@ int btrfs_run_defrag_inodes(struct btrfs_fs_info *fs_info)
&fs_info->fs_state))
break;
- if (!__need_auto_defrag(fs_info->tree_root))
+ if (btrfs_fs_closing(fs_info))
break;
/* find an inode to defrag */
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 1c22c6518504..c1a45d507613 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -121,6 +121,8 @@ static unsigned int btrfs_flags_to_ioctl(unsigned int flags)
iflags |= FS_DIRSYNC_FL;
if (flags & BTRFS_INODE_NODATACOW)
iflags |= FS_NOCOW_FL;
+ if (flags & BTRFS_INODE_AUTODEFRAG)
+ iflags |= FS_AUTODEFRAG_FL;
if ((flags & BTRFS_INODE_COMPRESS) && !(flags & BTRFS_INODE_NOCOMPRESS))
iflags |= FS_COMPR_FL;
@@ -157,7 +159,7 @@ void btrfs_update_iflags(struct inode *inode)
/*
* Inherit flags from the parent inode.
*
- * Currently only the compression flags and the cow flags are inherited.
+ * Currently only the compression, cow, and autodefrag flags are inherited.
*/
void btrfs_inherit_iflags(struct inode *inode, struct inode *dir)
{
@@ -182,6 +184,9 @@ void btrfs_inherit_iflags(struct inode *inode, struct inode *dir)
BTRFS_I(inode)->flags |= BTRFS_INODE_NODATASUM;
}
+ if (flags & BTRFS_INODE_AUTODEFRAG)
+ BTRFS_I(inode)->flags |= BTRFS_INODE_AUTODEFRAG;
+
btrfs_update_iflags(inode);
}
@@ -201,7 +206,7 @@ static int check_flags(unsigned int flags)
FS_NOATIME_FL | FS_NODUMP_FL | \
FS_SYNC_FL | FS_DIRSYNC_FL | \
FS_NOCOMP_FL | FS_COMPR_FL |
- FS_NOCOW_FL))
+ FS_NOCOW_FL | FS_AUTODEFRAG_FL))
return -EOPNOTSUPP;
if ((flags & FS_NOCOMP_FL) && (flags & FS_COMPR_FL))
@@ -278,6 +283,10 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
ip->flags |= BTRFS_INODE_DIRSYNC;
else
ip->flags &= ~BTRFS_INODE_DIRSYNC;
+ if (flags & FS_AUTODEFRAG_FL)
+ ip->flags |= BTRFS_INODE_AUTODEFRAG;
+ else
+ ip->flags &= ~BTRFS_INODE_AUTODEFRAG;
if (flags & FS_NOCOW_FL) {
if (S_ISREG(mode)) {
/*
diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h
index 9b964a5920af..8c7e8c7a0236 100644
--- a/include/uapi/linux/fs.h
+++ b/include/uapi/linux/fs.h
@@ -197,6 +197,7 @@ struct inodes_stat_t {
#define FS_EXTENT_FL 0x00080000 /* Extents */
#define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
#define FS_NOCOW_FL 0x00800000 /* Do not cow file */
+#define FS_AUTODEFRAG_FL 0x01000000 /* Auto-defragment file */
#define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
--
2.4.4
^ permalink raw reply related
* Re: [PATCH] hpsa: convert DEVICE_ATTR to RO|WO|RW and show methods must use scnprintf
From: Greg KH @ 2015-06-30 16:38 UTC (permalink / raw)
To: Seymour, Shane M
Cc: ISS StorageDev,
James Bottomley (JBottomley-O3H1v1f1dlM@public.gmane.org),
linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
In-Reply-To: <DDB9C85B850785449757F9914A034FCB3F8EC219-MCKW7lC+H9ISZAcGdq5asR6epYMZPwEe5NbjCUgZEJk@public.gmane.org>
On Tue, Jun 30, 2015 at 05:22:20AM +0000, Seymour, Shane M wrote:
>
> Changed DEVICE_ATTR macro usage to DEVICE_ATTR_RO|WO|RW.
> This also forced some show/store function names to change.
>
> Changed all show method sprint/snprintf usage to scnprintf per
> Documentation/filesystems/sysfs.txt.
There's no need to change sprintf() to scnprintf() at all, that's just
useless churn.
>
> Signed-off-by: Shane Seymour <shane.seymour-VXdhtT5mjnY@public.gmane.org>
> ---
> --- a/drivers/scsi/hpsa.c 2015-06-25 15:52:15.633031319 -0500
> +++ b/drivers/scsi/hpsa.c 2015-06-29 17:28:24.628475369 -0500
> @@ -376,7 +376,7 @@ static int check_for_busy(struct ctlr_in
> }
>
> static u32 lockup_detected(struct ctlr_info *h);
> -static ssize_t host_show_lockup_detected(struct device *dev,
> +static ssize_t lockup_detected_show(struct device *dev,
> struct device_attribute *attr, char *buf)
> {
> int ld;
> @@ -386,10 +386,10 @@ static ssize_t host_show_lockup_detected
> h = shost_to_hba(shost);
> ld = lockup_detected(h);
>
> - return sprintf(buf, "ld=%d\n", ld);
> + return scnprintf(buf, PAGE_SIZE, "ld=%d\n", ld);
Like here, it's obvious that the original will never overflow, so don't
even worry about checking, it's pointless.
So please don't change this.
greg k-h
^ permalink raw reply
* Re: [PATCH v6 0/9] Add simple NVMEM Framework via regmap.
From: Stefan Wahren @ 2015-06-30 17:47 UTC (permalink / raw)
To: Srinivas Kandagatla,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
Cc: wxt-TNX95d0MmH7DzftRWevZcw, linux-api-u79uwXL29TY76Z2rM5mHXA,
Kumar Gala, Rob Herring, arnd-r2nGTMty4D4,
sboyd-sgV2jX0FEOL9JmXXK+q4OQ, s.hauer-bIcnvbaLZ9MEGnE8C9+IrQ,
Greg Kroah-Hartman, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
mporter-OWPKS81ov/FWk0Htik3J/w,
linux-arm-msm-u79uwXL29TY76Z2rM5mHXA, Maxime Ripard,
pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w,
devicetree-u79uwXL29TY76Z2rM5mHXA, Mark Brown
In-Reply-To: <558AFC0B.1050400-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Hi Srinivas,
> Srinivas Kandagatla <srinivas.kandagatla-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> hat am 24. Juni 2015 um
> 20:50 geschrieben:
>
>
>
>
> On 24/06/15 18:47, Stefan Wahren wrote:
> > Hi Srinivas,
> >
> >> Srinivas Kandagatla <srinivas.kandagatla-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> hat am 24. Juni 2015
> >> um
> >> 15:03 geschrieben:
> >>
> >>
> >>
> >>
> >> On 24/06/15 13:30, Stefan Wahren wrote:
> >>>>> If the question is just about hexdump, then hexdump itself can read
> >>>>> file from given offset and size.
> >>> yes, this is my question at first. Let me show the difference between
> >>> the current implementation and my expectations as a user.
> >>>
> >>> $ hexdump /sys/class/nvmem/mxs-ocotp/nvmem
> >>>
> >>> Current implementation: dump the complete register range defined in DT
> >>>
> >> Its dumping the range which is specified in the provider regmap. If the
> >> requirement is to dump only particular range, this has to be made
> >> explicit while creating regmap, which is to specify the base address to
> >> start from "First data register" and max_register to be "Last data
> >> register "- "First data register"
> >
> > i know about max_register, but i can't find the base address in
> > regmap_config.
> >
> Base is not in the regmap config, its the value which you pass to the
>
thanks for you explanation. I was confused by the word base because in your
example
it is the context variable.
Now i've successful tested my first version of the OCOTP driver based on NVMEM
framework [1].
Currently only the raw sysfs access is working. So i have another question:
How do i get the cell info from the devicetree for the nvmem_config?
I expected a function like of_nvmem_cell_info_get() .
Regards
Stefan
[1] -
https://github.com/lategoodbye/fsl_ocotp/commit/7c98e19755b69f761885b0e1ceb2c258a7c47ade
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH RESEND] Btrfs: add autodefrag inode flag
From: Dave Chinner @ 2015-06-30 21:45 UTC (permalink / raw)
To: Omar Sandoval; +Cc: linux-btrfs, linux-fsdevel, linux-api
In-Reply-To: <85de09b87ad7b2847ea001f5bb03c044e8b419aa.1435681574.git.osandov@fb.com>
On Tue, Jun 30, 2015 at 09:32:20AM -0700, Omar Sandoval wrote:
> In some cases, we may not want to enable automatic defragmentation for
> the whole filesystem with the "autodefrag" mount option but we still
> want to defragment specific files or directories. Add an inode flag
> which allows us to do specify that.
>
> Signed-off-by: Omar Sandoval <osandov@fb.com>
> ---
> Resending this because I didn't send it to fsdevel or linux-api last
> time and I'm adding a new user-facing inode flag.
XFS has a "no defrag" inode flag to tell the defragmenter not to
defrag the file. (XFS_XFLAG_NODEFRAG, see xfsctl(3)). With the ext4
project quota work, this flag and interface is being pulled up to
the VFS, so perhaps it would be a good idea to turn this around the
other way? i.e. autodefrag is the default behaviour, and the inode
contains an inheritable "no defrag" flag to prevent defrag so that
we have the same flag, API and behaviour across filesystems?
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
^ permalink raw reply
* [PATCH v2] hpsa: convert DEVICE_ATTR to RO|WO|RW and show methods must not use snprintf
From: Seymour, Shane M @ 2015-07-01 1:56 UTC (permalink / raw)
To: ISS StorageDev,
James Bottomley (JBottomley-O3H1v1f1dlM@public.gmane.org),
Greg KH
Cc: linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Changed DEVICE_ATTR macro usage to DEVICE_ATTR_RO|WO|RW.
This also forced some show/store function names to change.
Changed all show method snprintf() usage to scnprintf() per
Documentation/filesystems/sysfs.txt.
Signed-off-by: Shane Seymour <shane.seymour-VXdhtT5mjnY@public.gmane.org>
---
Changes from v1:
Dropped one sprintf() to scnprintf() change in show method.
--- a/drivers/scsi/hpsa.c 2015-06-25 15:52:15.633031319 -0500
+++ b/drivers/scsi/hpsa.c 2015-06-30 15:06:14.664263348 -0500
@@ -376,7 +376,7 @@ static int check_for_busy(struct ctlr_in
}
static u32 lockup_detected(struct ctlr_info *h);
-static ssize_t host_show_lockup_detected(struct device *dev,
+static ssize_t lockup_detected_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
int ld;
@@ -389,7 +389,7 @@ static ssize_t host_show_lockup_detected
return sprintf(buf, "ld=%d\n", ld);
}
-static ssize_t host_store_hp_ssd_smart_path_status(struct device *dev,
+static ssize_t hp_ssd_smart_path_status_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
@@ -413,7 +413,7 @@ static ssize_t host_store_hp_ssd_smart_p
return count;
}
-static ssize_t host_store_raid_offload_debug(struct device *dev,
+static ssize_t raid_offload_debug_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
@@ -438,7 +438,7 @@ static ssize_t host_store_raid_offload_d
return count;
}
-static ssize_t host_store_rescan(struct device *dev,
+static ssize_t rescan_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
@@ -449,7 +449,7 @@ static ssize_t host_store_rescan(struct
return count;
}
-static ssize_t host_show_firmware_revision(struct device *dev,
+static ssize_t firmware_revision_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct ctlr_info *h;
@@ -460,40 +460,40 @@ static ssize_t host_show_firmware_revisi
if (!h->hba_inquiry_data)
return 0;
fwrev = &h->hba_inquiry_data[32];
- return snprintf(buf, 20, "%c%c%c%c\n",
+ return scnprintf(buf, 20, "%c%c%c%c\n",
fwrev[0], fwrev[1], fwrev[2], fwrev[3]);
}
-static ssize_t host_show_commands_outstanding(struct device *dev,
+static ssize_t commands_outstanding_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct Scsi_Host *shost = class_to_shost(dev);
struct ctlr_info *h = shost_to_hba(shost);
- return snprintf(buf, 20, "%d\n",
+ return scnprintf(buf, 20, "%d\n",
atomic_read(&h->commands_outstanding));
}
-static ssize_t host_show_transport_mode(struct device *dev,
+static ssize_t transport_mode_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct ctlr_info *h;
struct Scsi_Host *shost = class_to_shost(dev);
h = shost_to_hba(shost);
- return snprintf(buf, 20, "%s\n",
+ return scnprintf(buf, 20, "%s\n",
h->transMethod & CFGTBL_Trans_Performant ?
"performant" : "simple");
}
-static ssize_t host_show_hp_ssd_smart_path_status(struct device *dev,
+static ssize_t hp_ssd_smart_path_status_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct ctlr_info *h;
struct Scsi_Host *shost = class_to_shost(dev);
h = shost_to_hba(shost);
- return snprintf(buf, 30, "HP SSD Smart Path %s\n",
+ return scnprintf(buf, 30, "HP SSD Smart Path %s\n",
(h->acciopath_status == 1) ? "enabled" : "disabled");
}
@@ -582,14 +582,14 @@ static int ctlr_needs_abort_tags_swizzle
ARRAY_SIZE(needs_abort_tags_swizzled), board_id);
}
-static ssize_t host_show_resettable(struct device *dev,
+static ssize_t resettable_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct ctlr_info *h;
struct Scsi_Host *shost = class_to_shost(dev);
h = shost_to_hba(shost);
- return snprintf(buf, 20, "%d\n", ctlr_is_resettable(h->board_id));
+ return scnprintf(buf, 20, "%d\n", ctlr_is_resettable(h->board_id));
}
static inline int is_logical_dev_addr_mode(unsigned char scsi3addr[])
@@ -631,7 +631,7 @@ static ssize_t raid_level_show(struct de
/* Is this even a logical drive? */
if (!is_logical_dev_addr_mode(hdev->scsi3addr)) {
spin_unlock_irqrestore(&h->lock, flags);
- l = snprintf(buf, PAGE_SIZE, "N/A\n");
+ l = scnprintf(buf, PAGE_SIZE, "N/A\n");
return l;
}
@@ -639,7 +639,7 @@ static ssize_t raid_level_show(struct de
spin_unlock_irqrestore(&h->lock, flags);
if (rlevel > RAID_UNKNOWN)
rlevel = RAID_UNKNOWN;
- l = snprintf(buf, PAGE_SIZE, "RAID %s\n", raid_label[rlevel]);
+ l = scnprintf(buf, PAGE_SIZE, "RAID %s\n", raid_label[rlevel]);
return l;
}
@@ -662,7 +662,7 @@ static ssize_t lunid_show(struct device
}
memcpy(lunid, hdev->scsi3addr, sizeof(lunid));
spin_unlock_irqrestore(&h->lock, flags);
- return snprintf(buf, 20, "0x%02x%02x%02x%02x%02x%02x%02x%02x\n",
+ return scnprintf(buf, 20, "0x%02x%02x%02x%02x%02x%02x%02x%02x\n",
lunid[0], lunid[1], lunid[2], lunid[3],
lunid[4], lunid[5], lunid[6], lunid[7]);
}
@@ -686,7 +686,7 @@ static ssize_t unique_id_show(struct dev
}
memcpy(sn, hdev->device_id, sizeof(sn));
spin_unlock_irqrestore(&h->lock, flags);
- return snprintf(buf, 16 * 2 + 2,
+ return scnprintf(buf, 16 * 2 + 2,
"%02X%02X%02X%02X%02X%02X%02X%02X"
"%02X%02X%02X%02X%02X%02X%02X%02X\n",
sn[0], sn[1], sn[2], sn[3],
@@ -695,7 +695,7 @@ static ssize_t unique_id_show(struct dev
sn[12], sn[13], sn[14], sn[15]);
}
-static ssize_t host_show_hp_ssd_smart_path_enabled(struct device *dev,
+static ssize_t hp_ssd_smart_path_enabled_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct ctlr_info *h;
@@ -714,30 +714,21 @@ static ssize_t host_show_hp_ssd_smart_pa
}
offload_enabled = hdev->offload_enabled;
spin_unlock_irqrestore(&h->lock, flags);
- return snprintf(buf, 20, "%d\n", offload_enabled);
+ return scnprintf(buf, 20, "%d\n", offload_enabled);
}
-static DEVICE_ATTR(raid_level, S_IRUGO, raid_level_show, NULL);
-static DEVICE_ATTR(lunid, S_IRUGO, lunid_show, NULL);
-static DEVICE_ATTR(unique_id, S_IRUGO, unique_id_show, NULL);
-static DEVICE_ATTR(rescan, S_IWUSR, NULL, host_store_rescan);
-static DEVICE_ATTR(hp_ssd_smart_path_enabled, S_IRUGO,
- host_show_hp_ssd_smart_path_enabled, NULL);
-static DEVICE_ATTR(hp_ssd_smart_path_status, S_IWUSR|S_IRUGO|S_IROTH,
- host_show_hp_ssd_smart_path_status,
- host_store_hp_ssd_smart_path_status);
-static DEVICE_ATTR(raid_offload_debug, S_IWUSR, NULL,
- host_store_raid_offload_debug);
-static DEVICE_ATTR(firmware_revision, S_IRUGO,
- host_show_firmware_revision, NULL);
-static DEVICE_ATTR(commands_outstanding, S_IRUGO,
- host_show_commands_outstanding, NULL);
-static DEVICE_ATTR(transport_mode, S_IRUGO,
- host_show_transport_mode, NULL);
-static DEVICE_ATTR(resettable, S_IRUGO,
- host_show_resettable, NULL);
-static DEVICE_ATTR(lockup_detected, S_IRUGO,
- host_show_lockup_detected, NULL);
+static DEVICE_ATTR_RO(raid_level);
+static DEVICE_ATTR_RO(lunid);
+static DEVICE_ATTR_RO(unique_id);
+static DEVICE_ATTR_WO(rescan);
+static DEVICE_ATTR_RO(hp_ssd_smart_path_enabled);
+static DEVICE_ATTR_RW(hp_ssd_smart_path_status);
+static DEVICE_ATTR_WO(raid_offload_debug);
+static DEVICE_ATTR_RO(firmware_revision);
+static DEVICE_ATTR_RO(commands_outstanding);
+static DEVICE_ATTR_RO(transport_mode);
+static DEVICE_ATTR_RO(resettable);
+static DEVICE_ATTR_RO(lockup_detected);
static struct device_attribute *hpsa_sdev_attrs[] = {
&dev_attr_raid_level,
^ permalink raw reply
* Re: [PATCH v2] hpsa: convert DEVICE_ATTR to RO|WO|RW and show methods must not use snprintf
From: Greg KH @ 2015-07-01 2:29 UTC (permalink / raw)
To: Seymour, Shane M
Cc: ISS StorageDev,
James Bottomley (JBottomley-O3H1v1f1dlM@public.gmane.org),
linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
In-Reply-To: <DDB9C85B850785449757F9914A034FCB4442D0E6-4I1V4pQFGigSZAcGdq5asR6epYMZPwEe5NbjCUgZEJk@public.gmane.org>
On Wed, Jul 01, 2015 at 01:56:03AM +0000, Seymour, Shane M wrote:
>
> Changed DEVICE_ATTR macro usage to DEVICE_ATTR_RO|WO|RW.
> This also forced some show/store function names to change.
>
> Changed all show method snprintf() usage to scnprintf() per
> Documentation/filesystems/sysfs.txt.
Forgot to mention this before, but you are doing two different things,
so this really should be 2 different patches.
But I'm not the scsi maintainer, maybe they have more lax acceptance
rules here :)
thanks,
greg k-h
^ permalink raw reply
* [PATCH 1/3] hpsa: convert show method snprintf usage to scnprintf
From: Seymour, Shane M @ 2015-07-01 3:45 UTC (permalink / raw)
To: linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
James Bottomley (JBottomley-O3H1v1f1dlM@public.gmane.org),
ISS StorageDev
Cc: linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Greg KH <greg-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org> (greg-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org)
Changed all show method snprintf usage to scnprintf per
Documentation/filesystems/sysfs.txt.
Signed-off-by: Shane Seymour <shane.seymour-VXdhtT5mjnY@public.gmane.org>
---
Please let me know if this is not the correct way to submit
patches by separating them but keeping them logically
together.
--- a/drivers/scsi/hpsa.c 2015-06-25 15:52:15.633031319 -0500
+++ b/drivers/scsi/hpsa.c 2015-06-30 16:12:58.125990687 -0500
@@ -460,7 +460,7 @@ static ssize_t host_show_firmware_revisi
if (!h->hba_inquiry_data)
return 0;
fwrev = &h->hba_inquiry_data[32];
- return snprintf(buf, 20, "%c%c%c%c\n",
+ return scnprintf(buf, 20, "%c%c%c%c\n",
fwrev[0], fwrev[1], fwrev[2], fwrev[3]);
}
@@ -470,7 +470,7 @@ static ssize_t host_show_commands_outsta
struct Scsi_Host *shost = class_to_shost(dev);
struct ctlr_info *h = shost_to_hba(shost);
- return snprintf(buf, 20, "%d\n",
+ return scnprintf(buf, 20, "%d\n",
atomic_read(&h->commands_outstanding));
}
@@ -481,7 +481,7 @@ static ssize_t host_show_transport_mode(
struct Scsi_Host *shost = class_to_shost(dev);
h = shost_to_hba(shost);
- return snprintf(buf, 20, "%s\n",
+ return scnprintf(buf, 20, "%s\n",
h->transMethod & CFGTBL_Trans_Performant ?
"performant" : "simple");
}
@@ -493,7 +493,7 @@ static ssize_t host_show_hp_ssd_smart_pa
struct Scsi_Host *shost = class_to_shost(dev);
h = shost_to_hba(shost);
- return snprintf(buf, 30, "HP SSD Smart Path %s\n",
+ return scnprintf(buf, 30, "HP SSD Smart Path %s\n",
(h->acciopath_status == 1) ? "enabled" : "disabled");
}
@@ -589,7 +589,7 @@ static ssize_t host_show_resettable(stru
struct Scsi_Host *shost = class_to_shost(dev);
h = shost_to_hba(shost);
- return snprintf(buf, 20, "%d\n", ctlr_is_resettable(h->board_id));
+ return scnprintf(buf, 20, "%d\n", ctlr_is_resettable(h->board_id));
}
static inline int is_logical_dev_addr_mode(unsigned char scsi3addr[])
@@ -631,7 +631,7 @@ static ssize_t raid_level_show(struct de
/* Is this even a logical drive? */
if (!is_logical_dev_addr_mode(hdev->scsi3addr)) {
spin_unlock_irqrestore(&h->lock, flags);
- l = snprintf(buf, PAGE_SIZE, "N/A\n");
+ l = scnprintf(buf, PAGE_SIZE, "N/A\n");
return l;
}
@@ -639,7 +639,7 @@ static ssize_t raid_level_show(struct de
spin_unlock_irqrestore(&h->lock, flags);
if (rlevel > RAID_UNKNOWN)
rlevel = RAID_UNKNOWN;
- l = snprintf(buf, PAGE_SIZE, "RAID %s\n", raid_label[rlevel]);
+ l = scnprintf(buf, PAGE_SIZE, "RAID %s\n", raid_label[rlevel]);
return l;
}
@@ -662,7 +662,7 @@ static ssize_t lunid_show(struct device
}
memcpy(lunid, hdev->scsi3addr, sizeof(lunid));
spin_unlock_irqrestore(&h->lock, flags);
- return snprintf(buf, 20, "0x%02x%02x%02x%02x%02x%02x%02x%02x\n",
+ return scnprintf(buf, 20, "0x%02x%02x%02x%02x%02x%02x%02x%02x\n",
lunid[0], lunid[1], lunid[2], lunid[3],
lunid[4], lunid[5], lunid[6], lunid[7]);
}
@@ -686,7 +686,7 @@ static ssize_t unique_id_show(struct dev
}
memcpy(sn, hdev->device_id, sizeof(sn));
spin_unlock_irqrestore(&h->lock, flags);
- return snprintf(buf, 16 * 2 + 2,
+ return scnprintf(buf, 16 * 2 + 2,
"%02X%02X%02X%02X%02X%02X%02X%02X"
"%02X%02X%02X%02X%02X%02X%02X%02X\n",
sn[0], sn[1], sn[2], sn[3],
@@ -714,7 +714,7 @@ static ssize_t host_show_hp_ssd_smart_pa
}
offload_enabled = hdev->offload_enabled;
spin_unlock_irqrestore(&h->lock, flags);
- return snprintf(buf, 20, "%d\n", offload_enabled);
+ return scnprintf(buf, 20, "%d\n", offload_enabled);
}
static DEVICE_ATTR(raid_level, S_IRUGO, raid_level_show, NULL);
^ permalink raw reply
* [PATCH 3/3] hpsa: Convert DEVICE_ATTR macro usage to DEVICE_ATTR_RO|WR|WO
From: Seymour, Shane M @ 2015-07-01 3:47 UTC (permalink / raw)
To: linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
James Bottomley (JBottomley-O3H1v1f1dlM@public.gmane.org),
ISS StorageDev
Cc: linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Greg KH <greg-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org> (greg-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org)
Convert DEVICE_ATTR macro usage to DEVICE_ATTR_RO|WR|WO
Changes forced some function names to change.
Signed-off-by: Shane Seymour <shane.seymour-VXdhtT5mjnY@public.gmane.org>
---
--- a/drivers/scsi/hpsa.c 2015-06-30 16:34:01.403904650 -0500
+++ b/drivers/scsi/hpsa.c 2015-06-30 16:21:54.214954176 -0500
@@ -376,7 +376,7 @@ static int check_for_busy(struct ctlr_in
}
static u32 lockup_detected(struct ctlr_info *h);
-static ssize_t host_show_lockup_detected(struct device *dev,
+static ssize_t lockup_detected_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
int ld;
@@ -389,7 +389,7 @@ static ssize_t host_show_lockup_detected
return sprintf(buf, "ld=%d\n", ld);
}
-static ssize_t host_store_hp_ssd_smart_path_status(struct device *dev,
+static ssize_t hp_ssd_smart_path_status_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
@@ -413,7 +413,7 @@ static ssize_t host_store_hp_ssd_smart_p
return count;
}
-static ssize_t host_store_raid_offload_debug(struct device *dev,
+static ssize_t raid_offload_debug_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
@@ -438,7 +438,7 @@ static ssize_t host_store_raid_offload_d
return count;
}
-static ssize_t host_store_rescan(struct device *dev,
+static ssize_t rescan_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
@@ -449,7 +449,7 @@ static ssize_t host_store_rescan(struct
return count;
}
-static ssize_t host_show_firmware_revision(struct device *dev,
+static ssize_t firmware_revision_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct ctlr_info *h;
@@ -464,7 +464,7 @@ static ssize_t host_show_firmware_revisi
fwrev[0], fwrev[1], fwrev[2], fwrev[3]);
}
-static ssize_t host_show_commands_outstanding(struct device *dev,
+static ssize_t commands_outstanding_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct Scsi_Host *shost = class_to_shost(dev);
@@ -474,7 +474,7 @@ static ssize_t host_show_commands_outsta
atomic_read(&h->commands_outstanding));
}
-static ssize_t host_show_transport_mode(struct device *dev,
+static ssize_t transport_mode_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct ctlr_info *h;
@@ -486,7 +486,7 @@ static ssize_t host_show_transport_mode(
"performant" : "simple");
}
-static ssize_t host_show_hp_ssd_smart_path_status(struct device *dev,
+static ssize_t hp_ssd_smart_path_status_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct ctlr_info *h;
@@ -582,7 +582,7 @@ static int ctlr_needs_abort_tags_swizzle
ARRAY_SIZE(needs_abort_tags_swizzled), board_id);
}
-static ssize_t host_show_resettable(struct device *dev,
+static ssize_t resettable_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct ctlr_info *h;
@@ -692,7 +692,7 @@ static ssize_t unique_id_show(struct dev
sn[12], sn[13], sn[14], sn[15]);
}
-static ssize_t host_show_hp_ssd_smart_path_enabled(struct device *dev,
+static ssize_t hp_ssd_smart_path_enabled_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct ctlr_info *h;
@@ -714,27 +714,18 @@ static ssize_t host_show_hp_ssd_smart_pa
return scnprintf(buf, 20, "%d\n", offload_enabled);
}
-static DEVICE_ATTR(raid_level, S_IRUGO, raid_level_show, NULL);
-static DEVICE_ATTR(lunid, S_IRUGO, lunid_show, NULL);
-static DEVICE_ATTR(unique_id, S_IRUGO, unique_id_show, NULL);
-static DEVICE_ATTR(rescan, S_IWUSR, NULL, host_store_rescan);
-static DEVICE_ATTR(hp_ssd_smart_path_enabled, S_IRUGO,
- host_show_hp_ssd_smart_path_enabled, NULL);
-static DEVICE_ATTR(hp_ssd_smart_path_status, S_IWUSR|S_IRUGO|S_IROTH,
- host_show_hp_ssd_smart_path_status,
- host_store_hp_ssd_smart_path_status);
-static DEVICE_ATTR(raid_offload_debug, S_IWUSR, NULL,
- host_store_raid_offload_debug);
-static DEVICE_ATTR(firmware_revision, S_IRUGO,
- host_show_firmware_revision, NULL);
-static DEVICE_ATTR(commands_outstanding, S_IRUGO,
- host_show_commands_outstanding, NULL);
-static DEVICE_ATTR(transport_mode, S_IRUGO,
- host_show_transport_mode, NULL);
-static DEVICE_ATTR(resettable, S_IRUGO,
- host_show_resettable, NULL);
-static DEVICE_ATTR(lockup_detected, S_IRUGO,
- host_show_lockup_detected, NULL);
+static DEVICE_ATTR_RO(raid_level);
+static DEVICE_ATTR_RO(lunid);
+static DEVICE_ATTR_RO(unique_id);
+static DEVICE_ATTR_WO(rescan);
+static DEVICE_ATTR_RO(hp_ssd_smart_path_enabled);
+static DEVICE_ATTR_RW(hp_ssd_smart_path_status);
+static DEVICE_ATTR_WO(raid_offload_debug);
+static DEVICE_ATTR_RO(firmware_revision);
+static DEVICE_ATTR_RO(commands_outstanding);
+static DEVICE_ATTR_RO(transport_mode);
+static DEVICE_ATTR_RO(resettable);
+static DEVICE_ATTR_RO(lockup_detected);
static struct device_attribute *hpsa_sdev_attrs[] = {
&dev_attr_raid_level,
^ permalink raw reply
* Re: [PATCH 3/3] hpsa: Convert DEVICE_ATTR macro usage to DEVICE_ATTR_RO|WR|WO
From: Greg KH <greg-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org> (greg-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org) @ 2015-07-01 5:45 UTC (permalink / raw)
To: Seymour, Shane M
Cc: linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
James Bottomley (JBottomley-O3H1v1f1dlM@public.gmane.org),
ISS StorageDev, linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
In-Reply-To: <DDB9C85B850785449757F9914A034FCB4442E19F-4I1V4pQFGigSZAcGdq5asR6epYMZPwEe5NbjCUgZEJk@public.gmane.org>
On Wed, Jul 01, 2015 at 03:47:10AM +0000, Seymour, Shane M wrote:
>
> Convert DEVICE_ATTR macro usage to DEVICE_ATTR_RO|WR|WO
> Changes forced some function names to change.
>
> Signed-off-by: Shane Seymour <shane.seymour-VXdhtT5mjnY@public.gmane.org>
Acked-by: Greg Kroah-Hartman <gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>
^ permalink raw reply
* [PATCH] pci_regs: reintroduce PCI_MSIX_FLAGS_BIRMASK
From: Michael S. Tsirkin @ 2015-07-01 10:14 UTC (permalink / raw)
To: linux-kernel-u79uwXL29TY76Z2rM5mHXA
Cc: Bjorn Helgaas, Rajat Jain, Chen, Gong, Guenter Roeck,
=?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?=,
linux-api-u79uwXL29TY76Z2rM5mHXA
This partially reverts commit 09a2c73ddfc7f173237fc7209a65b34dd5bcb5ed.
PCI: Remove unused PCI_MSIX_FLAGS_BIRMASK definition
That commit dropped a symbol from an exported header claiming "no one
uses it". This isn't how Linux normally approaches userspace API though,
and in fact QEMU build fails if trying to use updated headers from linux
3.12 and up.
Sure, userspace can be fixed to use the new symbol, but the cost
of keeping the old one around is fairly low, too.
Signed-off-by: Michael S. Tsirkin <mst-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
include/uapi/linux/pci_regs.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/uapi/linux/pci_regs.h b/include/uapi/linux/pci_regs.h
index efe3443..66644ac 100644
--- a/include/uapi/linux/pci_regs.h
+++ b/include/uapi/linux/pci_regs.h
@@ -319,6 +319,7 @@
#define PCI_MSIX_PBA 8 /* Pending Bit Array offset */
#define PCI_MSIX_PBA_BIR 0x00000007 /* BAR index */
#define PCI_MSIX_PBA_OFFSET 0xfffffff8 /* Offset into specified BAR */
+#define PCI_MSIX_FLAGS_BIRMASK PCI_MSIX_PBA_BIR /* deprecated */
#define PCI_CAP_MSIX_SIZEOF 12 /* size of MSIX registers */
/* MSI-X Table entry format */
--
MST
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox