]> www.infradead.org Git - users/jedix/linux-maple.git/log
users/jedix/linux-maple.git
13 years agoqla2xxx: Do not check for minidump when device state is QLA82XX_DEV_READY.
Chad Dupuis [Wed, 19 Oct 2011 15:11:02 +0000 (10:11 -0500)]
qla2xxx: Do not check for minidump when device state is QLA82XX_DEV_READY.

Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
13 years agoqla2xxx: Move initialization of some variables before iospace_config.
Chad Dupuis [Sat, 17 Sep 2011 14:43:02 +0000 (10:43 -0400)]
qla2xxx: Move initialization of some variables before iospace_config.

Some variables need to be initialized before we config PCI I/O config space
or else strange firmware initialization errors may occur.

Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
13 years agoqla2xxx: Ensure there's enough request-queue space for passthru IOCBs.
Andrew Vasquez [Fri, 23 Sep 2011 22:09:46 +0000 (15:09 -0700)]
qla2xxx: Ensure there's enough request-queue space for passthru IOCBs.

The driver should ensure there's a sufficient number of IOCBs
to satisfy the number of scatter-gather entries specified in the
command.  Add a 'count' to the control structure, srb_ctx, to use
in qla2x00_alloc_iocbs().

Signed-off-by: Andrew Vasquez <andrew.vasquez@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
13 years agoqla2xxx: Implement FCP priority tagging for 82xx adapters.
Saurav Kashyap [Tue, 20 Sep 2011 14:54:51 +0000 (09:54 -0500)]
qla2xxx: Implement FCP priority tagging for 82xx adapters.

This provides a capability to set a priority in the FCP packet.

Signed-off-by: Saurav Kashyap <saurav.kashyap@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
13 years agoqla2xxx: Consolidated IOCB processing routines.
Giridhar Malavali [Fri, 16 Dec 2011 08:59:04 +0000 (00:59 -0800)]
qla2xxx: Consolidated IOCB processing routines.

Signed-off-by: Giridhar Malavali <giridhar.malavali@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
13 years agoqla2xxx: Process marker IOCB request on request queue 0.
Giridhar Malavali [Fri, 19 Aug 2011 01:43:55 +0000 (18:43 -0700)]
qla2xxx: Process marker IOCB request on request queue 0.

When multiple request queues are created process the marker IOCB request
on request queue 0.

Signed-off-by: Giridhar Malavali <giridhar.malavali@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
13 years agoqla2xxx: Added a new entry to ISP specific function pointers structure.
Giridhar Malavali [Thu, 18 Aug 2011 20:31:21 +0000 (13:31 -0700)]
qla2xxx: Added a new entry to ISP specific function pointers structure.

Add a new function to ISP specific pointers structure to take care of ISP
specific PCI IO space configuration.

Signed-off-by: Giridhar Malavali <giridhar.malavali@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
13 years agoqla2xxx: Corrected the display of firmware dump availability for ISP82xx.
Giridhar Malavali [Wed, 14 Sep 2011 22:21:26 +0000 (22:21 +0000)]
qla2xxx: Corrected the display of firmware dump availability for ISP82xx.

Signed-off-by: Giridhar Malavali <giridhar.malavali@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
13 years agoqla2xxx: Corrected the default setting of the help text of Minidump capture mask.
Giridhar Malavali [Thu, 1 Sep 2011 18:57:18 +0000 (11:57 -0700)]
qla2xxx: Corrected the default setting of the help text of Minidump capture mask.

Signed-off-by: Giridhar Malavali <giridhar.malavali@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic>
13 years agoqla2xxx: Corrections to returned sysfs error codes.
Joe Carnuccio [Thu, 1 Sep 2011 17:32:39 +0000 (10:32 -0700)]
qla2xxx: Corrections to returned sysfs error codes.

Correct the erroneous return codes introduced by the following patch:
"Return sysfs error codes appropriate to conditions".

Signed-off-by: Joe Carnuccio <joe.carnuccio@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
13 years agoqla2xxx: Correct report-id acquisition check
Giridhar Malavali [Mon, 19 Sep 2011 21:00:44 +0000 (16:00 -0500)]
qla2xxx: Correct report-id acquisition check

Signed-off-by: Giridhar Malavali <giridhar.malavali@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
13 years agoqla2xxx: Fix to include FCE data as part of dump.
Giridhar Malavali [Wed, 31 Aug 2011 23:00:25 +0000 (16:00 -0700)]
qla2xxx: Fix to include FCE data as part of dump.

Signed-off-by: Giridhar Malavali <giridhar.malavali@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
13 years agoqla2xxx: Limit excessive DPC cycles.
Andrew Vasquez [Sat, 3 Sep 2011 00:09:27 +0000 (00:09 +0000)]
qla2xxx: Limit excessive DPC cycles.

The 'continue' cases neglected to place the thread in an
interruptible state, causing the DPC routine to wake immediately.

Signed-off-by: Andrew Vasquez <andrew.vasquez@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
13 years agoqla2xxx: Only read requested mailbox registers.
Andrew Vasquez [Fri, 2 Sep 2011 23:59:27 +0000 (16:59 -0700)]
qla2xxx: Only read requested mailbox registers.

When reading the incoming mailbox registers, read only the specified ones.

Signed-off-by: Andrew Vasquez <andrew.vasquez@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
13 years agoqla2xxx: Proper cleanup of pass through commands when firmware returns error.
Giridhar Malavali [Fri, 9 Sep 2011 07:35:56 +0000 (00:35 -0700)]
qla2xxx: Proper cleanup of pass through commands when firmware returns error.

Signed-off-by: Giridhar Malavali <giridhar.malavali@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
13 years agoqla2xxx: Update to dynamic logging.
Chad Dupuis [Fri, 16 Dec 2011 08:49:42 +0000 (00:49 -0800)]
qla2xxx: Update to dynamic logging.

This patch contains minor fixes to our new logging infrastructure:

- Remove extranous messages.
- Re-add 'nexus' and 'hdl' information.
- Adjusted the message ids to fill up the holes.
- Display FCP_CMND priority on update.
- Log only mail box error conditions.
- Do not print "Firmware ready **** FAILED ****" if cable is unplugged.
- Drop noisy 'fw_state...curr time...' message.
- Correct nexus display during abort.
- Add a special case error-logging set to '1'.
- Catagorize I/O exception display handling.
- Correct the bsg msg code printing.
- Dont use dynamic logging after host is removed.

Signed-off-by: Saurav Kashyap <saurav.kashyap@qlogic.com>
Signed-off-by: Andrew Vasquez <andrew.vasquez@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
13 years agoqla2xxx: Make the logging functions verify their arguments and fixed the current...
Joe Perches [Fri, 5 Aug 2011 17:08:01 +0000 (10:08 -0700)]
qla2xxx: Make the logging functions verify their arguments and fixed the current broken uses as appropriate.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Saurav Kashyap <saurav.kashyap@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
13 years agoqla2xxx: Use less stack to emit logging messages.
Joe Perches [Tue, 2 Aug 2011 12:54:22 +0000 (05:54 -0700)]
qla2xxx: Use less stack to emit logging messages.

Return early when logging level too low.
Use normal kernel codeing style for function braces.
Add const where appropriate to logging functions.
Remove now unused #define QL_DBG_BUF_LEN.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Saurav Kashyap <saurav.kashyap@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
13 years agoqla2xxx: Update version number to 8.03.07.12-k.
Chad Dupuis [Tue, 15 Nov 2011 15:06:36 +0000 (09:06 -0600)]
qla2xxx: Update version number to 8.03.07.12-k.

Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
13 years agoqla2xxx: Submit all chained IOCBs for passthrough commands on request queue 0.
Giridhar Malavali [Thu, 8 Sep 2011 18:04:56 +0000 (11:04 -0700)]
qla2xxx: Submit all chained IOCBs for passthrough commands on request queue 0.

Signed-off-by: Giridhar Malavali <giridhar.malavali@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
13 years agoqla2xxx: Correct fc_host port_state display.
Saurav Kashyap [Mon, 3 Oct 2011 13:36:30 +0000 (08:36 -0500)]
qla2xxx: Correct fc_host port_state display.

Add more fine grain parsing of vha->loop_state to export a more accurate
fc_host port_state.

Signed-off-by: Saurav Kashyap <saurav.kashyap@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
13 years agoqla2xxx: Display IPE error message for ISP82xx.
Chad Dupuis [Mon, 17 Oct 2011 20:29:21 +0000 (15:29 -0500)]
qla2xxx: Display IPE error message for ISP82xx.

Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
13 years agoqla2xxx: Return the correct value for a mailbox command if 82xx is in reset recovery.
Andrew Vasquez [Mon, 10 Oct 2011 20:28:39 +0000 (15:28 -0500)]
qla2xxx: Return the correct value for a mailbox command if 82xx is in reset recovery.

We need to return QLA_FUNCTION_TIMEOUT immediately otherwise we mess up the
mailbox command state machine.

Signed-off-by: Andrew Vasquez <andrew.vasquez@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
13 years agoqla2xxx: Enable Minidump by default with default capture mask 0x1f.
Giridhar Malavali [Thu, 29 Sep 2011 17:49:47 +0000 (12:49 -0500)]
qla2xxx: Enable Minidump by default with default capture mask 0x1f.

Signed-off-by: Giridhar Malavali <giridhar.malavali@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
13 years agoqla2xxx: Stop unconditional completion of mailbox commands issued in interrupt mode...
Giridhar Malavali [Thu, 29 Sep 2011 17:46:07 +0000 (12:46 -0500)]
qla2xxx: Stop unconditional completion of mailbox commands issued in interrupt mode during firmware hang.

Signed-off-by: Giridhar Malavali <giridhar.malavali@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
13 years agoqla2xxx: Revert back the request queue mapping to request queue 0.
Giridhar Malavali [Mon, 19 Sep 2011 19:50:01 +0000 (19:50 +0000)]
qla2xxx: Revert back the request queue mapping to request queue 0.

If there is an error creating multiple response queues then we need to revert
the request queue mapping back to request queue 0.

Signed-off-by: Giridhar Malavali <giridhar.malavali@qlogic.com>
Signed-off-by: Andrew Vasquez <andrew.vasquez@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
13 years agoqla2xxx: Don't call alloc_fw_dump for ISP82XX.
Saurav Kashyap [Thu, 11 Aug 2011 20:05:55 +0000 (13:05 -0700)]
qla2xxx: Don't call alloc_fw_dump for ISP82XX.

Signed-off-by: Saurav Kashyap <saurav.kashyap@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
13 years agoqla2xxx: Check for SCSI status on underruns.
Arun Easi [Mon, 25 Jul 2011 23:59:51 +0000 (16:59 -0700)]
qla2xxx: Check for SCSI status on underruns.

Signed-off-by: Arun Easi <arun.easi@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
13 years agoqla2xxx: Remove qla2x00_wait_for_loop_ready function.
Saurav Kashyap [Thu, 11 Aug 2011 20:09:37 +0000 (13:09 -0700)]
qla2xxx: Remove qla2x00_wait_for_loop_ready function.

This function can wait for 5min under certain scenarios. One of them is when
the port is down from switch and bus reset is issued. The bus reset used to
wait for 5 minutes for the loop and upper layer callers used to hang and give
stack trace because of getting stuck for 120 sec. Its legacy code that was used
when the driver used to do queuing of the commands.

Signed-off-by: Saurav Kashyap <saurav.kashyap@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
13 years agoqla2xxx: Correct inadvertent clearing of RISC_INTR status.
Andrew Vasquez [Wed, 26 Oct 2011 21:20:13 +0000 (14:20 -0700)]
qla2xxx: Correct inadvertent clearing of RISC_INTR status.

During heavy I/O (CPU-affinity mode enabled) and CLI/Agent
interactions, the driver would report periodic mailbox command
timeout statuses.  Within the CPU-affinity ISR handler, the
driver should check the 'disable-msix-handshake' flag in deciding
whether or not to clear HCCRX_CLR_RISC_INT.  The mode is not
specific to a dedicated queue, instead, applies to the current
'ha' context.

Signed-off-by: Andrew Vasquez <andrew.vasquez@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
13 years agoqla2xxx: Fix crash in qla2x00_abort_all_cmds() on unload
Roland Dreier [Thu, 22 Sep 2011 07:06:05 +0000 (00:06 -0700)]
qla2xxx: Fix crash in qla2x00_abort_all_cmds() on unload

I hit a crash in qla2x00_abort_all_cmds() if the qla2xxx module is
unloaded right after it is loaded.  I debugged this down to the abort
handling improperly treating a command of type SRB_ADISC_CMD as if it
had a bsg_job to complete when that command actually uses the iocb_cmd
part of the union.  (I guess to hit this one has to unload the module
while the async FC initialization is still in progress)

It seems we should only look for a bsg_job if type is SRB_ELS_CMD_RPT,
SRB_ELS_CMD_HST or SRB_CT_CMD, so switch the test to make that explicit.

Signed-off-by: Roland Dreier <roland@purestorage.com>
Acked-by: Chad Dupuis <chad.dupuis@qlogic.com>
Cc: stable@kernel.org
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
13 years agoscsi: fix qla2xxx printk format warning
Randy Dunlap [Fri, 23 Sep 2011 22:40:50 +0000 (15:40 -0700)]
scsi: fix qla2xxx printk format warning

sector_t can be different types, so cast it to its largest possible
type.

  drivers/scsi/qla2xxx/qla_isr.c:1509:5: warning: format '%lx' expects type 'long unsigned int', but argument 5 has type 'sector_t'

Signed-off-by: Randy Dunlap <rdunlap@xenotime.net>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
13 years agoqla2xxx: Fix "active_mask" may be used uninitialized warning.
Chad Dupuis [Tue, 16 Aug 2011 18:31:55 +0000 (11:31 -0700)]
qla2xxx: Fix "active_mask" may be used uninitialized warning.

Since active_mask is first assigned in an "else" block, the compiler throws
a warning saying that the active_mask variable may be used uninitialized in
a print statement later.  Initialize active_mask to 0 in the declaration to
stop the warning.

Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
13 years agoqla2xxx: Issue mailbox command only when firmware hung bit is reset for ISP82xx.
Giridhar Malavali [Tue, 16 Aug 2011 18:31:54 +0000 (11:31 -0700)]
qla2xxx: Issue mailbox command only when firmware hung bit is reset for ISP82xx.

Signed-off-by: Giridhar Malavali <giridhar.malavali@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
13 years agoqla2xxx: Return sysfs error codes appropriate to conditions.
Joe Carnuccio [Tue, 16 Aug 2011 18:31:53 +0000 (11:31 -0700)]
qla2xxx: Return sysfs error codes appropriate to conditions.

Return sysfs error codes that match the conditions encountered.
This prevents sysfs from retrying a request which is conditioned
to fail under the current circumstance.

Signed-off-by: Joe Carnuccio <joe.carnuccio@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
13 years agoqla2xxx: Provide method for updating I2C attached VPD.
Joe Carnuccio [Tue, 16 Aug 2011 18:31:52 +0000 (11:31 -0700)]
qla2xxx: Provide method for updating I2C attached VPD.

Provide bsg interface for updating VPD attached on the I2C serial bus.

Signed-off-by: Joe Carnuccio <joe.carnuccio@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
13 years agoqla2xxx: Correction to sysfs edc interface.
Joe Carnuccio [Tue, 16 Aug 2011 18:31:51 +0000 (11:31 -0700)]
qla2xxx: Correction to sysfs edc interface.

Corrects the return value for the cases where read/write edc fails;
this prevents sysfs from retrying the operation until forever.

Corrects the printk width specifier for the first byte of buf.

Signed-off-by: Joe Carnuccio <joe.carnuccio@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
13 years agoqla2xxx: During loopdown perform Diagnostic loopback.
Saurav Kashyap [Tue, 16 Aug 2011 18:31:50 +0000 (11:31 -0700)]
qla2xxx: During loopdown perform Diagnostic loopback.

Signed-off-by: Saurav Kashyap <saurav.kashyap@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
13 years agoqla2xxx: Fix array out of bound warning.
Saurav Kashyap [Tue, 16 Aug 2011 18:31:49 +0000 (11:31 -0700)]
qla2xxx: Fix array out of bound warning.

Signed-off-by: Saurav Kashyap <saurav.kashyap@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
13 years agoqla2xxx: check for marker IOCB during response queue processing.
Saurav Kashyap [Tue, 16 Aug 2011 18:31:48 +0000 (11:31 -0700)]
qla2xxx: check for marker IOCB during response queue processing.

Signed-off-by: Saurav Kashyap <saurav.kashyap@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
13 years agoqla2xxx: Enable write permission to some debug related module parameters to be change...
Chad Dupuis [Tue, 16 Aug 2011 18:31:47 +0000 (11:31 -0700)]
qla2xxx: Enable write permission to some debug related module parameters to be changed dynamically.

Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
13 years agoqla2xxx: Prevent CPU lockups when "ql2xdontresethba" module param is set.
Saurav Kashyap [Tue, 16 Aug 2011 18:31:46 +0000 (11:31 -0700)]
qla2xxx: Prevent CPU lockups when "ql2xdontresethba" module param is set.

Driver is not releasing the lock if ql2xdontresethba is set, this might lead
to a lockup.

Signed-off-by: Saurav Kashyap <saurav.kashyap@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
13 years agoqla2xxx: Implemeted beacon on/off for ISP82XX.
Saurav Kashyap [Tue, 16 Aug 2011 18:31:45 +0000 (11:31 -0700)]
qla2xxx: Implemeted beacon on/off for ISP82XX.

[jejb: fix up checkpatch.pl errors]
Signed-off-by: Saurav Kashyap <saurav.kashyap@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
13 years agoqla2xxx: Add support for ISP82xx to capture dump (minidump) on failure.
Giridhar Malavali [Tue, 16 Aug 2011 18:31:44 +0000 (11:31 -0700)]
qla2xxx: Add support for ISP82xx to capture dump (minidump) on failure.

Minidump allows us to catpure a snapshot of the firmware/hardware states at the
time of failure for further analysis.

[jejb: added missing #include <linux/vmalloc.h>
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au> ]
Signed-off-by: Giridhar Malavali <giridhar.malavali@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
13 years agoqla2xxx: Update version number to 8.03.07.07-k.
Chad Dupuis [Tue, 16 Aug 2011 18:29:30 +0000 (11:29 -0700)]
qla2xxx: Update version number to 8.03.07.07-k.

Signed-off-by: James Bottomley <JBottomley@Parallels.com>
13 years agoqla2xxx: Set the task attributes after memsetting fcp cmnd.
Saurav Kashyap [Tue, 16 Aug 2011 18:29:29 +0000 (11:29 -0700)]
qla2xxx: Set the task attributes after memsetting fcp cmnd.

The memset of the fcp_cmnd struct needs to be moved so that it will not
zero-out valid data.

Signed-off-by: Saurav Kashyap <saurav.kashyap@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
13 years agoqla2xxx: Save and restore irq in the response queue interrupt handler.
Saurav Kashyap [Tue, 16 Aug 2011 18:29:27 +0000 (11:29 -0700)]
qla2xxx: Save and restore irq in the response queue interrupt handler.

Signed-off-by: Saurav Kashyap <saurav.kashyap@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
13 years agoqla2xxx: Double check for command completion if abort mailbox command fails.
Chad Dupuis [Tue, 16 Aug 2011 18:29:26 +0000 (11:29 -0700)]
qla2xxx: Double check for command completion if abort mailbox command fails.

Close a small window where we could falsely fail an abort request if the mailbox
command fails but the command was returned during interrupt context.

Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
13 years agoqla2xxx: Acquire hardware lock while manipulating dsd list.
Saurav Kashyap [Tue, 16 Aug 2011 18:29:25 +0000 (11:29 -0700)]
qla2xxx: Acquire hardware lock while manipulating dsd list.

The dsd list shouldn't be manipulated without taking the per host hardware
lock to prevent multiple callers from trampling upon one another.

Signed-off-by: Saurav Kashyap <saurav.kashyap@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
13 years agoqla2xxx: Fix qla24xx revision check while enabling interrupts.
Chad Dupuis [Tue, 16 Aug 2011 18:29:24 +0000 (11:29 -0700)]
qla2xxx: Fix qla24xx revision check while enabling interrupts.

Since we enable interrupts before initializing the firmware, use the chip
revision from PCI config space directly to perform the chip revision check.
Also remove the unnecessary firmware attributes test.

Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
13 years agoqla2xxx: T10 DIF - Fix incorrect error reporting.
Arun Easi [Tue, 16 Aug 2011 18:29:23 +0000 (11:29 -0700)]
qla2xxx: T10 DIF - Fix incorrect error reporting.

This fix:
    - Disables app tag peeking; correct tag check will be added when the
      SCSI API is available.
    - Always derive ref_tag from scsi_get_lba()
    - Removes incorrect swap of FCP_LUN in FCP_CMND
    - Moves app-tag error check before ref-tag check. The reason being,
      currently there is no interface in SCSI to retrieve the app-tag
      for protection I/Os, so driver puts zero for app-tag in the
      firmware interface, but requests not to validate it, but when a
      ref-tag error is detected by firmware, it would put
      expected/actual tags for all the protection tags (guard/app/ref).
      As driver checks for app tag error first, a ref-tag error is
      incorrectly flagged as app-tag error.
    - Convert HBA specific checks to capability based.

Signed-off-by: Arun Easi <arun.easi@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
13 years agoqla2xxx: T10 DIF - Handle uninitalized sectors.
Arun Easi [Tue, 16 Aug 2011 18:29:22 +0000 (11:29 -0700)]
qla2xxx: T10 DIF - Handle uninitalized sectors.

Driver needs to update protection bytes for uninitialized sectors as they are
not DMA-d.

Signed-off-by: Arun Easi <arun.easi@qlogic.com>
Reviewed-by: Andrew Vasquez <andrew.vasquez@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
13 years agoqla2xxx: Cleanup of previous infrastructure.
Saurav Kashyap [Thu, 14 Jul 2011 19:00:14 +0000 (12:00 -0700)]
qla2xxx: Cleanup of previous infrastructure.

Signed-off-by: Saurav Kashyap <saurav.kashyap@qlogic.com>
Signed-off-by: Giridhar Malavali <giridhar.malavali@qlogic.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
13 years agoqla2xxx: Code changes to support new dynamic logging infrastructure.
Saurav Kashyap [Thu, 14 Jul 2011 19:00:13 +0000 (12:00 -0700)]
qla2xxx: Code changes to support new dynamic logging infrastructure.

The code is changed to support the new dynamic logging infrastructure.
Following are the levels added.
Default is 0 - no logging.  0x40000000 - Module Init & Probe.
0x20000000 - Mailbox Cmnds. 0x10000000 - Device Discovery.
0x08000000 - IO tracing.    0x04000000 - DPC Thread.
0x02000000 - Async events.  0x01000000 - Timer routines.
0x00800000 - User space.    0x00400000 - Task Management.
0x00200000 - AER/EEH.       0x00100000 - Multi Q.
0x00080000 - P3P Specific.  0x00040000 - Virtual Port.
0x00020000 - Buffer Dump.   0x00010000 - Misc.
0x7fffffff - For enabling all logs, can be too many logs.

Setting ql2xextended_error_logging module parameter to any of the above
value, will enable the debug for that particular level.
Do LOGICAL OR of the value to enable more than one level.

Signed-off-by: Saurav Kashyap <saurav.kashyap@qlogic.com>
Signed-off-by: Giridhar Malavali <giridhar.malavali@qlogic.com>
Signed-off-by: Andrew Vasquez <andrew.vasquez@qlogic.com>
Signed-off-by: Joe Carnuccio <joe.carnuccio@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dupuis@qlogic.com>
Signed-off-by: Madhuranath Iyengar <Madhu.Iyengar@qlogic.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
13 years agoqla2xxx: Basic infrastructure for dynamic logging.
Saurav Kashyap [Thu, 14 Jul 2011 19:00:12 +0000 (12:00 -0700)]
qla2xxx: Basic infrastructure for dynamic logging.

This patch adds the dynamic logging framework to the qla2xxx driver.
The user will be able to change the logging levels on the fly i.e.
without load/unload of the driver. This also enables logging to be
enabled for a particular section of the driver such as initialization,
device discovery etc.

Signed-off-by: Saurav Kashyap <saurav.kashyap@qlogic.com>
Signed-off-by: Giridhar Malavali <giridhar.malavali@qlogic.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
13 years agoscsi: qla_isr.c: fix comment typo 'hammmer'
Justin P. Mattock [Fri, 24 Jun 2011 06:22:27 +0000 (23:22 -0700)]
scsi: qla_isr.c: fix comment typo 'hammmer'

Signed-off-by: Justin P. Mattock <justinmattock@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
13 years agoSPEC: ol6 req dracut-kernel-004-242.0.3
Maxim Uvarov [Tue, 6 Dec 2011 01:20:56 +0000 (17:20 -0800)]
SPEC: ol6 req dracut-kernel-004-242.0.3

Orabug: 13388545
Since firmware moved to uname -r directory dracut has to be able
to load firmware from that directory
Signed-off-by: Maxim Uvarov <maxim.uvarov@oracle.com>
13 years agoSPEC: req udev-095-14.27.0.1.el5_7.1 or more
Maxim Uvarov [Tue, 6 Dec 2011 01:15:22 +0000 (17:15 -0800)]
SPEC: req udev-095-14.27.0.1.el5_7.1 or more

Orabug: 13348381
Since firmware moved to uname -r directory udev has to be able
to load firmware from that directory
Signed-off-by: Maxim Uvarov <maxim.uvarov@oracle.com>
13 years agoSPEC: el5 mkinird more then 5.1.19.6-71.0.10
Maxim Uvarov [Tue, 6 Dec 2011 01:10:17 +0000 (17:10 -0800)]
SPEC: el5 mkinird more then 5.1.19.6-71.0.10

Orabug: 13459000
Since firmware moved to uname -r directory updated mkinird is required
for el5.
Signed-off-by: Maxim Uvarov <maxim.uvarov@oracle.com>
13 years agohpwd watchdog mark page executable
Maxim Uvarov [Mon, 5 Dec 2011 18:57:21 +0000 (10:57 -0800)]
hpwd watchdog mark page executable

Orabug: 13115973
Mark hpwdt watchdog pages executable to prevent failing:
BUG: unable to handle kernel paging request at c00f0000
 IP: [<c00f0000>] 0xc00effff
 *pdpt = 0000000000b7c001 *pde = 0000000000cf5067 *pte = 80000000000f0163
 Oops: 0011 [#1] SMP
 Modules linked in: hpwdt(+)(U) ipmi_si(U) ipmi_msghandler(U) serio_raw(U)
 pcspkr(U) k8temp(U) ext4(U) mbcache(U) jbd2(U) hpsa(U) cciss(U) lpfc(U)
 qla2xxx(U) scsi_transport_fc(U) scsi_tgt(U) radeon(U) ttm(U)
 drm_kms_helper(U) drm(U) hwmon(U) i2c_algo_bit(U) i2c_core(U) dm_mod(U)
 .
 Pid: 741, comm: modprobe Not tainted 2.6.39-100.0.15.el6uek.i686 #1 HP
 ProLiant BL685c G1
 EIP: 0060:[<c00f0000>] EFLAGS: 00010286 CPU: 1
 EIP is at 0xc00f0000
 EAX: 55524324 EBX: 00000000 ECX: 00000000 EDX: 00000000
 ESI: 00000000 EDI: 00000000 EBP: e892fda0 ESP: e892fd70
  DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
 Process modprobe (pid: 741, ti=e892e000 task=e96d0da0 task.ti=e892e000)
 Stack:
  f902b020 00000060 0000007b 00000286 ffffffed c00f0000 e892fda0 e892fda0
  c00f0000 00000001 00000000 c00f0000 e892fdc4 f902b500 f902c0e0 c00f0000
  e892fdc4 c0439b6f c00ffee0 c0100000 c00f0000 e892fdf0 f902b627 ea276860
 Call Trace:
  [<f902b020>] ? asminline_call+0x20/0x50 [hpwdt]
  [<f902b500>] cru_detect+0x43/0xf6 [hpwdt]
  [<c0439b6f>] ? ioremap_nocache+0x1f/0x30
  [<f902b627>] hpwdt_init_nmi_decoding+0x74/0x16b [hpwdt]
  [<c085f469>] ? printk+0x1d/0x24
  [<f902b7f4>] hpwdt_init_one+0xd6/0x162 [hpwdt]
  [<c06d8475>] ? pm_runtime_enable+0x45/0x70
  [<c06149c7>] local_pci_probe+0x47/0xb0
  [<c0615978>] pci_device_probe+0x68/0x90
  [<c06d0aee>] really_probe+0x5e/0x210
  [<c06d9808>] ? pm_runtime_barrier+0x48/0xb0
  [<c06d0ce3>] driver_probe_device+0x43/0xa0
  [<c061494e>] ? pci_match_device+0x9e/0xb0
  [<c06d0dc1>] __driver_attach+0x81/0x90
  [<c06d0020>] bus_for_each_dev+0x50/0x70
  [<c06d08fe>] driver_attach+0x1e/0x20
  [<c06d0d40>] ? driver_probe_device+0xa0/0xa0
  [<c06d0397>] bus_add_driver+0x197/0x270
  [<c06157f0>] ? pci_dev_put+0x20/0x20
  [<c06d13ea>] driver_register+0x6a/0x130
  [<c0615ba5>] __pci_register_driver+0x45/0xb0
  [<f902e017>] hpwdt_init+0x17/0x19 [hpwdt]
  [<c0403035>] do_one_initcall+0x35/0x170
  [<f902e000>] ? 0xf902dfff
  [<c0491ac5>] sys_init_module+0x75/0x1c0
  [<c04ac8a6>] ? audit_syscall_exit+0x216/0x240
  [<c0868f9f>] sysenter_do_call+0x12/0x28
 Code: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
  90 80 fc d8 75 0d e9 03 07 00 00 b8 04 00 00 02 05 00 00 9c
 EIP: [<c00f0000>] 0xc00f0000 SS:ESP 0068:e892fd70
 CR2: 00000000c00f0000

Signed-off-by: Maxim Uvarov <maxim.uvarov@oracle.com>
13 years agoput firmware to kernel version specific location
Maxim Uvarov [Sat, 3 Dec 2011 00:03:06 +0000 (16:03 -0800)]
put firmware to kernel version specific location

Orabug: 13254457
By default firmware loaded with priorities from this folders:
/lib/udev/firmware.sh:
FIRMWARE_DIRS="/lib/firmware/updates/$(uname -r) /lib/firmware/updates \
                /lib/firmware/$(uname -r) /lib/firmware"

Place firmware to /lib/firmware/$(uname -r) instead of /lib/firmware
to avoid collisions between different firmware versions.

Signed-off-by: Maxim Uvarov <maxim.uvarov@oracle.com>
13 years agoInstall include/drm headers
Maxim Uvarov [Thu, 1 Dec 2011 19:41:43 +0000 (11:41 -0800)]
Install include/drm headers

Orabug:13260234
Signed-off-by: Maxim Uvarov <maxim.uvarov@oracle.com>
13 years agoMerge branch 'uek2-oracleasm' of ca-git.us.oracle.com:linux-mkp-public into uek2...
Maxim Uvarov [Wed, 30 Nov 2011 01:19:46 +0000 (17:19 -0800)]
Merge branch 'uek2-oracleasm' of ca-git.us.oracle.com:linux-mkp-public into uek2-stable-update2

13 years agoSet panic_on_oops to default to true
Maxim Uvarov [Tue, 29 Nov 2011 22:31:43 +0000 (14:31 -0800)]
Set panic_on_oops to default to true

Orabug: 13248236
(cherry picked from commit 699300f48c4eb16308fec6575fa2047891d56fd1)
(cherry picked from commit 48f59636aca88a6c9c04c8e0919b4d117185037d)
Conflicts:

kernel/panic.c

Signed-off-by: Chris Mason <chris.mason@oracle.com>
Signed-off-by: Maxim Uvarov <maxim.uvarov@oracle.com>
13 years agomodsign: no sign if keys are missing
Maxim Uvarov [Tue, 29 Nov 2011 01:37:43 +0000 (17:37 -0800)]
modsign: no sign if keys are missing

Orabug: 13421398
- SPEC: use kernel source dir for gpg
- No sign modules if no keys

Signed-off-by: Maxim Uvarov <maxim.uvarov@oracle.com>
13 years agoOracle ASM Kernel Driver
Martin K. Petersen [Tue, 22 Nov 2011 21:27:39 +0000 (16:27 -0500)]
Oracle ASM Kernel Driver

Include version 2.0.7 of oracleasm.

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
13 years agoSPEC: v2.6.39-100.0.17
Maxim Uvarov [Wed, 16 Nov 2011 18:11:13 +0000 (10:11 -0800)]
SPEC: v2.6.39-100.0.17

Signed-off-by: Maxim Uvarov <maxim.uvarov@oracle.com>
13 years agoMerge branch 'uek2-stable' of ssh://ca-server1/home/mason/git/linux-uek-2.6.39 into...
Maxim Uvarov [Wed, 16 Nov 2011 18:04:24 +0000 (10:04 -0800)]
Merge branch 'uek2-stable' of ssh://ca-server1/home/mason/git/linux-uek-2.6.39 into uek2-stable-update

13 years agoBtrfs: fix tree corruption after multi-thread snapshots and inode_cache flush
Liu Bo [Tue, 15 Nov 2011 01:48:06 +0000 (20:48 -0500)]
Btrfs: fix tree corruption after multi-thread snapshots and inode_cache flush

The btrfs snapshotting code requires that once a root has been
snapshotted, we don't change it during a commit.

But there are two cases to lead to tree corruptions:

1) multi-thread snapshots can commit serveral snapshots in a transaction,
   and this may change the src root when processing the following pending
   snapshots, which lead to the former snapshots corruptions;

2) the free inode cache was changing the roots when it root the cache,
   which lead to corruptions.

This fixes things by making sure we force COW the block after we create a
snapshot during commiting a transaction, then any changes to the roots
will result in COW, and we get all the fs roots and snapshot roots to be
consistent.

Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
(cherry picked from commit f1ebcc74d5b2159f44c96b479b6eb8afc7829095)

13 years agobtrfs: rename the option to nospace_cache
David Sterba [Fri, 11 Nov 2011 15:14:57 +0000 (10:14 -0500)]
btrfs: rename the option to nospace_cache

Rename no_space_cache option to nospace_cache to be more consistent with
the rest, where the simple prefix 'no' is used to negate an option.

The option has been introduced during the -rc1 cycle and there are has not been
widely used, so it's safe.

Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
(cherry picked from commit 8965593e41dd2d0e2a2f1e6f245336005ea94a2c)

13 years agoBtrfs: handle bio_add_page failure gracefully in scrub
Arne Jansen [Fri, 11 Nov 2011 13:17:10 +0000 (08:17 -0500)]
Btrfs: handle bio_add_page failure gracefully in scrub

Currently scrub fails with ENOMEM when bio_add_page fails. Unfortunately
dm based targets accept only one page per bio, thus making scrub always
fails. This patch just submits the current bio when an error is encountered
and starts a new one.

Signed-off-by: Arne Jansen <sensille@gmx.net>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
(cherry picked from commit 69f4cb526bd02ae5af35846f9a710c099eec3347)

13 years agoBtrfs: fix deadlock caused by the race between relocation
Miao Xie [Fri, 11 Nov 2011 01:45:05 +0000 (20:45 -0500)]
Btrfs: fix deadlock caused by the race between relocation

We can not do flushable reservation for the relocation when we create snapshot,
because it may make the transaction commit task and the flush task wait for
each other and the deadlock happens.

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
(cherry picked from commit 62f30c5462374b991e7e3f42d49ce2265c1b82f1)

13 years agoBtrfs: only map pages if we know we need them when reading the space cache
Josef Bacik [Fri, 11 Nov 2011 01:45:05 +0000 (20:45 -0500)]
Btrfs: only map pages if we know we need them when reading the space cache

People have been running into a warning when loading space cache because the
page is already mapped when trying to read in a bitmap.  The way we read in
entries and pages is kind of convoluted, so fix it so that io_ctl_read_entry
maps the entries if it needs to, and if it hits the end of the page it simply
unmaps the page.  That way we can unconditionally unmap the io_ctl before
reading in the bitmap and we should stop hitting these warnings.  Thanks,

Signed-off-by: Josef Bacik <josef@redhat.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
(cherry picked from commit 2f120c05e67ae34c93786b1050c6828904314429)

13 years agoBtrfs: fix orphan backref nodes
Miao Xie [Fri, 11 Nov 2011 01:45:05 +0000 (20:45 -0500)]
Btrfs: fix orphan backref nodes

If the root node of a fs/file tree is in the block group that is
being relocated, but the others are not in the other block groups.
when we create a snapshot for this tree between the relocation tree
creation ends and ->create_reloc_tree is set to 0, Btrfs will create
some backref nodes that are the lowest nodes of the backrefs cache.
But we forget to add them into ->leaves list of the backref cache
and deal with them, and at last, they will triggered BUG_ON().

  kernel BUG at fs/btrfs/relocation.c:239!

This patch fixes it by adding them into ->leaves list of backref cache.

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
(cherry picked from commit 76b9e23d25d5c99f994bee3172de39492e452e93)

13 years agoBtrfs: Abstract similar code for btrfs_block_rsv_add{, _noflush}
Miao Xie [Fri, 11 Nov 2011 01:45:05 +0000 (20:45 -0500)]
Btrfs: Abstract similar code for btrfs_block_rsv_add{, _noflush}

btrfs_block_rsv_add{, _noflush}() have similar code, so abstract that code.

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
(cherry picked from commit 61b520a9d0083b9b361638e456af45fd75150c87)

13 years agoBtrfs: fix unreleased path in btrfs_orphan_cleanup()
Miao Xie [Fri, 11 Nov 2011 01:45:05 +0000 (20:45 -0500)]
Btrfs: fix unreleased path in btrfs_orphan_cleanup()

When we did stress test for the space relocation, the deadlock happened.
By debugging, We found it was caused by the carelessness that we forgot
to unlock the read lock of the extent buffers in btrfs_orphan_cleanup()
before we end the transaction handle, so the transaction commit task waited
the task, which called btrfs_orphan_cleanup(), to unlock the extent buffer,
but that task waited the commit task to end the transaction commit, and
the deadlock happened. Fix it.

Signed-ff-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
(cherry picked from commit 3254c87618354e58fa2a7b375c6664f567480c33)

13 years agoBtrfs: fix no reserved space for writing out inode cache
Miao Xie [Fri, 11 Nov 2011 01:45:04 +0000 (20:45 -0500)]
Btrfs: fix no reserved space for writing out inode cache

I-node cache forgets to reserve the space when writing out it. And when
we do some stress test, such as synctest, it will trigger WARN_ON() in
use_block_rsv().

WARNING: at fs/btrfs/extent-tree.c:5718 btrfs_alloc_free_block+0xbf/0x281 [btrfs]()
...
Call Trace:
 [<ffffffff8104df86>] warn_slowpath_common+0x80/0x98
 [<ffffffff8104dfb3>] warn_slowpath_null+0x15/0x17
 [<ffffffffa0369c60>] btrfs_alloc_free_block+0xbf/0x281 [btrfs]
 [<ffffffff810cbcb8>] ? __set_page_dirty_nobuffers+0xfe/0x108
 [<ffffffffa035c040>] __btrfs_cow_block+0x118/0x3b5 [btrfs]
 [<ffffffffa035c7ba>] btrfs_cow_block+0x103/0x14e [btrfs]
 [<ffffffffa035e4c4>] btrfs_search_slot+0x249/0x6a4 [btrfs]
 [<ffffffffa036d086>] btrfs_lookup_inode+0x2a/0x8a [btrfs]
 [<ffffffffa03788b7>] btrfs_update_inode+0xaa/0x141 [btrfs]
 [<ffffffffa036d7ec>] btrfs_save_ino_cache+0xea/0x202 [btrfs]
 [<ffffffffa03a761e>] ? btrfs_update_reloc_root+0x17e/0x197 [btrfs]
 [<ffffffffa0373867>] commit_fs_roots+0xaa/0x158 [btrfs]
 [<ffffffffa03746a6>] btrfs_commit_transaction+0x405/0x731 [btrfs]
 [<ffffffff810690df>] ? wake_up_bit+0x25/0x25
 [<ffffffffa039d652>] ? btrfs_log_dentry_safe+0x43/0x51 [btrfs]
 [<ffffffffa0381c5f>] btrfs_sync_file+0x16a/0x198 [btrfs]
 [<ffffffff81122806>] ? mntput+0x21/0x23
 [<ffffffff8112d150>] vfs_fsync_range+0x18/0x21
 [<ffffffff8112d170>] vfs_fsync+0x17/0x19
 [<ffffffff8112d316>] do_fsync+0x29/0x3e
 [<ffffffff8112d348>] sys_fsync+0xb/0xf
 [<ffffffff81468352>] system_call_fastpath+0x16/0x1b

Sometimes it causes BUG_ON() in the reservation code of the delayed inode
is triggered.

So we must reserve enough space for inode cache.

Note: If we can not reserve the enough space for inode cache, we will
give up writing out it.

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
(cherry picked from commit ba38eb4de354d228f2792f93cde2c748a3a3f3b2)

13 years agoBtrfs: fix nocow when deleting the item
Miao Xie [Fri, 11 Nov 2011 01:45:04 +0000 (20:45 -0500)]
Btrfs: fix nocow when deleting the item

btrfs_previous_item() just search the b+ tree, do not COW the nodes or leaves,
if we modify the result of it, the meta-data will be broken. fix it.

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
(cherry picked from commit 924cd8fbe41851eda2b68bf2ed501b2777fd77b4)

13 years agoBtrfs: tweak the delayed inode reservations again
Chris Mason [Fri, 11 Nov 2011 01:39:08 +0000 (20:39 -0500)]
Btrfs: tweak the delayed inode reservations again

Josef sent along an incremental to the inode reservation
code to make sure we try and fall back to directly updating
the inode item if things go horribly wrong.

This reworks that patch slightly, adding a fallback function
that will always try to update the inode item directly without
going through the delayed_inode code.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
(cherry picked from commit 2115133f8b9a8dbdb217d14080814df07ce90479)

13 years agoBtrfs: rework error handling in btrfs_mount()
Ilya Dryomov [Wed, 9 Nov 2011 12:41:22 +0000 (14:41 +0200)]
Btrfs: rework error handling in btrfs_mount()

Commits 6c41761f and 45ea6095 introduced the possibility of NULL pointer
dereference on error paths, also we would leave all devices busy and
leak fs_info with all sub-structures on error when trying to mount an
already mounted fs to a different directory.

Fix this by doing all allocations before trying to open any of the
devices, adjust error path for mount-already-mounted-fs case.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
(cherry picked from commit 04d21a244fdf79d0ac892eaaa9a46b682467277c)

13 years agoBtrfs: close devices on all error paths in open_ctree()
Ilya Dryomov [Wed, 9 Nov 2011 11:26:37 +0000 (13:26 +0200)]
Btrfs: close devices on all error paths in open_ctree()

Fix a bug introduced by 7e662854 where we would leave devices busy on
certain error paths in open_ctree().  fs_info is guaranteed to be
non-NULL now so it's safe to dereference it on all error paths.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
(cherry picked from commit 586e46e2813c589d26258a599580421fb6fb576b)

13 years agoBtrfs: avoid null dereference and leaks when bailing from open_ctree()
Ilya Dryomov [Tue, 8 Nov 2011 22:08:15 +0000 (00:08 +0200)]
Btrfs: avoid null dereference and leaks when bailing from open_ctree()

Fix bugs introduced by 6c41761f.  Firstly, after failing to allocate any
of the tree roots (first 'goto fail' in open_ctree()) we would
dereference a NULL fs_info pointer in free_fs_info().  Secondly, after
failures from init_srcu_struct(), setup_bdi() and new_inode() we would
leak all earlier allocated roots: fs_info fields haven't been
initialized yet so free_fs_info() is rendered useless.

Fix this by initializing fs_info pointer and fs_info fields before any
allocations happen.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
(cherry picked from commit 4d34b2789538befa45a68a191dc12e0886a69f7d)

13 years agoBtrfs: fix subvol_name leak on error in btrfs_mount()
Ilya Dryomov [Tue, 8 Nov 2011 17:15:05 +0000 (19:15 +0200)]
Btrfs: fix subvol_name leak on error in btrfs_mount()

btrfs_parse_early_options() can fail due to error while scanning devices
(-o device= option), but still strdup() subvol_name string:

mount -o subvol=SUBV,device=BAD_DEVICE <dev> <mnt>

So free subvol_name string on error.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
(cherry picked from commit f23c8af8ca2789eeb0ab9ea90c214f9694d96cc5)

13 years agoBtrfs: fix memory leak in btrfs_parse_early_options()
Ilya Dryomov [Tue, 8 Nov 2011 14:47:55 +0000 (16:47 +0200)]
Btrfs: fix memory leak in btrfs_parse_early_options()

Don't leak subvol_name string in case multiple subvol= options are
given.  "The lastest option is effective" behavior (consistent with
subvolid= and subvolrootid= options) is preserved.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
(cherry picked from commit a90e8b6fb80db43b029e1e76205452afa8bdc77a)

13 years agoBtrfs: fix our reservations for updating an inode when completing io
Josef Bacik [Tue, 8 Nov 2011 20:47:34 +0000 (15:47 -0500)]
Btrfs: fix our reservations for updating an inode when completing io

People have been reporting ENOSPC crashes in finish_ordered_io.  This is because
we try to steal from the delalloc block rsv to satisfy a reservation to update
the inode.  The problem with this is we don't explicitly save space for updating
the inode when doing delalloc.  This is kind of a problem and we've gotten away
with this because way back when we just stole from the delalloc reserve without
any questions, and this worked out fine because generally speaking the leaf had
been modified either by the mtime update when we did the original write or
because we just updated the leaf when we inserted the file extent item, only on
rare occasions had the leaf not actually been modified, and that was still ok
because we'd just use a block or two out of the over-reservation that is
delalloc.

Then came the delayed inode stuff.  This is amazing, except it wants a full
reservation for updating the inode since it may do it at some point down the
road after we've written the blocks and we have to recow everything again.  This
worked out because the delayed inode stuff just stole from the global reserve,
that is until recently when I changed that because it caused other problems.

So here we are, we're doing everything right and being screwed for it.  So take
an extra reservation for the inode at delalloc reservation time and carry it
through the life of the delalloc reservation.  If we need it we can steal it in
the delayed inode stuff.  If we have already stolen it try and do a normal
metadata reservation.  If that fails try to steal from the delalloc reservation.
If _that_ fails we'll get a WARN_ON() so I can start thinking of a better way to
solve this and in the meantime we'll steal from the global reserve.

With this patch I ran xfstests 13 in a loop for a couple of hours and didn't see
any problems.

Signed-off-by: Josef Bacik <josef@redhat.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
(cherry picked from commit 7fd2ae21a42d178982679b86086661292b4afe4a)

13 years agoBtrfs: fix oops on NULL trans handle in btrfs_truncate
Chris Mason [Tue, 8 Nov 2011 19:49:59 +0000 (14:49 -0500)]
Btrfs: fix oops on NULL trans handle in btrfs_truncate

If we fail to reserve space in the transaction during truncate, we can
error out with a NULL trans handle.  The cleanup code needs an extra
check to make sure we aren't trying to use the bad handle.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
(cherry picked from commit 917c16b2b69fc2eeb432eabca73258f08c58361e)

13 years agobtrfs: fix double-free 'tree_root' in 'btrfs_mount()'
slyich@gmail.com [Mon, 7 Nov 2011 21:08:01 +0000 (16:08 -0500)]
btrfs: fix double-free 'tree_root' in 'btrfs_mount()'

On error path 'tree_root' is treed in 'free_fs_info()'.
No need to free it explicitely. Noticed by SLUB in debug mode:

Complete reproducer under usermode linux (discovered on real
machine):

    bdev=/dev/ubda
    btr_root=/btr
    /mkfs.btrfs $bdev
    mount $bdev $btr_root
    mkdir $btr_root/subvols/
    cd $btr_root/subvols/
    /btrfs su cr foo
    /btrfs su cr bar
    mount $bdev -osubvol=subvols/foo $btr_root/subvols/bar
    umount $btr_root/subvols/bar

which gives

device fsid 4d55aa28-45b1-474b-b4ec-da912322195e devid 1 transid 7 /dev/ubda
=============================================================================
BUG kmalloc-2048: Object already free
-----------------------------------------------------------------------------

INFO: Allocated in btrfs_mount+0x389/0x7f0 age=0 cpu=0 pid=277
INFO: Freed in btrfs_mount+0x51c/0x7f0 age=0 cpu=0 pid=277
INFO: Slab 0x0000000062886200 objects=15 used=9 fp=0x0000000070b4d2d0 flags=0x4081
INFO: Object 0x0000000070b4d2d0 @offset=21200 fp=0x0000000070b4a968
...
Call Trace:
70b31948:  [<6008c522>] print_trailer+0xe2/0x130
70b31978:  [<6008c5aa>] object_err+0x3a/0x50
70b319a8:  [<6008e242>] free_debug_processing+0x142/0x2a0
70b319e0:  [<600ebf6f>] btrfs_mount+0x55f/0x7f0
70b319f8:  [<6008e5c1>] __slab_free+0x221/0x2d0

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Cc: Arne Jansen <sensille@gmx.net>
Cc: Chris Mason <chris.mason@oracle.com>
Cc: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
(cherry picked from commit 45ea6095c8f0d6caad5658306416a5d254f1205e)

13 years agoBtrfs: check for a null fs root when writing to the backup root log
Chris Mason [Sun, 6 Nov 2011 23:50:56 +0000 (18:50 -0500)]
Btrfs: check for a null fs root when writing to the backup root log

During log replay, can commit the transaction before the fs_root
pointers are setup, so we have to make sure they are not null before
trying to use them.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
(cherry picked from commit 7c7e82a77fe3d89ae50824aa7c897454675eb4c4)

13 years agoBtrfs: fix race during transaction joins
Chris Mason [Sun, 6 Nov 2011 08:26:19 +0000 (03:26 -0500)]
Btrfs: fix race during transaction joins

While we're allocating ram for a new transaction, we drop our spinlock.
When we get the lock back, we do check to see if a transaction started
while we slept, but we don't check to make sure it isn't blocked
because a commit has already started.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
(cherry picked from commit d43317dcd074818d4bd12ddd4184a29aff98907b)

13 years agoBtrfs: fix a potential btrfs_bio leak on scrub fixups
Ilya Dryomov [Fri, 4 Nov 2011 13:41:02 +0000 (09:41 -0400)]
Btrfs: fix a potential btrfs_bio leak on scrub fixups

In case we were able to map less than we wanted (length < PAGE_SIZE
clause is true) btrfs_bio is still allocated and we have to free it.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
(cherry picked from commit 56d2a48f81a1bde827c625b90221fade72fe9c61)

13 years agoBtrfs: rename btrfs_bio multi -> bbio for consistency
Ilya Dryomov [Fri, 4 Nov 2011 13:41:02 +0000 (09:41 -0400)]
Btrfs: rename btrfs_bio multi -> bbio for consistency

Signed-off-by: Chris Mason <chris.mason@oracle.com>
(cherry picked from commit 21ca543efc12674fddb22ddf4ea4906427f4e982)

13 years agoBtrfs: stop leaking btrfs_bios on readahead
Ilya Dryomov [Fri, 4 Nov 2011 13:41:02 +0000 (09:41 -0400)]
Btrfs: stop leaking btrfs_bios on readahead

Signed-off-by: Chris Mason <chris.mason@oracle.com>
(cherry picked from commit 9510dc4c62252e96dca44a94948327c76774f25b)

13 years agoBtrfs: fix delayed insertion reservation
Josef Bacik [Fri, 4 Nov 2011 23:56:02 +0000 (19:56 -0400)]
Btrfs: fix delayed insertion reservation

We all keep getting those stupid warnings from use_block_rsv when running
stress.sh, and it's because the delayed insertion stuff is being stupid.  It's
not the delayed insertion stuffs fault, it's all just stupid.  When marking an
inode dirty for oh say updating the time on it, we just do a
btrfs_join_transaction, which doesn't reserve any space.  This is stupid because
we're going to have to have space reserve to make this change, but we do it
because it's fast because chances are we're going to call it over and over again
and it doesn't matter.  Well thanks to the delayed insertion stuff this is
mostly the case, so we do actually need to make this reservation.  So if
trans->bytes_reserved is 0 then try to do a normal reservation.  If not return
ENOSPC which will make the btrfs_dirty_inode start a proper transaction which
will let it do the whole ENOSPC dance and reserve enough space for the delayed
insertion to steal the reservation from the transaction.

The other stupid thing we do is not reserve space for the inode when writing to
the thing.  Usually this is ok since we have to update the time so we'd have
already done all this work before we get to the endio stuff, so it doesn't
matter.  But this is stupid because we could write the data after the
transaction commits where we changed the mtime of the inode so we have to cow
all the way down to the inode anyway.  This used to be masked by the delalloc
reservation stuff, but because we delay the update it doesn't get masked in this
case.  So again the delayed insertion stuff bites us in the ass.  So if our
trans->block_rsv is delalloc, just steal the reservation from the delalloc
reserve.  Hopefully this won't bite us in the ass, but I've said that before.

With this patch stress.sh no longer spits out those stupid warnings (famous last
words).  Thanks,

Signed-off-by: Josef Bacik <josef@redhat.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
(cherry picked from commit c06a0e120a4e381a1c291c1fce3c6155c5791cae)

13 years agoBtrfs: ClearPageError during writepage and clean_tree_block
Chris Mason [Fri, 4 Nov 2011 16:29:37 +0000 (12:29 -0400)]
Btrfs: ClearPageError during writepage and clean_tree_block

Failure testing was tripping up over stale PageError bits in
metadata pages.  If we have an io error on a block, and later on
end up reusing it, nobody ever clears PageError on those pages.

During commit, we'll find PageError and think we had trouble writing
the block, which will lead to aborts and other problems.

This changes clean_tree_block and the btrfs writepage code to
clear the PageError bit.  In both cases we're either completely
done with the page or the page has good stuff and the error bit
is no longer valid.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
(cherry picked from commit bf0da8c183a15656eee63c54f334c3794320872a)

13 years agoBtrfs: be smarter about committing the transaction in reserve_metadata_bytes
Josef Bacik [Fri, 4 Nov 2011 02:54:25 +0000 (22:54 -0400)]
Btrfs: be smarter about committing the transaction in reserve_metadata_bytes

Because of the overcommit stuff I had to make it so that we committed the
transaction all the time in reserve_metadata_bytes in case we had overcommitted
because of delayed items.  This was because previously we had no way of knowing
how much space was reserved for delayed items.  Now that we have the
delayed_block_rsv we can check it to see if committing the transaction would get
us anywhere.  This patch breaks out the committing logic into a helper function
that will check to see if committing the transaction would free enough space for
us to get anything done.  With this patch xfstests 83 goes from taking 445
seconds to taking 28 seconds on my box.  Thanks,

Signed-off-by: Josef Bacik <josef@redhat.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
(cherry picked from commit 663350ac38c67ca388acea6e876dc6d668c232b0)

13 years agoBtrfs: make a delayed_block_rsv for the delayed item insertion
Josef Bacik [Fri, 4 Nov 2011 02:54:25 +0000 (22:54 -0400)]
Btrfs: make a delayed_block_rsv for the delayed item insertion

I've been hitting warnings in use_block_rsv when running the delayed insertion
stuff.  It's because we will readjust global block rsv based on what is in use,
which means we could end up discarding reservations that are for the delayed
insertion stuff.  So instead create a seperate block rsv for the delayed
insertion stuff.  This will also make it easier to debug problems with the
delayed insertion reservations since we will know that only the delayed
insertion code touches this block_rsv.  Thanks,

Signed-off-by: Josef Bacik <josef@redhat.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
(cherry picked from commit 6d668dda0caec537fbf28c4d91e6d18181af3cff)

13 years agoBtrfs: add a log of past tree roots
Chris Mason [Thu, 3 Nov 2011 19:17:42 +0000 (15:17 -0400)]
Btrfs: add a log of past tree roots

This takes some of the free space in the btrfs super block
to record information about most of the roots in the last four
commits.

It also adds a -o recovery to use the root history log when
we're not able to read the tree of tree roots, the extent
tree root, the device tree root or the csum root.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
(cherry picked from commit af31f5e5b84b5bf2bcec464153a5130b170b2770 with conflicts)

13 years agobtrfs: separate superblock items out of fs_info
David Sterba [Wed, 13 Apr 2011 13:41:04 +0000 (15:41 +0200)]
btrfs: separate superblock items out of fs_info

fs_info has now ~9kb, more than fits into one page. This will cause
mount failure when memory is too fragmented. Top space consumers are
super block structures super_copy and super_for_commit, ~2.8kb each.
Allocate them dynamically. fs_info will be ~3.5kb. (measured on x86_64)

Add a wrapper for freeing fs_info and all of it's dynamically allocated
members.

Signed-off-by: David Sterba <dsterba@suse.cz>
(cherry picked from commit 6c41761fc6efe1503103a1afe03a6635c0b5d4ec)

13 years agoBtrfs: use the global reserve when truncating the free space cache inode
Josef Bacik [Wed, 2 Nov 2011 13:29:35 +0000 (09:29 -0400)]
Btrfs: use the global reserve when truncating the free space cache inode

We no longer use the orphan block rsv for holding the reservation for truncating
the inode, so instead use the global block rsv and check to make sure it has
enough space for us to truncate the space.  Thanks,

Signed-off-by: Josef Bacik <josef@redhat.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
(cherry picked from commit c8174313a8102e874aaa321e2fc4c7c460a87151)

13 years agoBtrfs: release metadata from global reserve if we have to fallback for unlink
Josef Bacik [Tue, 1 Nov 2011 18:32:23 +0000 (14:32 -0400)]
Btrfs: release metadata from global reserve if we have to fallback for unlink

I fixed a problem where we weren't reserving space for an orphan item when we
had to fallback to using the global reserve for an unlink, but I introduced
another problem.  I was migrating the bytes from the transaction reserve to the
global reserve and then releasing from the global reserve in
btrfs_end_transaction().  The problem with this is that a migrate will jack up
the size for the destination, but leave the size alone for the source, with the
idea that you can do a release normally on the source and it all washes out, and
then you can do a release again on the destination and it works out right.  My
way was skipping the release on the trans_block_rsv which still had the jacked
up size from our original reservation.  So instead release manually from the
global reserve if this transaction was using it, and then set the
trans->block_rsv back to the trans_block_rsv so that btrfs_end_transaction
cleans everything up properly.  With this patch xfstest 83 doesn't emit warnings
about leaking space.  Thanks,

Signed-off-by: Josef Bacik <josef@redhat.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
(cherry picked from commit 5a77d76c243be18d854aa1b14d697525f60e169a)