diff options
221 files changed, 12561 insertions, 4568 deletions
diff --git a/Documentation/ABI/testing/sysfs-bus-pci-devices-cciss b/Documentation/ABI/testing/sysfs-bus-pci-devices-cciss index 4f29e5f1ebf..f5bb0a3bb8c 100644 --- a/Documentation/ABI/testing/sysfs-bus-pci-devices-cciss +++ b/Documentation/ABI/testing/sysfs-bus-pci-devices-cciss | |||
| @@ -59,3 +59,15 @@ Kernel Version: 2.6.31 | |||
| 59 | Contact: iss_storagedev@hp.com | 59 | Contact: iss_storagedev@hp.com |
| 60 | Description: Displays the usage count (number of opens) of logical drive Y | 60 | Description: Displays the usage count (number of opens) of logical drive Y |
| 61 | of controller X. | 61 | of controller X. |
| 62 | |||
| 63 | Where: /sys/bus/pci/devices/<dev>/ccissX/resettable | ||
| 64 | Date: February 2011 | ||
| 65 | Kernel Version: 2.6.38 | ||
| 66 | Contact: iss_storagedev@hp.com | ||
| 67 | Description: Value of 1 indicates the controller can honor the reset_devices | ||
| 68 | kernel parameter. Value of 0 indicates reset_devices cannot be | ||
| 69 | honored. This is to allow, for example, kexec tools to be able | ||
| 70 | to warn the user if they designate an unresettable device as | ||
| 71 | a dump device, as kdump requires resetting the device in order | ||
| 72 | to work reliably. | ||
| 73 | |||
diff --git a/Documentation/DocBook/Makefile b/Documentation/DocBook/Makefile index 2deb069aedf..8436b018c28 100644 --- a/Documentation/DocBook/Makefile +++ b/Documentation/DocBook/Makefile | |||
| @@ -55,7 +55,6 @@ mandocs: $(MAN) | |||
| 55 | build_images = mkdir -p $(objtree)/Documentation/DocBook/media/ && \ | 55 | build_images = mkdir -p $(objtree)/Documentation/DocBook/media/ && \ |
| 56 | cp $(srctree)/Documentation/DocBook/dvb/*.png \ | 56 | cp $(srctree)/Documentation/DocBook/dvb/*.png \ |
| 57 | $(srctree)/Documentation/DocBook/v4l/*.gif \ | 57 | $(srctree)/Documentation/DocBook/v4l/*.gif \ |
| 58 | $(srctree)/Documentation/DocBook/v4l/*.png \ | ||
| 59 | $(objtree)/Documentation/DocBook/media/ | 58 | $(objtree)/Documentation/DocBook/media/ |
| 60 | 59 | ||
| 61 | xmldoclinks: | 60 | xmldoclinks: |
diff --git a/Documentation/DocBook/rapidio.tmpl b/Documentation/DocBook/rapidio.tmpl index 54eb26b5737..50479360d84 100644 --- a/Documentation/DocBook/rapidio.tmpl +++ b/Documentation/DocBook/rapidio.tmpl | |||
| @@ -133,7 +133,6 @@ | |||
| 133 | !Idrivers/rapidio/rio-sysfs.c | 133 | !Idrivers/rapidio/rio-sysfs.c |
| 134 | </sect1> | 134 | </sect1> |
| 135 | <sect1 id="PPC32_support"><title>PPC32 support</title> | 135 | <sect1 id="PPC32_support"><title>PPC32 support</title> |
| 136 | !Earch/powerpc/sysdev/fsl_rio.c | ||
| 137 | !Iarch/powerpc/sysdev/fsl_rio.c | 136 | !Iarch/powerpc/sysdev/fsl_rio.c |
| 138 | </sect1> | 137 | </sect1> |
| 139 | </chapter> | 138 | </chapter> |
diff --git a/Documentation/development-process/1.Intro b/Documentation/development-process/1.Intro index 8cc2cba2b10..9b614480aa8 100644 --- a/Documentation/development-process/1.Intro +++ b/Documentation/development-process/1.Intro | |||
| @@ -56,13 +56,13 @@ information on kernel development. | |||
| 56 | 56 | ||
| 57 | 1.2: WHAT THIS DOCUMENT IS ABOUT | 57 | 1.2: WHAT THIS DOCUMENT IS ABOUT |
| 58 | 58 | ||
| 59 | The Linux kernel, at over 6 million lines of code and well over 1000 active | 59 | The Linux kernel, at over 8 million lines of code and well over 1000 |
| 60 | contributors, is one of the largest and most active free software projects | 60 | contributors to each release, is one of the largest and most active free |
| 61 | in existence. Since its humble beginning in 1991, this kernel has evolved | 61 | software projects in existence. Since its humble beginning in 1991, this |
| 62 | into a best-of-breed operating system component which runs on pocket-sized | 62 | kernel has evolved into a best-of-breed operating system component which |
| 63 | digital music players, desktop PCs, the largest supercomputers in | 63 | runs on pocket-sized digital music players, desktop PCs, the largest |
| 64 | existence, and all types of systems in between. It is a robust, efficient, | 64 | supercomputers in existence, and all types of systems in between. It is a |
| 65 | and scalable solution for almost any situation. | 65 | robust, efficient, and scalable solution for almost any situation. |
| 66 | 66 | ||
| 67 | With the growth of Linux has come an increase in the number of developers | 67 | With the growth of Linux has come an increase in the number of developers |
| 68 | (and companies) wishing to participate in its development. Hardware | 68 | (and companies) wishing to participate in its development. Hardware |
| @@ -115,7 +115,7 @@ This document was written by Jonathan Corbet, corbet@lwn.net. It has been | |||
| 115 | improved by comments from Johannes Berg, James Berry, Alex Chiang, Roland | 115 | improved by comments from Johannes Berg, James Berry, Alex Chiang, Roland |
| 116 | Dreier, Randy Dunlap, Jake Edge, Jiri Kosina, Matt Mackall, Arthur Marsh, | 116 | Dreier, Randy Dunlap, Jake Edge, Jiri Kosina, Matt Mackall, Arthur Marsh, |
| 117 | Amanda McPherson, Andrew Morton, Andrew Price, Tsugikazu Shibata, and | 117 | Amanda McPherson, Andrew Morton, Andrew Price, Tsugikazu Shibata, and |
| 118 | Jochen Voß. | 118 | Jochen Voß. |
| 119 | 119 | ||
| 120 | This work was supported by the Linux Foundation; thanks especially to | 120 | This work was supported by the Linux Foundation; thanks especially to |
| 121 | Amanda McPherson, who saw the value of this effort and made it all happen. | 121 | Amanda McPherson, who saw the value of this effort and made it all happen. |
| @@ -221,7 +221,7 @@ include: | |||
| 221 | - Everything that was said above about code review applies doubly to | 221 | - Everything that was said above about code review applies doubly to |
| 222 | closed-source code. Since this code is not available at all, it cannot | 222 | closed-source code. Since this code is not available at all, it cannot |
| 223 | have been reviewed by the community and will, beyond doubt, have serious | 223 | have been reviewed by the community and will, beyond doubt, have serious |
| 224 | problems. | 224 | problems. |
| 225 | 225 | ||
| 226 | Makers of embedded systems, in particular, may be tempted to disregard much | 226 | Makers of embedded systems, in particular, may be tempted to disregard much |
| 227 | of what has been said in this section in the belief that they are shipping | 227 | of what has been said in this section in the belief that they are shipping |
diff --git a/Documentation/development-process/2.Process b/Documentation/development-process/2.Process index 911a4518634..4823577c650 100644 --- a/Documentation/development-process/2.Process +++ b/Documentation/development-process/2.Process | |||
| @@ -14,16 +14,15 @@ The kernel developers use a loosely time-based release process, with a new | |||
| 14 | major kernel release happening every two or three months. The recent | 14 | major kernel release happening every two or three months. The recent |
| 15 | release history looks like this: | 15 | release history looks like this: |
| 16 | 16 | ||
| 17 | 2.6.26 July 13, 2008 | 17 | 2.6.38 March 14, 2011 |
| 18 | 2.6.25 April 16, 2008 | 18 | 2.6.37 January 4, 2011 |
| 19 | 2.6.24 January 24, 2008 | 19 | 2.6.36 October 20, 2010 |
| 20 | 2.6.23 October 9, 2007 | 20 | 2.6.35 August 1, 2010 |
| 21 | 2.6.22 July 8, 2007 | 21 | 2.6.34 May 15, 2010 |
| 22 | 2.6.21 April 25, 2007 | 22 | 2.6.33 February 24, 2010 |
| 23 | 2.6.20 February 4, 2007 | ||
| 24 | 23 | ||
| 25 | Every 2.6.x release is a major kernel release with new features, internal | 24 | Every 2.6.x release is a major kernel release with new features, internal |
| 26 | API changes, and more. A typical 2.6 release can contain over 10,000 | 25 | API changes, and more. A typical 2.6 release can contain nearly 10,000 |
| 27 | changesets with changes to several hundred thousand lines of code. 2.6 is | 26 | changesets with changes to several hundred thousand lines of code. 2.6 is |
| 28 | thus the leading edge of Linux kernel development; the kernel uses a | 27 | thus the leading edge of Linux kernel development; the kernel uses a |
| 29 | rolling development model which is continually integrating major changes. | 28 | rolling development model which is continually integrating major changes. |
| @@ -42,13 +41,13 @@ merge window do not come out of thin air; they have been collected, tested, | |||
| 42 | and staged ahead of time. How that process works will be described in | 41 | and staged ahead of time. How that process works will be described in |
| 43 | detail later on). | 42 | detail later on). |
| 44 | 43 | ||
| 45 | The merge window lasts for two weeks. At the end of this time, Linus | 44 | The merge window lasts for approximately two weeks. At the end of this |
| 46 | Torvalds will declare that the window is closed and release the first of | 45 | time, Linus Torvalds will declare that the window is closed and release the |
| 47 | the "rc" kernels. For the kernel which is destined to be 2.6.26, for | 46 | first of the "rc" kernels. For the kernel which is destined to be 2.6.40, |
| 48 | example, the release which happens at the end of the merge window will be | 47 | for example, the release which happens at the end of the merge window will |
| 49 | called 2.6.26-rc1. The -rc1 release is the signal that the time to merge | 48 | be called 2.6.40-rc1. The -rc1 release is the signal that the time to |
| 50 | new features has passed, and that the time to stabilize the next kernel has | 49 | merge new features has passed, and that the time to stabilize the next |
| 51 | begun. | 50 | kernel has begun. |
| 52 | 51 | ||
| 53 | Over the next six to ten weeks, only patches which fix problems should be | 52 | Over the next six to ten weeks, only patches which fix problems should be |
| 54 | submitted to the mainline. On occasion a more significant change will be | 53 | submitted to the mainline. On occasion a more significant change will be |
| @@ -66,20 +65,19 @@ will get up to somewhere between -rc6 and -rc9 before the kernel is | |||
| 66 | considered to be sufficiently stable and the final 2.6.x release is made. | 65 | considered to be sufficiently stable and the final 2.6.x release is made. |
| 67 | At that point the whole process starts over again. | 66 | At that point the whole process starts over again. |
| 68 | 67 | ||
| 69 | As an example, here is how the 2.6.25 development cycle went (all dates in | 68 | As an example, here is how the 2.6.38 development cycle went (all dates in |
| 70 | 2008): | 69 | 2011): |
| 71 | 70 | ||
| 72 | January 24 2.6.24 stable release | 71 | January 4 2.6.37 stable release |
| 73 | February 10 2.6.25-rc1, merge window closes | 72 | January 18 2.6.38-rc1, merge window closes |
| 74 | February 15 2.6.25-rc2 | 73 | January 21 2.6.38-rc2 |
| 75 | February 24 2.6.25-rc3 | 74 | February 1 2.6.38-rc3 |
| 76 | March 4 2.6.25-rc4 | 75 | February 7 2.6.38-rc4 |
| 77 | March 9 2.6.25-rc5 | 76 | February 15 2.6.38-rc5 |
| 78 | March 16 2.6.25-rc6 | 77 | February 21 2.6.38-rc6 |
| 79 | March 25 2.6.25-rc7 | 78 | March 1 2.6.38-rc7 |
| 80 | April 1 2.6.25-rc8 | 79 | March 7 2.6.38-rc8 |
| 81 | April 11 2.6.25-rc9 | 80 | March 14 2.6.38 stable release |
| 82 | April 16 2.6.25 stable release | ||
| 83 | 81 | ||
| 84 | How do the developers decide when to close the development cycle and create | 82 | How do the developers decide when to close the development cycle and create |
| 85 | the stable release? The most significant metric used is the list of | 83 | the stable release? The most significant metric used is the list of |
| @@ -87,7 +85,7 @@ regressions from previous releases. No bugs are welcome, but those which | |||
| 87 | break systems which worked in the past are considered to be especially | 85 | break systems which worked in the past are considered to be especially |
| 88 | serious. For this reason, patches which cause regressions are looked upon | 86 | serious. For this reason, patches which cause regressions are looked upon |
| 89 | unfavorably and are quite likely to be reverted during the stabilization | 87 | unfavorably and are quite likely to be reverted during the stabilization |
| 90 | period. | 88 | period. |
| 91 | 89 | ||
| 92 | The developers' goal is to fix all known regressions before the stable | 90 | The developers' goal is to fix all known regressions before the stable |
| 93 | release is made. In the real world, this kind of perfection is hard to | 91 | release is made. In the real world, this kind of perfection is hard to |
| @@ -99,26 +97,34 @@ kernels go out with a handful of known regressions though, hopefully, none | |||
| 99 | of them are serious. | 97 | of them are serious. |
| 100 | 98 | ||
| 101 | Once a stable release is made, its ongoing maintenance is passed off to the | 99 | Once a stable release is made, its ongoing maintenance is passed off to the |
| 102 | "stable team," currently comprised of Greg Kroah-Hartman and Chris Wright. | 100 | "stable team," currently consisting of Greg Kroah-Hartman. The stable team |
| 103 | The stable team will release occasional updates to the stable release using | 101 | will release occasional updates to the stable release using the 2.6.x.y |
| 104 | the 2.6.x.y numbering scheme. To be considered for an update release, a | 102 | numbering scheme. To be considered for an update release, a patch must (1) |
| 105 | patch must (1) fix a significant bug, and (2) already be merged into the | 103 | fix a significant bug, and (2) already be merged into the mainline for the |
| 106 | mainline for the next development kernel. Continuing our 2.6.25 example, | 104 | next development kernel. Kernels will typically receive stable updates for |
| 107 | the history (as of this writing) is: | 105 | a little more than one development cycle past their initial release. So, |
| 108 | 106 | for example, the 2.6.36 kernel's history looked like: | |
| 109 | May 1 2.6.25.1 | 107 | |
| 110 | May 6 2.6.25.2 | 108 | October 10 2.6.36 stable release |
| 111 | May 9 2.6.25.3 | 109 | November 22 2.6.36.1 |
| 112 | May 15 2.6.25.4 | 110 | December 9 2.6.36.2 |
| 113 | June 7 2.6.25.5 | 111 | January 7 2.6.36.3 |
| 114 | June 9 2.6.25.6 | 112 | February 17 2.6.36.4 |
| 115 | June 16 2.6.25.7 | 113 | |
| 116 | June 21 2.6.25.8 | 114 | 2.6.36.4 was the final stable update for the 2.6.36 release. |
| 117 | June 24 2.6.25.9 | 115 | |
| 118 | 116 | Some kernels are designated "long term" kernels; they will receive support | |
| 119 | Stable updates for a given kernel are made for approximately six months; | 117 | for a longer period. As of this writing, the current long term kernels |
| 120 | after that, the maintenance of stable releases is solely the responsibility | 118 | and their maintainers are: |
| 121 | of the distributors which have shipped that particular kernel. | 119 | |
| 120 | 2.6.27 Willy Tarreau (Deep-frozen stable kernel) | ||
| 121 | 2.6.32 Greg Kroah-Hartman | ||
| 122 | 2.6.35 Andi Kleen (Embedded flag kernel) | ||
| 123 | |||
| 124 | The selection of a kernel for long-term support is purely a matter of a | ||
| 125 | maintainer having the need and the time to maintain that release. There | ||
| 126 | are no known plans for long-term support for any specific upcoming | ||
| 127 | release. | ||
| 122 | 128 | ||
| 123 | 129 | ||
| 124 | 2.2: THE LIFECYCLE OF A PATCH | 130 | 2.2: THE LIFECYCLE OF A PATCH |
| @@ -130,7 +136,7 @@ each patch implements a change which is desirable to have in the mainline. | |||
| 130 | This process can happen quickly for minor fixes, or, in the case of large | 136 | This process can happen quickly for minor fixes, or, in the case of large |
| 131 | and controversial changes, go on for years. Much developer frustration | 137 | and controversial changes, go on for years. Much developer frustration |
| 132 | comes from a lack of understanding of this process or from attempts to | 138 | comes from a lack of understanding of this process or from attempts to |
| 133 | circumvent it. | 139 | circumvent it. |
| 134 | 140 | ||
| 135 | In the hopes of reducing that frustration, this document will describe how | 141 | In the hopes of reducing that frustration, this document will describe how |
| 136 | a patch gets into the kernel. What follows below is an introduction which | 142 | a patch gets into the kernel. What follows below is an introduction which |
| @@ -193,8 +199,8 @@ involved. | |||
| 193 | 2.3: HOW PATCHES GET INTO THE KERNEL | 199 | 2.3: HOW PATCHES GET INTO THE KERNEL |
| 194 | 200 | ||
| 195 | There is exactly one person who can merge patches into the mainline kernel | 201 | There is exactly one person who can merge patches into the mainline kernel |
| 196 | repository: Linus Torvalds. But, of the over 12,000 patches which went | 202 | repository: Linus Torvalds. But, of the over 9,500 patches which went |
| 197 | into the 2.6.25 kernel, only 250 (around 2%) were directly chosen by Linus | 203 | into the 2.6.38 kernel, only 112 (around 1.3%) were directly chosen by Linus |
| 198 | himself. The kernel project has long since grown to a size where no single | 204 | himself. The kernel project has long since grown to a size where no single |
| 199 | developer could possibly inspect and select every patch unassisted. The | 205 | developer could possibly inspect and select every patch unassisted. The |
| 200 | way the kernel developers have addressed this growth is through the use of | 206 | way the kernel developers have addressed this growth is through the use of |
| @@ -229,7 +235,7 @@ first in trees dedicated to network device drivers, wireless networking, | |||
| 229 | etc. This chain of repositories can be arbitrarily long, though it rarely | 235 | etc. This chain of repositories can be arbitrarily long, though it rarely |
| 230 | exceeds two or three links. Since each maintainer in the chain trusts | 236 | exceeds two or three links. Since each maintainer in the chain trusts |
| 231 | those managing lower-level trees, this process is known as the "chain of | 237 | those managing lower-level trees, this process is known as the "chain of |
| 232 | trust." | 238 | trust." |
| 233 | 239 | ||
| 234 | Clearly, in a system like this, getting patches into the kernel depends on | 240 | Clearly, in a system like this, getting patches into the kernel depends on |
| 235 | finding the right maintainer. Sending patches directly to Linus is not | 241 | finding the right maintainer. Sending patches directly to Linus is not |
| @@ -254,7 +260,7 @@ The answer comes in the form of -next trees, where subsystem trees are | |||
| 254 | collected for testing and review. The older of these trees, maintained by | 260 | collected for testing and review. The older of these trees, maintained by |
| 255 | Andrew Morton, is called "-mm" (for memory management, which is how it got | 261 | Andrew Morton, is called "-mm" (for memory management, which is how it got |
| 256 | started). The -mm tree integrates patches from a long list of subsystem | 262 | started). The -mm tree integrates patches from a long list of subsystem |
| 257 | trees; it also has some patches aimed at helping with debugging. | 263 | trees; it also has some patches aimed at helping with debugging. |
| 258 | 264 | ||
| 259 | Beyond that, -mm contains a significant collection of patches which have | 265 | Beyond that, -mm contains a significant collection of patches which have |
| 260 | been selected by Andrew directly. These patches may have been posted on a | 266 | been selected by Andrew directly. These patches may have been posted on a |
| @@ -264,8 +270,8 @@ subsystem tree of last resort; if there is no other obvious path for a | |||
| 264 | patch into the mainline, it is likely to end up in -mm. Miscellaneous | 270 | patch into the mainline, it is likely to end up in -mm. Miscellaneous |
| 265 | patches which accumulate in -mm will eventually either be forwarded on to | 271 | patches which accumulate in -mm will eventually either be forwarded on to |
| 266 | an appropriate subsystem tree or be sent directly to Linus. In a typical | 272 | an appropriate subsystem tree or be sent directly to Linus. In a typical |
| 267 | development cycle, approximately 10% of the patches going into the mainline | 273 | development cycle, approximately 5-10% of the patches going into the |
| 268 | get there via -mm. | 274 | mainline get there via -mm. |
| 269 | 275 | ||
| 270 | The current -mm patch is available in the "mmotm" (-mm of the moment) | 276 | The current -mm patch is available in the "mmotm" (-mm of the moment) |
| 271 | directory at: | 277 | directory at: |
| @@ -275,7 +281,7 @@ directory at: | |||
| 275 | Use of the MMOTM tree is likely to be a frustrating experience, though; | 281 | Use of the MMOTM tree is likely to be a frustrating experience, though; |
| 276 | there is a definite chance that it will not even compile. | 282 | there is a definite chance that it will not even compile. |
| 277 | 283 | ||
| 278 | The other -next tree, started more recently, is linux-next, maintained by | 284 | The primary tree for next-cycle patch merging is linux-next, maintained by |
| 279 | Stephen Rothwell. The linux-next tree is, by design, a snapshot of what | 285 | Stephen Rothwell. The linux-next tree is, by design, a snapshot of what |
| 280 | the mainline is expected to look like after the next merge window closes. | 286 | the mainline is expected to look like after the next merge window closes. |
| 281 | Linux-next trees are announced on the linux-kernel and linux-next mailing | 287 | Linux-next trees are announced on the linux-kernel and linux-next mailing |
| @@ -287,25 +293,14 @@ Some information about linux-next has been gathered at: | |||
| 287 | 293 | ||
| 288 | http://linux.f-seidel.de/linux-next/pmwiki/ | 294 | http://linux.f-seidel.de/linux-next/pmwiki/ |
| 289 | 295 | ||
| 290 | How the linux-next tree will fit into the development process is still | 296 | Linux-next has become an integral part of the kernel development process; |
| 291 | changing. As of this writing, the first full development cycle involving | 297 | all patches merged during a given merge window should really have found |
| 292 | linux-next (2.6.26) is coming to an end; thus far, it has proved to be a | 298 | their way into linux-next some time before the merge window opens. |
| 293 | valuable resource for finding and fixing integration problems before the | 299 | |
| 294 | beginning of the merge window. See http://lwn.net/Articles/287155/ for | ||
| 295 | more information on how linux-next has worked to set up the 2.6.27 merge | ||
| 296 | window. | ||
| 297 | |||
| 298 | Some developers have begun to suggest that linux-next should be used as the | ||
| 299 | target for future development as well. The linux-next tree does tend to be | ||
| 300 | far ahead of the mainline and is more representative of the tree into which | ||
| 301 | any new work will be merged. The downside to this idea is that the | ||
| 302 | volatility of linux-next tends to make it a difficult development target. | ||
| 303 | See http://lwn.net/Articles/289013/ for more information on this topic, and | ||
| 304 | stay tuned; much is still in flux where linux-next is involved. | ||
| 305 | 300 | ||
| 306 | 2.4.1: STAGING TREES | 301 | 2.4.1: STAGING TREES |
| 307 | 302 | ||
| 308 | The kernel source tree now contains the drivers/staging/ directory, where | 303 | The kernel source tree contains the drivers/staging/ directory, where |
| 309 | many sub-directories for drivers or filesystems that are on their way to | 304 | many sub-directories for drivers or filesystems that are on their way to |
| 310 | being added to the kernel tree live. They remain in drivers/staging while | 305 | being added to the kernel tree live. They remain in drivers/staging while |
| 311 | they still need more work; once complete, they can be moved into the | 306 | they still need more work; once complete, they can be moved into the |
| @@ -313,15 +308,23 @@ kernel proper. This is a way to keep track of drivers that aren't | |||
| 313 | up to Linux kernel coding or quality standards, but people may want to use | 308 | up to Linux kernel coding or quality standards, but people may want to use |
| 314 | them and track development. | 309 | them and track development. |
| 315 | 310 | ||
| 316 | Greg Kroah-Hartman currently (as of 2.6.36) maintains the staging tree. | 311 | Greg Kroah-Hartman currently maintains the staging tree. Drivers that |
| 317 | Drivers that still need work are sent to him, with each driver having | 312 | still need work are sent to him, with each driver having its own |
| 318 | its own subdirectory in drivers/staging/. Along with the driver source | 313 | subdirectory in drivers/staging/. Along with the driver source files, a |
| 319 | files, a TODO file should be present in the directory as well. The TODO | 314 | TODO file should be present in the directory as well. The TODO file lists |
| 320 | file lists the pending work that the driver needs for acceptance into | 315 | the pending work that the driver needs for acceptance into the kernel |
| 321 | the kernel proper, as well as a list of people that should be Cc'd for any | 316 | proper, as well as a list of people that should be Cc'd for any patches to |
| 322 | patches to the driver. Staging drivers that don't currently build should | 317 | the driver. Current rules require that drivers contributed to staging |
| 323 | have their config entries depend upon CONFIG_BROKEN. Once they can | 318 | must, at a minimum, compile properly. |
| 324 | be successfully built without outside patches, CONFIG_BROKEN can be removed. | 319 | |
| 320 | Staging can be a relatively easy way to get new drivers into the mainline | ||
| 321 | where, with luck, they will come to the attention of other developers and | ||
| 322 | improve quickly. Entry into staging is not the end of the story, though; | ||
| 323 | code in staging which is not seeing regular progress will eventually be | ||
| 324 | removed. Distributors also tend to be relatively reluctant to enable | ||
| 325 | staging drivers. So staging is, at best, a stop on the way toward becoming | ||
| 326 | a proper mainline driver. | ||
| 327 | |||
| 325 | 328 | ||
| 326 | 2.5: TOOLS | 329 | 2.5: TOOLS |
| 327 | 330 | ||
| @@ -347,11 +350,7 @@ page at: | |||
| 347 | 350 | ||
| 348 | http://git-scm.com/ | 351 | http://git-scm.com/ |
| 349 | 352 | ||
| 350 | That page has pointers to documentation and tutorials. One should be | 353 | That page has pointers to documentation and tutorials. |
| 351 | aware, in particular, of the Kernel Hacker's Guide to git, which has | ||
| 352 | information specific to kernel development: | ||
| 353 | |||
| 354 | http://linux.yyz.us/git-howto.html | ||
| 355 | 354 | ||
| 356 | Among the kernel developers who do not use git, the most popular choice is | 355 | Among the kernel developers who do not use git, the most popular choice is |
| 357 | almost certainly Mercurial: | 356 | almost certainly Mercurial: |
| @@ -408,7 +407,7 @@ There are a few hints which can help with linux-kernel survival: | |||
| 408 | important to filter on both the topic of interest (though note that | 407 | important to filter on both the topic of interest (though note that |
| 409 | long-running conversations can drift away from the original subject | 408 | long-running conversations can drift away from the original subject |
| 410 | without changing the email subject line) and the people who are | 409 | without changing the email subject line) and the people who are |
| 411 | participating. | 410 | participating. |
| 412 | 411 | ||
| 413 | - Do not feed the trolls. If somebody is trying to stir up an angry | 412 | - Do not feed the trolls. If somebody is trying to stir up an angry |
| 414 | response, ignore them. | 413 | response, ignore them. |
diff --git a/Documentation/development-process/3.Early-stage b/Documentation/development-process/3.Early-stage index 307a159a70c..f87ba7b3fba 100644 --- a/Documentation/development-process/3.Early-stage +++ b/Documentation/development-process/3.Early-stage | |||
| @@ -110,8 +110,8 @@ the kernel community's standards. Some examples include: | |||
| 110 | 110 | ||
| 111 | - The AppArmor security module made use of internal virtual filesystem | 111 | - The AppArmor security module made use of internal virtual filesystem |
| 112 | data structures in ways which were considered to be unsafe and | 112 | data structures in ways which were considered to be unsafe and |
| 113 | unreliable. This code has since been significantly reworked, but | 113 | unreliable. This concern (among others) kept AppArmor out of the |
| 114 | remains outside of the mainline. | 114 | mainline for years. |
| 115 | 115 | ||
| 116 | In each of these cases, a great deal of pain and extra work could have been | 116 | In each of these cases, a great deal of pain and extra work could have been |
| 117 | avoided with some early discussion with the kernel developers. | 117 | avoided with some early discussion with the kernel developers. |
| @@ -138,6 +138,19 @@ patches, and who, if anybody, is attaching Signed-off-by lines to those | |||
| 138 | patches. Those are the people who will be best placed to help with a new | 138 | patches. Those are the people who will be best placed to help with a new |
| 139 | development project. | 139 | development project. |
| 140 | 140 | ||
| 141 | The task of finding the right maintainer is sometimes challenging enough | ||
| 142 | that the kernel developers have added a script to ease the process: | ||
| 143 | |||
| 144 | .../scripts/get_maintainer.pl | ||
| 145 | |||
| 146 | This script will return the current maintainer(s) for a given file or | ||
| 147 | directory when given the "-f" option. If passed a patch on the | ||
| 148 | command line, it will list the maintainers who should probably receive | ||
| 149 | copies of the patch. There are a number of options regulating how hard | ||
| 150 | get_maintainer.pl will search for maintainers; please be careful about | ||
| 151 | using the more aggressive options as you may end up including developers | ||
| 152 | who have no real interest in the code you are modifying. | ||
| 153 | |||
| 141 | If all else fails, talking to Andrew Morton can be an effective way to | 154 | If all else fails, talking to Andrew Morton can be an effective way to |
| 142 | track down a maintainer for a specific piece of code. | 155 | track down a maintainer for a specific piece of code. |
| 143 | 156 | ||
| @@ -155,11 +168,15 @@ reaction, but, instead, little or no reaction at all. The sad truth of the | |||
| 155 | matter is (1) kernel developers tend to be busy, (2) there is no shortage | 168 | matter is (1) kernel developers tend to be busy, (2) there is no shortage |
| 156 | of people with grand plans and little code (or even prospect of code) to | 169 | of people with grand plans and little code (or even prospect of code) to |
| 157 | back them up, and (3) nobody is obligated to review or comment on ideas | 170 | back them up, and (3) nobody is obligated to review or comment on ideas |
| 158 | posted by others. If a request-for-comments posting yields little in the | 171 | posted by others. Beyond that, high-level designs often hide problems |
| 159 | way of comments, do not assume that it means there is no interest in the | 172 | which are only reviewed when somebody actually tries to implement those |
| 160 | project. Unfortunately, you also cannot assume that there are no problems | 173 | designs; for that reason, kernel developers would rather see the code. |
| 161 | with your idea. The best thing to do in this situation is to proceed, | 174 | |
| 162 | keeping the community informed as you go. | 175 | If a request-for-comments posting yields little in the way of comments, do |
| 176 | not assume that it means there is no interest in the project. | ||
| 177 | Unfortunately, you also cannot assume that there are no problems with your | ||
| 178 | idea. The best thing to do in this situation is to proceed, keeping the | ||
| 179 | community informed as you go. | ||
| 163 | 180 | ||
| 164 | 181 | ||
| 165 | 3.5: GETTING OFFICIAL BUY-IN | 182 | 3.5: GETTING OFFICIAL BUY-IN |
diff --git a/Documentation/development-process/4.Coding b/Documentation/development-process/4.Coding index 2278693c8ff..f3f1a469443 100644 --- a/Documentation/development-process/4.Coding +++ b/Documentation/development-process/4.Coding | |||
| @@ -131,6 +131,11 @@ classic time/space tradeoff taught in beginning data structures classes | |||
| 131 | often does not apply to contemporary hardware. Space *is* time, in that a | 131 | often does not apply to contemporary hardware. Space *is* time, in that a |
| 132 | larger program will run slower than one which is more compact. | 132 | larger program will run slower than one which is more compact. |
| 133 | 133 | ||
| 134 | More recent compilers take an increasingly active role in deciding whether | ||
| 135 | a given function should actually be inlined or not. So the liberal | ||
| 136 | placement of "inline" keywords may not just be excessive; it could also be | ||
| 137 | irrelevant. | ||
| 138 | |||
| 134 | 139 | ||
| 135 | * Locking | 140 | * Locking |
| 136 | 141 | ||
| @@ -285,6 +290,13 @@ be found at https://sparse.wiki.kernel.org/index.php/Main_Page if your | |||
| 285 | distributor does not package it); it can then be run on the code by adding | 290 | distributor does not package it); it can then be run on the code by adding |
| 286 | "C=1" to your make command. | 291 | "C=1" to your make command. |
| 287 | 292 | ||
| 293 | The "Coccinelle" tool (http://coccinelle.lip6.fr/) is able to find a wide | ||
| 294 | variety of potential coding problems; it can also propose fixes for those | ||
| 295 | problems. Quite a few "semantic patches" for the kernel have been packaged | ||
| 296 | under the scripts/coccinelle directory; running "make coccicheck" will run | ||
| 297 | through those semantic patches and report on any problems found. See | ||
| 298 | Documentation/coccinelle.txt for more information. | ||
| 299 | |||
| 288 | Other kinds of portability errors are best found by compiling your code for | 300 | Other kinds of portability errors are best found by compiling your code for |
| 289 | other architectures. If you do not happen to have an S/390 system or a | 301 | other architectures. If you do not happen to have an S/390 system or a |
| 290 | Blackfin development board handy, you can still perform the compilation | 302 | Blackfin development board handy, you can still perform the compilation |
| @@ -308,7 +320,9 @@ The first piece of documentation for any patch is its associated | |||
| 308 | changelog. Log entries should describe the problem being solved, the form | 320 | changelog. Log entries should describe the problem being solved, the form |
| 309 | of the solution, the people who worked on the patch, any relevant | 321 | of the solution, the people who worked on the patch, any relevant |
| 310 | effects on performance, and anything else that might be needed to | 322 | effects on performance, and anything else that might be needed to |
| 311 | understand the patch. | 323 | understand the patch. Be sure that the changelog says *why* the patch is |
| 324 | worth applying; a surprising number of developers fail to provide that | ||
| 325 | information. | ||
| 312 | 326 | ||
| 313 | Any code which adds a new user-space interface - including new sysfs or | 327 | Any code which adds a new user-space interface - including new sysfs or |
| 314 | /proc files - should include documentation of that interface which enables | 328 | /proc files - should include documentation of that interface which enables |
| @@ -321,7 +335,7 @@ boot-time parameters. Any patch which adds new parameters should add the | |||
| 321 | appropriate entries to this file. | 335 | appropriate entries to this file. |
| 322 | 336 | ||
| 323 | Any new configuration options must be accompanied by help text which | 337 | Any new configuration options must be accompanied by help text which |
| 324 | clearly explains the options and when the user might want to select them. | 338 | clearly explains the options and when the user might want to select them. |
| 325 | 339 | ||
| 326 | Internal API information for many subsystems is documented by way of | 340 | Internal API information for many subsystems is documented by way of |
| 327 | specially-formatted comments; these comments can be extracted and formatted | 341 | specially-formatted comments; these comments can be extracted and formatted |
| @@ -372,7 +386,8 @@ which is broken by the change. For a widely-used function, this duty can | |||
| 372 | lead to literally hundreds or thousands of changes - many of which are | 386 | lead to literally hundreds or thousands of changes - many of which are |
| 373 | likely to conflict with work being done by other developers. Needless to | 387 | likely to conflict with work being done by other developers. Needless to |
| 374 | say, this can be a large job, so it is best to be sure that the | 388 | say, this can be a large job, so it is best to be sure that the |
| 375 | justification is solid. | 389 | justification is solid. Note that the Coccinelle tool can help with |
| 390 | wide-ranging API changes. | ||
| 376 | 391 | ||
| 377 | When making an incompatible API change, one should, whenever possible, | 392 | When making an incompatible API change, one should, whenever possible, |
| 378 | ensure that code which has not been updated is caught by the compiler. | 393 | ensure that code which has not been updated is caught by the compiler. |
diff --git a/Documentation/development-process/5.Posting b/Documentation/development-process/5.Posting index f622c1e9f0f..903a2546f13 100644 --- a/Documentation/development-process/5.Posting +++ b/Documentation/development-process/5.Posting | |||
| @@ -60,12 +60,15 @@ even in the short term. | |||
| 60 | 60 | ||
| 61 | Patches must be prepared against a specific version of the kernel. As a | 61 | Patches must be prepared against a specific version of the kernel. As a |
| 62 | general rule, a patch should be based on the current mainline as found in | 62 | general rule, a patch should be based on the current mainline as found in |
| 63 | Linus's git tree. It may become necessary to make versions against -mm, | 63 | Linus's git tree. When basing on mainline, start with a well-known release |
| 64 | linux-next, or a subsystem tree, though, to facilitate wider testing and | 64 | point - a stable or -rc release - rather than branching off the mainline at |
| 65 | review. Depending on the area of your patch and what is going on | 65 | an arbitrary spot. |
| 66 | elsewhere, basing a patch against these other trees can require a | 66 | |
| 67 | significant amount of work resolving conflicts and dealing with API | 67 | It may become necessary to make versions against -mm, linux-next, or a |
| 68 | changes. | 68 | subsystem tree, though, to facilitate wider testing and review. Depending |
| 69 | on the area of your patch and what is going on elsewhere, basing a patch | ||
| 70 | against these other trees can require a significant amount of work | ||
| 71 | resolving conflicts and dealing with API changes. | ||
| 69 | 72 | ||
| 70 | Only the most simple changes should be formatted as a single patch; | 73 | Only the most simple changes should be formatted as a single patch; |
| 71 | everything else should be made as a logical series of changes. Splitting | 74 | everything else should be made as a logical series of changes. Splitting |
| @@ -100,11 +103,11 @@ rules of thumb, however, which can help considerably: | |||
| 100 | result is a broken kernel, you will make life harder for developers and | 103 | result is a broken kernel, you will make life harder for developers and |
| 101 | users who are engaging in the noble work of tracking down problems. | 104 | users who are engaging in the noble work of tracking down problems. |
| 102 | 105 | ||
| 103 | - Do not overdo it, though. One developer recently posted a set of edits | 106 | - Do not overdo it, though. One developer once posted a set of edits |
| 104 | to a single file as 500 separate patches - an act which did not make him | 107 | to a single file as 500 separate patches - an act which did not make him |
| 105 | the most popular person on the kernel mailing list. A single patch can | 108 | the most popular person on the kernel mailing list. A single patch can |
| 106 | be reasonably large as long as it still contains a single *logical* | 109 | be reasonably large as long as it still contains a single *logical* |
| 107 | change. | 110 | change. |
| 108 | 111 | ||
| 109 | - It can be tempting to add a whole new infrastructure with a series of | 112 | - It can be tempting to add a whole new infrastructure with a series of |
| 110 | patches, but to leave that infrastructure unused until the final patch | 113 | patches, but to leave that infrastructure unused until the final patch |
| @@ -162,7 +165,8 @@ To that end, the summary line should describe the effects of and motivation | |||
| 162 | for the change as well as possible given the one-line constraint. The | 165 | for the change as well as possible given the one-line constraint. The |
| 163 | detailed description can then amplify on those topics and provide any | 166 | detailed description can then amplify on those topics and provide any |
| 164 | needed additional information. If the patch fixes a bug, cite the commit | 167 | needed additional information. If the patch fixes a bug, cite the commit |
| 165 | which introduced the bug if possible. If a problem is associated with | 168 | which introduced the bug if possible (and please provide both the commit ID |
| 169 | and the title when citing commits). If a problem is associated with | ||
| 166 | specific log or compiler output, include that output to help others | 170 | specific log or compiler output, include that output to help others |
| 167 | searching for a solution to the same problem. If the change is meant to | 171 | searching for a solution to the same problem. If the change is meant to |
| 168 | support other changes coming in later patch, say so. If internal APIs are | 172 | support other changes coming in later patch, say so. If internal APIs are |
| @@ -230,7 +234,7 @@ take care of: | |||
| 230 | which have had gratuitous white-space changes or line wrapping performed | 234 | which have had gratuitous white-space changes or line wrapping performed |
| 231 | by the mail client will not apply at the other end, and often will not | 235 | by the mail client will not apply at the other end, and often will not |
| 232 | be examined in any detail. If there is any doubt at all, mail the patch | 236 | be examined in any detail. If there is any doubt at all, mail the patch |
| 233 | to yourself and convince yourself that it shows up intact. | 237 | to yourself and convince yourself that it shows up intact. |
| 234 | 238 | ||
| 235 | Documentation/email-clients.txt has some helpful hints on making | 239 | Documentation/email-clients.txt has some helpful hints on making |
| 236 | specific mail clients work for sending patches. | 240 | specific mail clients work for sending patches. |
| @@ -287,7 +291,7 @@ something like: | |||
| 287 | 291 | ||
| 288 | where "nn" is the ordinal number of the patch, "mm" is the total number of | 292 | where "nn" is the ordinal number of the patch, "mm" is the total number of |
| 289 | patches in the series, and "subsys" is the name of the affected subsystem. | 293 | patches in the series, and "subsys" is the name of the affected subsystem. |
| 290 | Clearly, nn/mm can be omitted for a single, standalone patch. | 294 | Clearly, nn/mm can be omitted for a single, standalone patch. |
| 291 | 295 | ||
| 292 | If you have a significant series of patches, it is customary to send an | 296 | If you have a significant series of patches, it is customary to send an |
| 293 | introductory description as part zero. This convention is not universally | 297 | introductory description as part zero. This convention is not universally |
| @@ -299,5 +303,5 @@ In general, the second and following parts of a multi-part patch should be | |||
| 299 | sent as a reply to the first part so that they all thread together at the | 303 | sent as a reply to the first part so that they all thread together at the |
| 300 | receiving end. Tools like git and quilt have commands to mail out a set of | 304 | receiving end. Tools like git and quilt have commands to mail out a set of |
| 301 | patches with the proper threading. If you have a long series, though, and | 305 | patches with the proper threading. If you have a long series, though, and |
| 302 | are using git, please provide the --no-chain-reply-to option to avoid | 306 | are using git, please stay away from the --chain-reply-to option to avoid |
| 303 | creating exceptionally deep nesting. | 307 | creating exceptionally deep nesting. |
diff --git a/Documentation/development-process/6.Followthrough b/Documentation/development-process/6.Followthrough index a8fba3d83a8..41d324a9420 100644 --- a/Documentation/development-process/6.Followthrough +++ b/Documentation/development-process/6.Followthrough | |||
| @@ -66,6 +66,11 @@ be easy to become blinded by your own solution to a problem to the point | |||
| 66 | that you don't realize that something is fundamentally wrong or, perhaps, | 66 | that you don't realize that something is fundamentally wrong or, perhaps, |
| 67 | you're not even solving the right problem. | 67 | you're not even solving the right problem. |
| 68 | 68 | ||
| 69 | Andrew Morton has suggested that every review comment which does not result | ||
| 70 | in a code change should result in an additional code comment instead; that | ||
| 71 | can help future reviewers avoid the questions which came up the first time | ||
| 72 | around. | ||
| 73 | |||
| 69 | One fatal mistake is to ignore review comments in the hope that they will | 74 | One fatal mistake is to ignore review comments in the hope that they will |
| 70 | go away. They will not go away. If you repost code without having | 75 | go away. They will not go away. If you repost code without having |
| 71 | responded to the comments you got the time before, you're likely to find | 76 | responded to the comments you got the time before, you're likely to find |
| @@ -100,7 +105,7 @@ entry into a subsystem maintainer's tree. How that works varies from one | |||
| 100 | subsystem to the next; each maintainer has his or her own way of doing | 105 | subsystem to the next; each maintainer has his or her own way of doing |
| 101 | things. In particular, there may be more than one tree - one, perhaps, | 106 | things. In particular, there may be more than one tree - one, perhaps, |
| 102 | dedicated to patches planned for the next merge window, and another for | 107 | dedicated to patches planned for the next merge window, and another for |
| 103 | longer-term work. | 108 | longer-term work. |
| 104 | 109 | ||
| 105 | For patches applying to areas for which there is no obvious subsystem tree | 110 | For patches applying to areas for which there is no obvious subsystem tree |
| 106 | (memory management patches, for example), the default tree often ends up | 111 | (memory management patches, for example), the default tree often ends up |
| @@ -109,11 +114,10 @@ through the -mm tree. | |||
| 109 | 114 | ||
| 110 | Inclusion into a subsystem tree can bring a higher level of visibility to a | 115 | Inclusion into a subsystem tree can bring a higher level of visibility to a |
| 111 | patch. Now other developers working with that tree will get the patch by | 116 | patch. Now other developers working with that tree will get the patch by |
| 112 | default. Subsystem trees typically feed into -mm and linux-next as well, | 117 | default. Subsystem trees typically feed linux-next as well, making their |
| 113 | making their contents visible to the development community as a whole. At | 118 | contents visible to the development community as a whole. At this point, |
| 114 | this point, there's a good chance that you will get more comments from a | 119 | there's a good chance that you will get more comments from a new set of |
| 115 | new set of reviewers; these comments need to be answered as in the previous | 120 | reviewers; these comments need to be answered as in the previous round. |
| 116 | round. | ||
| 117 | 121 | ||
| 118 | What may also happen at this point, depending on the nature of your patch, | 122 | What may also happen at this point, depending on the nature of your patch, |
| 119 | is that conflicts with work being done by others turn up. In the worst | 123 | is that conflicts with work being done by others turn up. In the worst |
diff --git a/Documentation/development-process/7.AdvancedTopics b/Documentation/development-process/7.AdvancedTopics index 837179447e1..26dc3fa196e 100644 --- a/Documentation/development-process/7.AdvancedTopics +++ b/Documentation/development-process/7.AdvancedTopics | |||
| @@ -119,7 +119,7 @@ can affect your ability to get trees pulled in the future. Quoting Linus: | |||
| 119 | to trust things *without* then having to go and check every | 119 | to trust things *without* then having to go and check every |
| 120 | individual change by hand. | 120 | individual change by hand. |
| 121 | 121 | ||
| 122 | (http://lwn.net/Articles/224135/). | 122 | (http://lwn.net/Articles/224135/). |
| 123 | 123 | ||
| 124 | To avoid this kind of situation, ensure that all patches within a given | 124 | To avoid this kind of situation, ensure that all patches within a given |
| 125 | branch stick closely to the associated topic; a "driver fixes" branch | 125 | branch stick closely to the associated topic; a "driver fixes" branch |
| @@ -138,7 +138,7 @@ When requesting a pull, be sure to give all the relevant information: where | |||
| 138 | your tree is, what branch to pull, and what changes will result from the | 138 | your tree is, what branch to pull, and what changes will result from the |
| 139 | pull. The git request-pull command can be helpful in this regard; it will | 139 | pull. The git request-pull command can be helpful in this regard; it will |
| 140 | format the request as other developers expect, and will also check to be | 140 | format the request as other developers expect, and will also check to be |
| 141 | sure that you have remembered to push those changes to the public server. | 141 | sure that you have remembered to push those changes to the public server. |
| 142 | 142 | ||
| 143 | 143 | ||
| 144 | 7.2: REVIEWING PATCHES | 144 | 7.2: REVIEWING PATCHES |
diff --git a/Documentation/dynamic-debug-howto.txt b/Documentation/dynamic-debug-howto.txt index e6c4b757025..f959909d715 100644 --- a/Documentation/dynamic-debug-howto.txt +++ b/Documentation/dynamic-debug-howto.txt | |||
| @@ -6,7 +6,7 @@ This document describes how to use the dynamic debug (ddebug) feature. | |||
| 6 | 6 | ||
| 7 | Dynamic debug is designed to allow you to dynamically enable/disable kernel | 7 | Dynamic debug is designed to allow you to dynamically enable/disable kernel |
| 8 | code to obtain additional kernel information. Currently, if | 8 | code to obtain additional kernel information. Currently, if |
| 9 | CONFIG_DYNAMIC_DEBUG is set, then all pr_debug()/dev_debug() calls can be | 9 | CONFIG_DYNAMIC_DEBUG is set, then all pr_debug()/dev_dbg() calls can be |
| 10 | dynamically enabled per-callsite. | 10 | dynamically enabled per-callsite. |
| 11 | 11 | ||
| 12 | Dynamic debug has even more useful features: | 12 | Dynamic debug has even more useful features: |
| @@ -26,7 +26,7 @@ Dynamic debug has even more useful features: | |||
| 26 | Controlling dynamic debug Behaviour | 26 | Controlling dynamic debug Behaviour |
| 27 | =================================== | 27 | =================================== |
| 28 | 28 | ||
| 29 | The behaviour of pr_debug()/dev_debug()s are controlled via writing to a | 29 | The behaviour of pr_debug()/dev_dbg()s are controlled via writing to a |
| 30 | control file in the 'debugfs' filesystem. Thus, you must first mount the debugfs | 30 | control file in the 'debugfs' filesystem. Thus, you must first mount the debugfs |
| 31 | filesystem, in order to make use of this feature. Subsequently, we refer to the | 31 | filesystem, in order to make use of this feature. Subsequently, we refer to the |
| 32 | control file as: <debugfs>/dynamic_debug/control. For example, if you want to | 32 | control file as: <debugfs>/dynamic_debug/control. For example, if you want to |
diff --git a/Documentation/hwmon/f71882fg b/Documentation/hwmon/f71882fg index 4d0bc70f185..df02245d141 100644 --- a/Documentation/hwmon/f71882fg +++ b/Documentation/hwmon/f71882fg | |||
| @@ -2,6 +2,10 @@ Kernel driver f71882fg | |||
| 2 | ====================== | 2 | ====================== |
| 3 | 3 | ||
| 4 | Supported chips: | 4 | Supported chips: |
| 5 | * Fintek F71808E | ||
| 6 | Prefix: 'f71808e' | ||
| 7 | Addresses scanned: none, address read from Super I/O config space | ||
| 8 | Datasheet: Not public | ||
| 5 | * Fintek F71858FG | 9 | * Fintek F71858FG |
| 6 | Prefix: 'f71858fg' | 10 | Prefix: 'f71858fg' |
| 7 | Addresses scanned: none, address read from Super I/O config space | 11 | Addresses scanned: none, address read from Super I/O config space |
| @@ -26,10 +30,25 @@ Supported chips: | |||
| 26 | Prefix: 'f71889ed' | 30 | Prefix: 'f71889ed' |
| 27 | Addresses scanned: none, address read from Super I/O config space | 31 | Addresses scanned: none, address read from Super I/O config space |
| 28 | Datasheet: Should become available on the Fintek website soon | 32 | Datasheet: Should become available on the Fintek website soon |
| 33 | * Fintek F71889A | ||
| 34 | Prefix: 'f71889a' | ||
| 35 | Addresses scanned: none, address read from Super I/O config space | ||
| 36 | Datasheet: Should become available on the Fintek website soon | ||
| 29 | * Fintek F8000 | 37 | * Fintek F8000 |
| 30 | Prefix: 'f8000' | 38 | Prefix: 'f8000' |
| 31 | Addresses scanned: none, address read from Super I/O config space | 39 | Addresses scanned: none, address read from Super I/O config space |
| 32 | Datasheet: Not public | 40 | Datasheet: Not public |
| 41 | * Fintek F81801U | ||
| 42 | Prefix: 'f71889fg' | ||
| 43 | Addresses scanned: none, address read from Super I/O config space | ||
| 44 | Datasheet: Not public | ||
| 45 | Note: This is the 64-pin variant of the F71889FG, they have the | ||
| 46 | same device ID and are fully compatible as far as hardware | ||
| 47 | monitoring is concerned. | ||
| 48 | * Fintek F81865F | ||
| 49 | Prefix: 'f81865f' | ||
| 50 | Addresses scanned: none, address read from Super I/O config space | ||
| 51 | Datasheet: Available from the Fintek website | ||
| 33 | 52 | ||
| 34 | Author: Hans de Goede <hdegoede@redhat.com> | 53 | Author: Hans de Goede <hdegoede@redhat.com> |
| 35 | 54 | ||
diff --git a/MAINTAINERS b/MAINTAINERS index 4fb9017b441..8aa1cacddbc 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
| @@ -548,10 +548,8 @@ S: Maintained | |||
| 548 | F: sound/aoa/ | 548 | F: sound/aoa/ |
| 549 | 549 | ||
| 550 | APM DRIVER | 550 | APM DRIVER |
| 551 | M: Stephen Rothwell <sfr@canb.auug.org.au> | ||
| 552 | L: linux-laptop@vger.kernel.org | 551 | L: linux-laptop@vger.kernel.org |
| 553 | W: http://www.canb.auug.org.au/~sfr/ | 552 | S: Orphan |
| 554 | S: Supported | ||
| 555 | F: arch/x86/kernel/apm_32.c | 553 | F: arch/x86/kernel/apm_32.c |
| 556 | F: include/linux/apm_bios.h | 554 | F: include/linux/apm_bios.h |
| 557 | 555 | ||
| @@ -6633,6 +6631,7 @@ F: drivers/media/video/zr364xx.c | |||
| 6633 | 6631 | ||
| 6634 | USER-MODE LINUX (UML) | 6632 | USER-MODE LINUX (UML) |
| 6635 | M: Jeff Dike <jdike@addtoit.com> | 6633 | M: Jeff Dike <jdike@addtoit.com> |
| 6634 | M: Richard Weinberger <richard@nod.at> | ||
| 6636 | L: user-mode-linux-devel@lists.sourceforge.net | 6635 | L: user-mode-linux-devel@lists.sourceforge.net |
| 6637 | L: user-mode-linux-user@lists.sourceforge.net | 6636 | L: user-mode-linux-user@lists.sourceforge.net |
| 6638 | W: http://user-mode-linux.sourceforge.net | 6637 | W: http://user-mode-linux.sourceforge.net |
diff --git a/arch/arm/mach-omap2/board-omap4panda.c b/arch/arm/mach-omap2/board-omap4panda.c index c936c6d7ded..f3a7b101191 100644 --- a/arch/arm/mach-omap2/board-omap4panda.c +++ b/arch/arm/mach-omap2/board-omap4panda.c | |||
| @@ -285,19 +285,6 @@ static int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers) | |||
| 285 | return 0; | 285 | return 0; |
| 286 | } | 286 | } |
| 287 | 287 | ||
| 288 | static struct regulator_init_data omap4_panda_vaux1 = { | ||
| 289 | .constraints = { | ||
| 290 | .min_uV = 1000000, | ||
| 291 | .max_uV = 3000000, | ||
| 292 | .apply_uV = true, | ||
| 293 | .valid_modes_mask = REGULATOR_MODE_NORMAL | ||
| 294 | | REGULATOR_MODE_STANDBY, | ||
| 295 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | ||
| 296 | | REGULATOR_CHANGE_MODE | ||
| 297 | | REGULATOR_CHANGE_STATUS, | ||
| 298 | }, | ||
| 299 | }; | ||
| 300 | |||
| 301 | static struct regulator_init_data omap4_panda_vaux2 = { | 288 | static struct regulator_init_data omap4_panda_vaux2 = { |
| 302 | .constraints = { | 289 | .constraints = { |
| 303 | .min_uV = 1200000, | 290 | .min_uV = 1200000, |
| @@ -353,19 +340,6 @@ static struct regulator_init_data omap4_panda_vpp = { | |||
| 353 | }, | 340 | }, |
| 354 | }; | 341 | }; |
| 355 | 342 | ||
| 356 | static struct regulator_init_data omap4_panda_vusim = { | ||
| 357 | .constraints = { | ||
| 358 | .min_uV = 1200000, | ||
| 359 | .max_uV = 2900000, | ||
| 360 | .apply_uV = true, | ||
| 361 | .valid_modes_mask = REGULATOR_MODE_NORMAL | ||
| 362 | | REGULATOR_MODE_STANDBY, | ||
| 363 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | ||
| 364 | | REGULATOR_CHANGE_MODE | ||
| 365 | | REGULATOR_CHANGE_STATUS, | ||
| 366 | }, | ||
| 367 | }; | ||
| 368 | |||
| 369 | static struct regulator_init_data omap4_panda_vana = { | 343 | static struct regulator_init_data omap4_panda_vana = { |
| 370 | .constraints = { | 344 | .constraints = { |
| 371 | .min_uV = 2100000, | 345 | .min_uV = 2100000, |
| @@ -424,12 +398,10 @@ static struct twl4030_platform_data omap4_panda_twldata = { | |||
| 424 | /* Regulators */ | 398 | /* Regulators */ |
| 425 | .vmmc = &omap4_panda_vmmc, | 399 | .vmmc = &omap4_panda_vmmc, |
| 426 | .vpp = &omap4_panda_vpp, | 400 | .vpp = &omap4_panda_vpp, |
| 427 | .vusim = &omap4_panda_vusim, | ||
| 428 | .vana = &omap4_panda_vana, | 401 | .vana = &omap4_panda_vana, |
| 429 | .vcxio = &omap4_panda_vcxio, | 402 | .vcxio = &omap4_panda_vcxio, |
| 430 | .vdac = &omap4_panda_vdac, | 403 | .vdac = &omap4_panda_vdac, |
| 431 | .vusb = &omap4_panda_vusb, | 404 | .vusb = &omap4_panda_vusb, |
| 432 | .vaux1 = &omap4_panda_vaux1, | ||
| 433 | .vaux2 = &omap4_panda_vaux2, | 405 | .vaux2 = &omap4_panda_vaux2, |
| 434 | .vaux3 = &omap4_panda_vaux3, | 406 | .vaux3 = &omap4_panda_vaux3, |
| 435 | .clk32kg = &omap4_panda_clk32kg, | 407 | .clk32kg = &omap4_panda_clk32kg, |
diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c index e9785149284..84d1b735fe8 100644 --- a/arch/arm/mach-omap2/devices.c +++ b/arch/arm/mach-omap2/devices.c | |||
| @@ -66,7 +66,7 @@ static int __init omap3_l3_init(void) | |||
| 66 | 66 | ||
| 67 | WARN(IS_ERR(od), "could not build omap_device for %s\n", oh_name); | 67 | WARN(IS_ERR(od), "could not build omap_device for %s\n", oh_name); |
| 68 | 68 | ||
| 69 | return PTR_ERR(od); | 69 | return IS_ERR(od) ? PTR_ERR(od) : 0; |
| 70 | } | 70 | } |
| 71 | postcore_initcall(omap3_l3_init); | 71 | postcore_initcall(omap3_l3_init); |
| 72 | 72 | ||
diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c index 674174365f7..493505c3b2f 100644 --- a/arch/arm/mach-omap2/gpmc.c +++ b/arch/arm/mach-omap2/gpmc.c | |||
| @@ -693,6 +693,7 @@ static int __init gpmc_init(void) | |||
| 693 | { | 693 | { |
| 694 | u32 l, irq; | 694 | u32 l, irq; |
| 695 | int cs, ret = -EINVAL; | 695 | int cs, ret = -EINVAL; |
| 696 | int gpmc_irq; | ||
| 696 | char *ck = NULL; | 697 | char *ck = NULL; |
| 697 | 698 | ||
| 698 | if (cpu_is_omap24xx()) { | 699 | if (cpu_is_omap24xx()) { |
| @@ -701,12 +702,15 @@ static int __init gpmc_init(void) | |||
| 701 | l = OMAP2420_GPMC_BASE; | 702 | l = OMAP2420_GPMC_BASE; |
| 702 | else | 703 | else |
| 703 | l = OMAP34XX_GPMC_BASE; | 704 | l = OMAP34XX_GPMC_BASE; |
| 705 | gpmc_irq = INT_34XX_GPMC_IRQ; | ||
| 704 | } else if (cpu_is_omap34xx()) { | 706 | } else if (cpu_is_omap34xx()) { |
| 705 | ck = "gpmc_fck"; | 707 | ck = "gpmc_fck"; |
| 706 | l = OMAP34XX_GPMC_BASE; | 708 | l = OMAP34XX_GPMC_BASE; |
| 709 | gpmc_irq = INT_34XX_GPMC_IRQ; | ||
| 707 | } else if (cpu_is_omap44xx()) { | 710 | } else if (cpu_is_omap44xx()) { |
| 708 | ck = "gpmc_ck"; | 711 | ck = "gpmc_ck"; |
| 709 | l = OMAP44XX_GPMC_BASE; | 712 | l = OMAP44XX_GPMC_BASE; |
| 713 | gpmc_irq = OMAP44XX_IRQ_GPMC; | ||
| 710 | } | 714 | } |
| 711 | 715 | ||
| 712 | if (WARN_ON(!ck)) | 716 | if (WARN_ON(!ck)) |
| @@ -739,16 +743,17 @@ static int __init gpmc_init(void) | |||
| 739 | /* initalize the irq_chained */ | 743 | /* initalize the irq_chained */ |
| 740 | irq = OMAP_GPMC_IRQ_BASE; | 744 | irq = OMAP_GPMC_IRQ_BASE; |
| 741 | for (cs = 0; cs < GPMC_CS_NUM; cs++) { | 745 | for (cs = 0; cs < GPMC_CS_NUM; cs++) { |
| 742 | set_irq_handler(irq, handle_simple_irq); | 746 | set_irq_chip_and_handler(irq, &dummy_irq_chip, |
| 747 | handle_simple_irq); | ||
| 743 | set_irq_flags(irq, IRQF_VALID); | 748 | set_irq_flags(irq, IRQF_VALID); |
| 744 | irq++; | 749 | irq++; |
| 745 | } | 750 | } |
| 746 | 751 | ||
| 747 | ret = request_irq(INT_34XX_GPMC_IRQ, | 752 | ret = request_irq(gpmc_irq, |
| 748 | gpmc_handle_irq, IRQF_SHARED, "gpmc", gpmc_base); | 753 | gpmc_handle_irq, IRQF_SHARED, "gpmc", gpmc_base); |
| 749 | if (ret) | 754 | if (ret) |
| 750 | pr_err("gpmc: irq-%d could not claim: err %d\n", | 755 | pr_err("gpmc: irq-%d could not claim: err %d\n", |
| 751 | INT_34XX_GPMC_IRQ, ret); | 756 | gpmc_irq, ret); |
| 752 | return ret; | 757 | return ret; |
| 753 | } | 758 | } |
| 754 | postcore_initcall(gpmc_init); | 759 | postcore_initcall(gpmc_init); |
| @@ -757,8 +762,6 @@ static irqreturn_t gpmc_handle_irq(int irq, void *dev) | |||
| 757 | { | 762 | { |
| 758 | u8 cs; | 763 | u8 cs; |
| 759 | 764 | ||
| 760 | if (irq != INT_34XX_GPMC_IRQ) | ||
| 761 | return IRQ_HANDLED; | ||
| 762 | /* check cs to invoke the irq */ | 765 | /* check cs to invoke the irq */ |
| 763 | cs = ((gpmc_read_reg(GPMC_PREFETCH_CONFIG1)) >> CS_NUM_SHIFT) & 0x7; | 766 | cs = ((gpmc_read_reg(GPMC_PREFETCH_CONFIG1)) >> CS_NUM_SHIFT) & 0x7; |
| 764 | if (OMAP_GPMC_IRQ_BASE+cs <= OMAP_GPMC_IRQ_END) | 767 | if (OMAP_GPMC_IRQ_BASE+cs <= OMAP_GPMC_IRQ_END) |
diff --git a/arch/arm/mach-omap2/omap_l3_smx.c b/arch/arm/mach-omap2/omap_l3_smx.c index 265bff3acb9..5f2da7565b6 100644 --- a/arch/arm/mach-omap2/omap_l3_smx.c +++ b/arch/arm/mach-omap2/omap_l3_smx.c | |||
| @@ -226,7 +226,6 @@ static int __init omap3_l3_probe(struct platform_device *pdev) | |||
| 226 | struct omap3_l3 *l3; | 226 | struct omap3_l3 *l3; |
| 227 | struct resource *res; | 227 | struct resource *res; |
| 228 | int ret; | 228 | int ret; |
| 229 | int irq; | ||
| 230 | 229 | ||
| 231 | l3 = kzalloc(sizeof(*l3), GFP_KERNEL); | 230 | l3 = kzalloc(sizeof(*l3), GFP_KERNEL); |
| 232 | if (!l3) { | 231 | if (!l3) { |
| @@ -249,18 +248,17 @@ static int __init omap3_l3_probe(struct platform_device *pdev) | |||
| 249 | goto err2; | 248 | goto err2; |
| 250 | } | 249 | } |
| 251 | 250 | ||
| 252 | irq = platform_get_irq(pdev, 0); | 251 | l3->debug_irq = platform_get_irq(pdev, 0); |
| 253 | ret = request_irq(irq, omap3_l3_app_irq, | 252 | ret = request_irq(l3->debug_irq, omap3_l3_app_irq, |
| 254 | IRQF_DISABLED | IRQF_TRIGGER_RISING, | 253 | IRQF_DISABLED | IRQF_TRIGGER_RISING, |
| 255 | "l3-debug-irq", l3); | 254 | "l3-debug-irq", l3); |
| 256 | if (ret) { | 255 | if (ret) { |
| 257 | dev_err(&pdev->dev, "couldn't request debug irq\n"); | 256 | dev_err(&pdev->dev, "couldn't request debug irq\n"); |
| 258 | goto err3; | 257 | goto err3; |
| 259 | } | 258 | } |
| 260 | l3->debug_irq = irq; | ||
| 261 | 259 | ||
| 262 | irq = platform_get_irq(pdev, 1); | 260 | l3->app_irq = platform_get_irq(pdev, 1); |
| 263 | ret = request_irq(irq, omap3_l3_app_irq, | 261 | ret = request_irq(l3->app_irq, omap3_l3_app_irq, |
| 264 | IRQF_DISABLED | IRQF_TRIGGER_RISING, | 262 | IRQF_DISABLED | IRQF_TRIGGER_RISING, |
| 265 | "l3-app-irq", l3); | 263 | "l3-app-irq", l3); |
| 266 | 264 | ||
| @@ -269,7 +267,6 @@ static int __init omap3_l3_probe(struct platform_device *pdev) | |||
| 269 | goto err4; | 267 | goto err4; |
| 270 | } | 268 | } |
| 271 | 269 | ||
| 272 | l3->app_irq = irq; | ||
| 273 | goto err0; | 270 | goto err0; |
| 274 | 271 | ||
| 275 | err4: | 272 | err4: |
diff --git a/arch/arm/mach-ux500/board-mop500-regulators.h b/arch/arm/mach-ux500/board-mop500-regulators.h index 2675fae5253..f979b892e4f 100644 --- a/arch/arm/mach-ux500/board-mop500-regulators.h +++ b/arch/arm/mach-ux500/board-mop500-regulators.h | |||
| @@ -14,6 +14,8 @@ | |||
| 14 | #include <linux/regulator/machine.h> | 14 | #include <linux/regulator/machine.h> |
| 15 | #include <linux/regulator/ab8500.h> | 15 | #include <linux/regulator/ab8500.h> |
| 16 | 16 | ||
| 17 | extern struct ab8500_regulator_reg_init | ||
| 18 | ab8500_regulator_reg_init[AB8500_NUM_REGULATOR_REGISTERS]; | ||
| 17 | extern struct regulator_init_data ab8500_regulators[AB8500_NUM_REGULATORS]; | 19 | extern struct regulator_init_data ab8500_regulators[AB8500_NUM_REGULATORS]; |
| 18 | 20 | ||
| 19 | #endif | 21 | #endif |
diff --git a/arch/arm/mach-ux500/board-mop500.c b/arch/arm/mach-ux500/board-mop500.c index 8790d984cac..d0076453d7f 100644 --- a/arch/arm/mach-ux500/board-mop500.c +++ b/arch/arm/mach-ux500/board-mop500.c | |||
| @@ -20,6 +20,7 @@ | |||
| 20 | #include <linux/amba/serial.h> | 20 | #include <linux/amba/serial.h> |
| 21 | #include <linux/spi/spi.h> | 21 | #include <linux/spi/spi.h> |
| 22 | #include <linux/mfd/ab8500.h> | 22 | #include <linux/mfd/ab8500.h> |
| 23 | #include <linux/regulator/ab8500.h> | ||
| 23 | #include <linux/mfd/tc3589x.h> | 24 | #include <linux/mfd/tc3589x.h> |
| 24 | #include <linux/leds-lp5521.h> | 25 | #include <linux/leds-lp5521.h> |
| 25 | #include <linux/input.h> | 26 | #include <linux/input.h> |
diff --git a/arch/arm/plat-omap/include/plat/irqs.h b/arch/arm/plat-omap/include/plat/irqs.h index d7792837046..5a25098ea7e 100644 --- a/arch/arm/plat-omap/include/plat/irqs.h +++ b/arch/arm/plat-omap/include/plat/irqs.h | |||
| @@ -416,7 +416,7 @@ | |||
| 416 | 416 | ||
| 417 | /* GPMC related */ | 417 | /* GPMC related */ |
| 418 | #define OMAP_GPMC_IRQ_BASE (TWL_IRQ_END) | 418 | #define OMAP_GPMC_IRQ_BASE (TWL_IRQ_END) |
| 419 | #define OMAP_GPMC_NR_IRQS 7 | 419 | #define OMAP_GPMC_NR_IRQS 8 |
| 420 | #define OMAP_GPMC_IRQ_END (OMAP_GPMC_IRQ_BASE + OMAP_GPMC_NR_IRQS) | 420 | #define OMAP_GPMC_IRQ_END (OMAP_GPMC_IRQ_BASE + OMAP_GPMC_NR_IRQS) |
| 421 | 421 | ||
| 422 | 422 | ||
diff --git a/arch/arm/plat-omap/include/plat/onenand.h b/arch/arm/plat-omap/include/plat/onenand.h index cbe897ca7f9..2858667d2e4 100644 --- a/arch/arm/plat-omap/include/plat/onenand.h +++ b/arch/arm/plat-omap/include/plat/onenand.h | |||
| @@ -32,6 +32,7 @@ struct omap_onenand_platform_data { | |||
| 32 | int dma_channel; | 32 | int dma_channel; |
| 33 | u8 flags; | 33 | u8 flags; |
| 34 | u8 regulator_can_sleep; | 34 | u8 regulator_can_sleep; |
| 35 | u8 skip_initial_unlocking; | ||
| 35 | }; | 36 | }; |
| 36 | 37 | ||
| 37 | #define ONENAND_MAX_PARTITIONS 8 | 38 | #define ONENAND_MAX_PARTITIONS 8 |
diff --git a/arch/arm/plat-pxa/include/plat/pxa3xx_nand.h b/arch/arm/plat-pxa/include/plat/pxa3xx_nand.h index 01a8448e471..442301fe48b 100644 --- a/arch/arm/plat-pxa/include/plat/pxa3xx_nand.h +++ b/arch/arm/plat-pxa/include/plat/pxa3xx_nand.h | |||
| @@ -30,6 +30,7 @@ struct pxa3xx_nand_cmdset { | |||
| 30 | }; | 30 | }; |
| 31 | 31 | ||
| 32 | struct pxa3xx_nand_flash { | 32 | struct pxa3xx_nand_flash { |
| 33 | char *name; | ||
| 33 | uint32_t chip_id; | 34 | uint32_t chip_id; |
| 34 | unsigned int page_per_block; /* Pages per block (PG_PER_BLK) */ | 35 | unsigned int page_per_block; /* Pages per block (PG_PER_BLK) */ |
| 35 | unsigned int page_size; /* Page size in bytes (PAGE_SZ) */ | 36 | unsigned int page_size; /* Page size in bytes (PAGE_SZ) */ |
| @@ -37,7 +38,6 @@ struct pxa3xx_nand_flash { | |||
| 37 | unsigned int dfc_width; /* Width of flash controller(DWIDTH_C) */ | 38 | unsigned int dfc_width; /* Width of flash controller(DWIDTH_C) */ |
| 38 | unsigned int num_blocks; /* Number of physical blocks in Flash */ | 39 | unsigned int num_blocks; /* Number of physical blocks in Flash */ |
| 39 | 40 | ||
| 40 | struct pxa3xx_nand_cmdset *cmdset; /* NAND command set */ | ||
| 41 | struct pxa3xx_nand_timing *timing; /* NAND Flash timing */ | 41 | struct pxa3xx_nand_timing *timing; /* NAND Flash timing */ |
| 42 | }; | 42 | }; |
| 43 | 43 | ||
diff --git a/arch/cris/Kconfig b/arch/cris/Kconfig index 4db5b46e1ef..04a7fc5eaf4 100644 --- a/arch/cris/Kconfig +++ b/arch/cris/Kconfig | |||
| @@ -276,7 +276,6 @@ config ETRAX_AXISFLASHMAP | |||
| 276 | select MTD_CHAR | 276 | select MTD_CHAR |
| 277 | select MTD_BLOCK | 277 | select MTD_BLOCK |
| 278 | select MTD_PARTITIONS | 278 | select MTD_PARTITIONS |
| 279 | select MTD_CONCAT | ||
| 280 | select MTD_COMPLEX_MAPPINGS | 279 | select MTD_COMPLEX_MAPPINGS |
| 281 | help | 280 | help |
| 282 | This option enables MTD mapping of flash devices. Needed to use | 281 | This option enables MTD mapping of flash devices. Needed to use |
diff --git a/arch/cris/arch-v10/drivers/axisflashmap.c b/arch/cris/arch-v10/drivers/axisflashmap.c index b2079703af7..ed708e19d09 100644 --- a/arch/cris/arch-v10/drivers/axisflashmap.c +++ b/arch/cris/arch-v10/drivers/axisflashmap.c | |||
| @@ -234,7 +234,6 @@ static struct mtd_info *flash_probe(void) | |||
| 234 | } | 234 | } |
| 235 | 235 | ||
| 236 | if (mtd_cse0 && mtd_cse1) { | 236 | if (mtd_cse0 && mtd_cse1) { |
| 237 | #ifdef CONFIG_MTD_CONCAT | ||
| 238 | struct mtd_info *mtds[] = { mtd_cse0, mtd_cse1 }; | 237 | struct mtd_info *mtds[] = { mtd_cse0, mtd_cse1 }; |
| 239 | 238 | ||
| 240 | /* Since the concatenation layer adds a small overhead we | 239 | /* Since the concatenation layer adds a small overhead we |
| @@ -246,11 +245,6 @@ static struct mtd_info *flash_probe(void) | |||
| 246 | */ | 245 | */ |
| 247 | mtd_cse = mtd_concat_create(mtds, ARRAY_SIZE(mtds), | 246 | mtd_cse = mtd_concat_create(mtds, ARRAY_SIZE(mtds), |
| 248 | "cse0+cse1"); | 247 | "cse0+cse1"); |
| 249 | #else | ||
| 250 | printk(KERN_ERR "%s and %s: Cannot concatenate due to kernel " | ||
| 251 | "(mis)configuration!\n", map_cse0.name, map_cse1.name); | ||
| 252 | mtd_cse = NULL; | ||
| 253 | #endif | ||
| 254 | if (!mtd_cse) { | 248 | if (!mtd_cse) { |
| 255 | printk(KERN_ERR "%s and %s: Concatenation failed!\n", | 249 | printk(KERN_ERR "%s and %s: Concatenation failed!\n", |
| 256 | map_cse0.name, map_cse1.name); | 250 | map_cse0.name, map_cse1.name); |
diff --git a/arch/cris/arch-v32/drivers/Kconfig b/arch/cris/arch-v32/drivers/Kconfig index a2dd740c590..1633b120aa8 100644 --- a/arch/cris/arch-v32/drivers/Kconfig +++ b/arch/cris/arch-v32/drivers/Kconfig | |||
| @@ -406,7 +406,6 @@ config ETRAX_AXISFLASHMAP | |||
| 406 | select MTD_CHAR | 406 | select MTD_CHAR |
| 407 | select MTD_BLOCK | 407 | select MTD_BLOCK |
| 408 | select MTD_PARTITIONS | 408 | select MTD_PARTITIONS |
| 409 | select MTD_CONCAT | ||
| 410 | select MTD_COMPLEX_MAPPINGS | 409 | select MTD_COMPLEX_MAPPINGS |
| 411 | help | 410 | help |
| 412 | This option enables MTD mapping of flash devices. Needed to use | 411 | This option enables MTD mapping of flash devices. Needed to use |
diff --git a/arch/cris/arch-v32/drivers/axisflashmap.c b/arch/cris/arch-v32/drivers/axisflashmap.c index 51e1e85df96..3d751250271 100644 --- a/arch/cris/arch-v32/drivers/axisflashmap.c +++ b/arch/cris/arch-v32/drivers/axisflashmap.c | |||
| @@ -275,7 +275,6 @@ static struct mtd_info *flash_probe(void) | |||
| 275 | } | 275 | } |
| 276 | 276 | ||
| 277 | if (count > 1) { | 277 | if (count > 1) { |
| 278 | #ifdef CONFIG_MTD_CONCAT | ||
| 279 | /* Since the concatenation layer adds a small overhead we | 278 | /* Since the concatenation layer adds a small overhead we |
| 280 | * could try to figure out if the chips in cse0 and cse1 are | 279 | * could try to figure out if the chips in cse0 and cse1 are |
| 281 | * identical and reprobe the whole cse0+cse1 window. But since | 280 | * identical and reprobe the whole cse0+cse1 window. But since |
| @@ -284,11 +283,6 @@ static struct mtd_info *flash_probe(void) | |||
| 284 | * complicating the probing procedure. | 283 | * complicating the probing procedure. |
| 285 | */ | 284 | */ |
| 286 | mtd_total = mtd_concat_create(mtds, count, "cse0+cse1"); | 285 | mtd_total = mtd_concat_create(mtds, count, "cse0+cse1"); |
| 287 | #else | ||
| 288 | printk(KERN_ERR "%s and %s: Cannot concatenate due to kernel " | ||
| 289 | "(mis)configuration!\n", map_cse0.name, map_cse1.name); | ||
| 290 | mtd_toal = NULL; | ||
| 291 | #endif | ||
| 292 | if (!mtd_total) { | 286 | if (!mtd_total) { |
| 293 | printk(KERN_ERR "%s and %s: Concatenation failed!\n", | 287 | printk(KERN_ERR "%s and %s: Concatenation failed!\n", |
| 294 | map_cse0.name, map_cse1.name); | 288 | map_cse0.name, map_cse1.name); |
diff --git a/arch/score/Kconfig b/arch/score/Kconfig index 27b2295f41f..4278bbc032c 100644 --- a/arch/score/Kconfig +++ b/arch/score/Kconfig | |||
| @@ -3,6 +3,8 @@ menu "Machine selection" | |||
| 3 | config SCORE | 3 | config SCORE |
| 4 | def_bool y | 4 | def_bool y |
| 5 | select HAVE_GENERIC_HARDIRQS | 5 | select HAVE_GENERIC_HARDIRQS |
| 6 | select GENERIC_HARDIRQS_NO_DEPRECATED | ||
| 7 | select GENERIC_IRQ_SHOW | ||
| 6 | 8 | ||
| 7 | choice | 9 | choice |
| 8 | prompt "System type" | 10 | prompt "System type" |
diff --git a/arch/score/include/asm/irqflags.h b/arch/score/include/asm/irqflags.h index 5c7563891e2..37c6ac9dd6e 100644 --- a/arch/score/include/asm/irqflags.h +++ b/arch/score/include/asm/irqflags.h | |||
| @@ -29,7 +29,7 @@ static inline unsigned long arch_local_save_flags(void) | |||
| 29 | 29 | ||
| 30 | static inline unsigned long arch_local_irq_save(void) | 30 | static inline unsigned long arch_local_irq_save(void) |
| 31 | { | 31 | { |
| 32 | unsigned long flags | 32 | unsigned long flags; |
| 33 | 33 | ||
| 34 | asm volatile( | 34 | asm volatile( |
| 35 | " mfcr r8, cr0 \n" | 35 | " mfcr r8, cr0 \n" |
diff --git a/arch/score/kernel/irq.c b/arch/score/kernel/irq.c index 47647dde09c..d4196732c65 100644 --- a/arch/score/kernel/irq.c +++ b/arch/score/kernel/irq.c | |||
| @@ -52,9 +52,9 @@ asmlinkage void do_IRQ(int irq) | |||
| 52 | irq_exit(); | 52 | irq_exit(); |
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | static void score_mask(unsigned int irq_nr) | 55 | static void score_mask(struct irq_data *d) |
| 56 | { | 56 | { |
| 57 | unsigned int irq_source = 63 - irq_nr; | 57 | unsigned int irq_source = 63 - d->irq; |
| 58 | 58 | ||
| 59 | if (irq_source < 32) | 59 | if (irq_source < 32) |
| 60 | __raw_writel((__raw_readl(SCORE_PIC + INT_MASKL) | \ | 60 | __raw_writel((__raw_readl(SCORE_PIC + INT_MASKL) | \ |
| @@ -64,9 +64,9 @@ static void score_mask(unsigned int irq_nr) | |||
| 64 | (1 << (irq_source - 32))), SCORE_PIC + INT_MASKH); | 64 | (1 << (irq_source - 32))), SCORE_PIC + INT_MASKH); |
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | static void score_unmask(unsigned int irq_nr) | 67 | static void score_unmask(struct irq_data *d) |
| 68 | { | 68 | { |
| 69 | unsigned int irq_source = 63 - irq_nr; | 69 | unsigned int irq_source = 63 - d->irq; |
| 70 | 70 | ||
| 71 | if (irq_source < 32) | 71 | if (irq_source < 32) |
| 72 | __raw_writel((__raw_readl(SCORE_PIC + INT_MASKL) & \ | 72 | __raw_writel((__raw_readl(SCORE_PIC + INT_MASKL) & \ |
| @@ -78,9 +78,9 @@ static void score_unmask(unsigned int irq_nr) | |||
| 78 | 78 | ||
| 79 | struct irq_chip score_irq_chip = { | 79 | struct irq_chip score_irq_chip = { |
| 80 | .name = "Score7-level", | 80 | .name = "Score7-level", |
| 81 | .mask = score_mask, | 81 | .irq_mask = score_mask, |
| 82 | .mask_ack = score_mask, | 82 | .irq_mask_ack = score_mask, |
| 83 | .unmask = score_unmask, | 83 | .irq_unmask = score_unmask, |
| 84 | }; | 84 | }; |
| 85 | 85 | ||
| 86 | /* | 86 | /* |
| @@ -92,7 +92,7 @@ void __init init_IRQ(void) | |||
| 92 | unsigned long target_addr; | 92 | unsigned long target_addr; |
| 93 | 93 | ||
| 94 | for (index = 0; index < NR_IRQS; ++index) | 94 | for (index = 0; index < NR_IRQS; ++index) |
| 95 | set_irq_chip_and_handler(index, &score_irq_chip, | 95 | irq_set_chip_and_handler(index, &score_irq_chip, |
| 96 | handle_level_irq); | 96 | handle_level_irq); |
| 97 | 97 | ||
| 98 | for (target_addr = IRQ_VECTOR_BASE_ADDR; | 98 | for (target_addr = IRQ_VECTOR_BASE_ADDR; |
| @@ -109,40 +109,3 @@ void __init init_IRQ(void) | |||
| 109 | : : "r" (EXCEPTION_VECTOR_BASE_ADDR | \ | 109 | : : "r" (EXCEPTION_VECTOR_BASE_ADDR | \ |
| 110 | VECTOR_ADDRESS_OFFSET_MODE16)); | 110 | VECTOR_ADDRESS_OFFSET_MODE16)); |
| 111 | } | 111 | } |
| 112 | |||
| 113 | /* | ||
| 114 | * Generic, controller-independent functions: | ||
| 115 | */ | ||
| 116 | int show_interrupts(struct seq_file *p, void *v) | ||
| 117 | { | ||
| 118 | int i = *(loff_t *)v, cpu; | ||
| 119 | struct irqaction *action; | ||
| 120 | unsigned long flags; | ||
| 121 | |||
| 122 | if (i == 0) { | ||
| 123 | seq_puts(p, " "); | ||
| 124 | for_each_online_cpu(cpu) | ||
| 125 | seq_printf(p, "CPU%d ", cpu); | ||
| 126 | seq_putc(p, '\n'); | ||
| 127 | } | ||
| 128 | |||
| 129 | if (i < NR_IRQS) { | ||
| 130 | spin_lock_irqsave(&irq_desc[i].lock, flags); | ||
| 131 | action = irq_desc[i].action; | ||
| 132 | if (!action) | ||
| 133 | goto unlock; | ||
| 134 | |||
| 135 | seq_printf(p, "%3d: ", i); | ||
| 136 | seq_printf(p, "%10u ", kstat_irqs(i)); | ||
| 137 | seq_printf(p, " %8s", irq_desc[i].chip->name ? : "-"); | ||
| 138 | seq_printf(p, " %s", action->name); | ||
| 139 | for (action = action->next; action; action = action->next) | ||
| 140 | seq_printf(p, ", %s", action->name); | ||
| 141 | |||
| 142 | seq_putc(p, '\n'); | ||
| 143 | unlock: | ||
| 144 | spin_unlock_irqrestore(&irq_desc[i].lock, flags); | ||
| 145 | } | ||
| 146 | |||
| 147 | return 0; | ||
| 148 | } | ||
diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig index f3b78701c21..5e34a9fee9b 100644 --- a/arch/tile/Kconfig +++ b/arch/tile/Kconfig | |||
| @@ -12,6 +12,7 @@ config TILE | |||
| 12 | select GENERIC_IRQ_PROBE | 12 | select GENERIC_IRQ_PROBE |
| 13 | select GENERIC_PENDING_IRQ if SMP | 13 | select GENERIC_PENDING_IRQ if SMP |
| 14 | select GENERIC_HARDIRQS_NO_DEPRECATED | 14 | select GENERIC_HARDIRQS_NO_DEPRECATED |
| 15 | select GENERIC_IRQ_SHOW | ||
| 15 | 16 | ||
| 16 | # FIXME: investigate whether we need/want these options. | 17 | # FIXME: investigate whether we need/want these options. |
| 17 | # select HAVE_IOREMAP_PROT | 18 | # select HAVE_IOREMAP_PROT |
diff --git a/arch/tile/kernel/irq.c b/arch/tile/kernel/irq.c index 0baa7580121..aa0134db2dd 100644 --- a/arch/tile/kernel/irq.c +++ b/arch/tile/kernel/irq.c | |||
| @@ -241,14 +241,14 @@ void tile_irq_activate(unsigned int irq, int tile_irq_type) | |||
| 241 | irq_flow_handler_t handle = handle_level_irq; | 241 | irq_flow_handler_t handle = handle_level_irq; |
| 242 | if (tile_irq_type == TILE_IRQ_PERCPU) | 242 | if (tile_irq_type == TILE_IRQ_PERCPU) |
| 243 | handle = handle_percpu_irq; | 243 | handle = handle_percpu_irq; |
| 244 | set_irq_chip_and_handler(irq, &tile_irq_chip, handle); | 244 | irq_set_chip_and_handler(irq, &tile_irq_chip, handle); |
| 245 | 245 | ||
| 246 | /* | 246 | /* |
| 247 | * Flag interrupts that are hardware-cleared so that ack() | 247 | * Flag interrupts that are hardware-cleared so that ack() |
| 248 | * won't clear them. | 248 | * won't clear them. |
| 249 | */ | 249 | */ |
| 250 | if (tile_irq_type == TILE_IRQ_HW_CLEAR) | 250 | if (tile_irq_type == TILE_IRQ_HW_CLEAR) |
| 251 | set_irq_chip_data(irq, (void *)IS_HW_CLEARED); | 251 | irq_set_chip_data(irq, (void *)IS_HW_CLEARED); |
| 252 | } | 252 | } |
| 253 | EXPORT_SYMBOL(tile_irq_activate); | 253 | EXPORT_SYMBOL(tile_irq_activate); |
| 254 | 254 | ||
| @@ -262,47 +262,6 @@ void ack_bad_irq(unsigned int irq) | |||
| 262 | * Generic, controller-independent functions: | 262 | * Generic, controller-independent functions: |
| 263 | */ | 263 | */ |
| 264 | 264 | ||
| 265 | int show_interrupts(struct seq_file *p, void *v) | ||
| 266 | { | ||
| 267 | int i = *(loff_t *) v, j; | ||
| 268 | struct irqaction *action; | ||
| 269 | unsigned long flags; | ||
| 270 | |||
| 271 | if (i == 0) { | ||
| 272 | seq_printf(p, " "); | ||
| 273 | for (j = 0; j < NR_CPUS; j++) | ||
| 274 | if (cpu_online(j)) | ||
| 275 | seq_printf(p, "CPU%-8d", j); | ||
| 276 | seq_putc(p, '\n'); | ||
| 277 | } | ||
| 278 | |||
| 279 | if (i < NR_IRQS) { | ||
| 280 | struct irq_desc *desc = irq_to_desc(i); | ||
| 281 | |||
| 282 | raw_spin_lock_irqsave(&desc->lock, flags); | ||
| 283 | action = desc->action; | ||
| 284 | if (!action) | ||
| 285 | goto skip; | ||
| 286 | seq_printf(p, "%3d: ", i); | ||
| 287 | #ifndef CONFIG_SMP | ||
| 288 | seq_printf(p, "%10u ", kstat_irqs(i)); | ||
| 289 | #else | ||
| 290 | for_each_online_cpu(j) | ||
| 291 | seq_printf(p, "%10u ", kstat_irqs_cpu(i, j)); | ||
| 292 | #endif | ||
| 293 | seq_printf(p, " %14s", get_irq_desc_chip(desc)->name); | ||
| 294 | seq_printf(p, " %s", action->name); | ||
| 295 | |||
| 296 | for (action = action->next; action; action = action->next) | ||
| 297 | seq_printf(p, ", %s", action->name); | ||
| 298 | |||
| 299 | seq_putc(p, '\n'); | ||
| 300 | skip: | ||
| 301 | raw_spin_unlock_irqrestore(&desc->lock, flags); | ||
| 302 | } | ||
| 303 | return 0; | ||
| 304 | } | ||
| 305 | |||
| 306 | #if CHIP_HAS_IPI() | 265 | #if CHIP_HAS_IPI() |
| 307 | int create_irq(void) | 266 | int create_irq(void) |
| 308 | { | 267 | { |
diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h index a09e1f052d8..d475b4398d8 100644 --- a/arch/x86/include/asm/percpu.h +++ b/arch/x86/include/asm/percpu.h | |||
| @@ -45,7 +45,7 @@ | |||
| 45 | #include <linux/stringify.h> | 45 | #include <linux/stringify.h> |
| 46 | 46 | ||
| 47 | #ifdef CONFIG_SMP | 47 | #ifdef CONFIG_SMP |
| 48 | #define __percpu_arg(x) "%%"__stringify(__percpu_seg)":%P" #x | 48 | #define __percpu_prefix "%%"__stringify(__percpu_seg)":" |
| 49 | #define __my_cpu_offset percpu_read(this_cpu_off) | 49 | #define __my_cpu_offset percpu_read(this_cpu_off) |
| 50 | 50 | ||
| 51 | /* | 51 | /* |
| @@ -62,9 +62,11 @@ | |||
| 62 | (typeof(*(ptr)) __kernel __force *)tcp_ptr__; \ | 62 | (typeof(*(ptr)) __kernel __force *)tcp_ptr__; \ |
| 63 | }) | 63 | }) |
| 64 | #else | 64 | #else |
| 65 | #define __percpu_arg(x) "%P" #x | 65 | #define __percpu_prefix "" |
| 66 | #endif | 66 | #endif |
| 67 | 67 | ||
| 68 | #define __percpu_arg(x) __percpu_prefix "%P" #x | ||
| 69 | |||
| 68 | /* | 70 | /* |
| 69 | * Initialized pointers to per-cpu variables needed for the boot | 71 | * Initialized pointers to per-cpu variables needed for the boot |
| 70 | * processor need to use these macros to get the proper address | 72 | * processor need to use these macros to get the proper address |
| @@ -516,11 +518,11 @@ do { \ | |||
| 516 | typeof(o2) __n2 = n2; \ | 518 | typeof(o2) __n2 = n2; \ |
| 517 | typeof(o2) __dummy; \ | 519 | typeof(o2) __dummy; \ |
| 518 | alternative_io("call this_cpu_cmpxchg16b_emu\n\t" P6_NOP4, \ | 520 | alternative_io("call this_cpu_cmpxchg16b_emu\n\t" P6_NOP4, \ |
| 519 | "cmpxchg16b %%gs:(%%rsi)\n\tsetz %0\n\t", \ | 521 | "cmpxchg16b " __percpu_prefix "(%%rsi)\n\tsetz %0\n\t", \ |
| 520 | X86_FEATURE_CX16, \ | 522 | X86_FEATURE_CX16, \ |
| 521 | ASM_OUTPUT2("=a"(__ret), "=d"(__dummy)), \ | 523 | ASM_OUTPUT2("=a"(__ret), "=d"(__dummy)), \ |
| 522 | "S" (&pcp1), "b"(__n1), "c"(__n2), \ | 524 | "S" (&pcp1), "b"(__n1), "c"(__n2), \ |
| 523 | "a"(__o1), "d"(__o2)); \ | 525 | "a"(__o1), "d"(__o2) : "memory"); \ |
| 524 | __ret; \ | 526 | __ret; \ |
| 525 | }) | 527 | }) |
| 526 | 528 | ||
diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S index 3e8b08a6de2..1e572c507d0 100644 --- a/arch/x86/lib/cmpxchg16b_emu.S +++ b/arch/x86/lib/cmpxchg16b_emu.S | |||
| @@ -10,6 +10,12 @@ | |||
| 10 | #include <asm/frame.h> | 10 | #include <asm/frame.h> |
| 11 | #include <asm/dwarf2.h> | 11 | #include <asm/dwarf2.h> |
| 12 | 12 | ||
| 13 | #ifdef CONFIG_SMP | ||
| 14 | #define SEG_PREFIX %gs: | ||
| 15 | #else | ||
| 16 | #define SEG_PREFIX | ||
| 17 | #endif | ||
| 18 | |||
| 13 | .text | 19 | .text |
| 14 | 20 | ||
| 15 | /* | 21 | /* |
| @@ -37,13 +43,13 @@ this_cpu_cmpxchg16b_emu: | |||
| 37 | pushf | 43 | pushf |
| 38 | cli | 44 | cli |
| 39 | 45 | ||
| 40 | cmpq %gs:(%rsi), %rax | 46 | cmpq SEG_PREFIX(%rsi), %rax |
| 41 | jne not_same | 47 | jne not_same |
| 42 | cmpq %gs:8(%rsi), %rdx | 48 | cmpq SEG_PREFIX 8(%rsi), %rdx |
| 43 | jne not_same | 49 | jne not_same |
| 44 | 50 | ||
| 45 | movq %rbx, %gs:(%rsi) | 51 | movq %rbx, SEG_PREFIX(%rsi) |
| 46 | movq %rcx, %gs:8(%rsi) | 52 | movq %rcx, SEG_PREFIX 8(%rsi) |
| 47 | 53 | ||
| 48 | popf | 54 | popf |
| 49 | mov $1, %al | 55 | mov $1, %al |
diff --git a/arch/x86/platform/olpc/olpc-xo1.c b/arch/x86/platform/olpc/olpc-xo1.c index 99513642a0e..ab81fb27176 100644 --- a/arch/x86/platform/olpc/olpc-xo1.c +++ b/arch/x86/platform/olpc/olpc-xo1.c | |||
| @@ -72,9 +72,9 @@ static int __devinit olpc_xo1_probe(struct platform_device *pdev) | |||
| 72 | dev_err(&pdev->dev, "can't fetch device resource info\n"); | 72 | dev_err(&pdev->dev, "can't fetch device resource info\n"); |
| 73 | return -EIO; | 73 | return -EIO; |
| 74 | } | 74 | } |
| 75 | if (strcmp(pdev->name, "olpc-xo1-pms") == 0) | 75 | if (strcmp(pdev->name, "cs5535-pms") == 0) |
| 76 | pms_base = res->start; | 76 | pms_base = res->start; |
| 77 | else if (strcmp(pdev->name, "olpc-xo1-ac-acpi") == 0) | 77 | else if (strcmp(pdev->name, "olpc-xo1-pm-acpi") == 0) |
| 78 | acpi_base = res->start; | 78 | acpi_base = res->start; |
| 79 | 79 | ||
| 80 | /* If we have both addresses, we can override the poweroff hook */ | 80 | /* If we have both addresses, we can override the poweroff hook */ |
| @@ -90,9 +90,9 @@ static int __devexit olpc_xo1_remove(struct platform_device *pdev) | |||
| 90 | { | 90 | { |
| 91 | mfd_cell_disable(pdev); | 91 | mfd_cell_disable(pdev); |
| 92 | 92 | ||
| 93 | if (strcmp(pdev->name, "olpc-xo1-pms") == 0) | 93 | if (strcmp(pdev->name, "cs5535-pms") == 0) |
| 94 | pms_base = 0; | 94 | pms_base = 0; |
| 95 | else if (strcmp(pdev->name, "olpc-xo1-acpi") == 0) | 95 | else if (strcmp(pdev->name, "olpc-xo1-pm-acpi") == 0) |
| 96 | acpi_base = 0; | 96 | acpi_base = 0; |
| 97 | 97 | ||
| 98 | pm_power_off = NULL; | 98 | pm_power_off = NULL; |
| @@ -101,7 +101,7 @@ static int __devexit olpc_xo1_remove(struct platform_device *pdev) | |||
| 101 | 101 | ||
| 102 | static struct platform_driver cs5535_pms_drv = { | 102 | static struct platform_driver cs5535_pms_drv = { |
| 103 | .driver = { | 103 | .driver = { |
| 104 | .name = "olpc-xo1-pms", | 104 | .name = "cs5535-pms", |
| 105 | .owner = THIS_MODULE, | 105 | .owner = THIS_MODULE, |
| 106 | }, | 106 | }, |
| 107 | .probe = olpc_xo1_probe, | 107 | .probe = olpc_xo1_probe, |
| @@ -110,7 +110,7 @@ static struct platform_driver cs5535_pms_drv = { | |||
| 110 | 110 | ||
| 111 | static struct platform_driver cs5535_acpi_drv = { | 111 | static struct platform_driver cs5535_acpi_drv = { |
| 112 | .driver = { | 112 | .driver = { |
| 113 | .name = "olpc-xo1-acpi", | 113 | .name = "olpc-xo1-pm-acpi", |
| 114 | .owner = THIS_MODULE, | 114 | .owner = THIS_MODULE, |
| 115 | }, | 115 | }, |
| 116 | .probe = olpc_xo1_probe, | 116 | .probe = olpc_xo1_probe, |
| @@ -121,22 +121,21 @@ static int __init olpc_xo1_init(void) | |||
| 121 | { | 121 | { |
| 122 | int r; | 122 | int r; |
| 123 | 123 | ||
| 124 | r = mfd_shared_platform_driver_register(&cs5535_pms_drv, "cs5535-pms"); | 124 | r = platform_driver_register(&cs5535_pms_drv); |
| 125 | if (r) | 125 | if (r) |
| 126 | return r; | 126 | return r; |
| 127 | 127 | ||
| 128 | r = mfd_shared_platform_driver_register(&cs5535_acpi_drv, | 128 | r = platform_driver_register(&cs5535_acpi_drv); |
| 129 | "cs5535-acpi"); | ||
| 130 | if (r) | 129 | if (r) |
| 131 | mfd_shared_platform_driver_unregister(&cs5535_pms_drv); | 130 | platform_driver_unregister(&cs5535_pms_drv); |
| 132 | 131 | ||
| 133 | return r; | 132 | return r; |
| 134 | } | 133 | } |
| 135 | 134 | ||
| 136 | static void __exit olpc_xo1_exit(void) | 135 | static void __exit olpc_xo1_exit(void) |
| 137 | { | 136 | { |
| 138 | mfd_shared_platform_driver_unregister(&cs5535_acpi_drv); | 137 | platform_driver_unregister(&cs5535_acpi_drv); |
| 139 | mfd_shared_platform_driver_unregister(&cs5535_pms_drv); | 138 | platform_driver_unregister(&cs5535_pms_drv); |
| 140 | } | 139 | } |
| 141 | 140 | ||
| 142 | MODULE_AUTHOR("Daniel Drake <dsd@laptop.org>"); | 141 | MODULE_AUTHOR("Daniel Drake <dsd@laptop.org>"); |
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index a18e497f1c3..31e9e10f657 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c | |||
| @@ -824,11 +824,6 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device) | |||
| 824 | device->backlight->props.brightness = | 824 | device->backlight->props.brightness = |
| 825 | acpi_video_get_brightness(device->backlight); | 825 | acpi_video_get_brightness(device->backlight); |
| 826 | 826 | ||
| 827 | result = sysfs_create_link(&device->backlight->dev.kobj, | ||
| 828 | &device->dev->dev.kobj, "device"); | ||
| 829 | if (result) | ||
| 830 | printk(KERN_ERR PREFIX "Create sysfs link\n"); | ||
| 831 | |||
| 832 | device->cooling_dev = thermal_cooling_device_register("LCD", | 827 | device->cooling_dev = thermal_cooling_device_register("LCD", |
| 833 | device->dev, &video_cooling_ops); | 828 | device->dev, &video_cooling_ops); |
| 834 | if (IS_ERR(device->cooling_dev)) { | 829 | if (IS_ERR(device->cooling_dev)) { |
| @@ -1381,7 +1376,6 @@ static int acpi_video_bus_put_one_device(struct acpi_video_device *device) | |||
| 1381 | "Cant remove video notify handler\n"); | 1376 | "Cant remove video notify handler\n"); |
| 1382 | } | 1377 | } |
| 1383 | if (device->backlight) { | 1378 | if (device->backlight) { |
| 1384 | sysfs_remove_link(&device->backlight->dev.kobj, "device"); | ||
| 1385 | backlight_device_unregister(device->backlight); | 1379 | backlight_device_unregister(device->backlight); |
| 1386 | device->backlight = NULL; | 1380 | device->backlight = NULL; |
| 1387 | } | 1381 | } |
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index 35658f445fc..9bf13988f1a 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c | |||
| @@ -193,7 +193,7 @@ static int __devinit cciss_find_cfg_addrs(struct pci_dev *pdev, | |||
| 193 | u64 *cfg_offset); | 193 | u64 *cfg_offset); |
| 194 | static int __devinit cciss_pci_find_memory_BAR(struct pci_dev *pdev, | 194 | static int __devinit cciss_pci_find_memory_BAR(struct pci_dev *pdev, |
| 195 | unsigned long *memory_bar); | 195 | unsigned long *memory_bar); |
| 196 | 196 | static inline u32 cciss_tag_discard_error_bits(ctlr_info_t *h, u32 tag); | |
| 197 | 197 | ||
| 198 | /* performant mode helper functions */ | 198 | /* performant mode helper functions */ |
| 199 | static void calc_bucket_map(int *bucket, int num_buckets, int nsgs, | 199 | static void calc_bucket_map(int *bucket, int num_buckets, int nsgs, |
| @@ -231,7 +231,7 @@ static const struct block_device_operations cciss_fops = { | |||
| 231 | */ | 231 | */ |
| 232 | static void set_performant_mode(ctlr_info_t *h, CommandList_struct *c) | 232 | static void set_performant_mode(ctlr_info_t *h, CommandList_struct *c) |
| 233 | { | 233 | { |
| 234 | if (likely(h->transMethod == CFGTBL_Trans_Performant)) | 234 | if (likely(h->transMethod & CFGTBL_Trans_Performant)) |
| 235 | c->busaddr |= 1 | (h->blockFetchTable[c->Header.SGList] << 1); | 235 | c->busaddr |= 1 | (h->blockFetchTable[c->Header.SGList] << 1); |
| 236 | } | 236 | } |
| 237 | 237 | ||
| @@ -556,6 +556,44 @@ static void __devinit cciss_procinit(ctlr_info_t *h) | |||
| 556 | #define to_hba(n) container_of(n, struct ctlr_info, dev) | 556 | #define to_hba(n) container_of(n, struct ctlr_info, dev) |
| 557 | #define to_drv(n) container_of(n, drive_info_struct, dev) | 557 | #define to_drv(n) container_of(n, drive_info_struct, dev) |
| 558 | 558 | ||
| 559 | /* List of controllers which cannot be reset on kexec with reset_devices */ | ||
| 560 | static u32 unresettable_controller[] = { | ||
| 561 | 0x324a103C, /* Smart Array P712m */ | ||
| 562 | 0x324b103C, /* SmartArray P711m */ | ||
| 563 | 0x3223103C, /* Smart Array P800 */ | ||
| 564 | 0x3234103C, /* Smart Array P400 */ | ||
| 565 | 0x3235103C, /* Smart Array P400i */ | ||
| 566 | 0x3211103C, /* Smart Array E200i */ | ||
| 567 | 0x3212103C, /* Smart Array E200 */ | ||
| 568 | 0x3213103C, /* Smart Array E200i */ | ||
| 569 | 0x3214103C, /* Smart Array E200i */ | ||
| 570 | 0x3215103C, /* Smart Array E200i */ | ||
| 571 | 0x3237103C, /* Smart Array E500 */ | ||
| 572 | 0x323D103C, /* Smart Array P700m */ | ||
| 573 | 0x409C0E11, /* Smart Array 6400 */ | ||
| 574 | 0x409D0E11, /* Smart Array 6400 EM */ | ||
| 575 | }; | ||
| 576 | |||
| 577 | static int ctlr_is_resettable(struct ctlr_info *h) | ||
| 578 | { | ||
| 579 | int i; | ||
| 580 | |||
| 581 | for (i = 0; i < ARRAY_SIZE(unresettable_controller); i++) | ||
| 582 | if (unresettable_controller[i] == h->board_id) | ||
| 583 | return 0; | ||
| 584 | return 1; | ||
| 585 | } | ||
| 586 | |||
| 587 | static ssize_t host_show_resettable(struct device *dev, | ||
| 588 | struct device_attribute *attr, | ||
| 589 | char *buf) | ||
| 590 | { | ||
| 591 | struct ctlr_info *h = to_hba(dev); | ||
| 592 | |||
| 593 | return snprintf(buf, 20, "%d\n", ctlr_is_resettable(h)); | ||
| 594 | } | ||
| 595 | static DEVICE_ATTR(resettable, S_IRUGO, host_show_resettable, NULL); | ||
| 596 | |||
| 559 | static ssize_t host_store_rescan(struct device *dev, | 597 | static ssize_t host_store_rescan(struct device *dev, |
| 560 | struct device_attribute *attr, | 598 | struct device_attribute *attr, |
| 561 | const char *buf, size_t count) | 599 | const char *buf, size_t count) |
| @@ -741,6 +779,7 @@ static DEVICE_ATTR(usage_count, S_IRUGO, cciss_show_usage_count, NULL); | |||
| 741 | 779 | ||
| 742 | static struct attribute *cciss_host_attrs[] = { | 780 | static struct attribute *cciss_host_attrs[] = { |
| 743 | &dev_attr_rescan.attr, | 781 | &dev_attr_rescan.attr, |
| 782 | &dev_attr_resettable.attr, | ||
| 744 | NULL | 783 | NULL |
| 745 | }; | 784 | }; |
| 746 | 785 | ||
| @@ -973,8 +1012,8 @@ static void cmd_special_free(ctlr_info_t *h, CommandList_struct *c) | |||
| 973 | temp64.val32.upper = c->ErrDesc.Addr.upper; | 1012 | temp64.val32.upper = c->ErrDesc.Addr.upper; |
| 974 | pci_free_consistent(h->pdev, sizeof(ErrorInfo_struct), | 1013 | pci_free_consistent(h->pdev, sizeof(ErrorInfo_struct), |
| 975 | c->err_info, (dma_addr_t) temp64.val); | 1014 | c->err_info, (dma_addr_t) temp64.val); |
| 976 | pci_free_consistent(h->pdev, sizeof(CommandList_struct), | 1015 | pci_free_consistent(h->pdev, sizeof(CommandList_struct), c, |
| 977 | c, (dma_addr_t) c->busaddr); | 1016 | (dma_addr_t) cciss_tag_discard_error_bits(h, (u32) c->busaddr)); |
| 978 | } | 1017 | } |
| 979 | 1018 | ||
| 980 | static inline ctlr_info_t *get_host(struct gendisk *disk) | 1019 | static inline ctlr_info_t *get_host(struct gendisk *disk) |
| @@ -1490,8 +1529,7 @@ static int cciss_bigpassthru(ctlr_info_t *h, void __user *argp) | |||
| 1490 | return -EINVAL; | 1529 | return -EINVAL; |
| 1491 | if (!capable(CAP_SYS_RAWIO)) | 1530 | if (!capable(CAP_SYS_RAWIO)) |
| 1492 | return -EPERM; | 1531 | return -EPERM; |
| 1493 | ioc = (BIG_IOCTL_Command_struct *) | 1532 | ioc = kmalloc(sizeof(*ioc), GFP_KERNEL); |
| 1494 | kmalloc(sizeof(*ioc), GFP_KERNEL); | ||
| 1495 | if (!ioc) { | 1533 | if (!ioc) { |
| 1496 | status = -ENOMEM; | 1534 | status = -ENOMEM; |
| 1497 | goto cleanup1; | 1535 | goto cleanup1; |
| @@ -2653,6 +2691,10 @@ static int process_sendcmd_error(ctlr_info_t *h, CommandList_struct *c) | |||
| 2653 | c->Request.CDB[0]); | 2691 | c->Request.CDB[0]); |
| 2654 | return_status = IO_NEEDS_RETRY; | 2692 | return_status = IO_NEEDS_RETRY; |
| 2655 | break; | 2693 | break; |
| 2694 | case CMD_UNABORTABLE: | ||
| 2695 | dev_warn(&h->pdev->dev, "cmd unabortable\n"); | ||
| 2696 | return_status = IO_ERROR; | ||
| 2697 | break; | ||
| 2656 | default: | 2698 | default: |
| 2657 | dev_warn(&h->pdev->dev, "cmd 0x%02x returned " | 2699 | dev_warn(&h->pdev->dev, "cmd 0x%02x returned " |
| 2658 | "unknown status %x\n", c->Request.CDB[0], | 2700 | "unknown status %x\n", c->Request.CDB[0], |
| @@ -3103,6 +3145,13 @@ static inline void complete_command(ctlr_info_t *h, CommandList_struct *cmd, | |||
| 3103 | (cmd->rq->cmd_type == REQ_TYPE_BLOCK_PC) ? | 3145 | (cmd->rq->cmd_type == REQ_TYPE_BLOCK_PC) ? |
| 3104 | DID_PASSTHROUGH : DID_ERROR); | 3146 | DID_PASSTHROUGH : DID_ERROR); |
| 3105 | break; | 3147 | break; |
| 3148 | case CMD_UNABORTABLE: | ||
| 3149 | dev_warn(&h->pdev->dev, "cmd %p unabortable\n", cmd); | ||
| 3150 | rq->errors = make_status_bytes(SAM_STAT_GOOD, | ||
| 3151 | cmd->err_info->CommandStatus, DRIVER_OK, | ||
| 3152 | cmd->rq->cmd_type == REQ_TYPE_BLOCK_PC ? | ||
| 3153 | DID_PASSTHROUGH : DID_ERROR); | ||
| 3154 | break; | ||
| 3106 | default: | 3155 | default: |
| 3107 | dev_warn(&h->pdev->dev, "cmd %p returned " | 3156 | dev_warn(&h->pdev->dev, "cmd %p returned " |
| 3108 | "unknown status %x\n", cmd, | 3157 | "unknown status %x\n", cmd, |
| @@ -3136,10 +3185,13 @@ static inline u32 cciss_tag_to_index(u32 tag) | |||
| 3136 | return tag >> DIRECT_LOOKUP_SHIFT; | 3185 | return tag >> DIRECT_LOOKUP_SHIFT; |
| 3137 | } | 3186 | } |
| 3138 | 3187 | ||
| 3139 | static inline u32 cciss_tag_discard_error_bits(u32 tag) | 3188 | static inline u32 cciss_tag_discard_error_bits(ctlr_info_t *h, u32 tag) |
| 3140 | { | 3189 | { |
| 3141 | #define CCISS_ERROR_BITS 0x03 | 3190 | #define CCISS_PERF_ERROR_BITS ((1 << DIRECT_LOOKUP_SHIFT) - 1) |
| 3142 | return tag & ~CCISS_ERROR_BITS; | 3191 | #define CCISS_SIMPLE_ERROR_BITS 0x03 |
| 3192 | if (likely(h->transMethod & CFGTBL_Trans_Performant)) | ||
| 3193 | return tag & ~CCISS_PERF_ERROR_BITS; | ||
| 3194 | return tag & ~CCISS_SIMPLE_ERROR_BITS; | ||
| 3143 | } | 3195 | } |
| 3144 | 3196 | ||
| 3145 | static inline void cciss_mark_tag_indexed(u32 *tag) | 3197 | static inline void cciss_mark_tag_indexed(u32 *tag) |
| @@ -3359,7 +3411,7 @@ static inline u32 next_command(ctlr_info_t *h) | |||
| 3359 | { | 3411 | { |
| 3360 | u32 a; | 3412 | u32 a; |
| 3361 | 3413 | ||
| 3362 | if (unlikely(h->transMethod != CFGTBL_Trans_Performant)) | 3414 | if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant))) |
| 3363 | return h->access.command_completed(h); | 3415 | return h->access.command_completed(h); |
| 3364 | 3416 | ||
| 3365 | if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) { | 3417 | if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) { |
| @@ -3394,14 +3446,12 @@ static inline u32 process_indexed_cmd(ctlr_info_t *h, u32 raw_tag) | |||
| 3394 | /* process completion of a non-indexed command */ | 3446 | /* process completion of a non-indexed command */ |
| 3395 | static inline u32 process_nonindexed_cmd(ctlr_info_t *h, u32 raw_tag) | 3447 | static inline u32 process_nonindexed_cmd(ctlr_info_t *h, u32 raw_tag) |
| 3396 | { | 3448 | { |
| 3397 | u32 tag; | ||
| 3398 | CommandList_struct *c = NULL; | 3449 | CommandList_struct *c = NULL; |
| 3399 | __u32 busaddr_masked, tag_masked; | 3450 | __u32 busaddr_masked, tag_masked; |
| 3400 | 3451 | ||
| 3401 | tag = cciss_tag_discard_error_bits(raw_tag); | 3452 | tag_masked = cciss_tag_discard_error_bits(h, raw_tag); |
| 3402 | list_for_each_entry(c, &h->cmpQ, list) { | 3453 | list_for_each_entry(c, &h->cmpQ, list) { |
| 3403 | busaddr_masked = cciss_tag_discard_error_bits(c->busaddr); | 3454 | busaddr_masked = cciss_tag_discard_error_bits(h, c->busaddr); |
| 3404 | tag_masked = cciss_tag_discard_error_bits(tag); | ||
| 3405 | if (busaddr_masked == tag_masked) { | 3455 | if (busaddr_masked == tag_masked) { |
| 3406 | finish_cmd(h, c, raw_tag); | 3456 | finish_cmd(h, c, raw_tag); |
| 3407 | return next_command(h); | 3457 | return next_command(h); |
| @@ -3753,7 +3803,8 @@ static void __devinit cciss_wait_for_mode_change_ack(ctlr_info_t *h) | |||
| 3753 | } | 3803 | } |
| 3754 | } | 3804 | } |
| 3755 | 3805 | ||
| 3756 | static __devinit void cciss_enter_performant_mode(ctlr_info_t *h) | 3806 | static __devinit void cciss_enter_performant_mode(ctlr_info_t *h, |
| 3807 | u32 use_short_tags) | ||
| 3757 | { | 3808 | { |
| 3758 | /* This is a bit complicated. There are 8 registers on | 3809 | /* This is a bit complicated. There are 8 registers on |
| 3759 | * the controller which we write to to tell it 8 different | 3810 | * the controller which we write to to tell it 8 different |
| @@ -3808,7 +3859,7 @@ static __devinit void cciss_enter_performant_mode(ctlr_info_t *h) | |||
| 3808 | writel(0, &h->transtable->RepQCtrAddrHigh32); | 3859 | writel(0, &h->transtable->RepQCtrAddrHigh32); |
| 3809 | writel(h->reply_pool_dhandle, &h->transtable->RepQAddr0Low32); | 3860 | writel(h->reply_pool_dhandle, &h->transtable->RepQAddr0Low32); |
| 3810 | writel(0, &h->transtable->RepQAddr0High32); | 3861 | writel(0, &h->transtable->RepQAddr0High32); |
| 3811 | writel(CFGTBL_Trans_Performant, | 3862 | writel(CFGTBL_Trans_Performant | use_short_tags, |
| 3812 | &(h->cfgtable->HostWrite.TransportRequest)); | 3863 | &(h->cfgtable->HostWrite.TransportRequest)); |
| 3813 | 3864 | ||
| 3814 | writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL); | 3865 | writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL); |
| @@ -3855,7 +3906,8 @@ static void __devinit cciss_put_controller_into_performant_mode(ctlr_info_t *h) | |||
| 3855 | if ((h->reply_pool == NULL) || (h->blockFetchTable == NULL)) | 3906 | if ((h->reply_pool == NULL) || (h->blockFetchTable == NULL)) |
| 3856 | goto clean_up; | 3907 | goto clean_up; |
| 3857 | 3908 | ||
| 3858 | cciss_enter_performant_mode(h); | 3909 | cciss_enter_performant_mode(h, |
| 3910 | trans_support & CFGTBL_Trans_use_short_tags); | ||
| 3859 | 3911 | ||
| 3860 | /* Change the access methods to the performant access methods */ | 3912 | /* Change the access methods to the performant access methods */ |
| 3861 | h->access = SA5_performant_access; | 3913 | h->access = SA5_performant_access; |
diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h index 579f7491849..554bbd907d1 100644 --- a/drivers/block/cciss.h +++ b/drivers/block/cciss.h | |||
| @@ -222,6 +222,7 @@ static void SA5_submit_command( ctlr_info_t *h, CommandList_struct *c) | |||
| 222 | h->ctlr, c->busaddr); | 222 | h->ctlr, c->busaddr); |
| 223 | #endif /* CCISS_DEBUG */ | 223 | #endif /* CCISS_DEBUG */ |
| 224 | writel(c->busaddr, h->vaddr + SA5_REQUEST_PORT_OFFSET); | 224 | writel(c->busaddr, h->vaddr + SA5_REQUEST_PORT_OFFSET); |
| 225 | readl(h->vaddr + SA5_REQUEST_PORT_OFFSET); | ||
| 225 | h->commands_outstanding++; | 226 | h->commands_outstanding++; |
| 226 | if ( h->commands_outstanding > h->max_outstanding) | 227 | if ( h->commands_outstanding > h->max_outstanding) |
| 227 | h->max_outstanding = h->commands_outstanding; | 228 | h->max_outstanding = h->commands_outstanding; |
diff --git a/drivers/block/cciss_cmd.h b/drivers/block/cciss_cmd.h index 35463d2f0ee..cd441bef031 100644 --- a/drivers/block/cciss_cmd.h +++ b/drivers/block/cciss_cmd.h | |||
| @@ -56,6 +56,7 @@ | |||
| 56 | 56 | ||
| 57 | #define CFGTBL_Trans_Simple 0x00000002l | 57 | #define CFGTBL_Trans_Simple 0x00000002l |
| 58 | #define CFGTBL_Trans_Performant 0x00000004l | 58 | #define CFGTBL_Trans_Performant 0x00000004l |
| 59 | #define CFGTBL_Trans_use_short_tags 0x20000000l | ||
| 59 | 60 | ||
| 60 | #define CFGTBL_BusType_Ultra2 0x00000001l | 61 | #define CFGTBL_BusType_Ultra2 0x00000001l |
| 61 | #define CFGTBL_BusType_Ultra3 0x00000002l | 62 | #define CFGTBL_BusType_Ultra3 0x00000002l |
diff --git a/drivers/block/cciss_scsi.c b/drivers/block/cciss_scsi.c index 727d0225b7d..df793803f5a 100644 --- a/drivers/block/cciss_scsi.c +++ b/drivers/block/cciss_scsi.c | |||
| @@ -824,13 +824,18 @@ static void complete_scsi_command(CommandList_struct *c, int timeout, | |||
| 824 | break; | 824 | break; |
| 825 | case CMD_UNSOLICITED_ABORT: | 825 | case CMD_UNSOLICITED_ABORT: |
| 826 | cmd->result = DID_ABORT << 16; | 826 | cmd->result = DID_ABORT << 16; |
| 827 | dev_warn(&h->pdev->dev, "%p aborted do to an " | 827 | dev_warn(&h->pdev->dev, "%p aborted due to an " |
| 828 | "unsolicited abort\n", c); | 828 | "unsolicited abort\n", c); |
| 829 | break; | 829 | break; |
| 830 | case CMD_TIMEOUT: | 830 | case CMD_TIMEOUT: |
| 831 | cmd->result = DID_TIME_OUT << 16; | 831 | cmd->result = DID_TIME_OUT << 16; |
| 832 | dev_warn(&h->pdev->dev, "%p timedout\n", c); | 832 | dev_warn(&h->pdev->dev, "%p timedout\n", c); |
| 833 | break; | 833 | break; |
| 834 | case CMD_UNABORTABLE: | ||
| 835 | cmd->result = DID_ERROR << 16; | ||
| 836 | dev_warn(&h->pdev->dev, "c %p command " | ||
| 837 | "unabortable\n", c); | ||
| 838 | break; | ||
| 834 | default: | 839 | default: |
| 835 | cmd->result = DID_ERROR << 16; | 840 | cmd->result = DID_ERROR << 16; |
| 836 | dev_warn(&h->pdev->dev, | 841 | dev_warn(&h->pdev->dev, |
| @@ -1007,11 +1012,15 @@ cciss_scsi_interpret_error(ctlr_info_t *h, CommandList_struct *c) | |||
| 1007 | break; | 1012 | break; |
| 1008 | case CMD_UNSOLICITED_ABORT: | 1013 | case CMD_UNSOLICITED_ABORT: |
| 1009 | dev_warn(&h->pdev->dev, | 1014 | dev_warn(&h->pdev->dev, |
| 1010 | "%p aborted do to an unsolicited abort\n", c); | 1015 | "%p aborted due to an unsolicited abort\n", c); |
| 1011 | break; | 1016 | break; |
| 1012 | case CMD_TIMEOUT: | 1017 | case CMD_TIMEOUT: |
| 1013 | dev_warn(&h->pdev->dev, "%p timedout\n", c); | 1018 | dev_warn(&h->pdev->dev, "%p timedout\n", c); |
| 1014 | break; | 1019 | break; |
| 1020 | case CMD_UNABORTABLE: | ||
| 1021 | dev_warn(&h->pdev->dev, | ||
| 1022 | "%p unabortable\n", c); | ||
| 1023 | break; | ||
| 1015 | default: | 1024 | default: |
| 1016 | dev_warn(&h->pdev->dev, | 1025 | dev_warn(&h->pdev->dev, |
| 1017 | "%p returned unknown status %x\n", | 1026 | "%p returned unknown status %x\n", |
diff --git a/drivers/block/drbd/drbd_actlog.c b/drivers/block/drbd/drbd_actlog.c index aca302492ff..2a1642bc451 100644 --- a/drivers/block/drbd/drbd_actlog.c +++ b/drivers/block/drbd/drbd_actlog.c | |||
| @@ -92,7 +92,7 @@ static int _drbd_md_sync_page_io(struct drbd_conf *mdev, | |||
| 92 | bio->bi_end_io = drbd_md_io_complete; | 92 | bio->bi_end_io = drbd_md_io_complete; |
| 93 | bio->bi_rw = rw; | 93 | bio->bi_rw = rw; |
| 94 | 94 | ||
| 95 | if (FAULT_ACTIVE(mdev, (rw & WRITE) ? DRBD_FAULT_MD_WR : DRBD_FAULT_MD_RD)) | 95 | if (drbd_insert_fault(mdev, (rw & WRITE) ? DRBD_FAULT_MD_WR : DRBD_FAULT_MD_RD)) |
| 96 | bio_endio(bio, -EIO); | 96 | bio_endio(bio, -EIO); |
| 97 | else | 97 | else |
| 98 | submit_bio(rw, bio); | 98 | submit_bio(rw, bio); |
| @@ -176,13 +176,17 @@ static struct lc_element *_al_get(struct drbd_conf *mdev, unsigned int enr) | |||
| 176 | struct lc_element *al_ext; | 176 | struct lc_element *al_ext; |
| 177 | struct lc_element *tmp; | 177 | struct lc_element *tmp; |
| 178 | unsigned long al_flags = 0; | 178 | unsigned long al_flags = 0; |
| 179 | int wake; | ||
| 179 | 180 | ||
| 180 | spin_lock_irq(&mdev->al_lock); | 181 | spin_lock_irq(&mdev->al_lock); |
| 181 | tmp = lc_find(mdev->resync, enr/AL_EXT_PER_BM_SECT); | 182 | tmp = lc_find(mdev->resync, enr/AL_EXT_PER_BM_SECT); |
| 182 | if (unlikely(tmp != NULL)) { | 183 | if (unlikely(tmp != NULL)) { |
| 183 | struct bm_extent *bm_ext = lc_entry(tmp, struct bm_extent, lce); | 184 | struct bm_extent *bm_ext = lc_entry(tmp, struct bm_extent, lce); |
| 184 | if (test_bit(BME_NO_WRITES, &bm_ext->flags)) { | 185 | if (test_bit(BME_NO_WRITES, &bm_ext->flags)) { |
| 186 | wake = !test_and_set_bit(BME_PRIORITY, &bm_ext->flags); | ||
| 185 | spin_unlock_irq(&mdev->al_lock); | 187 | spin_unlock_irq(&mdev->al_lock); |
| 188 | if (wake) | ||
| 189 | wake_up(&mdev->al_wait); | ||
| 186 | return NULL; | 190 | return NULL; |
| 187 | } | 191 | } |
| 188 | } | 192 | } |
| @@ -258,6 +262,33 @@ void drbd_al_complete_io(struct drbd_conf *mdev, sector_t sector) | |||
| 258 | spin_unlock_irqrestore(&mdev->al_lock, flags); | 262 | spin_unlock_irqrestore(&mdev->al_lock, flags); |
| 259 | } | 263 | } |
| 260 | 264 | ||
| 265 | #if (PAGE_SHIFT + 3) < (AL_EXTENT_SHIFT - BM_BLOCK_SHIFT) | ||
| 266 | /* Currently BM_BLOCK_SHIFT, BM_EXT_SHIFT and AL_EXTENT_SHIFT | ||
| 267 | * are still coupled, or assume too much about their relation. | ||
| 268 | * Code below will not work if this is violated. | ||
| 269 | * Will be cleaned up with some followup patch. | ||
| 270 | */ | ||
| 271 | # error FIXME | ||
| 272 | #endif | ||
| 273 | |||
| 274 | static unsigned int al_extent_to_bm_page(unsigned int al_enr) | ||
| 275 | { | ||
| 276 | return al_enr >> | ||
| 277 | /* bit to page */ | ||
| 278 | ((PAGE_SHIFT + 3) - | ||
| 279 | /* al extent number to bit */ | ||
| 280 | (AL_EXTENT_SHIFT - BM_BLOCK_SHIFT)); | ||
| 281 | } | ||
| 282 | |||
| 283 | static unsigned int rs_extent_to_bm_page(unsigned int rs_enr) | ||
| 284 | { | ||
| 285 | return rs_enr >> | ||
| 286 | /* bit to page */ | ||
| 287 | ((PAGE_SHIFT + 3) - | ||
| 288 | /* al extent number to bit */ | ||
| 289 | (BM_EXT_SHIFT - BM_BLOCK_SHIFT)); | ||
| 290 | } | ||
| 291 | |||
| 261 | int | 292 | int |
| 262 | w_al_write_transaction(struct drbd_conf *mdev, struct drbd_work *w, int unused) | 293 | w_al_write_transaction(struct drbd_conf *mdev, struct drbd_work *w, int unused) |
| 263 | { | 294 | { |
| @@ -285,7 +316,7 @@ w_al_write_transaction(struct drbd_conf *mdev, struct drbd_work *w, int unused) | |||
| 285 | * For now, we must not write the transaction, | 316 | * For now, we must not write the transaction, |
| 286 | * if we cannot write out the bitmap of the evicted extent. */ | 317 | * if we cannot write out the bitmap of the evicted extent. */ |
| 287 | if (mdev->state.conn < C_CONNECTED && evicted != LC_FREE) | 318 | if (mdev->state.conn < C_CONNECTED && evicted != LC_FREE) |
| 288 | drbd_bm_write_sect(mdev, evicted/AL_EXT_PER_BM_SECT); | 319 | drbd_bm_write_page(mdev, al_extent_to_bm_page(evicted)); |
| 289 | 320 | ||
| 290 | /* The bitmap write may have failed, causing a state change. */ | 321 | /* The bitmap write may have failed, causing a state change. */ |
| 291 | if (mdev->state.disk < D_INCONSISTENT) { | 322 | if (mdev->state.disk < D_INCONSISTENT) { |
| @@ -334,7 +365,7 @@ w_al_write_transaction(struct drbd_conf *mdev, struct drbd_work *w, int unused) | |||
| 334 | + mdev->ldev->md.al_offset + mdev->al_tr_pos; | 365 | + mdev->ldev->md.al_offset + mdev->al_tr_pos; |
| 335 | 366 | ||
| 336 | if (!drbd_md_sync_page_io(mdev, mdev->ldev, sector, WRITE)) | 367 | if (!drbd_md_sync_page_io(mdev, mdev->ldev, sector, WRITE)) |
| 337 | drbd_chk_io_error(mdev, 1, TRUE); | 368 | drbd_chk_io_error(mdev, 1, true); |
| 338 | 369 | ||
| 339 | if (++mdev->al_tr_pos > | 370 | if (++mdev->al_tr_pos > |
| 340 | div_ceil(mdev->act_log->nr_elements, AL_EXTENTS_PT)) | 371 | div_ceil(mdev->act_log->nr_elements, AL_EXTENTS_PT)) |
| @@ -511,225 +542,6 @@ cancel: | |||
| 511 | return 1; | 542 | return 1; |
| 512 | } | 543 | } |
| 513 | 544 | ||
| 514 | static void atodb_endio(struct bio *bio, int error) | ||
| 515 | { | ||
| 516 | struct drbd_atodb_wait *wc = bio->bi_private; | ||
| 517 | struct drbd_conf *mdev = wc->mdev; | ||
| 518 | struct page *page; | ||
| 519 | int uptodate = bio_flagged(bio, BIO_UPTODATE); | ||
| 520 | |||
| 521 | /* strange behavior of some lower level drivers... | ||
| 522 | * fail the request by clearing the uptodate flag, | ||
| 523 | * but do not return any error?! */ | ||
| 524 | if (!error && !uptodate) | ||
| 525 | error = -EIO; | ||
| 526 | |||
| 527 | drbd_chk_io_error(mdev, error, TRUE); | ||
| 528 | if (error && wc->error == 0) | ||
| 529 | wc->error = error; | ||
| 530 | |||
| 531 | if (atomic_dec_and_test(&wc->count)) | ||
| 532 | complete(&wc->io_done); | ||
| 533 | |||
| 534 | page = bio->bi_io_vec[0].bv_page; | ||
| 535 | put_page(page); | ||
| 536 | bio_put(bio); | ||
| 537 | mdev->bm_writ_cnt++; | ||
| 538 | put_ldev(mdev); | ||
| 539 | } | ||
| 540 | |||
| 541 | /* sector to word */ | ||
| 542 | #define S2W(s) ((s)<<(BM_EXT_SHIFT-BM_BLOCK_SHIFT-LN2_BPL)) | ||
| 543 | |||
| 544 | /* activity log to on disk bitmap -- prepare bio unless that sector | ||
| 545 | * is already covered by previously prepared bios */ | ||
| 546 | static int atodb_prepare_unless_covered(struct drbd_conf *mdev, | ||
| 547 | struct bio **bios, | ||
| 548 | unsigned int enr, | ||
| 549 | struct drbd_atodb_wait *wc) __must_hold(local) | ||
| 550 | { | ||
| 551 | struct bio *bio; | ||
| 552 | struct page *page; | ||
| 553 | sector_t on_disk_sector; | ||
| 554 | unsigned int page_offset = PAGE_SIZE; | ||
| 555 | int offset; | ||
| 556 | int i = 0; | ||
| 557 | int err = -ENOMEM; | ||
| 558 | |||
| 559 | /* We always write aligned, full 4k blocks, | ||
| 560 | * so we can ignore the logical_block_size (for now) */ | ||
| 561 | enr &= ~7U; | ||
| 562 | on_disk_sector = enr + mdev->ldev->md.md_offset | ||
| 563 | + mdev->ldev->md.bm_offset; | ||
| 564 | |||
| 565 | D_ASSERT(!(on_disk_sector & 7U)); | ||
| 566 | |||
| 567 | /* Check if that enr is already covered by an already created bio. | ||
| 568 | * Caution, bios[] is not NULL terminated, | ||
| 569 | * but only initialized to all NULL. | ||
| 570 | * For completely scattered activity log, | ||
| 571 | * the last invocation iterates over all bios, | ||
| 572 | * and finds the last NULL entry. | ||
| 573 | */ | ||
| 574 | while ((bio = bios[i])) { | ||
| 575 | if (bio->bi_sector == on_disk_sector) | ||
| 576 | return 0; | ||
| 577 | i++; | ||
| 578 | } | ||
| 579 | /* bios[i] == NULL, the next not yet used slot */ | ||
| 580 | |||
| 581 | /* GFP_KERNEL, we are not in the write-out path */ | ||
| 582 | bio = bio_alloc(GFP_KERNEL, 1); | ||
| 583 | if (bio == NULL) | ||
| 584 | return -ENOMEM; | ||
| 585 | |||
| 586 | if (i > 0) { | ||
| 587 | const struct bio_vec *prev_bv = bios[i-1]->bi_io_vec; | ||
| 588 | page_offset = prev_bv->bv_offset + prev_bv->bv_len; | ||
| 589 | page = prev_bv->bv_page; | ||
| 590 | } | ||
| 591 | if (page_offset == PAGE_SIZE) { | ||
| 592 | page = alloc_page(__GFP_HIGHMEM); | ||
| 593 | if (page == NULL) | ||
| 594 | goto out_bio_put; | ||
| 595 | page_offset = 0; | ||
| 596 | } else { | ||
| 597 | get_page(page); | ||
| 598 | } | ||
| 599 | |||
| 600 | offset = S2W(enr); | ||
| 601 | drbd_bm_get_lel(mdev, offset, | ||
| 602 | min_t(size_t, S2W(8), drbd_bm_words(mdev) - offset), | ||
| 603 | kmap(page) + page_offset); | ||
| 604 | kunmap(page); | ||
| 605 | |||
| 606 | bio->bi_private = wc; | ||
| 607 | bio->bi_end_io = atodb_endio; | ||
| 608 | bio->bi_bdev = mdev->ldev->md_bdev; | ||
| 609 | bio->bi_sector = on_disk_sector; | ||
| 610 | |||
| 611 | if (bio_add_page(bio, page, 4096, page_offset) != 4096) | ||
| 612 | goto out_put_page; | ||
| 613 | |||
| 614 | atomic_inc(&wc->count); | ||
| 615 | /* we already know that we may do this... | ||
| 616 | * get_ldev_if_state(mdev,D_ATTACHING); | ||
| 617 | * just get the extra reference, so that the local_cnt reflects | ||
| 618 | * the number of pending IO requests DRBD at its backing device. | ||
| 619 | */ | ||
| 620 | atomic_inc(&mdev->local_cnt); | ||
| 621 | |||
| 622 | bios[i] = bio; | ||
| 623 | |||
| 624 | return 0; | ||
| 625 | |||
| 626 | out_put_page: | ||
| 627 | err = -EINVAL; | ||
| 628 | put_page(page); | ||
| 629 | out_bio_put: | ||
| 630 | bio_put(bio); | ||
| 631 | return err; | ||
| 632 | } | ||
| 633 | |||
| 634 | /** | ||
| 635 | * drbd_al_to_on_disk_bm() - * Writes bitmap parts covered by active AL extents | ||
| 636 | * @mdev: DRBD device. | ||
| 637 | * | ||
| 638 | * Called when we detach (unconfigure) local storage, | ||
| 639 | * or when we go from R_PRIMARY to R_SECONDARY role. | ||
| 640 | */ | ||
| 641 | void drbd_al_to_on_disk_bm(struct drbd_conf *mdev) | ||
| 642 | { | ||
| 643 | int i, nr_elements; | ||
| 644 | unsigned int enr; | ||
| 645 | struct bio **bios; | ||
| 646 | struct drbd_atodb_wait wc; | ||
| 647 | |||
| 648 | ERR_IF (!get_ldev_if_state(mdev, D_ATTACHING)) | ||
| 649 | return; /* sorry, I don't have any act_log etc... */ | ||
| 650 | |||
| 651 | wait_event(mdev->al_wait, lc_try_lock(mdev->act_log)); | ||
| 652 | |||
| 653 | nr_elements = mdev->act_log->nr_elements; | ||
| 654 | |||
| 655 | /* GFP_KERNEL, we are not in anyone's write-out path */ | ||
| 656 | bios = kzalloc(sizeof(struct bio *) * nr_elements, GFP_KERNEL); | ||
| 657 | if (!bios) | ||
| 658 | goto submit_one_by_one; | ||
| 659 | |||
| 660 | atomic_set(&wc.count, 0); | ||
| 661 | init_completion(&wc.io_done); | ||
| 662 | wc.mdev = mdev; | ||
| 663 | wc.error = 0; | ||
| 664 | |||
| 665 | for (i = 0; i < nr_elements; i++) { | ||
| 666 | enr = lc_element_by_index(mdev->act_log, i)->lc_number; | ||
| 667 | if (enr == LC_FREE) | ||
| 668 | continue; | ||
| 669 | /* next statement also does atomic_inc wc.count and local_cnt */ | ||
| 670 | if (atodb_prepare_unless_covered(mdev, bios, | ||
| 671 | enr/AL_EXT_PER_BM_SECT, | ||
| 672 | &wc)) | ||
| 673 | goto free_bios_submit_one_by_one; | ||
| 674 | } | ||
| 675 | |||
| 676 | /* unnecessary optimization? */ | ||
| 677 | lc_unlock(mdev->act_log); | ||
| 678 | wake_up(&mdev->al_wait); | ||
| 679 | |||
| 680 | /* all prepared, submit them */ | ||
| 681 | for (i = 0; i < nr_elements; i++) { | ||
| 682 | if (bios[i] == NULL) | ||
| 683 | break; | ||
| 684 | if (FAULT_ACTIVE(mdev, DRBD_FAULT_MD_WR)) { | ||
| 685 | bios[i]->bi_rw = WRITE; | ||
| 686 | bio_endio(bios[i], -EIO); | ||
| 687 | } else { | ||
| 688 | submit_bio(WRITE, bios[i]); | ||
| 689 | } | ||
| 690 | } | ||
| 691 | |||
| 692 | /* always (try to) flush bitmap to stable storage */ | ||
| 693 | drbd_md_flush(mdev); | ||
| 694 | |||
| 695 | /* In case we did not submit a single IO do not wait for | ||
| 696 | * them to complete. ( Because we would wait forever here. ) | ||
| 697 | * | ||
| 698 | * In case we had IOs and they are already complete, there | ||
| 699 | * is not point in waiting anyways. | ||
| 700 | * Therefore this if () ... */ | ||
| 701 | if (atomic_read(&wc.count)) | ||
| 702 | wait_for_completion(&wc.io_done); | ||
| 703 | |||
| 704 | put_ldev(mdev); | ||
| 705 | |||
| 706 | kfree(bios); | ||
| 707 | return; | ||
| 708 | |||
| 709 | free_bios_submit_one_by_one: | ||
| 710 | /* free everything by calling the endio callback directly. */ | ||
| 711 | for (i = 0; i < nr_elements && bios[i]; i++) | ||
| 712 | bio_endio(bios[i], 0); | ||
| 713 | |||
| 714 | kfree(bios); | ||
| 715 | |||
| 716 | submit_one_by_one: | ||
| 717 | dev_warn(DEV, "Using the slow drbd_al_to_on_disk_bm()\n"); | ||
| 718 | |||
| 719 | for (i = 0; i < mdev->act_log->nr_elements; i++) { | ||
| 720 | enr = lc_element_by_index(mdev->act_log, i)->lc_number; | ||
| 721 | if (enr == LC_FREE) | ||
| 722 | continue; | ||
| 723 | /* Really slow: if we have al-extents 16..19 active, | ||
| 724 | * sector 4 will be written four times! Synchronous! */ | ||
| 725 | drbd_bm_write_sect(mdev, enr/AL_EXT_PER_BM_SECT); | ||
| 726 | } | ||
| 727 | |||
| 728 | lc_unlock(mdev->act_log); | ||
| 729 | wake_up(&mdev->al_wait); | ||
| 730 | put_ldev(mdev); | ||
| 731 | } | ||
| 732 | |||
| 733 | /** | 545 | /** |
| 734 | * drbd_al_apply_to_bm() - Sets the bitmap to diry(1) where covered ba active AL extents | 546 | * drbd_al_apply_to_bm() - Sets the bitmap to diry(1) where covered ba active AL extents |
| 735 | * @mdev: DRBD device. | 547 | * @mdev: DRBD device. |
| @@ -809,7 +621,7 @@ static int w_update_odbm(struct drbd_conf *mdev, struct drbd_work *w, int unused | |||
| 809 | return 1; | 621 | return 1; |
| 810 | } | 622 | } |
| 811 | 623 | ||
| 812 | drbd_bm_write_sect(mdev, udw->enr); | 624 | drbd_bm_write_page(mdev, rs_extent_to_bm_page(udw->enr)); |
| 813 | put_ldev(mdev); | 625 | put_ldev(mdev); |
| 814 | 626 | ||
| 815 | kfree(udw); | 627 | kfree(udw); |
| @@ -889,7 +701,6 @@ static void drbd_try_clear_on_disk_bm(struct drbd_conf *mdev, sector_t sector, | |||
| 889 | dev_warn(DEV, "Kicking resync_lru element enr=%u " | 701 | dev_warn(DEV, "Kicking resync_lru element enr=%u " |
| 890 | "out with rs_failed=%d\n", | 702 | "out with rs_failed=%d\n", |
| 891 | ext->lce.lc_number, ext->rs_failed); | 703 | ext->lce.lc_number, ext->rs_failed); |
| 892 | set_bit(WRITE_BM_AFTER_RESYNC, &mdev->flags); | ||
| 893 | } | 704 | } |
| 894 | ext->rs_left = rs_left; | 705 | ext->rs_left = rs_left; |
| 895 | ext->rs_failed = success ? 0 : count; | 706 | ext->rs_failed = success ? 0 : count; |
| @@ -908,7 +719,6 @@ static void drbd_try_clear_on_disk_bm(struct drbd_conf *mdev, sector_t sector, | |||
| 908 | drbd_queue_work_front(&mdev->data.work, &udw->w); | 719 | drbd_queue_work_front(&mdev->data.work, &udw->w); |
| 909 | } else { | 720 | } else { |
| 910 | dev_warn(DEV, "Could not kmalloc an udw\n"); | 721 | dev_warn(DEV, "Could not kmalloc an udw\n"); |
| 911 | set_bit(WRITE_BM_AFTER_RESYNC, &mdev->flags); | ||
| 912 | } | 722 | } |
| 913 | } | 723 | } |
| 914 | } else { | 724 | } else { |
| @@ -919,6 +729,22 @@ static void drbd_try_clear_on_disk_bm(struct drbd_conf *mdev, sector_t sector, | |||
| 919 | } | 729 | } |
| 920 | } | 730 | } |
| 921 | 731 | ||
| 732 | void drbd_advance_rs_marks(struct drbd_conf *mdev, unsigned long still_to_go) | ||
| 733 | { | ||
| 734 | unsigned long now = jiffies; | ||
| 735 | unsigned long last = mdev->rs_mark_time[mdev->rs_last_mark]; | ||
| 736 | int next = (mdev->rs_last_mark + 1) % DRBD_SYNC_MARKS; | ||
| 737 | if (time_after_eq(now, last + DRBD_SYNC_MARK_STEP)) { | ||
| 738 | if (mdev->rs_mark_left[mdev->rs_last_mark] != still_to_go && | ||
| 739 | mdev->state.conn != C_PAUSED_SYNC_T && | ||
| 740 | mdev->state.conn != C_PAUSED_SYNC_S) { | ||
| 741 | mdev->rs_mark_time[next] = now; | ||
| 742 | mdev->rs_mark_left[next] = still_to_go; | ||
| 743 | mdev->rs_last_mark = next; | ||
| 744 | } | ||
| 745 | } | ||
| 746 | } | ||
| 747 | |||
| 922 | /* clear the bit corresponding to the piece of storage in question: | 748 | /* clear the bit corresponding to the piece of storage in question: |
| 923 | * size byte of data starting from sector. Only clear a bits of the affected | 749 | * size byte of data starting from sector. Only clear a bits of the affected |
| 924 | * one ore more _aligned_ BM_BLOCK_SIZE blocks. | 750 | * one ore more _aligned_ BM_BLOCK_SIZE blocks. |
| @@ -936,7 +762,7 @@ void __drbd_set_in_sync(struct drbd_conf *mdev, sector_t sector, int size, | |||
| 936 | int wake_up = 0; | 762 | int wake_up = 0; |
| 937 | unsigned long flags; | 763 | unsigned long flags; |
| 938 | 764 | ||
| 939 | if (size <= 0 || (size & 0x1ff) != 0 || size > DRBD_MAX_SEGMENT_SIZE) { | 765 | if (size <= 0 || (size & 0x1ff) != 0 || size > DRBD_MAX_BIO_SIZE) { |
| 940 | dev_err(DEV, "drbd_set_in_sync: sector=%llus size=%d nonsense!\n", | 766 | dev_err(DEV, "drbd_set_in_sync: sector=%llus size=%d nonsense!\n", |
| 941 | (unsigned long long)sector, size); | 767 | (unsigned long long)sector, size); |
| 942 | return; | 768 | return; |
| @@ -969,21 +795,9 @@ void __drbd_set_in_sync(struct drbd_conf *mdev, sector_t sector, int size, | |||
| 969 | */ | 795 | */ |
| 970 | count = drbd_bm_clear_bits(mdev, sbnr, ebnr); | 796 | count = drbd_bm_clear_bits(mdev, sbnr, ebnr); |
| 971 | if (count && get_ldev(mdev)) { | 797 | if (count && get_ldev(mdev)) { |
| 972 | unsigned long now = jiffies; | 798 | drbd_advance_rs_marks(mdev, drbd_bm_total_weight(mdev)); |
| 973 | unsigned long last = mdev->rs_mark_time[mdev->rs_last_mark]; | ||
| 974 | int next = (mdev->rs_last_mark + 1) % DRBD_SYNC_MARKS; | ||
| 975 | if (time_after_eq(now, last + DRBD_SYNC_MARK_STEP)) { | ||
| 976 | unsigned long tw = drbd_bm_total_weight(mdev); | ||
| 977 | if (mdev->rs_mark_left[mdev->rs_last_mark] != tw && | ||
| 978 | mdev->state.conn != C_PAUSED_SYNC_T && | ||
| 979 | mdev->state.conn != C_PAUSED_SYNC_S) { | ||
| 980 | mdev->rs_mark_time[next] = now; | ||
| 981 | mdev->rs_mark_left[next] = tw; | ||
| 982 | mdev->rs_last_mark = next; | ||
| 983 | } | ||
| 984 | } | ||
| 985 | spin_lock_irqsave(&mdev->al_lock, flags); | 799 | spin_lock_irqsave(&mdev->al_lock, flags); |
| 986 | drbd_try_clear_on_disk_bm(mdev, sector, count, TRUE); | 800 | drbd_try_clear_on_disk_bm(mdev, sector, count, true); |
| 987 | spin_unlock_irqrestore(&mdev->al_lock, flags); | 801 | spin_unlock_irqrestore(&mdev->al_lock, flags); |
| 988 | 802 | ||
| 989 | /* just wake_up unconditional now, various lc_chaged(), | 803 | /* just wake_up unconditional now, various lc_chaged(), |
| @@ -998,27 +812,27 @@ void __drbd_set_in_sync(struct drbd_conf *mdev, sector_t sector, int size, | |||
| 998 | /* | 812 | /* |
| 999 | * this is intended to set one request worth of data out of sync. | 813 | * this is intended to set one request worth of data out of sync. |
| 1000 | * affects at least 1 bit, | 814 | * affects at least 1 bit, |
| 1001 | * and at most 1+DRBD_MAX_SEGMENT_SIZE/BM_BLOCK_SIZE bits. | 815 | * and at most 1+DRBD_MAX_BIO_SIZE/BM_BLOCK_SIZE bits. |
| 1002 | * | 816 | * |
| 1003 | * called by tl_clear and drbd_send_dblock (==drbd_make_request). | 817 | * called by tl_clear and drbd_send_dblock (==drbd_make_request). |
| 1004 | * so this can be _any_ process. | 818 | * so this can be _any_ process. |
| 1005 | */ | 819 | */ |
| 1006 | void __drbd_set_out_of_sync(struct drbd_conf *mdev, sector_t sector, int size, | 820 | int __drbd_set_out_of_sync(struct drbd_conf *mdev, sector_t sector, int size, |
| 1007 | const char *file, const unsigned int line) | 821 | const char *file, const unsigned int line) |
| 1008 | { | 822 | { |
| 1009 | unsigned long sbnr, ebnr, lbnr, flags; | 823 | unsigned long sbnr, ebnr, lbnr, flags; |
| 1010 | sector_t esector, nr_sectors; | 824 | sector_t esector, nr_sectors; |
| 1011 | unsigned int enr, count; | 825 | unsigned int enr, count = 0; |
| 1012 | struct lc_element *e; | 826 | struct lc_element *e; |
| 1013 | 827 | ||
| 1014 | if (size <= 0 || (size & 0x1ff) != 0 || size > DRBD_MAX_SEGMENT_SIZE) { | 828 | if (size <= 0 || (size & 0x1ff) != 0 || size > DRBD_MAX_BIO_SIZE) { |
| 1015 | dev_err(DEV, "sector: %llus, size: %d\n", | 829 | dev_err(DEV, "sector: %llus, size: %d\n", |
| 1016 | (unsigned long long)sector, size); | 830 | (unsigned long long)sector, size); |
| 1017 | return; | 831 | return 0; |
| 1018 | } | 832 | } |
| 1019 | 833 | ||
| 1020 | if (!get_ldev(mdev)) | 834 | if (!get_ldev(mdev)) |
| 1021 | return; /* no disk, no metadata, no bitmap to set bits in */ | 835 | return 0; /* no disk, no metadata, no bitmap to set bits in */ |
| 1022 | 836 | ||
| 1023 | nr_sectors = drbd_get_capacity(mdev->this_bdev); | 837 | nr_sectors = drbd_get_capacity(mdev->this_bdev); |
| 1024 | esector = sector + (size >> 9) - 1; | 838 | esector = sector + (size >> 9) - 1; |
| @@ -1048,6 +862,8 @@ void __drbd_set_out_of_sync(struct drbd_conf *mdev, sector_t sector, int size, | |||
| 1048 | 862 | ||
| 1049 | out: | 863 | out: |
| 1050 | put_ldev(mdev); | 864 | put_ldev(mdev); |
| 865 | |||
| 866 | return count; | ||
| 1051 | } | 867 | } |
| 1052 | 868 | ||
| 1053 | static | 869 | static |
| @@ -1128,7 +944,10 @@ int drbd_rs_begin_io(struct drbd_conf *mdev, sector_t sector) | |||
| 1128 | unsigned int enr = BM_SECT_TO_EXT(sector); | 944 | unsigned int enr = BM_SECT_TO_EXT(sector); |
| 1129 | struct bm_extent *bm_ext; | 945 | struct bm_extent *bm_ext; |
| 1130 | int i, sig; | 946 | int i, sig; |
| 947 | int sa = 200; /* Step aside 200 times, then grab the extent and let app-IO wait. | ||
| 948 | 200 times -> 20 seconds. */ | ||
| 1131 | 949 | ||
| 950 | retry: | ||
| 1132 | sig = wait_event_interruptible(mdev->al_wait, | 951 | sig = wait_event_interruptible(mdev->al_wait, |
| 1133 | (bm_ext = _bme_get(mdev, enr))); | 952 | (bm_ext = _bme_get(mdev, enr))); |
| 1134 | if (sig) | 953 | if (sig) |
| @@ -1139,16 +958,25 @@ int drbd_rs_begin_io(struct drbd_conf *mdev, sector_t sector) | |||
| 1139 | 958 | ||
| 1140 | for (i = 0; i < AL_EXT_PER_BM_SECT; i++) { | 959 | for (i = 0; i < AL_EXT_PER_BM_SECT; i++) { |
| 1141 | sig = wait_event_interruptible(mdev->al_wait, | 960 | sig = wait_event_interruptible(mdev->al_wait, |
| 1142 | !_is_in_al(mdev, enr * AL_EXT_PER_BM_SECT + i)); | 961 | !_is_in_al(mdev, enr * AL_EXT_PER_BM_SECT + i) || |
| 1143 | if (sig) { | 962 | test_bit(BME_PRIORITY, &bm_ext->flags)); |
| 963 | |||
| 964 | if (sig || (test_bit(BME_PRIORITY, &bm_ext->flags) && sa)) { | ||
| 1144 | spin_lock_irq(&mdev->al_lock); | 965 | spin_lock_irq(&mdev->al_lock); |
| 1145 | if (lc_put(mdev->resync, &bm_ext->lce) == 0) { | 966 | if (lc_put(mdev->resync, &bm_ext->lce) == 0) { |
| 1146 | clear_bit(BME_NO_WRITES, &bm_ext->flags); | 967 | bm_ext->flags = 0; /* clears BME_NO_WRITES and eventually BME_PRIORITY */ |
| 1147 | mdev->resync_locked--; | 968 | mdev->resync_locked--; |
| 1148 | wake_up(&mdev->al_wait); | 969 | wake_up(&mdev->al_wait); |
| 1149 | } | 970 | } |
| 1150 | spin_unlock_irq(&mdev->al_lock); | 971 | spin_unlock_irq(&mdev->al_lock); |
| 1151 | return -EINTR; | 972 | if (sig) |
| 973 | return -EINTR; | ||
| 974 | if (schedule_timeout_interruptible(HZ/10)) | ||
| 975 | return -EINTR; | ||
| 976 | if (sa && --sa == 0) | ||
| 977 | dev_warn(DEV,"drbd_rs_begin_io() stepped aside for 20sec." | ||
| 978 | "Resync stalled?\n"); | ||
| 979 | goto retry; | ||
| 1152 | } | 980 | } |
| 1153 | } | 981 | } |
| 1154 | set_bit(BME_LOCKED, &bm_ext->flags); | 982 | set_bit(BME_LOCKED, &bm_ext->flags); |
| @@ -1291,8 +1119,7 @@ void drbd_rs_complete_io(struct drbd_conf *mdev, sector_t sector) | |||
| 1291 | } | 1119 | } |
| 1292 | 1120 | ||
| 1293 | if (lc_put(mdev->resync, &bm_ext->lce) == 0) { | 1121 | if (lc_put(mdev->resync, &bm_ext->lce) == 0) { |
| 1294 | clear_bit(BME_LOCKED, &bm_ext->flags); | 1122 | bm_ext->flags = 0; /* clear BME_LOCKED, BME_NO_WRITES and BME_PRIORITY */ |
| 1295 | clear_bit(BME_NO_WRITES, &bm_ext->flags); | ||
| 1296 | mdev->resync_locked--; | 1123 | mdev->resync_locked--; |
| 1297 | wake_up(&mdev->al_wait); | 1124 | wake_up(&mdev->al_wait); |
| 1298 | } | 1125 | } |
| @@ -1383,7 +1210,7 @@ void drbd_rs_failed_io(struct drbd_conf *mdev, sector_t sector, int size) | |||
| 1383 | sector_t esector, nr_sectors; | 1210 | sector_t esector, nr_sectors; |
| 1384 | int wake_up = 0; | 1211 | int wake_up = 0; |
| 1385 | 1212 | ||
| 1386 | if (size <= 0 || (size & 0x1ff) != 0 || size > DRBD_MAX_SEGMENT_SIZE) { | 1213 | if (size <= 0 || (size & 0x1ff) != 0 || size > DRBD_MAX_BIO_SIZE) { |
| 1387 | dev_err(DEV, "drbd_rs_failed_io: sector=%llus size=%d nonsense!\n", | 1214 | dev_err(DEV, "drbd_rs_failed_io: sector=%llus size=%d nonsense!\n", |
| 1388 | (unsigned long long)sector, size); | 1215 | (unsigned long long)sector, size); |
| 1389 | return; | 1216 | return; |
| @@ -1420,7 +1247,7 @@ void drbd_rs_failed_io(struct drbd_conf *mdev, sector_t sector, int size) | |||
| 1420 | mdev->rs_failed += count; | 1247 | mdev->rs_failed += count; |
| 1421 | 1248 | ||
| 1422 | if (get_ldev(mdev)) { | 1249 | if (get_ldev(mdev)) { |
| 1423 | drbd_try_clear_on_disk_bm(mdev, sector, count, FALSE); | 1250 | drbd_try_clear_on_disk_bm(mdev, sector, count, false); |
| 1424 | put_ldev(mdev); | 1251 | put_ldev(mdev); |
| 1425 | } | 1252 | } |
| 1426 | 1253 | ||
diff --git a/drivers/block/drbd/drbd_bitmap.c b/drivers/block/drbd/drbd_bitmap.c index 0645ca829a9..76210ba401a 100644 --- a/drivers/block/drbd/drbd_bitmap.c +++ b/drivers/block/drbd/drbd_bitmap.c | |||
| @@ -28,18 +28,56 @@ | |||
| 28 | #include <linux/drbd.h> | 28 | #include <linux/drbd.h> |
| 29 | #include <linux/slab.h> | 29 | #include <linux/slab.h> |
| 30 | #include <asm/kmap_types.h> | 30 | #include <asm/kmap_types.h> |
| 31 | |||
| 31 | #include "drbd_int.h" | 32 | #include "drbd_int.h" |
| 32 | 33 | ||
| 34 | |||
| 33 | /* OPAQUE outside this file! | 35 | /* OPAQUE outside this file! |
| 34 | * interface defined in drbd_int.h | 36 | * interface defined in drbd_int.h |
| 35 | 37 | ||
| 36 | * convention: | 38 | * convention: |
| 37 | * function name drbd_bm_... => used elsewhere, "public". | 39 | * function name drbd_bm_... => used elsewhere, "public". |
| 38 | * function name bm_... => internal to implementation, "private". | 40 | * function name bm_... => internal to implementation, "private". |
| 41 | */ | ||
| 39 | 42 | ||
| 40 | * Note that since find_first_bit returns int, at the current granularity of | 43 | |
| 41 | * the bitmap (4KB per byte), this implementation "only" supports up to | 44 | /* |
| 42 | * 1<<(32+12) == 16 TB... | 45 | * LIMITATIONS: |
| 46 | * We want to support >= peta byte of backend storage, while for now still using | ||
| 47 | * a granularity of one bit per 4KiB of storage. | ||
| 48 | * 1 << 50 bytes backend storage (1 PiB) | ||
| 49 | * 1 << (50 - 12) bits needed | ||
| 50 | * 38 --> we need u64 to index and count bits | ||
| 51 | * 1 << (38 - 3) bitmap bytes needed | ||
| 52 | * 35 --> we still need u64 to index and count bytes | ||
| 53 | * (that's 32 GiB of bitmap for 1 PiB storage) | ||
| 54 | * 1 << (35 - 2) 32bit longs needed | ||
| 55 | * 33 --> we'd even need u64 to index and count 32bit long words. | ||
| 56 | * 1 << (35 - 3) 64bit longs needed | ||
| 57 | * 32 --> we could get away with a 32bit unsigned int to index and count | ||
| 58 | * 64bit long words, but I rather stay with unsigned long for now. | ||
| 59 | * We probably should neither count nor point to bytes or long words | ||
| 60 | * directly, but either by bitnumber, or by page index and offset. | ||
| 61 | * 1 << (35 - 12) | ||
| 62 | * 22 --> we need that much 4KiB pages of bitmap. | ||
| 63 | * 1 << (22 + 3) --> on a 64bit arch, | ||
| 64 | * we need 32 MiB to store the array of page pointers. | ||
| 65 | * | ||
| 66 | * Because I'm lazy, and because the resulting patch was too large, too ugly | ||
| 67 | * and still incomplete, on 32bit we still "only" support 16 TiB (minus some), | ||
| 68 | * (1 << 32) bits * 4k storage. | ||
| 69 | * | ||
| 70 | |||
| 71 | * bitmap storage and IO: | ||
| 72 | * Bitmap is stored little endian on disk, and is kept little endian in | ||
| 73 | * core memory. Currently we still hold the full bitmap in core as long | ||
| 74 | * as we are "attached" to a local disk, which at 32 GiB for 1PiB storage | ||
| 75 | * seems excessive. | ||
| 76 | * | ||
| 77 | * We plan to reduce the amount of in-core bitmap pages by pageing them in | ||
| 78 | * and out against their on-disk location as necessary, but need to make | ||
| 79 | * sure we don't cause too much meta data IO, and must not deadlock in | ||
| 80 | * tight memory situations. This needs some more work. | ||
| 43 | */ | 81 | */ |
| 44 | 82 | ||
| 45 | /* | 83 | /* |
| @@ -55,13 +93,9 @@ | |||
| 55 | struct drbd_bitmap { | 93 | struct drbd_bitmap { |
| 56 | struct page **bm_pages; | 94 | struct page **bm_pages; |
| 57 | spinlock_t bm_lock; | 95 | spinlock_t bm_lock; |
| 58 | /* WARNING unsigned long bm_*: | 96 | |
| 59 | * 32bit number of bit offset is just enough for 512 MB bitmap. | 97 | /* see LIMITATIONS: above */ |
| 60 | * it will blow up if we make the bitmap bigger... | 98 | |
| 61 | * not that it makes much sense to have a bitmap that large, | ||
| 62 | * rather change the granularity to 16k or 64k or something. | ||
| 63 | * (that implies other problems, however...) | ||
| 64 | */ | ||
| 65 | unsigned long bm_set; /* nr of set bits; THINK maybe atomic_t? */ | 99 | unsigned long bm_set; /* nr of set bits; THINK maybe atomic_t? */ |
| 66 | unsigned long bm_bits; | 100 | unsigned long bm_bits; |
| 67 | size_t bm_words; | 101 | size_t bm_words; |
| @@ -69,29 +103,18 @@ struct drbd_bitmap { | |||
| 69 | sector_t bm_dev_capacity; | 103 | sector_t bm_dev_capacity; |
| 70 | struct mutex bm_change; /* serializes resize operations */ | 104 | struct mutex bm_change; /* serializes resize operations */ |
| 71 | 105 | ||
| 72 | atomic_t bm_async_io; | 106 | wait_queue_head_t bm_io_wait; /* used to serialize IO of single pages */ |
| 73 | wait_queue_head_t bm_io_wait; | ||
| 74 | 107 | ||
| 75 | unsigned long bm_flags; | 108 | enum bm_flag bm_flags; |
| 76 | 109 | ||
| 77 | /* debugging aid, in case we are still racy somewhere */ | 110 | /* debugging aid, in case we are still racy somewhere */ |
| 78 | char *bm_why; | 111 | char *bm_why; |
| 79 | struct task_struct *bm_task; | 112 | struct task_struct *bm_task; |
| 80 | }; | 113 | }; |
| 81 | 114 | ||
| 82 | /* definition of bits in bm_flags */ | ||
| 83 | #define BM_LOCKED 0 | ||
| 84 | #define BM_MD_IO_ERROR 1 | ||
| 85 | #define BM_P_VMALLOCED 2 | ||
| 86 | |||
| 87 | static int __bm_change_bits_to(struct drbd_conf *mdev, const unsigned long s, | 115 | static int __bm_change_bits_to(struct drbd_conf *mdev, const unsigned long s, |
| 88 | unsigned long e, int val, const enum km_type km); | 116 | unsigned long e, int val, const enum km_type km); |
| 89 | 117 | ||
| 90 | static int bm_is_locked(struct drbd_bitmap *b) | ||
| 91 | { | ||
| 92 | return test_bit(BM_LOCKED, &b->bm_flags); | ||
| 93 | } | ||
| 94 | |||
| 95 | #define bm_print_lock_info(m) __bm_print_lock_info(m, __func__) | 118 | #define bm_print_lock_info(m) __bm_print_lock_info(m, __func__) |
| 96 | static void __bm_print_lock_info(struct drbd_conf *mdev, const char *func) | 119 | static void __bm_print_lock_info(struct drbd_conf *mdev, const char *func) |
| 97 | { | 120 | { |
| @@ -108,7 +131,7 @@ static void __bm_print_lock_info(struct drbd_conf *mdev, const char *func) | |||
| 108 | b->bm_task == mdev->worker.task ? "worker" : "?"); | 131 | b->bm_task == mdev->worker.task ? "worker" : "?"); |
| 109 | } | 132 | } |
| 110 | 133 | ||
| 111 | void drbd_bm_lock(struct drbd_conf *mdev, char *why) | 134 | void drbd_bm_lock(struct drbd_conf *mdev, char *why, enum bm_flag flags) |
| 112 | { | 135 | { |
| 113 | struct drbd_bitmap *b = mdev->bitmap; | 136 | struct drbd_bitmap *b = mdev->bitmap; |
| 114 | int trylock_failed; | 137 | int trylock_failed; |
| @@ -131,8 +154,9 @@ void drbd_bm_lock(struct drbd_conf *mdev, char *why) | |||
| 131 | b->bm_task == mdev->worker.task ? "worker" : "?"); | 154 | b->bm_task == mdev->worker.task ? "worker" : "?"); |
| 132 | mutex_lock(&b->bm_change); | 155 | mutex_lock(&b->bm_change); |
| 133 | } | 156 | } |
| 134 | if (__test_and_set_bit(BM_LOCKED, &b->bm_flags)) | 157 | if (BM_LOCKED_MASK & b->bm_flags) |
| 135 | dev_err(DEV, "FIXME bitmap already locked in bm_lock\n"); | 158 | dev_err(DEV, "FIXME bitmap already locked in bm_lock\n"); |
| 159 | b->bm_flags |= flags & BM_LOCKED_MASK; | ||
| 136 | 160 | ||
| 137 | b->bm_why = why; | 161 | b->bm_why = why; |
| 138 | b->bm_task = current; | 162 | b->bm_task = current; |
| @@ -146,31 +170,137 @@ void drbd_bm_unlock(struct drbd_conf *mdev) | |||
| 146 | return; | 170 | return; |
| 147 | } | 171 | } |
| 148 | 172 | ||
| 149 | if (!__test_and_clear_bit(BM_LOCKED, &mdev->bitmap->bm_flags)) | 173 | if (!(BM_LOCKED_MASK & mdev->bitmap->bm_flags)) |
| 150 | dev_err(DEV, "FIXME bitmap not locked in bm_unlock\n"); | 174 | dev_err(DEV, "FIXME bitmap not locked in bm_unlock\n"); |
| 151 | 175 | ||
| 176 | b->bm_flags &= ~BM_LOCKED_MASK; | ||
| 152 | b->bm_why = NULL; | 177 | b->bm_why = NULL; |
| 153 | b->bm_task = NULL; | 178 | b->bm_task = NULL; |
| 154 | mutex_unlock(&b->bm_change); | 179 | mutex_unlock(&b->bm_change); |
| 155 | } | 180 | } |
| 156 | 181 | ||
| 157 | /* word offset to long pointer */ | 182 | /* we store some "meta" info about our pages in page->private */ |
| 158 | static unsigned long *__bm_map_paddr(struct drbd_bitmap *b, unsigned long offset, const enum km_type km) | 183 | /* at a granularity of 4k storage per bitmap bit: |
| 184 | * one peta byte storage: 1<<50 byte, 1<<38 * 4k storage blocks | ||
| 185 | * 1<<38 bits, | ||
| 186 | * 1<<23 4k bitmap pages. | ||
| 187 | * Use 24 bits as page index, covers 2 peta byte storage | ||
| 188 | * at a granularity of 4k per bit. | ||
| 189 | * Used to report the failed page idx on io error from the endio handlers. | ||
| 190 | */ | ||
| 191 | #define BM_PAGE_IDX_MASK ((1UL<<24)-1) | ||
| 192 | /* this page is currently read in, or written back */ | ||
| 193 | #define BM_PAGE_IO_LOCK 31 | ||
| 194 | /* if there has been an IO error for this page */ | ||
| 195 | #define BM_PAGE_IO_ERROR 30 | ||
| 196 | /* this is to be able to intelligently skip disk IO, | ||
| 197 | * set if bits have been set since last IO. */ | ||
| 198 | #define BM_PAGE_NEED_WRITEOUT 29 | ||
| 199 | /* to mark for lazy writeout once syncer cleared all clearable bits, | ||
| 200 | * we if bits have been cleared since last IO. */ | ||
| 201 | #define BM_PAGE_LAZY_WRITEOUT 28 | ||
| 202 | |||
| 203 | /* store_page_idx uses non-atomic assingment. It is only used directly after | ||
| 204 | * allocating the page. All other bm_set_page_* and bm_clear_page_* need to | ||
| 205 | * use atomic bit manipulation, as set_out_of_sync (and therefore bitmap | ||
| 206 | * changes) may happen from various contexts, and wait_on_bit/wake_up_bit | ||
| 207 | * requires it all to be atomic as well. */ | ||
| 208 | static void bm_store_page_idx(struct page *page, unsigned long idx) | ||
| 209 | { | ||
| 210 | BUG_ON(0 != (idx & ~BM_PAGE_IDX_MASK)); | ||
| 211 | page_private(page) |= idx; | ||
| 212 | } | ||
| 213 | |||
| 214 | static unsigned long bm_page_to_idx(struct page *page) | ||
| 159 | { | 215 | { |
| 160 | struct page *page; | 216 | return page_private(page) & BM_PAGE_IDX_MASK; |
| 161 | unsigned long page_nr; | 217 | } |
| 218 | |||
| 219 | /* As is very unlikely that the same page is under IO from more than one | ||
| 220 | * context, we can get away with a bit per page and one wait queue per bitmap. | ||
| 221 | */ | ||
| 222 | static void bm_page_lock_io(struct drbd_conf *mdev, int page_nr) | ||
| 223 | { | ||
| 224 | struct drbd_bitmap *b = mdev->bitmap; | ||
| 225 | void *addr = &page_private(b->bm_pages[page_nr]); | ||
| 226 | wait_event(b->bm_io_wait, !test_and_set_bit(BM_PAGE_IO_LOCK, addr)); | ||
| 227 | } | ||
| 228 | |||
| 229 | static void bm_page_unlock_io(struct drbd_conf *mdev, int page_nr) | ||
| 230 | { | ||
| 231 | struct drbd_bitmap *b = mdev->bitmap; | ||
| 232 | void *addr = &page_private(b->bm_pages[page_nr]); | ||
| 233 | clear_bit(BM_PAGE_IO_LOCK, addr); | ||
| 234 | smp_mb__after_clear_bit(); | ||
| 235 | wake_up(&mdev->bitmap->bm_io_wait); | ||
| 236 | } | ||
| 237 | |||
| 238 | /* set _before_ submit_io, so it may be reset due to being changed | ||
| 239 | * while this page is in flight... will get submitted later again */ | ||
| 240 | static void bm_set_page_unchanged(struct page *page) | ||
| 241 | { | ||
| 242 | /* use cmpxchg? */ | ||
| 243 | clear_bit(BM_PAGE_NEED_WRITEOUT, &page_private(page)); | ||
| 244 | clear_bit(BM_PAGE_LAZY_WRITEOUT, &page_private(page)); | ||
| 245 | } | ||
| 162 | 246 | ||
| 247 | static void bm_set_page_need_writeout(struct page *page) | ||
| 248 | { | ||
| 249 | set_bit(BM_PAGE_NEED_WRITEOUT, &page_private(page)); | ||
| 250 | } | ||
| 251 | |||
| 252 | static int bm_test_page_unchanged(struct page *page) | ||
| 253 | { | ||
| 254 | volatile const unsigned long *addr = &page_private(page); | ||
| 255 | return (*addr & ((1UL<<BM_PAGE_NEED_WRITEOUT)|(1UL<<BM_PAGE_LAZY_WRITEOUT))) == 0; | ||
| 256 | } | ||
| 257 | |||
| 258 | static void bm_set_page_io_err(struct page *page) | ||
| 259 | { | ||
| 260 | set_bit(BM_PAGE_IO_ERROR, &page_private(page)); | ||
| 261 | } | ||
| 262 | |||
| 263 | static void bm_clear_page_io_err(struct page *page) | ||
| 264 | { | ||
| 265 | clear_bit(BM_PAGE_IO_ERROR, &page_private(page)); | ||
| 266 | } | ||
| 267 | |||
| 268 | static void bm_set_page_lazy_writeout(struct page *page) | ||
| 269 | { | ||
| 270 | set_bit(BM_PAGE_LAZY_WRITEOUT, &page_private(page)); | ||
| 271 | } | ||
| 272 | |||
| 273 | static int bm_test_page_lazy_writeout(struct page *page) | ||
| 274 | { | ||
| 275 | return test_bit(BM_PAGE_LAZY_WRITEOUT, &page_private(page)); | ||
| 276 | } | ||
| 277 | |||
| 278 | /* on a 32bit box, this would allow for exactly (2<<38) bits. */ | ||
| 279 | static unsigned int bm_word_to_page_idx(struct drbd_bitmap *b, unsigned long long_nr) | ||
| 280 | { | ||
| 163 | /* page_nr = (word*sizeof(long)) >> PAGE_SHIFT; */ | 281 | /* page_nr = (word*sizeof(long)) >> PAGE_SHIFT; */ |
| 164 | page_nr = offset >> (PAGE_SHIFT - LN2_BPL + 3); | 282 | unsigned int page_nr = long_nr >> (PAGE_SHIFT - LN2_BPL + 3); |
| 165 | BUG_ON(page_nr >= b->bm_number_of_pages); | 283 | BUG_ON(page_nr >= b->bm_number_of_pages); |
| 166 | page = b->bm_pages[page_nr]; | 284 | return page_nr; |
| 285 | } | ||
| 167 | 286 | ||
| 287 | static unsigned int bm_bit_to_page_idx(struct drbd_bitmap *b, u64 bitnr) | ||
| 288 | { | ||
| 289 | /* page_nr = (bitnr/8) >> PAGE_SHIFT; */ | ||
| 290 | unsigned int page_nr = bitnr >> (PAGE_SHIFT + 3); | ||
| 291 | BUG_ON(page_nr >= b->bm_number_of_pages); | ||
| 292 | return page_nr; | ||
| 293 | } | ||
| 294 | |||
| 295 | static unsigned long *__bm_map_pidx(struct drbd_bitmap *b, unsigned int idx, const enum km_type km) | ||
| 296 | { | ||
| 297 | struct page *page = b->bm_pages[idx]; | ||
| 168 | return (unsigned long *) kmap_atomic(page, km); | 298 | return (unsigned long *) kmap_atomic(page, km); |
| 169 | } | 299 | } |
| 170 | 300 | ||
| 171 | static unsigned long * bm_map_paddr(struct drbd_bitmap *b, unsigned long offset) | 301 | static unsigned long *bm_map_pidx(struct drbd_bitmap *b, unsigned int idx) |
| 172 | { | 302 | { |
| 173 | return __bm_map_paddr(b, offset, KM_IRQ1); | 303 | return __bm_map_pidx(b, idx, KM_IRQ1); |
| 174 | } | 304 | } |
| 175 | 305 | ||
| 176 | static void __bm_unmap(unsigned long *p_addr, const enum km_type km) | 306 | static void __bm_unmap(unsigned long *p_addr, const enum km_type km) |
| @@ -202,6 +332,7 @@ static void bm_unmap(unsigned long *p_addr) | |||
| 202 | * to be able to report device specific. | 332 | * to be able to report device specific. |
| 203 | */ | 333 | */ |
| 204 | 334 | ||
| 335 | |||
| 205 | static void bm_free_pages(struct page **pages, unsigned long number) | 336 | static void bm_free_pages(struct page **pages, unsigned long number) |
| 206 | { | 337 | { |
| 207 | unsigned long i; | 338 | unsigned long i; |
| @@ -269,6 +400,9 @@ static struct page **bm_realloc_pages(struct drbd_bitmap *b, unsigned long want) | |||
| 269 | bm_vk_free(new_pages, vmalloced); | 400 | bm_vk_free(new_pages, vmalloced); |
| 270 | return NULL; | 401 | return NULL; |
| 271 | } | 402 | } |
| 403 | /* we want to know which page it is | ||
| 404 | * from the endio handlers */ | ||
| 405 | bm_store_page_idx(page, i); | ||
| 272 | new_pages[i] = page; | 406 | new_pages[i] = page; |
| 273 | } | 407 | } |
| 274 | } else { | 408 | } else { |
| @@ -280,9 +414,9 @@ static struct page **bm_realloc_pages(struct drbd_bitmap *b, unsigned long want) | |||
| 280 | } | 414 | } |
| 281 | 415 | ||
| 282 | if (vmalloced) | 416 | if (vmalloced) |
| 283 | set_bit(BM_P_VMALLOCED, &b->bm_flags); | 417 | b->bm_flags |= BM_P_VMALLOCED; |
| 284 | else | 418 | else |
| 285 | clear_bit(BM_P_VMALLOCED, &b->bm_flags); | 419 | b->bm_flags &= ~BM_P_VMALLOCED; |
| 286 | 420 | ||
| 287 | return new_pages; | 421 | return new_pages; |
| 288 | } | 422 | } |
| @@ -319,7 +453,7 @@ void drbd_bm_cleanup(struct drbd_conf *mdev) | |||
| 319 | { | 453 | { |
| 320 | ERR_IF (!mdev->bitmap) return; | 454 | ERR_IF (!mdev->bitmap) return; |
| 321 | bm_free_pages(mdev->bitmap->bm_pages, mdev->bitmap->bm_number_of_pages); | 455 | bm_free_pages(mdev->bitmap->bm_pages, mdev->bitmap->bm_number_of_pages); |
| 322 | bm_vk_free(mdev->bitmap->bm_pages, test_bit(BM_P_VMALLOCED, &mdev->bitmap->bm_flags)); | 456 | bm_vk_free(mdev->bitmap->bm_pages, (BM_P_VMALLOCED & mdev->bitmap->bm_flags)); |
| 323 | kfree(mdev->bitmap); | 457 | kfree(mdev->bitmap); |
| 324 | mdev->bitmap = NULL; | 458 | mdev->bitmap = NULL; |
| 325 | } | 459 | } |
| @@ -329,22 +463,39 @@ void drbd_bm_cleanup(struct drbd_conf *mdev) | |||
| 329 | * this masks out the remaining bits. | 463 | * this masks out the remaining bits. |
| 330 | * Returns the number of bits cleared. | 464 | * Returns the number of bits cleared. |
| 331 | */ | 465 | */ |
| 466 | #define BITS_PER_PAGE (1UL << (PAGE_SHIFT + 3)) | ||
| 467 | #define BITS_PER_PAGE_MASK (BITS_PER_PAGE - 1) | ||
| 468 | #define BITS_PER_LONG_MASK (BITS_PER_LONG - 1) | ||
| 332 | static int bm_clear_surplus(struct drbd_bitmap *b) | 469 | static int bm_clear_surplus(struct drbd_bitmap *b) |
| 333 | { | 470 | { |
| 334 | const unsigned long mask = (1UL << (b->bm_bits & (BITS_PER_LONG-1))) - 1; | 471 | unsigned long mask; |
| 335 | size_t w = b->bm_bits >> LN2_BPL; | ||
| 336 | int cleared = 0; | ||
| 337 | unsigned long *p_addr, *bm; | 472 | unsigned long *p_addr, *bm; |
| 473 | int tmp; | ||
| 474 | int cleared = 0; | ||
| 338 | 475 | ||
| 339 | p_addr = bm_map_paddr(b, w); | 476 | /* number of bits modulo bits per page */ |
| 340 | bm = p_addr + MLPP(w); | 477 | tmp = (b->bm_bits & BITS_PER_PAGE_MASK); |
| 341 | if (w < b->bm_words) { | 478 | /* mask the used bits of the word containing the last bit */ |
| 479 | mask = (1UL << (tmp & BITS_PER_LONG_MASK)) -1; | ||
| 480 | /* bitmap is always stored little endian, | ||
| 481 | * on disk and in core memory alike */ | ||
| 482 | mask = cpu_to_lel(mask); | ||
| 483 | |||
| 484 | p_addr = bm_map_pidx(b, b->bm_number_of_pages - 1); | ||
| 485 | bm = p_addr + (tmp/BITS_PER_LONG); | ||
| 486 | if (mask) { | ||
| 487 | /* If mask != 0, we are not exactly aligned, so bm now points | ||
| 488 | * to the long containing the last bit. | ||
| 489 | * If mask == 0, bm already points to the word immediately | ||
| 490 | * after the last (long word aligned) bit. */ | ||
| 342 | cleared = hweight_long(*bm & ~mask); | 491 | cleared = hweight_long(*bm & ~mask); |
| 343 | *bm &= mask; | 492 | *bm &= mask; |
| 344 | w++; bm++; | 493 | bm++; |
| 345 | } | 494 | } |
| 346 | 495 | ||
| 347 | if (w < b->bm_words) { | 496 | if (BITS_PER_LONG == 32 && ((bm - p_addr) & 1) == 1) { |
| 497 | /* on a 32bit arch, we may need to zero out | ||
| 498 | * a padding long to align with a 64bit remote */ | ||
| 348 | cleared += hweight_long(*bm); | 499 | cleared += hweight_long(*bm); |
| 349 | *bm = 0; | 500 | *bm = 0; |
| 350 | } | 501 | } |
| @@ -354,66 +505,75 @@ static int bm_clear_surplus(struct drbd_bitmap *b) | |||
| 354 | 505 | ||
| 355 | static void bm_set_surplus(struct drbd_bitmap *b) | 506 | static void bm_set_surplus(struct drbd_bitmap *b) |
| 356 | { | 507 | { |
| 357 | const unsigned long mask = (1UL << (b->bm_bits & (BITS_PER_LONG-1))) - 1; | 508 | unsigned long mask; |
| 358 | size_t w = b->bm_bits >> LN2_BPL; | ||
| 359 | unsigned long *p_addr, *bm; | 509 | unsigned long *p_addr, *bm; |
| 360 | 510 | int tmp; | |
| 361 | p_addr = bm_map_paddr(b, w); | 511 | |
| 362 | bm = p_addr + MLPP(w); | 512 | /* number of bits modulo bits per page */ |
| 363 | if (w < b->bm_words) { | 513 | tmp = (b->bm_bits & BITS_PER_PAGE_MASK); |
| 514 | /* mask the used bits of the word containing the last bit */ | ||
| 515 | mask = (1UL << (tmp & BITS_PER_LONG_MASK)) -1; | ||
| 516 | /* bitmap is always stored little endian, | ||
| 517 | * on disk and in core memory alike */ | ||
| 518 | mask = cpu_to_lel(mask); | ||
| 519 | |||
| 520 | p_addr = bm_map_pidx(b, b->bm_number_of_pages - 1); | ||
| 521 | bm = p_addr + (tmp/BITS_PER_LONG); | ||
| 522 | if (mask) { | ||
| 523 | /* If mask != 0, we are not exactly aligned, so bm now points | ||
| 524 | * to the long containing the last bit. | ||
| 525 | * If mask == 0, bm already points to the word immediately | ||
| 526 | * after the last (long word aligned) bit. */ | ||
| 364 | *bm |= ~mask; | 527 | *bm |= ~mask; |
| 365 | bm++; w++; | 528 | bm++; |
| 366 | } | 529 | } |
| 367 | 530 | ||
| 368 | if (w < b->bm_words) { | 531 | if (BITS_PER_LONG == 32 && ((bm - p_addr) & 1) == 1) { |
| 369 | *bm = ~(0UL); | 532 | /* on a 32bit arch, we may need to zero out |
| 533 | * a padding long to align with a 64bit remote */ | ||
| 534 | *bm = ~0UL; | ||
| 370 | } | 535 | } |
| 371 | bm_unmap(p_addr); | 536 | bm_unmap(p_addr); |
| 372 | } | 537 | } |
| 373 | 538 | ||
| 374 | static unsigned long __bm_count_bits(struct drbd_bitmap *b, const int swap_endian) | 539 | /* you better not modify the bitmap while this is running, |
| 540 | * or its results will be stale */ | ||
| 541 | static unsigned long bm_count_bits(struct drbd_bitmap *b) | ||
| 375 | { | 542 | { |
| 376 | unsigned long *p_addr, *bm, offset = 0; | 543 | unsigned long *p_addr; |
| 377 | unsigned long bits = 0; | 544 | unsigned long bits = 0; |
| 378 | unsigned long i, do_now; | 545 | unsigned long mask = (1UL << (b->bm_bits & BITS_PER_LONG_MASK)) -1; |
| 379 | 546 | int idx, i, last_word; | |
| 380 | while (offset < b->bm_words) { | 547 | |
| 381 | i = do_now = min_t(size_t, b->bm_words-offset, LWPP); | 548 | /* all but last page */ |
| 382 | p_addr = __bm_map_paddr(b, offset, KM_USER0); | 549 | for (idx = 0; idx < b->bm_number_of_pages - 1; idx++) { |
| 383 | bm = p_addr + MLPP(offset); | 550 | p_addr = __bm_map_pidx(b, idx, KM_USER0); |
| 384 | while (i--) { | 551 | for (i = 0; i < LWPP; i++) |
| 385 | #ifndef __LITTLE_ENDIAN | 552 | bits += hweight_long(p_addr[i]); |
| 386 | if (swap_endian) | ||
| 387 | *bm = lel_to_cpu(*bm); | ||
| 388 | #endif | ||
| 389 | bits += hweight_long(*bm++); | ||
| 390 | } | ||
| 391 | __bm_unmap(p_addr, KM_USER0); | 553 | __bm_unmap(p_addr, KM_USER0); |
| 392 | offset += do_now; | ||
| 393 | cond_resched(); | 554 | cond_resched(); |
| 394 | } | 555 | } |
| 395 | 556 | /* last (or only) page */ | |
| 557 | last_word = ((b->bm_bits - 1) & BITS_PER_PAGE_MASK) >> LN2_BPL; | ||
| 558 | p_addr = __bm_map_pidx(b, idx, KM_USER0); | ||
| 559 | for (i = 0; i < last_word; i++) | ||
| 560 | bits += hweight_long(p_addr[i]); | ||
| 561 | p_addr[last_word] &= cpu_to_lel(mask); | ||
| 562 | bits += hweight_long(p_addr[last_word]); | ||
| 563 | /* 32bit arch, may have an unused padding long */ | ||
| 564 | if (BITS_PER_LONG == 32 && (last_word & 1) == 0) | ||
| 565 | p_addr[last_word+1] = 0; | ||
| 566 | __bm_unmap(p_addr, KM_USER0); | ||
| 396 | return bits; | 567 | return bits; |
| 397 | } | 568 | } |
| 398 | 569 | ||
| 399 | static unsigned long bm_count_bits(struct drbd_bitmap *b) | ||
| 400 | { | ||
| 401 | return __bm_count_bits(b, 0); | ||
| 402 | } | ||
| 403 | |||
| 404 | static unsigned long bm_count_bits_swap_endian(struct drbd_bitmap *b) | ||
| 405 | { | ||
| 406 | return __bm_count_bits(b, 1); | ||
| 407 | } | ||
| 408 | |||
| 409 | /* offset and len in long words.*/ | 570 | /* offset and len in long words.*/ |
| 410 | static void bm_memset(struct drbd_bitmap *b, size_t offset, int c, size_t len) | 571 | static void bm_memset(struct drbd_bitmap *b, size_t offset, int c, size_t len) |
| 411 | { | 572 | { |
| 412 | unsigned long *p_addr, *bm; | 573 | unsigned long *p_addr, *bm; |
| 574 | unsigned int idx; | ||
| 413 | size_t do_now, end; | 575 | size_t do_now, end; |
| 414 | 576 | ||
| 415 | #define BM_SECTORS_PER_BIT (BM_BLOCK_SIZE/512) | ||
| 416 | |||
| 417 | end = offset + len; | 577 | end = offset + len; |
| 418 | 578 | ||
| 419 | if (end > b->bm_words) { | 579 | if (end > b->bm_words) { |
| @@ -423,15 +583,16 @@ static void bm_memset(struct drbd_bitmap *b, size_t offset, int c, size_t len) | |||
| 423 | 583 | ||
| 424 | while (offset < end) { | 584 | while (offset < end) { |
| 425 | do_now = min_t(size_t, ALIGN(offset + 1, LWPP), end) - offset; | 585 | do_now = min_t(size_t, ALIGN(offset + 1, LWPP), end) - offset; |
| 426 | p_addr = bm_map_paddr(b, offset); | 586 | idx = bm_word_to_page_idx(b, offset); |
| 587 | p_addr = bm_map_pidx(b, idx); | ||
| 427 | bm = p_addr + MLPP(offset); | 588 | bm = p_addr + MLPP(offset); |
| 428 | if (bm+do_now > p_addr + LWPP) { | 589 | if (bm+do_now > p_addr + LWPP) { |
| 429 | printk(KERN_ALERT "drbd: BUG BUG BUG! p_addr:%p bm:%p do_now:%d\n", | 590 | printk(KERN_ALERT "drbd: BUG BUG BUG! p_addr:%p bm:%p do_now:%d\n", |
| 430 | p_addr, bm, (int)do_now); | 591 | p_addr, bm, (int)do_now); |
| 431 | break; /* breaks to after catch_oob_access_end() only! */ | 592 | } else |
| 432 | } | 593 | memset(bm, c, do_now * sizeof(long)); |
| 433 | memset(bm, c, do_now * sizeof(long)); | ||
| 434 | bm_unmap(p_addr); | 594 | bm_unmap(p_addr); |
| 595 | bm_set_page_need_writeout(b->bm_pages[idx]); | ||
| 435 | offset += do_now; | 596 | offset += do_now; |
| 436 | } | 597 | } |
| 437 | } | 598 | } |
| @@ -447,7 +608,7 @@ static void bm_memset(struct drbd_bitmap *b, size_t offset, int c, size_t len) | |||
| 447 | int drbd_bm_resize(struct drbd_conf *mdev, sector_t capacity, int set_new_bits) | 608 | int drbd_bm_resize(struct drbd_conf *mdev, sector_t capacity, int set_new_bits) |
| 448 | { | 609 | { |
| 449 | struct drbd_bitmap *b = mdev->bitmap; | 610 | struct drbd_bitmap *b = mdev->bitmap; |
| 450 | unsigned long bits, words, owords, obits, *p_addr, *bm; | 611 | unsigned long bits, words, owords, obits; |
| 451 | unsigned long want, have, onpages; /* number of pages */ | 612 | unsigned long want, have, onpages; /* number of pages */ |
| 452 | struct page **npages, **opages = NULL; | 613 | struct page **npages, **opages = NULL; |
| 453 | int err = 0, growing; | 614 | int err = 0, growing; |
| @@ -455,7 +616,7 @@ int drbd_bm_resize(struct drbd_conf *mdev, sector_t capacity, int set_new_bits) | |||
| 455 | 616 | ||
| 456 | ERR_IF(!b) return -ENOMEM; | 617 | ERR_IF(!b) return -ENOMEM; |
| 457 | 618 | ||
| 458 | drbd_bm_lock(mdev, "resize"); | 619 | drbd_bm_lock(mdev, "resize", BM_LOCKED_MASK); |
| 459 | 620 | ||
| 460 | dev_info(DEV, "drbd_bm_resize called with capacity == %llu\n", | 621 | dev_info(DEV, "drbd_bm_resize called with capacity == %llu\n", |
| 461 | (unsigned long long)capacity); | 622 | (unsigned long long)capacity); |
| @@ -463,7 +624,7 @@ int drbd_bm_resize(struct drbd_conf *mdev, sector_t capacity, int set_new_bits) | |||
| 463 | if (capacity == b->bm_dev_capacity) | 624 | if (capacity == b->bm_dev_capacity) |
| 464 | goto out; | 625 | goto out; |
| 465 | 626 | ||
| 466 | opages_vmalloced = test_bit(BM_P_VMALLOCED, &b->bm_flags); | 627 | opages_vmalloced = (BM_P_VMALLOCED & b->bm_flags); |
| 467 | 628 | ||
| 468 | if (capacity == 0) { | 629 | if (capacity == 0) { |
| 469 | spin_lock_irq(&b->bm_lock); | 630 | spin_lock_irq(&b->bm_lock); |
| @@ -491,18 +652,23 @@ int drbd_bm_resize(struct drbd_conf *mdev, sector_t capacity, int set_new_bits) | |||
| 491 | words = ALIGN(bits, 64) >> LN2_BPL; | 652 | words = ALIGN(bits, 64) >> LN2_BPL; |
| 492 | 653 | ||
| 493 | if (get_ldev(mdev)) { | 654 | if (get_ldev(mdev)) { |
| 494 | D_ASSERT((u64)bits <= (((u64)mdev->ldev->md.md_size_sect-MD_BM_OFFSET) << 12)); | 655 | u64 bits_on_disk = ((u64)mdev->ldev->md.md_size_sect-MD_BM_OFFSET) << 12; |
| 495 | put_ldev(mdev); | 656 | put_ldev(mdev); |
| 657 | if (bits > bits_on_disk) { | ||
| 658 | dev_info(DEV, "bits = %lu\n", bits); | ||
| 659 | dev_info(DEV, "bits_on_disk = %llu\n", bits_on_disk); | ||
| 660 | err = -ENOSPC; | ||
| 661 | goto out; | ||
| 662 | } | ||
| 496 | } | 663 | } |
| 497 | 664 | ||
| 498 | /* one extra long to catch off by one errors */ | 665 | want = ALIGN(words*sizeof(long), PAGE_SIZE) >> PAGE_SHIFT; |
| 499 | want = ALIGN((words+1)*sizeof(long), PAGE_SIZE) >> PAGE_SHIFT; | ||
| 500 | have = b->bm_number_of_pages; | 666 | have = b->bm_number_of_pages; |
| 501 | if (want == have) { | 667 | if (want == have) { |
| 502 | D_ASSERT(b->bm_pages != NULL); | 668 | D_ASSERT(b->bm_pages != NULL); |
| 503 | npages = b->bm_pages; | 669 | npages = b->bm_pages; |
| 504 | } else { | 670 | } else { |
| 505 | if (FAULT_ACTIVE(mdev, DRBD_FAULT_BM_ALLOC)) | 671 | if (drbd_insert_fault(mdev, DRBD_FAULT_BM_ALLOC)) |
| 506 | npages = NULL; | 672 | npages = NULL; |
| 507 | else | 673 | else |
| 508 | npages = bm_realloc_pages(b, want); | 674 | npages = bm_realloc_pages(b, want); |
| @@ -542,11 +708,6 @@ int drbd_bm_resize(struct drbd_conf *mdev, sector_t capacity, int set_new_bits) | |||
| 542 | bm_free_pages(opages + want, have - want); | 708 | bm_free_pages(opages + want, have - want); |
| 543 | } | 709 | } |
| 544 | 710 | ||
| 545 | p_addr = bm_map_paddr(b, words); | ||
| 546 | bm = p_addr + MLPP(words); | ||
| 547 | *bm = DRBD_MAGIC; | ||
| 548 | bm_unmap(p_addr); | ||
| 549 | |||
| 550 | (void)bm_clear_surplus(b); | 711 | (void)bm_clear_surplus(b); |
| 551 | 712 | ||
| 552 | spin_unlock_irq(&b->bm_lock); | 713 | spin_unlock_irq(&b->bm_lock); |
| @@ -554,7 +715,7 @@ int drbd_bm_resize(struct drbd_conf *mdev, sector_t capacity, int set_new_bits) | |||
| 554 | bm_vk_free(opages, opages_vmalloced); | 715 | bm_vk_free(opages, opages_vmalloced); |
| 555 | if (!growing) | 716 | if (!growing) |
| 556 | b->bm_set = bm_count_bits(b); | 717 | b->bm_set = bm_count_bits(b); |
| 557 | dev_info(DEV, "resync bitmap: bits=%lu words=%lu\n", bits, words); | 718 | dev_info(DEV, "resync bitmap: bits=%lu words=%lu pages=%lu\n", bits, words, want); |
| 558 | 719 | ||
| 559 | out: | 720 | out: |
| 560 | drbd_bm_unlock(mdev); | 721 | drbd_bm_unlock(mdev); |
| @@ -624,6 +785,7 @@ void drbd_bm_merge_lel(struct drbd_conf *mdev, size_t offset, size_t number, | |||
| 624 | struct drbd_bitmap *b = mdev->bitmap; | 785 | struct drbd_bitmap *b = mdev->bitmap; |
| 625 | unsigned long *p_addr, *bm; | 786 | unsigned long *p_addr, *bm; |
| 626 | unsigned long word, bits; | 787 | unsigned long word, bits; |
| 788 | unsigned int idx; | ||
| 627 | size_t end, do_now; | 789 | size_t end, do_now; |
| 628 | 790 | ||
| 629 | end = offset + number; | 791 | end = offset + number; |
| @@ -638,16 +800,18 @@ void drbd_bm_merge_lel(struct drbd_conf *mdev, size_t offset, size_t number, | |||
| 638 | spin_lock_irq(&b->bm_lock); | 800 | spin_lock_irq(&b->bm_lock); |
| 639 | while (offset < end) { | 801 | while (offset < end) { |
| 640 | do_now = min_t(size_t, ALIGN(offset+1, LWPP), end) - offset; | 802 | do_now = min_t(size_t, ALIGN(offset+1, LWPP), end) - offset; |
| 641 | p_addr = bm_map_paddr(b, offset); | 803 | idx = bm_word_to_page_idx(b, offset); |
| 804 | p_addr = bm_map_pidx(b, idx); | ||
| 642 | bm = p_addr + MLPP(offset); | 805 | bm = p_addr + MLPP(offset); |
| 643 | offset += do_now; | 806 | offset += do_now; |
| 644 | while (do_now--) { | 807 | while (do_now--) { |
| 645 | bits = hweight_long(*bm); | 808 | bits = hweight_long(*bm); |
| 646 | word = *bm | lel_to_cpu(*buffer++); | 809 | word = *bm | *buffer++; |
| 647 | *bm++ = word; | 810 | *bm++ = word; |
| 648 | b->bm_set += hweight_long(word) - bits; | 811 | b->bm_set += hweight_long(word) - bits; |
| 649 | } | 812 | } |
| 650 | bm_unmap(p_addr); | 813 | bm_unmap(p_addr); |
| 814 | bm_set_page_need_writeout(b->bm_pages[idx]); | ||
| 651 | } | 815 | } |
| 652 | /* with 32bit <-> 64bit cross-platform connect | 816 | /* with 32bit <-> 64bit cross-platform connect |
| 653 | * this is only correct for current usage, | 817 | * this is only correct for current usage, |
| @@ -656,7 +820,6 @@ void drbd_bm_merge_lel(struct drbd_conf *mdev, size_t offset, size_t number, | |||
| 656 | */ | 820 | */ |
| 657 | if (end == b->bm_words) | 821 | if (end == b->bm_words) |
| 658 | b->bm_set -= bm_clear_surplus(b); | 822 | b->bm_set -= bm_clear_surplus(b); |
| 659 | |||
| 660 | spin_unlock_irq(&b->bm_lock); | 823 | spin_unlock_irq(&b->bm_lock); |
| 661 | } | 824 | } |
| 662 | 825 | ||
| @@ -686,11 +849,11 @@ void drbd_bm_get_lel(struct drbd_conf *mdev, size_t offset, size_t number, | |||
| 686 | else { | 849 | else { |
| 687 | while (offset < end) { | 850 | while (offset < end) { |
| 688 | do_now = min_t(size_t, ALIGN(offset+1, LWPP), end) - offset; | 851 | do_now = min_t(size_t, ALIGN(offset+1, LWPP), end) - offset; |
| 689 | p_addr = bm_map_paddr(b, offset); | 852 | p_addr = bm_map_pidx(b, bm_word_to_page_idx(b, offset)); |
| 690 | bm = p_addr + MLPP(offset); | 853 | bm = p_addr + MLPP(offset); |
| 691 | offset += do_now; | 854 | offset += do_now; |
| 692 | while (do_now--) | 855 | while (do_now--) |
| 693 | *buffer++ = cpu_to_lel(*bm++); | 856 | *buffer++ = *bm++; |
| 694 | bm_unmap(p_addr); | 857 | bm_unmap(p_addr); |
| 695 | } | 858 | } |
| 696 | } | 859 | } |
| @@ -724,9 +887,22 @@ void drbd_bm_clear_all(struct drbd_conf *mdev) | |||
| 724 | spin_unlock_irq(&b->bm_lock); | 887 | spin_unlock_irq(&b->bm_lock); |
| 725 | } | 888 | } |
| 726 | 889 | ||
| 890 | struct bm_aio_ctx { | ||
| 891 | struct drbd_conf *mdev; | ||
| 892 | atomic_t in_flight; | ||
| 893 | struct completion done; | ||
| 894 | unsigned flags; | ||
| 895 | #define BM_AIO_COPY_PAGES 1 | ||
| 896 | int error; | ||
| 897 | }; | ||
| 898 | |||
| 899 | /* bv_page may be a copy, or may be the original */ | ||
| 727 | static void bm_async_io_complete(struct bio *bio, int error) | 900 | static void bm_async_io_complete(struct bio *bio, int error) |
| 728 | { | 901 | { |
| 729 | struct drbd_bitmap *b = bio->bi_private; | 902 | struct bm_aio_ctx *ctx = bio->bi_private; |
| 903 | struct drbd_conf *mdev = ctx->mdev; | ||
| 904 | struct drbd_bitmap *b = mdev->bitmap; | ||
| 905 | unsigned int idx = bm_page_to_idx(bio->bi_io_vec[0].bv_page); | ||
| 730 | int uptodate = bio_flagged(bio, BIO_UPTODATE); | 906 | int uptodate = bio_flagged(bio, BIO_UPTODATE); |
| 731 | 907 | ||
| 732 | 908 | ||
| @@ -737,38 +913,83 @@ static void bm_async_io_complete(struct bio *bio, int error) | |||
| 737 | if (!error && !uptodate) | 913 | if (!error && !uptodate) |
| 738 | error = -EIO; | 914 | error = -EIO; |
| 739 | 915 | ||
| 916 | if ((ctx->flags & BM_AIO_COPY_PAGES) == 0 && | ||
| 917 | !bm_test_page_unchanged(b->bm_pages[idx])) | ||
| 918 | dev_warn(DEV, "bitmap page idx %u changed during IO!\n", idx); | ||
| 919 | |||
| 740 | if (error) { | 920 | if (error) { |
| 741 | /* doh. what now? | 921 | /* ctx error will hold the completed-last non-zero error code, |
| 742 | * for now, set all bits, and flag MD_IO_ERROR */ | 922 | * in case error codes differ. */ |
| 743 | __set_bit(BM_MD_IO_ERROR, &b->bm_flags); | 923 | ctx->error = error; |
| 924 | bm_set_page_io_err(b->bm_pages[idx]); | ||
| 925 | /* Not identical to on disk version of it. | ||
| 926 | * Is BM_PAGE_IO_ERROR enough? */ | ||
| 927 | if (__ratelimit(&drbd_ratelimit_state)) | ||
| 928 | dev_err(DEV, "IO ERROR %d on bitmap page idx %u\n", | ||
| 929 | error, idx); | ||
| 930 | } else { | ||
| 931 | bm_clear_page_io_err(b->bm_pages[idx]); | ||
| 932 | dynamic_dev_dbg(DEV, "bitmap page idx %u completed\n", idx); | ||
| 744 | } | 933 | } |
| 745 | if (atomic_dec_and_test(&b->bm_async_io)) | 934 | |
| 746 | wake_up(&b->bm_io_wait); | 935 | bm_page_unlock_io(mdev, idx); |
| 936 | |||
| 937 | /* FIXME give back to page pool */ | ||
| 938 | if (ctx->flags & BM_AIO_COPY_PAGES) | ||
| 939 | put_page(bio->bi_io_vec[0].bv_page); | ||
| 747 | 940 | ||
| 748 | bio_put(bio); | 941 | bio_put(bio); |
| 942 | |||
| 943 | if (atomic_dec_and_test(&ctx->in_flight)) | ||
| 944 | complete(&ctx->done); | ||
| 749 | } | 945 | } |
| 750 | 946 | ||
| 751 | static void bm_page_io_async(struct drbd_conf *mdev, struct drbd_bitmap *b, int page_nr, int rw) __must_hold(local) | 947 | static void bm_page_io_async(struct bm_aio_ctx *ctx, int page_nr, int rw) __must_hold(local) |
| 752 | { | 948 | { |
| 753 | /* we are process context. we always get a bio */ | 949 | /* we are process context. we always get a bio */ |
| 754 | struct bio *bio = bio_alloc(GFP_KERNEL, 1); | 950 | struct bio *bio = bio_alloc(GFP_KERNEL, 1); |
| 951 | struct drbd_conf *mdev = ctx->mdev; | ||
| 952 | struct drbd_bitmap *b = mdev->bitmap; | ||
| 953 | struct page *page; | ||
| 755 | unsigned int len; | 954 | unsigned int len; |
| 955 | |||
| 756 | sector_t on_disk_sector = | 956 | sector_t on_disk_sector = |
| 757 | mdev->ldev->md.md_offset + mdev->ldev->md.bm_offset; | 957 | mdev->ldev->md.md_offset + mdev->ldev->md.bm_offset; |
| 758 | on_disk_sector += ((sector_t)page_nr) << (PAGE_SHIFT-9); | 958 | on_disk_sector += ((sector_t)page_nr) << (PAGE_SHIFT-9); |
| 759 | 959 | ||
| 760 | /* this might happen with very small | 960 | /* this might happen with very small |
| 761 | * flexible external meta data device */ | 961 | * flexible external meta data device, |
| 962 | * or with PAGE_SIZE > 4k */ | ||
| 762 | len = min_t(unsigned int, PAGE_SIZE, | 963 | len = min_t(unsigned int, PAGE_SIZE, |
| 763 | (drbd_md_last_sector(mdev->ldev) - on_disk_sector + 1)<<9); | 964 | (drbd_md_last_sector(mdev->ldev) - on_disk_sector + 1)<<9); |
| 764 | 965 | ||
| 966 | /* serialize IO on this page */ | ||
| 967 | bm_page_lock_io(mdev, page_nr); | ||
| 968 | /* before memcpy and submit, | ||
| 969 | * so it can be redirtied any time */ | ||
| 970 | bm_set_page_unchanged(b->bm_pages[page_nr]); | ||
| 971 | |||
| 972 | if (ctx->flags & BM_AIO_COPY_PAGES) { | ||
| 973 | /* FIXME alloc_page is good enough for now, but actually needs | ||
| 974 | * to use pre-allocated page pool */ | ||
| 975 | void *src, *dest; | ||
| 976 | page = alloc_page(__GFP_HIGHMEM|__GFP_WAIT); | ||
| 977 | dest = kmap_atomic(page, KM_USER0); | ||
| 978 | src = kmap_atomic(b->bm_pages[page_nr], KM_USER1); | ||
| 979 | memcpy(dest, src, PAGE_SIZE); | ||
| 980 | kunmap_atomic(src, KM_USER1); | ||
| 981 | kunmap_atomic(dest, KM_USER0); | ||
| 982 | bm_store_page_idx(page, page_nr); | ||
| 983 | } else | ||
| 984 | page = b->bm_pages[page_nr]; | ||
| 985 | |||
| 765 | bio->bi_bdev = mdev->ldev->md_bdev; | 986 | bio->bi_bdev = mdev->ldev->md_bdev; |
| 766 | bio->bi_sector = on_disk_sector; | 987 | bio->bi_sector = on_disk_sector; |
| 767 | bio_add_page(bio, b->bm_pages[page_nr], len, 0); | 988 | bio_add_page(bio, page, len, 0); |
| 768 | bio->bi_private = b; | 989 | bio->bi_private = ctx; |
| 769 | bio->bi_end_io = bm_async_io_complete; | 990 | bio->bi_end_io = bm_async_io_complete; |
| 770 | 991 | ||
| 771 | if (FAULT_ACTIVE(mdev, (rw & WRITE) ? DRBD_FAULT_MD_WR : DRBD_FAULT_MD_RD)) { | 992 | if (drbd_insert_fault(mdev, (rw & WRITE) ? DRBD_FAULT_MD_WR : DRBD_FAULT_MD_RD)) { |
| 772 | bio->bi_rw |= rw; | 993 | bio->bi_rw |= rw; |
| 773 | bio_endio(bio, -EIO); | 994 | bio_endio(bio, -EIO); |
| 774 | } else { | 995 | } else { |
| @@ -776,87 +997,84 @@ static void bm_page_io_async(struct drbd_conf *mdev, struct drbd_bitmap *b, int | |||
| 776 | } | 997 | } |
| 777 | } | 998 | } |
| 778 | 999 | ||
| 779 | # if defined(__LITTLE_ENDIAN) | ||
| 780 | /* nothing to do, on disk == in memory */ | ||
| 781 | # define bm_cpu_to_lel(x) ((void)0) | ||
| 782 | # else | ||
| 783 | static void bm_cpu_to_lel(struct drbd_bitmap *b) | ||
| 784 | { | ||
| 785 | /* need to cpu_to_lel all the pages ... | ||
| 786 | * this may be optimized by using | ||
| 787 | * cpu_to_lel(-1) == -1 and cpu_to_lel(0) == 0; | ||
| 788 | * the following is still not optimal, but better than nothing */ | ||
| 789 | unsigned int i; | ||
| 790 | unsigned long *p_addr, *bm; | ||
| 791 | if (b->bm_set == 0) { | ||
| 792 | /* no page at all; avoid swap if all is 0 */ | ||
| 793 | i = b->bm_number_of_pages; | ||
| 794 | } else if (b->bm_set == b->bm_bits) { | ||
| 795 | /* only the last page */ | ||
| 796 | i = b->bm_number_of_pages - 1; | ||
| 797 | } else { | ||
| 798 | /* all pages */ | ||
| 799 | i = 0; | ||
| 800 | } | ||
| 801 | for (; i < b->bm_number_of_pages; i++) { | ||
| 802 | p_addr = kmap_atomic(b->bm_pages[i], KM_USER0); | ||
| 803 | for (bm = p_addr; bm < p_addr + PAGE_SIZE/sizeof(long); bm++) | ||
| 804 | *bm = cpu_to_lel(*bm); | ||
| 805 | kunmap_atomic(p_addr, KM_USER0); | ||
| 806 | } | ||
| 807 | } | ||
| 808 | # endif | ||
| 809 | /* lel_to_cpu == cpu_to_lel */ | ||
| 810 | # define bm_lel_to_cpu(x) bm_cpu_to_lel(x) | ||
| 811 | |||
| 812 | /* | 1000 | /* |
| 813 | * bm_rw: read/write the whole bitmap from/to its on disk location. | 1001 | * bm_rw: read/write the whole bitmap from/to its on disk location. |
| 814 | */ | 1002 | */ |
| 815 | static int bm_rw(struct drbd_conf *mdev, int rw) __must_hold(local) | 1003 | static int bm_rw(struct drbd_conf *mdev, int rw, unsigned lazy_writeout_upper_idx) __must_hold(local) |
| 816 | { | 1004 | { |
| 1005 | struct bm_aio_ctx ctx = { | ||
| 1006 | .mdev = mdev, | ||
| 1007 | .in_flight = ATOMIC_INIT(1), | ||
| 1008 | .done = COMPLETION_INITIALIZER_ONSTACK(ctx.done), | ||
| 1009 | .flags = lazy_writeout_upper_idx ? BM_AIO_COPY_PAGES : 0, | ||
| 1010 | }; | ||
| 817 | struct drbd_bitmap *b = mdev->bitmap; | 1011 | struct drbd_bitmap *b = mdev->bitmap; |
| 818 | /* sector_t sector; */ | 1012 | int num_pages, i, count = 0; |
| 819 | int bm_words, num_pages, i; | ||
| 820 | unsigned long now; | 1013 | unsigned long now; |
| 821 | char ppb[10]; | 1014 | char ppb[10]; |
| 822 | int err = 0; | 1015 | int err = 0; |
| 823 | 1016 | ||
| 824 | WARN_ON(!bm_is_locked(b)); | 1017 | /* |
| 825 | 1018 | * We are protected against bitmap disappearing/resizing by holding an | |
| 826 | /* no spinlock here, the drbd_bm_lock should be enough! */ | 1019 | * ldev reference (caller must have called get_ldev()). |
| 827 | 1020 | * For read/write, we are protected against changes to the bitmap by | |
| 828 | bm_words = drbd_bm_words(mdev); | 1021 | * the bitmap lock (see drbd_bitmap_io). |
| 829 | num_pages = (bm_words*sizeof(long) + PAGE_SIZE-1) >> PAGE_SHIFT; | 1022 | * For lazy writeout, we don't care for ongoing changes to the bitmap, |
| 1023 | * as we submit copies of pages anyways. | ||
| 1024 | */ | ||
| 1025 | if (!ctx.flags) | ||
| 1026 | WARN_ON(!(BM_LOCKED_MASK & b->bm_flags)); | ||
| 830 | 1027 | ||
| 831 | /* on disk bitmap is little endian */ | 1028 | num_pages = b->bm_number_of_pages; |
| 832 | if (rw == WRITE) | ||
| 833 | bm_cpu_to_lel(b); | ||
| 834 | 1029 | ||
| 835 | now = jiffies; | 1030 | now = jiffies; |
| 836 | atomic_set(&b->bm_async_io, num_pages); | ||
| 837 | __clear_bit(BM_MD_IO_ERROR, &b->bm_flags); | ||
| 838 | 1031 | ||
| 839 | /* let the layers below us try to merge these bios... */ | 1032 | /* let the layers below us try to merge these bios... */ |
| 840 | for (i = 0; i < num_pages; i++) | 1033 | for (i = 0; i < num_pages; i++) { |
| 841 | bm_page_io_async(mdev, b, i, rw); | 1034 | /* ignore completely unchanged pages */ |
| 1035 | if (lazy_writeout_upper_idx && i == lazy_writeout_upper_idx) | ||
| 1036 | break; | ||
| 1037 | if (rw & WRITE) { | ||
| 1038 | if (bm_test_page_unchanged(b->bm_pages[i])) { | ||
| 1039 | dynamic_dev_dbg(DEV, "skipped bm write for idx %u\n", i); | ||
| 1040 | continue; | ||
| 1041 | } | ||
| 1042 | /* during lazy writeout, | ||
| 1043 | * ignore those pages not marked for lazy writeout. */ | ||
| 1044 | if (lazy_writeout_upper_idx && | ||
| 1045 | !bm_test_page_lazy_writeout(b->bm_pages[i])) { | ||
| 1046 | dynamic_dev_dbg(DEV, "skipped bm lazy write for idx %u\n", i); | ||
| 1047 | continue; | ||
| 1048 | } | ||
| 1049 | } | ||
| 1050 | atomic_inc(&ctx.in_flight); | ||
| 1051 | bm_page_io_async(&ctx, i, rw); | ||
| 1052 | ++count; | ||
| 1053 | cond_resched(); | ||
| 1054 | } | ||
| 842 | 1055 | ||
| 843 | wait_event(b->bm_io_wait, atomic_read(&b->bm_async_io) == 0); | 1056 | /* |
| 1057 | * We initialize ctx.in_flight to one to make sure bm_async_io_complete | ||
| 1058 | * will not complete() early, and decrement / test it here. If there | ||
| 1059 | * are still some bios in flight, we need to wait for them here. | ||
| 1060 | */ | ||
| 1061 | if (!atomic_dec_and_test(&ctx.in_flight)) | ||
| 1062 | wait_for_completion(&ctx.done); | ||
| 1063 | dev_info(DEV, "bitmap %s of %u pages took %lu jiffies\n", | ||
| 1064 | rw == WRITE ? "WRITE" : "READ", | ||
| 1065 | count, jiffies - now); | ||
| 844 | 1066 | ||
| 845 | if (test_bit(BM_MD_IO_ERROR, &b->bm_flags)) { | 1067 | if (ctx.error) { |
| 846 | dev_alert(DEV, "we had at least one MD IO ERROR during bitmap IO\n"); | 1068 | dev_alert(DEV, "we had at least one MD IO ERROR during bitmap IO\n"); |
| 847 | drbd_chk_io_error(mdev, 1, TRUE); | 1069 | drbd_chk_io_error(mdev, 1, true); |
| 848 | err = -EIO; | 1070 | err = -EIO; /* ctx.error ? */ |
| 849 | } | 1071 | } |
| 850 | 1072 | ||
| 851 | now = jiffies; | 1073 | now = jiffies; |
| 852 | if (rw == WRITE) { | 1074 | if (rw == WRITE) { |
| 853 | /* swap back endianness */ | ||
| 854 | bm_lel_to_cpu(b); | ||
| 855 | /* flush bitmap to stable storage */ | ||
| 856 | drbd_md_flush(mdev); | 1075 | drbd_md_flush(mdev); |
| 857 | } else /* rw == READ */ { | 1076 | } else /* rw == READ */ { |
| 858 | /* just read, if necessary adjust endianness */ | 1077 | b->bm_set = bm_count_bits(b); |
| 859 | b->bm_set = bm_count_bits_swap_endian(b); | ||
| 860 | dev_info(DEV, "recounting of set bits took additional %lu jiffies\n", | 1078 | dev_info(DEV, "recounting of set bits took additional %lu jiffies\n", |
| 861 | jiffies - now); | 1079 | jiffies - now); |
| 862 | } | 1080 | } |
| @@ -874,112 +1092,128 @@ static int bm_rw(struct drbd_conf *mdev, int rw) __must_hold(local) | |||
| 874 | */ | 1092 | */ |
| 875 | int drbd_bm_read(struct drbd_conf *mdev) __must_hold(local) | 1093 | int drbd_bm_read(struct drbd_conf *mdev) __must_hold(local) |
| 876 | { | 1094 | { |
| 877 | return bm_rw(mdev, READ); | 1095 | return bm_rw(mdev, READ, 0); |
| 878 | } | 1096 | } |
| 879 | 1097 | ||
| 880 | /** | 1098 | /** |
| 881 | * drbd_bm_write() - Write the whole bitmap to its on disk location. | 1099 | * drbd_bm_write() - Write the whole bitmap to its on disk location. |
| 882 | * @mdev: DRBD device. | 1100 | * @mdev: DRBD device. |
| 1101 | * | ||
| 1102 | * Will only write pages that have changed since last IO. | ||
| 883 | */ | 1103 | */ |
| 884 | int drbd_bm_write(struct drbd_conf *mdev) __must_hold(local) | 1104 | int drbd_bm_write(struct drbd_conf *mdev) __must_hold(local) |
| 885 | { | 1105 | { |
| 886 | return bm_rw(mdev, WRITE); | 1106 | return bm_rw(mdev, WRITE, 0); |
| 887 | } | 1107 | } |
| 888 | 1108 | ||
| 889 | /** | 1109 | /** |
| 890 | * drbd_bm_write_sect: Writes a 512 (MD_SECTOR_SIZE) byte piece of the bitmap | 1110 | * drbd_bm_lazy_write_out() - Write bitmap pages 0 to @upper_idx-1, if they have changed. |
| 891 | * @mdev: DRBD device. | 1111 | * @mdev: DRBD device. |
| 892 | * @enr: Extent number in the resync lru (happens to be sector offset) | 1112 | * @upper_idx: 0: write all changed pages; +ve: page index to stop scanning for changed pages |
| 893 | * | ||
| 894 | * The BM_EXT_SIZE is on purpose exactly the amount of the bitmap covered | ||
| 895 | * by a single sector write. Therefore enr == sector offset from the | ||
| 896 | * start of the bitmap. | ||
| 897 | */ | 1113 | */ |
| 898 | int drbd_bm_write_sect(struct drbd_conf *mdev, unsigned long enr) __must_hold(local) | 1114 | int drbd_bm_write_lazy(struct drbd_conf *mdev, unsigned upper_idx) __must_hold(local) |
| 899 | { | 1115 | { |
| 900 | sector_t on_disk_sector = enr + mdev->ldev->md.md_offset | 1116 | return bm_rw(mdev, WRITE, upper_idx); |
| 901 | + mdev->ldev->md.bm_offset; | 1117 | } |
| 902 | int bm_words, num_words, offset; | 1118 | |
| 903 | int err = 0; | ||
| 904 | 1119 | ||
| 905 | mutex_lock(&mdev->md_io_mutex); | 1120 | /** |
| 906 | bm_words = drbd_bm_words(mdev); | 1121 | * drbd_bm_write_page: Writes a PAGE_SIZE aligned piece of bitmap |
| 907 | offset = S2W(enr); /* word offset into bitmap */ | 1122 | * @mdev: DRBD device. |
| 908 | num_words = min(S2W(1), bm_words - offset); | 1123 | * @idx: bitmap page index |
| 909 | if (num_words < S2W(1)) | 1124 | * |
| 910 | memset(page_address(mdev->md_io_page), 0, MD_SECTOR_SIZE); | 1125 | * We don't want to special case on logical_block_size of the backend device, |
| 911 | drbd_bm_get_lel(mdev, offset, num_words, | 1126 | * so we submit PAGE_SIZE aligned pieces. |
| 912 | page_address(mdev->md_io_page)); | 1127 | * Note that on "most" systems, PAGE_SIZE is 4k. |
| 913 | if (!drbd_md_sync_page_io(mdev, mdev->ldev, on_disk_sector, WRITE)) { | 1128 | * |
| 914 | int i; | 1129 | * In case this becomes an issue on systems with larger PAGE_SIZE, |
| 915 | err = -EIO; | 1130 | * we may want to change this again to write 4k aligned 4k pieces. |
| 916 | dev_err(DEV, "IO ERROR writing bitmap sector %lu " | 1131 | */ |
| 917 | "(meta-disk sector %llus)\n", | 1132 | int drbd_bm_write_page(struct drbd_conf *mdev, unsigned int idx) __must_hold(local) |
| 918 | enr, (unsigned long long)on_disk_sector); | 1133 | { |
| 919 | drbd_chk_io_error(mdev, 1, TRUE); | 1134 | struct bm_aio_ctx ctx = { |
| 920 | for (i = 0; i < AL_EXT_PER_BM_SECT; i++) | 1135 | .mdev = mdev, |
| 921 | drbd_bm_ALe_set_all(mdev, enr*AL_EXT_PER_BM_SECT+i); | 1136 | .in_flight = ATOMIC_INIT(1), |
| 1137 | .done = COMPLETION_INITIALIZER_ONSTACK(ctx.done), | ||
| 1138 | .flags = BM_AIO_COPY_PAGES, | ||
| 1139 | }; | ||
| 1140 | |||
| 1141 | if (bm_test_page_unchanged(mdev->bitmap->bm_pages[idx])) { | ||
| 1142 | dynamic_dev_dbg(DEV, "skipped bm page write for idx %u\n", idx); | ||
| 1143 | return 0; | ||
| 922 | } | 1144 | } |
| 1145 | |||
| 1146 | bm_page_io_async(&ctx, idx, WRITE_SYNC); | ||
| 1147 | wait_for_completion(&ctx.done); | ||
| 1148 | |||
| 1149 | if (ctx.error) | ||
| 1150 | drbd_chk_io_error(mdev, 1, true); | ||
| 1151 | /* that should force detach, so the in memory bitmap will be | ||
| 1152 | * gone in a moment as well. */ | ||
| 1153 | |||
| 923 | mdev->bm_writ_cnt++; | 1154 | mdev->bm_writ_cnt++; |
| 924 | mutex_unlock(&mdev->md_io_mutex); | 1155 | return ctx.error; |
| 925 | return err; | ||
| 926 | } | 1156 | } |
| 927 | 1157 | ||
| 928 | /* NOTE | 1158 | /* NOTE |
| 929 | * find_first_bit returns int, we return unsigned long. | 1159 | * find_first_bit returns int, we return unsigned long. |
| 930 | * should not make much difference anyways, but ... | 1160 | * For this to work on 32bit arch with bitnumbers > (1<<32), |
| 1161 | * we'd need to return u64, and get a whole lot of other places | ||
| 1162 | * fixed where we still use unsigned long. | ||
| 931 | * | 1163 | * |
| 932 | * this returns a bit number, NOT a sector! | 1164 | * this returns a bit number, NOT a sector! |
| 933 | */ | 1165 | */ |
| 934 | #define BPP_MASK ((1UL << (PAGE_SHIFT+3)) - 1) | ||
| 935 | static unsigned long __bm_find_next(struct drbd_conf *mdev, unsigned long bm_fo, | 1166 | static unsigned long __bm_find_next(struct drbd_conf *mdev, unsigned long bm_fo, |
| 936 | const int find_zero_bit, const enum km_type km) | 1167 | const int find_zero_bit, const enum km_type km) |
| 937 | { | 1168 | { |
| 938 | struct drbd_bitmap *b = mdev->bitmap; | 1169 | struct drbd_bitmap *b = mdev->bitmap; |
| 939 | unsigned long i = -1UL; | ||
| 940 | unsigned long *p_addr; | 1170 | unsigned long *p_addr; |
| 941 | unsigned long bit_offset; /* bit offset of the mapped page. */ | 1171 | unsigned long bit_offset; |
| 1172 | unsigned i; | ||
| 1173 | |||
| 942 | 1174 | ||
| 943 | if (bm_fo > b->bm_bits) { | 1175 | if (bm_fo > b->bm_bits) { |
| 944 | dev_err(DEV, "bm_fo=%lu bm_bits=%lu\n", bm_fo, b->bm_bits); | 1176 | dev_err(DEV, "bm_fo=%lu bm_bits=%lu\n", bm_fo, b->bm_bits); |
| 1177 | bm_fo = DRBD_END_OF_BITMAP; | ||
| 945 | } else { | 1178 | } else { |
| 946 | while (bm_fo < b->bm_bits) { | 1179 | while (bm_fo < b->bm_bits) { |
| 947 | unsigned long offset; | 1180 | /* bit offset of the first bit in the page */ |
| 948 | bit_offset = bm_fo & ~BPP_MASK; /* bit offset of the page */ | 1181 | bit_offset = bm_fo & ~BITS_PER_PAGE_MASK; |
| 949 | offset = bit_offset >> LN2_BPL; /* word offset of the page */ | 1182 | p_addr = __bm_map_pidx(b, bm_bit_to_page_idx(b, bm_fo), km); |
| 950 | p_addr = __bm_map_paddr(b, offset, km); | ||
| 951 | 1183 | ||
| 952 | if (find_zero_bit) | 1184 | if (find_zero_bit) |
| 953 | i = find_next_zero_bit(p_addr, PAGE_SIZE*8, bm_fo & BPP_MASK); | 1185 | i = find_next_zero_bit_le(p_addr, |
| 1186 | PAGE_SIZE*8, bm_fo & BITS_PER_PAGE_MASK); | ||
| 954 | else | 1187 | else |
| 955 | i = find_next_bit(p_addr, PAGE_SIZE*8, bm_fo & BPP_MASK); | 1188 | i = find_next_bit_le(p_addr, |
| 1189 | PAGE_SIZE*8, bm_fo & BITS_PER_PAGE_MASK); | ||
| 956 | 1190 | ||
| 957 | __bm_unmap(p_addr, km); | 1191 | __bm_unmap(p_addr, km); |
| 958 | if (i < PAGE_SIZE*8) { | 1192 | if (i < PAGE_SIZE*8) { |
| 959 | i = bit_offset + i; | 1193 | bm_fo = bit_offset + i; |
| 960 | if (i >= b->bm_bits) | 1194 | if (bm_fo >= b->bm_bits) |
| 961 | break; | 1195 | break; |
| 962 | goto found; | 1196 | goto found; |
| 963 | } | 1197 | } |
| 964 | bm_fo = bit_offset + PAGE_SIZE*8; | 1198 | bm_fo = bit_offset + PAGE_SIZE*8; |
| 965 | } | 1199 | } |
| 966 | i = -1UL; | 1200 | bm_fo = DRBD_END_OF_BITMAP; |
| 967 | } | 1201 | } |
| 968 | found: | 1202 | found: |
| 969 | return i; | 1203 | return bm_fo; |
| 970 | } | 1204 | } |
| 971 | 1205 | ||
| 972 | static unsigned long bm_find_next(struct drbd_conf *mdev, | 1206 | static unsigned long bm_find_next(struct drbd_conf *mdev, |
| 973 | unsigned long bm_fo, const int find_zero_bit) | 1207 | unsigned long bm_fo, const int find_zero_bit) |
| 974 | { | 1208 | { |
| 975 | struct drbd_bitmap *b = mdev->bitmap; | 1209 | struct drbd_bitmap *b = mdev->bitmap; |
| 976 | unsigned long i = -1UL; | 1210 | unsigned long i = DRBD_END_OF_BITMAP; |
| 977 | 1211 | ||
| 978 | ERR_IF(!b) return i; | 1212 | ERR_IF(!b) return i; |
| 979 | ERR_IF(!b->bm_pages) return i; | 1213 | ERR_IF(!b->bm_pages) return i; |
| 980 | 1214 | ||
| 981 | spin_lock_irq(&b->bm_lock); | 1215 | spin_lock_irq(&b->bm_lock); |
| 982 | if (bm_is_locked(b)) | 1216 | if (BM_DONT_TEST & b->bm_flags) |
| 983 | bm_print_lock_info(mdev); | 1217 | bm_print_lock_info(mdev); |
| 984 | 1218 | ||
| 985 | i = __bm_find_next(mdev, bm_fo, find_zero_bit, KM_IRQ1); | 1219 | i = __bm_find_next(mdev, bm_fo, find_zero_bit, KM_IRQ1); |
| @@ -1005,13 +1239,13 @@ unsigned long drbd_bm_find_next_zero(struct drbd_conf *mdev, unsigned long bm_fo | |||
| 1005 | * you must take drbd_bm_lock() first */ | 1239 | * you must take drbd_bm_lock() first */ |
| 1006 | unsigned long _drbd_bm_find_next(struct drbd_conf *mdev, unsigned long bm_fo) | 1240 | unsigned long _drbd_bm_find_next(struct drbd_conf *mdev, unsigned long bm_fo) |
| 1007 | { | 1241 | { |
| 1008 | /* WARN_ON(!bm_is_locked(mdev)); */ | 1242 | /* WARN_ON(!(BM_DONT_SET & mdev->b->bm_flags)); */ |
| 1009 | return __bm_find_next(mdev, bm_fo, 0, KM_USER1); | 1243 | return __bm_find_next(mdev, bm_fo, 0, KM_USER1); |
| 1010 | } | 1244 | } |
| 1011 | 1245 | ||
| 1012 | unsigned long _drbd_bm_find_next_zero(struct drbd_conf *mdev, unsigned long bm_fo) | 1246 | unsigned long _drbd_bm_find_next_zero(struct drbd_conf *mdev, unsigned long bm_fo) |
| 1013 | { | 1247 | { |
| 1014 | /* WARN_ON(!bm_is_locked(mdev)); */ | 1248 | /* WARN_ON(!(BM_DONT_SET & mdev->b->bm_flags)); */ |
| 1015 | return __bm_find_next(mdev, bm_fo, 1, KM_USER1); | 1249 | return __bm_find_next(mdev, bm_fo, 1, KM_USER1); |
| 1016 | } | 1250 | } |
| 1017 | 1251 | ||
| @@ -1027,8 +1261,9 @@ static int __bm_change_bits_to(struct drbd_conf *mdev, const unsigned long s, | |||
| 1027 | struct drbd_bitmap *b = mdev->bitmap; | 1261 | struct drbd_bitmap *b = mdev->bitmap; |
| 1028 | unsigned long *p_addr = NULL; | 1262 | unsigned long *p_addr = NULL; |
| 1029 | unsigned long bitnr; | 1263 | unsigned long bitnr; |
| 1030 | unsigned long last_page_nr = -1UL; | 1264 | unsigned int last_page_nr = -1U; |
| 1031 | int c = 0; | 1265 | int c = 0; |
| 1266 | int changed_total = 0; | ||
| 1032 | 1267 | ||
| 1033 | if (e >= b->bm_bits) { | 1268 | if (e >= b->bm_bits) { |
| 1034 | dev_err(DEV, "ASSERT FAILED: bit_s=%lu bit_e=%lu bm_bits=%lu\n", | 1269 | dev_err(DEV, "ASSERT FAILED: bit_s=%lu bit_e=%lu bm_bits=%lu\n", |
| @@ -1036,23 +1271,33 @@ static int __bm_change_bits_to(struct drbd_conf *mdev, const unsigned long s, | |||
| 1036 | e = b->bm_bits ? b->bm_bits -1 : 0; | 1271 | e = b->bm_bits ? b->bm_bits -1 : 0; |
| 1037 | } | 1272 | } |
| 1038 | for (bitnr = s; bitnr <= e; bitnr++) { | 1273 | for (bitnr = s; bitnr <= e; bitnr++) { |
| 1039 | unsigned long offset = bitnr>>LN2_BPL; | 1274 | unsigned int page_nr = bm_bit_to_page_idx(b, bitnr); |
| 1040 | unsigned long page_nr = offset >> (PAGE_SHIFT - LN2_BPL + 3); | ||
| 1041 | if (page_nr != last_page_nr) { | 1275 | if (page_nr != last_page_nr) { |
| 1042 | if (p_addr) | 1276 | if (p_addr) |
| 1043 | __bm_unmap(p_addr, km); | 1277 | __bm_unmap(p_addr, km); |
| 1044 | p_addr = __bm_map_paddr(b, offset, km); | 1278 | if (c < 0) |
| 1279 | bm_set_page_lazy_writeout(b->bm_pages[last_page_nr]); | ||
| 1280 | else if (c > 0) | ||
| 1281 | bm_set_page_need_writeout(b->bm_pages[last_page_nr]); | ||
| 1282 | changed_total += c; | ||
| 1283 | c = 0; | ||
| 1284 | p_addr = __bm_map_pidx(b, page_nr, km); | ||
| 1045 | last_page_nr = page_nr; | 1285 | last_page_nr = page_nr; |
| 1046 | } | 1286 | } |
| 1047 | if (val) | 1287 | if (val) |
| 1048 | c += (0 == __test_and_set_bit(bitnr & BPP_MASK, p_addr)); | 1288 | c += (0 == __test_and_set_bit_le(bitnr & BITS_PER_PAGE_MASK, p_addr)); |
| 1049 | else | 1289 | else |
| 1050 | c -= (0 != __test_and_clear_bit(bitnr & BPP_MASK, p_addr)); | 1290 | c -= (0 != __test_and_clear_bit_le(bitnr & BITS_PER_PAGE_MASK, p_addr)); |
| 1051 | } | 1291 | } |
| 1052 | if (p_addr) | 1292 | if (p_addr) |
| 1053 | __bm_unmap(p_addr, km); | 1293 | __bm_unmap(p_addr, km); |
| 1054 | b->bm_set += c; | 1294 | if (c < 0) |
| 1055 | return c; | 1295 | bm_set_page_lazy_writeout(b->bm_pages[last_page_nr]); |
| 1296 | else if (c > 0) | ||
| 1297 | bm_set_page_need_writeout(b->bm_pages[last_page_nr]); | ||
| 1298 | changed_total += c; | ||
| 1299 | b->bm_set += changed_total; | ||
| 1300 | return changed_total; | ||
| 1056 | } | 1301 | } |
| 1057 | 1302 | ||
| 1058 | /* returns number of bits actually changed. | 1303 | /* returns number of bits actually changed. |
| @@ -1070,7 +1315,7 @@ static int bm_change_bits_to(struct drbd_conf *mdev, const unsigned long s, | |||
| 1070 | ERR_IF(!b->bm_pages) return 0; | 1315 | ERR_IF(!b->bm_pages) return 0; |
| 1071 | 1316 | ||
| 1072 | spin_lock_irqsave(&b->bm_lock, flags); | 1317 | spin_lock_irqsave(&b->bm_lock, flags); |
| 1073 | if (bm_is_locked(b)) | 1318 | if ((val ? BM_DONT_SET : BM_DONT_CLEAR) & b->bm_flags) |
| 1074 | bm_print_lock_info(mdev); | 1319 | bm_print_lock_info(mdev); |
| 1075 | 1320 | ||
| 1076 | c = __bm_change_bits_to(mdev, s, e, val, KM_IRQ1); | 1321 | c = __bm_change_bits_to(mdev, s, e, val, KM_IRQ1); |
| @@ -1187,12 +1432,11 @@ int drbd_bm_test_bit(struct drbd_conf *mdev, const unsigned long bitnr) | |||
| 1187 | ERR_IF(!b->bm_pages) return 0; | 1432 | ERR_IF(!b->bm_pages) return 0; |
| 1188 | 1433 | ||
| 1189 | spin_lock_irqsave(&b->bm_lock, flags); | 1434 | spin_lock_irqsave(&b->bm_lock, flags); |
| 1190 | if (bm_is_locked(b)) | 1435 | if (BM_DONT_TEST & b->bm_flags) |
| 1191 | bm_print_lock_info(mdev); | 1436 | bm_print_lock_info(mdev); |
| 1192 | if (bitnr < b->bm_bits) { | 1437 | if (bitnr < b->bm_bits) { |
| 1193 | unsigned long offset = bitnr>>LN2_BPL; | 1438 | p_addr = bm_map_pidx(b, bm_bit_to_page_idx(b, bitnr)); |
| 1194 | p_addr = bm_map_paddr(b, offset); | 1439 | i = test_bit_le(bitnr & BITS_PER_PAGE_MASK, p_addr) ? 1 : 0; |
| 1195 | i = test_bit(bitnr & BPP_MASK, p_addr) ? 1 : 0; | ||
| 1196 | bm_unmap(p_addr); | 1440 | bm_unmap(p_addr); |
| 1197 | } else if (bitnr == b->bm_bits) { | 1441 | } else if (bitnr == b->bm_bits) { |
| 1198 | i = -1; | 1442 | i = -1; |
| @@ -1210,10 +1454,10 @@ int drbd_bm_count_bits(struct drbd_conf *mdev, const unsigned long s, const unsi | |||
| 1210 | { | 1454 | { |
| 1211 | unsigned long flags; | 1455 | unsigned long flags; |
| 1212 | struct drbd_bitmap *b = mdev->bitmap; | 1456 | struct drbd_bitmap *b = mdev->bitmap; |
| 1213 | unsigned long *p_addr = NULL, page_nr = -1; | 1457 | unsigned long *p_addr = NULL; |
| 1214 | unsigned long bitnr; | 1458 | unsigned long bitnr; |
| 1459 | unsigned int page_nr = -1U; | ||
| 1215 | int c = 0; | 1460 | int c = 0; |
| 1216 | size_t w; | ||
| 1217 | 1461 | ||
| 1218 | /* If this is called without a bitmap, that is a bug. But just to be | 1462 | /* If this is called without a bitmap, that is a bug. But just to be |
| 1219 | * robust in case we screwed up elsewhere, in that case pretend there | 1463 | * robust in case we screwed up elsewhere, in that case pretend there |
| @@ -1223,20 +1467,20 @@ int drbd_bm_count_bits(struct drbd_conf *mdev, const unsigned long s, const unsi | |||
| 1223 | ERR_IF(!b->bm_pages) return 1; | 1467 | ERR_IF(!b->bm_pages) return 1; |
| 1224 | 1468 | ||
| 1225 | spin_lock_irqsave(&b->bm_lock, flags); | 1469 | spin_lock_irqsave(&b->bm_lock, flags); |
| 1226 | if (bm_is_locked(b)) | 1470 | if (BM_DONT_TEST & b->bm_flags) |
| 1227 | bm_print_lock_info(mdev); | 1471 | bm_print_lock_info(mdev); |
| 1228 | for (bitnr = s; bitnr <= e; bitnr++) { | 1472 | for (bitnr = s; bitnr <= e; bitnr++) { |
| 1229 | w = bitnr >> LN2_BPL; | 1473 | unsigned int idx = bm_bit_to_page_idx(b, bitnr); |
| 1230 | if (page_nr != w >> (PAGE_SHIFT - LN2_BPL + 3)) { | 1474 | if (page_nr != idx) { |
| 1231 | page_nr = w >> (PAGE_SHIFT - LN2_BPL + 3); | 1475 | page_nr = idx; |
| 1232 | if (p_addr) | 1476 | if (p_addr) |
| 1233 | bm_unmap(p_addr); | 1477 | bm_unmap(p_addr); |
| 1234 | p_addr = bm_map_paddr(b, w); | 1478 | p_addr = bm_map_pidx(b, idx); |
| 1235 | } | 1479 | } |
| 1236 | ERR_IF (bitnr >= b->bm_bits) { | 1480 | ERR_IF (bitnr >= b->bm_bits) { |
| 1237 | dev_err(DEV, "bitnr=%lu bm_bits=%lu\n", bitnr, b->bm_bits); | 1481 | dev_err(DEV, "bitnr=%lu bm_bits=%lu\n", bitnr, b->bm_bits); |
| 1238 | } else { | 1482 | } else { |
| 1239 | c += (0 != test_bit(bitnr - (page_nr << (PAGE_SHIFT+3)), p_addr)); | 1483 | c += (0 != test_bit_le(bitnr - (page_nr << (PAGE_SHIFT+3)), p_addr)); |
| 1240 | } | 1484 | } |
| 1241 | } | 1485 | } |
| 1242 | if (p_addr) | 1486 | if (p_addr) |
| @@ -1271,7 +1515,7 @@ int drbd_bm_e_weight(struct drbd_conf *mdev, unsigned long enr) | |||
| 1271 | ERR_IF(!b->bm_pages) return 0; | 1515 | ERR_IF(!b->bm_pages) return 0; |
| 1272 | 1516 | ||
| 1273 | spin_lock_irqsave(&b->bm_lock, flags); | 1517 | spin_lock_irqsave(&b->bm_lock, flags); |
| 1274 | if (bm_is_locked(b)) | 1518 | if (BM_DONT_TEST & b->bm_flags) |
| 1275 | bm_print_lock_info(mdev); | 1519 | bm_print_lock_info(mdev); |
| 1276 | 1520 | ||
| 1277 | s = S2W(enr); | 1521 | s = S2W(enr); |
| @@ -1279,7 +1523,7 @@ int drbd_bm_e_weight(struct drbd_conf *mdev, unsigned long enr) | |||
| 1279 | count = 0; | 1523 | count = 0; |
| 1280 | if (s < b->bm_words) { | 1524 | if (s < b->bm_words) { |
| 1281 | int n = e-s; | 1525 | int n = e-s; |
| 1282 | p_addr = bm_map_paddr(b, s); | 1526 | p_addr = bm_map_pidx(b, bm_word_to_page_idx(b, s)); |
| 1283 | bm = p_addr + MLPP(s); | 1527 | bm = p_addr + MLPP(s); |
| 1284 | while (n--) | 1528 | while (n--) |
| 1285 | count += hweight_long(*bm++); | 1529 | count += hweight_long(*bm++); |
| @@ -1291,18 +1535,20 @@ int drbd_bm_e_weight(struct drbd_conf *mdev, unsigned long enr) | |||
| 1291 | return count; | 1535 | return count; |
| 1292 | } | 1536 | } |
| 1293 | 1537 | ||
| 1294 | /* set all bits covered by the AL-extent al_enr */ | 1538 | /* Set all bits covered by the AL-extent al_enr. |
| 1539 | * Returns number of bits changed. */ | ||
| 1295 | unsigned long drbd_bm_ALe_set_all(struct drbd_conf *mdev, unsigned long al_enr) | 1540 | unsigned long drbd_bm_ALe_set_all(struct drbd_conf *mdev, unsigned long al_enr) |
| 1296 | { | 1541 | { |
| 1297 | struct drbd_bitmap *b = mdev->bitmap; | 1542 | struct drbd_bitmap *b = mdev->bitmap; |
| 1298 | unsigned long *p_addr, *bm; | 1543 | unsigned long *p_addr, *bm; |
| 1299 | unsigned long weight; | 1544 | unsigned long weight; |
| 1300 | int count, s, e, i, do_now; | 1545 | unsigned long s, e; |
| 1546 | int count, i, do_now; | ||
| 1301 | ERR_IF(!b) return 0; | 1547 | ERR_IF(!b) return 0; |
| 1302 | ERR_IF(!b->bm_pages) return 0; | 1548 | ERR_IF(!b->bm_pages) return 0; |
| 1303 | 1549 | ||
| 1304 | spin_lock_irq(&b->bm_lock); | 1550 | spin_lock_irq(&b->bm_lock); |
| 1305 | if (bm_is_locked(b)) | 1551 | if (BM_DONT_SET & b->bm_flags) |
| 1306 | bm_print_lock_info(mdev); | 1552 | bm_print_lock_info(mdev); |
| 1307 | weight = b->bm_set; | 1553 | weight = b->bm_set; |
| 1308 | 1554 | ||
| @@ -1314,7 +1560,7 @@ unsigned long drbd_bm_ALe_set_all(struct drbd_conf *mdev, unsigned long al_enr) | |||
| 1314 | count = 0; | 1560 | count = 0; |
| 1315 | if (s < b->bm_words) { | 1561 | if (s < b->bm_words) { |
| 1316 | i = do_now = e-s; | 1562 | i = do_now = e-s; |
| 1317 | p_addr = bm_map_paddr(b, s); | 1563 | p_addr = bm_map_pidx(b, bm_word_to_page_idx(b, s)); |
| 1318 | bm = p_addr + MLPP(s); | 1564 | bm = p_addr + MLPP(s); |
| 1319 | while (i--) { | 1565 | while (i--) { |
| 1320 | count += hweight_long(*bm); | 1566 | count += hweight_long(*bm); |
| @@ -1326,7 +1572,7 @@ unsigned long drbd_bm_ALe_set_all(struct drbd_conf *mdev, unsigned long al_enr) | |||
| 1326 | if (e == b->bm_words) | 1572 | if (e == b->bm_words) |
| 1327 | b->bm_set -= bm_clear_surplus(b); | 1573 | b->bm_set -= bm_clear_surplus(b); |
| 1328 | } else { | 1574 | } else { |
| 1329 | dev_err(DEV, "start offset (%d) too large in drbd_bm_ALe_set_all\n", s); | 1575 | dev_err(DEV, "start offset (%lu) too large in drbd_bm_ALe_set_all\n", s); |
| 1330 | } | 1576 | } |
| 1331 | weight = b->bm_set - weight; | 1577 | weight = b->bm_set - weight; |
| 1332 | spin_unlock_irq(&b->bm_lock); | 1578 | spin_unlock_irq(&b->bm_lock); |
diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h index b0bd27dfc1e..81030d8d654 100644 --- a/drivers/block/drbd/drbd_int.h +++ b/drivers/block/drbd/drbd_int.h | |||
| @@ -72,13 +72,6 @@ extern int fault_devs; | |||
| 72 | extern char usermode_helper[]; | 72 | extern char usermode_helper[]; |
| 73 | 73 | ||
| 74 | 74 | ||
| 75 | #ifndef TRUE | ||
| 76 | #define TRUE 1 | ||
| 77 | #endif | ||
| 78 | #ifndef FALSE | ||
| 79 | #define FALSE 0 | ||
| 80 | #endif | ||
| 81 | |||
| 82 | /* I don't remember why XCPU ... | 75 | /* I don't remember why XCPU ... |
| 83 | * This is used to wake the asender, | 76 | * This is used to wake the asender, |
| 84 | * and to interrupt sending the sending task | 77 | * and to interrupt sending the sending task |
| @@ -104,6 +97,7 @@ extern char usermode_helper[]; | |||
| 104 | #define ID_SYNCER (-1ULL) | 97 | #define ID_SYNCER (-1ULL) |
| 105 | #define ID_VACANT 0 | 98 | #define ID_VACANT 0 |
| 106 | #define is_syncer_block_id(id) ((id) == ID_SYNCER) | 99 | #define is_syncer_block_id(id) ((id) == ID_SYNCER) |
| 100 | #define UUID_NEW_BM_OFFSET ((u64)0x0001000000000000ULL) | ||
| 107 | 101 | ||
| 108 | struct drbd_conf; | 102 | struct drbd_conf; |
| 109 | 103 | ||
| @@ -137,20 +131,19 @@ enum { | |||
| 137 | DRBD_FAULT_MAX, | 131 | DRBD_FAULT_MAX, |
| 138 | }; | 132 | }; |
| 139 | 133 | ||
| 140 | #ifdef CONFIG_DRBD_FAULT_INJECTION | ||
| 141 | extern unsigned int | 134 | extern unsigned int |
| 142 | _drbd_insert_fault(struct drbd_conf *mdev, unsigned int type); | 135 | _drbd_insert_fault(struct drbd_conf *mdev, unsigned int type); |
| 136 | |||
| 143 | static inline int | 137 | static inline int |
| 144 | drbd_insert_fault(struct drbd_conf *mdev, unsigned int type) { | 138 | drbd_insert_fault(struct drbd_conf *mdev, unsigned int type) { |
| 139 | #ifdef CONFIG_DRBD_FAULT_INJECTION | ||
| 145 | return fault_rate && | 140 | return fault_rate && |
| 146 | (enable_faults & (1<<type)) && | 141 | (enable_faults & (1<<type)) && |
| 147 | _drbd_insert_fault(mdev, type); | 142 | _drbd_insert_fault(mdev, type); |
| 148 | } | ||
| 149 | #define FAULT_ACTIVE(_m, _t) (drbd_insert_fault((_m), (_t))) | ||
| 150 | |||
| 151 | #else | 143 | #else |
| 152 | #define FAULT_ACTIVE(_m, _t) (0) | 144 | return 0; |
| 153 | #endif | 145 | #endif |
| 146 | } | ||
| 154 | 147 | ||
| 155 | /* integer division, round _UP_ to the next integer */ | 148 | /* integer division, round _UP_ to the next integer */ |
| 156 | #define div_ceil(A, B) ((A)/(B) + ((A)%(B) ? 1 : 0)) | 149 | #define div_ceil(A, B) ((A)/(B) + ((A)%(B) ? 1 : 0)) |
| @@ -212,8 +205,10 @@ enum drbd_packets { | |||
| 212 | /* P_CKPT_FENCE_REQ = 0x25, * currently reserved for protocol D */ | 205 | /* P_CKPT_FENCE_REQ = 0x25, * currently reserved for protocol D */ |
| 213 | /* P_CKPT_DISABLE_REQ = 0x26, * currently reserved for protocol D */ | 206 | /* P_CKPT_DISABLE_REQ = 0x26, * currently reserved for protocol D */ |
| 214 | P_DELAY_PROBE = 0x27, /* is used on BOTH sockets */ | 207 | P_DELAY_PROBE = 0x27, /* is used on BOTH sockets */ |
| 208 | P_OUT_OF_SYNC = 0x28, /* Mark as out of sync (Outrunning), data socket */ | ||
| 209 | P_RS_CANCEL = 0x29, /* meta: Used to cancel RS_DATA_REQUEST packet by SyncSource */ | ||
| 215 | 210 | ||
| 216 | P_MAX_CMD = 0x28, | 211 | P_MAX_CMD = 0x2A, |
| 217 | P_MAY_IGNORE = 0x100, /* Flag to test if (cmd > P_MAY_IGNORE) ... */ | 212 | P_MAY_IGNORE = 0x100, /* Flag to test if (cmd > P_MAY_IGNORE) ... */ |
| 218 | P_MAX_OPT_CMD = 0x101, | 213 | P_MAX_OPT_CMD = 0x101, |
| 219 | 214 | ||
| @@ -269,6 +264,7 @@ static inline const char *cmdname(enum drbd_packets cmd) | |||
| 269 | [P_RS_IS_IN_SYNC] = "CsumRSIsInSync", | 264 | [P_RS_IS_IN_SYNC] = "CsumRSIsInSync", |
| 270 | [P_COMPRESSED_BITMAP] = "CBitmap", | 265 | [P_COMPRESSED_BITMAP] = "CBitmap", |
| 271 | [P_DELAY_PROBE] = "DelayProbe", | 266 | [P_DELAY_PROBE] = "DelayProbe", |
| 267 | [P_OUT_OF_SYNC] = "OutOfSync", | ||
| 272 | [P_MAX_CMD] = NULL, | 268 | [P_MAX_CMD] = NULL, |
| 273 | }; | 269 | }; |
| 274 | 270 | ||
| @@ -512,7 +508,7 @@ struct p_sizes { | |||
| 512 | u64 d_size; /* size of disk */ | 508 | u64 d_size; /* size of disk */ |
| 513 | u64 u_size; /* user requested size */ | 509 | u64 u_size; /* user requested size */ |
| 514 | u64 c_size; /* current exported size */ | 510 | u64 c_size; /* current exported size */ |
| 515 | u32 max_segment_size; /* Maximal size of a BIO */ | 511 | u32 max_bio_size; /* Maximal size of a BIO */ |
| 516 | u16 queue_order_type; /* not yet implemented in DRBD*/ | 512 | u16 queue_order_type; /* not yet implemented in DRBD*/ |
| 517 | u16 dds_flags; /* use enum dds_flags here. */ | 513 | u16 dds_flags; /* use enum dds_flags here. */ |
| 518 | } __packed; | 514 | } __packed; |
| @@ -550,6 +546,13 @@ struct p_discard { | |||
| 550 | u32 pad; | 546 | u32 pad; |
| 551 | } __packed; | 547 | } __packed; |
| 552 | 548 | ||
| 549 | struct p_block_desc { | ||
| 550 | struct p_header80 head; | ||
| 551 | u64 sector; | ||
| 552 | u32 blksize; | ||
| 553 | u32 pad; /* to multiple of 8 Byte */ | ||
| 554 | } __packed; | ||
| 555 | |||
| 553 | /* Valid values for the encoding field. | 556 | /* Valid values for the encoding field. |
| 554 | * Bump proto version when changing this. */ | 557 | * Bump proto version when changing this. */ |
| 555 | enum drbd_bitmap_code { | 558 | enum drbd_bitmap_code { |
| @@ -647,6 +650,7 @@ union p_polymorph { | |||
| 647 | struct p_block_req block_req; | 650 | struct p_block_req block_req; |
| 648 | struct p_delay_probe93 delay_probe93; | 651 | struct p_delay_probe93 delay_probe93; |
| 649 | struct p_rs_uuid rs_uuid; | 652 | struct p_rs_uuid rs_uuid; |
| 653 | struct p_block_desc block_desc; | ||
| 650 | } __packed; | 654 | } __packed; |
| 651 | 655 | ||
| 652 | /**********************************************************************/ | 656 | /**********************************************************************/ |
| @@ -677,13 +681,6 @@ static inline enum drbd_thread_state get_t_state(struct drbd_thread *thi) | |||
| 677 | return thi->t_state; | 681 | return thi->t_state; |
| 678 | } | 682 | } |
| 679 | 683 | ||
| 680 | |||
| 681 | /* | ||
| 682 | * Having this as the first member of a struct provides sort of "inheritance". | ||
| 683 | * "derived" structs can be "drbd_queue_work()"ed. | ||
| 684 | * The callback should know and cast back to the descendant struct. | ||
| 685 | * drbd_request and drbd_epoch_entry are descendants of drbd_work. | ||
| 686 | */ | ||
| 687 | struct drbd_work; | 684 | struct drbd_work; |
| 688 | typedef int (*drbd_work_cb)(struct drbd_conf *, struct drbd_work *, int cancel); | 685 | typedef int (*drbd_work_cb)(struct drbd_conf *, struct drbd_work *, int cancel); |
| 689 | struct drbd_work { | 686 | struct drbd_work { |
| @@ -712,9 +709,6 @@ struct drbd_request { | |||
| 712 | * starting a new epoch... | 709 | * starting a new epoch... |
| 713 | */ | 710 | */ |
| 714 | 711 | ||
| 715 | /* up to here, the struct layout is identical to drbd_epoch_entry; | ||
| 716 | * we might be able to use that to our advantage... */ | ||
| 717 | |||
| 718 | struct list_head tl_requests; /* ring list in the transfer log */ | 712 | struct list_head tl_requests; /* ring list in the transfer log */ |
| 719 | struct bio *master_bio; /* master bio pointer */ | 713 | struct bio *master_bio; /* master bio pointer */ |
| 720 | unsigned long rq_state; /* see comments above _req_mod() */ | 714 | unsigned long rq_state; /* see comments above _req_mod() */ |
| @@ -831,7 +825,7 @@ enum { | |||
| 831 | CRASHED_PRIMARY, /* This node was a crashed primary. | 825 | CRASHED_PRIMARY, /* This node was a crashed primary. |
| 832 | * Gets cleared when the state.conn | 826 | * Gets cleared when the state.conn |
| 833 | * goes into C_CONNECTED state. */ | 827 | * goes into C_CONNECTED state. */ |
| 834 | WRITE_BM_AFTER_RESYNC, /* A kmalloc() during resync failed */ | 828 | NO_BARRIER_SUPP, /* underlying block device doesn't implement barriers */ |
| 835 | CONSIDER_RESYNC, | 829 | CONSIDER_RESYNC, |
| 836 | 830 | ||
| 837 | MD_NO_FUA, /* Users wants us to not use FUA/FLUSH on meta data dev */ | 831 | MD_NO_FUA, /* Users wants us to not use FUA/FLUSH on meta data dev */ |
| @@ -856,10 +850,37 @@ enum { | |||
| 856 | GOT_PING_ACK, /* set when we receive a ping_ack packet, misc wait gets woken */ | 850 | GOT_PING_ACK, /* set when we receive a ping_ack packet, misc wait gets woken */ |
| 857 | NEW_CUR_UUID, /* Create new current UUID when thawing IO */ | 851 | NEW_CUR_UUID, /* Create new current UUID when thawing IO */ |
| 858 | AL_SUSPENDED, /* Activity logging is currently suspended. */ | 852 | AL_SUSPENDED, /* Activity logging is currently suspended. */ |
| 853 | AHEAD_TO_SYNC_SOURCE, /* Ahead -> SyncSource queued */ | ||
| 859 | }; | 854 | }; |
| 860 | 855 | ||
| 861 | struct drbd_bitmap; /* opaque for drbd_conf */ | 856 | struct drbd_bitmap; /* opaque for drbd_conf */ |
| 862 | 857 | ||
| 858 | /* definition of bits in bm_flags to be used in drbd_bm_lock | ||
| 859 | * and drbd_bitmap_io and friends. */ | ||
| 860 | enum bm_flag { | ||
| 861 | /* do we need to kfree, or vfree bm_pages? */ | ||
| 862 | BM_P_VMALLOCED = 0x10000, /* internal use only, will be masked out */ | ||
| 863 | |||
| 864 | /* currently locked for bulk operation */ | ||
| 865 | BM_LOCKED_MASK = 0x7, | ||
| 866 | |||
| 867 | /* in detail, that is: */ | ||
| 868 | BM_DONT_CLEAR = 0x1, | ||
| 869 | BM_DONT_SET = 0x2, | ||
| 870 | BM_DONT_TEST = 0x4, | ||
| 871 | |||
| 872 | /* (test bit, count bit) allowed (common case) */ | ||
| 873 | BM_LOCKED_TEST_ALLOWED = 0x3, | ||
| 874 | |||
| 875 | /* testing bits, as well as setting new bits allowed, but clearing bits | ||
| 876 | * would be unexpected. Used during bitmap receive. Setting new bits | ||
| 877 | * requires sending of "out-of-sync" information, though. */ | ||
| 878 | BM_LOCKED_SET_ALLOWED = 0x1, | ||
| 879 | |||
| 880 | /* clear is not expected while bitmap is locked for bulk operation */ | ||
| 881 | }; | ||
| 882 | |||
| 883 | |||
| 863 | /* TODO sort members for performance | 884 | /* TODO sort members for performance |
| 864 | * MAYBE group them further */ | 885 | * MAYBE group them further */ |
| 865 | 886 | ||
| @@ -925,6 +946,7 @@ struct drbd_md_io { | |||
| 925 | struct bm_io_work { | 946 | struct bm_io_work { |
| 926 | struct drbd_work w; | 947 | struct drbd_work w; |
| 927 | char *why; | 948 | char *why; |
| 949 | enum bm_flag flags; | ||
| 928 | int (*io_fn)(struct drbd_conf *mdev); | 950 | int (*io_fn)(struct drbd_conf *mdev); |
| 929 | void (*done)(struct drbd_conf *mdev, int rv); | 951 | void (*done)(struct drbd_conf *mdev, int rv); |
| 930 | }; | 952 | }; |
| @@ -963,9 +985,12 @@ struct drbd_conf { | |||
| 963 | struct drbd_work resync_work, | 985 | struct drbd_work resync_work, |
| 964 | unplug_work, | 986 | unplug_work, |
| 965 | go_diskless, | 987 | go_diskless, |
| 966 | md_sync_work; | 988 | md_sync_work, |
| 989 | start_resync_work; | ||
| 967 | struct timer_list resync_timer; | 990 | struct timer_list resync_timer; |
| 968 | struct timer_list md_sync_timer; | 991 | struct timer_list md_sync_timer; |
| 992 | struct timer_list start_resync_timer; | ||
| 993 | struct timer_list request_timer; | ||
| 969 | #ifdef DRBD_DEBUG_MD_SYNC | 994 | #ifdef DRBD_DEBUG_MD_SYNC |
| 970 | struct { | 995 | struct { |
| 971 | unsigned int line; | 996 | unsigned int line; |
| @@ -1000,9 +1025,9 @@ struct drbd_conf { | |||
| 1000 | struct hlist_head *tl_hash; | 1025 | struct hlist_head *tl_hash; |
| 1001 | unsigned int tl_hash_s; | 1026 | unsigned int tl_hash_s; |
| 1002 | 1027 | ||
| 1003 | /* blocks to sync in this run [unit BM_BLOCK_SIZE] */ | 1028 | /* blocks to resync in this run [unit BM_BLOCK_SIZE] */ |
| 1004 | unsigned long rs_total; | 1029 | unsigned long rs_total; |
| 1005 | /* number of sync IOs that failed in this run */ | 1030 | /* number of resync blocks that failed in this run */ |
| 1006 | unsigned long rs_failed; | 1031 | unsigned long rs_failed; |
| 1007 | /* Syncer's start time [unit jiffies] */ | 1032 | /* Syncer's start time [unit jiffies] */ |
| 1008 | unsigned long rs_start; | 1033 | unsigned long rs_start; |
| @@ -1102,6 +1127,7 @@ struct drbd_conf { | |||
| 1102 | struct fifo_buffer rs_plan_s; /* correction values of resync planer */ | 1127 | struct fifo_buffer rs_plan_s; /* correction values of resync planer */ |
| 1103 | int rs_in_flight; /* resync sectors in flight (to proxy, in proxy and from proxy) */ | 1128 | int rs_in_flight; /* resync sectors in flight (to proxy, in proxy and from proxy) */ |
| 1104 | int rs_planed; /* resync sectors already planed */ | 1129 | int rs_planed; /* resync sectors already planed */ |
| 1130 | atomic_t ap_in_flight; /* App sectors in flight (waiting for ack) */ | ||
| 1105 | }; | 1131 | }; |
| 1106 | 1132 | ||
| 1107 | static inline struct drbd_conf *minor_to_mdev(unsigned int minor) | 1133 | static inline struct drbd_conf *minor_to_mdev(unsigned int minor) |
| @@ -1163,14 +1189,19 @@ enum dds_flags { | |||
| 1163 | }; | 1189 | }; |
| 1164 | 1190 | ||
| 1165 | extern void drbd_init_set_defaults(struct drbd_conf *mdev); | 1191 | extern void drbd_init_set_defaults(struct drbd_conf *mdev); |
| 1166 | extern int drbd_change_state(struct drbd_conf *mdev, enum chg_state_flags f, | 1192 | extern enum drbd_state_rv drbd_change_state(struct drbd_conf *mdev, |
| 1167 | union drbd_state mask, union drbd_state val); | 1193 | enum chg_state_flags f, |
| 1194 | union drbd_state mask, | ||
| 1195 | union drbd_state val); | ||
| 1168 | extern void drbd_force_state(struct drbd_conf *, union drbd_state, | 1196 | extern void drbd_force_state(struct drbd_conf *, union drbd_state, |
| 1169 | union drbd_state); | 1197 | union drbd_state); |
| 1170 | extern int _drbd_request_state(struct drbd_conf *, union drbd_state, | 1198 | extern enum drbd_state_rv _drbd_request_state(struct drbd_conf *, |
| 1171 | union drbd_state, enum chg_state_flags); | 1199 | union drbd_state, |
| 1172 | extern int __drbd_set_state(struct drbd_conf *, union drbd_state, | 1200 | union drbd_state, |
| 1173 | enum chg_state_flags, struct completion *done); | 1201 | enum chg_state_flags); |
| 1202 | extern enum drbd_state_rv __drbd_set_state(struct drbd_conf *, union drbd_state, | ||
| 1203 | enum chg_state_flags, | ||
| 1204 | struct completion *done); | ||
| 1174 | extern void print_st_err(struct drbd_conf *, union drbd_state, | 1205 | extern void print_st_err(struct drbd_conf *, union drbd_state, |
| 1175 | union drbd_state, int); | 1206 | union drbd_state, int); |
| 1176 | extern int drbd_thread_start(struct drbd_thread *thi); | 1207 | extern int drbd_thread_start(struct drbd_thread *thi); |
| @@ -1195,7 +1226,7 @@ extern int drbd_send(struct drbd_conf *mdev, struct socket *sock, | |||
| 1195 | extern int drbd_send_protocol(struct drbd_conf *mdev); | 1226 | extern int drbd_send_protocol(struct drbd_conf *mdev); |
| 1196 | extern int drbd_send_uuids(struct drbd_conf *mdev); | 1227 | extern int drbd_send_uuids(struct drbd_conf *mdev); |
| 1197 | extern int drbd_send_uuids_skip_initial_sync(struct drbd_conf *mdev); | 1228 | extern int drbd_send_uuids_skip_initial_sync(struct drbd_conf *mdev); |
| 1198 | extern int drbd_send_sync_uuid(struct drbd_conf *mdev, u64 val); | 1229 | extern int drbd_gen_and_send_sync_uuid(struct drbd_conf *mdev); |
| 1199 | extern int drbd_send_sizes(struct drbd_conf *mdev, int trigger_reply, enum dds_flags flags); | 1230 | extern int drbd_send_sizes(struct drbd_conf *mdev, int trigger_reply, enum dds_flags flags); |
| 1200 | extern int _drbd_send_state(struct drbd_conf *mdev); | 1231 | extern int _drbd_send_state(struct drbd_conf *mdev); |
| 1201 | extern int drbd_send_state(struct drbd_conf *mdev); | 1232 | extern int drbd_send_state(struct drbd_conf *mdev); |
| @@ -1220,11 +1251,10 @@ extern int drbd_send_ack_dp(struct drbd_conf *mdev, enum drbd_packets cmd, | |||
| 1220 | struct p_data *dp, int data_size); | 1251 | struct p_data *dp, int data_size); |
| 1221 | extern int drbd_send_ack_ex(struct drbd_conf *mdev, enum drbd_packets cmd, | 1252 | extern int drbd_send_ack_ex(struct drbd_conf *mdev, enum drbd_packets cmd, |
| 1222 | sector_t sector, int blksize, u64 block_id); | 1253 | sector_t sector, int blksize, u64 block_id); |
| 1254 | extern int drbd_send_oos(struct drbd_conf *mdev, struct drbd_request *req); | ||
| 1223 | extern int drbd_send_block(struct drbd_conf *mdev, enum drbd_packets cmd, | 1255 | extern int drbd_send_block(struct drbd_conf *mdev, enum drbd_packets cmd, |
| 1224 | struct drbd_epoch_entry *e); | 1256 | struct drbd_epoch_entry *e); |
| 1225 | extern int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req); | 1257 | extern int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req); |
| 1226 | extern int _drbd_send_barrier(struct drbd_conf *mdev, | ||
| 1227 | struct drbd_tl_epoch *barrier); | ||
| 1228 | extern int drbd_send_drequest(struct drbd_conf *mdev, int cmd, | 1258 | extern int drbd_send_drequest(struct drbd_conf *mdev, int cmd, |
| 1229 | sector_t sector, int size, u64 block_id); | 1259 | sector_t sector, int size, u64 block_id); |
| 1230 | extern int drbd_send_drequest_csum(struct drbd_conf *mdev, | 1260 | extern int drbd_send_drequest_csum(struct drbd_conf *mdev, |
| @@ -1235,14 +1265,13 @@ extern int drbd_send_ov_request(struct drbd_conf *mdev,sector_t sector,int size) | |||
| 1235 | 1265 | ||
| 1236 | extern int drbd_send_bitmap(struct drbd_conf *mdev); | 1266 | extern int drbd_send_bitmap(struct drbd_conf *mdev); |
| 1237 | extern int _drbd_send_bitmap(struct drbd_conf *mdev); | 1267 | extern int _drbd_send_bitmap(struct drbd_conf *mdev); |
| 1238 | extern int drbd_send_sr_reply(struct drbd_conf *mdev, int retcode); | 1268 | extern int drbd_send_sr_reply(struct drbd_conf *mdev, enum drbd_state_rv retcode); |
| 1239 | extern void drbd_free_bc(struct drbd_backing_dev *ldev); | 1269 | extern void drbd_free_bc(struct drbd_backing_dev *ldev); |
| 1240 | extern void drbd_mdev_cleanup(struct drbd_conf *mdev); | 1270 | extern void drbd_mdev_cleanup(struct drbd_conf *mdev); |
| 1271 | void drbd_print_uuids(struct drbd_conf *mdev, const char *text); | ||
| 1241 | 1272 | ||
| 1242 | /* drbd_meta-data.c (still in drbd_main.c) */ | ||
| 1243 | extern void drbd_md_sync(struct drbd_conf *mdev); | 1273 | extern void drbd_md_sync(struct drbd_conf *mdev); |
| 1244 | extern int drbd_md_read(struct drbd_conf *mdev, struct drbd_backing_dev *bdev); | 1274 | extern int drbd_md_read(struct drbd_conf *mdev, struct drbd_backing_dev *bdev); |
| 1245 | /* maybe define them below as inline? */ | ||
| 1246 | extern void drbd_uuid_set(struct drbd_conf *mdev, int idx, u64 val) __must_hold(local); | 1275 | extern void drbd_uuid_set(struct drbd_conf *mdev, int idx, u64 val) __must_hold(local); |
| 1247 | extern void _drbd_uuid_set(struct drbd_conf *mdev, int idx, u64 val) __must_hold(local); | 1276 | extern void _drbd_uuid_set(struct drbd_conf *mdev, int idx, u64 val) __must_hold(local); |
| 1248 | extern void drbd_uuid_new_current(struct drbd_conf *mdev) __must_hold(local); | 1277 | extern void drbd_uuid_new_current(struct drbd_conf *mdev) __must_hold(local); |
| @@ -1261,10 +1290,12 @@ extern void drbd_md_mark_dirty_(struct drbd_conf *mdev, | |||
| 1261 | extern void drbd_queue_bitmap_io(struct drbd_conf *mdev, | 1290 | extern void drbd_queue_bitmap_io(struct drbd_conf *mdev, |
| 1262 | int (*io_fn)(struct drbd_conf *), | 1291 | int (*io_fn)(struct drbd_conf *), |
| 1263 | void (*done)(struct drbd_conf *, int), | 1292 | void (*done)(struct drbd_conf *, int), |
| 1264 | char *why); | 1293 | char *why, enum bm_flag flags); |
| 1294 | extern int drbd_bitmap_io(struct drbd_conf *mdev, | ||
| 1295 | int (*io_fn)(struct drbd_conf *), | ||
| 1296 | char *why, enum bm_flag flags); | ||
| 1265 | extern int drbd_bmio_set_n_write(struct drbd_conf *mdev); | 1297 | extern int drbd_bmio_set_n_write(struct drbd_conf *mdev); |
| 1266 | extern int drbd_bmio_clear_n_write(struct drbd_conf *mdev); | 1298 | extern int drbd_bmio_clear_n_write(struct drbd_conf *mdev); |
| 1267 | extern int drbd_bitmap_io(struct drbd_conf *mdev, int (*io_fn)(struct drbd_conf *), char *why); | ||
| 1268 | extern void drbd_go_diskless(struct drbd_conf *mdev); | 1299 | extern void drbd_go_diskless(struct drbd_conf *mdev); |
| 1269 | extern void drbd_ldev_destroy(struct drbd_conf *mdev); | 1300 | extern void drbd_ldev_destroy(struct drbd_conf *mdev); |
| 1270 | 1301 | ||
| @@ -1313,6 +1344,7 @@ struct bm_extent { | |||
| 1313 | 1344 | ||
| 1314 | #define BME_NO_WRITES 0 /* bm_extent.flags: no more requests on this one! */ | 1345 | #define BME_NO_WRITES 0 /* bm_extent.flags: no more requests on this one! */ |
| 1315 | #define BME_LOCKED 1 /* bm_extent.flags: syncer active on this one. */ | 1346 | #define BME_LOCKED 1 /* bm_extent.flags: syncer active on this one. */ |
| 1347 | #define BME_PRIORITY 2 /* finish resync IO on this extent ASAP! App IO waiting! */ | ||
| 1316 | 1348 | ||
| 1317 | /* drbd_bitmap.c */ | 1349 | /* drbd_bitmap.c */ |
| 1318 | /* | 1350 | /* |
| @@ -1390,7 +1422,9 @@ struct bm_extent { | |||
| 1390 | * you should use 64bit OS for that much storage, anyways. */ | 1422 | * you should use 64bit OS for that much storage, anyways. */ |
| 1391 | #define DRBD_MAX_SECTORS_FLEX BM_BIT_TO_SECT(0xffff7fff) | 1423 | #define DRBD_MAX_SECTORS_FLEX BM_BIT_TO_SECT(0xffff7fff) |
| 1392 | #else | 1424 | #else |
| 1393 | #define DRBD_MAX_SECTORS_FLEX BM_BIT_TO_SECT(0x1LU << 32) | 1425 | /* we allow up to 1 PiB now on 64bit architecture with "flexible" meta data */ |
| 1426 | #define DRBD_MAX_SECTORS_FLEX (1UL << 51) | ||
| 1427 | /* corresponds to (1UL << 38) bits right now. */ | ||
| 1394 | #endif | 1428 | #endif |
| 1395 | #endif | 1429 | #endif |
| 1396 | 1430 | ||
| @@ -1398,7 +1432,7 @@ struct bm_extent { | |||
| 1398 | * With a value of 8 all IO in one 128K block make it to the same slot of the | 1432 | * With a value of 8 all IO in one 128K block make it to the same slot of the |
| 1399 | * hash table. */ | 1433 | * hash table. */ |
| 1400 | #define HT_SHIFT 8 | 1434 | #define HT_SHIFT 8 |
| 1401 | #define DRBD_MAX_SEGMENT_SIZE (1U<<(9+HT_SHIFT)) | 1435 | #define DRBD_MAX_BIO_SIZE (1U<<(9+HT_SHIFT)) |
| 1402 | 1436 | ||
| 1403 | #define DRBD_MAX_SIZE_H80_PACKET (1 << 15) /* The old header only allows packets up to 32Kib data */ | 1437 | #define DRBD_MAX_SIZE_H80_PACKET (1 << 15) /* The old header only allows packets up to 32Kib data */ |
| 1404 | 1438 | ||
| @@ -1410,16 +1444,20 @@ extern int drbd_bm_resize(struct drbd_conf *mdev, sector_t sectors, int set_new | |||
| 1410 | extern void drbd_bm_cleanup(struct drbd_conf *mdev); | 1444 | extern void drbd_bm_cleanup(struct drbd_conf *mdev); |
| 1411 | extern void drbd_bm_set_all(struct drbd_conf *mdev); | 1445 | extern void drbd_bm_set_all(struct drbd_conf *mdev); |
| 1412 | extern void drbd_bm_clear_all(struct drbd_conf *mdev); | 1446 | extern void drbd_bm_clear_all(struct drbd_conf *mdev); |
| 1447 | /* set/clear/test only a few bits at a time */ | ||
| 1413 | extern int drbd_bm_set_bits( | 1448 | extern int drbd_bm_set_bits( |
| 1414 | struct drbd_conf *mdev, unsigned long s, unsigned long e); | 1449 | struct drbd_conf *mdev, unsigned long s, unsigned long e); |
| 1415 | extern int drbd_bm_clear_bits( | 1450 | extern int drbd_bm_clear_bits( |
| 1416 | struct drbd_conf *mdev, unsigned long s, unsigned long e); | 1451 | struct drbd_conf *mdev, unsigned long s, unsigned long e); |
| 1417 | /* bm_set_bits variant for use while holding drbd_bm_lock */ | 1452 | extern int drbd_bm_count_bits( |
| 1453 | struct drbd_conf *mdev, const unsigned long s, const unsigned long e); | ||
| 1454 | /* bm_set_bits variant for use while holding drbd_bm_lock, | ||
| 1455 | * may process the whole bitmap in one go */ | ||
| 1418 | extern void _drbd_bm_set_bits(struct drbd_conf *mdev, | 1456 | extern void _drbd_bm_set_bits(struct drbd_conf *mdev, |
| 1419 | const unsigned long s, const unsigned long e); | 1457 | const unsigned long s, const unsigned long e); |
| 1420 | extern int drbd_bm_test_bit(struct drbd_conf *mdev, unsigned long bitnr); | 1458 | extern int drbd_bm_test_bit(struct drbd_conf *mdev, unsigned long bitnr); |
| 1421 | extern int drbd_bm_e_weight(struct drbd_conf *mdev, unsigned long enr); | 1459 | extern int drbd_bm_e_weight(struct drbd_conf *mdev, unsigned long enr); |
| 1422 | extern int drbd_bm_write_sect(struct drbd_conf *mdev, unsigned long enr) __must_hold(local); | 1460 | extern int drbd_bm_write_page(struct drbd_conf *mdev, unsigned int idx) __must_hold(local); |
| 1423 | extern int drbd_bm_read(struct drbd_conf *mdev) __must_hold(local); | 1461 | extern int drbd_bm_read(struct drbd_conf *mdev) __must_hold(local); |
| 1424 | extern int drbd_bm_write(struct drbd_conf *mdev) __must_hold(local); | 1462 | extern int drbd_bm_write(struct drbd_conf *mdev) __must_hold(local); |
| 1425 | extern unsigned long drbd_bm_ALe_set_all(struct drbd_conf *mdev, | 1463 | extern unsigned long drbd_bm_ALe_set_all(struct drbd_conf *mdev, |
| @@ -1427,6 +1465,8 @@ extern unsigned long drbd_bm_ALe_set_all(struct drbd_conf *mdev, | |||
| 1427 | extern size_t drbd_bm_words(struct drbd_conf *mdev); | 1465 | extern size_t drbd_bm_words(struct drbd_conf *mdev); |
| 1428 | extern unsigned long drbd_bm_bits(struct drbd_conf *mdev); | 1466 | extern unsigned long drbd_bm_bits(struct drbd_conf *mdev); |
| 1429 | extern sector_t drbd_bm_capacity(struct drbd_conf *mdev); | 1467 | extern sector_t drbd_bm_capacity(struct drbd_conf *mdev); |
| 1468 | |||
| 1469 | #define DRBD_END_OF_BITMAP (~(unsigned long)0) | ||
| 1430 | extern unsigned long drbd_bm_find_next(struct drbd_conf *mdev, unsigned long bm_fo); | 1470 | extern unsigned long drbd_bm_find_next(struct drbd_conf *mdev, unsigned long bm_fo); |
| 1431 | /* bm_find_next variants for use while you hold drbd_bm_lock() */ | 1471 | /* bm_find_next variants for use while you hold drbd_bm_lock() */ |
| 1432 | extern unsigned long _drbd_bm_find_next(struct drbd_conf *mdev, unsigned long bm_fo); | 1472 | extern unsigned long _drbd_bm_find_next(struct drbd_conf *mdev, unsigned long bm_fo); |
| @@ -1437,14 +1477,12 @@ extern int drbd_bm_rs_done(struct drbd_conf *mdev); | |||
| 1437 | /* for receive_bitmap */ | 1477 | /* for receive_bitmap */ |
| 1438 | extern void drbd_bm_merge_lel(struct drbd_conf *mdev, size_t offset, | 1478 | extern void drbd_bm_merge_lel(struct drbd_conf *mdev, size_t offset, |
| 1439 | size_t number, unsigned long *buffer); | 1479 | size_t number, unsigned long *buffer); |
| 1440 | /* for _drbd_send_bitmap and drbd_bm_write_sect */ | 1480 | /* for _drbd_send_bitmap */ |
| 1441 | extern void drbd_bm_get_lel(struct drbd_conf *mdev, size_t offset, | 1481 | extern void drbd_bm_get_lel(struct drbd_conf *mdev, size_t offset, |
| 1442 | size_t number, unsigned long *buffer); | 1482 | size_t number, unsigned long *buffer); |
| 1443 | 1483 | ||
| 1444 | extern void drbd_bm_lock(struct drbd_conf *mdev, char *why); | 1484 | extern void drbd_bm_lock(struct drbd_conf *mdev, char *why, enum bm_flag flags); |
| 1445 | extern void drbd_bm_unlock(struct drbd_conf *mdev); | 1485 | extern void drbd_bm_unlock(struct drbd_conf *mdev); |
| 1446 | |||
| 1447 | extern int drbd_bm_count_bits(struct drbd_conf *mdev, const unsigned long s, const unsigned long e); | ||
| 1448 | /* drbd_main.c */ | 1486 | /* drbd_main.c */ |
| 1449 | 1487 | ||
| 1450 | extern struct kmem_cache *drbd_request_cache; | 1488 | extern struct kmem_cache *drbd_request_cache; |
| @@ -1467,7 +1505,7 @@ extern void drbd_free_mdev(struct drbd_conf *mdev); | |||
| 1467 | extern int proc_details; | 1505 | extern int proc_details; |
| 1468 | 1506 | ||
| 1469 | /* drbd_req */ | 1507 | /* drbd_req */ |
| 1470 | extern int drbd_make_request_26(struct request_queue *q, struct bio *bio); | 1508 | extern int drbd_make_request(struct request_queue *q, struct bio *bio); |
| 1471 | extern int drbd_read_remote(struct drbd_conf *mdev, struct drbd_request *req); | 1509 | extern int drbd_read_remote(struct drbd_conf *mdev, struct drbd_request *req); |
| 1472 | extern int drbd_merge_bvec(struct request_queue *q, struct bvec_merge_data *bvm, struct bio_vec *bvec); | 1510 | extern int drbd_merge_bvec(struct request_queue *q, struct bvec_merge_data *bvm, struct bio_vec *bvec); |
| 1473 | extern int is_valid_ar_handle(struct drbd_request *, sector_t); | 1511 | extern int is_valid_ar_handle(struct drbd_request *, sector_t); |
| @@ -1482,8 +1520,9 @@ enum determine_dev_size { dev_size_error = -1, unchanged = 0, shrunk = 1, grew = | |||
| 1482 | extern enum determine_dev_size drbd_determin_dev_size(struct drbd_conf *, enum dds_flags) __must_hold(local); | 1520 | extern enum determine_dev_size drbd_determin_dev_size(struct drbd_conf *, enum dds_flags) __must_hold(local); |
| 1483 | extern void resync_after_online_grow(struct drbd_conf *); | 1521 | extern void resync_after_online_grow(struct drbd_conf *); |
| 1484 | extern void drbd_setup_queue_param(struct drbd_conf *mdev, unsigned int) __must_hold(local); | 1522 | extern void drbd_setup_queue_param(struct drbd_conf *mdev, unsigned int) __must_hold(local); |
| 1485 | extern int drbd_set_role(struct drbd_conf *mdev, enum drbd_role new_role, | 1523 | extern enum drbd_state_rv drbd_set_role(struct drbd_conf *mdev, |
| 1486 | int force); | 1524 | enum drbd_role new_role, |
| 1525 | int force); | ||
| 1487 | extern enum drbd_disk_state drbd_try_outdate_peer(struct drbd_conf *mdev); | 1526 | extern enum drbd_disk_state drbd_try_outdate_peer(struct drbd_conf *mdev); |
| 1488 | extern void drbd_try_outdate_peer_async(struct drbd_conf *mdev); | 1527 | extern void drbd_try_outdate_peer_async(struct drbd_conf *mdev); |
| 1489 | extern int drbd_khelper(struct drbd_conf *mdev, char *cmd); | 1528 | extern int drbd_khelper(struct drbd_conf *mdev, char *cmd); |
| @@ -1499,6 +1538,7 @@ extern int drbd_resync_finished(struct drbd_conf *mdev); | |||
| 1499 | extern int drbd_md_sync_page_io(struct drbd_conf *mdev, | 1538 | extern int drbd_md_sync_page_io(struct drbd_conf *mdev, |
| 1500 | struct drbd_backing_dev *bdev, sector_t sector, int rw); | 1539 | struct drbd_backing_dev *bdev, sector_t sector, int rw); |
| 1501 | extern void drbd_ov_oos_found(struct drbd_conf*, sector_t, int); | 1540 | extern void drbd_ov_oos_found(struct drbd_conf*, sector_t, int); |
| 1541 | extern void drbd_rs_controller_reset(struct drbd_conf *mdev); | ||
| 1502 | 1542 | ||
| 1503 | static inline void ov_oos_print(struct drbd_conf *mdev) | 1543 | static inline void ov_oos_print(struct drbd_conf *mdev) |
| 1504 | { | 1544 | { |
| @@ -1522,21 +1562,23 @@ extern int w_e_end_csum_rs_req(struct drbd_conf *, struct drbd_work *, int); | |||
| 1522 | extern int w_e_end_ov_reply(struct drbd_conf *, struct drbd_work *, int); | 1562 | extern int w_e_end_ov_reply(struct drbd_conf *, struct drbd_work *, int); |
| 1523 | extern int w_e_end_ov_req(struct drbd_conf *, struct drbd_work *, int); | 1563 | extern int w_e_end_ov_req(struct drbd_conf *, struct drbd_work *, int); |
| 1524 | extern int w_ov_finished(struct drbd_conf *, struct drbd_work *, int); | 1564 | extern int w_ov_finished(struct drbd_conf *, struct drbd_work *, int); |
| 1525 | extern int w_resync_inactive(struct drbd_conf *, struct drbd_work *, int); | 1565 | extern int w_resync_timer(struct drbd_conf *, struct drbd_work *, int); |
| 1526 | extern int w_resume_next_sg(struct drbd_conf *, struct drbd_work *, int); | 1566 | extern int w_resume_next_sg(struct drbd_conf *, struct drbd_work *, int); |
| 1527 | extern int w_send_write_hint(struct drbd_conf *, struct drbd_work *, int); | 1567 | extern int w_send_write_hint(struct drbd_conf *, struct drbd_work *, int); |
| 1528 | extern int w_make_resync_request(struct drbd_conf *, struct drbd_work *, int); | ||
| 1529 | extern int w_send_dblock(struct drbd_conf *, struct drbd_work *, int); | 1568 | extern int w_send_dblock(struct drbd_conf *, struct drbd_work *, int); |
| 1530 | extern int w_send_barrier(struct drbd_conf *, struct drbd_work *, int); | 1569 | extern int w_send_barrier(struct drbd_conf *, struct drbd_work *, int); |
| 1531 | extern int w_send_read_req(struct drbd_conf *, struct drbd_work *, int); | 1570 | extern int w_send_read_req(struct drbd_conf *, struct drbd_work *, int); |
| 1532 | extern int w_prev_work_done(struct drbd_conf *, struct drbd_work *, int); | 1571 | extern int w_prev_work_done(struct drbd_conf *, struct drbd_work *, int); |
| 1533 | extern int w_e_reissue(struct drbd_conf *, struct drbd_work *, int); | 1572 | extern int w_e_reissue(struct drbd_conf *, struct drbd_work *, int); |
| 1534 | extern int w_restart_disk_io(struct drbd_conf *, struct drbd_work *, int); | 1573 | extern int w_restart_disk_io(struct drbd_conf *, struct drbd_work *, int); |
| 1574 | extern int w_send_oos(struct drbd_conf *, struct drbd_work *, int); | ||
| 1575 | extern int w_start_resync(struct drbd_conf *, struct drbd_work *, int); | ||
| 1535 | 1576 | ||
| 1536 | extern void resync_timer_fn(unsigned long data); | 1577 | extern void resync_timer_fn(unsigned long data); |
| 1578 | extern void start_resync_timer_fn(unsigned long data); | ||
| 1537 | 1579 | ||
| 1538 | /* drbd_receiver.c */ | 1580 | /* drbd_receiver.c */ |
| 1539 | extern int drbd_rs_should_slow_down(struct drbd_conf *mdev); | 1581 | extern int drbd_rs_should_slow_down(struct drbd_conf *mdev, sector_t sector); |
| 1540 | extern int drbd_submit_ee(struct drbd_conf *mdev, struct drbd_epoch_entry *e, | 1582 | extern int drbd_submit_ee(struct drbd_conf *mdev, struct drbd_epoch_entry *e, |
| 1541 | const unsigned rw, const int fault_type); | 1583 | const unsigned rw, const int fault_type); |
| 1542 | extern int drbd_release_ee(struct drbd_conf *mdev, struct list_head *list); | 1584 | extern int drbd_release_ee(struct drbd_conf *mdev, struct list_head *list); |
| @@ -1619,16 +1661,16 @@ extern int drbd_rs_del_all(struct drbd_conf *mdev); | |||
| 1619 | extern void drbd_rs_failed_io(struct drbd_conf *mdev, | 1661 | extern void drbd_rs_failed_io(struct drbd_conf *mdev, |
| 1620 | sector_t sector, int size); | 1662 | sector_t sector, int size); |
| 1621 | extern int drbd_al_read_log(struct drbd_conf *mdev, struct drbd_backing_dev *); | 1663 | extern int drbd_al_read_log(struct drbd_conf *mdev, struct drbd_backing_dev *); |
| 1664 | extern void drbd_advance_rs_marks(struct drbd_conf *mdev, unsigned long still_to_go); | ||
| 1622 | extern void __drbd_set_in_sync(struct drbd_conf *mdev, sector_t sector, | 1665 | extern void __drbd_set_in_sync(struct drbd_conf *mdev, sector_t sector, |
| 1623 | int size, const char *file, const unsigned int line); | 1666 | int size, const char *file, const unsigned int line); |
| 1624 | #define drbd_set_in_sync(mdev, sector, size) \ | 1667 | #define drbd_set_in_sync(mdev, sector, size) \ |
| 1625 | __drbd_set_in_sync(mdev, sector, size, __FILE__, __LINE__) | 1668 | __drbd_set_in_sync(mdev, sector, size, __FILE__, __LINE__) |
| 1626 | extern void __drbd_set_out_of_sync(struct drbd_conf *mdev, sector_t sector, | 1669 | extern int __drbd_set_out_of_sync(struct drbd_conf *mdev, sector_t sector, |
| 1627 | int size, const char *file, const unsigned int line); | 1670 | int size, const char *file, const unsigned int line); |
| 1628 | #define drbd_set_out_of_sync(mdev, sector, size) \ | 1671 | #define drbd_set_out_of_sync(mdev, sector, size) \ |
| 1629 | __drbd_set_out_of_sync(mdev, sector, size, __FILE__, __LINE__) | 1672 | __drbd_set_out_of_sync(mdev, sector, size, __FILE__, __LINE__) |
| 1630 | extern void drbd_al_apply_to_bm(struct drbd_conf *mdev); | 1673 | extern void drbd_al_apply_to_bm(struct drbd_conf *mdev); |
| 1631 | extern void drbd_al_to_on_disk_bm(struct drbd_conf *mdev); | ||
| 1632 | extern void drbd_al_shrink(struct drbd_conf *mdev); | 1674 | extern void drbd_al_shrink(struct drbd_conf *mdev); |
| 1633 | 1675 | ||
| 1634 | 1676 | ||
| @@ -1747,11 +1789,11 @@ static inline void drbd_state_unlock(struct drbd_conf *mdev) | |||
| 1747 | wake_up(&mdev->misc_wait); | 1789 | wake_up(&mdev->misc_wait); |
| 1748 | } | 1790 | } |
| 1749 | 1791 | ||
| 1750 | static inline int _drbd_set_state(struct drbd_conf *mdev, | 1792 | static inline enum drbd_state_rv |
| 1751 | union drbd_state ns, enum chg_state_flags flags, | 1793 | _drbd_set_state(struct drbd_conf *mdev, union drbd_state ns, |
| 1752 | struct completion *done) | 1794 | enum chg_state_flags flags, struct completion *done) |
| 1753 | { | 1795 | { |
| 1754 | int rv; | 1796 | enum drbd_state_rv rv; |
| 1755 | 1797 | ||
| 1756 | read_lock(&global_state_lock); | 1798 | read_lock(&global_state_lock); |
| 1757 | rv = __drbd_set_state(mdev, ns, flags, done); | 1799 | rv = __drbd_set_state(mdev, ns, flags, done); |
| @@ -1982,17 +2024,17 @@ static inline int drbd_send_ping_ack(struct drbd_conf *mdev) | |||
| 1982 | 2024 | ||
| 1983 | static inline void drbd_thread_stop(struct drbd_thread *thi) | 2025 | static inline void drbd_thread_stop(struct drbd_thread *thi) |
| 1984 | { | 2026 | { |
| 1985 | _drbd_thread_stop(thi, FALSE, TRUE); | 2027 | _drbd_thread_stop(thi, false, true); |
| 1986 | } | 2028 | } |
| 1987 | 2029 | ||
| 1988 | static inline void drbd_thread_stop_nowait(struct drbd_thread *thi) | 2030 | static inline void drbd_thread_stop_nowait(struct drbd_thread *thi) |
| 1989 | { | 2031 | { |
| 1990 | _drbd_thread_stop(thi, FALSE, FALSE); | 2032 | _drbd_thread_stop(thi, false, false); |
| 1991 | } | 2033 | } |
| 1992 | 2034 | ||
| 1993 | static inline void drbd_thread_restart_nowait(struct drbd_thread *thi) | 2035 | static inline void drbd_thread_restart_nowait(struct drbd_thread *thi) |
| 1994 | { | 2036 | { |
| 1995 | _drbd_thread_stop(thi, TRUE, FALSE); | 2037 | _drbd_thread_stop(thi, true, false); |
| 1996 | } | 2038 | } |
| 1997 | 2039 | ||
| 1998 | /* counts how many answer packets packets we expect from our peer, | 2040 | /* counts how many answer packets packets we expect from our peer, |
| @@ -2146,17 +2188,18 @@ extern int _get_ldev_if_state(struct drbd_conf *mdev, enum drbd_disk_state mins) | |||
| 2146 | static inline void drbd_get_syncer_progress(struct drbd_conf *mdev, | 2188 | static inline void drbd_get_syncer_progress(struct drbd_conf *mdev, |
| 2147 | unsigned long *bits_left, unsigned int *per_mil_done) | 2189 | unsigned long *bits_left, unsigned int *per_mil_done) |
| 2148 | { | 2190 | { |
| 2149 | /* | 2191 | /* this is to break it at compile time when we change that, in case we |
| 2150 | * this is to break it at compile time when we change that | 2192 | * want to support more than (1<<32) bits on a 32bit arch. */ |
| 2151 | * (we may feel 4TB maximum storage per drbd is not enough) | ||
| 2152 | */ | ||
| 2153 | typecheck(unsigned long, mdev->rs_total); | 2193 | typecheck(unsigned long, mdev->rs_total); |
| 2154 | 2194 | ||
| 2155 | /* note: both rs_total and rs_left are in bits, i.e. in | 2195 | /* note: both rs_total and rs_left are in bits, i.e. in |
| 2156 | * units of BM_BLOCK_SIZE. | 2196 | * units of BM_BLOCK_SIZE. |
| 2157 | * for the percentage, we don't care. */ | 2197 | * for the percentage, we don't care. */ |
| 2158 | 2198 | ||
| 2159 | *bits_left = drbd_bm_total_weight(mdev) - mdev->rs_failed; | 2199 | if (mdev->state.conn == C_VERIFY_S || mdev->state.conn == C_VERIFY_T) |
| 2200 | *bits_left = mdev->ov_left; | ||
| 2201 | else | ||
| 2202 | *bits_left = drbd_bm_total_weight(mdev) - mdev->rs_failed; | ||
| 2160 | /* >> 10 to prevent overflow, | 2203 | /* >> 10 to prevent overflow, |
| 2161 | * +1 to prevent division by zero */ | 2204 | * +1 to prevent division by zero */ |
| 2162 | if (*bits_left > mdev->rs_total) { | 2205 | if (*bits_left > mdev->rs_total) { |
| @@ -2171,10 +2214,19 @@ static inline void drbd_get_syncer_progress(struct drbd_conf *mdev, | |||
| 2171 | *bits_left, mdev->rs_total, mdev->rs_failed); | 2214 | *bits_left, mdev->rs_total, mdev->rs_failed); |
| 2172 | *per_mil_done = 0; | 2215 | *per_mil_done = 0; |
| 2173 | } else { | 2216 | } else { |
| 2174 | /* make sure the calculation happens in long context */ | 2217 | /* Make sure the division happens in long context. |
| 2175 | unsigned long tmp = 1000UL - | 2218 | * We allow up to one petabyte storage right now, |
| 2176 | (*bits_left >> 10)*1000UL | 2219 | * at a granularity of 4k per bit that is 2**38 bits. |
| 2177 | / ((mdev->rs_total >> 10) + 1UL); | 2220 | * After shift right and multiplication by 1000, |
| 2221 | * this should still fit easily into a 32bit long, | ||
| 2222 | * so we don't need a 64bit division on 32bit arch. | ||
| 2223 | * Note: currently we don't support such large bitmaps on 32bit | ||
| 2224 | * arch anyways, but no harm done to be prepared for it here. | ||
| 2225 | */ | ||
| 2226 | unsigned int shift = mdev->rs_total >= (1ULL << 32) ? 16 : 10; | ||
| 2227 | unsigned long left = *bits_left >> shift; | ||
| 2228 | unsigned long total = 1UL + (mdev->rs_total >> shift); | ||
| 2229 | unsigned long tmp = 1000UL - left * 1000UL/total; | ||
| 2178 | *per_mil_done = tmp; | 2230 | *per_mil_done = tmp; |
| 2179 | } | 2231 | } |
| 2180 | } | 2232 | } |
| @@ -2193,8 +2245,9 @@ static inline int drbd_get_max_buffers(struct drbd_conf *mdev) | |||
| 2193 | return mxb; | 2245 | return mxb; |
| 2194 | } | 2246 | } |
| 2195 | 2247 | ||
| 2196 | static inline int drbd_state_is_stable(union drbd_state s) | 2248 | static inline int drbd_state_is_stable(struct drbd_conf *mdev) |
| 2197 | { | 2249 | { |
| 2250 | union drbd_state s = mdev->state; | ||
| 2198 | 2251 | ||
| 2199 | /* DO NOT add a default clause, we want the compiler to warn us | 2252 | /* DO NOT add a default clause, we want the compiler to warn us |
| 2200 | * for any newly introduced state we may have forgotten to add here */ | 2253 | * for any newly introduced state we may have forgotten to add here */ |
| @@ -2211,11 +2264,9 @@ static inline int drbd_state_is_stable(union drbd_state s) | |||
| 2211 | case C_VERIFY_T: | 2264 | case C_VERIFY_T: |
| 2212 | case C_PAUSED_SYNC_S: | 2265 | case C_PAUSED_SYNC_S: |
| 2213 | case C_PAUSED_SYNC_T: | 2266 | case C_PAUSED_SYNC_T: |
| 2214 | /* maybe stable, look at the disk state */ | 2267 | case C_AHEAD: |
| 2215 | break; | 2268 | case C_BEHIND: |
| 2216 | 2269 | /* transitional states, IO allowed */ | |
| 2217 | /* no new io accepted during tansitional states | ||
| 2218 | * like handshake or teardown */ | ||
| 2219 | case C_DISCONNECTING: | 2270 | case C_DISCONNECTING: |
| 2220 | case C_UNCONNECTED: | 2271 | case C_UNCONNECTED: |
| 2221 | case C_TIMEOUT: | 2272 | case C_TIMEOUT: |
| @@ -2226,7 +2277,15 @@ static inline int drbd_state_is_stable(union drbd_state s) | |||
| 2226 | case C_WF_REPORT_PARAMS: | 2277 | case C_WF_REPORT_PARAMS: |
| 2227 | case C_STARTING_SYNC_S: | 2278 | case C_STARTING_SYNC_S: |
| 2228 | case C_STARTING_SYNC_T: | 2279 | case C_STARTING_SYNC_T: |
| 2280 | break; | ||
| 2281 | |||
| 2282 | /* Allow IO in BM exchange states with new protocols */ | ||
| 2229 | case C_WF_BITMAP_S: | 2283 | case C_WF_BITMAP_S: |
| 2284 | if (mdev->agreed_pro_version < 96) | ||
| 2285 | return 0; | ||
| 2286 | break; | ||
| 2287 | |||
| 2288 | /* no new io accepted in these states */ | ||
| 2230 | case C_WF_BITMAP_T: | 2289 | case C_WF_BITMAP_T: |
| 2231 | case C_WF_SYNC_UUID: | 2290 | case C_WF_SYNC_UUID: |
| 2232 | case C_MASK: | 2291 | case C_MASK: |
| @@ -2261,41 +2320,47 @@ static inline int is_susp(union drbd_state s) | |||
| 2261 | return s.susp || s.susp_nod || s.susp_fen; | 2320 | return s.susp || s.susp_nod || s.susp_fen; |
| 2262 | } | 2321 | } |
| 2263 | 2322 | ||
| 2264 | static inline int __inc_ap_bio_cond(struct drbd_conf *mdev) | 2323 | static inline bool may_inc_ap_bio(struct drbd_conf *mdev) |
| 2265 | { | 2324 | { |
| 2266 | int mxb = drbd_get_max_buffers(mdev); | 2325 | int mxb = drbd_get_max_buffers(mdev); |
| 2267 | 2326 | ||
| 2268 | if (is_susp(mdev->state)) | 2327 | if (is_susp(mdev->state)) |
| 2269 | return 0; | 2328 | return false; |
| 2270 | if (test_bit(SUSPEND_IO, &mdev->flags)) | 2329 | if (test_bit(SUSPEND_IO, &mdev->flags)) |
| 2271 | return 0; | 2330 | return false; |
| 2272 | 2331 | ||
| 2273 | /* to avoid potential deadlock or bitmap corruption, | 2332 | /* to avoid potential deadlock or bitmap corruption, |
| 2274 | * in various places, we only allow new application io | 2333 | * in various places, we only allow new application io |
| 2275 | * to start during "stable" states. */ | 2334 | * to start during "stable" states. */ |
| 2276 | 2335 | ||
| 2277 | /* no new io accepted when attaching or detaching the disk */ | 2336 | /* no new io accepted when attaching or detaching the disk */ |
| 2278 | if (!drbd_state_is_stable(mdev->state)) | 2337 | if (!drbd_state_is_stable(mdev)) |
| 2279 | return 0; | 2338 | return false; |
| 2280 | 2339 | ||
| 2281 | /* since some older kernels don't have atomic_add_unless, | 2340 | /* since some older kernels don't have atomic_add_unless, |
| 2282 | * and we are within the spinlock anyways, we have this workaround. */ | 2341 | * and we are within the spinlock anyways, we have this workaround. */ |
| 2283 | if (atomic_read(&mdev->ap_bio_cnt) > mxb) | 2342 | if (atomic_read(&mdev->ap_bio_cnt) > mxb) |
| 2284 | return 0; | 2343 | return false; |
| 2285 | if (test_bit(BITMAP_IO, &mdev->flags)) | 2344 | if (test_bit(BITMAP_IO, &mdev->flags)) |
| 2286 | return 0; | 2345 | return false; |
| 2287 | return 1; | 2346 | return true; |
| 2288 | } | 2347 | } |
| 2289 | 2348 | ||
| 2290 | /* I'd like to use wait_event_lock_irq, | 2349 | static inline bool inc_ap_bio_cond(struct drbd_conf *mdev, int count) |
| 2291 | * but I'm not sure when it got introduced, | ||
| 2292 | * and not sure when it has 3 or 4 arguments */ | ||
| 2293 | static inline void inc_ap_bio(struct drbd_conf *mdev, int count) | ||
| 2294 | { | 2350 | { |
| 2295 | /* compare with after_state_ch, | 2351 | bool rv = false; |
| 2296 | * os.conn != C_WF_BITMAP_S && ns.conn == C_WF_BITMAP_S */ | 2352 | |
| 2297 | DEFINE_WAIT(wait); | 2353 | spin_lock_irq(&mdev->req_lock); |
| 2354 | rv = may_inc_ap_bio(mdev); | ||
| 2355 | if (rv) | ||
| 2356 | atomic_add(count, &mdev->ap_bio_cnt); | ||
| 2357 | spin_unlock_irq(&mdev->req_lock); | ||
| 2358 | |||
| 2359 | return rv; | ||
| 2360 | } | ||
| 2298 | 2361 | ||
| 2362 | static inline void inc_ap_bio(struct drbd_conf *mdev, int count) | ||
| 2363 | { | ||
| 2299 | /* we wait here | 2364 | /* we wait here |
| 2300 | * as long as the device is suspended | 2365 | * as long as the device is suspended |
| 2301 | * until the bitmap is no longer on the fly during connection | 2366 | * until the bitmap is no longer on the fly during connection |
| @@ -2304,16 +2369,7 @@ static inline void inc_ap_bio(struct drbd_conf *mdev, int count) | |||
| 2304 | * to avoid races with the reconnect code, | 2369 | * to avoid races with the reconnect code, |
| 2305 | * we need to atomic_inc within the spinlock. */ | 2370 | * we need to atomic_inc within the spinlock. */ |
| 2306 | 2371 | ||
| 2307 | spin_lock_irq(&mdev->req_lock); | 2372 | wait_event(mdev->misc_wait, inc_ap_bio_cond(mdev, count)); |
| 2308 | while (!__inc_ap_bio_cond(mdev)) { | ||
| 2309 | prepare_to_wait(&mdev->misc_wait, &wait, TASK_UNINTERRUPTIBLE); | ||
| 2310 | spin_unlock_irq(&mdev->req_lock); | ||
| 2311 | schedule(); | ||
| 2312 | finish_wait(&mdev->misc_wait, &wait); | ||
| 2313 | spin_lock_irq(&mdev->req_lock); | ||
| 2314 | } | ||
| 2315 | atomic_add(count, &mdev->ap_bio_cnt); | ||
| 2316 | spin_unlock_irq(&mdev->req_lock); | ||
| 2317 | } | 2373 | } |
| 2318 | 2374 | ||
| 2319 | static inline void dec_ap_bio(struct drbd_conf *mdev) | 2375 | static inline void dec_ap_bio(struct drbd_conf *mdev) |
| @@ -2333,9 +2389,11 @@ static inline void dec_ap_bio(struct drbd_conf *mdev) | |||
| 2333 | } | 2389 | } |
| 2334 | } | 2390 | } |
| 2335 | 2391 | ||
| 2336 | static inline void drbd_set_ed_uuid(struct drbd_conf *mdev, u64 val) | 2392 | static inline int drbd_set_ed_uuid(struct drbd_conf *mdev, u64 val) |
| 2337 | { | 2393 | { |
| 2394 | int changed = mdev->ed_uuid != val; | ||
| 2338 | mdev->ed_uuid = val; | 2395 | mdev->ed_uuid = val; |
| 2396 | return changed; | ||
| 2339 | } | 2397 | } |
| 2340 | 2398 | ||
| 2341 | static inline int seq_cmp(u32 a, u32 b) | 2399 | static inline int seq_cmp(u32 a, u32 b) |
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index 8a43ce0edee..dfc85f32d31 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c | |||
| @@ -85,7 +85,8 @@ MODULE_AUTHOR("Philipp Reisner <phil@linbit.com>, " | |||
| 85 | MODULE_DESCRIPTION("drbd - Distributed Replicated Block Device v" REL_VERSION); | 85 | MODULE_DESCRIPTION("drbd - Distributed Replicated Block Device v" REL_VERSION); |
| 86 | MODULE_VERSION(REL_VERSION); | 86 | MODULE_VERSION(REL_VERSION); |
| 87 | MODULE_LICENSE("GPL"); | 87 | MODULE_LICENSE("GPL"); |
| 88 | MODULE_PARM_DESC(minor_count, "Maximum number of drbd devices (1-255)"); | 88 | MODULE_PARM_DESC(minor_count, "Maximum number of drbd devices (" |
| 89 | __stringify(DRBD_MINOR_COUNT_MIN) "-" __stringify(DRBD_MINOR_COUNT_MAX) ")"); | ||
| 89 | MODULE_ALIAS_BLOCKDEV_MAJOR(DRBD_MAJOR); | 90 | MODULE_ALIAS_BLOCKDEV_MAJOR(DRBD_MAJOR); |
| 90 | 91 | ||
| 91 | #include <linux/moduleparam.h> | 92 | #include <linux/moduleparam.h> |
| @@ -115,7 +116,7 @@ module_param(fault_devs, int, 0644); | |||
| 115 | #endif | 116 | #endif |
| 116 | 117 | ||
| 117 | /* module parameter, defined */ | 118 | /* module parameter, defined */ |
| 118 | unsigned int minor_count = 32; | 119 | unsigned int minor_count = DRBD_MINOR_COUNT_DEF; |
| 119 | int disable_sendpage; | 120 | int disable_sendpage; |
| 120 | int allow_oos; | 121 | int allow_oos; |
| 121 | unsigned int cn_idx = CN_IDX_DRBD; | 122 | unsigned int cn_idx = CN_IDX_DRBD; |
| @@ -335,6 +336,7 @@ bail: | |||
| 335 | drbd_force_state(mdev, NS(conn, C_PROTOCOL_ERROR)); | 336 | drbd_force_state(mdev, NS(conn, C_PROTOCOL_ERROR)); |
| 336 | } | 337 | } |
| 337 | 338 | ||
| 339 | |||
| 338 | /** | 340 | /** |
| 339 | * _tl_restart() - Walks the transfer log, and applies an action to all requests | 341 | * _tl_restart() - Walks the transfer log, and applies an action to all requests |
| 340 | * @mdev: DRBD device. | 342 | * @mdev: DRBD device. |
| @@ -456,7 +458,7 @@ void tl_restart(struct drbd_conf *mdev, enum drbd_req_event what) | |||
| 456 | } | 458 | } |
| 457 | 459 | ||
| 458 | /** | 460 | /** |
| 459 | * cl_wide_st_chg() - TRUE if the state change is a cluster wide one | 461 | * cl_wide_st_chg() - true if the state change is a cluster wide one |
| 460 | * @mdev: DRBD device. | 462 | * @mdev: DRBD device. |
| 461 | * @os: old (current) state. | 463 | * @os: old (current) state. |
| 462 | * @ns: new (wanted) state. | 464 | * @ns: new (wanted) state. |
| @@ -473,12 +475,13 @@ static int cl_wide_st_chg(struct drbd_conf *mdev, | |||
| 473 | (os.conn == C_CONNECTED && ns.conn == C_VERIFY_S); | 475 | (os.conn == C_CONNECTED && ns.conn == C_VERIFY_S); |
| 474 | } | 476 | } |
| 475 | 477 | ||
| 476 | int drbd_change_state(struct drbd_conf *mdev, enum chg_state_flags f, | 478 | enum drbd_state_rv |
| 477 | union drbd_state mask, union drbd_state val) | 479 | drbd_change_state(struct drbd_conf *mdev, enum chg_state_flags f, |
| 480 | union drbd_state mask, union drbd_state val) | ||
| 478 | { | 481 | { |
| 479 | unsigned long flags; | 482 | unsigned long flags; |
| 480 | union drbd_state os, ns; | 483 | union drbd_state os, ns; |
| 481 | int rv; | 484 | enum drbd_state_rv rv; |
| 482 | 485 | ||
| 483 | spin_lock_irqsave(&mdev->req_lock, flags); | 486 | spin_lock_irqsave(&mdev->req_lock, flags); |
| 484 | os = mdev->state; | 487 | os = mdev->state; |
| @@ -502,20 +505,22 @@ void drbd_force_state(struct drbd_conf *mdev, | |||
| 502 | drbd_change_state(mdev, CS_HARD, mask, val); | 505 | drbd_change_state(mdev, CS_HARD, mask, val); |
| 503 | } | 506 | } |
| 504 | 507 | ||
| 505 | static int is_valid_state(struct drbd_conf *mdev, union drbd_state ns); | 508 | static enum drbd_state_rv is_valid_state(struct drbd_conf *, union drbd_state); |
| 506 | static int is_valid_state_transition(struct drbd_conf *, | 509 | static enum drbd_state_rv is_valid_state_transition(struct drbd_conf *, |
| 507 | union drbd_state, union drbd_state); | 510 | union drbd_state, |
| 511 | union drbd_state); | ||
| 508 | static union drbd_state sanitize_state(struct drbd_conf *mdev, union drbd_state os, | 512 | static union drbd_state sanitize_state(struct drbd_conf *mdev, union drbd_state os, |
| 509 | union drbd_state ns, const char **warn_sync_abort); | 513 | union drbd_state ns, const char **warn_sync_abort); |
| 510 | int drbd_send_state_req(struct drbd_conf *, | 514 | int drbd_send_state_req(struct drbd_conf *, |
| 511 | union drbd_state, union drbd_state); | 515 | union drbd_state, union drbd_state); |
| 512 | 516 | ||
| 513 | static enum drbd_state_ret_codes _req_st_cond(struct drbd_conf *mdev, | 517 | static enum drbd_state_rv |
| 514 | union drbd_state mask, union drbd_state val) | 518 | _req_st_cond(struct drbd_conf *mdev, union drbd_state mask, |
| 519 | union drbd_state val) | ||
| 515 | { | 520 | { |
| 516 | union drbd_state os, ns; | 521 | union drbd_state os, ns; |
| 517 | unsigned long flags; | 522 | unsigned long flags; |
| 518 | int rv; | 523 | enum drbd_state_rv rv; |
| 519 | 524 | ||
| 520 | if (test_and_clear_bit(CL_ST_CHG_SUCCESS, &mdev->flags)) | 525 | if (test_and_clear_bit(CL_ST_CHG_SUCCESS, &mdev->flags)) |
| 521 | return SS_CW_SUCCESS; | 526 | return SS_CW_SUCCESS; |
| @@ -536,7 +541,7 @@ static enum drbd_state_ret_codes _req_st_cond(struct drbd_conf *mdev, | |||
| 536 | if (rv == SS_SUCCESS) { | 541 | if (rv == SS_SUCCESS) { |
| 537 | rv = is_valid_state_transition(mdev, ns, os); | 542 | rv = is_valid_state_transition(mdev, ns, os); |
| 538 | if (rv == SS_SUCCESS) | 543 | if (rv == SS_SUCCESS) |
| 539 | rv = 0; /* cont waiting, otherwise fail. */ | 544 | rv = SS_UNKNOWN_ERROR; /* cont waiting, otherwise fail. */ |
| 540 | } | 545 | } |
| 541 | } | 546 | } |
| 542 | spin_unlock_irqrestore(&mdev->req_lock, flags); | 547 | spin_unlock_irqrestore(&mdev->req_lock, flags); |
| @@ -554,14 +559,14 @@ static enum drbd_state_ret_codes _req_st_cond(struct drbd_conf *mdev, | |||
| 554 | * Should not be called directly, use drbd_request_state() or | 559 | * Should not be called directly, use drbd_request_state() or |
| 555 | * _drbd_request_state(). | 560 | * _drbd_request_state(). |
| 556 | */ | 561 | */ |
| 557 | static int drbd_req_state(struct drbd_conf *mdev, | 562 | static enum drbd_state_rv |
| 558 | union drbd_state mask, union drbd_state val, | 563 | drbd_req_state(struct drbd_conf *mdev, union drbd_state mask, |
| 559 | enum chg_state_flags f) | 564 | union drbd_state val, enum chg_state_flags f) |
| 560 | { | 565 | { |
| 561 | struct completion done; | 566 | struct completion done; |
| 562 | unsigned long flags; | 567 | unsigned long flags; |
| 563 | union drbd_state os, ns; | 568 | union drbd_state os, ns; |
| 564 | int rv; | 569 | enum drbd_state_rv rv; |
| 565 | 570 | ||
| 566 | init_completion(&done); | 571 | init_completion(&done); |
| 567 | 572 | ||
| @@ -636,10 +641,11 @@ abort: | |||
| 636 | * Cousin of drbd_request_state(), useful with the CS_WAIT_COMPLETE | 641 | * Cousin of drbd_request_state(), useful with the CS_WAIT_COMPLETE |
| 637 | * flag, or when logging of failed state change requests is not desired. | 642 | * flag, or when logging of failed state change requests is not desired. |
| 638 | */ | 643 | */ |
| 639 | int _drbd_request_state(struct drbd_conf *mdev, union drbd_state mask, | 644 | enum drbd_state_rv |
| 640 | union drbd_state val, enum chg_state_flags f) | 645 | _drbd_request_state(struct drbd_conf *mdev, union drbd_state mask, |
| 646 | union drbd_state val, enum chg_state_flags f) | ||
| 641 | { | 647 | { |
| 642 | int rv; | 648 | enum drbd_state_rv rv; |
| 643 | 649 | ||
| 644 | wait_event(mdev->state_wait, | 650 | wait_event(mdev->state_wait, |
| 645 | (rv = drbd_req_state(mdev, mask, val, f)) != SS_IN_TRANSIENT_STATE); | 651 | (rv = drbd_req_state(mdev, mask, val, f)) != SS_IN_TRANSIENT_STATE); |
| @@ -663,8 +669,8 @@ static void print_st(struct drbd_conf *mdev, char *name, union drbd_state ns) | |||
| 663 | ); | 669 | ); |
| 664 | } | 670 | } |
| 665 | 671 | ||
| 666 | void print_st_err(struct drbd_conf *mdev, | 672 | void print_st_err(struct drbd_conf *mdev, union drbd_state os, |
| 667 | union drbd_state os, union drbd_state ns, int err) | 673 | union drbd_state ns, enum drbd_state_rv err) |
| 668 | { | 674 | { |
| 669 | if (err == SS_IN_TRANSIENT_STATE) | 675 | if (err == SS_IN_TRANSIENT_STATE) |
| 670 | return; | 676 | return; |
| @@ -674,32 +680,18 @@ void print_st_err(struct drbd_conf *mdev, | |||
| 674 | } | 680 | } |
| 675 | 681 | ||
| 676 | 682 | ||
| 677 | #define drbd_peer_str drbd_role_str | ||
| 678 | #define drbd_pdsk_str drbd_disk_str | ||
| 679 | |||
| 680 | #define drbd_susp_str(A) ((A) ? "1" : "0") | ||
| 681 | #define drbd_aftr_isp_str(A) ((A) ? "1" : "0") | ||
| 682 | #define drbd_peer_isp_str(A) ((A) ? "1" : "0") | ||
| 683 | #define drbd_user_isp_str(A) ((A) ? "1" : "0") | ||
| 684 | |||
| 685 | #define PSC(A) \ | ||
| 686 | ({ if (ns.A != os.A) { \ | ||
| 687 | pbp += sprintf(pbp, #A "( %s -> %s ) ", \ | ||
| 688 | drbd_##A##_str(os.A), \ | ||
| 689 | drbd_##A##_str(ns.A)); \ | ||
| 690 | } }) | ||
| 691 | |||
| 692 | /** | 683 | /** |
| 693 | * is_valid_state() - Returns an SS_ error code if ns is not valid | 684 | * is_valid_state() - Returns an SS_ error code if ns is not valid |
| 694 | * @mdev: DRBD device. | 685 | * @mdev: DRBD device. |
| 695 | * @ns: State to consider. | 686 | * @ns: State to consider. |
| 696 | */ | 687 | */ |
| 697 | static int is_valid_state(struct drbd_conf *mdev, union drbd_state ns) | 688 | static enum drbd_state_rv |
| 689 | is_valid_state(struct drbd_conf *mdev, union drbd_state ns) | ||
| 698 | { | 690 | { |
| 699 | /* See drbd_state_sw_errors in drbd_strings.c */ | 691 | /* See drbd_state_sw_errors in drbd_strings.c */ |
| 700 | 692 | ||
| 701 | enum drbd_fencing_p fp; | 693 | enum drbd_fencing_p fp; |
| 702 | int rv = SS_SUCCESS; | 694 | enum drbd_state_rv rv = SS_SUCCESS; |
| 703 | 695 | ||
| 704 | fp = FP_DONT_CARE; | 696 | fp = FP_DONT_CARE; |
| 705 | if (get_ldev(mdev)) { | 697 | if (get_ldev(mdev)) { |
| @@ -762,10 +754,11 @@ static int is_valid_state(struct drbd_conf *mdev, union drbd_state ns) | |||
| 762 | * @ns: new state. | 754 | * @ns: new state. |
| 763 | * @os: old state. | 755 | * @os: old state. |
| 764 | */ | 756 | */ |
| 765 | static int is_valid_state_transition(struct drbd_conf *mdev, | 757 | static enum drbd_state_rv |
| 766 | union drbd_state ns, union drbd_state os) | 758 | is_valid_state_transition(struct drbd_conf *mdev, union drbd_state ns, |
| 759 | union drbd_state os) | ||
| 767 | { | 760 | { |
| 768 | int rv = SS_SUCCESS; | 761 | enum drbd_state_rv rv = SS_SUCCESS; |
| 769 | 762 | ||
| 770 | if ((ns.conn == C_STARTING_SYNC_T || ns.conn == C_STARTING_SYNC_S) && | 763 | if ((ns.conn == C_STARTING_SYNC_T || ns.conn == C_STARTING_SYNC_S) && |
| 771 | os.conn > C_CONNECTED) | 764 | os.conn > C_CONNECTED) |
| @@ -800,6 +793,10 @@ static int is_valid_state_transition(struct drbd_conf *mdev, | |||
| 800 | os.conn < C_CONNECTED) | 793 | os.conn < C_CONNECTED) |
| 801 | rv = SS_NEED_CONNECTION; | 794 | rv = SS_NEED_CONNECTION; |
| 802 | 795 | ||
| 796 | if ((ns.conn == C_SYNC_TARGET || ns.conn == C_SYNC_SOURCE) | ||
| 797 | && os.conn < C_WF_REPORT_PARAMS) | ||
| 798 | rv = SS_NEED_CONNECTION; /* No NetworkFailure -> SyncTarget etc... */ | ||
| 799 | |||
| 803 | return rv; | 800 | return rv; |
| 804 | } | 801 | } |
| 805 | 802 | ||
| @@ -817,6 +814,7 @@ static union drbd_state sanitize_state(struct drbd_conf *mdev, union drbd_state | |||
| 817 | union drbd_state ns, const char **warn_sync_abort) | 814 | union drbd_state ns, const char **warn_sync_abort) |
| 818 | { | 815 | { |
| 819 | enum drbd_fencing_p fp; | 816 | enum drbd_fencing_p fp; |
| 817 | enum drbd_disk_state disk_min, disk_max, pdsk_min, pdsk_max; | ||
| 820 | 818 | ||
| 821 | fp = FP_DONT_CARE; | 819 | fp = FP_DONT_CARE; |
| 822 | if (get_ldev(mdev)) { | 820 | if (get_ldev(mdev)) { |
| @@ -869,56 +867,6 @@ static union drbd_state sanitize_state(struct drbd_conf *mdev, union drbd_state | |||
| 869 | ns.conn = C_CONNECTED; | 867 | ns.conn = C_CONNECTED; |
| 870 | } | 868 | } |
| 871 | 869 | ||
| 872 | if (ns.conn >= C_CONNECTED && | ||
| 873 | ((ns.disk == D_CONSISTENT || ns.disk == D_OUTDATED) || | ||
| 874 | (ns.disk == D_NEGOTIATING && ns.conn == C_WF_BITMAP_T))) { | ||
| 875 | switch (ns.conn) { | ||
| 876 | case C_WF_BITMAP_T: | ||
| 877 | case C_PAUSED_SYNC_T: | ||
| 878 | ns.disk = D_OUTDATED; | ||
| 879 | break; | ||
| 880 | case C_CONNECTED: | ||
| 881 | case C_WF_BITMAP_S: | ||
| 882 | case C_SYNC_SOURCE: | ||
| 883 | case C_PAUSED_SYNC_S: | ||
| 884 | ns.disk = D_UP_TO_DATE; | ||
| 885 | break; | ||
| 886 | case C_SYNC_TARGET: | ||
| 887 | ns.disk = D_INCONSISTENT; | ||
| 888 | dev_warn(DEV, "Implicitly set disk state Inconsistent!\n"); | ||
| 889 | break; | ||
| 890 | } | ||
| 891 | if (os.disk == D_OUTDATED && ns.disk == D_UP_TO_DATE) | ||
| 892 | dev_warn(DEV, "Implicitly set disk from Outdated to UpToDate\n"); | ||
| 893 | } | ||
| 894 | |||
| 895 | if (ns.conn >= C_CONNECTED && | ||
| 896 | (ns.pdsk == D_CONSISTENT || ns.pdsk == D_OUTDATED)) { | ||
| 897 | switch (ns.conn) { | ||
| 898 | case C_CONNECTED: | ||
| 899 | case C_WF_BITMAP_T: | ||
| 900 | case C_PAUSED_SYNC_T: | ||
| 901 | case C_SYNC_TARGET: | ||
| 902 | ns.pdsk = D_UP_TO_DATE; | ||
| 903 | break; | ||
| 904 | case C_WF_BITMAP_S: | ||
| 905 | case C_PAUSED_SYNC_S: | ||
| 906 | /* remap any consistent state to D_OUTDATED, | ||
| 907 | * but disallow "upgrade" of not even consistent states. | ||
| 908 | */ | ||
| 909 | ns.pdsk = | ||
| 910 | (D_DISKLESS < os.pdsk && os.pdsk < D_OUTDATED) | ||
| 911 | ? os.pdsk : D_OUTDATED; | ||
| 912 | break; | ||
| 913 | case C_SYNC_SOURCE: | ||
| 914 | ns.pdsk = D_INCONSISTENT; | ||
| 915 | dev_warn(DEV, "Implicitly set pdsk Inconsistent!\n"); | ||
| 916 | break; | ||
| 917 | } | ||
| 918 | if (os.pdsk == D_OUTDATED && ns.pdsk == D_UP_TO_DATE) | ||
| 919 | dev_warn(DEV, "Implicitly set pdsk from Outdated to UpToDate\n"); | ||
| 920 | } | ||
| 921 | |||
| 922 | /* Connection breaks down before we finished "Negotiating" */ | 870 | /* Connection breaks down before we finished "Negotiating" */ |
| 923 | if (ns.conn < C_CONNECTED && ns.disk == D_NEGOTIATING && | 871 | if (ns.conn < C_CONNECTED && ns.disk == D_NEGOTIATING && |
| 924 | get_ldev_if_state(mdev, D_NEGOTIATING)) { | 872 | get_ldev_if_state(mdev, D_NEGOTIATING)) { |
| @@ -933,6 +881,94 @@ static union drbd_state sanitize_state(struct drbd_conf *mdev, union drbd_state | |||
| 933 | put_ldev(mdev); | 881 | put_ldev(mdev); |
| 934 | } | 882 | } |
| 935 | 883 | ||
| 884 | /* D_CONSISTENT and D_OUTDATED vanish when we get connected */ | ||
| 885 | if (ns.conn >= C_CONNECTED && ns.conn < C_AHEAD) { | ||
| 886 | if (ns.disk == D_CONSISTENT || ns.disk == D_OUTDATED) | ||
| 887 | ns.disk = D_UP_TO_DATE; | ||
| 888 | if (ns.pdsk == D_CONSISTENT || ns.pdsk == D_OUTDATED) | ||
| 889 | ns.pdsk = D_UP_TO_DATE; | ||
| 890 | } | ||
| 891 | |||
| 892 | /* Implications of the connection stat on the disk states */ | ||
| 893 | disk_min = D_DISKLESS; | ||
| 894 | disk_max = D_UP_TO_DATE; | ||
| 895 | pdsk_min = D_INCONSISTENT; | ||
| 896 | pdsk_max = D_UNKNOWN; | ||
| 897 | switch ((enum drbd_conns)ns.conn) { | ||
| 898 | case C_WF_BITMAP_T: | ||
| 899 | case C_PAUSED_SYNC_T: | ||
| 900 | case C_STARTING_SYNC_T: | ||
| 901 | case C_WF_SYNC_UUID: | ||
| 902 | case C_BEHIND: | ||
| 903 | disk_min = D_INCONSISTENT; | ||
| 904 | disk_max = D_OUTDATED; | ||
| 905 | pdsk_min = D_UP_TO_DATE; | ||
| 906 | pdsk_max = D_UP_TO_DATE; | ||
| 907 | break; | ||
| 908 | case C_VERIFY_S: | ||
| 909 | case C_VERIFY_T: | ||
| 910 | disk_min = D_UP_TO_DATE; | ||
| 911 | disk_max = D_UP_TO_DATE; | ||
| 912 | pdsk_min = D_UP_TO_DATE; | ||
| 913 | pdsk_max = D_UP_TO_DATE; | ||
| 914 | break; | ||
| 915 | case C_CONNECTED: | ||
| 916 | disk_min = D_DISKLESS; | ||
| 917 | disk_max = D_UP_TO_DATE; | ||
| 918 | pdsk_min = D_DISKLESS; | ||
| 919 | pdsk_max = D_UP_TO_DATE; | ||
| 920 | break; | ||
| 921 | case C_WF_BITMAP_S: | ||
| 922 | case C_PAUSED_SYNC_S: | ||
| 923 | case C_STARTING_SYNC_S: | ||
| 924 | case C_AHEAD: | ||
| 925 | disk_min = D_UP_TO_DATE; | ||
| 926 | disk_max = D_UP_TO_DATE; | ||
| 927 | pdsk_min = D_INCONSISTENT; | ||
| 928 | pdsk_max = D_CONSISTENT; /* D_OUTDATED would be nice. But explicit outdate necessary*/ | ||
| 929 | break; | ||
| 930 | case C_SYNC_TARGET: | ||
| 931 | disk_min = D_INCONSISTENT; | ||
| 932 | disk_max = D_INCONSISTENT; | ||
| 933 | pdsk_min = D_UP_TO_DATE; | ||
| 934 | pdsk_max = D_UP_TO_DATE; | ||
| 935 | break; | ||
| 936 | case C_SYNC_SOURCE: | ||
| 937 | disk_min = D_UP_TO_DATE; | ||
| 938 | disk_max = D_UP_TO_DATE; | ||
| 939 | pdsk_min = D_INCONSISTENT; | ||
| 940 | pdsk_max = D_INCONSISTENT; | ||
| 941 | break; | ||
| 942 | case C_STANDALONE: | ||
| 943 | case C_DISCONNECTING: | ||
| 944 | case C_UNCONNECTED: | ||
| 945 | case C_TIMEOUT: | ||
| 946 | case C_BROKEN_PIPE: | ||
| 947 | case C_NETWORK_FAILURE: | ||
| 948 | case C_PROTOCOL_ERROR: | ||
| 949 | case C_TEAR_DOWN: | ||
| 950 | case C_WF_CONNECTION: | ||
| 951 | case C_WF_REPORT_PARAMS: | ||
| 952 | case C_MASK: | ||
| 953 | break; | ||
| 954 | } | ||
| 955 | if (ns.disk > disk_max) | ||
| 956 | ns.disk = disk_max; | ||
| 957 | |||
| 958 | if (ns.disk < disk_min) { | ||
| 959 | dev_warn(DEV, "Implicitly set disk from %s to %s\n", | ||
| 960 | drbd_disk_str(ns.disk), drbd_disk_str(disk_min)); | ||
| 961 | ns.disk = disk_min; | ||
| 962 | } | ||
| 963 | if (ns.pdsk > pdsk_max) | ||
| 964 | ns.pdsk = pdsk_max; | ||
| 965 | |||
| 966 | if (ns.pdsk < pdsk_min) { | ||
| 967 | dev_warn(DEV, "Implicitly set pdsk from %s to %s\n", | ||
| 968 | drbd_disk_str(ns.pdsk), drbd_disk_str(pdsk_min)); | ||
| 969 | ns.pdsk = pdsk_min; | ||
| 970 | } | ||
| 971 | |||
| 936 | if (fp == FP_STONITH && | 972 | if (fp == FP_STONITH && |
| 937 | (ns.role == R_PRIMARY && ns.conn < C_CONNECTED && ns.pdsk > D_OUTDATED) && | 973 | (ns.role == R_PRIMARY && ns.conn < C_CONNECTED && ns.pdsk > D_OUTDATED) && |
| 938 | !(os.role == R_PRIMARY && os.conn < C_CONNECTED && os.pdsk > D_OUTDATED)) | 974 | !(os.role == R_PRIMARY && os.conn < C_CONNECTED && os.pdsk > D_OUTDATED)) |
| @@ -961,6 +997,10 @@ static union drbd_state sanitize_state(struct drbd_conf *mdev, union drbd_state | |||
| 961 | /* helper for __drbd_set_state */ | 997 | /* helper for __drbd_set_state */ |
| 962 | static void set_ov_position(struct drbd_conf *mdev, enum drbd_conns cs) | 998 | static void set_ov_position(struct drbd_conf *mdev, enum drbd_conns cs) |
| 963 | { | 999 | { |
| 1000 | if (mdev->agreed_pro_version < 90) | ||
| 1001 | mdev->ov_start_sector = 0; | ||
| 1002 | mdev->rs_total = drbd_bm_bits(mdev); | ||
| 1003 | mdev->ov_position = 0; | ||
| 964 | if (cs == C_VERIFY_T) { | 1004 | if (cs == C_VERIFY_T) { |
| 965 | /* starting online verify from an arbitrary position | 1005 | /* starting online verify from an arbitrary position |
| 966 | * does not fit well into the existing protocol. | 1006 | * does not fit well into the existing protocol. |
| @@ -970,11 +1010,15 @@ static void set_ov_position(struct drbd_conf *mdev, enum drbd_conns cs) | |||
| 970 | mdev->ov_start_sector = ~(sector_t)0; | 1010 | mdev->ov_start_sector = ~(sector_t)0; |
| 971 | } else { | 1011 | } else { |
| 972 | unsigned long bit = BM_SECT_TO_BIT(mdev->ov_start_sector); | 1012 | unsigned long bit = BM_SECT_TO_BIT(mdev->ov_start_sector); |
| 973 | if (bit >= mdev->rs_total) | 1013 | if (bit >= mdev->rs_total) { |
| 974 | mdev->ov_start_sector = | 1014 | mdev->ov_start_sector = |
| 975 | BM_BIT_TO_SECT(mdev->rs_total - 1); | 1015 | BM_BIT_TO_SECT(mdev->rs_total - 1); |
| 1016 | mdev->rs_total = 1; | ||
| 1017 | } else | ||
| 1018 | mdev->rs_total -= bit; | ||
| 976 | mdev->ov_position = mdev->ov_start_sector; | 1019 | mdev->ov_position = mdev->ov_start_sector; |
| 977 | } | 1020 | } |
| 1021 | mdev->ov_left = mdev->rs_total; | ||
| 978 | } | 1022 | } |
| 979 | 1023 | ||
| 980 | static void drbd_resume_al(struct drbd_conf *mdev) | 1024 | static void drbd_resume_al(struct drbd_conf *mdev) |
| @@ -992,12 +1036,12 @@ static void drbd_resume_al(struct drbd_conf *mdev) | |||
| 992 | * | 1036 | * |
| 993 | * Caller needs to hold req_lock, and global_state_lock. Do not call directly. | 1037 | * Caller needs to hold req_lock, and global_state_lock. Do not call directly. |
| 994 | */ | 1038 | */ |
| 995 | int __drbd_set_state(struct drbd_conf *mdev, | 1039 | enum drbd_state_rv |
| 996 | union drbd_state ns, enum chg_state_flags flags, | 1040 | __drbd_set_state(struct drbd_conf *mdev, union drbd_state ns, |
| 997 | struct completion *done) | 1041 | enum chg_state_flags flags, struct completion *done) |
| 998 | { | 1042 | { |
| 999 | union drbd_state os; | 1043 | union drbd_state os; |
| 1000 | int rv = SS_SUCCESS; | 1044 | enum drbd_state_rv rv = SS_SUCCESS; |
| 1001 | const char *warn_sync_abort = NULL; | 1045 | const char *warn_sync_abort = NULL; |
| 1002 | struct after_state_chg_work *ascw; | 1046 | struct after_state_chg_work *ascw; |
| 1003 | 1047 | ||
| @@ -1033,22 +1077,46 @@ int __drbd_set_state(struct drbd_conf *mdev, | |||
| 1033 | dev_warn(DEV, "%s aborted.\n", warn_sync_abort); | 1077 | dev_warn(DEV, "%s aborted.\n", warn_sync_abort); |
| 1034 | 1078 | ||
| 1035 | { | 1079 | { |
| 1036 | char *pbp, pb[300]; | 1080 | char *pbp, pb[300]; |
| 1037 | pbp = pb; | 1081 | pbp = pb; |
| 1038 | *pbp = 0; | 1082 | *pbp = 0; |
| 1039 | PSC(role); | 1083 | if (ns.role != os.role) |
| 1040 | PSC(peer); | 1084 | pbp += sprintf(pbp, "role( %s -> %s ) ", |
| 1041 | PSC(conn); | 1085 | drbd_role_str(os.role), |
| 1042 | PSC(disk); | 1086 | drbd_role_str(ns.role)); |
| 1043 | PSC(pdsk); | 1087 | if (ns.peer != os.peer) |
| 1044 | if (is_susp(ns) != is_susp(os)) | 1088 | pbp += sprintf(pbp, "peer( %s -> %s ) ", |
| 1045 | pbp += sprintf(pbp, "susp( %s -> %s ) ", | 1089 | drbd_role_str(os.peer), |
| 1046 | drbd_susp_str(is_susp(os)), | 1090 | drbd_role_str(ns.peer)); |
| 1047 | drbd_susp_str(is_susp(ns))); | 1091 | if (ns.conn != os.conn) |
| 1048 | PSC(aftr_isp); | 1092 | pbp += sprintf(pbp, "conn( %s -> %s ) ", |
| 1049 | PSC(peer_isp); | 1093 | drbd_conn_str(os.conn), |
| 1050 | PSC(user_isp); | 1094 | drbd_conn_str(ns.conn)); |
| 1051 | dev_info(DEV, "%s\n", pb); | 1095 | if (ns.disk != os.disk) |
| 1096 | pbp += sprintf(pbp, "disk( %s -> %s ) ", | ||
| 1097 | drbd_disk_str(os.disk), | ||
| 1098 | drbd_disk_str(ns.disk)); | ||
| 1099 | if (ns.pdsk != os.pdsk) | ||
| 1100 | pbp += sprintf(pbp, "pdsk( %s -> %s ) ", | ||
| 1101 | drbd_disk_str(os.pdsk), | ||
| 1102 | drbd_disk_str(ns.pdsk)); | ||
| 1103 | if (is_susp(ns) != is_susp(os)) | ||
| 1104 | pbp += sprintf(pbp, "susp( %d -> %d ) ", | ||
| 1105 | is_susp(os), | ||
| 1106 | is_susp(ns)); | ||
| 1107 | if (ns.aftr_isp != os.aftr_isp) | ||
| 1108 | pbp += sprintf(pbp, "aftr_isp( %d -> %d ) ", | ||
| 1109 | os.aftr_isp, | ||
| 1110 | ns.aftr_isp); | ||
| 1111 | if (ns.peer_isp != os.peer_isp) | ||
| 1112 | pbp += sprintf(pbp, "peer_isp( %d -> %d ) ", | ||
| 1113 | os.peer_isp, | ||
| 1114 | ns.peer_isp); | ||
| 1115 | if (ns.user_isp != os.user_isp) | ||
| 1116 | pbp += sprintf(pbp, "user_isp( %d -> %d ) ", | ||
| 1117 | os.user_isp, | ||
| 1118 | ns.user_isp); | ||
| 1119 | dev_info(DEV, "%s\n", pb); | ||
| 1052 | } | 1120 | } |
| 1053 | 1121 | ||
| 1054 | /* solve the race between becoming unconfigured, | 1122 | /* solve the race between becoming unconfigured, |
| @@ -1074,6 +1142,10 @@ int __drbd_set_state(struct drbd_conf *mdev, | |||
| 1074 | atomic_inc(&mdev->local_cnt); | 1142 | atomic_inc(&mdev->local_cnt); |
| 1075 | 1143 | ||
| 1076 | mdev->state = ns; | 1144 | mdev->state = ns; |
| 1145 | |||
| 1146 | if (os.disk == D_ATTACHING && ns.disk >= D_NEGOTIATING) | ||
| 1147 | drbd_print_uuids(mdev, "attached to UUIDs"); | ||
| 1148 | |||
| 1077 | wake_up(&mdev->misc_wait); | 1149 | wake_up(&mdev->misc_wait); |
| 1078 | wake_up(&mdev->state_wait); | 1150 | wake_up(&mdev->state_wait); |
| 1079 | 1151 | ||
| @@ -1081,7 +1153,7 @@ int __drbd_set_state(struct drbd_conf *mdev, | |||
| 1081 | if ((os.conn == C_VERIFY_S || os.conn == C_VERIFY_T) && | 1153 | if ((os.conn == C_VERIFY_S || os.conn == C_VERIFY_T) && |
| 1082 | ns.conn < C_CONNECTED) { | 1154 | ns.conn < C_CONNECTED) { |
| 1083 | mdev->ov_start_sector = | 1155 | mdev->ov_start_sector = |
| 1084 | BM_BIT_TO_SECT(mdev->rs_total - mdev->ov_left); | 1156 | BM_BIT_TO_SECT(drbd_bm_bits(mdev) - mdev->ov_left); |
| 1085 | dev_info(DEV, "Online Verify reached sector %llu\n", | 1157 | dev_info(DEV, "Online Verify reached sector %llu\n", |
| 1086 | (unsigned long long)mdev->ov_start_sector); | 1158 | (unsigned long long)mdev->ov_start_sector); |
| 1087 | } | 1159 | } |
| @@ -1106,14 +1178,7 @@ int __drbd_set_state(struct drbd_conf *mdev, | |||
| 1106 | unsigned long now = jiffies; | 1178 | unsigned long now = jiffies; |
| 1107 | int i; | 1179 | int i; |
| 1108 | 1180 | ||
| 1109 | mdev->ov_position = 0; | 1181 | set_ov_position(mdev, ns.conn); |
| 1110 | mdev->rs_total = drbd_bm_bits(mdev); | ||
| 1111 | if (mdev->agreed_pro_version >= 90) | ||
| 1112 | set_ov_position(mdev, ns.conn); | ||
| 1113 | else | ||
| 1114 | mdev->ov_start_sector = 0; | ||
| 1115 | mdev->ov_left = mdev->rs_total | ||
| 1116 | - BM_SECT_TO_BIT(mdev->ov_position); | ||
| 1117 | mdev->rs_start = now; | 1182 | mdev->rs_start = now; |
| 1118 | mdev->rs_last_events = 0; | 1183 | mdev->rs_last_events = 0; |
| 1119 | mdev->rs_last_sect_ev = 0; | 1184 | mdev->rs_last_sect_ev = 0; |
| @@ -1121,10 +1186,12 @@ int __drbd_set_state(struct drbd_conf *mdev, | |||
| 1121 | mdev->ov_last_oos_start = 0; | 1186 | mdev->ov_last_oos_start = 0; |
| 1122 | 1187 | ||
| 1123 | for (i = 0; i < DRBD_SYNC_MARKS; i++) { | 1188 | for (i = 0; i < DRBD_SYNC_MARKS; i++) { |
| 1124 | mdev->rs_mark_left[i] = mdev->rs_total; | 1189 | mdev->rs_mark_left[i] = mdev->ov_left; |
| 1125 | mdev->rs_mark_time[i] = now; | 1190 | mdev->rs_mark_time[i] = now; |
| 1126 | } | 1191 | } |
| 1127 | 1192 | ||
| 1193 | drbd_rs_controller_reset(mdev); | ||
| 1194 | |||
| 1128 | if (ns.conn == C_VERIFY_S) { | 1195 | if (ns.conn == C_VERIFY_S) { |
| 1129 | dev_info(DEV, "Starting Online Verify from sector %llu\n", | 1196 | dev_info(DEV, "Starting Online Verify from sector %llu\n", |
| 1130 | (unsigned long long)mdev->ov_position); | 1197 | (unsigned long long)mdev->ov_position); |
| @@ -1228,6 +1295,26 @@ static void abw_start_sync(struct drbd_conf *mdev, int rv) | |||
| 1228 | } | 1295 | } |
| 1229 | } | 1296 | } |
| 1230 | 1297 | ||
| 1298 | int drbd_bitmap_io_from_worker(struct drbd_conf *mdev, | ||
| 1299 | int (*io_fn)(struct drbd_conf *), | ||
| 1300 | char *why, enum bm_flag flags) | ||
| 1301 | { | ||
| 1302 | int rv; | ||
| 1303 | |||
| 1304 | D_ASSERT(current == mdev->worker.task); | ||
| 1305 | |||
| 1306 | /* open coded non-blocking drbd_suspend_io(mdev); */ | ||
| 1307 | set_bit(SUSPEND_IO, &mdev->flags); | ||
| 1308 | |||
| 1309 | drbd_bm_lock(mdev, why, flags); | ||
| 1310 | rv = io_fn(mdev); | ||
| 1311 | drbd_bm_unlock(mdev); | ||
| 1312 | |||
| 1313 | drbd_resume_io(mdev); | ||
| 1314 | |||
| 1315 | return rv; | ||
| 1316 | } | ||
| 1317 | |||
| 1231 | /** | 1318 | /** |
| 1232 | * after_state_ch() - Perform after state change actions that may sleep | 1319 | * after_state_ch() - Perform after state change actions that may sleep |
| 1233 | * @mdev: DRBD device. | 1320 | * @mdev: DRBD device. |
| @@ -1266,16 +1353,14 @@ static void after_state_ch(struct drbd_conf *mdev, union drbd_state os, | |||
| 1266 | 1353 | ||
| 1267 | nsm.i = -1; | 1354 | nsm.i = -1; |
| 1268 | if (ns.susp_nod) { | 1355 | if (ns.susp_nod) { |
| 1269 | if (os.conn < C_CONNECTED && ns.conn >= C_CONNECTED) { | 1356 | if (os.conn < C_CONNECTED && ns.conn >= C_CONNECTED) |
| 1270 | if (ns.conn == C_CONNECTED) | 1357 | what = resend; |
| 1271 | what = resend, nsm.susp_nod = 0; | ||
| 1272 | else /* ns.conn > C_CONNECTED */ | ||
| 1273 | dev_err(DEV, "Unexpected Resynd going on!\n"); | ||
| 1274 | } | ||
| 1275 | 1358 | ||
| 1276 | if (os.disk == D_ATTACHING && ns.disk > D_ATTACHING) | 1359 | if (os.disk == D_ATTACHING && ns.disk > D_ATTACHING) |
| 1277 | what = restart_frozen_disk_io, nsm.susp_nod = 0; | 1360 | what = restart_frozen_disk_io; |
| 1278 | 1361 | ||
| 1362 | if (what != nothing) | ||
| 1363 | nsm.susp_nod = 0; | ||
| 1279 | } | 1364 | } |
| 1280 | 1365 | ||
| 1281 | if (ns.susp_fen) { | 1366 | if (ns.susp_fen) { |
| @@ -1306,13 +1391,30 @@ static void after_state_ch(struct drbd_conf *mdev, union drbd_state os, | |||
| 1306 | spin_unlock_irq(&mdev->req_lock); | 1391 | spin_unlock_irq(&mdev->req_lock); |
| 1307 | } | 1392 | } |
| 1308 | 1393 | ||
| 1394 | /* Became sync source. With protocol >= 96, we still need to send out | ||
| 1395 | * the sync uuid now. Need to do that before any drbd_send_state, or | ||
| 1396 | * the other side may go "paused sync" before receiving the sync uuids, | ||
| 1397 | * which is unexpected. */ | ||
| 1398 | if ((os.conn != C_SYNC_SOURCE && os.conn != C_PAUSED_SYNC_S) && | ||
| 1399 | (ns.conn == C_SYNC_SOURCE || ns.conn == C_PAUSED_SYNC_S) && | ||
| 1400 | mdev->agreed_pro_version >= 96 && get_ldev(mdev)) { | ||
| 1401 | drbd_gen_and_send_sync_uuid(mdev); | ||
| 1402 | put_ldev(mdev); | ||
| 1403 | } | ||
| 1404 | |||
| 1309 | /* Do not change the order of the if above and the two below... */ | 1405 | /* Do not change the order of the if above and the two below... */ |
| 1310 | if (os.pdsk == D_DISKLESS && ns.pdsk > D_DISKLESS) { /* attach on the peer */ | 1406 | if (os.pdsk == D_DISKLESS && ns.pdsk > D_DISKLESS) { /* attach on the peer */ |
| 1311 | drbd_send_uuids(mdev); | 1407 | drbd_send_uuids(mdev); |
| 1312 | drbd_send_state(mdev); | 1408 | drbd_send_state(mdev); |
| 1313 | } | 1409 | } |
| 1314 | if (os.conn != C_WF_BITMAP_S && ns.conn == C_WF_BITMAP_S) | 1410 | /* No point in queuing send_bitmap if we don't have a connection |
| 1315 | drbd_queue_bitmap_io(mdev, &drbd_send_bitmap, NULL, "send_bitmap (WFBitMapS)"); | 1411 | * anymore, so check also the _current_ state, not only the new state |
| 1412 | * at the time this work was queued. */ | ||
| 1413 | if (os.conn != C_WF_BITMAP_S && ns.conn == C_WF_BITMAP_S && | ||
| 1414 | mdev->state.conn == C_WF_BITMAP_S) | ||
| 1415 | drbd_queue_bitmap_io(mdev, &drbd_send_bitmap, NULL, | ||
| 1416 | "send_bitmap (WFBitMapS)", | ||
| 1417 | BM_LOCKED_TEST_ALLOWED); | ||
| 1316 | 1418 | ||
| 1317 | /* Lost contact to peer's copy of the data */ | 1419 | /* Lost contact to peer's copy of the data */ |
| 1318 | if ((os.pdsk >= D_INCONSISTENT && | 1420 | if ((os.pdsk >= D_INCONSISTENT && |
| @@ -1343,7 +1445,23 @@ static void after_state_ch(struct drbd_conf *mdev, union drbd_state os, | |||
| 1343 | 1445 | ||
| 1344 | /* D_DISKLESS Peer becomes secondary */ | 1446 | /* D_DISKLESS Peer becomes secondary */ |
| 1345 | if (os.peer == R_PRIMARY && ns.peer == R_SECONDARY) | 1447 | if (os.peer == R_PRIMARY && ns.peer == R_SECONDARY) |
| 1346 | drbd_al_to_on_disk_bm(mdev); | 1448 | /* We may still be Primary ourselves. |
| 1449 | * No harm done if the bitmap still changes, | ||
| 1450 | * redirtied pages will follow later. */ | ||
| 1451 | drbd_bitmap_io_from_worker(mdev, &drbd_bm_write, | ||
| 1452 | "demote diskless peer", BM_LOCKED_SET_ALLOWED); | ||
| 1453 | put_ldev(mdev); | ||
| 1454 | } | ||
| 1455 | |||
| 1456 | /* Write out all changed bits on demote. | ||
| 1457 | * Though, no need to da that just yet | ||
| 1458 | * if there is a resync going on still */ | ||
| 1459 | if (os.role == R_PRIMARY && ns.role == R_SECONDARY && | ||
| 1460 | mdev->state.conn <= C_CONNECTED && get_ldev(mdev)) { | ||
| 1461 | /* No changes to the bitmap expected this time, so assert that, | ||
| 1462 | * even though no harm was done if it did change. */ | ||
| 1463 | drbd_bitmap_io_from_worker(mdev, &drbd_bm_write, | ||
| 1464 | "demote", BM_LOCKED_TEST_ALLOWED); | ||
| 1347 | put_ldev(mdev); | 1465 | put_ldev(mdev); |
| 1348 | } | 1466 | } |
| 1349 | 1467 | ||
| @@ -1371,15 +1489,23 @@ static void after_state_ch(struct drbd_conf *mdev, union drbd_state os, | |||
| 1371 | if (os.conn == C_WF_REPORT_PARAMS && ns.conn >= C_CONNECTED) | 1489 | if (os.conn == C_WF_REPORT_PARAMS && ns.conn >= C_CONNECTED) |
| 1372 | drbd_send_state(mdev); | 1490 | drbd_send_state(mdev); |
| 1373 | 1491 | ||
| 1492 | if (os.conn != C_AHEAD && ns.conn == C_AHEAD) | ||
| 1493 | drbd_send_state(mdev); | ||
| 1494 | |||
| 1374 | /* We are in the progress to start a full sync... */ | 1495 | /* We are in the progress to start a full sync... */ |
| 1375 | if ((os.conn != C_STARTING_SYNC_T && ns.conn == C_STARTING_SYNC_T) || | 1496 | if ((os.conn != C_STARTING_SYNC_T && ns.conn == C_STARTING_SYNC_T) || |
| 1376 | (os.conn != C_STARTING_SYNC_S && ns.conn == C_STARTING_SYNC_S)) | 1497 | (os.conn != C_STARTING_SYNC_S && ns.conn == C_STARTING_SYNC_S)) |
| 1377 | drbd_queue_bitmap_io(mdev, &drbd_bmio_set_n_write, &abw_start_sync, "set_n_write from StartingSync"); | 1498 | /* no other bitmap changes expected during this phase */ |
| 1499 | drbd_queue_bitmap_io(mdev, | ||
| 1500 | &drbd_bmio_set_n_write, &abw_start_sync, | ||
| 1501 | "set_n_write from StartingSync", BM_LOCKED_TEST_ALLOWED); | ||
| 1378 | 1502 | ||
| 1379 | /* We are invalidating our self... */ | 1503 | /* We are invalidating our self... */ |
| 1380 | if (os.conn < C_CONNECTED && ns.conn < C_CONNECTED && | 1504 | if (os.conn < C_CONNECTED && ns.conn < C_CONNECTED && |
| 1381 | os.disk > D_INCONSISTENT && ns.disk == D_INCONSISTENT) | 1505 | os.disk > D_INCONSISTENT && ns.disk == D_INCONSISTENT) |
| 1382 | drbd_queue_bitmap_io(mdev, &drbd_bmio_set_n_write, NULL, "set_n_write from invalidate"); | 1506 | /* other bitmap operation expected during this phase */ |
| 1507 | drbd_queue_bitmap_io(mdev, &drbd_bmio_set_n_write, NULL, | ||
| 1508 | "set_n_write from invalidate", BM_LOCKED_MASK); | ||
| 1383 | 1509 | ||
| 1384 | /* first half of local IO error, failure to attach, | 1510 | /* first half of local IO error, failure to attach, |
| 1385 | * or administrative detach */ | 1511 | * or administrative detach */ |
| @@ -1434,8 +1560,6 @@ static void after_state_ch(struct drbd_conf *mdev, union drbd_state os, | |||
| 1434 | 1560 | ||
| 1435 | if (drbd_send_state(mdev)) | 1561 | if (drbd_send_state(mdev)) |
| 1436 | dev_warn(DEV, "Notified peer that I'm now diskless.\n"); | 1562 | dev_warn(DEV, "Notified peer that I'm now diskless.\n"); |
| 1437 | else | ||
| 1438 | dev_err(DEV, "Sending state for being diskless failed\n"); | ||
| 1439 | /* corresponding get_ldev in __drbd_set_state | 1563 | /* corresponding get_ldev in __drbd_set_state |
| 1440 | * this may finaly trigger drbd_ldev_destroy. */ | 1564 | * this may finaly trigger drbd_ldev_destroy. */ |
| 1441 | put_ldev(mdev); | 1565 | put_ldev(mdev); |
| @@ -1459,6 +1583,19 @@ static void after_state_ch(struct drbd_conf *mdev, union drbd_state os, | |||
| 1459 | if (os.disk < D_UP_TO_DATE && os.conn >= C_SYNC_SOURCE && ns.conn == C_CONNECTED) | 1583 | if (os.disk < D_UP_TO_DATE && os.conn >= C_SYNC_SOURCE && ns.conn == C_CONNECTED) |
| 1460 | drbd_send_state(mdev); | 1584 | drbd_send_state(mdev); |
| 1461 | 1585 | ||
| 1586 | /* This triggers bitmap writeout of potentially still unwritten pages | ||
| 1587 | * if the resync finished cleanly, or aborted because of peer disk | ||
| 1588 | * failure, or because of connection loss. | ||
| 1589 | * For resync aborted because of local disk failure, we cannot do | ||
| 1590 | * any bitmap writeout anymore. | ||
| 1591 | * No harm done if some bits change during this phase. | ||
| 1592 | */ | ||
| 1593 | if (os.conn > C_CONNECTED && ns.conn <= C_CONNECTED && get_ldev(mdev)) { | ||
| 1594 | drbd_queue_bitmap_io(mdev, &drbd_bm_write, NULL, | ||
| 1595 | "write from resync_finished", BM_LOCKED_SET_ALLOWED); | ||
| 1596 | put_ldev(mdev); | ||
| 1597 | } | ||
| 1598 | |||
| 1462 | /* free tl_hash if we Got thawed and are C_STANDALONE */ | 1599 | /* free tl_hash if we Got thawed and are C_STANDALONE */ |
| 1463 | if (ns.conn == C_STANDALONE && !is_susp(ns) && mdev->tl_hash) | 1600 | if (ns.conn == C_STANDALONE && !is_susp(ns) && mdev->tl_hash) |
| 1464 | drbd_free_tl_hash(mdev); | 1601 | drbd_free_tl_hash(mdev); |
| @@ -1559,7 +1696,7 @@ int drbd_thread_start(struct drbd_thread *thi) | |||
| 1559 | if (!try_module_get(THIS_MODULE)) { | 1696 | if (!try_module_get(THIS_MODULE)) { |
| 1560 | dev_err(DEV, "Failed to get module reference in drbd_thread_start\n"); | 1697 | dev_err(DEV, "Failed to get module reference in drbd_thread_start\n"); |
| 1561 | spin_unlock_irqrestore(&thi->t_lock, flags); | 1698 | spin_unlock_irqrestore(&thi->t_lock, flags); |
| 1562 | return FALSE; | 1699 | return false; |
| 1563 | } | 1700 | } |
| 1564 | 1701 | ||
| 1565 | init_completion(&thi->stop); | 1702 | init_completion(&thi->stop); |
| @@ -1576,7 +1713,7 @@ int drbd_thread_start(struct drbd_thread *thi) | |||
| 1576 | dev_err(DEV, "Couldn't start thread\n"); | 1713 | dev_err(DEV, "Couldn't start thread\n"); |
| 1577 | 1714 | ||
| 1578 | module_put(THIS_MODULE); | 1715 | module_put(THIS_MODULE); |
| 1579 | return FALSE; | 1716 | return false; |
| 1580 | } | 1717 | } |
| 1581 | spin_lock_irqsave(&thi->t_lock, flags); | 1718 | spin_lock_irqsave(&thi->t_lock, flags); |
| 1582 | thi->task = nt; | 1719 | thi->task = nt; |
| @@ -1596,7 +1733,7 @@ int drbd_thread_start(struct drbd_thread *thi) | |||
| 1596 | break; | 1733 | break; |
| 1597 | } | 1734 | } |
| 1598 | 1735 | ||
| 1599 | return TRUE; | 1736 | return true; |
| 1600 | } | 1737 | } |
| 1601 | 1738 | ||
| 1602 | 1739 | ||
| @@ -1694,8 +1831,8 @@ int _drbd_send_cmd(struct drbd_conf *mdev, struct socket *sock, | |||
| 1694 | { | 1831 | { |
| 1695 | int sent, ok; | 1832 | int sent, ok; |
| 1696 | 1833 | ||
| 1697 | ERR_IF(!h) return FALSE; | 1834 | ERR_IF(!h) return false; |
| 1698 | ERR_IF(!size) return FALSE; | 1835 | ERR_IF(!size) return false; |
| 1699 | 1836 | ||
| 1700 | h->magic = BE_DRBD_MAGIC; | 1837 | h->magic = BE_DRBD_MAGIC; |
| 1701 | h->command = cpu_to_be16(cmd); | 1838 | h->command = cpu_to_be16(cmd); |
| @@ -1704,8 +1841,8 @@ int _drbd_send_cmd(struct drbd_conf *mdev, struct socket *sock, | |||
| 1704 | sent = drbd_send(mdev, sock, h, size, msg_flags); | 1841 | sent = drbd_send(mdev, sock, h, size, msg_flags); |
| 1705 | 1842 | ||
| 1706 | ok = (sent == size); | 1843 | ok = (sent == size); |
| 1707 | if (!ok) | 1844 | if (!ok && !signal_pending(current)) |
| 1708 | dev_err(DEV, "short sent %s size=%d sent=%d\n", | 1845 | dev_warn(DEV, "short sent %s size=%d sent=%d\n", |
| 1709 | cmdname(cmd), (int)size, sent); | 1846 | cmdname(cmd), (int)size, sent); |
| 1710 | return ok; | 1847 | return ok; |
| 1711 | } | 1848 | } |
| @@ -1840,7 +1977,7 @@ int drbd_send_protocol(struct drbd_conf *mdev) | |||
| 1840 | else { | 1977 | else { |
| 1841 | dev_err(DEV, "--dry-run is not supported by peer"); | 1978 | dev_err(DEV, "--dry-run is not supported by peer"); |
| 1842 | kfree(p); | 1979 | kfree(p); |
| 1843 | return 0; | 1980 | return -1; |
| 1844 | } | 1981 | } |
| 1845 | } | 1982 | } |
| 1846 | p->conn_flags = cpu_to_be32(cf); | 1983 | p->conn_flags = cpu_to_be32(cf); |
| @@ -1888,12 +2025,36 @@ int drbd_send_uuids_skip_initial_sync(struct drbd_conf *mdev) | |||
| 1888 | return _drbd_send_uuids(mdev, 8); | 2025 | return _drbd_send_uuids(mdev, 8); |
| 1889 | } | 2026 | } |
| 1890 | 2027 | ||
| 2028 | void drbd_print_uuids(struct drbd_conf *mdev, const char *text) | ||
| 2029 | { | ||
| 2030 | if (get_ldev_if_state(mdev, D_NEGOTIATING)) { | ||
| 2031 | u64 *uuid = mdev->ldev->md.uuid; | ||
| 2032 | dev_info(DEV, "%s %016llX:%016llX:%016llX:%016llX\n", | ||
| 2033 | text, | ||
| 2034 | (unsigned long long)uuid[UI_CURRENT], | ||
| 2035 | (unsigned long long)uuid[UI_BITMAP], | ||
| 2036 | (unsigned long long)uuid[UI_HISTORY_START], | ||
| 2037 | (unsigned long long)uuid[UI_HISTORY_END]); | ||
| 2038 | put_ldev(mdev); | ||
| 2039 | } else { | ||
| 2040 | dev_info(DEV, "%s effective data uuid: %016llX\n", | ||
| 2041 | text, | ||
| 2042 | (unsigned long long)mdev->ed_uuid); | ||
| 2043 | } | ||
| 2044 | } | ||
| 1891 | 2045 | ||
| 1892 | int drbd_send_sync_uuid(struct drbd_conf *mdev, u64 val) | 2046 | int drbd_gen_and_send_sync_uuid(struct drbd_conf *mdev) |
| 1893 | { | 2047 | { |
| 1894 | struct p_rs_uuid p; | 2048 | struct p_rs_uuid p; |
| 2049 | u64 uuid; | ||
| 1895 | 2050 | ||
| 1896 | p.uuid = cpu_to_be64(val); | 2051 | D_ASSERT(mdev->state.disk == D_UP_TO_DATE); |
| 2052 | |||
| 2053 | uuid = mdev->ldev->md.uuid[UI_BITMAP] + UUID_NEW_BM_OFFSET; | ||
| 2054 | drbd_uuid_set(mdev, UI_BITMAP, uuid); | ||
| 2055 | drbd_print_uuids(mdev, "updated sync UUID"); | ||
| 2056 | drbd_md_sync(mdev); | ||
| 2057 | p.uuid = cpu_to_be64(uuid); | ||
| 1897 | 2058 | ||
| 1898 | return drbd_send_cmd(mdev, USE_DATA_SOCKET, P_SYNC_UUID, | 2059 | return drbd_send_cmd(mdev, USE_DATA_SOCKET, P_SYNC_UUID, |
| 1899 | (struct p_header80 *)&p, sizeof(p)); | 2060 | (struct p_header80 *)&p, sizeof(p)); |
| @@ -1921,7 +2082,7 @@ int drbd_send_sizes(struct drbd_conf *mdev, int trigger_reply, enum dds_flags fl | |||
| 1921 | p.d_size = cpu_to_be64(d_size); | 2082 | p.d_size = cpu_to_be64(d_size); |
| 1922 | p.u_size = cpu_to_be64(u_size); | 2083 | p.u_size = cpu_to_be64(u_size); |
| 1923 | p.c_size = cpu_to_be64(trigger_reply ? 0 : drbd_get_capacity(mdev->this_bdev)); | 2084 | p.c_size = cpu_to_be64(trigger_reply ? 0 : drbd_get_capacity(mdev->this_bdev)); |
| 1924 | p.max_segment_size = cpu_to_be32(queue_max_segment_size(mdev->rq_queue)); | 2085 | p.max_bio_size = cpu_to_be32(queue_max_hw_sectors(mdev->rq_queue) << 9); |
| 1925 | p.queue_order_type = cpu_to_be16(q_order_type); | 2086 | p.queue_order_type = cpu_to_be16(q_order_type); |
| 1926 | p.dds_flags = cpu_to_be16(flags); | 2087 | p.dds_flags = cpu_to_be16(flags); |
| 1927 | 2088 | ||
| @@ -1972,7 +2133,7 @@ int drbd_send_state_req(struct drbd_conf *mdev, | |||
| 1972 | (struct p_header80 *)&p, sizeof(p)); | 2133 | (struct p_header80 *)&p, sizeof(p)); |
| 1973 | } | 2134 | } |
| 1974 | 2135 | ||
| 1975 | int drbd_send_sr_reply(struct drbd_conf *mdev, int retcode) | 2136 | int drbd_send_sr_reply(struct drbd_conf *mdev, enum drbd_state_rv retcode) |
| 1976 | { | 2137 | { |
| 1977 | struct p_req_state_reply p; | 2138 | struct p_req_state_reply p; |
| 1978 | 2139 | ||
| @@ -2076,9 +2237,15 @@ int fill_bitmap_rle_bits(struct drbd_conf *mdev, | |||
| 2076 | return len; | 2237 | return len; |
| 2077 | } | 2238 | } |
| 2078 | 2239 | ||
| 2079 | enum { OK, FAILED, DONE } | 2240 | /** |
| 2241 | * send_bitmap_rle_or_plain | ||
| 2242 | * | ||
| 2243 | * Return 0 when done, 1 when another iteration is needed, and a negative error | ||
| 2244 | * code upon failure. | ||
| 2245 | */ | ||
| 2246 | static int | ||
| 2080 | send_bitmap_rle_or_plain(struct drbd_conf *mdev, | 2247 | send_bitmap_rle_or_plain(struct drbd_conf *mdev, |
| 2081 | struct p_header80 *h, struct bm_xfer_ctx *c) | 2248 | struct p_header80 *h, struct bm_xfer_ctx *c) |
| 2082 | { | 2249 | { |
| 2083 | struct p_compressed_bm *p = (void*)h; | 2250 | struct p_compressed_bm *p = (void*)h; |
| 2084 | unsigned long num_words; | 2251 | unsigned long num_words; |
| @@ -2088,7 +2255,7 @@ send_bitmap_rle_or_plain(struct drbd_conf *mdev, | |||
| 2088 | len = fill_bitmap_rle_bits(mdev, p, c); | 2255 | len = fill_bitmap_rle_bits(mdev, p, c); |
| 2089 | 2256 | ||
| 2090 | if (len < 0) | 2257 | if (len < 0) |
| 2091 | return FAILED; | 2258 | return -EIO; |
| 2092 | 2259 | ||
| 2093 | if (len) { | 2260 | if (len) { |
| 2094 | DCBP_set_code(p, RLE_VLI_Bits); | 2261 | DCBP_set_code(p, RLE_VLI_Bits); |
| @@ -2118,11 +2285,14 @@ send_bitmap_rle_or_plain(struct drbd_conf *mdev, | |||
| 2118 | if (c->bit_offset > c->bm_bits) | 2285 | if (c->bit_offset > c->bm_bits) |
| 2119 | c->bit_offset = c->bm_bits; | 2286 | c->bit_offset = c->bm_bits; |
| 2120 | } | 2287 | } |
| 2121 | ok = ok ? ((len == 0) ? DONE : OK) : FAILED; | 2288 | if (ok) { |
| 2122 | 2289 | if (len == 0) { | |
| 2123 | if (ok == DONE) | 2290 | INFO_bm_xfer_stats(mdev, "send", c); |
| 2124 | INFO_bm_xfer_stats(mdev, "send", c); | 2291 | return 0; |
| 2125 | return ok; | 2292 | } else |
| 2293 | return 1; | ||
| 2294 | } | ||
| 2295 | return -EIO; | ||
| 2126 | } | 2296 | } |
| 2127 | 2297 | ||
| 2128 | /* See the comment at receive_bitmap() */ | 2298 | /* See the comment at receive_bitmap() */ |
| @@ -2130,16 +2300,16 @@ int _drbd_send_bitmap(struct drbd_conf *mdev) | |||
| 2130 | { | 2300 | { |
| 2131 | struct bm_xfer_ctx c; | 2301 | struct bm_xfer_ctx c; |
| 2132 | struct p_header80 *p; | 2302 | struct p_header80 *p; |
| 2133 | int ret; | 2303 | int err; |
| 2134 | 2304 | ||
| 2135 | ERR_IF(!mdev->bitmap) return FALSE; | 2305 | ERR_IF(!mdev->bitmap) return false; |
| 2136 | 2306 | ||
| 2137 | /* maybe we should use some per thread scratch page, | 2307 | /* maybe we should use some per thread scratch page, |
| 2138 | * and allocate that during initial device creation? */ | 2308 | * and allocate that during initial device creation? */ |
| 2139 | p = (struct p_header80 *) __get_free_page(GFP_NOIO); | 2309 | p = (struct p_header80 *) __get_free_page(GFP_NOIO); |
| 2140 | if (!p) { | 2310 | if (!p) { |
| 2141 | dev_err(DEV, "failed to allocate one page buffer in %s\n", __func__); | 2311 | dev_err(DEV, "failed to allocate one page buffer in %s\n", __func__); |
| 2142 | return FALSE; | 2312 | return false; |
| 2143 | } | 2313 | } |
| 2144 | 2314 | ||
| 2145 | if (get_ldev(mdev)) { | 2315 | if (get_ldev(mdev)) { |
| @@ -2165,11 +2335,11 @@ int _drbd_send_bitmap(struct drbd_conf *mdev) | |||
| 2165 | }; | 2335 | }; |
| 2166 | 2336 | ||
| 2167 | do { | 2337 | do { |
| 2168 | ret = send_bitmap_rle_or_plain(mdev, p, &c); | 2338 | err = send_bitmap_rle_or_plain(mdev, p, &c); |
| 2169 | } while (ret == OK); | 2339 | } while (err > 0); |
| 2170 | 2340 | ||
| 2171 | free_page((unsigned long) p); | 2341 | free_page((unsigned long) p); |
| 2172 | return (ret == DONE); | 2342 | return err == 0; |
| 2173 | } | 2343 | } |
| 2174 | 2344 | ||
| 2175 | int drbd_send_bitmap(struct drbd_conf *mdev) | 2345 | int drbd_send_bitmap(struct drbd_conf *mdev) |
| @@ -2192,7 +2362,7 @@ int drbd_send_b_ack(struct drbd_conf *mdev, u32 barrier_nr, u32 set_size) | |||
| 2192 | p.set_size = cpu_to_be32(set_size); | 2362 | p.set_size = cpu_to_be32(set_size); |
| 2193 | 2363 | ||
| 2194 | if (mdev->state.conn < C_CONNECTED) | 2364 | if (mdev->state.conn < C_CONNECTED) |
| 2195 | return FALSE; | 2365 | return false; |
| 2196 | ok = drbd_send_cmd(mdev, USE_META_SOCKET, P_BARRIER_ACK, | 2366 | ok = drbd_send_cmd(mdev, USE_META_SOCKET, P_BARRIER_ACK, |
| 2197 | (struct p_header80 *)&p, sizeof(p)); | 2367 | (struct p_header80 *)&p, sizeof(p)); |
| 2198 | return ok; | 2368 | return ok; |
| @@ -2220,7 +2390,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packets cmd, | |||
| 2220 | p.seq_num = cpu_to_be32(atomic_add_return(1, &mdev->packet_seq)); | 2390 | p.seq_num = cpu_to_be32(atomic_add_return(1, &mdev->packet_seq)); |
| 2221 | 2391 | ||
| 2222 | if (!mdev->meta.socket || mdev->state.conn < C_CONNECTED) | 2392 | if (!mdev->meta.socket || mdev->state.conn < C_CONNECTED) |
| 2223 | return FALSE; | 2393 | return false; |
| 2224 | ok = drbd_send_cmd(mdev, USE_META_SOCKET, cmd, | 2394 | ok = drbd_send_cmd(mdev, USE_META_SOCKET, cmd, |
| 2225 | (struct p_header80 *)&p, sizeof(p)); | 2395 | (struct p_header80 *)&p, sizeof(p)); |
| 2226 | return ok; | 2396 | return ok; |
| @@ -2326,8 +2496,8 @@ int drbd_send_ov_request(struct drbd_conf *mdev, sector_t sector, int size) | |||
| 2326 | } | 2496 | } |
| 2327 | 2497 | ||
| 2328 | /* called on sndtimeo | 2498 | /* called on sndtimeo |
| 2329 | * returns FALSE if we should retry, | 2499 | * returns false if we should retry, |
| 2330 | * TRUE if we think connection is dead | 2500 | * true if we think connection is dead |
| 2331 | */ | 2501 | */ |
| 2332 | static int we_should_drop_the_connection(struct drbd_conf *mdev, struct socket *sock) | 2502 | static int we_should_drop_the_connection(struct drbd_conf *mdev, struct socket *sock) |
| 2333 | { | 2503 | { |
| @@ -2340,7 +2510,7 @@ static int we_should_drop_the_connection(struct drbd_conf *mdev, struct socket * | |||
| 2340 | || mdev->state.conn < C_CONNECTED; | 2510 | || mdev->state.conn < C_CONNECTED; |
| 2341 | 2511 | ||
| 2342 | if (drop_it) | 2512 | if (drop_it) |
| 2343 | return TRUE; | 2513 | return true; |
| 2344 | 2514 | ||
| 2345 | drop_it = !--mdev->ko_count; | 2515 | drop_it = !--mdev->ko_count; |
| 2346 | if (!drop_it) { | 2516 | if (!drop_it) { |
| @@ -2531,13 +2701,39 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req) | |||
| 2531 | if (ok && dgs) { | 2701 | if (ok && dgs) { |
| 2532 | dgb = mdev->int_dig_out; | 2702 | dgb = mdev->int_dig_out; |
| 2533 | drbd_csum_bio(mdev, mdev->integrity_w_tfm, req->master_bio, dgb); | 2703 | drbd_csum_bio(mdev, mdev->integrity_w_tfm, req->master_bio, dgb); |
| 2534 | ok = drbd_send(mdev, mdev->data.socket, dgb, dgs, 0); | 2704 | ok = dgs == drbd_send(mdev, mdev->data.socket, dgb, dgs, 0); |
| 2535 | } | 2705 | } |
| 2536 | if (ok) { | 2706 | if (ok) { |
| 2537 | if (mdev->net_conf->wire_protocol == DRBD_PROT_A) | 2707 | /* For protocol A, we have to memcpy the payload into |
| 2708 | * socket buffers, as we may complete right away | ||
| 2709 | * as soon as we handed it over to tcp, at which point the data | ||
| 2710 | * pages may become invalid. | ||
| 2711 | * | ||
| 2712 | * For data-integrity enabled, we copy it as well, so we can be | ||
| 2713 | * sure that even if the bio pages may still be modified, it | ||
| 2714 | * won't change the data on the wire, thus if the digest checks | ||
| 2715 | * out ok after sending on this side, but does not fit on the | ||
| 2716 | * receiving side, we sure have detected corruption elsewhere. | ||
| 2717 | */ | ||
| 2718 | if (mdev->net_conf->wire_protocol == DRBD_PROT_A || dgs) | ||
| 2538 | ok = _drbd_send_bio(mdev, req->master_bio); | 2719 | ok = _drbd_send_bio(mdev, req->master_bio); |
| 2539 | else | 2720 | else |
| 2540 | ok = _drbd_send_zc_bio(mdev, req->master_bio); | 2721 | ok = _drbd_send_zc_bio(mdev, req->master_bio); |
| 2722 | |||
| 2723 | /* double check digest, sometimes buffers have been modified in flight. */ | ||
| 2724 | if (dgs > 0 && dgs <= 64) { | ||
| 2725 | /* 64 byte, 512 bit, is the larges digest size | ||
| 2726 | * currently supported in kernel crypto. */ | ||
| 2727 | unsigned char digest[64]; | ||
| 2728 | drbd_csum_bio(mdev, mdev->integrity_w_tfm, req->master_bio, digest); | ||
| 2729 | if (memcmp(mdev->int_dig_out, digest, dgs)) { | ||
| 2730 | dev_warn(DEV, | ||
| 2731 | "Digest mismatch, buffer modified by upper layers during write: %llus +%u\n", | ||
| 2732 | (unsigned long long)req->sector, req->size); | ||
| 2733 | } | ||
| 2734 | } /* else if (dgs > 64) { | ||
| 2735 | ... Be noisy about digest too large ... | ||
| 2736 | } */ | ||
| 2541 | } | 2737 | } |
| 2542 | 2738 | ||
| 2543 | drbd_put_data_sock(mdev); | 2739 | drbd_put_data_sock(mdev); |
| @@ -2587,7 +2783,7 @@ int drbd_send_block(struct drbd_conf *mdev, enum drbd_packets cmd, | |||
| 2587 | if (ok && dgs) { | 2783 | if (ok && dgs) { |
| 2588 | dgb = mdev->int_dig_out; | 2784 | dgb = mdev->int_dig_out; |
| 2589 | drbd_csum_ee(mdev, mdev->integrity_w_tfm, e, dgb); | 2785 | drbd_csum_ee(mdev, mdev->integrity_w_tfm, e, dgb); |
| 2590 | ok = drbd_send(mdev, mdev->data.socket, dgb, dgs, 0); | 2786 | ok = dgs == drbd_send(mdev, mdev->data.socket, dgb, dgs, 0); |
| 2591 | } | 2787 | } |
| 2592 | if (ok) | 2788 | if (ok) |
| 2593 | ok = _drbd_send_zc_ee(mdev, e); | 2789 | ok = _drbd_send_zc_ee(mdev, e); |
| @@ -2597,6 +2793,16 @@ int drbd_send_block(struct drbd_conf *mdev, enum drbd_packets cmd, | |||
| 2597 | return ok; | 2793 | return ok; |
| 2598 | } | 2794 | } |
| 2599 | 2795 | ||
| 2796 | int drbd_send_oos(struct drbd_conf *mdev, struct drbd_request *req) | ||
| 2797 | { | ||
| 2798 | struct p_block_desc p; | ||
| 2799 | |||
| 2800 | p.sector = cpu_to_be64(req->sector); | ||
| 2801 | p.blksize = cpu_to_be32(req->size); | ||
| 2802 | |||
| 2803 | return drbd_send_cmd(mdev, USE_DATA_SOCKET, P_OUT_OF_SYNC, &p.head, sizeof(p)); | ||
| 2804 | } | ||
| 2805 | |||
| 2600 | /* | 2806 | /* |
| 2601 | drbd_send distinguishes two cases: | 2807 | drbd_send distinguishes two cases: |
| 2602 | 2808 | ||
| @@ -2770,6 +2976,7 @@ void drbd_init_set_defaults(struct drbd_conf *mdev) | |||
| 2770 | atomic_set(&mdev->pp_in_use_by_net, 0); | 2976 | atomic_set(&mdev->pp_in_use_by_net, 0); |
| 2771 | atomic_set(&mdev->rs_sect_in, 0); | 2977 | atomic_set(&mdev->rs_sect_in, 0); |
| 2772 | atomic_set(&mdev->rs_sect_ev, 0); | 2978 | atomic_set(&mdev->rs_sect_ev, 0); |
| 2979 | atomic_set(&mdev->ap_in_flight, 0); | ||
| 2773 | 2980 | ||
| 2774 | mutex_init(&mdev->md_io_mutex); | 2981 | mutex_init(&mdev->md_io_mutex); |
| 2775 | mutex_init(&mdev->data.mutex); | 2982 | mutex_init(&mdev->data.mutex); |
| @@ -2798,19 +3005,27 @@ void drbd_init_set_defaults(struct drbd_conf *mdev) | |||
| 2798 | INIT_LIST_HEAD(&mdev->unplug_work.list); | 3005 | INIT_LIST_HEAD(&mdev->unplug_work.list); |
| 2799 | INIT_LIST_HEAD(&mdev->go_diskless.list); | 3006 | INIT_LIST_HEAD(&mdev->go_diskless.list); |
| 2800 | INIT_LIST_HEAD(&mdev->md_sync_work.list); | 3007 | INIT_LIST_HEAD(&mdev->md_sync_work.list); |
| 3008 | INIT_LIST_HEAD(&mdev->start_resync_work.list); | ||
| 2801 | INIT_LIST_HEAD(&mdev->bm_io_work.w.list); | 3009 | INIT_LIST_HEAD(&mdev->bm_io_work.w.list); |
| 2802 | 3010 | ||
| 2803 | mdev->resync_work.cb = w_resync_inactive; | 3011 | mdev->resync_work.cb = w_resync_timer; |
| 2804 | mdev->unplug_work.cb = w_send_write_hint; | 3012 | mdev->unplug_work.cb = w_send_write_hint; |
| 2805 | mdev->go_diskless.cb = w_go_diskless; | 3013 | mdev->go_diskless.cb = w_go_diskless; |
| 2806 | mdev->md_sync_work.cb = w_md_sync; | 3014 | mdev->md_sync_work.cb = w_md_sync; |
| 2807 | mdev->bm_io_work.w.cb = w_bitmap_io; | 3015 | mdev->bm_io_work.w.cb = w_bitmap_io; |
| 3016 | mdev->start_resync_work.cb = w_start_resync; | ||
| 2808 | init_timer(&mdev->resync_timer); | 3017 | init_timer(&mdev->resync_timer); |
| 2809 | init_timer(&mdev->md_sync_timer); | 3018 | init_timer(&mdev->md_sync_timer); |
| 3019 | init_timer(&mdev->start_resync_timer); | ||
| 3020 | init_timer(&mdev->request_timer); | ||
| 2810 | mdev->resync_timer.function = resync_timer_fn; | 3021 | mdev->resync_timer.function = resync_timer_fn; |
| 2811 | mdev->resync_timer.data = (unsigned long) mdev; | 3022 | mdev->resync_timer.data = (unsigned long) mdev; |
| 2812 | mdev->md_sync_timer.function = md_sync_timer_fn; | 3023 | mdev->md_sync_timer.function = md_sync_timer_fn; |
| 2813 | mdev->md_sync_timer.data = (unsigned long) mdev; | 3024 | mdev->md_sync_timer.data = (unsigned long) mdev; |
| 3025 | mdev->start_resync_timer.function = start_resync_timer_fn; | ||
| 3026 | mdev->start_resync_timer.data = (unsigned long) mdev; | ||
| 3027 | mdev->request_timer.function = request_timer_fn; | ||
| 3028 | mdev->request_timer.data = (unsigned long) mdev; | ||
| 2814 | 3029 | ||
| 2815 | init_waitqueue_head(&mdev->misc_wait); | 3030 | init_waitqueue_head(&mdev->misc_wait); |
| 2816 | init_waitqueue_head(&mdev->state_wait); | 3031 | init_waitqueue_head(&mdev->state_wait); |
| @@ -2881,6 +3096,8 @@ void drbd_mdev_cleanup(struct drbd_conf *mdev) | |||
| 2881 | D_ASSERT(list_empty(&mdev->resync_work.list)); | 3096 | D_ASSERT(list_empty(&mdev->resync_work.list)); |
| 2882 | D_ASSERT(list_empty(&mdev->unplug_work.list)); | 3097 | D_ASSERT(list_empty(&mdev->unplug_work.list)); |
| 2883 | D_ASSERT(list_empty(&mdev->go_diskless.list)); | 3098 | D_ASSERT(list_empty(&mdev->go_diskless.list)); |
| 3099 | |||
| 3100 | drbd_set_defaults(mdev); | ||
| 2884 | } | 3101 | } |
| 2885 | 3102 | ||
| 2886 | 3103 | ||
| @@ -2923,7 +3140,7 @@ static void drbd_destroy_mempools(void) | |||
| 2923 | static int drbd_create_mempools(void) | 3140 | static int drbd_create_mempools(void) |
| 2924 | { | 3141 | { |
| 2925 | struct page *page; | 3142 | struct page *page; |
| 2926 | const int number = (DRBD_MAX_SEGMENT_SIZE/PAGE_SIZE) * minor_count; | 3143 | const int number = (DRBD_MAX_BIO_SIZE/PAGE_SIZE) * minor_count; |
| 2927 | int i; | 3144 | int i; |
| 2928 | 3145 | ||
| 2929 | /* prepare our caches and mempools */ | 3146 | /* prepare our caches and mempools */ |
| @@ -3087,11 +3304,20 @@ static void drbd_cleanup(void) | |||
| 3087 | 3304 | ||
| 3088 | unregister_reboot_notifier(&drbd_notifier); | 3305 | unregister_reboot_notifier(&drbd_notifier); |
| 3089 | 3306 | ||
| 3307 | /* first remove proc, | ||
| 3308 | * drbdsetup uses it's presence to detect | ||
| 3309 | * whether DRBD is loaded. | ||
| 3310 | * If we would get stuck in proc removal, | ||
| 3311 | * but have netlink already deregistered, | ||
| 3312 | * some drbdsetup commands may wait forever | ||
| 3313 | * for an answer. | ||
| 3314 | */ | ||
| 3315 | if (drbd_proc) | ||
| 3316 | remove_proc_entry("drbd", NULL); | ||
| 3317 | |||
| 3090 | drbd_nl_cleanup(); | 3318 | drbd_nl_cleanup(); |
| 3091 | 3319 | ||
| 3092 | if (minor_table) { | 3320 | if (minor_table) { |
| 3093 | if (drbd_proc) | ||
| 3094 | remove_proc_entry("drbd", NULL); | ||
| 3095 | i = minor_count; | 3321 | i = minor_count; |
| 3096 | while (i--) | 3322 | while (i--) |
| 3097 | drbd_delete_device(i); | 3323 | drbd_delete_device(i); |
| @@ -3119,7 +3345,7 @@ static int drbd_congested(void *congested_data, int bdi_bits) | |||
| 3119 | char reason = '-'; | 3345 | char reason = '-'; |
| 3120 | int r = 0; | 3346 | int r = 0; |
| 3121 | 3347 | ||
| 3122 | if (!__inc_ap_bio_cond(mdev)) { | 3348 | if (!may_inc_ap_bio(mdev)) { |
| 3123 | /* DRBD has frozen IO */ | 3349 | /* DRBD has frozen IO */ |
| 3124 | r = bdi_bits; | 3350 | r = bdi_bits; |
| 3125 | reason = 'd'; | 3351 | reason = 'd'; |
| @@ -3172,7 +3398,7 @@ struct drbd_conf *drbd_new_device(unsigned int minor) | |||
| 3172 | goto out_no_disk; | 3398 | goto out_no_disk; |
| 3173 | mdev->vdisk = disk; | 3399 | mdev->vdisk = disk; |
| 3174 | 3400 | ||
| 3175 | set_disk_ro(disk, TRUE); | 3401 | set_disk_ro(disk, true); |
| 3176 | 3402 | ||
| 3177 | disk->queue = q; | 3403 | disk->queue = q; |
| 3178 | disk->major = DRBD_MAJOR; | 3404 | disk->major = DRBD_MAJOR; |
| @@ -3188,8 +3414,8 @@ struct drbd_conf *drbd_new_device(unsigned int minor) | |||
| 3188 | q->backing_dev_info.congested_fn = drbd_congested; | 3414 | q->backing_dev_info.congested_fn = drbd_congested; |
| 3189 | q->backing_dev_info.congested_data = mdev; | 3415 | q->backing_dev_info.congested_data = mdev; |
| 3190 | 3416 | ||
| 3191 | blk_queue_make_request(q, drbd_make_request_26); | 3417 | blk_queue_make_request(q, drbd_make_request); |
| 3192 | blk_queue_max_segment_size(q, DRBD_MAX_SEGMENT_SIZE); | 3418 | blk_queue_max_hw_sectors(q, DRBD_MAX_BIO_SIZE >> 9); |
| 3193 | blk_queue_bounce_limit(q, BLK_BOUNCE_ANY); | 3419 | blk_queue_bounce_limit(q, BLK_BOUNCE_ANY); |
| 3194 | blk_queue_merge_bvec(q, drbd_merge_bvec); | 3420 | blk_queue_merge_bvec(q, drbd_merge_bvec); |
| 3195 | q->queue_lock = &mdev->req_lock; | 3421 | q->queue_lock = &mdev->req_lock; |
| @@ -3251,6 +3477,7 @@ void drbd_free_mdev(struct drbd_conf *mdev) | |||
| 3251 | put_disk(mdev->vdisk); | 3477 | put_disk(mdev->vdisk); |
| 3252 | blk_cleanup_queue(mdev->rq_queue); | 3478 | blk_cleanup_queue(mdev->rq_queue); |
| 3253 | free_cpumask_var(mdev->cpu_mask); | 3479 | free_cpumask_var(mdev->cpu_mask); |
| 3480 | drbd_free_tl_hash(mdev); | ||
| 3254 | kfree(mdev); | 3481 | kfree(mdev); |
| 3255 | } | 3482 | } |
| 3256 | 3483 | ||
| @@ -3266,7 +3493,7 @@ int __init drbd_init(void) | |||
| 3266 | return -EINVAL; | 3493 | return -EINVAL; |
| 3267 | } | 3494 | } |
| 3268 | 3495 | ||
| 3269 | if (1 > minor_count || minor_count > 255) { | 3496 | if (minor_count < DRBD_MINOR_COUNT_MIN || minor_count > DRBD_MINOR_COUNT_MAX) { |
| 3270 | printk(KERN_ERR | 3497 | printk(KERN_ERR |
| 3271 | "drbd: invalid minor_count (%d)\n", minor_count); | 3498 | "drbd: invalid minor_count (%d)\n", minor_count); |
| 3272 | #ifdef MODULE | 3499 | #ifdef MODULE |
| @@ -3448,7 +3675,7 @@ void drbd_md_sync(struct drbd_conf *mdev) | |||
| 3448 | if (!drbd_md_sync_page_io(mdev, mdev->ldev, sector, WRITE)) { | 3675 | if (!drbd_md_sync_page_io(mdev, mdev->ldev, sector, WRITE)) { |
| 3449 | /* this was a try anyways ... */ | 3676 | /* this was a try anyways ... */ |
| 3450 | dev_err(DEV, "meta data update failed!\n"); | 3677 | dev_err(DEV, "meta data update failed!\n"); |
| 3451 | drbd_chk_io_error(mdev, 1, TRUE); | 3678 | drbd_chk_io_error(mdev, 1, true); |
| 3452 | } | 3679 | } |
| 3453 | 3680 | ||
| 3454 | /* Update mdev->ldev->md.la_size_sect, | 3681 | /* Update mdev->ldev->md.la_size_sect, |
| @@ -3464,7 +3691,7 @@ void drbd_md_sync(struct drbd_conf *mdev) | |||
| 3464 | * @mdev: DRBD device. | 3691 | * @mdev: DRBD device. |
| 3465 | * @bdev: Device from which the meta data should be read in. | 3692 | * @bdev: Device from which the meta data should be read in. |
| 3466 | * | 3693 | * |
| 3467 | * Return 0 (NO_ERROR) on success, and an enum drbd_ret_codes in case | 3694 | * Return 0 (NO_ERROR) on success, and an enum drbd_ret_code in case |
| 3468 | * something goes wrong. Currently only: ERR_IO_MD_DISK, ERR_MD_INVALID. | 3695 | * something goes wrong. Currently only: ERR_IO_MD_DISK, ERR_MD_INVALID. |
| 3469 | */ | 3696 | */ |
| 3470 | int drbd_md_read(struct drbd_conf *mdev, struct drbd_backing_dev *bdev) | 3697 | int drbd_md_read(struct drbd_conf *mdev, struct drbd_backing_dev *bdev) |
| @@ -3534,28 +3761,6 @@ int drbd_md_read(struct drbd_conf *mdev, struct drbd_backing_dev *bdev) | |||
| 3534 | return rv; | 3761 | return rv; |
| 3535 | } | 3762 | } |
| 3536 | 3763 | ||
| 3537 | static void debug_drbd_uuid(struct drbd_conf *mdev, enum drbd_uuid_index index) | ||
| 3538 | { | ||
| 3539 | static char *uuid_str[UI_EXTENDED_SIZE] = { | ||
| 3540 | [UI_CURRENT] = "CURRENT", | ||
| 3541 | [UI_BITMAP] = "BITMAP", | ||
| 3542 | [UI_HISTORY_START] = "HISTORY_START", | ||
| 3543 | [UI_HISTORY_END] = "HISTORY_END", | ||
| 3544 | [UI_SIZE] = "SIZE", | ||
| 3545 | [UI_FLAGS] = "FLAGS", | ||
| 3546 | }; | ||
| 3547 | |||
| 3548 | if (index >= UI_EXTENDED_SIZE) { | ||
| 3549 | dev_warn(DEV, " uuid_index >= EXTENDED_SIZE\n"); | ||
| 3550 | return; | ||
| 3551 | } | ||
| 3552 | |||
| 3553 | dynamic_dev_dbg(DEV, " uuid[%s] now %016llX\n", | ||
| 3554 | uuid_str[index], | ||
| 3555 | (unsigned long long)mdev->ldev->md.uuid[index]); | ||
| 3556 | } | ||
| 3557 | |||
| 3558 | |||
| 3559 | /** | 3764 | /** |
| 3560 | * drbd_md_mark_dirty() - Mark meta data super block as dirty | 3765 | * drbd_md_mark_dirty() - Mark meta data super block as dirty |
| 3561 | * @mdev: DRBD device. | 3766 | * @mdev: DRBD device. |
| @@ -3585,10 +3790,8 @@ static void drbd_uuid_move_history(struct drbd_conf *mdev) __must_hold(local) | |||
| 3585 | { | 3790 | { |
| 3586 | int i; | 3791 | int i; |
| 3587 | 3792 | ||
| 3588 | for (i = UI_HISTORY_START; i < UI_HISTORY_END; i++) { | 3793 | for (i = UI_HISTORY_START; i < UI_HISTORY_END; i++) |
| 3589 | mdev->ldev->md.uuid[i+1] = mdev->ldev->md.uuid[i]; | 3794 | mdev->ldev->md.uuid[i+1] = mdev->ldev->md.uuid[i]; |
| 3590 | debug_drbd_uuid(mdev, i+1); | ||
| 3591 | } | ||
| 3592 | } | 3795 | } |
| 3593 | 3796 | ||
| 3594 | void _drbd_uuid_set(struct drbd_conf *mdev, int idx, u64 val) __must_hold(local) | 3797 | void _drbd_uuid_set(struct drbd_conf *mdev, int idx, u64 val) __must_hold(local) |
| @@ -3603,7 +3806,6 @@ void _drbd_uuid_set(struct drbd_conf *mdev, int idx, u64 val) __must_hold(local) | |||
| 3603 | } | 3806 | } |
| 3604 | 3807 | ||
| 3605 | mdev->ldev->md.uuid[idx] = val; | 3808 | mdev->ldev->md.uuid[idx] = val; |
| 3606 | debug_drbd_uuid(mdev, idx); | ||
| 3607 | drbd_md_mark_dirty(mdev); | 3809 | drbd_md_mark_dirty(mdev); |
| 3608 | } | 3810 | } |
| 3609 | 3811 | ||
| @@ -3613,7 +3815,6 @@ void drbd_uuid_set(struct drbd_conf *mdev, int idx, u64 val) __must_hold(local) | |||
| 3613 | if (mdev->ldev->md.uuid[idx]) { | 3815 | if (mdev->ldev->md.uuid[idx]) { |
| 3614 | drbd_uuid_move_history(mdev); | 3816 | drbd_uuid_move_history(mdev); |
| 3615 | mdev->ldev->md.uuid[UI_HISTORY_START] = mdev->ldev->md.uuid[idx]; | 3817 | mdev->ldev->md.uuid[UI_HISTORY_START] = mdev->ldev->md.uuid[idx]; |
| 3616 | debug_drbd_uuid(mdev, UI_HISTORY_START); | ||
| 3617 | } | 3818 | } |
| 3618 | _drbd_uuid_set(mdev, idx, val); | 3819 | _drbd_uuid_set(mdev, idx, val); |
| 3619 | } | 3820 | } |
| @@ -3628,14 +3829,16 @@ void drbd_uuid_set(struct drbd_conf *mdev, int idx, u64 val) __must_hold(local) | |||
| 3628 | void drbd_uuid_new_current(struct drbd_conf *mdev) __must_hold(local) | 3829 | void drbd_uuid_new_current(struct drbd_conf *mdev) __must_hold(local) |
| 3629 | { | 3830 | { |
| 3630 | u64 val; | 3831 | u64 val; |
| 3832 | unsigned long long bm_uuid = mdev->ldev->md.uuid[UI_BITMAP]; | ||
| 3833 | |||
| 3834 | if (bm_uuid) | ||
| 3835 | dev_warn(DEV, "bm UUID was already set: %llX\n", bm_uuid); | ||
| 3631 | 3836 | ||
| 3632 | dev_info(DEV, "Creating new current UUID\n"); | ||
| 3633 | D_ASSERT(mdev->ldev->md.uuid[UI_BITMAP] == 0); | ||
| 3634 | mdev->ldev->md.uuid[UI_BITMAP] = mdev->ldev->md.uuid[UI_CURRENT]; | 3837 | mdev->ldev->md.uuid[UI_BITMAP] = mdev->ldev->md.uuid[UI_CURRENT]; |
| 3635 | debug_drbd_uuid(mdev, UI_BITMAP); | ||
| 3636 | 3838 | ||
| 3637 | get_random_bytes(&val, sizeof(u64)); | 3839 | get_random_bytes(&val, sizeof(u64)); |
| 3638 | _drbd_uuid_set(mdev, UI_CURRENT, val); | 3840 | _drbd_uuid_set(mdev, UI_CURRENT, val); |
| 3841 | drbd_print_uuids(mdev, "new current UUID"); | ||
| 3639 | /* get it to stable storage _now_ */ | 3842 | /* get it to stable storage _now_ */ |
| 3640 | drbd_md_sync(mdev); | 3843 | drbd_md_sync(mdev); |
| 3641 | } | 3844 | } |
| @@ -3649,16 +3852,12 @@ void drbd_uuid_set_bm(struct drbd_conf *mdev, u64 val) __must_hold(local) | |||
| 3649 | drbd_uuid_move_history(mdev); | 3852 | drbd_uuid_move_history(mdev); |
| 3650 | mdev->ldev->md.uuid[UI_HISTORY_START] = mdev->ldev->md.uuid[UI_BITMAP]; | 3853 | mdev->ldev->md.uuid[UI_HISTORY_START] = mdev->ldev->md.uuid[UI_BITMAP]; |
| 3651 | mdev->ldev->md.uuid[UI_BITMAP] = 0; | 3854 | mdev->ldev->md.uuid[UI_BITMAP] = 0; |
| 3652 | debug_drbd_uuid(mdev, UI_HISTORY_START); | ||
| 3653 | debug_drbd_uuid(mdev, UI_BITMAP); | ||
| 3654 | } else { | 3855 | } else { |
| 3655 | if (mdev->ldev->md.uuid[UI_BITMAP]) | 3856 | unsigned long long bm_uuid = mdev->ldev->md.uuid[UI_BITMAP]; |
| 3656 | dev_warn(DEV, "bm UUID already set"); | 3857 | if (bm_uuid) |
| 3657 | 3858 | dev_warn(DEV, "bm UUID was already set: %llX\n", bm_uuid); | |
| 3658 | mdev->ldev->md.uuid[UI_BITMAP] = val; | ||
| 3659 | mdev->ldev->md.uuid[UI_BITMAP] &= ~((u64)1); | ||
| 3660 | 3859 | ||
| 3661 | debug_drbd_uuid(mdev, UI_BITMAP); | 3860 | mdev->ldev->md.uuid[UI_BITMAP] = val & ~((u64)1); |
| 3662 | } | 3861 | } |
| 3663 | drbd_md_mark_dirty(mdev); | 3862 | drbd_md_mark_dirty(mdev); |
| 3664 | } | 3863 | } |
| @@ -3714,15 +3913,19 @@ int drbd_bmio_clear_n_write(struct drbd_conf *mdev) | |||
| 3714 | static int w_bitmap_io(struct drbd_conf *mdev, struct drbd_work *w, int unused) | 3913 | static int w_bitmap_io(struct drbd_conf *mdev, struct drbd_work *w, int unused) |
| 3715 | { | 3914 | { |
| 3716 | struct bm_io_work *work = container_of(w, struct bm_io_work, w); | 3915 | struct bm_io_work *work = container_of(w, struct bm_io_work, w); |
| 3717 | int rv; | 3916 | int rv = -EIO; |
| 3718 | 3917 | ||
| 3719 | D_ASSERT(atomic_read(&mdev->ap_bio_cnt) == 0); | 3918 | D_ASSERT(atomic_read(&mdev->ap_bio_cnt) == 0); |
| 3720 | 3919 | ||
| 3721 | drbd_bm_lock(mdev, work->why); | 3920 | if (get_ldev(mdev)) { |
| 3722 | rv = work->io_fn(mdev); | 3921 | drbd_bm_lock(mdev, work->why, work->flags); |
| 3723 | drbd_bm_unlock(mdev); | 3922 | rv = work->io_fn(mdev); |
| 3923 | drbd_bm_unlock(mdev); | ||
| 3924 | put_ldev(mdev); | ||
| 3925 | } | ||
| 3724 | 3926 | ||
| 3725 | clear_bit(BITMAP_IO, &mdev->flags); | 3927 | clear_bit(BITMAP_IO, &mdev->flags); |
| 3928 | smp_mb__after_clear_bit(); | ||
| 3726 | wake_up(&mdev->misc_wait); | 3929 | wake_up(&mdev->misc_wait); |
| 3727 | 3930 | ||
| 3728 | if (work->done) | 3931 | if (work->done) |
| @@ -3730,6 +3933,7 @@ static int w_bitmap_io(struct drbd_conf *mdev, struct drbd_work *w, int unused) | |||
| 3730 | 3933 | ||
| 3731 | clear_bit(BITMAP_IO_QUEUED, &mdev->flags); | 3934 | clear_bit(BITMAP_IO_QUEUED, &mdev->flags); |
| 3732 | work->why = NULL; | 3935 | work->why = NULL; |
| 3936 | work->flags = 0; | ||
| 3733 | 3937 | ||
| 3734 | return 1; | 3938 | return 1; |
| 3735 | } | 3939 | } |
| @@ -3784,7 +3988,7 @@ void drbd_go_diskless(struct drbd_conf *mdev) | |||
| 3784 | void drbd_queue_bitmap_io(struct drbd_conf *mdev, | 3988 | void drbd_queue_bitmap_io(struct drbd_conf *mdev, |
| 3785 | int (*io_fn)(struct drbd_conf *), | 3989 | int (*io_fn)(struct drbd_conf *), |
| 3786 | void (*done)(struct drbd_conf *, int), | 3990 | void (*done)(struct drbd_conf *, int), |
| 3787 | char *why) | 3991 | char *why, enum bm_flag flags) |
| 3788 | { | 3992 | { |
| 3789 | D_ASSERT(current == mdev->worker.task); | 3993 | D_ASSERT(current == mdev->worker.task); |
| 3790 | 3994 | ||
| @@ -3798,15 +4002,15 @@ void drbd_queue_bitmap_io(struct drbd_conf *mdev, | |||
| 3798 | mdev->bm_io_work.io_fn = io_fn; | 4002 | mdev->bm_io_work.io_fn = io_fn; |
| 3799 | mdev->bm_io_work.done = done; | 4003 | mdev->bm_io_work.done = done; |
| 3800 | mdev->bm_io_work.why = why; | 4004 | mdev->bm_io_work.why = why; |
| 4005 | mdev->bm_io_work.flags = flags; | ||
| 3801 | 4006 | ||
| 4007 | spin_lock_irq(&mdev->req_lock); | ||
| 3802 | set_bit(BITMAP_IO, &mdev->flags); | 4008 | set_bit(BITMAP_IO, &mdev->flags); |
| 3803 | if (atomic_read(&mdev->ap_bio_cnt) == 0) { | 4009 | if (atomic_read(&mdev->ap_bio_cnt) == 0) { |
| 3804 | if (list_empty(&mdev->bm_io_work.w.list)) { | 4010 | if (!test_and_set_bit(BITMAP_IO_QUEUED, &mdev->flags)) |
| 3805 | set_bit(BITMAP_IO_QUEUED, &mdev->flags); | ||
| 3806 | drbd_queue_work(&mdev->data.work, &mdev->bm_io_work.w); | 4011 | drbd_queue_work(&mdev->data.work, &mdev->bm_io_work.w); |
| 3807 | } else | ||
| 3808 | dev_err(DEV, "FIXME avoided double queuing bm_io_work\n"); | ||
| 3809 | } | 4012 | } |
| 4013 | spin_unlock_irq(&mdev->req_lock); | ||
| 3810 | } | 4014 | } |
| 3811 | 4015 | ||
| 3812 | /** | 4016 | /** |
| @@ -3818,19 +4022,22 @@ void drbd_queue_bitmap_io(struct drbd_conf *mdev, | |||
| 3818 | * freezes application IO while that the actual IO operations runs. This | 4022 | * freezes application IO while that the actual IO operations runs. This |
| 3819 | * functions MAY NOT be called from worker context. | 4023 | * functions MAY NOT be called from worker context. |
| 3820 | */ | 4024 | */ |
| 3821 | int drbd_bitmap_io(struct drbd_conf *mdev, int (*io_fn)(struct drbd_conf *), char *why) | 4025 | int drbd_bitmap_io(struct drbd_conf *mdev, int (*io_fn)(struct drbd_conf *), |
| 4026 | char *why, enum bm_flag flags) | ||
| 3822 | { | 4027 | { |
| 3823 | int rv; | 4028 | int rv; |
| 3824 | 4029 | ||
| 3825 | D_ASSERT(current != mdev->worker.task); | 4030 | D_ASSERT(current != mdev->worker.task); |
| 3826 | 4031 | ||
| 3827 | drbd_suspend_io(mdev); | 4032 | if ((flags & BM_LOCKED_SET_ALLOWED) == 0) |
| 4033 | drbd_suspend_io(mdev); | ||
| 3828 | 4034 | ||
| 3829 | drbd_bm_lock(mdev, why); | 4035 | drbd_bm_lock(mdev, why, flags); |
| 3830 | rv = io_fn(mdev); | 4036 | rv = io_fn(mdev); |
| 3831 | drbd_bm_unlock(mdev); | 4037 | drbd_bm_unlock(mdev); |
| 3832 | 4038 | ||
| 3833 | drbd_resume_io(mdev); | 4039 | if ((flags & BM_LOCKED_SET_ALLOWED) == 0) |
| 4040 | drbd_resume_io(mdev); | ||
| 3834 | 4041 | ||
| 3835 | return rv; | 4042 | return rv; |
| 3836 | } | 4043 | } |
diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c index fe81c851ca8..03b29f78a37 100644 --- a/drivers/block/drbd/drbd_nl.c +++ b/drivers/block/drbd/drbd_nl.c | |||
| @@ -288,10 +288,11 @@ void drbd_try_outdate_peer_async(struct drbd_conf *mdev) | |||
| 288 | dev_err(DEV, "out of mem, failed to invoke fence-peer helper\n"); | 288 | dev_err(DEV, "out of mem, failed to invoke fence-peer helper\n"); |
| 289 | } | 289 | } |
| 290 | 290 | ||
| 291 | int drbd_set_role(struct drbd_conf *mdev, enum drbd_role new_role, int force) | 291 | enum drbd_state_rv |
| 292 | drbd_set_role(struct drbd_conf *mdev, enum drbd_role new_role, int force) | ||
| 292 | { | 293 | { |
| 293 | const int max_tries = 4; | 294 | const int max_tries = 4; |
| 294 | int r = 0; | 295 | enum drbd_state_rv rv = SS_UNKNOWN_ERROR; |
| 295 | int try = 0; | 296 | int try = 0; |
| 296 | int forced = 0; | 297 | int forced = 0; |
| 297 | union drbd_state mask, val; | 298 | union drbd_state mask, val; |
| @@ -306,17 +307,17 @@ int drbd_set_role(struct drbd_conf *mdev, enum drbd_role new_role, int force) | |||
| 306 | val.i = 0; val.role = new_role; | 307 | val.i = 0; val.role = new_role; |
| 307 | 308 | ||
| 308 | while (try++ < max_tries) { | 309 | while (try++ < max_tries) { |
| 309 | r = _drbd_request_state(mdev, mask, val, CS_WAIT_COMPLETE); | 310 | rv = _drbd_request_state(mdev, mask, val, CS_WAIT_COMPLETE); |
| 310 | 311 | ||
| 311 | /* in case we first succeeded to outdate, | 312 | /* in case we first succeeded to outdate, |
| 312 | * but now suddenly could establish a connection */ | 313 | * but now suddenly could establish a connection */ |
| 313 | if (r == SS_CW_FAILED_BY_PEER && mask.pdsk != 0) { | 314 | if (rv == SS_CW_FAILED_BY_PEER && mask.pdsk != 0) { |
| 314 | val.pdsk = 0; | 315 | val.pdsk = 0; |
| 315 | mask.pdsk = 0; | 316 | mask.pdsk = 0; |
| 316 | continue; | 317 | continue; |
| 317 | } | 318 | } |
| 318 | 319 | ||
| 319 | if (r == SS_NO_UP_TO_DATE_DISK && force && | 320 | if (rv == SS_NO_UP_TO_DATE_DISK && force && |
| 320 | (mdev->state.disk < D_UP_TO_DATE && | 321 | (mdev->state.disk < D_UP_TO_DATE && |
| 321 | mdev->state.disk >= D_INCONSISTENT)) { | 322 | mdev->state.disk >= D_INCONSISTENT)) { |
| 322 | mask.disk = D_MASK; | 323 | mask.disk = D_MASK; |
| @@ -325,7 +326,7 @@ int drbd_set_role(struct drbd_conf *mdev, enum drbd_role new_role, int force) | |||
| 325 | continue; | 326 | continue; |
| 326 | } | 327 | } |
| 327 | 328 | ||
| 328 | if (r == SS_NO_UP_TO_DATE_DISK && | 329 | if (rv == SS_NO_UP_TO_DATE_DISK && |
| 329 | mdev->state.disk == D_CONSISTENT && mask.pdsk == 0) { | 330 | mdev->state.disk == D_CONSISTENT && mask.pdsk == 0) { |
| 330 | D_ASSERT(mdev->state.pdsk == D_UNKNOWN); | 331 | D_ASSERT(mdev->state.pdsk == D_UNKNOWN); |
| 331 | nps = drbd_try_outdate_peer(mdev); | 332 | nps = drbd_try_outdate_peer(mdev); |
| @@ -341,9 +342,9 @@ int drbd_set_role(struct drbd_conf *mdev, enum drbd_role new_role, int force) | |||
| 341 | continue; | 342 | continue; |
| 342 | } | 343 | } |
| 343 | 344 | ||
| 344 | if (r == SS_NOTHING_TO_DO) | 345 | if (rv == SS_NOTHING_TO_DO) |
| 345 | goto fail; | 346 | goto fail; |
| 346 | if (r == SS_PRIMARY_NOP && mask.pdsk == 0) { | 347 | if (rv == SS_PRIMARY_NOP && mask.pdsk == 0) { |
| 347 | nps = drbd_try_outdate_peer(mdev); | 348 | nps = drbd_try_outdate_peer(mdev); |
| 348 | 349 | ||
| 349 | if (force && nps > D_OUTDATED) { | 350 | if (force && nps > D_OUTDATED) { |
| @@ -356,25 +357,24 @@ int drbd_set_role(struct drbd_conf *mdev, enum drbd_role new_role, int force) | |||
| 356 | 357 | ||
| 357 | continue; | 358 | continue; |
| 358 | } | 359 | } |
| 359 | if (r == SS_TWO_PRIMARIES) { | 360 | if (rv == SS_TWO_PRIMARIES) { |
| 360 | /* Maybe the peer is detected as dead very soon... | 361 | /* Maybe the peer is detected as dead very soon... |
| 361 | retry at most once more in this case. */ | 362 | retry at most once more in this case. */ |
| 362 | __set_current_state(TASK_INTERRUPTIBLE); | 363 | schedule_timeout_interruptible((mdev->net_conf->ping_timeo+1)*HZ/10); |
| 363 | schedule_timeout((mdev->net_conf->ping_timeo+1)*HZ/10); | ||
| 364 | if (try < max_tries) | 364 | if (try < max_tries) |
| 365 | try = max_tries - 1; | 365 | try = max_tries - 1; |
| 366 | continue; | 366 | continue; |
| 367 | } | 367 | } |
| 368 | if (r < SS_SUCCESS) { | 368 | if (rv < SS_SUCCESS) { |
| 369 | r = _drbd_request_state(mdev, mask, val, | 369 | rv = _drbd_request_state(mdev, mask, val, |
| 370 | CS_VERBOSE + CS_WAIT_COMPLETE); | 370 | CS_VERBOSE + CS_WAIT_COMPLETE); |
| 371 | if (r < SS_SUCCESS) | 371 | if (rv < SS_SUCCESS) |
| 372 | goto fail; | 372 | goto fail; |
| 373 | } | 373 | } |
| 374 | break; | 374 | break; |
| 375 | } | 375 | } |
| 376 | 376 | ||
| 377 | if (r < SS_SUCCESS) | 377 | if (rv < SS_SUCCESS) |
| 378 | goto fail; | 378 | goto fail; |
| 379 | 379 | ||
| 380 | if (forced) | 380 | if (forced) |
| @@ -384,7 +384,7 @@ int drbd_set_role(struct drbd_conf *mdev, enum drbd_role new_role, int force) | |||
| 384 | wait_event(mdev->misc_wait, atomic_read(&mdev->ap_pending_cnt) == 0); | 384 | wait_event(mdev->misc_wait, atomic_read(&mdev->ap_pending_cnt) == 0); |
| 385 | 385 | ||
| 386 | if (new_role == R_SECONDARY) { | 386 | if (new_role == R_SECONDARY) { |
| 387 | set_disk_ro(mdev->vdisk, TRUE); | 387 | set_disk_ro(mdev->vdisk, true); |
| 388 | if (get_ldev(mdev)) { | 388 | if (get_ldev(mdev)) { |
| 389 | mdev->ldev->md.uuid[UI_CURRENT] &= ~(u64)1; | 389 | mdev->ldev->md.uuid[UI_CURRENT] &= ~(u64)1; |
| 390 | put_ldev(mdev); | 390 | put_ldev(mdev); |
| @@ -394,7 +394,7 @@ int drbd_set_role(struct drbd_conf *mdev, enum drbd_role new_role, int force) | |||
| 394 | mdev->net_conf->want_lose = 0; | 394 | mdev->net_conf->want_lose = 0; |
| 395 | put_net_conf(mdev); | 395 | put_net_conf(mdev); |
| 396 | } | 396 | } |
| 397 | set_disk_ro(mdev->vdisk, FALSE); | 397 | set_disk_ro(mdev->vdisk, false); |
| 398 | if (get_ldev(mdev)) { | 398 | if (get_ldev(mdev)) { |
| 399 | if (((mdev->state.conn < C_CONNECTED || | 399 | if (((mdev->state.conn < C_CONNECTED || |
| 400 | mdev->state.pdsk <= D_FAILED) | 400 | mdev->state.pdsk <= D_FAILED) |
| @@ -406,10 +406,8 @@ int drbd_set_role(struct drbd_conf *mdev, enum drbd_role new_role, int force) | |||
| 406 | } | 406 | } |
| 407 | } | 407 | } |
| 408 | 408 | ||
| 409 | if ((new_role == R_SECONDARY) && get_ldev(mdev)) { | 409 | /* writeout of activity log covered areas of the bitmap |
| 410 | drbd_al_to_on_disk_bm(mdev); | 410 | * to stable storage done in after state change already */ |
| 411 | put_ldev(mdev); | ||
| 412 | } | ||
| 413 | 411 | ||
| 414 | if (mdev->state.conn >= C_WF_REPORT_PARAMS) { | 412 | if (mdev->state.conn >= C_WF_REPORT_PARAMS) { |
| 415 | /* if this was forced, we should consider sync */ | 413 | /* if this was forced, we should consider sync */ |
| @@ -423,7 +421,7 @@ int drbd_set_role(struct drbd_conf *mdev, enum drbd_role new_role, int force) | |||
| 423 | kobject_uevent(&disk_to_dev(mdev->vdisk)->kobj, KOBJ_CHANGE); | 421 | kobject_uevent(&disk_to_dev(mdev->vdisk)->kobj, KOBJ_CHANGE); |
| 424 | fail: | 422 | fail: |
| 425 | mutex_unlock(&mdev->state_mutex); | 423 | mutex_unlock(&mdev->state_mutex); |
| 426 | return r; | 424 | return rv; |
| 427 | } | 425 | } |
| 428 | 426 | ||
| 429 | static struct drbd_conf *ensure_mdev(int minor, int create) | 427 | static struct drbd_conf *ensure_mdev(int minor, int create) |
| @@ -528,17 +526,19 @@ static void drbd_md_set_sector_offsets(struct drbd_conf *mdev, | |||
| 528 | } | 526 | } |
| 529 | } | 527 | } |
| 530 | 528 | ||
| 529 | /* input size is expected to be in KB */ | ||
| 531 | char *ppsize(char *buf, unsigned long long size) | 530 | char *ppsize(char *buf, unsigned long long size) |
| 532 | { | 531 | { |
| 533 | /* Needs 9 bytes at max. */ | 532 | /* Needs 9 bytes at max including trailing NUL: |
| 533 | * -1ULL ==> "16384 EB" */ | ||
| 534 | static char units[] = { 'K', 'M', 'G', 'T', 'P', 'E' }; | 534 | static char units[] = { 'K', 'M', 'G', 'T', 'P', 'E' }; |
| 535 | int base = 0; | 535 | int base = 0; |
| 536 | while (size >= 10000) { | 536 | while (size >= 10000 && base < sizeof(units)-1) { |
| 537 | /* shift + round */ | 537 | /* shift + round */ |
| 538 | size = (size >> 10) + !!(size & (1<<9)); | 538 | size = (size >> 10) + !!(size & (1<<9)); |
| 539 | base++; | 539 | base++; |
| 540 | } | 540 | } |
| 541 | sprintf(buf, "%lu %cB", (long)size, units[base]); | 541 | sprintf(buf, "%u %cB", (unsigned)size, units[base]); |
| 542 | 542 | ||
| 543 | return buf; | 543 | return buf; |
| 544 | } | 544 | } |
| @@ -642,11 +642,19 @@ enum determine_dev_size drbd_determin_dev_size(struct drbd_conf *mdev, enum dds_ | |||
| 642 | || prev_size != mdev->ldev->md.md_size_sect; | 642 | || prev_size != mdev->ldev->md.md_size_sect; |
| 643 | 643 | ||
| 644 | if (la_size_changed || md_moved) { | 644 | if (la_size_changed || md_moved) { |
| 645 | int err; | ||
| 646 | |||
| 645 | drbd_al_shrink(mdev); /* All extents inactive. */ | 647 | drbd_al_shrink(mdev); /* All extents inactive. */ |
| 646 | dev_info(DEV, "Writing the whole bitmap, %s\n", | 648 | dev_info(DEV, "Writing the whole bitmap, %s\n", |
| 647 | la_size_changed && md_moved ? "size changed and md moved" : | 649 | la_size_changed && md_moved ? "size changed and md moved" : |
| 648 | la_size_changed ? "size changed" : "md moved"); | 650 | la_size_changed ? "size changed" : "md moved"); |
| 649 | rv = drbd_bitmap_io(mdev, &drbd_bm_write, "size changed"); /* does drbd_resume_io() ! */ | 651 | /* next line implicitly does drbd_suspend_io()+drbd_resume_io() */ |
| 652 | err = drbd_bitmap_io(mdev, &drbd_bm_write, | ||
| 653 | "size changed", BM_LOCKED_MASK); | ||
| 654 | if (err) { | ||
| 655 | rv = dev_size_error; | ||
| 656 | goto out; | ||
| 657 | } | ||
| 650 | drbd_md_mark_dirty(mdev); | 658 | drbd_md_mark_dirty(mdev); |
| 651 | } | 659 | } |
| 652 | 660 | ||
| @@ -765,22 +773,21 @@ static int drbd_check_al_size(struct drbd_conf *mdev) | |||
| 765 | return 0; | 773 | return 0; |
| 766 | } | 774 | } |
| 767 | 775 | ||
| 768 | void drbd_setup_queue_param(struct drbd_conf *mdev, unsigned int max_seg_s) __must_hold(local) | 776 | void drbd_setup_queue_param(struct drbd_conf *mdev, unsigned int max_bio_size) __must_hold(local) |
| 769 | { | 777 | { |
| 770 | struct request_queue * const q = mdev->rq_queue; | 778 | struct request_queue * const q = mdev->rq_queue; |
| 771 | struct request_queue * const b = mdev->ldev->backing_bdev->bd_disk->queue; | 779 | struct request_queue * const b = mdev->ldev->backing_bdev->bd_disk->queue; |
| 772 | int max_segments = mdev->ldev->dc.max_bio_bvecs; | 780 | int max_segments = mdev->ldev->dc.max_bio_bvecs; |
| 781 | int max_hw_sectors = min(queue_max_hw_sectors(b), max_bio_size >> 9); | ||
| 773 | 782 | ||
| 774 | max_seg_s = min(queue_max_sectors(b) * queue_logical_block_size(b), max_seg_s); | ||
| 775 | |||
| 776 | blk_queue_max_hw_sectors(q, max_seg_s >> 9); | ||
| 777 | blk_queue_max_segments(q, max_segments ? max_segments : BLK_MAX_SEGMENTS); | ||
| 778 | blk_queue_max_segment_size(q, max_seg_s); | ||
| 779 | blk_queue_logical_block_size(q, 512); | 783 | blk_queue_logical_block_size(q, 512); |
| 780 | blk_queue_segment_boundary(q, PAGE_SIZE-1); | 784 | blk_queue_max_hw_sectors(q, max_hw_sectors); |
| 781 | blk_stack_limits(&q->limits, &b->limits, 0); | 785 | /* This is the workaround for "bio would need to, but cannot, be split" */ |
| 786 | blk_queue_max_segments(q, max_segments ? max_segments : BLK_MAX_SEGMENTS); | ||
| 787 | blk_queue_segment_boundary(q, PAGE_CACHE_SIZE-1); | ||
| 788 | blk_queue_stack_limits(q, b); | ||
| 782 | 789 | ||
| 783 | dev_info(DEV, "max_segment_size ( = BIO size ) = %u\n", queue_max_segment_size(q)); | 790 | dev_info(DEV, "max BIO size = %u\n", queue_max_hw_sectors(q) << 9); |
| 784 | 791 | ||
| 785 | if (q->backing_dev_info.ra_pages != b->backing_dev_info.ra_pages) { | 792 | if (q->backing_dev_info.ra_pages != b->backing_dev_info.ra_pages) { |
| 786 | dev_info(DEV, "Adjusting my ra_pages to backing device's (%lu -> %lu)\n", | 793 | dev_info(DEV, "Adjusting my ra_pages to backing device's (%lu -> %lu)\n", |
| @@ -850,7 +857,7 @@ static void drbd_suspend_al(struct drbd_conf *mdev) | |||
| 850 | static int drbd_nl_disk_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp, | 857 | static int drbd_nl_disk_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp, |
| 851 | struct drbd_nl_cfg_reply *reply) | 858 | struct drbd_nl_cfg_reply *reply) |
| 852 | { | 859 | { |
| 853 | enum drbd_ret_codes retcode; | 860 | enum drbd_ret_code retcode; |
| 854 | enum determine_dev_size dd; | 861 | enum determine_dev_size dd; |
| 855 | sector_t max_possible_sectors; | 862 | sector_t max_possible_sectors; |
| 856 | sector_t min_md_device_sectors; | 863 | sector_t min_md_device_sectors; |
| @@ -858,8 +865,8 @@ static int drbd_nl_disk_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp | |||
| 858 | struct block_device *bdev; | 865 | struct block_device *bdev; |
| 859 | struct lru_cache *resync_lru = NULL; | 866 | struct lru_cache *resync_lru = NULL; |
| 860 | union drbd_state ns, os; | 867 | union drbd_state ns, os; |
| 861 | unsigned int max_seg_s; | 868 | unsigned int max_bio_size; |
| 862 | int rv; | 869 | enum drbd_state_rv rv; |
| 863 | int cp_discovered = 0; | 870 | int cp_discovered = 0; |
| 864 | int logical_block_size; | 871 | int logical_block_size; |
| 865 | 872 | ||
| @@ -1005,9 +1012,10 @@ static int drbd_nl_disk_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp | |||
| 1005 | /* and for any other previously queued work */ | 1012 | /* and for any other previously queued work */ |
| 1006 | drbd_flush_workqueue(mdev); | 1013 | drbd_flush_workqueue(mdev); |
| 1007 | 1014 | ||
| 1008 | retcode = _drbd_request_state(mdev, NS(disk, D_ATTACHING), CS_VERBOSE); | 1015 | rv = _drbd_request_state(mdev, NS(disk, D_ATTACHING), CS_VERBOSE); |
| 1016 | retcode = rv; /* FIXME: Type mismatch. */ | ||
| 1009 | drbd_resume_io(mdev); | 1017 | drbd_resume_io(mdev); |
| 1010 | if (retcode < SS_SUCCESS) | 1018 | if (rv < SS_SUCCESS) |
| 1011 | goto fail; | 1019 | goto fail; |
| 1012 | 1020 | ||
| 1013 | if (!get_ldev_if_state(mdev, D_ATTACHING)) | 1021 | if (!get_ldev_if_state(mdev, D_ATTACHING)) |
| @@ -1109,20 +1117,20 @@ static int drbd_nl_disk_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp | |||
| 1109 | mdev->read_cnt = 0; | 1117 | mdev->read_cnt = 0; |
| 1110 | mdev->writ_cnt = 0; | 1118 | mdev->writ_cnt = 0; |
| 1111 | 1119 | ||
| 1112 | max_seg_s = DRBD_MAX_SEGMENT_SIZE; | 1120 | max_bio_size = DRBD_MAX_BIO_SIZE; |
| 1113 | if (mdev->state.conn == C_CONNECTED) { | 1121 | if (mdev->state.conn == C_CONNECTED) { |
| 1114 | /* We are Primary, Connected, and now attach a new local | 1122 | /* We are Primary, Connected, and now attach a new local |
| 1115 | * backing store. We must not increase the user visible maximum | 1123 | * backing store. We must not increase the user visible maximum |
| 1116 | * bio size on this device to something the peer may not be | 1124 | * bio size on this device to something the peer may not be |
| 1117 | * able to handle. */ | 1125 | * able to handle. */ |
| 1118 | if (mdev->agreed_pro_version < 94) | 1126 | if (mdev->agreed_pro_version < 94) |
| 1119 | max_seg_s = queue_max_segment_size(mdev->rq_queue); | 1127 | max_bio_size = queue_max_hw_sectors(mdev->rq_queue) << 9; |
| 1120 | else if (mdev->agreed_pro_version == 94) | 1128 | else if (mdev->agreed_pro_version == 94) |
| 1121 | max_seg_s = DRBD_MAX_SIZE_H80_PACKET; | 1129 | max_bio_size = DRBD_MAX_SIZE_H80_PACKET; |
| 1122 | /* else: drbd 8.3.9 and later, stay with default */ | 1130 | /* else: drbd 8.3.9 and later, stay with default */ |
| 1123 | } | 1131 | } |
| 1124 | 1132 | ||
| 1125 | drbd_setup_queue_param(mdev, max_seg_s); | 1133 | drbd_setup_queue_param(mdev, max_bio_size); |
| 1126 | 1134 | ||
| 1127 | /* If I am currently not R_PRIMARY, | 1135 | /* If I am currently not R_PRIMARY, |
| 1128 | * but meta data primary indicator is set, | 1136 | * but meta data primary indicator is set, |
| @@ -1154,12 +1162,14 @@ static int drbd_nl_disk_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp | |||
| 1154 | if (drbd_md_test_flag(mdev->ldev, MDF_FULL_SYNC)) { | 1162 | if (drbd_md_test_flag(mdev->ldev, MDF_FULL_SYNC)) { |
| 1155 | dev_info(DEV, "Assuming that all blocks are out of sync " | 1163 | dev_info(DEV, "Assuming that all blocks are out of sync " |
| 1156 | "(aka FullSync)\n"); | 1164 | "(aka FullSync)\n"); |
| 1157 | if (drbd_bitmap_io(mdev, &drbd_bmio_set_n_write, "set_n_write from attaching")) { | 1165 | if (drbd_bitmap_io(mdev, &drbd_bmio_set_n_write, |
| 1166 | "set_n_write from attaching", BM_LOCKED_MASK)) { | ||
| 1158 | retcode = ERR_IO_MD_DISK; | 1167 | retcode = ERR_IO_MD_DISK; |
| 1159 | goto force_diskless_dec; | 1168 | goto force_diskless_dec; |
| 1160 | } | 1169 | } |
| 1161 | } else { | 1170 | } else { |
| 1162 | if (drbd_bitmap_io(mdev, &drbd_bm_read, "read from attaching") < 0) { | 1171 | if (drbd_bitmap_io(mdev, &drbd_bm_read, |
| 1172 | "read from attaching", BM_LOCKED_MASK) < 0) { | ||
| 1163 | retcode = ERR_IO_MD_DISK; | 1173 | retcode = ERR_IO_MD_DISK; |
| 1164 | goto force_diskless_dec; | 1174 | goto force_diskless_dec; |
| 1165 | } | 1175 | } |
| @@ -1167,7 +1177,11 @@ static int drbd_nl_disk_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp | |||
| 1167 | 1177 | ||
| 1168 | if (cp_discovered) { | 1178 | if (cp_discovered) { |
| 1169 | drbd_al_apply_to_bm(mdev); | 1179 | drbd_al_apply_to_bm(mdev); |
| 1170 | drbd_al_to_on_disk_bm(mdev); | 1180 | if (drbd_bitmap_io(mdev, &drbd_bm_write, |
| 1181 | "crashed primary apply AL", BM_LOCKED_MASK)) { | ||
| 1182 | retcode = ERR_IO_MD_DISK; | ||
| 1183 | goto force_diskless_dec; | ||
| 1184 | } | ||
| 1171 | } | 1185 | } |
| 1172 | 1186 | ||
| 1173 | if (_drbd_bm_total_weight(mdev) == drbd_bm_bits(mdev)) | 1187 | if (_drbd_bm_total_weight(mdev) == drbd_bm_bits(mdev)) |
| @@ -1279,7 +1293,7 @@ static int drbd_nl_net_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp, | |||
| 1279 | struct drbd_nl_cfg_reply *reply) | 1293 | struct drbd_nl_cfg_reply *reply) |
| 1280 | { | 1294 | { |
| 1281 | int i, ns; | 1295 | int i, ns; |
| 1282 | enum drbd_ret_codes retcode; | 1296 | enum drbd_ret_code retcode; |
| 1283 | struct net_conf *new_conf = NULL; | 1297 | struct net_conf *new_conf = NULL; |
| 1284 | struct crypto_hash *tfm = NULL; | 1298 | struct crypto_hash *tfm = NULL; |
| 1285 | struct crypto_hash *integrity_w_tfm = NULL; | 1299 | struct crypto_hash *integrity_w_tfm = NULL; |
| @@ -1324,6 +1338,8 @@ static int drbd_nl_net_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp, | |||
| 1324 | new_conf->wire_protocol = DRBD_PROT_C; | 1338 | new_conf->wire_protocol = DRBD_PROT_C; |
| 1325 | new_conf->ping_timeo = DRBD_PING_TIMEO_DEF; | 1339 | new_conf->ping_timeo = DRBD_PING_TIMEO_DEF; |
| 1326 | new_conf->rr_conflict = DRBD_RR_CONFLICT_DEF; | 1340 | new_conf->rr_conflict = DRBD_RR_CONFLICT_DEF; |
| 1341 | new_conf->on_congestion = DRBD_ON_CONGESTION_DEF; | ||
| 1342 | new_conf->cong_extents = DRBD_CONG_EXTENTS_DEF; | ||
| 1327 | 1343 | ||
| 1328 | if (!net_conf_from_tags(mdev, nlp->tag_list, new_conf)) { | 1344 | if (!net_conf_from_tags(mdev, nlp->tag_list, new_conf)) { |
| 1329 | retcode = ERR_MANDATORY_TAG; | 1345 | retcode = ERR_MANDATORY_TAG; |
| @@ -1345,6 +1361,11 @@ static int drbd_nl_net_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp, | |||
| 1345 | } | 1361 | } |
| 1346 | } | 1362 | } |
| 1347 | 1363 | ||
| 1364 | if (new_conf->on_congestion != OC_BLOCK && new_conf->wire_protocol != DRBD_PROT_A) { | ||
| 1365 | retcode = ERR_CONG_NOT_PROTO_A; | ||
| 1366 | goto fail; | ||
| 1367 | } | ||
| 1368 | |||
| 1348 | if (mdev->state.role == R_PRIMARY && new_conf->want_lose) { | 1369 | if (mdev->state.role == R_PRIMARY && new_conf->want_lose) { |
| 1349 | retcode = ERR_DISCARD; | 1370 | retcode = ERR_DISCARD; |
| 1350 | goto fail; | 1371 | goto fail; |
| @@ -1525,6 +1546,21 @@ static int drbd_nl_disconnect(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nl | |||
| 1525 | struct drbd_nl_cfg_reply *reply) | 1546 | struct drbd_nl_cfg_reply *reply) |
| 1526 | { | 1547 | { |
| 1527 | int retcode; | 1548 | int retcode; |
| 1549 | struct disconnect dc; | ||
| 1550 | |||
| 1551 | memset(&dc, 0, sizeof(struct disconnect)); | ||
| 1552 | if (!disconnect_from_tags(mdev, nlp->tag_list, &dc)) { | ||
| 1553 | retcode = ERR_MANDATORY_TAG; | ||
| 1554 | goto fail; | ||
| 1555 | } | ||
| 1556 | |||
| 1557 | if (dc.force) { | ||
| 1558 | spin_lock_irq(&mdev->req_lock); | ||
| 1559 | if (mdev->state.conn >= C_WF_CONNECTION) | ||
| 1560 | _drbd_set_state(_NS(mdev, conn, C_DISCONNECTING), CS_HARD, NULL); | ||
| 1561 | spin_unlock_irq(&mdev->req_lock); | ||
| 1562 | goto done; | ||
| 1563 | } | ||
| 1528 | 1564 | ||
| 1529 | retcode = _drbd_request_state(mdev, NS(conn, C_DISCONNECTING), CS_ORDERED); | 1565 | retcode = _drbd_request_state(mdev, NS(conn, C_DISCONNECTING), CS_ORDERED); |
| 1530 | 1566 | ||
| @@ -1842,6 +1878,10 @@ static int drbd_nl_invalidate(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nl | |||
| 1842 | { | 1878 | { |
| 1843 | int retcode; | 1879 | int retcode; |
| 1844 | 1880 | ||
| 1881 | /* If there is still bitmap IO pending, probably because of a previous | ||
| 1882 | * resync just being finished, wait for it before requesting a new resync. */ | ||
| 1883 | wait_event(mdev->misc_wait, !test_bit(BITMAP_IO, &mdev->flags)); | ||
| 1884 | |||
| 1845 | retcode = _drbd_request_state(mdev, NS(conn, C_STARTING_SYNC_T), CS_ORDERED); | 1885 | retcode = _drbd_request_state(mdev, NS(conn, C_STARTING_SYNC_T), CS_ORDERED); |
| 1846 | 1886 | ||
| 1847 | if (retcode < SS_SUCCESS && retcode != SS_NEED_CONNECTION) | 1887 | if (retcode < SS_SUCCESS && retcode != SS_NEED_CONNECTION) |
| @@ -1877,6 +1917,10 @@ static int drbd_nl_invalidate_peer(struct drbd_conf *mdev, struct drbd_nl_cfg_re | |||
| 1877 | { | 1917 | { |
| 1878 | int retcode; | 1918 | int retcode; |
| 1879 | 1919 | ||
| 1920 | /* If there is still bitmap IO pending, probably because of a previous | ||
| 1921 | * resync just being finished, wait for it before requesting a new resync. */ | ||
| 1922 | wait_event(mdev->misc_wait, !test_bit(BITMAP_IO, &mdev->flags)); | ||
| 1923 | |||
| 1880 | retcode = _drbd_request_state(mdev, NS(conn, C_STARTING_SYNC_S), CS_ORDERED); | 1924 | retcode = _drbd_request_state(mdev, NS(conn, C_STARTING_SYNC_S), CS_ORDERED); |
| 1881 | 1925 | ||
| 1882 | if (retcode < SS_SUCCESS) { | 1926 | if (retcode < SS_SUCCESS) { |
| @@ -1885,9 +1929,9 @@ static int drbd_nl_invalidate_peer(struct drbd_conf *mdev, struct drbd_nl_cfg_re | |||
| 1885 | into a full resync. */ | 1929 | into a full resync. */ |
| 1886 | retcode = drbd_request_state(mdev, NS(pdsk, D_INCONSISTENT)); | 1930 | retcode = drbd_request_state(mdev, NS(pdsk, D_INCONSISTENT)); |
| 1887 | if (retcode >= SS_SUCCESS) { | 1931 | if (retcode >= SS_SUCCESS) { |
| 1888 | /* open coded drbd_bitmap_io() */ | ||
| 1889 | if (drbd_bitmap_io(mdev, &drbd_bmio_set_susp_al, | 1932 | if (drbd_bitmap_io(mdev, &drbd_bmio_set_susp_al, |
| 1890 | "set_n_write from invalidate_peer")) | 1933 | "set_n_write from invalidate_peer", |
| 1934 | BM_LOCKED_SET_ALLOWED)) | ||
| 1891 | retcode = ERR_IO_MD_DISK; | 1935 | retcode = ERR_IO_MD_DISK; |
| 1892 | } | 1936 | } |
| 1893 | } else | 1937 | } else |
| @@ -1914,9 +1958,17 @@ static int drbd_nl_resume_sync(struct drbd_conf *mdev, struct drbd_nl_cfg_req *n | |||
| 1914 | struct drbd_nl_cfg_reply *reply) | 1958 | struct drbd_nl_cfg_reply *reply) |
| 1915 | { | 1959 | { |
| 1916 | int retcode = NO_ERROR; | 1960 | int retcode = NO_ERROR; |
| 1961 | union drbd_state s; | ||
| 1917 | 1962 | ||
| 1918 | if (drbd_request_state(mdev, NS(user_isp, 0)) == SS_NOTHING_TO_DO) | 1963 | if (drbd_request_state(mdev, NS(user_isp, 0)) == SS_NOTHING_TO_DO) { |
| 1919 | retcode = ERR_PAUSE_IS_CLEAR; | 1964 | s = mdev->state; |
| 1965 | if (s.conn == C_PAUSED_SYNC_S || s.conn == C_PAUSED_SYNC_T) { | ||
| 1966 | retcode = s.aftr_isp ? ERR_PIC_AFTER_DEP : | ||
| 1967 | s.peer_isp ? ERR_PIC_PEER_DEP : ERR_PAUSE_IS_CLEAR; | ||
| 1968 | } else { | ||
| 1969 | retcode = ERR_PAUSE_IS_CLEAR; | ||
| 1970 | } | ||
| 1971 | } | ||
| 1920 | 1972 | ||
| 1921 | reply->ret_code = retcode; | 1973 | reply->ret_code = retcode; |
| 1922 | return 0; | 1974 | return 0; |
| @@ -2054,6 +2106,11 @@ static int drbd_nl_start_ov(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp, | |||
| 2054 | reply->ret_code = ERR_MANDATORY_TAG; | 2106 | reply->ret_code = ERR_MANDATORY_TAG; |
| 2055 | return 0; | 2107 | return 0; |
| 2056 | } | 2108 | } |
| 2109 | |||
| 2110 | /* If there is still bitmap IO pending, e.g. previous resync or verify | ||
| 2111 | * just being finished, wait for it before requesting a new resync. */ | ||
| 2112 | wait_event(mdev->misc_wait, !test_bit(BITMAP_IO, &mdev->flags)); | ||
| 2113 | |||
| 2057 | /* w_make_ov_request expects position to be aligned */ | 2114 | /* w_make_ov_request expects position to be aligned */ |
| 2058 | mdev->ov_start_sector = args.start_sector & ~BM_SECT_PER_BIT; | 2115 | mdev->ov_start_sector = args.start_sector & ~BM_SECT_PER_BIT; |
| 2059 | reply->ret_code = drbd_request_state(mdev,NS(conn,C_VERIFY_S)); | 2116 | reply->ret_code = drbd_request_state(mdev,NS(conn,C_VERIFY_S)); |
| @@ -2097,7 +2154,8 @@ static int drbd_nl_new_c_uuid(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nl | |||
| 2097 | drbd_uuid_new_current(mdev); /* New current, previous to UI_BITMAP */ | 2154 | drbd_uuid_new_current(mdev); /* New current, previous to UI_BITMAP */ |
| 2098 | 2155 | ||
| 2099 | if (args.clear_bm) { | 2156 | if (args.clear_bm) { |
| 2100 | err = drbd_bitmap_io(mdev, &drbd_bmio_clear_n_write, "clear_n_write from new_c_uuid"); | 2157 | err = drbd_bitmap_io(mdev, &drbd_bmio_clear_n_write, |
| 2158 | "clear_n_write from new_c_uuid", BM_LOCKED_MASK); | ||
| 2101 | if (err) { | 2159 | if (err) { |
| 2102 | dev_err(DEV, "Writing bitmap failed with %d\n",err); | 2160 | dev_err(DEV, "Writing bitmap failed with %d\n",err); |
| 2103 | retcode = ERR_IO_MD_DISK; | 2161 | retcode = ERR_IO_MD_DISK; |
| @@ -2105,6 +2163,7 @@ static int drbd_nl_new_c_uuid(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nl | |||
| 2105 | if (skip_initial_sync) { | 2163 | if (skip_initial_sync) { |
| 2106 | drbd_send_uuids_skip_initial_sync(mdev); | 2164 | drbd_send_uuids_skip_initial_sync(mdev); |
| 2107 | _drbd_uuid_set(mdev, UI_BITMAP, 0); | 2165 | _drbd_uuid_set(mdev, UI_BITMAP, 0); |
| 2166 | drbd_print_uuids(mdev, "cleared bitmap UUID"); | ||
| 2108 | spin_lock_irq(&mdev->req_lock); | 2167 | spin_lock_irq(&mdev->req_lock); |
| 2109 | _drbd_set_state(_NS2(mdev, disk, D_UP_TO_DATE, pdsk, D_UP_TO_DATE), | 2168 | _drbd_set_state(_NS2(mdev, disk, D_UP_TO_DATE, pdsk, D_UP_TO_DATE), |
| 2110 | CS_VERBOSE, NULL); | 2169 | CS_VERBOSE, NULL); |
| @@ -2189,7 +2248,8 @@ static void drbd_connector_callback(struct cn_msg *req, struct netlink_skb_parms | |||
| 2189 | goto fail; | 2248 | goto fail; |
| 2190 | } | 2249 | } |
| 2191 | 2250 | ||
| 2192 | if (nlp->packet_type >= P_nl_after_last_packet) { | 2251 | if (nlp->packet_type >= P_nl_after_last_packet || |
| 2252 | nlp->packet_type == P_return_code_only) { | ||
| 2193 | retcode = ERR_PACKET_NR; | 2253 | retcode = ERR_PACKET_NR; |
| 2194 | goto fail; | 2254 | goto fail; |
| 2195 | } | 2255 | } |
| @@ -2205,7 +2265,7 @@ static void drbd_connector_callback(struct cn_msg *req, struct netlink_skb_parms | |||
| 2205 | reply_size += cm->reply_body_size; | 2265 | reply_size += cm->reply_body_size; |
| 2206 | 2266 | ||
| 2207 | /* allocation not in the IO path, cqueue thread context */ | 2267 | /* allocation not in the IO path, cqueue thread context */ |
| 2208 | cn_reply = kmalloc(reply_size, GFP_KERNEL); | 2268 | cn_reply = kzalloc(reply_size, GFP_KERNEL); |
| 2209 | if (!cn_reply) { | 2269 | if (!cn_reply) { |
| 2210 | retcode = ERR_NOMEM; | 2270 | retcode = ERR_NOMEM; |
| 2211 | goto fail; | 2271 | goto fail; |
| @@ -2213,7 +2273,7 @@ static void drbd_connector_callback(struct cn_msg *req, struct netlink_skb_parms | |||
| 2213 | reply = (struct drbd_nl_cfg_reply *) cn_reply->data; | 2273 | reply = (struct drbd_nl_cfg_reply *) cn_reply->data; |
| 2214 | 2274 | ||
| 2215 | reply->packet_type = | 2275 | reply->packet_type = |
| 2216 | cm->reply_body_size ? nlp->packet_type : P_nl_after_last_packet; | 2276 | cm->reply_body_size ? nlp->packet_type : P_return_code_only; |
| 2217 | reply->minor = nlp->drbd_minor; | 2277 | reply->minor = nlp->drbd_minor; |
| 2218 | reply->ret_code = NO_ERROR; /* Might by modified by cm->function. */ | 2278 | reply->ret_code = NO_ERROR; /* Might by modified by cm->function. */ |
| 2219 | /* reply->tag_list; might be modified by cm->function. */ | 2279 | /* reply->tag_list; might be modified by cm->function. */ |
| @@ -2376,7 +2436,7 @@ void drbd_bcast_ee(struct drbd_conf *mdev, | |||
| 2376 | /* receiver thread context, which is not in the writeout path (of this node), | 2436 | /* receiver thread context, which is not in the writeout path (of this node), |
| 2377 | * but may be in the writeout path of the _other_ node. | 2437 | * but may be in the writeout path of the _other_ node. |
| 2378 | * GFP_NOIO to avoid potential "distributed deadlock". */ | 2438 | * GFP_NOIO to avoid potential "distributed deadlock". */ |
| 2379 | cn_reply = kmalloc( | 2439 | cn_reply = kzalloc( |
| 2380 | sizeof(struct cn_msg)+ | 2440 | sizeof(struct cn_msg)+ |
| 2381 | sizeof(struct drbd_nl_cfg_reply)+ | 2441 | sizeof(struct drbd_nl_cfg_reply)+ |
| 2382 | sizeof(struct dump_ee_tag_len_struct)+ | 2442 | sizeof(struct dump_ee_tag_len_struct)+ |
| @@ -2398,10 +2458,11 @@ void drbd_bcast_ee(struct drbd_conf *mdev, | |||
| 2398 | tl = tl_add_int(tl, T_ee_sector, &e->sector); | 2458 | tl = tl_add_int(tl, T_ee_sector, &e->sector); |
| 2399 | tl = tl_add_int(tl, T_ee_block_id, &e->block_id); | 2459 | tl = tl_add_int(tl, T_ee_block_id, &e->block_id); |
| 2400 | 2460 | ||
| 2461 | /* dump the first 32k */ | ||
| 2462 | len = min_t(unsigned, e->size, 32 << 10); | ||
| 2401 | put_unaligned(T_ee_data, tl++); | 2463 | put_unaligned(T_ee_data, tl++); |
| 2402 | put_unaligned(e->size, tl++); | 2464 | put_unaligned(len, tl++); |
| 2403 | 2465 | ||
| 2404 | len = e->size; | ||
| 2405 | page = e->pages; | 2466 | page = e->pages; |
| 2406 | page_chain_for_each(page) { | 2467 | page_chain_for_each(page) { |
| 2407 | void *d = kmap_atomic(page, KM_USER0); | 2468 | void *d = kmap_atomic(page, KM_USER0); |
| @@ -2410,6 +2471,8 @@ void drbd_bcast_ee(struct drbd_conf *mdev, | |||
| 2410 | kunmap_atomic(d, KM_USER0); | 2471 | kunmap_atomic(d, KM_USER0); |
| 2411 | tl = (unsigned short*)((char*)tl + l); | 2472 | tl = (unsigned short*)((char*)tl + l); |
| 2412 | len -= l; | 2473 | len -= l; |
| 2474 | if (len == 0) | ||
| 2475 | break; | ||
| 2413 | } | 2476 | } |
| 2414 | put_unaligned(TT_END, tl++); /* Close the tag list */ | 2477 | put_unaligned(TT_END, tl++); /* Close the tag list */ |
| 2415 | 2478 | ||
| @@ -2508,6 +2571,7 @@ void drbd_nl_send_reply(struct cn_msg *req, int ret_code) | |||
| 2508 | (struct drbd_nl_cfg_reply *)cn_reply->data; | 2571 | (struct drbd_nl_cfg_reply *)cn_reply->data; |
| 2509 | int rr; | 2572 | int rr; |
| 2510 | 2573 | ||
| 2574 | memset(buffer, 0, sizeof(buffer)); | ||
| 2511 | cn_reply->id = req->id; | 2575 | cn_reply->id = req->id; |
| 2512 | 2576 | ||
| 2513 | cn_reply->seq = req->seq; | 2577 | cn_reply->seq = req->seq; |
| @@ -2515,6 +2579,7 @@ void drbd_nl_send_reply(struct cn_msg *req, int ret_code) | |||
| 2515 | cn_reply->len = sizeof(struct drbd_nl_cfg_reply); | 2579 | cn_reply->len = sizeof(struct drbd_nl_cfg_reply); |
| 2516 | cn_reply->flags = 0; | 2580 | cn_reply->flags = 0; |
| 2517 | 2581 | ||
| 2582 | reply->packet_type = P_return_code_only; | ||
| 2518 | reply->minor = ((struct drbd_nl_cfg_req *)req->data)->drbd_minor; | 2583 | reply->minor = ((struct drbd_nl_cfg_req *)req->data)->drbd_minor; |
| 2519 | reply->ret_code = ret_code; | 2584 | reply->ret_code = ret_code; |
| 2520 | 2585 | ||
diff --git a/drivers/block/drbd/drbd_proc.c b/drivers/block/drbd/drbd_proc.c index 7e6ac307e2d..2959cdfb77f 100644 --- a/drivers/block/drbd/drbd_proc.c +++ b/drivers/block/drbd/drbd_proc.c | |||
| @@ -34,6 +34,7 @@ | |||
| 34 | #include "drbd_int.h" | 34 | #include "drbd_int.h" |
| 35 | 35 | ||
| 36 | static int drbd_proc_open(struct inode *inode, struct file *file); | 36 | static int drbd_proc_open(struct inode *inode, struct file *file); |
| 37 | static int drbd_proc_release(struct inode *inode, struct file *file); | ||
| 37 | 38 | ||
| 38 | 39 | ||
| 39 | struct proc_dir_entry *drbd_proc; | 40 | struct proc_dir_entry *drbd_proc; |
| @@ -42,9 +43,22 @@ const struct file_operations drbd_proc_fops = { | |||
| 42 | .open = drbd_proc_open, | 43 | .open = drbd_proc_open, |
| 43 | .read = seq_read, | 44 | .read = seq_read, |
| 44 | .llseek = seq_lseek, | 45 | .llseek = seq_lseek, |
| 45 | .release = single_release, | 46 | .release = drbd_proc_release, |
| 46 | }; | 47 | }; |
| 47 | 48 | ||
| 49 | void seq_printf_with_thousands_grouping(struct seq_file *seq, long v) | ||
| 50 | { | ||
| 51 | /* v is in kB/sec. We don't expect TiByte/sec yet. */ | ||
| 52 | if (unlikely(v >= 1000000)) { | ||
| 53 | /* cool: > GiByte/s */ | ||
| 54 | seq_printf(seq, "%ld,", v / 1000000); | ||
| 55 | v /= 1000000; | ||
| 56 | seq_printf(seq, "%03ld,%03ld", v/1000, v % 1000); | ||
| 57 | } else if (likely(v >= 1000)) | ||
| 58 | seq_printf(seq, "%ld,%03ld", v/1000, v % 1000); | ||
| 59 | else | ||
| 60 | seq_printf(seq, "%ld", v); | ||
| 61 | } | ||
| 48 | 62 | ||
| 49 | /*lge | 63 | /*lge |
| 50 | * progress bars shamelessly adapted from driver/md/md.c | 64 | * progress bars shamelessly adapted from driver/md/md.c |
| @@ -71,10 +85,15 @@ static void drbd_syncer_progress(struct drbd_conf *mdev, struct seq_file *seq) | |||
| 71 | seq_printf(seq, "."); | 85 | seq_printf(seq, "."); |
| 72 | seq_printf(seq, "] "); | 86 | seq_printf(seq, "] "); |
| 73 | 87 | ||
| 74 | seq_printf(seq, "sync'ed:%3u.%u%% ", res / 10, res % 10); | 88 | if (mdev->state.conn == C_VERIFY_S || mdev->state.conn == C_VERIFY_T) |
| 75 | /* if more than 1 GB display in MB */ | 89 | seq_printf(seq, "verified:"); |
| 76 | if (mdev->rs_total > 0x100000L) | 90 | else |
| 77 | seq_printf(seq, "(%lu/%lu)M\n\t", | 91 | seq_printf(seq, "sync'ed:"); |
| 92 | seq_printf(seq, "%3u.%u%% ", res / 10, res % 10); | ||
| 93 | |||
| 94 | /* if more than a few GB, display in MB */ | ||
| 95 | if (mdev->rs_total > (4UL << (30 - BM_BLOCK_SHIFT))) | ||
| 96 | seq_printf(seq, "(%lu/%lu)M", | ||
| 78 | (unsigned long) Bit2KB(rs_left >> 10), | 97 | (unsigned long) Bit2KB(rs_left >> 10), |
| 79 | (unsigned long) Bit2KB(mdev->rs_total >> 10)); | 98 | (unsigned long) Bit2KB(mdev->rs_total >> 10)); |
| 80 | else | 99 | else |
| @@ -94,6 +113,7 @@ static void drbd_syncer_progress(struct drbd_conf *mdev, struct seq_file *seq) | |||
| 94 | /* Rolling marks. last_mark+1 may just now be modified. last_mark+2 is | 113 | /* Rolling marks. last_mark+1 may just now be modified. last_mark+2 is |
| 95 | * at least (DRBD_SYNC_MARKS-2)*DRBD_SYNC_MARK_STEP old, and has at | 114 | * at least (DRBD_SYNC_MARKS-2)*DRBD_SYNC_MARK_STEP old, and has at |
| 96 | * least DRBD_SYNC_MARK_STEP time before it will be modified. */ | 115 | * least DRBD_SYNC_MARK_STEP time before it will be modified. */ |
| 116 | /* ------------------------ ~18s average ------------------------ */ | ||
| 97 | i = (mdev->rs_last_mark + 2) % DRBD_SYNC_MARKS; | 117 | i = (mdev->rs_last_mark + 2) % DRBD_SYNC_MARKS; |
| 98 | dt = (jiffies - mdev->rs_mark_time[i]) / HZ; | 118 | dt = (jiffies - mdev->rs_mark_time[i]) / HZ; |
| 99 | if (dt > (DRBD_SYNC_MARK_STEP * DRBD_SYNC_MARKS)) | 119 | if (dt > (DRBD_SYNC_MARK_STEP * DRBD_SYNC_MARKS)) |
| @@ -107,14 +127,24 @@ static void drbd_syncer_progress(struct drbd_conf *mdev, struct seq_file *seq) | |||
| 107 | seq_printf(seq, "finish: %lu:%02lu:%02lu", | 127 | seq_printf(seq, "finish: %lu:%02lu:%02lu", |
| 108 | rt / 3600, (rt % 3600) / 60, rt % 60); | 128 | rt / 3600, (rt % 3600) / 60, rt % 60); |
| 109 | 129 | ||
| 110 | /* current speed average over (SYNC_MARKS * SYNC_MARK_STEP) jiffies */ | ||
| 111 | dbdt = Bit2KB(db/dt); | 130 | dbdt = Bit2KB(db/dt); |
| 112 | if (dbdt > 1000) | 131 | seq_printf(seq, " speed: "); |
| 113 | seq_printf(seq, " speed: %ld,%03ld", | 132 | seq_printf_with_thousands_grouping(seq, dbdt); |
| 114 | dbdt/1000, dbdt % 1000); | 133 | seq_printf(seq, " ("); |
| 115 | else | 134 | /* ------------------------- ~3s average ------------------------ */ |
| 116 | seq_printf(seq, " speed: %ld", dbdt); | 135 | if (proc_details >= 1) { |
| 136 | /* this is what drbd_rs_should_slow_down() uses */ | ||
| 137 | i = (mdev->rs_last_mark + DRBD_SYNC_MARKS-1) % DRBD_SYNC_MARKS; | ||
| 138 | dt = (jiffies - mdev->rs_mark_time[i]) / HZ; | ||
| 139 | if (!dt) | ||
| 140 | dt++; | ||
| 141 | db = mdev->rs_mark_left[i] - rs_left; | ||
| 142 | dbdt = Bit2KB(db/dt); | ||
| 143 | seq_printf_with_thousands_grouping(seq, dbdt); | ||
| 144 | seq_printf(seq, " -- "); | ||
| 145 | } | ||
| 117 | 146 | ||
| 147 | /* --------------------- long term average ---------------------- */ | ||
| 118 | /* mean speed since syncer started | 148 | /* mean speed since syncer started |
| 119 | * we do account for PausedSync periods */ | 149 | * we do account for PausedSync periods */ |
| 120 | dt = (jiffies - mdev->rs_start - mdev->rs_paused) / HZ; | 150 | dt = (jiffies - mdev->rs_start - mdev->rs_paused) / HZ; |
| @@ -122,20 +152,34 @@ static void drbd_syncer_progress(struct drbd_conf *mdev, struct seq_file *seq) | |||
| 122 | dt = 1; | 152 | dt = 1; |
| 123 | db = mdev->rs_total - rs_left; | 153 | db = mdev->rs_total - rs_left; |
| 124 | dbdt = Bit2KB(db/dt); | 154 | dbdt = Bit2KB(db/dt); |
| 125 | if (dbdt > 1000) | 155 | seq_printf_with_thousands_grouping(seq, dbdt); |
| 126 | seq_printf(seq, " (%ld,%03ld)", | 156 | seq_printf(seq, ")"); |
| 127 | dbdt/1000, dbdt % 1000); | ||
| 128 | else | ||
| 129 | seq_printf(seq, " (%ld)", dbdt); | ||
| 130 | 157 | ||
| 131 | if (mdev->state.conn == C_SYNC_TARGET) { | 158 | if (mdev->state.conn == C_SYNC_TARGET || |
| 132 | if (mdev->c_sync_rate > 1000) | 159 | mdev->state.conn == C_VERIFY_S) { |
| 133 | seq_printf(seq, " want: %d,%03d", | 160 | seq_printf(seq, " want: "); |
| 134 | mdev->c_sync_rate / 1000, mdev->c_sync_rate % 1000); | 161 | seq_printf_with_thousands_grouping(seq, mdev->c_sync_rate); |
| 135 | else | ||
| 136 | seq_printf(seq, " want: %d", mdev->c_sync_rate); | ||
| 137 | } | 162 | } |
| 138 | seq_printf(seq, " K/sec%s\n", stalled ? " (stalled)" : ""); | 163 | seq_printf(seq, " K/sec%s\n", stalled ? " (stalled)" : ""); |
| 164 | |||
| 165 | if (proc_details >= 1) { | ||
| 166 | /* 64 bit: | ||
| 167 | * we convert to sectors in the display below. */ | ||
| 168 | unsigned long bm_bits = drbd_bm_bits(mdev); | ||
| 169 | unsigned long bit_pos; | ||
| 170 | if (mdev->state.conn == C_VERIFY_S || | ||
| 171 | mdev->state.conn == C_VERIFY_T) | ||
| 172 | bit_pos = bm_bits - mdev->ov_left; | ||
| 173 | else | ||
| 174 | bit_pos = mdev->bm_resync_fo; | ||
| 175 | /* Total sectors may be slightly off for oddly | ||
| 176 | * sized devices. So what. */ | ||
| 177 | seq_printf(seq, | ||
| 178 | "\t%3d%% sector pos: %llu/%llu\n", | ||
| 179 | (int)(bit_pos / (bm_bits/100+1)), | ||
| 180 | (unsigned long long)bit_pos * BM_SECT_PER_BIT, | ||
| 181 | (unsigned long long)bm_bits * BM_SECT_PER_BIT); | ||
| 182 | } | ||
| 139 | } | 183 | } |
| 140 | 184 | ||
| 141 | static void resync_dump_detail(struct seq_file *seq, struct lc_element *e) | 185 | static void resync_dump_detail(struct seq_file *seq, struct lc_element *e) |
| @@ -232,20 +276,16 @@ static int drbd_seq_show(struct seq_file *seq, void *v) | |||
| 232 | mdev->epochs, | 276 | mdev->epochs, |
| 233 | write_ordering_chars[mdev->write_ordering] | 277 | write_ordering_chars[mdev->write_ordering] |
| 234 | ); | 278 | ); |
| 235 | seq_printf(seq, " oos:%lu\n", | 279 | seq_printf(seq, " oos:%llu\n", |
| 236 | Bit2KB(drbd_bm_total_weight(mdev))); | 280 | Bit2KB((unsigned long long) |
| 281 | drbd_bm_total_weight(mdev))); | ||
| 237 | } | 282 | } |
| 238 | if (mdev->state.conn == C_SYNC_SOURCE || | 283 | if (mdev->state.conn == C_SYNC_SOURCE || |
| 239 | mdev->state.conn == C_SYNC_TARGET) | 284 | mdev->state.conn == C_SYNC_TARGET || |
| 285 | mdev->state.conn == C_VERIFY_S || | ||
| 286 | mdev->state.conn == C_VERIFY_T) | ||
| 240 | drbd_syncer_progress(mdev, seq); | 287 | drbd_syncer_progress(mdev, seq); |
| 241 | 288 | ||
| 242 | if (mdev->state.conn == C_VERIFY_S || mdev->state.conn == C_VERIFY_T) | ||
| 243 | seq_printf(seq, "\t%3d%% %lu/%lu\n", | ||
| 244 | (int)((mdev->rs_total-mdev->ov_left) / | ||
| 245 | (mdev->rs_total/100+1)), | ||
| 246 | mdev->rs_total - mdev->ov_left, | ||
| 247 | mdev->rs_total); | ||
| 248 | |||
| 249 | if (proc_details >= 1 && get_ldev_if_state(mdev, D_FAILED)) { | 289 | if (proc_details >= 1 && get_ldev_if_state(mdev, D_FAILED)) { |
| 250 | lc_seq_printf_stats(seq, mdev->resync); | 290 | lc_seq_printf_stats(seq, mdev->resync); |
| 251 | lc_seq_printf_stats(seq, mdev->act_log); | 291 | lc_seq_printf_stats(seq, mdev->act_log); |
| @@ -265,7 +305,15 @@ static int drbd_seq_show(struct seq_file *seq, void *v) | |||
| 265 | 305 | ||
| 266 | static int drbd_proc_open(struct inode *inode, struct file *file) | 306 | static int drbd_proc_open(struct inode *inode, struct file *file) |
| 267 | { | 307 | { |
| 268 | return single_open(file, drbd_seq_show, PDE(inode)->data); | 308 | if (try_module_get(THIS_MODULE)) |
| 309 | return single_open(file, drbd_seq_show, PDE(inode)->data); | ||
| 310 | return -ENODEV; | ||
| 311 | } | ||
| 312 | |||
| 313 | static int drbd_proc_release(struct inode *inode, struct file *file) | ||
| 314 | { | ||
| 315 | module_put(THIS_MODULE); | ||
| 316 | return single_release(inode, file); | ||
| 269 | } | 317 | } |
| 270 | 318 | ||
| 271 | /* PROC FS stuff end */ | 319 | /* PROC FS stuff end */ |
diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c index 8e68be939de..fe1564c7d8b 100644 --- a/drivers/block/drbd/drbd_receiver.c +++ b/drivers/block/drbd/drbd_receiver.c | |||
| @@ -277,7 +277,7 @@ static void drbd_pp_free(struct drbd_conf *mdev, struct page *page, int is_net) | |||
| 277 | atomic_t *a = is_net ? &mdev->pp_in_use_by_net : &mdev->pp_in_use; | 277 | atomic_t *a = is_net ? &mdev->pp_in_use_by_net : &mdev->pp_in_use; |
| 278 | int i; | 278 | int i; |
| 279 | 279 | ||
| 280 | if (drbd_pp_vacant > (DRBD_MAX_SEGMENT_SIZE/PAGE_SIZE)*minor_count) | 280 | if (drbd_pp_vacant > (DRBD_MAX_BIO_SIZE/PAGE_SIZE)*minor_count) |
| 281 | i = page_chain_free(page); | 281 | i = page_chain_free(page); |
| 282 | else { | 282 | else { |
| 283 | struct page *tmp; | 283 | struct page *tmp; |
| @@ -319,7 +319,7 @@ struct drbd_epoch_entry *drbd_alloc_ee(struct drbd_conf *mdev, | |||
| 319 | struct page *page; | 319 | struct page *page; |
| 320 | unsigned nr_pages = (data_size + PAGE_SIZE -1) >> PAGE_SHIFT; | 320 | unsigned nr_pages = (data_size + PAGE_SIZE -1) >> PAGE_SHIFT; |
| 321 | 321 | ||
| 322 | if (FAULT_ACTIVE(mdev, DRBD_FAULT_AL_EE)) | 322 | if (drbd_insert_fault(mdev, DRBD_FAULT_AL_EE)) |
| 323 | return NULL; | 323 | return NULL; |
| 324 | 324 | ||
| 325 | e = mempool_alloc(drbd_ee_mempool, gfp_mask & ~__GFP_HIGHMEM); | 325 | e = mempool_alloc(drbd_ee_mempool, gfp_mask & ~__GFP_HIGHMEM); |
| @@ -725,16 +725,16 @@ static int drbd_socket_okay(struct drbd_conf *mdev, struct socket **sock) | |||
| 725 | char tb[4]; | 725 | char tb[4]; |
| 726 | 726 | ||
| 727 | if (!*sock) | 727 | if (!*sock) |
| 728 | return FALSE; | 728 | return false; |
| 729 | 729 | ||
| 730 | rr = drbd_recv_short(mdev, *sock, tb, 4, MSG_DONTWAIT | MSG_PEEK); | 730 | rr = drbd_recv_short(mdev, *sock, tb, 4, MSG_DONTWAIT | MSG_PEEK); |
| 731 | 731 | ||
| 732 | if (rr > 0 || rr == -EAGAIN) { | 732 | if (rr > 0 || rr == -EAGAIN) { |
| 733 | return TRUE; | 733 | return true; |
| 734 | } else { | 734 | } else { |
| 735 | sock_release(*sock); | 735 | sock_release(*sock); |
| 736 | *sock = NULL; | 736 | *sock = NULL; |
| 737 | return FALSE; | 737 | return false; |
| 738 | } | 738 | } |
| 739 | } | 739 | } |
| 740 | 740 | ||
| @@ -768,8 +768,7 @@ static int drbd_connect(struct drbd_conf *mdev) | |||
| 768 | if (s || ++try >= 3) | 768 | if (s || ++try >= 3) |
| 769 | break; | 769 | break; |
| 770 | /* give the other side time to call bind() & listen() */ | 770 | /* give the other side time to call bind() & listen() */ |
| 771 | __set_current_state(TASK_INTERRUPTIBLE); | 771 | schedule_timeout_interruptible(HZ / 10); |
| 772 | schedule_timeout(HZ / 10); | ||
| 773 | } | 772 | } |
| 774 | 773 | ||
| 775 | if (s) { | 774 | if (s) { |
| @@ -788,8 +787,7 @@ static int drbd_connect(struct drbd_conf *mdev) | |||
| 788 | } | 787 | } |
| 789 | 788 | ||
| 790 | if (sock && msock) { | 789 | if (sock && msock) { |
| 791 | __set_current_state(TASK_INTERRUPTIBLE); | 790 | schedule_timeout_interruptible(HZ / 10); |
| 792 | schedule_timeout(HZ / 10); | ||
| 793 | ok = drbd_socket_okay(mdev, &sock); | 791 | ok = drbd_socket_okay(mdev, &sock); |
| 794 | ok = drbd_socket_okay(mdev, &msock) && ok; | 792 | ok = drbd_socket_okay(mdev, &msock) && ok; |
| 795 | if (ok) | 793 | if (ok) |
| @@ -906,7 +904,7 @@ retry: | |||
| 906 | put_ldev(mdev); | 904 | put_ldev(mdev); |
| 907 | } | 905 | } |
| 908 | 906 | ||
| 909 | if (!drbd_send_protocol(mdev)) | 907 | if (drbd_send_protocol(mdev) == -1) |
| 910 | return -1; | 908 | return -1; |
| 911 | drbd_send_sync_param(mdev, &mdev->sync_conf); | 909 | drbd_send_sync_param(mdev, &mdev->sync_conf); |
| 912 | drbd_send_sizes(mdev, 0, 0); | 910 | drbd_send_sizes(mdev, 0, 0); |
| @@ -914,6 +912,7 @@ retry: | |||
| 914 | drbd_send_state(mdev); | 912 | drbd_send_state(mdev); |
| 915 | clear_bit(USE_DEGR_WFC_T, &mdev->flags); | 913 | clear_bit(USE_DEGR_WFC_T, &mdev->flags); |
| 916 | clear_bit(RESIZE_PENDING, &mdev->flags); | 914 | clear_bit(RESIZE_PENDING, &mdev->flags); |
| 915 | mod_timer(&mdev->request_timer, jiffies + HZ); /* just start it here. */ | ||
| 917 | 916 | ||
| 918 | return 1; | 917 | return 1; |
| 919 | 918 | ||
| @@ -932,8 +931,9 @@ static int drbd_recv_header(struct drbd_conf *mdev, enum drbd_packets *cmd, unsi | |||
| 932 | 931 | ||
| 933 | r = drbd_recv(mdev, h, sizeof(*h)); | 932 | r = drbd_recv(mdev, h, sizeof(*h)); |
| 934 | if (unlikely(r != sizeof(*h))) { | 933 | if (unlikely(r != sizeof(*h))) { |
| 935 | dev_err(DEV, "short read expecting header on sock: r=%d\n", r); | 934 | if (!signal_pending(current)) |
| 936 | return FALSE; | 935 | dev_warn(DEV, "short read expecting header on sock: r=%d\n", r); |
| 936 | return false; | ||
| 937 | } | 937 | } |
| 938 | 938 | ||
| 939 | if (likely(h->h80.magic == BE_DRBD_MAGIC)) { | 939 | if (likely(h->h80.magic == BE_DRBD_MAGIC)) { |
| @@ -947,11 +947,11 @@ static int drbd_recv_header(struct drbd_conf *mdev, enum drbd_packets *cmd, unsi | |||
| 947 | be32_to_cpu(h->h80.magic), | 947 | be32_to_cpu(h->h80.magic), |
| 948 | be16_to_cpu(h->h80.command), | 948 | be16_to_cpu(h->h80.command), |
| 949 | be16_to_cpu(h->h80.length)); | 949 | be16_to_cpu(h->h80.length)); |
| 950 | return FALSE; | 950 | return false; |
| 951 | } | 951 | } |
| 952 | mdev->last_received = jiffies; | 952 | mdev->last_received = jiffies; |
| 953 | 953 | ||
| 954 | return TRUE; | 954 | return true; |
| 955 | } | 955 | } |
| 956 | 956 | ||
| 957 | static void drbd_flush(struct drbd_conf *mdev) | 957 | static void drbd_flush(struct drbd_conf *mdev) |
| @@ -1074,6 +1074,16 @@ void drbd_bump_write_ordering(struct drbd_conf *mdev, enum write_ordering_e wo) | |||
| 1074 | * @mdev: DRBD device. | 1074 | * @mdev: DRBD device. |
| 1075 | * @e: epoch entry | 1075 | * @e: epoch entry |
| 1076 | * @rw: flag field, see bio->bi_rw | 1076 | * @rw: flag field, see bio->bi_rw |
| 1077 | * | ||
| 1078 | * May spread the pages to multiple bios, | ||
| 1079 | * depending on bio_add_page restrictions. | ||
| 1080 | * | ||
| 1081 | * Returns 0 if all bios have been submitted, | ||
| 1082 | * -ENOMEM if we could not allocate enough bios, | ||
| 1083 | * -ENOSPC (any better suggestion?) if we have not been able to bio_add_page a | ||
| 1084 | * single page to an empty bio (which should never happen and likely indicates | ||
| 1085 | * that the lower level IO stack is in some way broken). This has been observed | ||
| 1086 | * on certain Xen deployments. | ||
| 1077 | */ | 1087 | */ |
| 1078 | /* TODO allocate from our own bio_set. */ | 1088 | /* TODO allocate from our own bio_set. */ |
| 1079 | int drbd_submit_ee(struct drbd_conf *mdev, struct drbd_epoch_entry *e, | 1089 | int drbd_submit_ee(struct drbd_conf *mdev, struct drbd_epoch_entry *e, |
| @@ -1086,6 +1096,7 @@ int drbd_submit_ee(struct drbd_conf *mdev, struct drbd_epoch_entry *e, | |||
| 1086 | unsigned ds = e->size; | 1096 | unsigned ds = e->size; |
| 1087 | unsigned n_bios = 0; | 1097 | unsigned n_bios = 0; |
| 1088 | unsigned nr_pages = (ds + PAGE_SIZE -1) >> PAGE_SHIFT; | 1098 | unsigned nr_pages = (ds + PAGE_SIZE -1) >> PAGE_SHIFT; |
| 1099 | int err = -ENOMEM; | ||
| 1089 | 1100 | ||
| 1090 | /* In most cases, we will only need one bio. But in case the lower | 1101 | /* In most cases, we will only need one bio. But in case the lower |
| 1091 | * level restrictions happen to be different at this offset on this | 1102 | * level restrictions happen to be different at this offset on this |
| @@ -1111,8 +1122,17 @@ next_bio: | |||
| 1111 | page_chain_for_each(page) { | 1122 | page_chain_for_each(page) { |
| 1112 | unsigned len = min_t(unsigned, ds, PAGE_SIZE); | 1123 | unsigned len = min_t(unsigned, ds, PAGE_SIZE); |
| 1113 | if (!bio_add_page(bio, page, len, 0)) { | 1124 | if (!bio_add_page(bio, page, len, 0)) { |
| 1114 | /* a single page must always be possible! */ | 1125 | /* A single page must always be possible! |
| 1115 | BUG_ON(bio->bi_vcnt == 0); | 1126 | * But in case it fails anyways, |
| 1127 | * we deal with it, and complain (below). */ | ||
| 1128 | if (bio->bi_vcnt == 0) { | ||
| 1129 | dev_err(DEV, | ||
| 1130 | "bio_add_page failed for len=%u, " | ||
| 1131 | "bi_vcnt=0 (bi_sector=%llu)\n", | ||
| 1132 | len, (unsigned long long)bio->bi_sector); | ||
| 1133 | err = -ENOSPC; | ||
| 1134 | goto fail; | ||
| 1135 | } | ||
| 1116 | goto next_bio; | 1136 | goto next_bio; |
| 1117 | } | 1137 | } |
| 1118 | ds -= len; | 1138 | ds -= len; |
| @@ -1138,7 +1158,7 @@ fail: | |||
| 1138 | bios = bios->bi_next; | 1158 | bios = bios->bi_next; |
| 1139 | bio_put(bio); | 1159 | bio_put(bio); |
| 1140 | } | 1160 | } |
| 1141 | return -ENOMEM; | 1161 | return err; |
| 1142 | } | 1162 | } |
| 1143 | 1163 | ||
| 1144 | static int receive_Barrier(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned int data_size) | 1164 | static int receive_Barrier(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned int data_size) |
| @@ -1160,7 +1180,7 @@ static int receive_Barrier(struct drbd_conf *mdev, enum drbd_packets cmd, unsign | |||
| 1160 | switch (mdev->write_ordering) { | 1180 | switch (mdev->write_ordering) { |
| 1161 | case WO_none: | 1181 | case WO_none: |
| 1162 | if (rv == FE_RECYCLED) | 1182 | if (rv == FE_RECYCLED) |
| 1163 | return TRUE; | 1183 | return true; |
| 1164 | 1184 | ||
| 1165 | /* receiver context, in the writeout path of the other node. | 1185 | /* receiver context, in the writeout path of the other node. |
| 1166 | * avoid potential distributed deadlock */ | 1186 | * avoid potential distributed deadlock */ |
| @@ -1188,10 +1208,10 @@ static int receive_Barrier(struct drbd_conf *mdev, enum drbd_packets cmd, unsign | |||
| 1188 | D_ASSERT(atomic_read(&epoch->active) == 0); | 1208 | D_ASSERT(atomic_read(&epoch->active) == 0); |
| 1189 | D_ASSERT(epoch->flags == 0); | 1209 | D_ASSERT(epoch->flags == 0); |
| 1190 | 1210 | ||
| 1191 | return TRUE; | 1211 | return true; |
| 1192 | default: | 1212 | default: |
| 1193 | dev_err(DEV, "Strangeness in mdev->write_ordering %d\n", mdev->write_ordering); | 1213 | dev_err(DEV, "Strangeness in mdev->write_ordering %d\n", mdev->write_ordering); |
| 1194 | return FALSE; | 1214 | return false; |
| 1195 | } | 1215 | } |
| 1196 | 1216 | ||
| 1197 | epoch->flags = 0; | 1217 | epoch->flags = 0; |
| @@ -1209,7 +1229,7 @@ static int receive_Barrier(struct drbd_conf *mdev, enum drbd_packets cmd, unsign | |||
| 1209 | } | 1229 | } |
| 1210 | spin_unlock(&mdev->epoch_lock); | 1230 | spin_unlock(&mdev->epoch_lock); |
| 1211 | 1231 | ||
| 1212 | return TRUE; | 1232 | return true; |
| 1213 | } | 1233 | } |
| 1214 | 1234 | ||
| 1215 | /* used from receive_RSDataReply (recv_resync_read) | 1235 | /* used from receive_RSDataReply (recv_resync_read) |
| @@ -1231,21 +1251,25 @@ read_in_block(struct drbd_conf *mdev, u64 id, sector_t sector, int data_size) __ | |||
| 1231 | if (dgs) { | 1251 | if (dgs) { |
| 1232 | rr = drbd_recv(mdev, dig_in, dgs); | 1252 | rr = drbd_recv(mdev, dig_in, dgs); |
| 1233 | if (rr != dgs) { | 1253 | if (rr != dgs) { |
| 1234 | dev_warn(DEV, "short read receiving data digest: read %d expected %d\n", | 1254 | if (!signal_pending(current)) |
| 1235 | rr, dgs); | 1255 | dev_warn(DEV, |
| 1256 | "short read receiving data digest: read %d expected %d\n", | ||
| 1257 | rr, dgs); | ||
| 1236 | return NULL; | 1258 | return NULL; |
| 1237 | } | 1259 | } |
| 1238 | } | 1260 | } |
| 1239 | 1261 | ||
| 1240 | data_size -= dgs; | 1262 | data_size -= dgs; |
| 1241 | 1263 | ||
| 1264 | ERR_IF(data_size == 0) return NULL; | ||
| 1242 | ERR_IF(data_size & 0x1ff) return NULL; | 1265 | ERR_IF(data_size & 0x1ff) return NULL; |
| 1243 | ERR_IF(data_size > DRBD_MAX_SEGMENT_SIZE) return NULL; | 1266 | ERR_IF(data_size > DRBD_MAX_BIO_SIZE) return NULL; |
| 1244 | 1267 | ||
| 1245 | /* even though we trust out peer, | 1268 | /* even though we trust out peer, |
| 1246 | * we sometimes have to double check. */ | 1269 | * we sometimes have to double check. */ |
| 1247 | if (sector + (data_size>>9) > capacity) { | 1270 | if (sector + (data_size>>9) > capacity) { |
| 1248 | dev_err(DEV, "capacity: %llus < sector: %llus + size: %u\n", | 1271 | dev_err(DEV, "request from peer beyond end of local disk: " |
| 1272 | "capacity: %llus < sector: %llus + size: %u\n", | ||
| 1249 | (unsigned long long)capacity, | 1273 | (unsigned long long)capacity, |
| 1250 | (unsigned long long)sector, data_size); | 1274 | (unsigned long long)sector, data_size); |
| 1251 | return NULL; | 1275 | return NULL; |
| @@ -1264,15 +1288,16 @@ read_in_block(struct drbd_conf *mdev, u64 id, sector_t sector, int data_size) __ | |||
| 1264 | unsigned len = min_t(int, ds, PAGE_SIZE); | 1288 | unsigned len = min_t(int, ds, PAGE_SIZE); |
| 1265 | data = kmap(page); | 1289 | data = kmap(page); |
| 1266 | rr = drbd_recv(mdev, data, len); | 1290 | rr = drbd_recv(mdev, data, len); |
| 1267 | if (FAULT_ACTIVE(mdev, DRBD_FAULT_RECEIVE)) { | 1291 | if (drbd_insert_fault(mdev, DRBD_FAULT_RECEIVE)) { |
| 1268 | dev_err(DEV, "Fault injection: Corrupting data on receive\n"); | 1292 | dev_err(DEV, "Fault injection: Corrupting data on receive\n"); |
| 1269 | data[0] = data[0] ^ (unsigned long)-1; | 1293 | data[0] = data[0] ^ (unsigned long)-1; |
| 1270 | } | 1294 | } |
| 1271 | kunmap(page); | 1295 | kunmap(page); |
| 1272 | if (rr != len) { | 1296 | if (rr != len) { |
| 1273 | drbd_free_ee(mdev, e); | 1297 | drbd_free_ee(mdev, e); |
| 1274 | dev_warn(DEV, "short read receiving data: read %d expected %d\n", | 1298 | if (!signal_pending(current)) |
| 1275 | rr, len); | 1299 | dev_warn(DEV, "short read receiving data: read %d expected %d\n", |
| 1300 | rr, len); | ||
| 1276 | return NULL; | 1301 | return NULL; |
| 1277 | } | 1302 | } |
| 1278 | ds -= rr; | 1303 | ds -= rr; |
| @@ -1281,7 +1306,8 @@ read_in_block(struct drbd_conf *mdev, u64 id, sector_t sector, int data_size) __ | |||
| 1281 | if (dgs) { | 1306 | if (dgs) { |
| 1282 | drbd_csum_ee(mdev, mdev->integrity_r_tfm, e, dig_vv); | 1307 | drbd_csum_ee(mdev, mdev->integrity_r_tfm, e, dig_vv); |
| 1283 | if (memcmp(dig_in, dig_vv, dgs)) { | 1308 | if (memcmp(dig_in, dig_vv, dgs)) { |
| 1284 | dev_err(DEV, "Digest integrity check FAILED.\n"); | 1309 | dev_err(DEV, "Digest integrity check FAILED: %llus +%u\n", |
| 1310 | (unsigned long long)sector, data_size); | ||
| 1285 | drbd_bcast_ee(mdev, "digest failed", | 1311 | drbd_bcast_ee(mdev, "digest failed", |
| 1286 | dgs, dig_in, dig_vv, e); | 1312 | dgs, dig_in, dig_vv, e); |
| 1287 | drbd_free_ee(mdev, e); | 1313 | drbd_free_ee(mdev, e); |
| @@ -1302,7 +1328,7 @@ static int drbd_drain_block(struct drbd_conf *mdev, int data_size) | |||
| 1302 | void *data; | 1328 | void *data; |
| 1303 | 1329 | ||
| 1304 | if (!data_size) | 1330 | if (!data_size) |
| 1305 | return TRUE; | 1331 | return true; |
| 1306 | 1332 | ||
| 1307 | page = drbd_pp_alloc(mdev, 1, 1); | 1333 | page = drbd_pp_alloc(mdev, 1, 1); |
| 1308 | 1334 | ||
| @@ -1311,8 +1337,10 @@ static int drbd_drain_block(struct drbd_conf *mdev, int data_size) | |||
| 1311 | rr = drbd_recv(mdev, data, min_t(int, data_size, PAGE_SIZE)); | 1337 | rr = drbd_recv(mdev, data, min_t(int, data_size, PAGE_SIZE)); |
| 1312 | if (rr != min_t(int, data_size, PAGE_SIZE)) { | 1338 | if (rr != min_t(int, data_size, PAGE_SIZE)) { |
| 1313 | rv = 0; | 1339 | rv = 0; |
| 1314 | dev_warn(DEV, "short read receiving data: read %d expected %d\n", | 1340 | if (!signal_pending(current)) |
| 1315 | rr, min_t(int, data_size, PAGE_SIZE)); | 1341 | dev_warn(DEV, |
| 1342 | "short read receiving data: read %d expected %d\n", | ||
| 1343 | rr, min_t(int, data_size, PAGE_SIZE)); | ||
| 1316 | break; | 1344 | break; |
| 1317 | } | 1345 | } |
| 1318 | data_size -= rr; | 1346 | data_size -= rr; |
| @@ -1337,8 +1365,10 @@ static int recv_dless_read(struct drbd_conf *mdev, struct drbd_request *req, | |||
| 1337 | if (dgs) { | 1365 | if (dgs) { |
| 1338 | rr = drbd_recv(mdev, dig_in, dgs); | 1366 | rr = drbd_recv(mdev, dig_in, dgs); |
| 1339 | if (rr != dgs) { | 1367 | if (rr != dgs) { |
| 1340 | dev_warn(DEV, "short read receiving data reply digest: read %d expected %d\n", | 1368 | if (!signal_pending(current)) |
| 1341 | rr, dgs); | 1369 | dev_warn(DEV, |
| 1370 | "short read receiving data reply digest: read %d expected %d\n", | ||
| 1371 | rr, dgs); | ||
| 1342 | return 0; | 1372 | return 0; |
| 1343 | } | 1373 | } |
| 1344 | } | 1374 | } |
| @@ -1359,9 +1389,10 @@ static int recv_dless_read(struct drbd_conf *mdev, struct drbd_request *req, | |||
| 1359 | expect); | 1389 | expect); |
| 1360 | kunmap(bvec->bv_page); | 1390 | kunmap(bvec->bv_page); |
| 1361 | if (rr != expect) { | 1391 | if (rr != expect) { |
| 1362 | dev_warn(DEV, "short read receiving data reply: " | 1392 | if (!signal_pending(current)) |
| 1363 | "read %d expected %d\n", | 1393 | dev_warn(DEV, "short read receiving data reply: " |
| 1364 | rr, expect); | 1394 | "read %d expected %d\n", |
| 1395 | rr, expect); | ||
| 1365 | return 0; | 1396 | return 0; |
| 1366 | } | 1397 | } |
| 1367 | data_size -= rr; | 1398 | data_size -= rr; |
| @@ -1425,11 +1456,10 @@ static int recv_resync_read(struct drbd_conf *mdev, sector_t sector, int data_si | |||
| 1425 | 1456 | ||
| 1426 | atomic_add(data_size >> 9, &mdev->rs_sect_ev); | 1457 | atomic_add(data_size >> 9, &mdev->rs_sect_ev); |
| 1427 | if (drbd_submit_ee(mdev, e, WRITE, DRBD_FAULT_RS_WR) == 0) | 1458 | if (drbd_submit_ee(mdev, e, WRITE, DRBD_FAULT_RS_WR) == 0) |
| 1428 | return TRUE; | 1459 | return true; |
| 1429 | 1460 | ||
| 1430 | /* drbd_submit_ee currently fails for one reason only: | 1461 | /* don't care for the reason here */ |
| 1431 | * not being able to allocate enough bios. | 1462 | dev_err(DEV, "submit failed, triggering re-connect\n"); |
| 1432 | * Is dropping the connection going to help? */ | ||
| 1433 | spin_lock_irq(&mdev->req_lock); | 1463 | spin_lock_irq(&mdev->req_lock); |
| 1434 | list_del(&e->w.list); | 1464 | list_del(&e->w.list); |
| 1435 | spin_unlock_irq(&mdev->req_lock); | 1465 | spin_unlock_irq(&mdev->req_lock); |
| @@ -1437,7 +1467,7 @@ static int recv_resync_read(struct drbd_conf *mdev, sector_t sector, int data_si | |||
| 1437 | drbd_free_ee(mdev, e); | 1467 | drbd_free_ee(mdev, e); |
| 1438 | fail: | 1468 | fail: |
| 1439 | put_ldev(mdev); | 1469 | put_ldev(mdev); |
| 1440 | return FALSE; | 1470 | return false; |
| 1441 | } | 1471 | } |
| 1442 | 1472 | ||
| 1443 | static int receive_DataReply(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned int data_size) | 1473 | static int receive_DataReply(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned int data_size) |
| @@ -1454,7 +1484,7 @@ static int receive_DataReply(struct drbd_conf *mdev, enum drbd_packets cmd, unsi | |||
| 1454 | spin_unlock_irq(&mdev->req_lock); | 1484 | spin_unlock_irq(&mdev->req_lock); |
| 1455 | if (unlikely(!req)) { | 1485 | if (unlikely(!req)) { |
| 1456 | dev_err(DEV, "Got a corrupt block_id/sector pair(1).\n"); | 1486 | dev_err(DEV, "Got a corrupt block_id/sector pair(1).\n"); |
| 1457 | return FALSE; | 1487 | return false; |
| 1458 | } | 1488 | } |
| 1459 | 1489 | ||
| 1460 | /* hlist_del(&req->colision) is done in _req_may_be_done, to avoid | 1490 | /* hlist_del(&req->colision) is done in _req_may_be_done, to avoid |
| @@ -1611,15 +1641,15 @@ static int drbd_wait_peer_seq(struct drbd_conf *mdev, const u32 packet_seq) | |||
| 1611 | return ret; | 1641 | return ret; |
| 1612 | } | 1642 | } |
| 1613 | 1643 | ||
| 1614 | static unsigned long write_flags_to_bio(struct drbd_conf *mdev, u32 dpf) | 1644 | /* see also bio_flags_to_wire() |
| 1645 | * DRBD_REQ_*, because we need to semantically map the flags to data packet | ||
| 1646 | * flags and back. We may replicate to other kernel versions. */ | ||
| 1647 | static unsigned long wire_flags_to_bio(struct drbd_conf *mdev, u32 dpf) | ||
| 1615 | { | 1648 | { |
| 1616 | if (mdev->agreed_pro_version >= 95) | 1649 | return (dpf & DP_RW_SYNC ? REQ_SYNC : 0) | |
| 1617 | return (dpf & DP_RW_SYNC ? REQ_SYNC : 0) | | 1650 | (dpf & DP_FUA ? REQ_FUA : 0) | |
| 1618 | (dpf & DP_FUA ? REQ_FUA : 0) | | 1651 | (dpf & DP_FLUSH ? REQ_FLUSH : 0) | |
| 1619 | (dpf & DP_FLUSH ? REQ_FUA : 0) | | 1652 | (dpf & DP_DISCARD ? REQ_DISCARD : 0); |
| 1620 | (dpf & DP_DISCARD ? REQ_DISCARD : 0); | ||
| 1621 | else | ||
| 1622 | return dpf & DP_RW_SYNC ? REQ_SYNC : 0; | ||
| 1623 | } | 1653 | } |
| 1624 | 1654 | ||
| 1625 | /* mirrored write */ | 1655 | /* mirrored write */ |
| @@ -1632,9 +1662,6 @@ static int receive_Data(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned | |||
| 1632 | u32 dp_flags; | 1662 | u32 dp_flags; |
| 1633 | 1663 | ||
| 1634 | if (!get_ldev(mdev)) { | 1664 | if (!get_ldev(mdev)) { |
| 1635 | if (__ratelimit(&drbd_ratelimit_state)) | ||
| 1636 | dev_err(DEV, "Can not write mirrored data block " | ||
| 1637 | "to local disk.\n"); | ||
| 1638 | spin_lock(&mdev->peer_seq_lock); | 1665 | spin_lock(&mdev->peer_seq_lock); |
| 1639 | if (mdev->peer_seq+1 == be32_to_cpu(p->seq_num)) | 1666 | if (mdev->peer_seq+1 == be32_to_cpu(p->seq_num)) |
| 1640 | mdev->peer_seq++; | 1667 | mdev->peer_seq++; |
| @@ -1654,23 +1681,23 @@ static int receive_Data(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned | |||
| 1654 | e = read_in_block(mdev, p->block_id, sector, data_size); | 1681 | e = read_in_block(mdev, p->block_id, sector, data_size); |
| 1655 | if (!e) { | 1682 | if (!e) { |
| 1656 | put_ldev(mdev); | 1683 | put_ldev(mdev); |
| 1657 | return FALSE; | 1684 | return false; |
| 1658 | } | 1685 | } |
| 1659 | 1686 | ||
| 1660 | e->w.cb = e_end_block; | 1687 | e->w.cb = e_end_block; |
| 1661 | 1688 | ||
| 1689 | dp_flags = be32_to_cpu(p->dp_flags); | ||
| 1690 | rw |= wire_flags_to_bio(mdev, dp_flags); | ||
| 1691 | |||
| 1692 | if (dp_flags & DP_MAY_SET_IN_SYNC) | ||
| 1693 | e->flags |= EE_MAY_SET_IN_SYNC; | ||
| 1694 | |||
| 1662 | spin_lock(&mdev->epoch_lock); | 1695 | spin_lock(&mdev->epoch_lock); |
| 1663 | e->epoch = mdev->current_epoch; | 1696 | e->epoch = mdev->current_epoch; |
| 1664 | atomic_inc(&e->epoch->epoch_size); | 1697 | atomic_inc(&e->epoch->epoch_size); |
| 1665 | atomic_inc(&e->epoch->active); | 1698 | atomic_inc(&e->epoch->active); |
| 1666 | spin_unlock(&mdev->epoch_lock); | 1699 | spin_unlock(&mdev->epoch_lock); |
| 1667 | 1700 | ||
| 1668 | dp_flags = be32_to_cpu(p->dp_flags); | ||
| 1669 | rw |= write_flags_to_bio(mdev, dp_flags); | ||
| 1670 | |||
| 1671 | if (dp_flags & DP_MAY_SET_IN_SYNC) | ||
| 1672 | e->flags |= EE_MAY_SET_IN_SYNC; | ||
| 1673 | |||
| 1674 | /* I'm the receiver, I do hold a net_cnt reference. */ | 1701 | /* I'm the receiver, I do hold a net_cnt reference. */ |
| 1675 | if (!mdev->net_conf->two_primaries) { | 1702 | if (!mdev->net_conf->two_primaries) { |
| 1676 | spin_lock_irq(&mdev->req_lock); | 1703 | spin_lock_irq(&mdev->req_lock); |
| @@ -1773,7 +1800,7 @@ static int receive_Data(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned | |||
| 1773 | put_ldev(mdev); | 1800 | put_ldev(mdev); |
| 1774 | wake_asender(mdev); | 1801 | wake_asender(mdev); |
| 1775 | finish_wait(&mdev->misc_wait, &wait); | 1802 | finish_wait(&mdev->misc_wait, &wait); |
| 1776 | return TRUE; | 1803 | return true; |
| 1777 | } | 1804 | } |
| 1778 | 1805 | ||
| 1779 | if (signal_pending(current)) { | 1806 | if (signal_pending(current)) { |
| @@ -1829,11 +1856,10 @@ static int receive_Data(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned | |||
| 1829 | } | 1856 | } |
| 1830 | 1857 | ||
| 1831 | if (drbd_submit_ee(mdev, e, rw, DRBD_FAULT_DT_WR) == 0) | 1858 | if (drbd_submit_ee(mdev, e, rw, DRBD_FAULT_DT_WR) == 0) |
| 1832 | return TRUE; | 1859 | return true; |
| 1833 | 1860 | ||
| 1834 | /* drbd_submit_ee currently fails for one reason only: | 1861 | /* don't care for the reason here */ |
| 1835 | * not being able to allocate enough bios. | 1862 | dev_err(DEV, "submit failed, triggering re-connect\n"); |
| 1836 | * Is dropping the connection going to help? */ | ||
| 1837 | spin_lock_irq(&mdev->req_lock); | 1863 | spin_lock_irq(&mdev->req_lock); |
| 1838 | list_del(&e->w.list); | 1864 | list_del(&e->w.list); |
| 1839 | hlist_del_init(&e->colision); | 1865 | hlist_del_init(&e->colision); |
| @@ -1842,12 +1868,10 @@ static int receive_Data(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned | |||
| 1842 | drbd_al_complete_io(mdev, e->sector); | 1868 | drbd_al_complete_io(mdev, e->sector); |
| 1843 | 1869 | ||
| 1844 | out_interrupted: | 1870 | out_interrupted: |
| 1845 | /* yes, the epoch_size now is imbalanced. | 1871 | drbd_may_finish_epoch(mdev, e->epoch, EV_PUT + EV_CLEANUP); |
| 1846 | * but we drop the connection anyways, so we don't have a chance to | ||
| 1847 | * receive a barrier... atomic_inc(&mdev->epoch_size); */ | ||
| 1848 | put_ldev(mdev); | 1872 | put_ldev(mdev); |
| 1849 | drbd_free_ee(mdev, e); | 1873 | drbd_free_ee(mdev, e); |
| 1850 | return FALSE; | 1874 | return false; |
| 1851 | } | 1875 | } |
| 1852 | 1876 | ||
| 1853 | /* We may throttle resync, if the lower device seems to be busy, | 1877 | /* We may throttle resync, if the lower device seems to be busy, |
| @@ -1861,10 +1885,11 @@ out_interrupted: | |||
| 1861 | * The current sync rate used here uses only the most recent two step marks, | 1885 | * The current sync rate used here uses only the most recent two step marks, |
| 1862 | * to have a short time average so we can react faster. | 1886 | * to have a short time average so we can react faster. |
| 1863 | */ | 1887 | */ |
| 1864 | int drbd_rs_should_slow_down(struct drbd_conf *mdev) | 1888 | int drbd_rs_should_slow_down(struct drbd_conf *mdev, sector_t sector) |
| 1865 | { | 1889 | { |
| 1866 | struct gendisk *disk = mdev->ldev->backing_bdev->bd_contains->bd_disk; | 1890 | struct gendisk *disk = mdev->ldev->backing_bdev->bd_contains->bd_disk; |
| 1867 | unsigned long db, dt, dbdt; | 1891 | unsigned long db, dt, dbdt; |
| 1892 | struct lc_element *tmp; | ||
| 1868 | int curr_events; | 1893 | int curr_events; |
| 1869 | int throttle = 0; | 1894 | int throttle = 0; |
| 1870 | 1895 | ||
| @@ -1872,9 +1897,22 @@ int drbd_rs_should_slow_down(struct drbd_conf *mdev) | |||
| 1872 | if (mdev->sync_conf.c_min_rate == 0) | 1897 | if (mdev->sync_conf.c_min_rate == 0) |
| 1873 | return 0; | 1898 | return 0; |
| 1874 | 1899 | ||
| 1900 | spin_lock_irq(&mdev->al_lock); | ||
| 1901 | tmp = lc_find(mdev->resync, BM_SECT_TO_EXT(sector)); | ||
| 1902 | if (tmp) { | ||
| 1903 | struct bm_extent *bm_ext = lc_entry(tmp, struct bm_extent, lce); | ||
| 1904 | if (test_bit(BME_PRIORITY, &bm_ext->flags)) { | ||
| 1905 | spin_unlock_irq(&mdev->al_lock); | ||
| 1906 | return 0; | ||
| 1907 | } | ||
| 1908 | /* Do not slow down if app IO is already waiting for this extent */ | ||
| 1909 | } | ||
| 1910 | spin_unlock_irq(&mdev->al_lock); | ||
| 1911 | |||
| 1875 | curr_events = (int)part_stat_read(&disk->part0, sectors[0]) + | 1912 | curr_events = (int)part_stat_read(&disk->part0, sectors[0]) + |
| 1876 | (int)part_stat_read(&disk->part0, sectors[1]) - | 1913 | (int)part_stat_read(&disk->part0, sectors[1]) - |
| 1877 | atomic_read(&mdev->rs_sect_ev); | 1914 | atomic_read(&mdev->rs_sect_ev); |
| 1915 | |||
| 1878 | if (!mdev->rs_last_events || curr_events - mdev->rs_last_events > 64) { | 1916 | if (!mdev->rs_last_events || curr_events - mdev->rs_last_events > 64) { |
| 1879 | unsigned long rs_left; | 1917 | unsigned long rs_left; |
| 1880 | int i; | 1918 | int i; |
| @@ -1883,8 +1921,12 @@ int drbd_rs_should_slow_down(struct drbd_conf *mdev) | |||
| 1883 | 1921 | ||
| 1884 | /* sync speed average over the last 2*DRBD_SYNC_MARK_STEP, | 1922 | /* sync speed average over the last 2*DRBD_SYNC_MARK_STEP, |
| 1885 | * approx. */ | 1923 | * approx. */ |
| 1886 | i = (mdev->rs_last_mark + DRBD_SYNC_MARKS-2) % DRBD_SYNC_MARKS; | 1924 | i = (mdev->rs_last_mark + DRBD_SYNC_MARKS-1) % DRBD_SYNC_MARKS; |
| 1887 | rs_left = drbd_bm_total_weight(mdev) - mdev->rs_failed; | 1925 | |
| 1926 | if (mdev->state.conn == C_VERIFY_S || mdev->state.conn == C_VERIFY_T) | ||
| 1927 | rs_left = mdev->ov_left; | ||
| 1928 | else | ||
| 1929 | rs_left = drbd_bm_total_weight(mdev) - mdev->rs_failed; | ||
| 1888 | 1930 | ||
| 1889 | dt = ((long)jiffies - (long)mdev->rs_mark_time[i]) / HZ; | 1931 | dt = ((long)jiffies - (long)mdev->rs_mark_time[i]) / HZ; |
| 1890 | if (!dt) | 1932 | if (!dt) |
| @@ -1912,15 +1954,15 @@ static int receive_DataRequest(struct drbd_conf *mdev, enum drbd_packets cmd, un | |||
| 1912 | sector = be64_to_cpu(p->sector); | 1954 | sector = be64_to_cpu(p->sector); |
| 1913 | size = be32_to_cpu(p->blksize); | 1955 | size = be32_to_cpu(p->blksize); |
| 1914 | 1956 | ||
| 1915 | if (size <= 0 || (size & 0x1ff) != 0 || size > DRBD_MAX_SEGMENT_SIZE) { | 1957 | if (size <= 0 || (size & 0x1ff) != 0 || size > DRBD_MAX_BIO_SIZE) { |
| 1916 | dev_err(DEV, "%s:%d: sector: %llus, size: %u\n", __FILE__, __LINE__, | 1958 | dev_err(DEV, "%s:%d: sector: %llus, size: %u\n", __FILE__, __LINE__, |
| 1917 | (unsigned long long)sector, size); | 1959 | (unsigned long long)sector, size); |
| 1918 | return FALSE; | 1960 | return false; |
| 1919 | } | 1961 | } |
| 1920 | if (sector + (size>>9) > capacity) { | 1962 | if (sector + (size>>9) > capacity) { |
| 1921 | dev_err(DEV, "%s:%d: sector: %llus, size: %u\n", __FILE__, __LINE__, | 1963 | dev_err(DEV, "%s:%d: sector: %llus, size: %u\n", __FILE__, __LINE__, |
| 1922 | (unsigned long long)sector, size); | 1964 | (unsigned long long)sector, size); |
| 1923 | return FALSE; | 1965 | return false; |
| 1924 | } | 1966 | } |
| 1925 | 1967 | ||
| 1926 | if (!get_ldev_if_state(mdev, D_UP_TO_DATE)) { | 1968 | if (!get_ldev_if_state(mdev, D_UP_TO_DATE)) { |
| @@ -1957,7 +1999,7 @@ static int receive_DataRequest(struct drbd_conf *mdev, enum drbd_packets cmd, un | |||
| 1957 | e = drbd_alloc_ee(mdev, p->block_id, sector, size, GFP_NOIO); | 1999 | e = drbd_alloc_ee(mdev, p->block_id, sector, size, GFP_NOIO); |
| 1958 | if (!e) { | 2000 | if (!e) { |
| 1959 | put_ldev(mdev); | 2001 | put_ldev(mdev); |
| 1960 | return FALSE; | 2002 | return false; |
| 1961 | } | 2003 | } |
| 1962 | 2004 | ||
| 1963 | switch (cmd) { | 2005 | switch (cmd) { |
| @@ -1970,6 +2012,8 @@ static int receive_DataRequest(struct drbd_conf *mdev, enum drbd_packets cmd, un | |||
| 1970 | case P_RS_DATA_REQUEST: | 2012 | case P_RS_DATA_REQUEST: |
| 1971 | e->w.cb = w_e_end_rsdata_req; | 2013 | e->w.cb = w_e_end_rsdata_req; |
| 1972 | fault_type = DRBD_FAULT_RS_RD; | 2014 | fault_type = DRBD_FAULT_RS_RD; |
| 2015 | /* used in the sector offset progress display */ | ||
| 2016 | mdev->bm_resync_fo = BM_SECT_TO_BIT(sector); | ||
| 1973 | break; | 2017 | break; |
| 1974 | 2018 | ||
| 1975 | case P_OV_REPLY: | 2019 | case P_OV_REPLY: |
| @@ -1991,7 +2035,11 @@ static int receive_DataRequest(struct drbd_conf *mdev, enum drbd_packets cmd, un | |||
| 1991 | if (cmd == P_CSUM_RS_REQUEST) { | 2035 | if (cmd == P_CSUM_RS_REQUEST) { |
| 1992 | D_ASSERT(mdev->agreed_pro_version >= 89); | 2036 | D_ASSERT(mdev->agreed_pro_version >= 89); |
| 1993 | e->w.cb = w_e_end_csum_rs_req; | 2037 | e->w.cb = w_e_end_csum_rs_req; |
| 2038 | /* used in the sector offset progress display */ | ||
| 2039 | mdev->bm_resync_fo = BM_SECT_TO_BIT(sector); | ||
| 1994 | } else if (cmd == P_OV_REPLY) { | 2040 | } else if (cmd == P_OV_REPLY) { |
| 2041 | /* track progress, we may need to throttle */ | ||
| 2042 | atomic_add(size >> 9, &mdev->rs_sect_in); | ||
| 1995 | e->w.cb = w_e_end_ov_reply; | 2043 | e->w.cb = w_e_end_ov_reply; |
| 1996 | dec_rs_pending(mdev); | 2044 | dec_rs_pending(mdev); |
| 1997 | /* drbd_rs_begin_io done when we sent this request, | 2045 | /* drbd_rs_begin_io done when we sent this request, |
| @@ -2003,9 +2051,16 @@ static int receive_DataRequest(struct drbd_conf *mdev, enum drbd_packets cmd, un | |||
| 2003 | case P_OV_REQUEST: | 2051 | case P_OV_REQUEST: |
| 2004 | if (mdev->ov_start_sector == ~(sector_t)0 && | 2052 | if (mdev->ov_start_sector == ~(sector_t)0 && |
| 2005 | mdev->agreed_pro_version >= 90) { | 2053 | mdev->agreed_pro_version >= 90) { |
| 2054 | unsigned long now = jiffies; | ||
| 2055 | int i; | ||
| 2006 | mdev->ov_start_sector = sector; | 2056 | mdev->ov_start_sector = sector; |
| 2007 | mdev->ov_position = sector; | 2057 | mdev->ov_position = sector; |
| 2008 | mdev->ov_left = mdev->rs_total - BM_SECT_TO_BIT(sector); | 2058 | mdev->ov_left = drbd_bm_bits(mdev) - BM_SECT_TO_BIT(sector); |
| 2059 | mdev->rs_total = mdev->ov_left; | ||
| 2060 | for (i = 0; i < DRBD_SYNC_MARKS; i++) { | ||
| 2061 | mdev->rs_mark_left[i] = mdev->ov_left; | ||
| 2062 | mdev->rs_mark_time[i] = now; | ||
| 2063 | } | ||
| 2009 | dev_info(DEV, "Online Verify start sector: %llu\n", | 2064 | dev_info(DEV, "Online Verify start sector: %llu\n", |
| 2010 | (unsigned long long)sector); | 2065 | (unsigned long long)sector); |
| 2011 | } | 2066 | } |
| @@ -2042,9 +2097,9 @@ static int receive_DataRequest(struct drbd_conf *mdev, enum drbd_packets cmd, un | |||
| 2042 | * we would also throttle its application reads. | 2097 | * we would also throttle its application reads. |
| 2043 | * In that case, throttling is done on the SyncTarget only. | 2098 | * In that case, throttling is done on the SyncTarget only. |
| 2044 | */ | 2099 | */ |
| 2045 | if (mdev->state.peer != R_PRIMARY && drbd_rs_should_slow_down(mdev)) | 2100 | if (mdev->state.peer != R_PRIMARY && drbd_rs_should_slow_down(mdev, sector)) |
| 2046 | msleep(100); | 2101 | schedule_timeout_uninterruptible(HZ/10); |
| 2047 | if (drbd_rs_begin_io(mdev, e->sector)) | 2102 | if (drbd_rs_begin_io(mdev, sector)) |
| 2048 | goto out_free_e; | 2103 | goto out_free_e; |
| 2049 | 2104 | ||
| 2050 | submit_for_resync: | 2105 | submit_for_resync: |
| @@ -2057,11 +2112,10 @@ submit: | |||
| 2057 | spin_unlock_irq(&mdev->req_lock); | 2112 | spin_unlock_irq(&mdev->req_lock); |
| 2058 | 2113 | ||
| 2059 | if (drbd_submit_ee(mdev, e, READ, fault_type) == 0) | 2114 | if (drbd_submit_ee(mdev, e, READ, fault_type) == 0) |
| 2060 | return TRUE; | 2115 | return true; |
| 2061 | 2116 | ||
| 2062 | /* drbd_submit_ee currently fails for one reason only: | 2117 | /* don't care for the reason here */ |
| 2063 | * not being able to allocate enough bios. | 2118 | dev_err(DEV, "submit failed, triggering re-connect\n"); |
| 2064 | * Is dropping the connection going to help? */ | ||
| 2065 | spin_lock_irq(&mdev->req_lock); | 2119 | spin_lock_irq(&mdev->req_lock); |
| 2066 | list_del(&e->w.list); | 2120 | list_del(&e->w.list); |
| 2067 | spin_unlock_irq(&mdev->req_lock); | 2121 | spin_unlock_irq(&mdev->req_lock); |
| @@ -2070,7 +2124,7 @@ submit: | |||
| 2070 | out_free_e: | 2124 | out_free_e: |
| 2071 | put_ldev(mdev); | 2125 | put_ldev(mdev); |
| 2072 | drbd_free_ee(mdev, e); | 2126 | drbd_free_ee(mdev, e); |
| 2073 | return FALSE; | 2127 | return false; |
| 2074 | } | 2128 | } |
| 2075 | 2129 | ||
| 2076 | static int drbd_asb_recover_0p(struct drbd_conf *mdev) __must_hold(local) | 2130 | static int drbd_asb_recover_0p(struct drbd_conf *mdev) __must_hold(local) |
| @@ -2147,10 +2201,7 @@ static int drbd_asb_recover_0p(struct drbd_conf *mdev) __must_hold(local) | |||
| 2147 | 2201 | ||
| 2148 | static int drbd_asb_recover_1p(struct drbd_conf *mdev) __must_hold(local) | 2202 | static int drbd_asb_recover_1p(struct drbd_conf *mdev) __must_hold(local) |
| 2149 | { | 2203 | { |
| 2150 | int self, peer, hg, rv = -100; | 2204 | int hg, rv = -100; |
| 2151 | |||
| 2152 | self = mdev->ldev->md.uuid[UI_BITMAP] & 1; | ||
| 2153 | peer = mdev->p_uuid[UI_BITMAP] & 1; | ||
| 2154 | 2205 | ||
| 2155 | switch (mdev->net_conf->after_sb_1p) { | 2206 | switch (mdev->net_conf->after_sb_1p) { |
| 2156 | case ASB_DISCARD_YOUNGER_PRI: | 2207 | case ASB_DISCARD_YOUNGER_PRI: |
| @@ -2177,12 +2228,14 @@ static int drbd_asb_recover_1p(struct drbd_conf *mdev) __must_hold(local) | |||
| 2177 | case ASB_CALL_HELPER: | 2228 | case ASB_CALL_HELPER: |
| 2178 | hg = drbd_asb_recover_0p(mdev); | 2229 | hg = drbd_asb_recover_0p(mdev); |
| 2179 | if (hg == -1 && mdev->state.role == R_PRIMARY) { | 2230 | if (hg == -1 && mdev->state.role == R_PRIMARY) { |
| 2180 | self = drbd_set_role(mdev, R_SECONDARY, 0); | 2231 | enum drbd_state_rv rv2; |
| 2232 | |||
| 2233 | drbd_set_role(mdev, R_SECONDARY, 0); | ||
| 2181 | /* drbd_change_state() does not sleep while in SS_IN_TRANSIENT_STATE, | 2234 | /* drbd_change_state() does not sleep while in SS_IN_TRANSIENT_STATE, |
| 2182 | * we might be here in C_WF_REPORT_PARAMS which is transient. | 2235 | * we might be here in C_WF_REPORT_PARAMS which is transient. |
| 2183 | * we do not need to wait for the after state change work either. */ | 2236 | * we do not need to wait for the after state change work either. */ |
| 2184 | self = drbd_change_state(mdev, CS_VERBOSE, NS(role, R_SECONDARY)); | 2237 | rv2 = drbd_change_state(mdev, CS_VERBOSE, NS(role, R_SECONDARY)); |
| 2185 | if (self != SS_SUCCESS) { | 2238 | if (rv2 != SS_SUCCESS) { |
| 2186 | drbd_khelper(mdev, "pri-lost-after-sb"); | 2239 | drbd_khelper(mdev, "pri-lost-after-sb"); |
| 2187 | } else { | 2240 | } else { |
| 2188 | dev_warn(DEV, "Successfully gave up primary role.\n"); | 2241 | dev_warn(DEV, "Successfully gave up primary role.\n"); |
| @@ -2197,10 +2250,7 @@ static int drbd_asb_recover_1p(struct drbd_conf *mdev) __must_hold(local) | |||
| 2197 | 2250 | ||
| 2198 | static int drbd_asb_recover_2p(struct drbd_conf *mdev) __must_hold(local) | 2251 | static int drbd_asb_recover_2p(struct drbd_conf *mdev) __must_hold(local) |
| 2199 | { | 2252 | { |
| 2200 | int self, peer, hg, rv = -100; | 2253 | int hg, rv = -100; |
| 2201 | |||
| 2202 | self = mdev->ldev->md.uuid[UI_BITMAP] & 1; | ||
| 2203 | peer = mdev->p_uuid[UI_BITMAP] & 1; | ||
| 2204 | 2254 | ||
| 2205 | switch (mdev->net_conf->after_sb_2p) { | 2255 | switch (mdev->net_conf->after_sb_2p) { |
| 2206 | case ASB_DISCARD_YOUNGER_PRI: | 2256 | case ASB_DISCARD_YOUNGER_PRI: |
| @@ -2220,11 +2270,13 @@ static int drbd_asb_recover_2p(struct drbd_conf *mdev) __must_hold(local) | |||
| 2220 | case ASB_CALL_HELPER: | 2270 | case ASB_CALL_HELPER: |
| 2221 | hg = drbd_asb_recover_0p(mdev); | 2271 | hg = drbd_asb_recover_0p(mdev); |
| 2222 | if (hg == -1) { | 2272 | if (hg == -1) { |
| 2273 | enum drbd_state_rv rv2; | ||
| 2274 | |||
| 2223 | /* drbd_change_state() does not sleep while in SS_IN_TRANSIENT_STATE, | 2275 | /* drbd_change_state() does not sleep while in SS_IN_TRANSIENT_STATE, |
| 2224 | * we might be here in C_WF_REPORT_PARAMS which is transient. | 2276 | * we might be here in C_WF_REPORT_PARAMS which is transient. |
| 2225 | * we do not need to wait for the after state change work either. */ | 2277 | * we do not need to wait for the after state change work either. */ |
| 2226 | self = drbd_change_state(mdev, CS_VERBOSE, NS(role, R_SECONDARY)); | 2278 | rv2 = drbd_change_state(mdev, CS_VERBOSE, NS(role, R_SECONDARY)); |
| 2227 | if (self != SS_SUCCESS) { | 2279 | if (rv2 != SS_SUCCESS) { |
| 2228 | drbd_khelper(mdev, "pri-lost-after-sb"); | 2280 | drbd_khelper(mdev, "pri-lost-after-sb"); |
| 2229 | } else { | 2281 | } else { |
| 2230 | dev_warn(DEV, "Successfully gave up primary role.\n"); | 2282 | dev_warn(DEV, "Successfully gave up primary role.\n"); |
| @@ -2263,6 +2315,8 @@ static void drbd_uuid_dump(struct drbd_conf *mdev, char *text, u64 *uuid, | |||
| 2263 | -2 C_SYNC_TARGET set BitMap | 2315 | -2 C_SYNC_TARGET set BitMap |
| 2264 | -100 after split brain, disconnect | 2316 | -100 after split brain, disconnect |
| 2265 | -1000 unrelated data | 2317 | -1000 unrelated data |
| 2318 | -1091 requires proto 91 | ||
| 2319 | -1096 requires proto 96 | ||
| 2266 | */ | 2320 | */ |
| 2267 | static int drbd_uuid_compare(struct drbd_conf *mdev, int *rule_nr) __must_hold(local) | 2321 | static int drbd_uuid_compare(struct drbd_conf *mdev, int *rule_nr) __must_hold(local) |
| 2268 | { | 2322 | { |
| @@ -2292,7 +2346,7 @@ static int drbd_uuid_compare(struct drbd_conf *mdev, int *rule_nr) __must_hold(l | |||
| 2292 | if (mdev->p_uuid[UI_BITMAP] == (u64)0 && mdev->ldev->md.uuid[UI_BITMAP] != (u64)0) { | 2346 | if (mdev->p_uuid[UI_BITMAP] == (u64)0 && mdev->ldev->md.uuid[UI_BITMAP] != (u64)0) { |
| 2293 | 2347 | ||
| 2294 | if (mdev->agreed_pro_version < 91) | 2348 | if (mdev->agreed_pro_version < 91) |
| 2295 | return -1001; | 2349 | return -1091; |
| 2296 | 2350 | ||
| 2297 | if ((mdev->ldev->md.uuid[UI_BITMAP] & ~((u64)1)) == (mdev->p_uuid[UI_HISTORY_START] & ~((u64)1)) && | 2351 | if ((mdev->ldev->md.uuid[UI_BITMAP] & ~((u64)1)) == (mdev->p_uuid[UI_HISTORY_START] & ~((u64)1)) && |
| 2298 | (mdev->ldev->md.uuid[UI_HISTORY_START] & ~((u64)1)) == (mdev->p_uuid[UI_HISTORY_START + 1] & ~((u64)1))) { | 2352 | (mdev->ldev->md.uuid[UI_HISTORY_START] & ~((u64)1)) == (mdev->p_uuid[UI_HISTORY_START + 1] & ~((u64)1))) { |
| @@ -2313,7 +2367,7 @@ static int drbd_uuid_compare(struct drbd_conf *mdev, int *rule_nr) __must_hold(l | |||
| 2313 | if (mdev->ldev->md.uuid[UI_BITMAP] == (u64)0 && mdev->p_uuid[UI_BITMAP] != (u64)0) { | 2367 | if (mdev->ldev->md.uuid[UI_BITMAP] == (u64)0 && mdev->p_uuid[UI_BITMAP] != (u64)0) { |
| 2314 | 2368 | ||
| 2315 | if (mdev->agreed_pro_version < 91) | 2369 | if (mdev->agreed_pro_version < 91) |
| 2316 | return -1001; | 2370 | return -1091; |
| 2317 | 2371 | ||
| 2318 | if ((mdev->ldev->md.uuid[UI_HISTORY_START] & ~((u64)1)) == (mdev->p_uuid[UI_BITMAP] & ~((u64)1)) && | 2372 | if ((mdev->ldev->md.uuid[UI_HISTORY_START] & ~((u64)1)) == (mdev->p_uuid[UI_BITMAP] & ~((u64)1)) && |
| 2319 | (mdev->ldev->md.uuid[UI_HISTORY_START + 1] & ~((u64)1)) == (mdev->p_uuid[UI_HISTORY_START] & ~((u64)1))) { | 2373 | (mdev->ldev->md.uuid[UI_HISTORY_START + 1] & ~((u64)1)) == (mdev->p_uuid[UI_HISTORY_START] & ~((u64)1))) { |
| @@ -2358,17 +2412,22 @@ static int drbd_uuid_compare(struct drbd_conf *mdev, int *rule_nr) __must_hold(l | |||
| 2358 | *rule_nr = 51; | 2412 | *rule_nr = 51; |
| 2359 | peer = mdev->p_uuid[UI_HISTORY_START] & ~((u64)1); | 2413 | peer = mdev->p_uuid[UI_HISTORY_START] & ~((u64)1); |
| 2360 | if (self == peer) { | 2414 | if (self == peer) { |
| 2361 | self = mdev->ldev->md.uuid[UI_HISTORY_START] & ~((u64)1); | 2415 | if (mdev->agreed_pro_version < 96 ? |
| 2362 | peer = mdev->p_uuid[UI_HISTORY_START + 1] & ~((u64)1); | 2416 | (mdev->ldev->md.uuid[UI_HISTORY_START] & ~((u64)1)) == |
| 2363 | if (self == peer) { | 2417 | (mdev->p_uuid[UI_HISTORY_START + 1] & ~((u64)1)) : |
| 2418 | peer + UUID_NEW_BM_OFFSET == (mdev->p_uuid[UI_BITMAP] & ~((u64)1))) { | ||
| 2364 | /* The last P_SYNC_UUID did not get though. Undo the last start of | 2419 | /* The last P_SYNC_UUID did not get though. Undo the last start of |
| 2365 | resync as sync source modifications of the peer's UUIDs. */ | 2420 | resync as sync source modifications of the peer's UUIDs. */ |
| 2366 | 2421 | ||
| 2367 | if (mdev->agreed_pro_version < 91) | 2422 | if (mdev->agreed_pro_version < 91) |
| 2368 | return -1001; | 2423 | return -1091; |
| 2369 | 2424 | ||
| 2370 | mdev->p_uuid[UI_BITMAP] = mdev->p_uuid[UI_HISTORY_START]; | 2425 | mdev->p_uuid[UI_BITMAP] = mdev->p_uuid[UI_HISTORY_START]; |
| 2371 | mdev->p_uuid[UI_HISTORY_START] = mdev->p_uuid[UI_HISTORY_START + 1]; | 2426 | mdev->p_uuid[UI_HISTORY_START] = mdev->p_uuid[UI_HISTORY_START + 1]; |
| 2427 | |||
| 2428 | dev_info(DEV, "Did not got last syncUUID packet, corrected:\n"); | ||
| 2429 | drbd_uuid_dump(mdev, "peer", mdev->p_uuid, mdev->p_uuid[UI_SIZE], mdev->p_uuid[UI_FLAGS]); | ||
| 2430 | |||
| 2372 | return -1; | 2431 | return -1; |
| 2373 | } | 2432 | } |
| 2374 | } | 2433 | } |
| @@ -2390,20 +2449,20 @@ static int drbd_uuid_compare(struct drbd_conf *mdev, int *rule_nr) __must_hold(l | |||
| 2390 | *rule_nr = 71; | 2449 | *rule_nr = 71; |
| 2391 | self = mdev->ldev->md.uuid[UI_HISTORY_START] & ~((u64)1); | 2450 | self = mdev->ldev->md.uuid[UI_HISTORY_START] & ~((u64)1); |
| 2392 | if (self == peer) { | 2451 | if (self == peer) { |
| 2393 | self = mdev->ldev->md.uuid[UI_HISTORY_START + 1] & ~((u64)1); | 2452 | if (mdev->agreed_pro_version < 96 ? |
| 2394 | peer = mdev->p_uuid[UI_HISTORY_START] & ~((u64)1); | 2453 | (mdev->ldev->md.uuid[UI_HISTORY_START + 1] & ~((u64)1)) == |
| 2395 | if (self == peer) { | 2454 | (mdev->p_uuid[UI_HISTORY_START] & ~((u64)1)) : |
| 2455 | self + UUID_NEW_BM_OFFSET == (mdev->ldev->md.uuid[UI_BITMAP] & ~((u64)1))) { | ||
| 2396 | /* The last P_SYNC_UUID did not get though. Undo the last start of | 2456 | /* The last P_SYNC_UUID did not get though. Undo the last start of |
| 2397 | resync as sync source modifications of our UUIDs. */ | 2457 | resync as sync source modifications of our UUIDs. */ |
| 2398 | 2458 | ||
| 2399 | if (mdev->agreed_pro_version < 91) | 2459 | if (mdev->agreed_pro_version < 91) |
| 2400 | return -1001; | 2460 | return -1091; |
| 2401 | 2461 | ||
| 2402 | _drbd_uuid_set(mdev, UI_BITMAP, mdev->ldev->md.uuid[UI_HISTORY_START]); | 2462 | _drbd_uuid_set(mdev, UI_BITMAP, mdev->ldev->md.uuid[UI_HISTORY_START]); |
| 2403 | _drbd_uuid_set(mdev, UI_HISTORY_START, mdev->ldev->md.uuid[UI_HISTORY_START + 1]); | 2463 | _drbd_uuid_set(mdev, UI_HISTORY_START, mdev->ldev->md.uuid[UI_HISTORY_START + 1]); |
| 2404 | 2464 | ||
| 2405 | dev_info(DEV, "Undid last start of resync:\n"); | 2465 | dev_info(DEV, "Last syncUUID did not get through, corrected:\n"); |
| 2406 | |||
| 2407 | drbd_uuid_dump(mdev, "self", mdev->ldev->md.uuid, | 2466 | drbd_uuid_dump(mdev, "self", mdev->ldev->md.uuid, |
| 2408 | mdev->state.disk >= D_NEGOTIATING ? drbd_bm_total_weight(mdev) : 0, 0); | 2467 | mdev->state.disk >= D_NEGOTIATING ? drbd_bm_total_weight(mdev) : 0, 0); |
| 2409 | 2468 | ||
| @@ -2466,8 +2525,8 @@ static enum drbd_conns drbd_sync_handshake(struct drbd_conf *mdev, enum drbd_rol | |||
| 2466 | dev_alert(DEV, "Unrelated data, aborting!\n"); | 2525 | dev_alert(DEV, "Unrelated data, aborting!\n"); |
| 2467 | return C_MASK; | 2526 | return C_MASK; |
| 2468 | } | 2527 | } |
| 2469 | if (hg == -1001) { | 2528 | if (hg < -1000) { |
| 2470 | dev_alert(DEV, "To resolve this both sides have to support at least protocol\n"); | 2529 | dev_alert(DEV, "To resolve this both sides have to support at least protocol %d\n", -hg - 1000); |
| 2471 | return C_MASK; | 2530 | return C_MASK; |
| 2472 | } | 2531 | } |
| 2473 | 2532 | ||
| @@ -2566,7 +2625,8 @@ static enum drbd_conns drbd_sync_handshake(struct drbd_conf *mdev, enum drbd_rol | |||
| 2566 | 2625 | ||
| 2567 | if (abs(hg) >= 2) { | 2626 | if (abs(hg) >= 2) { |
| 2568 | dev_info(DEV, "Writing the whole bitmap, full sync required after drbd_sync_handshake.\n"); | 2627 | dev_info(DEV, "Writing the whole bitmap, full sync required after drbd_sync_handshake.\n"); |
| 2569 | if (drbd_bitmap_io(mdev, &drbd_bmio_set_n_write, "set_n_write from sync_handshake")) | 2628 | if (drbd_bitmap_io(mdev, &drbd_bmio_set_n_write, "set_n_write from sync_handshake", |
| 2629 | BM_LOCKED_SET_ALLOWED)) | ||
| 2570 | return C_MASK; | 2630 | return C_MASK; |
| 2571 | } | 2631 | } |
| 2572 | 2632 | ||
| @@ -2660,7 +2720,7 @@ static int receive_protocol(struct drbd_conf *mdev, enum drbd_packets cmd, unsig | |||
| 2660 | unsigned char *my_alg = mdev->net_conf->integrity_alg; | 2720 | unsigned char *my_alg = mdev->net_conf->integrity_alg; |
| 2661 | 2721 | ||
| 2662 | if (drbd_recv(mdev, p_integrity_alg, data_size) != data_size) | 2722 | if (drbd_recv(mdev, p_integrity_alg, data_size) != data_size) |
| 2663 | return FALSE; | 2723 | return false; |
| 2664 | 2724 | ||
| 2665 | p_integrity_alg[SHARED_SECRET_MAX-1] = 0; | 2725 | p_integrity_alg[SHARED_SECRET_MAX-1] = 0; |
| 2666 | if (strcmp(p_integrity_alg, my_alg)) { | 2726 | if (strcmp(p_integrity_alg, my_alg)) { |
| @@ -2671,11 +2731,11 @@ static int receive_protocol(struct drbd_conf *mdev, enum drbd_packets cmd, unsig | |||
| 2671 | my_alg[0] ? my_alg : (unsigned char *)"<not-used>"); | 2731 | my_alg[0] ? my_alg : (unsigned char *)"<not-used>"); |
| 2672 | } | 2732 | } |
| 2673 | 2733 | ||
| 2674 | return TRUE; | 2734 | return true; |
| 2675 | 2735 | ||
| 2676 | disconnect: | 2736 | disconnect: |
| 2677 | drbd_force_state(mdev, NS(conn, C_DISCONNECTING)); | 2737 | drbd_force_state(mdev, NS(conn, C_DISCONNECTING)); |
| 2678 | return FALSE; | 2738 | return false; |
| 2679 | } | 2739 | } |
| 2680 | 2740 | ||
| 2681 | /* helper function | 2741 | /* helper function |
| @@ -2707,7 +2767,7 @@ struct crypto_hash *drbd_crypto_alloc_digest_safe(const struct drbd_conf *mdev, | |||
| 2707 | 2767 | ||
| 2708 | static int receive_SyncParam(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned int packet_size) | 2768 | static int receive_SyncParam(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned int packet_size) |
| 2709 | { | 2769 | { |
| 2710 | int ok = TRUE; | 2770 | int ok = true; |
| 2711 | struct p_rs_param_95 *p = &mdev->data.rbuf.rs_param_95; | 2771 | struct p_rs_param_95 *p = &mdev->data.rbuf.rs_param_95; |
| 2712 | unsigned int header_size, data_size, exp_max_sz; | 2772 | unsigned int header_size, data_size, exp_max_sz; |
| 2713 | struct crypto_hash *verify_tfm = NULL; | 2773 | struct crypto_hash *verify_tfm = NULL; |
| @@ -2725,7 +2785,7 @@ static int receive_SyncParam(struct drbd_conf *mdev, enum drbd_packets cmd, unsi | |||
| 2725 | if (packet_size > exp_max_sz) { | 2785 | if (packet_size > exp_max_sz) { |
| 2726 | dev_err(DEV, "SyncParam packet too long: received %u, expected <= %u bytes\n", | 2786 | dev_err(DEV, "SyncParam packet too long: received %u, expected <= %u bytes\n", |
| 2727 | packet_size, exp_max_sz); | 2787 | packet_size, exp_max_sz); |
| 2728 | return FALSE; | 2788 | return false; |
| 2729 | } | 2789 | } |
| 2730 | 2790 | ||
| 2731 | if (apv <= 88) { | 2791 | if (apv <= 88) { |
| @@ -2745,7 +2805,7 @@ static int receive_SyncParam(struct drbd_conf *mdev, enum drbd_packets cmd, unsi | |||
| 2745 | memset(p->verify_alg, 0, 2 * SHARED_SECRET_MAX); | 2805 | memset(p->verify_alg, 0, 2 * SHARED_SECRET_MAX); |
| 2746 | 2806 | ||
| 2747 | if (drbd_recv(mdev, &p->head.payload, header_size) != header_size) | 2807 | if (drbd_recv(mdev, &p->head.payload, header_size) != header_size) |
| 2748 | return FALSE; | 2808 | return false; |
| 2749 | 2809 | ||
| 2750 | mdev->sync_conf.rate = be32_to_cpu(p->rate); | 2810 | mdev->sync_conf.rate = be32_to_cpu(p->rate); |
| 2751 | 2811 | ||
| @@ -2755,11 +2815,11 @@ static int receive_SyncParam(struct drbd_conf *mdev, enum drbd_packets cmd, unsi | |||
| 2755 | dev_err(DEV, "verify-alg too long, " | 2815 | dev_err(DEV, "verify-alg too long, " |
| 2756 | "peer wants %u, accepting only %u byte\n", | 2816 | "peer wants %u, accepting only %u byte\n", |
| 2757 | data_size, SHARED_SECRET_MAX); | 2817 | data_size, SHARED_SECRET_MAX); |
| 2758 | return FALSE; | 2818 | return false; |
| 2759 | } | 2819 | } |
| 2760 | 2820 | ||
| 2761 | if (drbd_recv(mdev, p->verify_alg, data_size) != data_size) | 2821 | if (drbd_recv(mdev, p->verify_alg, data_size) != data_size) |
| 2762 | return FALSE; | 2822 | return false; |
| 2763 | 2823 | ||
| 2764 | /* we expect NUL terminated string */ | 2824 | /* we expect NUL terminated string */ |
| 2765 | /* but just in case someone tries to be evil */ | 2825 | /* but just in case someone tries to be evil */ |
| @@ -2853,7 +2913,7 @@ disconnect: | |||
| 2853 | /* but free the verify_tfm again, if csums_tfm did not work out */ | 2913 | /* but free the verify_tfm again, if csums_tfm did not work out */ |
| 2854 | crypto_free_hash(verify_tfm); | 2914 | crypto_free_hash(verify_tfm); |
| 2855 | drbd_force_state(mdev, NS(conn, C_DISCONNECTING)); | 2915 | drbd_force_state(mdev, NS(conn, C_DISCONNECTING)); |
| 2856 | return FALSE; | 2916 | return false; |
| 2857 | } | 2917 | } |
| 2858 | 2918 | ||
| 2859 | static void drbd_setup_order_type(struct drbd_conf *mdev, int peer) | 2919 | static void drbd_setup_order_type(struct drbd_conf *mdev, int peer) |
| @@ -2879,7 +2939,7 @@ static int receive_sizes(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned | |||
| 2879 | { | 2939 | { |
| 2880 | struct p_sizes *p = &mdev->data.rbuf.sizes; | 2940 | struct p_sizes *p = &mdev->data.rbuf.sizes; |
| 2881 | enum determine_dev_size dd = unchanged; | 2941 | enum determine_dev_size dd = unchanged; |
| 2882 | unsigned int max_seg_s; | 2942 | unsigned int max_bio_size; |
| 2883 | sector_t p_size, p_usize, my_usize; | 2943 | sector_t p_size, p_usize, my_usize; |
| 2884 | int ldsc = 0; /* local disk size changed */ | 2944 | int ldsc = 0; /* local disk size changed */ |
| 2885 | enum dds_flags ddsf; | 2945 | enum dds_flags ddsf; |
| @@ -2890,7 +2950,7 @@ static int receive_sizes(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned | |||
| 2890 | if (p_size == 0 && mdev->state.disk == D_DISKLESS) { | 2950 | if (p_size == 0 && mdev->state.disk == D_DISKLESS) { |
| 2891 | dev_err(DEV, "some backing storage is needed\n"); | 2951 | dev_err(DEV, "some backing storage is needed\n"); |
| 2892 | drbd_force_state(mdev, NS(conn, C_DISCONNECTING)); | 2952 | drbd_force_state(mdev, NS(conn, C_DISCONNECTING)); |
| 2893 | return FALSE; | 2953 | return false; |
| 2894 | } | 2954 | } |
| 2895 | 2955 | ||
| 2896 | /* just store the peer's disk size for now. | 2956 | /* just store the peer's disk size for now. |
| @@ -2927,18 +2987,17 @@ static int receive_sizes(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned | |||
| 2927 | drbd_force_state(mdev, NS(conn, C_DISCONNECTING)); | 2987 | drbd_force_state(mdev, NS(conn, C_DISCONNECTING)); |
| 2928 | mdev->ldev->dc.disk_size = my_usize; | 2988 | mdev->ldev->dc.disk_size = my_usize; |
| 2929 | put_ldev(mdev); | 2989 | put_ldev(mdev); |
| 2930 | return FALSE; | 2990 | return false; |
| 2931 | } | 2991 | } |
| 2932 | put_ldev(mdev); | 2992 | put_ldev(mdev); |
| 2933 | } | 2993 | } |
| 2934 | #undef min_not_zero | ||
| 2935 | 2994 | ||
| 2936 | ddsf = be16_to_cpu(p->dds_flags); | 2995 | ddsf = be16_to_cpu(p->dds_flags); |
| 2937 | if (get_ldev(mdev)) { | 2996 | if (get_ldev(mdev)) { |
| 2938 | dd = drbd_determin_dev_size(mdev, ddsf); | 2997 | dd = drbd_determin_dev_size(mdev, ddsf); |
| 2939 | put_ldev(mdev); | 2998 | put_ldev(mdev); |
| 2940 | if (dd == dev_size_error) | 2999 | if (dd == dev_size_error) |
| 2941 | return FALSE; | 3000 | return false; |
| 2942 | drbd_md_sync(mdev); | 3001 | drbd_md_sync(mdev); |
| 2943 | } else { | 3002 | } else { |
| 2944 | /* I am diskless, need to accept the peer's size. */ | 3003 | /* I am diskless, need to accept the peer's size. */ |
| @@ -2952,14 +3011,14 @@ static int receive_sizes(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned | |||
| 2952 | } | 3011 | } |
| 2953 | 3012 | ||
| 2954 | if (mdev->agreed_pro_version < 94) | 3013 | if (mdev->agreed_pro_version < 94) |
| 2955 | max_seg_s = be32_to_cpu(p->max_segment_size); | 3014 | max_bio_size = be32_to_cpu(p->max_bio_size); |
| 2956 | else if (mdev->agreed_pro_version == 94) | 3015 | else if (mdev->agreed_pro_version == 94) |
| 2957 | max_seg_s = DRBD_MAX_SIZE_H80_PACKET; | 3016 | max_bio_size = DRBD_MAX_SIZE_H80_PACKET; |
| 2958 | else /* drbd 8.3.8 onwards */ | 3017 | else /* drbd 8.3.8 onwards */ |
| 2959 | max_seg_s = DRBD_MAX_SEGMENT_SIZE; | 3018 | max_bio_size = DRBD_MAX_BIO_SIZE; |
| 2960 | 3019 | ||
| 2961 | if (max_seg_s != queue_max_segment_size(mdev->rq_queue)) | 3020 | if (max_bio_size != queue_max_hw_sectors(mdev->rq_queue) << 9) |
| 2962 | drbd_setup_queue_param(mdev, max_seg_s); | 3021 | drbd_setup_queue_param(mdev, max_bio_size); |
| 2963 | 3022 | ||
| 2964 | drbd_setup_order_type(mdev, be16_to_cpu(p->queue_order_type)); | 3023 | drbd_setup_order_type(mdev, be16_to_cpu(p->queue_order_type)); |
| 2965 | put_ldev(mdev); | 3024 | put_ldev(mdev); |
| @@ -2985,14 +3044,14 @@ static int receive_sizes(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned | |||
| 2985 | } | 3044 | } |
| 2986 | } | 3045 | } |
| 2987 | 3046 | ||
| 2988 | return TRUE; | 3047 | return true; |
| 2989 | } | 3048 | } |
| 2990 | 3049 | ||
| 2991 | static int receive_uuids(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned int data_size) | 3050 | static int receive_uuids(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned int data_size) |
| 2992 | { | 3051 | { |
| 2993 | struct p_uuids *p = &mdev->data.rbuf.uuids; | 3052 | struct p_uuids *p = &mdev->data.rbuf.uuids; |
| 2994 | u64 *p_uuid; | 3053 | u64 *p_uuid; |
| 2995 | int i; | 3054 | int i, updated_uuids = 0; |
| 2996 | 3055 | ||
| 2997 | p_uuid = kmalloc(sizeof(u64)*UI_EXTENDED_SIZE, GFP_NOIO); | 3056 | p_uuid = kmalloc(sizeof(u64)*UI_EXTENDED_SIZE, GFP_NOIO); |
| 2998 | 3057 | ||
| @@ -3009,7 +3068,7 @@ static int receive_uuids(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned | |||
| 3009 | dev_err(DEV, "Can only connect to data with current UUID=%016llX\n", | 3068 | dev_err(DEV, "Can only connect to data with current UUID=%016llX\n", |
| 3010 | (unsigned long long)mdev->ed_uuid); | 3069 | (unsigned long long)mdev->ed_uuid); |
| 3011 | drbd_force_state(mdev, NS(conn, C_DISCONNECTING)); | 3070 | drbd_force_state(mdev, NS(conn, C_DISCONNECTING)); |
| 3012 | return FALSE; | 3071 | return false; |
| 3013 | } | 3072 | } |
| 3014 | 3073 | ||
| 3015 | if (get_ldev(mdev)) { | 3074 | if (get_ldev(mdev)) { |
| @@ -3021,19 +3080,21 @@ static int receive_uuids(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned | |||
| 3021 | if (skip_initial_sync) { | 3080 | if (skip_initial_sync) { |
| 3022 | dev_info(DEV, "Accepted new current UUID, preparing to skip initial sync\n"); | 3081 | dev_info(DEV, "Accepted new current UUID, preparing to skip initial sync\n"); |
| 3023 | drbd_bitmap_io(mdev, &drbd_bmio_clear_n_write, | 3082 | drbd_bitmap_io(mdev, &drbd_bmio_clear_n_write, |
| 3024 | "clear_n_write from receive_uuids"); | 3083 | "clear_n_write from receive_uuids", |
| 3084 | BM_LOCKED_TEST_ALLOWED); | ||
| 3025 | _drbd_uuid_set(mdev, UI_CURRENT, p_uuid[UI_CURRENT]); | 3085 | _drbd_uuid_set(mdev, UI_CURRENT, p_uuid[UI_CURRENT]); |
| 3026 | _drbd_uuid_set(mdev, UI_BITMAP, 0); | 3086 | _drbd_uuid_set(mdev, UI_BITMAP, 0); |
| 3027 | _drbd_set_state(_NS2(mdev, disk, D_UP_TO_DATE, pdsk, D_UP_TO_DATE), | 3087 | _drbd_set_state(_NS2(mdev, disk, D_UP_TO_DATE, pdsk, D_UP_TO_DATE), |
| 3028 | CS_VERBOSE, NULL); | 3088 | CS_VERBOSE, NULL); |
| 3029 | drbd_md_sync(mdev); | 3089 | drbd_md_sync(mdev); |
| 3090 | updated_uuids = 1; | ||
| 3030 | } | 3091 | } |
| 3031 | put_ldev(mdev); | 3092 | put_ldev(mdev); |
| 3032 | } else if (mdev->state.disk < D_INCONSISTENT && | 3093 | } else if (mdev->state.disk < D_INCONSISTENT && |
| 3033 | mdev->state.role == R_PRIMARY) { | 3094 | mdev->state.role == R_PRIMARY) { |
| 3034 | /* I am a diskless primary, the peer just created a new current UUID | 3095 | /* I am a diskless primary, the peer just created a new current UUID |
| 3035 | for me. */ | 3096 | for me. */ |
| 3036 | drbd_set_ed_uuid(mdev, p_uuid[UI_CURRENT]); | 3097 | updated_uuids = drbd_set_ed_uuid(mdev, p_uuid[UI_CURRENT]); |
| 3037 | } | 3098 | } |
| 3038 | 3099 | ||
| 3039 | /* Before we test for the disk state, we should wait until an eventually | 3100 | /* Before we test for the disk state, we should wait until an eventually |
| @@ -3042,9 +3103,12 @@ static int receive_uuids(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned | |||
| 3042 | new disk state... */ | 3103 | new disk state... */ |
| 3043 | wait_event(mdev->misc_wait, !test_bit(CLUSTER_ST_CHANGE, &mdev->flags)); | 3104 | wait_event(mdev->misc_wait, !test_bit(CLUSTER_ST_CHANGE, &mdev->flags)); |
| 3044 | if (mdev->state.conn >= C_CONNECTED && mdev->state.disk < D_INCONSISTENT) | 3105 | if (mdev->state.conn >= C_CONNECTED && mdev->state.disk < D_INCONSISTENT) |
| 3045 | drbd_set_ed_uuid(mdev, p_uuid[UI_CURRENT]); | 3106 | updated_uuids |= drbd_set_ed_uuid(mdev, p_uuid[UI_CURRENT]); |
| 3046 | 3107 | ||
| 3047 | return TRUE; | 3108 | if (updated_uuids) |
| 3109 | drbd_print_uuids(mdev, "receiver updated UUIDs to"); | ||
| 3110 | |||
| 3111 | return true; | ||
| 3048 | } | 3112 | } |
| 3049 | 3113 | ||
| 3050 | /** | 3114 | /** |
| @@ -3081,7 +3145,7 @@ static int receive_req_state(struct drbd_conf *mdev, enum drbd_packets cmd, unsi | |||
| 3081 | { | 3145 | { |
| 3082 | struct p_req_state *p = &mdev->data.rbuf.req_state; | 3146 | struct p_req_state *p = &mdev->data.rbuf.req_state; |
| 3083 | union drbd_state mask, val; | 3147 | union drbd_state mask, val; |
| 3084 | int rv; | 3148 | enum drbd_state_rv rv; |
| 3085 | 3149 | ||
| 3086 | mask.i = be32_to_cpu(p->mask); | 3150 | mask.i = be32_to_cpu(p->mask); |
| 3087 | val.i = be32_to_cpu(p->val); | 3151 | val.i = be32_to_cpu(p->val); |
| @@ -3089,7 +3153,7 @@ static int receive_req_state(struct drbd_conf *mdev, enum drbd_packets cmd, unsi | |||
| 3089 | if (test_bit(DISCARD_CONCURRENT, &mdev->flags) && | 3153 | if (test_bit(DISCARD_CONCURRENT, &mdev->flags) && |
| 3090 | test_bit(CLUSTER_ST_CHANGE, &mdev->flags)) { | 3154 | test_bit(CLUSTER_ST_CHANGE, &mdev->flags)) { |
| 3091 | drbd_send_sr_reply(mdev, SS_CONCURRENT_ST_CHG); | 3155 | drbd_send_sr_reply(mdev, SS_CONCURRENT_ST_CHG); |
| 3092 | return TRUE; | 3156 | return true; |
| 3093 | } | 3157 | } |
| 3094 | 3158 | ||
| 3095 | mask = convert_state(mask); | 3159 | mask = convert_state(mask); |
| @@ -3100,7 +3164,7 @@ static int receive_req_state(struct drbd_conf *mdev, enum drbd_packets cmd, unsi | |||
| 3100 | drbd_send_sr_reply(mdev, rv); | 3164 | drbd_send_sr_reply(mdev, rv); |
| 3101 | drbd_md_sync(mdev); | 3165 | drbd_md_sync(mdev); |
| 3102 | 3166 | ||
| 3103 | return TRUE; | 3167 | return true; |
| 3104 | } | 3168 | } |
| 3105 | 3169 | ||
| 3106 | static int receive_state(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned int data_size) | 3170 | static int receive_state(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned int data_size) |
| @@ -3145,7 +3209,7 @@ static int receive_state(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned | |||
| 3145 | peer_state.conn == C_CONNECTED) { | 3209 | peer_state.conn == C_CONNECTED) { |
| 3146 | if (drbd_bm_total_weight(mdev) <= mdev->rs_failed) | 3210 | if (drbd_bm_total_weight(mdev) <= mdev->rs_failed) |
| 3147 | drbd_resync_finished(mdev); | 3211 | drbd_resync_finished(mdev); |
| 3148 | return TRUE; | 3212 | return true; |
| 3149 | } | 3213 | } |
| 3150 | } | 3214 | } |
| 3151 | 3215 | ||
| @@ -3161,6 +3225,9 @@ static int receive_state(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned | |||
| 3161 | if (ns.conn == C_WF_REPORT_PARAMS) | 3225 | if (ns.conn == C_WF_REPORT_PARAMS) |
| 3162 | ns.conn = C_CONNECTED; | 3226 | ns.conn = C_CONNECTED; |
| 3163 | 3227 | ||
| 3228 | if (peer_state.conn == C_AHEAD) | ||
| 3229 | ns.conn = C_BEHIND; | ||
| 3230 | |||
| 3164 | if (mdev->p_uuid && peer_state.disk >= D_NEGOTIATING && | 3231 | if (mdev->p_uuid && peer_state.disk >= D_NEGOTIATING && |
| 3165 | get_ldev_if_state(mdev, D_NEGOTIATING)) { | 3232 | get_ldev_if_state(mdev, D_NEGOTIATING)) { |
| 3166 | int cr; /* consider resync */ | 3233 | int cr; /* consider resync */ |
| @@ -3195,10 +3262,10 @@ static int receive_state(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned | |||
| 3195 | real_peer_disk = D_DISKLESS; | 3262 | real_peer_disk = D_DISKLESS; |
| 3196 | } else { | 3263 | } else { |
| 3197 | if (test_and_clear_bit(CONN_DRY_RUN, &mdev->flags)) | 3264 | if (test_and_clear_bit(CONN_DRY_RUN, &mdev->flags)) |
| 3198 | return FALSE; | 3265 | return false; |
| 3199 | D_ASSERT(os.conn == C_WF_REPORT_PARAMS); | 3266 | D_ASSERT(os.conn == C_WF_REPORT_PARAMS); |
| 3200 | drbd_force_state(mdev, NS(conn, C_DISCONNECTING)); | 3267 | drbd_force_state(mdev, NS(conn, C_DISCONNECTING)); |
| 3201 | return FALSE; | 3268 | return false; |
| 3202 | } | 3269 | } |
| 3203 | } | 3270 | } |
| 3204 | } | 3271 | } |
| @@ -3223,7 +3290,7 @@ static int receive_state(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned | |||
| 3223 | drbd_uuid_new_current(mdev); | 3290 | drbd_uuid_new_current(mdev); |
| 3224 | clear_bit(NEW_CUR_UUID, &mdev->flags); | 3291 | clear_bit(NEW_CUR_UUID, &mdev->flags); |
| 3225 | drbd_force_state(mdev, NS2(conn, C_PROTOCOL_ERROR, susp, 0)); | 3292 | drbd_force_state(mdev, NS2(conn, C_PROTOCOL_ERROR, susp, 0)); |
| 3226 | return FALSE; | 3293 | return false; |
| 3227 | } | 3294 | } |
| 3228 | rv = _drbd_set_state(mdev, ns, cs_flags, NULL); | 3295 | rv = _drbd_set_state(mdev, ns, cs_flags, NULL); |
| 3229 | ns = mdev->state; | 3296 | ns = mdev->state; |
| @@ -3231,7 +3298,7 @@ static int receive_state(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned | |||
| 3231 | 3298 | ||
| 3232 | if (rv < SS_SUCCESS) { | 3299 | if (rv < SS_SUCCESS) { |
| 3233 | drbd_force_state(mdev, NS(conn, C_DISCONNECTING)); | 3300 | drbd_force_state(mdev, NS(conn, C_DISCONNECTING)); |
| 3234 | return FALSE; | 3301 | return false; |
| 3235 | } | 3302 | } |
| 3236 | 3303 | ||
| 3237 | if (os.conn > C_WF_REPORT_PARAMS) { | 3304 | if (os.conn > C_WF_REPORT_PARAMS) { |
| @@ -3249,7 +3316,7 @@ static int receive_state(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned | |||
| 3249 | 3316 | ||
| 3250 | drbd_md_sync(mdev); /* update connected indicator, la_size, ... */ | 3317 | drbd_md_sync(mdev); /* update connected indicator, la_size, ... */ |
| 3251 | 3318 | ||
| 3252 | return TRUE; | 3319 | return true; |
| 3253 | } | 3320 | } |
| 3254 | 3321 | ||
| 3255 | static int receive_sync_uuid(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned int data_size) | 3322 | static int receive_sync_uuid(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned int data_size) |
| @@ -3258,6 +3325,7 @@ static int receive_sync_uuid(struct drbd_conf *mdev, enum drbd_packets cmd, unsi | |||
| 3258 | 3325 | ||
| 3259 | wait_event(mdev->misc_wait, | 3326 | wait_event(mdev->misc_wait, |
| 3260 | mdev->state.conn == C_WF_SYNC_UUID || | 3327 | mdev->state.conn == C_WF_SYNC_UUID || |
| 3328 | mdev->state.conn == C_BEHIND || | ||
| 3261 | mdev->state.conn < C_CONNECTED || | 3329 | mdev->state.conn < C_CONNECTED || |
| 3262 | mdev->state.disk < D_NEGOTIATING); | 3330 | mdev->state.disk < D_NEGOTIATING); |
| 3263 | 3331 | ||
| @@ -3269,32 +3337,42 @@ static int receive_sync_uuid(struct drbd_conf *mdev, enum drbd_packets cmd, unsi | |||
| 3269 | _drbd_uuid_set(mdev, UI_CURRENT, be64_to_cpu(p->uuid)); | 3337 | _drbd_uuid_set(mdev, UI_CURRENT, be64_to_cpu(p->uuid)); |
| 3270 | _drbd_uuid_set(mdev, UI_BITMAP, 0UL); | 3338 | _drbd_uuid_set(mdev, UI_BITMAP, 0UL); |
| 3271 | 3339 | ||
| 3340 | drbd_print_uuids(mdev, "updated sync uuid"); | ||
| 3272 | drbd_start_resync(mdev, C_SYNC_TARGET); | 3341 | drbd_start_resync(mdev, C_SYNC_TARGET); |
| 3273 | 3342 | ||
| 3274 | put_ldev(mdev); | 3343 | put_ldev(mdev); |
| 3275 | } else | 3344 | } else |
| 3276 | dev_err(DEV, "Ignoring SyncUUID packet!\n"); | 3345 | dev_err(DEV, "Ignoring SyncUUID packet!\n"); |
| 3277 | 3346 | ||
| 3278 | return TRUE; | 3347 | return true; |
| 3279 | } | 3348 | } |
| 3280 | 3349 | ||
| 3281 | enum receive_bitmap_ret { OK, DONE, FAILED }; | 3350 | /** |
| 3282 | 3351 | * receive_bitmap_plain | |
| 3283 | static enum receive_bitmap_ret | 3352 | * |
| 3353 | * Return 0 when done, 1 when another iteration is needed, and a negative error | ||
| 3354 | * code upon failure. | ||
| 3355 | */ | ||
| 3356 | static int | ||
| 3284 | receive_bitmap_plain(struct drbd_conf *mdev, unsigned int data_size, | 3357 | receive_bitmap_plain(struct drbd_conf *mdev, unsigned int data_size, |
| 3285 | unsigned long *buffer, struct bm_xfer_ctx *c) | 3358 | unsigned long *buffer, struct bm_xfer_ctx *c) |
| 3286 | { | 3359 | { |
| 3287 | unsigned num_words = min_t(size_t, BM_PACKET_WORDS, c->bm_words - c->word_offset); | 3360 | unsigned num_words = min_t(size_t, BM_PACKET_WORDS, c->bm_words - c->word_offset); |
| 3288 | unsigned want = num_words * sizeof(long); | 3361 | unsigned want = num_words * sizeof(long); |
| 3362 | int err; | ||
| 3289 | 3363 | ||
| 3290 | if (want != data_size) { | 3364 | if (want != data_size) { |
| 3291 | dev_err(DEV, "%s:want (%u) != data_size (%u)\n", __func__, want, data_size); | 3365 | dev_err(DEV, "%s:want (%u) != data_size (%u)\n", __func__, want, data_size); |
| 3292 | return FAILED; | 3366 | return -EIO; |
| 3293 | } | 3367 | } |
| 3294 | if (want == 0) | 3368 | if (want == 0) |
| 3295 | return DONE; | 3369 | return 0; |
| 3296 | if (drbd_recv(mdev, buffer, want) != want) | 3370 | err = drbd_recv(mdev, buffer, want); |
| 3297 | return FAILED; | 3371 | if (err != want) { |
| 3372 | if (err >= 0) | ||
| 3373 | err = -EIO; | ||
| 3374 | return err; | ||
| 3375 | } | ||
| 3298 | 3376 | ||
| 3299 | drbd_bm_merge_lel(mdev, c->word_offset, num_words, buffer); | 3377 | drbd_bm_merge_lel(mdev, c->word_offset, num_words, buffer); |
| 3300 | 3378 | ||
| @@ -3303,10 +3381,16 @@ receive_bitmap_plain(struct drbd_conf *mdev, unsigned int data_size, | |||
| 3303 | if (c->bit_offset > c->bm_bits) | 3381 | if (c->bit_offset > c->bm_bits) |
| 3304 | c->bit_offset = c->bm_bits; | 3382 | c->bit_offset = c->bm_bits; |
| 3305 | 3383 | ||
| 3306 | return OK; | 3384 | return 1; |
| 3307 | } | 3385 | } |
| 3308 | 3386 | ||
| 3309 | static enum receive_bitmap_ret | 3387 | /** |
| 3388 | * recv_bm_rle_bits | ||
| 3389 | * | ||
| 3390 | * Return 0 when done, 1 when another iteration is needed, and a negative error | ||
| 3391 | * code upon failure. | ||
| 3392 | */ | ||
| 3393 | static int | ||
| 3310 | recv_bm_rle_bits(struct drbd_conf *mdev, | 3394 | recv_bm_rle_bits(struct drbd_conf *mdev, |
| 3311 | struct p_compressed_bm *p, | 3395 | struct p_compressed_bm *p, |
| 3312 | struct bm_xfer_ctx *c) | 3396 | struct bm_xfer_ctx *c) |
| @@ -3326,18 +3410,18 @@ recv_bm_rle_bits(struct drbd_conf *mdev, | |||
| 3326 | 3410 | ||
| 3327 | bits = bitstream_get_bits(&bs, &look_ahead, 64); | 3411 | bits = bitstream_get_bits(&bs, &look_ahead, 64); |
| 3328 | if (bits < 0) | 3412 | if (bits < 0) |
| 3329 | return FAILED; | 3413 | return -EIO; |
| 3330 | 3414 | ||
| 3331 | for (have = bits; have > 0; s += rl, toggle = !toggle) { | 3415 | for (have = bits; have > 0; s += rl, toggle = !toggle) { |
| 3332 | bits = vli_decode_bits(&rl, look_ahead); | 3416 | bits = vli_decode_bits(&rl, look_ahead); |
| 3333 | if (bits <= 0) | 3417 | if (bits <= 0) |
| 3334 | return FAILED; | 3418 | return -EIO; |
| 3335 | 3419 | ||
| 3336 | if (toggle) { | 3420 | if (toggle) { |
| 3337 | e = s + rl -1; | 3421 | e = s + rl -1; |
| 3338 | if (e >= c->bm_bits) { | 3422 | if (e >= c->bm_bits) { |
| 3339 | dev_err(DEV, "bitmap overflow (e:%lu) while decoding bm RLE packet\n", e); | 3423 | dev_err(DEV, "bitmap overflow (e:%lu) while decoding bm RLE packet\n", e); |
| 3340 | return FAILED; | 3424 | return -EIO; |
| 3341 | } | 3425 | } |
| 3342 | _drbd_bm_set_bits(mdev, s, e); | 3426 | _drbd_bm_set_bits(mdev, s, e); |
| 3343 | } | 3427 | } |
| @@ -3347,14 +3431,14 @@ recv_bm_rle_bits(struct drbd_conf *mdev, | |||
| 3347 | have, bits, look_ahead, | 3431 | have, bits, look_ahead, |
| 3348 | (unsigned int)(bs.cur.b - p->code), | 3432 | (unsigned int)(bs.cur.b - p->code), |
| 3349 | (unsigned int)bs.buf_len); | 3433 | (unsigned int)bs.buf_len); |
| 3350 | return FAILED; | 3434 | return -EIO; |
| 3351 | } | 3435 | } |
| 3352 | look_ahead >>= bits; | 3436 | look_ahead >>= bits; |
| 3353 | have -= bits; | 3437 | have -= bits; |
| 3354 | 3438 | ||
| 3355 | bits = bitstream_get_bits(&bs, &tmp, 64 - have); | 3439 | bits = bitstream_get_bits(&bs, &tmp, 64 - have); |
| 3356 | if (bits < 0) | 3440 | if (bits < 0) |
| 3357 | return FAILED; | 3441 | return -EIO; |
| 3358 | look_ahead |= tmp << have; | 3442 | look_ahead |= tmp << have; |
| 3359 | have += bits; | 3443 | have += bits; |
| 3360 | } | 3444 | } |
| @@ -3362,10 +3446,16 @@ recv_bm_rle_bits(struct drbd_conf *mdev, | |||
| 3362 | c->bit_offset = s; | 3446 | c->bit_offset = s; |
| 3363 | bm_xfer_ctx_bit_to_word_offset(c); | 3447 | bm_xfer_ctx_bit_to_word_offset(c); |
| 3364 | 3448 | ||
| 3365 | return (s == c->bm_bits) ? DONE : OK; | 3449 | return (s != c->bm_bits); |
| 3366 | } | 3450 | } |
| 3367 | 3451 | ||
| 3368 | static enum receive_bitmap_ret | 3452 | /** |
| 3453 | * decode_bitmap_c | ||
| 3454 | * | ||
| 3455 | * Return 0 when done, 1 when another iteration is needed, and a negative error | ||
| 3456 | * code upon failure. | ||
| 3457 | */ | ||
| 3458 | static int | ||
| 3369 | decode_bitmap_c(struct drbd_conf *mdev, | 3459 | decode_bitmap_c(struct drbd_conf *mdev, |
| 3370 | struct p_compressed_bm *p, | 3460 | struct p_compressed_bm *p, |
| 3371 | struct bm_xfer_ctx *c) | 3461 | struct bm_xfer_ctx *c) |
| @@ -3379,7 +3469,7 @@ decode_bitmap_c(struct drbd_conf *mdev, | |||
| 3379 | 3469 | ||
| 3380 | dev_err(DEV, "receive_bitmap_c: unknown encoding %u\n", p->encoding); | 3470 | dev_err(DEV, "receive_bitmap_c: unknown encoding %u\n", p->encoding); |
| 3381 | drbd_force_state(mdev, NS(conn, C_PROTOCOL_ERROR)); | 3471 | drbd_force_state(mdev, NS(conn, C_PROTOCOL_ERROR)); |
| 3382 | return FAILED; | 3472 | return -EIO; |
| 3383 | } | 3473 | } |
| 3384 | 3474 | ||
| 3385 | void INFO_bm_xfer_stats(struct drbd_conf *mdev, | 3475 | void INFO_bm_xfer_stats(struct drbd_conf *mdev, |
| @@ -3428,13 +3518,13 @@ static int receive_bitmap(struct drbd_conf *mdev, enum drbd_packets cmd, unsigne | |||
| 3428 | { | 3518 | { |
| 3429 | struct bm_xfer_ctx c; | 3519 | struct bm_xfer_ctx c; |
| 3430 | void *buffer; | 3520 | void *buffer; |
| 3431 | enum receive_bitmap_ret ret; | 3521 | int err; |
| 3432 | int ok = FALSE; | 3522 | int ok = false; |
| 3433 | struct p_header80 *h = &mdev->data.rbuf.header.h80; | 3523 | struct p_header80 *h = &mdev->data.rbuf.header.h80; |
| 3434 | 3524 | ||
| 3435 | wait_event(mdev->misc_wait, !atomic_read(&mdev->ap_bio_cnt)); | 3525 | drbd_bm_lock(mdev, "receive bitmap", BM_LOCKED_SET_ALLOWED); |
| 3436 | 3526 | /* you are supposed to send additional out-of-sync information | |
| 3437 | drbd_bm_lock(mdev, "receive bitmap"); | 3527 | * if you actually set bits during this phase */ |
| 3438 | 3528 | ||
| 3439 | /* maybe we should use some per thread scratch page, | 3529 | /* maybe we should use some per thread scratch page, |
| 3440 | * and allocate that during initial device creation? */ | 3530 | * and allocate that during initial device creation? */ |
| @@ -3449,9 +3539,9 @@ static int receive_bitmap(struct drbd_conf *mdev, enum drbd_packets cmd, unsigne | |||
| 3449 | .bm_words = drbd_bm_words(mdev), | 3539 | .bm_words = drbd_bm_words(mdev), |
| 3450 | }; | 3540 | }; |
| 3451 | 3541 | ||
| 3452 | do { | 3542 | for(;;) { |
| 3453 | if (cmd == P_BITMAP) { | 3543 | if (cmd == P_BITMAP) { |
| 3454 | ret = receive_bitmap_plain(mdev, data_size, buffer, &c); | 3544 | err = receive_bitmap_plain(mdev, data_size, buffer, &c); |
| 3455 | } else if (cmd == P_COMPRESSED_BITMAP) { | 3545 | } else if (cmd == P_COMPRESSED_BITMAP) { |
| 3456 | /* MAYBE: sanity check that we speak proto >= 90, | 3546 | /* MAYBE: sanity check that we speak proto >= 90, |
| 3457 | * and the feature is enabled! */ | 3547 | * and the feature is enabled! */ |
| @@ -3468,9 +3558,9 @@ static int receive_bitmap(struct drbd_conf *mdev, enum drbd_packets cmd, unsigne | |||
| 3468 | goto out; | 3558 | goto out; |
| 3469 | if (data_size <= (sizeof(*p) - sizeof(p->head))) { | 3559 | if (data_size <= (sizeof(*p) - sizeof(p->head))) { |
| 3470 | dev_err(DEV, "ReportCBitmap packet too small (l:%u)\n", data_size); | 3560 | dev_err(DEV, "ReportCBitmap packet too small (l:%u)\n", data_size); |
| 3471 | return FAILED; | 3561 | goto out; |
| 3472 | } | 3562 | } |
| 3473 | ret = decode_bitmap_c(mdev, p, &c); | 3563 | err = decode_bitmap_c(mdev, p, &c); |
| 3474 | } else { | 3564 | } else { |
| 3475 | dev_warn(DEV, "receive_bitmap: cmd neither ReportBitMap nor ReportCBitMap (is 0x%x)", cmd); | 3565 | dev_warn(DEV, "receive_bitmap: cmd neither ReportBitMap nor ReportCBitMap (is 0x%x)", cmd); |
| 3476 | goto out; | 3566 | goto out; |
| @@ -3479,24 +3569,26 @@ static int receive_bitmap(struct drbd_conf *mdev, enum drbd_packets cmd, unsigne | |||
| 3479 | c.packets[cmd == P_BITMAP]++; | 3569 | c.packets[cmd == P_BITMAP]++; |
| 3480 | c.bytes[cmd == P_BITMAP] += sizeof(struct p_header80) + data_size; | 3570 | c.bytes[cmd == P_BITMAP] += sizeof(struct p_header80) + data_size; |
| 3481 | 3571 | ||
| 3482 | if (ret != OK) | 3572 | if (err <= 0) { |
| 3573 | if (err < 0) | ||
| 3574 | goto out; | ||
| 3483 | break; | 3575 | break; |
| 3484 | 3576 | } | |
| 3485 | if (!drbd_recv_header(mdev, &cmd, &data_size)) | 3577 | if (!drbd_recv_header(mdev, &cmd, &data_size)) |
| 3486 | goto out; | 3578 | goto out; |
| 3487 | } while (ret == OK); | 3579 | } |
| 3488 | if (ret == FAILED) | ||
| 3489 | goto out; | ||
| 3490 | 3580 | ||
| 3491 | INFO_bm_xfer_stats(mdev, "receive", &c); | 3581 | INFO_bm_xfer_stats(mdev, "receive", &c); |
| 3492 | 3582 | ||
| 3493 | if (mdev->state.conn == C_WF_BITMAP_T) { | 3583 | if (mdev->state.conn == C_WF_BITMAP_T) { |
| 3584 | enum drbd_state_rv rv; | ||
| 3585 | |||
| 3494 | ok = !drbd_send_bitmap(mdev); | 3586 | ok = !drbd_send_bitmap(mdev); |
| 3495 | if (!ok) | 3587 | if (!ok) |
| 3496 | goto out; | 3588 | goto out; |
| 3497 | /* Omit CS_ORDERED with this state transition to avoid deadlocks. */ | 3589 | /* Omit CS_ORDERED with this state transition to avoid deadlocks. */ |
| 3498 | ok = _drbd_request_state(mdev, NS(conn, C_WF_SYNC_UUID), CS_VERBOSE); | 3590 | rv = _drbd_request_state(mdev, NS(conn, C_WF_SYNC_UUID), CS_VERBOSE); |
| 3499 | D_ASSERT(ok == SS_SUCCESS); | 3591 | D_ASSERT(rv == SS_SUCCESS); |
| 3500 | } else if (mdev->state.conn != C_WF_BITMAP_S) { | 3592 | } else if (mdev->state.conn != C_WF_BITMAP_S) { |
| 3501 | /* admin may have requested C_DISCONNECTING, | 3593 | /* admin may have requested C_DISCONNECTING, |
| 3502 | * other threads may have noticed network errors */ | 3594 | * other threads may have noticed network errors */ |
| @@ -3504,7 +3596,7 @@ static int receive_bitmap(struct drbd_conf *mdev, enum drbd_packets cmd, unsigne | |||
| 3504 | drbd_conn_str(mdev->state.conn)); | 3596 | drbd_conn_str(mdev->state.conn)); |
| 3505 | } | 3597 | } |
| 3506 | 3598 | ||
| 3507 | ok = TRUE; | 3599 | ok = true; |
| 3508 | out: | 3600 | out: |
| 3509 | drbd_bm_unlock(mdev); | 3601 | drbd_bm_unlock(mdev); |
| 3510 | if (ok && mdev->state.conn == C_WF_BITMAP_S) | 3602 | if (ok && mdev->state.conn == C_WF_BITMAP_S) |
| @@ -3538,7 +3630,26 @@ static int receive_UnplugRemote(struct drbd_conf *mdev, enum drbd_packets cmd, u | |||
| 3538 | * with the data requests being unplugged */ | 3630 | * with the data requests being unplugged */ |
| 3539 | drbd_tcp_quickack(mdev->data.socket); | 3631 | drbd_tcp_quickack(mdev->data.socket); |
| 3540 | 3632 | ||
| 3541 | return TRUE; | 3633 | return true; |
| 3634 | } | ||
| 3635 | |||
| 3636 | static int receive_out_of_sync(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned int data_size) | ||
| 3637 | { | ||
| 3638 | struct p_block_desc *p = &mdev->data.rbuf.block_desc; | ||
| 3639 | |||
| 3640 | switch (mdev->state.conn) { | ||
| 3641 | case C_WF_SYNC_UUID: | ||
| 3642 | case C_WF_BITMAP_T: | ||
| 3643 | case C_BEHIND: | ||
| 3644 | break; | ||
| 3645 | default: | ||
| 3646 | dev_err(DEV, "ASSERT FAILED cstate = %s, expected: WFSyncUUID|WFBitMapT|Behind\n", | ||
| 3647 | drbd_conn_str(mdev->state.conn)); | ||
| 3648 | } | ||
| 3649 | |||
| 3650 | drbd_set_out_of_sync(mdev, be64_to_cpu(p->sector), be32_to_cpu(p->blksize)); | ||
| 3651 | |||
| 3652 | return true; | ||
| 3542 | } | 3653 | } |
| 3543 | 3654 | ||
| 3544 | typedef int (*drbd_cmd_handler_f)(struct drbd_conf *, enum drbd_packets cmd, unsigned int to_receive); | 3655 | typedef int (*drbd_cmd_handler_f)(struct drbd_conf *, enum drbd_packets cmd, unsigned int to_receive); |
| @@ -3571,6 +3682,7 @@ static struct data_cmd drbd_cmd_handler[] = { | |||
| 3571 | [P_OV_REPLY] = { 1, sizeof(struct p_block_req), receive_DataRequest }, | 3682 | [P_OV_REPLY] = { 1, sizeof(struct p_block_req), receive_DataRequest }, |
| 3572 | [P_CSUM_RS_REQUEST] = { 1, sizeof(struct p_block_req), receive_DataRequest }, | 3683 | [P_CSUM_RS_REQUEST] = { 1, sizeof(struct p_block_req), receive_DataRequest }, |
| 3573 | [P_DELAY_PROBE] = { 0, sizeof(struct p_delay_probe93), receive_skip }, | 3684 | [P_DELAY_PROBE] = { 0, sizeof(struct p_delay_probe93), receive_skip }, |
| 3685 | [P_OUT_OF_SYNC] = { 0, sizeof(struct p_block_desc), receive_out_of_sync }, | ||
| 3574 | /* anything missing from this table is in | 3686 | /* anything missing from this table is in |
| 3575 | * the asender_tbl, see get_asender_cmd */ | 3687 | * the asender_tbl, see get_asender_cmd */ |
| 3576 | [P_MAX_CMD] = { 0, 0, NULL }, | 3688 | [P_MAX_CMD] = { 0, 0, NULL }, |
| @@ -3610,7 +3722,8 @@ static void drbdd(struct drbd_conf *mdev) | |||
| 3610 | if (shs) { | 3722 | if (shs) { |
| 3611 | rv = drbd_recv(mdev, &header->h80.payload, shs); | 3723 | rv = drbd_recv(mdev, &header->h80.payload, shs); |
| 3612 | if (unlikely(rv != shs)) { | 3724 | if (unlikely(rv != shs)) { |
| 3613 | dev_err(DEV, "short read while reading sub header: rv=%d\n", rv); | 3725 | if (!signal_pending(current)) |
| 3726 | dev_warn(DEV, "short read while reading sub header: rv=%d\n", rv); | ||
| 3614 | goto err_out; | 3727 | goto err_out; |
| 3615 | } | 3728 | } |
| 3616 | } | 3729 | } |
| @@ -3682,9 +3795,6 @@ static void drbd_disconnect(struct drbd_conf *mdev) | |||
| 3682 | 3795 | ||
| 3683 | if (mdev->state.conn == C_STANDALONE) | 3796 | if (mdev->state.conn == C_STANDALONE) |
| 3684 | return; | 3797 | return; |
| 3685 | if (mdev->state.conn >= C_WF_CONNECTION) | ||
| 3686 | dev_err(DEV, "ASSERT FAILED cstate = %s, expected < WFConnection\n", | ||
| 3687 | drbd_conn_str(mdev->state.conn)); | ||
| 3688 | 3798 | ||
| 3689 | /* asender does not clean up anything. it must not interfere, either */ | 3799 | /* asender does not clean up anything. it must not interfere, either */ |
| 3690 | drbd_thread_stop(&mdev->asender); | 3800 | drbd_thread_stop(&mdev->asender); |
| @@ -3713,6 +3823,8 @@ static void drbd_disconnect(struct drbd_conf *mdev) | |||
| 3713 | atomic_set(&mdev->rs_pending_cnt, 0); | 3823 | atomic_set(&mdev->rs_pending_cnt, 0); |
| 3714 | wake_up(&mdev->misc_wait); | 3824 | wake_up(&mdev->misc_wait); |
| 3715 | 3825 | ||
| 3826 | del_timer(&mdev->request_timer); | ||
| 3827 | |||
| 3716 | /* make sure syncer is stopped and w_resume_next_sg queued */ | 3828 | /* make sure syncer is stopped and w_resume_next_sg queued */ |
| 3717 | del_timer_sync(&mdev->resync_timer); | 3829 | del_timer_sync(&mdev->resync_timer); |
| 3718 | resync_timer_fn((unsigned long)mdev); | 3830 | resync_timer_fn((unsigned long)mdev); |
| @@ -3758,13 +3870,6 @@ static void drbd_disconnect(struct drbd_conf *mdev) | |||
| 3758 | if (os.conn == C_DISCONNECTING) { | 3870 | if (os.conn == C_DISCONNECTING) { |
| 3759 | wait_event(mdev->net_cnt_wait, atomic_read(&mdev->net_cnt) == 0); | 3871 | wait_event(mdev->net_cnt_wait, atomic_read(&mdev->net_cnt) == 0); |
| 3760 | 3872 | ||
| 3761 | if (!is_susp(mdev->state)) { | ||
| 3762 | /* we must not free the tl_hash | ||
| 3763 | * while application io is still on the fly */ | ||
| 3764 | wait_event(mdev->misc_wait, !atomic_read(&mdev->ap_bio_cnt)); | ||
| 3765 | drbd_free_tl_hash(mdev); | ||
| 3766 | } | ||
| 3767 | |||
| 3768 | crypto_free_hash(mdev->cram_hmac_tfm); | 3873 | crypto_free_hash(mdev->cram_hmac_tfm); |
| 3769 | mdev->cram_hmac_tfm = NULL; | 3874 | mdev->cram_hmac_tfm = NULL; |
| 3770 | 3875 | ||
| @@ -3773,6 +3878,10 @@ static void drbd_disconnect(struct drbd_conf *mdev) | |||
| 3773 | drbd_request_state(mdev, NS(conn, C_STANDALONE)); | 3878 | drbd_request_state(mdev, NS(conn, C_STANDALONE)); |
| 3774 | } | 3879 | } |
| 3775 | 3880 | ||
| 3881 | /* serialize with bitmap writeout triggered by the state change, | ||
| 3882 | * if any. */ | ||
| 3883 | wait_event(mdev->misc_wait, !test_bit(BITMAP_IO, &mdev->flags)); | ||
| 3884 | |||
| 3776 | /* tcp_close and release of sendpage pages can be deferred. I don't | 3885 | /* tcp_close and release of sendpage pages can be deferred. I don't |
| 3777 | * want to use SO_LINGER, because apparently it can be deferred for | 3886 | * want to use SO_LINGER, because apparently it can be deferred for |
| 3778 | * more than 20 seconds (longest time I checked). | 3887 | * more than 20 seconds (longest time I checked). |
| @@ -3873,7 +3982,8 @@ static int drbd_do_handshake(struct drbd_conf *mdev) | |||
| 3873 | rv = drbd_recv(mdev, &p->head.payload, expect); | 3982 | rv = drbd_recv(mdev, &p->head.payload, expect); |
| 3874 | 3983 | ||
| 3875 | if (rv != expect) { | 3984 | if (rv != expect) { |
| 3876 | dev_err(DEV, "short read receiving handshake packet: l=%u\n", rv); | 3985 | if (!signal_pending(current)) |
| 3986 | dev_warn(DEV, "short read receiving handshake packet: l=%u\n", rv); | ||
| 3877 | return 0; | 3987 | return 0; |
| 3878 | } | 3988 | } |
| 3879 | 3989 | ||
| @@ -3975,7 +4085,8 @@ static int drbd_do_auth(struct drbd_conf *mdev) | |||
| 3975 | rv = drbd_recv(mdev, peers_ch, length); | 4085 | rv = drbd_recv(mdev, peers_ch, length); |
| 3976 | 4086 | ||
| 3977 | if (rv != length) { | 4087 | if (rv != length) { |
| 3978 | dev_err(DEV, "short read AuthChallenge: l=%u\n", rv); | 4088 | if (!signal_pending(current)) |
| 4089 | dev_warn(DEV, "short read AuthChallenge: l=%u\n", rv); | ||
| 3979 | rv = 0; | 4090 | rv = 0; |
| 3980 | goto fail; | 4091 | goto fail; |
| 3981 | } | 4092 | } |
| @@ -4022,7 +4133,8 @@ static int drbd_do_auth(struct drbd_conf *mdev) | |||
| 4022 | rv = drbd_recv(mdev, response , resp_size); | 4133 | rv = drbd_recv(mdev, response , resp_size); |
| 4023 | 4134 | ||
| 4024 | if (rv != resp_size) { | 4135 | if (rv != resp_size) { |
| 4025 | dev_err(DEV, "short read receiving AuthResponse: l=%u\n", rv); | 4136 | if (!signal_pending(current)) |
| 4137 | dev_warn(DEV, "short read receiving AuthResponse: l=%u\n", rv); | ||
| 4026 | rv = 0; | 4138 | rv = 0; |
| 4027 | goto fail; | 4139 | goto fail; |
| 4028 | } | 4140 | } |
| @@ -4074,8 +4186,7 @@ int drbdd_init(struct drbd_thread *thi) | |||
| 4074 | h = drbd_connect(mdev); | 4186 | h = drbd_connect(mdev); |
| 4075 | if (h == 0) { | 4187 | if (h == 0) { |
| 4076 | drbd_disconnect(mdev); | 4188 | drbd_disconnect(mdev); |
| 4077 | __set_current_state(TASK_INTERRUPTIBLE); | 4189 | schedule_timeout_interruptible(HZ); |
| 4078 | schedule_timeout(HZ); | ||
| 4079 | } | 4190 | } |
| 4080 | if (h == -1) { | 4191 | if (h == -1) { |
| 4081 | dev_warn(DEV, "Discarding network configuration.\n"); | 4192 | dev_warn(DEV, "Discarding network configuration.\n"); |
| @@ -4113,7 +4224,7 @@ static int got_RqSReply(struct drbd_conf *mdev, struct p_header80 *h) | |||
| 4113 | } | 4224 | } |
| 4114 | wake_up(&mdev->state_wait); | 4225 | wake_up(&mdev->state_wait); |
| 4115 | 4226 | ||
| 4116 | return TRUE; | 4227 | return true; |
| 4117 | } | 4228 | } |
| 4118 | 4229 | ||
| 4119 | static int got_Ping(struct drbd_conf *mdev, struct p_header80 *h) | 4230 | static int got_Ping(struct drbd_conf *mdev, struct p_header80 *h) |
| @@ -4129,7 +4240,7 @@ static int got_PingAck(struct drbd_conf *mdev, struct p_header80 *h) | |||
| 4129 | if (!test_and_set_bit(GOT_PING_ACK, &mdev->flags)) | 4240 | if (!test_and_set_bit(GOT_PING_ACK, &mdev->flags)) |
| 4130 | wake_up(&mdev->misc_wait); | 4241 | wake_up(&mdev->misc_wait); |
| 4131 | 4242 | ||
| 4132 | return TRUE; | 4243 | return true; |
| 4133 | } | 4244 | } |
| 4134 | 4245 | ||
| 4135 | static int got_IsInSync(struct drbd_conf *mdev, struct p_header80 *h) | 4246 | static int got_IsInSync(struct drbd_conf *mdev, struct p_header80 *h) |
| @@ -4152,7 +4263,7 @@ static int got_IsInSync(struct drbd_conf *mdev, struct p_header80 *h) | |||
| 4152 | dec_rs_pending(mdev); | 4263 | dec_rs_pending(mdev); |
| 4153 | atomic_add(blksize >> 9, &mdev->rs_sect_in); | 4264 | atomic_add(blksize >> 9, &mdev->rs_sect_in); |
| 4154 | 4265 | ||
| 4155 | return TRUE; | 4266 | return true; |
| 4156 | } | 4267 | } |
| 4157 | 4268 | ||
| 4158 | /* when we receive the ACK for a write request, | 4269 | /* when we receive the ACK for a write request, |
| @@ -4176,8 +4287,6 @@ static struct drbd_request *_ack_id_to_req(struct drbd_conf *mdev, | |||
| 4176 | return req; | 4287 | return req; |
| 4177 | } | 4288 | } |
| 4178 | } | 4289 | } |
| 4179 | dev_err(DEV, "_ack_id_to_req: failed to find req %p, sector %llus in list\n", | ||
| 4180 | (void *)(unsigned long)id, (unsigned long long)sector); | ||
| 4181 | return NULL; | 4290 | return NULL; |
| 4182 | } | 4291 | } |
| 4183 | 4292 | ||
| @@ -4195,15 +4304,17 @@ static int validate_req_change_req_state(struct drbd_conf *mdev, | |||
| 4195 | req = validator(mdev, id, sector); | 4304 | req = validator(mdev, id, sector); |
| 4196 | if (unlikely(!req)) { | 4305 | if (unlikely(!req)) { |
| 4197 | spin_unlock_irq(&mdev->req_lock); | 4306 | spin_unlock_irq(&mdev->req_lock); |
| 4198 | dev_err(DEV, "%s: got a corrupt block_id/sector pair\n", func); | 4307 | |
| 4199 | return FALSE; | 4308 | dev_err(DEV, "%s: failed to find req %p, sector %llus\n", func, |
| 4309 | (void *)(unsigned long)id, (unsigned long long)sector); | ||
| 4310 | return false; | ||
| 4200 | } | 4311 | } |
| 4201 | __req_mod(req, what, &m); | 4312 | __req_mod(req, what, &m); |
| 4202 | spin_unlock_irq(&mdev->req_lock); | 4313 | spin_unlock_irq(&mdev->req_lock); |
| 4203 | 4314 | ||
| 4204 | if (m.bio) | 4315 | if (m.bio) |
| 4205 | complete_master_bio(mdev, &m); | 4316 | complete_master_bio(mdev, &m); |
| 4206 | return TRUE; | 4317 | return true; |
| 4207 | } | 4318 | } |
| 4208 | 4319 | ||
| 4209 | static int got_BlockAck(struct drbd_conf *mdev, struct p_header80 *h) | 4320 | static int got_BlockAck(struct drbd_conf *mdev, struct p_header80 *h) |
| @@ -4218,7 +4329,7 @@ static int got_BlockAck(struct drbd_conf *mdev, struct p_header80 *h) | |||
| 4218 | if (is_syncer_block_id(p->block_id)) { | 4329 | if (is_syncer_block_id(p->block_id)) { |
| 4219 | drbd_set_in_sync(mdev, sector, blksize); | 4330 | drbd_set_in_sync(mdev, sector, blksize); |
| 4220 | dec_rs_pending(mdev); | 4331 | dec_rs_pending(mdev); |
| 4221 | return TRUE; | 4332 | return true; |
| 4222 | } | 4333 | } |
| 4223 | switch (be16_to_cpu(h->command)) { | 4334 | switch (be16_to_cpu(h->command)) { |
| 4224 | case P_RS_WRITE_ACK: | 4335 | case P_RS_WRITE_ACK: |
| @@ -4239,7 +4350,7 @@ static int got_BlockAck(struct drbd_conf *mdev, struct p_header80 *h) | |||
| 4239 | break; | 4350 | break; |
| 4240 | default: | 4351 | default: |
| 4241 | D_ASSERT(0); | 4352 | D_ASSERT(0); |
| 4242 | return FALSE; | 4353 | return false; |
| 4243 | } | 4354 | } |
| 4244 | 4355 | ||
| 4245 | return validate_req_change_req_state(mdev, p->block_id, sector, | 4356 | return validate_req_change_req_state(mdev, p->block_id, sector, |
| @@ -4250,20 +4361,44 @@ static int got_NegAck(struct drbd_conf *mdev, struct p_header80 *h) | |||
| 4250 | { | 4361 | { |
| 4251 | struct p_block_ack *p = (struct p_block_ack *)h; | 4362 | struct p_block_ack *p = (struct p_block_ack *)h; |
| 4252 | sector_t sector = be64_to_cpu(p->sector); | 4363 | sector_t sector = be64_to_cpu(p->sector); |
| 4253 | 4364 | int size = be32_to_cpu(p->blksize); | |
| 4254 | if (__ratelimit(&drbd_ratelimit_state)) | 4365 | struct drbd_request *req; |
| 4255 | dev_warn(DEV, "Got NegAck packet. Peer is in troubles?\n"); | 4366 | struct bio_and_error m; |
| 4256 | 4367 | ||
| 4257 | update_peer_seq(mdev, be32_to_cpu(p->seq_num)); | 4368 | update_peer_seq(mdev, be32_to_cpu(p->seq_num)); |
| 4258 | 4369 | ||
| 4259 | if (is_syncer_block_id(p->block_id)) { | 4370 | if (is_syncer_block_id(p->block_id)) { |
| 4260 | int size = be32_to_cpu(p->blksize); | ||
| 4261 | dec_rs_pending(mdev); | 4371 | dec_rs_pending(mdev); |
| 4262 | drbd_rs_failed_io(mdev, sector, size); | 4372 | drbd_rs_failed_io(mdev, sector, size); |
| 4263 | return TRUE; | 4373 | return true; |
| 4264 | } | 4374 | } |
| 4265 | return validate_req_change_req_state(mdev, p->block_id, sector, | 4375 | |
| 4266 | _ack_id_to_req, __func__ , neg_acked); | 4376 | spin_lock_irq(&mdev->req_lock); |
| 4377 | req = _ack_id_to_req(mdev, p->block_id, sector); | ||
| 4378 | if (!req) { | ||
| 4379 | spin_unlock_irq(&mdev->req_lock); | ||
| 4380 | if (mdev->net_conf->wire_protocol == DRBD_PROT_A || | ||
| 4381 | mdev->net_conf->wire_protocol == DRBD_PROT_B) { | ||
| 4382 | /* Protocol A has no P_WRITE_ACKs, but has P_NEG_ACKs. | ||
| 4383 | The master bio might already be completed, therefore the | ||
| 4384 | request is no longer in the collision hash. | ||
| 4385 | => Do not try to validate block_id as request. */ | ||
| 4386 | /* In Protocol B we might already have got a P_RECV_ACK | ||
| 4387 | but then get a P_NEG_ACK after wards. */ | ||
| 4388 | drbd_set_out_of_sync(mdev, sector, size); | ||
| 4389 | return true; | ||
| 4390 | } else { | ||
| 4391 | dev_err(DEV, "%s: failed to find req %p, sector %llus\n", __func__, | ||
| 4392 | (void *)(unsigned long)p->block_id, (unsigned long long)sector); | ||
| 4393 | return false; | ||
| 4394 | } | ||
| 4395 | } | ||
| 4396 | __req_mod(req, neg_acked, &m); | ||
| 4397 | spin_unlock_irq(&mdev->req_lock); | ||
| 4398 | |||
| 4399 | if (m.bio) | ||
| 4400 | complete_master_bio(mdev, &m); | ||
| 4401 | return true; | ||
| 4267 | } | 4402 | } |
| 4268 | 4403 | ||
| 4269 | static int got_NegDReply(struct drbd_conf *mdev, struct p_header80 *h) | 4404 | static int got_NegDReply(struct drbd_conf *mdev, struct p_header80 *h) |
| @@ -4294,11 +4429,20 @@ static int got_NegRSDReply(struct drbd_conf *mdev, struct p_header80 *h) | |||
| 4294 | 4429 | ||
| 4295 | if (get_ldev_if_state(mdev, D_FAILED)) { | 4430 | if (get_ldev_if_state(mdev, D_FAILED)) { |
| 4296 | drbd_rs_complete_io(mdev, sector); | 4431 | drbd_rs_complete_io(mdev, sector); |
| 4297 | drbd_rs_failed_io(mdev, sector, size); | 4432 | switch (be16_to_cpu(h->command)) { |
| 4433 | case P_NEG_RS_DREPLY: | ||
| 4434 | drbd_rs_failed_io(mdev, sector, size); | ||
| 4435 | case P_RS_CANCEL: | ||
| 4436 | break; | ||
| 4437 | default: | ||
| 4438 | D_ASSERT(0); | ||
| 4439 | put_ldev(mdev); | ||
| 4440 | return false; | ||
| 4441 | } | ||
| 4298 | put_ldev(mdev); | 4442 | put_ldev(mdev); |
| 4299 | } | 4443 | } |
| 4300 | 4444 | ||
| 4301 | return TRUE; | 4445 | return true; |
| 4302 | } | 4446 | } |
| 4303 | 4447 | ||
| 4304 | static int got_BarrierAck(struct drbd_conf *mdev, struct p_header80 *h) | 4448 | static int got_BarrierAck(struct drbd_conf *mdev, struct p_header80 *h) |
| @@ -4307,7 +4451,14 @@ static int got_BarrierAck(struct drbd_conf *mdev, struct p_header80 *h) | |||
| 4307 | 4451 | ||
| 4308 | tl_release(mdev, p->barrier, be32_to_cpu(p->set_size)); | 4452 | tl_release(mdev, p->barrier, be32_to_cpu(p->set_size)); |
| 4309 | 4453 | ||
| 4310 | return TRUE; | 4454 | if (mdev->state.conn == C_AHEAD && |
| 4455 | atomic_read(&mdev->ap_in_flight) == 0 && | ||
| 4456 | !test_and_set_bit(AHEAD_TO_SYNC_SOURCE, &mdev->current_epoch->flags)) { | ||
| 4457 | mdev->start_resync_timer.expires = jiffies + HZ; | ||
| 4458 | add_timer(&mdev->start_resync_timer); | ||
| 4459 | } | ||
| 4460 | |||
| 4461 | return true; | ||
| 4311 | } | 4462 | } |
| 4312 | 4463 | ||
| 4313 | static int got_OVResult(struct drbd_conf *mdev, struct p_header80 *h) | 4464 | static int got_OVResult(struct drbd_conf *mdev, struct p_header80 *h) |
| @@ -4328,12 +4479,18 @@ static int got_OVResult(struct drbd_conf *mdev, struct p_header80 *h) | |||
| 4328 | ov_oos_print(mdev); | 4479 | ov_oos_print(mdev); |
| 4329 | 4480 | ||
| 4330 | if (!get_ldev(mdev)) | 4481 | if (!get_ldev(mdev)) |
| 4331 | return TRUE; | 4482 | return true; |
| 4332 | 4483 | ||
| 4333 | drbd_rs_complete_io(mdev, sector); | 4484 | drbd_rs_complete_io(mdev, sector); |
| 4334 | dec_rs_pending(mdev); | 4485 | dec_rs_pending(mdev); |
| 4335 | 4486 | ||
| 4336 | if (--mdev->ov_left == 0) { | 4487 | --mdev->ov_left; |
| 4488 | |||
| 4489 | /* let's advance progress step marks only for every other megabyte */ | ||
| 4490 | if ((mdev->ov_left & 0x200) == 0x200) | ||
| 4491 | drbd_advance_rs_marks(mdev, mdev->ov_left); | ||
| 4492 | |||
| 4493 | if (mdev->ov_left == 0) { | ||
| 4337 | w = kmalloc(sizeof(*w), GFP_NOIO); | 4494 | w = kmalloc(sizeof(*w), GFP_NOIO); |
| 4338 | if (w) { | 4495 | if (w) { |
| 4339 | w->cb = w_ov_finished; | 4496 | w->cb = w_ov_finished; |
| @@ -4345,12 +4502,12 @@ static int got_OVResult(struct drbd_conf *mdev, struct p_header80 *h) | |||
| 4345 | } | 4502 | } |
| 4346 | } | 4503 | } |
| 4347 | put_ldev(mdev); | 4504 | put_ldev(mdev); |
| 4348 | return TRUE; | 4505 | return true; |
| 4349 | } | 4506 | } |
| 4350 | 4507 | ||
| 4351 | static int got_skip(struct drbd_conf *mdev, struct p_header80 *h) | 4508 | static int got_skip(struct drbd_conf *mdev, struct p_header80 *h) |
| 4352 | { | 4509 | { |
| 4353 | return TRUE; | 4510 | return true; |
| 4354 | } | 4511 | } |
| 4355 | 4512 | ||
| 4356 | struct asender_cmd { | 4513 | struct asender_cmd { |
| @@ -4378,6 +4535,7 @@ static struct asender_cmd *get_asender_cmd(int cmd) | |||
| 4378 | [P_STATE_CHG_REPLY] = { sizeof(struct p_req_state_reply), got_RqSReply }, | 4535 | [P_STATE_CHG_REPLY] = { sizeof(struct p_req_state_reply), got_RqSReply }, |
| 4379 | [P_RS_IS_IN_SYNC] = { sizeof(struct p_block_ack), got_IsInSync }, | 4536 | [P_RS_IS_IN_SYNC] = { sizeof(struct p_block_ack), got_IsInSync }, |
| 4380 | [P_DELAY_PROBE] = { sizeof(struct p_delay_probe93), got_skip }, | 4537 | [P_DELAY_PROBE] = { sizeof(struct p_delay_probe93), got_skip }, |
| 4538 | [P_RS_CANCEL] = { sizeof(struct p_block_ack), got_NegRSDReply}, | ||
| 4381 | [P_MAX_CMD] = { 0, NULL }, | 4539 | [P_MAX_CMD] = { 0, NULL }, |
| 4382 | }; | 4540 | }; |
| 4383 | if (cmd > P_MAX_CMD || asender_tbl[cmd].process == NULL) | 4541 | if (cmd > P_MAX_CMD || asender_tbl[cmd].process == NULL) |
diff --git a/drivers/block/drbd/drbd_req.c b/drivers/block/drbd/drbd_req.c index ad3fc6228f2..5c0c8be1bb0 100644 --- a/drivers/block/drbd/drbd_req.c +++ b/drivers/block/drbd/drbd_req.c | |||
| @@ -140,9 +140,14 @@ static void _about_to_complete_local_write(struct drbd_conf *mdev, | |||
| 140 | struct hlist_node *n; | 140 | struct hlist_node *n; |
| 141 | struct hlist_head *slot; | 141 | struct hlist_head *slot; |
| 142 | 142 | ||
| 143 | /* before we can signal completion to the upper layers, | 143 | /* Before we can signal completion to the upper layers, |
| 144 | * we may need to close the current epoch */ | 144 | * we may need to close the current epoch. |
| 145 | * We can skip this, if this request has not even been sent, because we | ||
| 146 | * did not have a fully established connection yet/anymore, during | ||
| 147 | * bitmap exchange, or while we are C_AHEAD due to congestion policy. | ||
| 148 | */ | ||
| 145 | if (mdev->state.conn >= C_CONNECTED && | 149 | if (mdev->state.conn >= C_CONNECTED && |
| 150 | (s & RQ_NET_SENT) != 0 && | ||
| 146 | req->epoch == mdev->newest_tle->br_number) | 151 | req->epoch == mdev->newest_tle->br_number) |
| 147 | queue_barrier(mdev); | 152 | queue_barrier(mdev); |
| 148 | 153 | ||
| @@ -440,7 +445,7 @@ int __req_mod(struct drbd_request *req, enum drbd_req_event what, | |||
| 440 | req->rq_state |= RQ_LOCAL_COMPLETED; | 445 | req->rq_state |= RQ_LOCAL_COMPLETED; |
| 441 | req->rq_state &= ~RQ_LOCAL_PENDING; | 446 | req->rq_state &= ~RQ_LOCAL_PENDING; |
| 442 | 447 | ||
| 443 | __drbd_chk_io_error(mdev, FALSE); | 448 | __drbd_chk_io_error(mdev, false); |
| 444 | _req_may_be_done_not_susp(req, m); | 449 | _req_may_be_done_not_susp(req, m); |
| 445 | put_ldev(mdev); | 450 | put_ldev(mdev); |
| 446 | break; | 451 | break; |
| @@ -461,7 +466,7 @@ int __req_mod(struct drbd_request *req, enum drbd_req_event what, | |||
| 461 | 466 | ||
| 462 | D_ASSERT(!(req->rq_state & RQ_NET_MASK)); | 467 | D_ASSERT(!(req->rq_state & RQ_NET_MASK)); |
| 463 | 468 | ||
| 464 | __drbd_chk_io_error(mdev, FALSE); | 469 | __drbd_chk_io_error(mdev, false); |
| 465 | put_ldev(mdev); | 470 | put_ldev(mdev); |
| 466 | 471 | ||
| 467 | /* no point in retrying if there is no good remote data, | 472 | /* no point in retrying if there is no good remote data, |
| @@ -545,6 +550,14 @@ int __req_mod(struct drbd_request *req, enum drbd_req_event what, | |||
| 545 | 550 | ||
| 546 | break; | 551 | break; |
| 547 | 552 | ||
| 553 | case queue_for_send_oos: | ||
| 554 | req->rq_state |= RQ_NET_QUEUED; | ||
| 555 | req->w.cb = w_send_oos; | ||
| 556 | drbd_queue_work(&mdev->data.work, &req->w); | ||
| 557 | break; | ||
| 558 | |||
| 559 | case oos_handed_to_network: | ||
| 560 | /* actually the same */ | ||
| 548 | case send_canceled: | 561 | case send_canceled: |
| 549 | /* treat it the same */ | 562 | /* treat it the same */ |
| 550 | case send_failed: | 563 | case send_failed: |
| @@ -558,6 +571,9 @@ int __req_mod(struct drbd_request *req, enum drbd_req_event what, | |||
| 558 | 571 | ||
| 559 | case handed_over_to_network: | 572 | case handed_over_to_network: |
| 560 | /* assert something? */ | 573 | /* assert something? */ |
| 574 | if (bio_data_dir(req->master_bio) == WRITE) | ||
| 575 | atomic_add(req->size>>9, &mdev->ap_in_flight); | ||
| 576 | |||
| 561 | if (bio_data_dir(req->master_bio) == WRITE && | 577 | if (bio_data_dir(req->master_bio) == WRITE && |
| 562 | mdev->net_conf->wire_protocol == DRBD_PROT_A) { | 578 | mdev->net_conf->wire_protocol == DRBD_PROT_A) { |
| 563 | /* this is what is dangerous about protocol A: | 579 | /* this is what is dangerous about protocol A: |
| @@ -591,6 +607,9 @@ int __req_mod(struct drbd_request *req, enum drbd_req_event what, | |||
| 591 | dec_ap_pending(mdev); | 607 | dec_ap_pending(mdev); |
| 592 | req->rq_state &= ~(RQ_NET_OK|RQ_NET_PENDING); | 608 | req->rq_state &= ~(RQ_NET_OK|RQ_NET_PENDING); |
| 593 | req->rq_state |= RQ_NET_DONE; | 609 | req->rq_state |= RQ_NET_DONE; |
| 610 | if (req->rq_state & RQ_NET_SENT && req->rq_state & RQ_WRITE) | ||
| 611 | atomic_sub(req->size>>9, &mdev->ap_in_flight); | ||
| 612 | |||
| 594 | /* if it is still queued, we may not complete it here. | 613 | /* if it is still queued, we may not complete it here. |
| 595 | * it will be canceled soon. */ | 614 | * it will be canceled soon. */ |
| 596 | if (!(req->rq_state & RQ_NET_QUEUED)) | 615 | if (!(req->rq_state & RQ_NET_QUEUED)) |
| @@ -628,14 +647,17 @@ int __req_mod(struct drbd_request *req, enum drbd_req_event what, | |||
| 628 | req->rq_state |= RQ_NET_OK; | 647 | req->rq_state |= RQ_NET_OK; |
| 629 | D_ASSERT(req->rq_state & RQ_NET_PENDING); | 648 | D_ASSERT(req->rq_state & RQ_NET_PENDING); |
| 630 | dec_ap_pending(mdev); | 649 | dec_ap_pending(mdev); |
| 650 | atomic_sub(req->size>>9, &mdev->ap_in_flight); | ||
| 631 | req->rq_state &= ~RQ_NET_PENDING; | 651 | req->rq_state &= ~RQ_NET_PENDING; |
| 632 | _req_may_be_done_not_susp(req, m); | 652 | _req_may_be_done_not_susp(req, m); |
| 633 | break; | 653 | break; |
| 634 | 654 | ||
| 635 | case neg_acked: | 655 | case neg_acked: |
| 636 | /* assert something? */ | 656 | /* assert something? */ |
| 637 | if (req->rq_state & RQ_NET_PENDING) | 657 | if (req->rq_state & RQ_NET_PENDING) { |
| 638 | dec_ap_pending(mdev); | 658 | dec_ap_pending(mdev); |
| 659 | atomic_sub(req->size>>9, &mdev->ap_in_flight); | ||
| 660 | } | ||
| 639 | req->rq_state &= ~(RQ_NET_OK|RQ_NET_PENDING); | 661 | req->rq_state &= ~(RQ_NET_OK|RQ_NET_PENDING); |
| 640 | 662 | ||
| 641 | req->rq_state |= RQ_NET_DONE; | 663 | req->rq_state |= RQ_NET_DONE; |
| @@ -690,8 +712,11 @@ int __req_mod(struct drbd_request *req, enum drbd_req_event what, | |||
| 690 | dev_err(DEV, "FIXME (barrier_acked but pending)\n"); | 712 | dev_err(DEV, "FIXME (barrier_acked but pending)\n"); |
| 691 | list_move(&req->tl_requests, &mdev->out_of_sequence_requests); | 713 | list_move(&req->tl_requests, &mdev->out_of_sequence_requests); |
| 692 | } | 714 | } |
| 693 | D_ASSERT(req->rq_state & RQ_NET_SENT); | 715 | if ((req->rq_state & RQ_NET_MASK) != 0) { |
| 694 | req->rq_state |= RQ_NET_DONE; | 716 | req->rq_state |= RQ_NET_DONE; |
| 717 | if (mdev->net_conf->wire_protocol == DRBD_PROT_A) | ||
| 718 | atomic_sub(req->size>>9, &mdev->ap_in_flight); | ||
| 719 | } | ||
| 695 | _req_may_be_done(req, m); /* Allowed while state.susp */ | 720 | _req_may_be_done(req, m); /* Allowed while state.susp */ |
| 696 | break; | 721 | break; |
| 697 | 722 | ||
| @@ -738,14 +763,14 @@ static int drbd_may_do_local_read(struct drbd_conf *mdev, sector_t sector, int s | |||
| 738 | return 0 == drbd_bm_count_bits(mdev, sbnr, ebnr); | 763 | return 0 == drbd_bm_count_bits(mdev, sbnr, ebnr); |
| 739 | } | 764 | } |
| 740 | 765 | ||
| 741 | static int drbd_make_request_common(struct drbd_conf *mdev, struct bio *bio) | 766 | static int drbd_make_request_common(struct drbd_conf *mdev, struct bio *bio, unsigned long start_time) |
| 742 | { | 767 | { |
| 743 | const int rw = bio_rw(bio); | 768 | const int rw = bio_rw(bio); |
| 744 | const int size = bio->bi_size; | 769 | const int size = bio->bi_size; |
| 745 | const sector_t sector = bio->bi_sector; | 770 | const sector_t sector = bio->bi_sector; |
| 746 | struct drbd_tl_epoch *b = NULL; | 771 | struct drbd_tl_epoch *b = NULL; |
| 747 | struct drbd_request *req; | 772 | struct drbd_request *req; |
| 748 | int local, remote; | 773 | int local, remote, send_oos = 0; |
| 749 | int err = -EIO; | 774 | int err = -EIO; |
| 750 | int ret = 0; | 775 | int ret = 0; |
| 751 | 776 | ||
| @@ -759,6 +784,7 @@ static int drbd_make_request_common(struct drbd_conf *mdev, struct bio *bio) | |||
| 759 | bio_endio(bio, -ENOMEM); | 784 | bio_endio(bio, -ENOMEM); |
| 760 | return 0; | 785 | return 0; |
| 761 | } | 786 | } |
| 787 | req->start_time = start_time; | ||
| 762 | 788 | ||
| 763 | local = get_ldev(mdev); | 789 | local = get_ldev(mdev); |
| 764 | if (!local) { | 790 | if (!local) { |
| @@ -808,9 +834,9 @@ static int drbd_make_request_common(struct drbd_conf *mdev, struct bio *bio) | |||
| 808 | drbd_al_begin_io(mdev, sector); | 834 | drbd_al_begin_io(mdev, sector); |
| 809 | } | 835 | } |
| 810 | 836 | ||
| 811 | remote = remote && (mdev->state.pdsk == D_UP_TO_DATE || | 837 | remote = remote && drbd_should_do_remote(mdev->state); |
| 812 | (mdev->state.pdsk == D_INCONSISTENT && | 838 | send_oos = rw == WRITE && drbd_should_send_oos(mdev->state); |
| 813 | mdev->state.conn >= C_CONNECTED)); | 839 | D_ASSERT(!(remote && send_oos)); |
| 814 | 840 | ||
| 815 | if (!(local || remote) && !is_susp(mdev->state)) { | 841 | if (!(local || remote) && !is_susp(mdev->state)) { |
| 816 | if (__ratelimit(&drbd_ratelimit_state)) | 842 | if (__ratelimit(&drbd_ratelimit_state)) |
| @@ -824,7 +850,7 @@ static int drbd_make_request_common(struct drbd_conf *mdev, struct bio *bio) | |||
| 824 | * but there is a race between testing the bit and pointer outside the | 850 | * but there is a race between testing the bit and pointer outside the |
| 825 | * spinlock, and grabbing the spinlock. | 851 | * spinlock, and grabbing the spinlock. |
| 826 | * if we lost that race, we retry. */ | 852 | * if we lost that race, we retry. */ |
| 827 | if (rw == WRITE && remote && | 853 | if (rw == WRITE && (remote || send_oos) && |
| 828 | mdev->unused_spare_tle == NULL && | 854 | mdev->unused_spare_tle == NULL && |
| 829 | test_bit(CREATE_BARRIER, &mdev->flags)) { | 855 | test_bit(CREATE_BARRIER, &mdev->flags)) { |
| 830 | allocate_barrier: | 856 | allocate_barrier: |
| @@ -842,18 +868,19 @@ allocate_barrier: | |||
| 842 | if (is_susp(mdev->state)) { | 868 | if (is_susp(mdev->state)) { |
| 843 | /* If we got suspended, use the retry mechanism of | 869 | /* If we got suspended, use the retry mechanism of |
| 844 | generic_make_request() to restart processing of this | 870 | generic_make_request() to restart processing of this |
| 845 | bio. In the next call to drbd_make_request_26 | 871 | bio. In the next call to drbd_make_request |
| 846 | we sleep in inc_ap_bio() */ | 872 | we sleep in inc_ap_bio() */ |
| 847 | ret = 1; | 873 | ret = 1; |
| 848 | spin_unlock_irq(&mdev->req_lock); | 874 | spin_unlock_irq(&mdev->req_lock); |
| 849 | goto fail_free_complete; | 875 | goto fail_free_complete; |
| 850 | } | 876 | } |
| 851 | 877 | ||
| 852 | if (remote) { | 878 | if (remote || send_oos) { |
| 853 | remote = (mdev->state.pdsk == D_UP_TO_DATE || | 879 | remote = drbd_should_do_remote(mdev->state); |
| 854 | (mdev->state.pdsk == D_INCONSISTENT && | 880 | send_oos = rw == WRITE && drbd_should_send_oos(mdev->state); |
| 855 | mdev->state.conn >= C_CONNECTED)); | 881 | D_ASSERT(!(remote && send_oos)); |
| 856 | if (!remote) | 882 | |
| 883 | if (!(remote || send_oos)) | ||
| 857 | dev_warn(DEV, "lost connection while grabbing the req_lock!\n"); | 884 | dev_warn(DEV, "lost connection while grabbing the req_lock!\n"); |
| 858 | if (!(local || remote)) { | 885 | if (!(local || remote)) { |
| 859 | dev_err(DEV, "IO ERROR: neither local nor remote disk\n"); | 886 | dev_err(DEV, "IO ERROR: neither local nor remote disk\n"); |
| @@ -866,7 +893,7 @@ allocate_barrier: | |||
| 866 | mdev->unused_spare_tle = b; | 893 | mdev->unused_spare_tle = b; |
| 867 | b = NULL; | 894 | b = NULL; |
| 868 | } | 895 | } |
| 869 | if (rw == WRITE && remote && | 896 | if (rw == WRITE && (remote || send_oos) && |
| 870 | mdev->unused_spare_tle == NULL && | 897 | mdev->unused_spare_tle == NULL && |
| 871 | test_bit(CREATE_BARRIER, &mdev->flags)) { | 898 | test_bit(CREATE_BARRIER, &mdev->flags)) { |
| 872 | /* someone closed the current epoch | 899 | /* someone closed the current epoch |
| @@ -889,7 +916,7 @@ allocate_barrier: | |||
| 889 | * barrier packet. To get the write ordering right, we only have to | 916 | * barrier packet. To get the write ordering right, we only have to |
| 890 | * make sure that, if this is a write request and it triggered a | 917 | * make sure that, if this is a write request and it triggered a |
| 891 | * barrier packet, this request is queued within the same spinlock. */ | 918 | * barrier packet, this request is queued within the same spinlock. */ |
| 892 | if (remote && mdev->unused_spare_tle && | 919 | if ((remote || send_oos) && mdev->unused_spare_tle && |
| 893 | test_and_clear_bit(CREATE_BARRIER, &mdev->flags)) { | 920 | test_and_clear_bit(CREATE_BARRIER, &mdev->flags)) { |
| 894 | _tl_add_barrier(mdev, mdev->unused_spare_tle); | 921 | _tl_add_barrier(mdev, mdev->unused_spare_tle); |
| 895 | mdev->unused_spare_tle = NULL; | 922 | mdev->unused_spare_tle = NULL; |
| @@ -937,6 +964,34 @@ allocate_barrier: | |||
| 937 | ? queue_for_net_write | 964 | ? queue_for_net_write |
| 938 | : queue_for_net_read); | 965 | : queue_for_net_read); |
| 939 | } | 966 | } |
| 967 | if (send_oos && drbd_set_out_of_sync(mdev, sector, size)) | ||
| 968 | _req_mod(req, queue_for_send_oos); | ||
| 969 | |||
| 970 | if (remote && | ||
| 971 | mdev->net_conf->on_congestion != OC_BLOCK && mdev->agreed_pro_version >= 96) { | ||
| 972 | int congested = 0; | ||
| 973 | |||
| 974 | if (mdev->net_conf->cong_fill && | ||
| 975 | atomic_read(&mdev->ap_in_flight) >= mdev->net_conf->cong_fill) { | ||
| 976 | dev_info(DEV, "Congestion-fill threshold reached\n"); | ||
| 977 | congested = 1; | ||
| 978 | } | ||
| 979 | |||
| 980 | if (mdev->act_log->used >= mdev->net_conf->cong_extents) { | ||
| 981 | dev_info(DEV, "Congestion-extents threshold reached\n"); | ||
| 982 | congested = 1; | ||
| 983 | } | ||
| 984 | |||
| 985 | if (congested) { | ||
| 986 | queue_barrier(mdev); /* last barrier, after mirrored writes */ | ||
| 987 | |||
| 988 | if (mdev->net_conf->on_congestion == OC_PULL_AHEAD) | ||
| 989 | _drbd_set_state(_NS(mdev, conn, C_AHEAD), 0, NULL); | ||
| 990 | else /*mdev->net_conf->on_congestion == OC_DISCONNECT */ | ||
| 991 | _drbd_set_state(_NS(mdev, conn, C_DISCONNECTING), 0, NULL); | ||
| 992 | } | ||
| 993 | } | ||
| 994 | |||
| 940 | spin_unlock_irq(&mdev->req_lock); | 995 | spin_unlock_irq(&mdev->req_lock); |
| 941 | kfree(b); /* if someone else has beaten us to it... */ | 996 | kfree(b); /* if someone else has beaten us to it... */ |
| 942 | 997 | ||
| @@ -949,9 +1004,9 @@ allocate_barrier: | |||
| 949 | * stable storage, and this is a WRITE, we may not even submit | 1004 | * stable storage, and this is a WRITE, we may not even submit |
| 950 | * this bio. */ | 1005 | * this bio. */ |
| 951 | if (get_ldev(mdev)) { | 1006 | if (get_ldev(mdev)) { |
| 952 | if (FAULT_ACTIVE(mdev, rw == WRITE ? DRBD_FAULT_DT_WR | 1007 | if (drbd_insert_fault(mdev, rw == WRITE ? DRBD_FAULT_DT_WR |
| 953 | : rw == READ ? DRBD_FAULT_DT_RD | 1008 | : rw == READ ? DRBD_FAULT_DT_RD |
| 954 | : DRBD_FAULT_DT_RA)) | 1009 | : DRBD_FAULT_DT_RA)) |
| 955 | bio_endio(req->private_bio, -EIO); | 1010 | bio_endio(req->private_bio, -EIO); |
| 956 | else | 1011 | else |
| 957 | generic_make_request(req->private_bio); | 1012 | generic_make_request(req->private_bio); |
| @@ -1018,16 +1073,19 @@ static int drbd_fail_request_early(struct drbd_conf *mdev, int is_write) | |||
| 1018 | return 0; | 1073 | return 0; |
| 1019 | } | 1074 | } |
| 1020 | 1075 | ||
| 1021 | int drbd_make_request_26(struct request_queue *q, struct bio *bio) | 1076 | int drbd_make_request(struct request_queue *q, struct bio *bio) |
| 1022 | { | 1077 | { |
| 1023 | unsigned int s_enr, e_enr; | 1078 | unsigned int s_enr, e_enr; |
| 1024 | struct drbd_conf *mdev = (struct drbd_conf *) q->queuedata; | 1079 | struct drbd_conf *mdev = (struct drbd_conf *) q->queuedata; |
| 1080 | unsigned long start_time; | ||
| 1025 | 1081 | ||
| 1026 | if (drbd_fail_request_early(mdev, bio_data_dir(bio) & WRITE)) { | 1082 | if (drbd_fail_request_early(mdev, bio_data_dir(bio) & WRITE)) { |
| 1027 | bio_endio(bio, -EPERM); | 1083 | bio_endio(bio, -EPERM); |
| 1028 | return 0; | 1084 | return 0; |
| 1029 | } | 1085 | } |
| 1030 | 1086 | ||
| 1087 | start_time = jiffies; | ||
| 1088 | |||
| 1031 | /* | 1089 | /* |
| 1032 | * what we "blindly" assume: | 1090 | * what we "blindly" assume: |
| 1033 | */ | 1091 | */ |
| @@ -1042,12 +1100,12 @@ int drbd_make_request_26(struct request_queue *q, struct bio *bio) | |||
| 1042 | 1100 | ||
| 1043 | if (likely(s_enr == e_enr)) { | 1101 | if (likely(s_enr == e_enr)) { |
| 1044 | inc_ap_bio(mdev, 1); | 1102 | inc_ap_bio(mdev, 1); |
| 1045 | return drbd_make_request_common(mdev, bio); | 1103 | return drbd_make_request_common(mdev, bio, start_time); |
| 1046 | } | 1104 | } |
| 1047 | 1105 | ||
| 1048 | /* can this bio be split generically? | 1106 | /* can this bio be split generically? |
| 1049 | * Maybe add our own split-arbitrary-bios function. */ | 1107 | * Maybe add our own split-arbitrary-bios function. */ |
| 1050 | if (bio->bi_vcnt != 1 || bio->bi_idx != 0 || bio->bi_size > DRBD_MAX_SEGMENT_SIZE) { | 1108 | if (bio->bi_vcnt != 1 || bio->bi_idx != 0 || bio->bi_size > DRBD_MAX_BIO_SIZE) { |
| 1051 | /* rather error out here than BUG in bio_split */ | 1109 | /* rather error out here than BUG in bio_split */ |
| 1052 | dev_err(DEV, "bio would need to, but cannot, be split: " | 1110 | dev_err(DEV, "bio would need to, but cannot, be split: " |
| 1053 | "(vcnt=%u,idx=%u,size=%u,sector=%llu)\n", | 1111 | "(vcnt=%u,idx=%u,size=%u,sector=%llu)\n", |
| @@ -1069,11 +1127,7 @@ int drbd_make_request_26(struct request_queue *q, struct bio *bio) | |||
| 1069 | const int sps = 1 << HT_SHIFT; /* sectors per slot */ | 1127 | const int sps = 1 << HT_SHIFT; /* sectors per slot */ |
| 1070 | const int mask = sps - 1; | 1128 | const int mask = sps - 1; |
| 1071 | const sector_t first_sectors = sps - (sect & mask); | 1129 | const sector_t first_sectors = sps - (sect & mask); |
| 1072 | bp = bio_split(bio, | 1130 | bp = bio_split(bio, first_sectors); |
| 1073 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28) | ||
| 1074 | bio_split_pool, | ||
| 1075 | #endif | ||
| 1076 | first_sectors); | ||
| 1077 | 1131 | ||
| 1078 | /* we need to get a "reference count" (ap_bio_cnt) | 1132 | /* we need to get a "reference count" (ap_bio_cnt) |
| 1079 | * to avoid races with the disconnect/reconnect/suspend code. | 1133 | * to avoid races with the disconnect/reconnect/suspend code. |
| @@ -1084,10 +1138,10 @@ int drbd_make_request_26(struct request_queue *q, struct bio *bio) | |||
| 1084 | 1138 | ||
| 1085 | D_ASSERT(e_enr == s_enr + 1); | 1139 | D_ASSERT(e_enr == s_enr + 1); |
| 1086 | 1140 | ||
| 1087 | while (drbd_make_request_common(mdev, &bp->bio1)) | 1141 | while (drbd_make_request_common(mdev, &bp->bio1, start_time)) |
| 1088 | inc_ap_bio(mdev, 1); | 1142 | inc_ap_bio(mdev, 1); |
| 1089 | 1143 | ||
| 1090 | while (drbd_make_request_common(mdev, &bp->bio2)) | 1144 | while (drbd_make_request_common(mdev, &bp->bio2, start_time)) |
| 1091 | inc_ap_bio(mdev, 1); | 1145 | inc_ap_bio(mdev, 1); |
| 1092 | 1146 | ||
| 1093 | dec_ap_bio(mdev); | 1147 | dec_ap_bio(mdev); |
| @@ -1098,7 +1152,7 @@ int drbd_make_request_26(struct request_queue *q, struct bio *bio) | |||
| 1098 | } | 1152 | } |
| 1099 | 1153 | ||
| 1100 | /* This is called by bio_add_page(). With this function we reduce | 1154 | /* This is called by bio_add_page(). With this function we reduce |
| 1101 | * the number of BIOs that span over multiple DRBD_MAX_SEGMENT_SIZEs | 1155 | * the number of BIOs that span over multiple DRBD_MAX_BIO_SIZEs |
| 1102 | * units (was AL_EXTENTs). | 1156 | * units (was AL_EXTENTs). |
| 1103 | * | 1157 | * |
| 1104 | * we do the calculation within the lower 32bit of the byte offsets, | 1158 | * we do the calculation within the lower 32bit of the byte offsets, |
| @@ -1108,7 +1162,7 @@ int drbd_make_request_26(struct request_queue *q, struct bio *bio) | |||
| 1108 | * As long as the BIO is empty we have to allow at least one bvec, | 1162 | * As long as the BIO is empty we have to allow at least one bvec, |
| 1109 | * regardless of size and offset. so the resulting bio may still | 1163 | * regardless of size and offset. so the resulting bio may still |
| 1110 | * cross extent boundaries. those are dealt with (bio_split) in | 1164 | * cross extent boundaries. those are dealt with (bio_split) in |
| 1111 | * drbd_make_request_26. | 1165 | * drbd_make_request. |
| 1112 | */ | 1166 | */ |
| 1113 | int drbd_merge_bvec(struct request_queue *q, struct bvec_merge_data *bvm, struct bio_vec *bvec) | 1167 | int drbd_merge_bvec(struct request_queue *q, struct bvec_merge_data *bvm, struct bio_vec *bvec) |
| 1114 | { | 1168 | { |
| @@ -1118,8 +1172,8 @@ int drbd_merge_bvec(struct request_queue *q, struct bvec_merge_data *bvm, struct | |||
| 1118 | unsigned int bio_size = bvm->bi_size; | 1172 | unsigned int bio_size = bvm->bi_size; |
| 1119 | int limit, backing_limit; | 1173 | int limit, backing_limit; |
| 1120 | 1174 | ||
| 1121 | limit = DRBD_MAX_SEGMENT_SIZE | 1175 | limit = DRBD_MAX_BIO_SIZE |
| 1122 | - ((bio_offset & (DRBD_MAX_SEGMENT_SIZE-1)) + bio_size); | 1176 | - ((bio_offset & (DRBD_MAX_BIO_SIZE-1)) + bio_size); |
| 1123 | if (limit < 0) | 1177 | if (limit < 0) |
| 1124 | limit = 0; | 1178 | limit = 0; |
| 1125 | if (bio_size == 0) { | 1179 | if (bio_size == 0) { |
| @@ -1136,3 +1190,42 @@ int drbd_merge_bvec(struct request_queue *q, struct bvec_merge_data *bvm, struct | |||
| 1136 | } | 1190 | } |
| 1137 | return limit; | 1191 | return limit; |
| 1138 | } | 1192 | } |
| 1193 | |||
| 1194 | void request_timer_fn(unsigned long data) | ||
| 1195 | { | ||
| 1196 | struct drbd_conf *mdev = (struct drbd_conf *) data; | ||
| 1197 | struct drbd_request *req; /* oldest request */ | ||
| 1198 | struct list_head *le; | ||
| 1199 | unsigned long et = 0; /* effective timeout = ko_count * timeout */ | ||
| 1200 | |||
| 1201 | if (get_net_conf(mdev)) { | ||
| 1202 | et = mdev->net_conf->timeout*HZ/10 * mdev->net_conf->ko_count; | ||
| 1203 | put_net_conf(mdev); | ||
| 1204 | } | ||
| 1205 | if (!et || mdev->state.conn < C_WF_REPORT_PARAMS) | ||
| 1206 | return; /* Recurring timer stopped */ | ||
| 1207 | |||
| 1208 | spin_lock_irq(&mdev->req_lock); | ||
| 1209 | le = &mdev->oldest_tle->requests; | ||
| 1210 | if (list_empty(le)) { | ||
| 1211 | spin_unlock_irq(&mdev->req_lock); | ||
| 1212 | mod_timer(&mdev->request_timer, jiffies + et); | ||
| 1213 | return; | ||
| 1214 | } | ||
| 1215 | |||
| 1216 | le = le->prev; | ||
| 1217 | req = list_entry(le, struct drbd_request, tl_requests); | ||
| 1218 | if (time_is_before_eq_jiffies(req->start_time + et)) { | ||
| 1219 | if (req->rq_state & RQ_NET_PENDING) { | ||
| 1220 | dev_warn(DEV, "Remote failed to finish a request within ko-count * timeout\n"); | ||
| 1221 | _drbd_set_state(_NS(mdev, conn, C_TIMEOUT), CS_VERBOSE, NULL); | ||
| 1222 | } else { | ||
| 1223 | dev_warn(DEV, "Local backing block device frozen?\n"); | ||
| 1224 | mod_timer(&mdev->request_timer, jiffies + et); | ||
| 1225 | } | ||
| 1226 | } else { | ||
| 1227 | mod_timer(&mdev->request_timer, req->start_time + et); | ||
| 1228 | } | ||
| 1229 | |||
| 1230 | spin_unlock_irq(&mdev->req_lock); | ||
| 1231 | } | ||
diff --git a/drivers/block/drbd/drbd_req.h b/drivers/block/drbd/drbd_req.h index ab2bd09d54b..32e2c3e6a81 100644 --- a/drivers/block/drbd/drbd_req.h +++ b/drivers/block/drbd/drbd_req.h | |||
| @@ -82,14 +82,16 @@ enum drbd_req_event { | |||
| 82 | to_be_submitted, | 82 | to_be_submitted, |
| 83 | 83 | ||
| 84 | /* XXX yes, now I am inconsistent... | 84 | /* XXX yes, now I am inconsistent... |
| 85 | * these two are not "events" but "actions" | 85 | * these are not "events" but "actions" |
| 86 | * oh, well... */ | 86 | * oh, well... */ |
| 87 | queue_for_net_write, | 87 | queue_for_net_write, |
| 88 | queue_for_net_read, | 88 | queue_for_net_read, |
| 89 | queue_for_send_oos, | ||
| 89 | 90 | ||
| 90 | send_canceled, | 91 | send_canceled, |
| 91 | send_failed, | 92 | send_failed, |
| 92 | handed_over_to_network, | 93 | handed_over_to_network, |
| 94 | oos_handed_to_network, | ||
| 93 | connection_lost_while_pending, | 95 | connection_lost_while_pending, |
| 94 | read_retry_remote_canceled, | 96 | read_retry_remote_canceled, |
| 95 | recv_acked_by_peer, | 97 | recv_acked_by_peer, |
| @@ -289,7 +291,6 @@ static inline struct drbd_request *drbd_req_new(struct drbd_conf *mdev, | |||
| 289 | req->epoch = 0; | 291 | req->epoch = 0; |
| 290 | req->sector = bio_src->bi_sector; | 292 | req->sector = bio_src->bi_sector; |
| 291 | req->size = bio_src->bi_size; | 293 | req->size = bio_src->bi_size; |
| 292 | req->start_time = jiffies; | ||
| 293 | INIT_HLIST_NODE(&req->colision); | 294 | INIT_HLIST_NODE(&req->colision); |
| 294 | INIT_LIST_HEAD(&req->tl_requests); | 295 | INIT_LIST_HEAD(&req->tl_requests); |
| 295 | INIT_LIST_HEAD(&req->w.list); | 296 | INIT_LIST_HEAD(&req->w.list); |
| @@ -321,6 +322,7 @@ extern int __req_mod(struct drbd_request *req, enum drbd_req_event what, | |||
| 321 | struct bio_and_error *m); | 322 | struct bio_and_error *m); |
| 322 | extern void complete_master_bio(struct drbd_conf *mdev, | 323 | extern void complete_master_bio(struct drbd_conf *mdev, |
| 323 | struct bio_and_error *m); | 324 | struct bio_and_error *m); |
| 325 | extern void request_timer_fn(unsigned long data); | ||
| 324 | 326 | ||
| 325 | /* use this if you don't want to deal with calling complete_master_bio() | 327 | /* use this if you don't want to deal with calling complete_master_bio() |
| 326 | * outside the spinlock, e.g. when walking some list on cleanup. */ | 328 | * outside the spinlock, e.g. when walking some list on cleanup. */ |
| @@ -338,23 +340,43 @@ static inline int _req_mod(struct drbd_request *req, enum drbd_req_event what) | |||
| 338 | return rv; | 340 | return rv; |
| 339 | } | 341 | } |
| 340 | 342 | ||
| 341 | /* completion of master bio is outside of spinlock. | 343 | /* completion of master bio is outside of our spinlock. |
| 342 | * If you need it irqsave, do it your self! | 344 | * We still may or may not be inside some irqs disabled section |
| 343 | * Which means: don't use from bio endio callback. */ | 345 | * of the lower level driver completion callback, so we need to |
| 346 | * spin_lock_irqsave here. */ | ||
| 344 | static inline int req_mod(struct drbd_request *req, | 347 | static inline int req_mod(struct drbd_request *req, |
| 345 | enum drbd_req_event what) | 348 | enum drbd_req_event what) |
| 346 | { | 349 | { |
| 350 | unsigned long flags; | ||
| 347 | struct drbd_conf *mdev = req->mdev; | 351 | struct drbd_conf *mdev = req->mdev; |
| 348 | struct bio_and_error m; | 352 | struct bio_and_error m; |
| 349 | int rv; | 353 | int rv; |
| 350 | 354 | ||
| 351 | spin_lock_irq(&mdev->req_lock); | 355 | spin_lock_irqsave(&mdev->req_lock, flags); |
| 352 | rv = __req_mod(req, what, &m); | 356 | rv = __req_mod(req, what, &m); |
| 353 | spin_unlock_irq(&mdev->req_lock); | 357 | spin_unlock_irqrestore(&mdev->req_lock, flags); |
| 354 | 358 | ||
| 355 | if (m.bio) | 359 | if (m.bio) |
| 356 | complete_master_bio(mdev, &m); | 360 | complete_master_bio(mdev, &m); |
| 357 | 361 | ||
| 358 | return rv; | 362 | return rv; |
| 359 | } | 363 | } |
| 364 | |||
| 365 | static inline bool drbd_should_do_remote(union drbd_state s) | ||
| 366 | { | ||
| 367 | return s.pdsk == D_UP_TO_DATE || | ||
| 368 | (s.pdsk >= D_INCONSISTENT && | ||
| 369 | s.conn >= C_WF_BITMAP_T && | ||
| 370 | s.conn < C_AHEAD); | ||
| 371 | /* Before proto 96 that was >= CONNECTED instead of >= C_WF_BITMAP_T. | ||
| 372 | That is equivalent since before 96 IO was frozen in the C_WF_BITMAP* | ||
| 373 | states. */ | ||
| 374 | } | ||
| 375 | static inline bool drbd_should_send_oos(union drbd_state s) | ||
| 376 | { | ||
| 377 | return s.conn == C_AHEAD || s.conn == C_WF_BITMAP_S; | ||
| 378 | /* pdsk = D_INCONSISTENT as a consequence. Protocol 96 check not necessary | ||
| 379 | since we enter state C_AHEAD only if proto >= 96 */ | ||
| 380 | } | ||
| 381 | |||
| 360 | #endif | 382 | #endif |
diff --git a/drivers/block/drbd/drbd_strings.c b/drivers/block/drbd/drbd_strings.c index 85179e1fb50..c44a2a60277 100644 --- a/drivers/block/drbd/drbd_strings.c +++ b/drivers/block/drbd/drbd_strings.c | |||
| @@ -48,6 +48,8 @@ static const char *drbd_conn_s_names[] = { | |||
| 48 | [C_PAUSED_SYNC_T] = "PausedSyncT", | 48 | [C_PAUSED_SYNC_T] = "PausedSyncT", |
| 49 | [C_VERIFY_S] = "VerifyS", | 49 | [C_VERIFY_S] = "VerifyS", |
| 50 | [C_VERIFY_T] = "VerifyT", | 50 | [C_VERIFY_T] = "VerifyT", |
| 51 | [C_AHEAD] = "Ahead", | ||
| 52 | [C_BEHIND] = "Behind", | ||
| 51 | }; | 53 | }; |
| 52 | 54 | ||
| 53 | static const char *drbd_role_s_names[] = { | 55 | static const char *drbd_role_s_names[] = { |
| @@ -92,7 +94,7 @@ static const char *drbd_state_sw_errors[] = { | |||
| 92 | const char *drbd_conn_str(enum drbd_conns s) | 94 | const char *drbd_conn_str(enum drbd_conns s) |
| 93 | { | 95 | { |
| 94 | /* enums are unsigned... */ | 96 | /* enums are unsigned... */ |
| 95 | return s > C_PAUSED_SYNC_T ? "TOO_LARGE" : drbd_conn_s_names[s]; | 97 | return s > C_BEHIND ? "TOO_LARGE" : drbd_conn_s_names[s]; |
| 96 | } | 98 | } |
| 97 | 99 | ||
| 98 | const char *drbd_role_str(enum drbd_role s) | 100 | const char *drbd_role_str(enum drbd_role s) |
| @@ -105,7 +107,7 @@ const char *drbd_disk_str(enum drbd_disk_state s) | |||
| 105 | return s > D_UP_TO_DATE ? "TOO_LARGE" : drbd_disk_s_names[s]; | 107 | return s > D_UP_TO_DATE ? "TOO_LARGE" : drbd_disk_s_names[s]; |
| 106 | } | 108 | } |
| 107 | 109 | ||
| 108 | const char *drbd_set_st_err_str(enum drbd_state_ret_codes err) | 110 | const char *drbd_set_st_err_str(enum drbd_state_rv err) |
| 109 | { | 111 | { |
| 110 | return err <= SS_AFTER_LAST_ERROR ? "TOO_SMALL" : | 112 | return err <= SS_AFTER_LAST_ERROR ? "TOO_SMALL" : |
| 111 | err > SS_TWO_PRIMARIES ? "TOO_LARGE" | 113 | err > SS_TWO_PRIMARIES ? "TOO_LARGE" |
diff --git a/drivers/block/drbd/drbd_worker.c b/drivers/block/drbd/drbd_worker.c index e027446590d..f7e6c92f8d0 100644 --- a/drivers/block/drbd/drbd_worker.c +++ b/drivers/block/drbd/drbd_worker.c | |||
| @@ -39,18 +39,17 @@ | |||
| 39 | #include "drbd_req.h" | 39 | #include "drbd_req.h" |
| 40 | 40 | ||
| 41 | static int w_make_ov_request(struct drbd_conf *mdev, struct drbd_work *w, int cancel); | 41 | static int w_make_ov_request(struct drbd_conf *mdev, struct drbd_work *w, int cancel); |
| 42 | static int w_make_resync_request(struct drbd_conf *mdev, | ||
| 43 | struct drbd_work *w, int cancel); | ||
| 42 | 44 | ||
| 43 | 45 | ||
| 44 | 46 | ||
| 45 | /* defined here: | 47 | /* endio handlers: |
| 46 | drbd_md_io_complete | 48 | * drbd_md_io_complete (defined here) |
| 47 | drbd_endio_sec | 49 | * drbd_endio_pri (defined here) |
| 48 | drbd_endio_pri | 50 | * drbd_endio_sec (defined here) |
| 49 | 51 | * bm_async_io_complete (defined in drbd_bitmap.c) | |
| 50 | * more endio handlers: | 52 | * |
| 51 | atodb_endio in drbd_actlog.c | ||
| 52 | drbd_bm_async_io_complete in drbd_bitmap.c | ||
| 53 | |||
| 54 | * For all these callbacks, note the following: | 53 | * For all these callbacks, note the following: |
| 55 | * The callbacks will be called in irq context by the IDE drivers, | 54 | * The callbacks will be called in irq context by the IDE drivers, |
| 56 | * and in Softirqs/Tasklets/BH context by the SCSI drivers. | 55 | * and in Softirqs/Tasklets/BH context by the SCSI drivers. |
| @@ -94,7 +93,7 @@ void drbd_endio_read_sec_final(struct drbd_epoch_entry *e) __releases(local) | |||
| 94 | if (list_empty(&mdev->read_ee)) | 93 | if (list_empty(&mdev->read_ee)) |
| 95 | wake_up(&mdev->ee_wait); | 94 | wake_up(&mdev->ee_wait); |
| 96 | if (test_bit(__EE_WAS_ERROR, &e->flags)) | 95 | if (test_bit(__EE_WAS_ERROR, &e->flags)) |
| 97 | __drbd_chk_io_error(mdev, FALSE); | 96 | __drbd_chk_io_error(mdev, false); |
| 98 | spin_unlock_irqrestore(&mdev->req_lock, flags); | 97 | spin_unlock_irqrestore(&mdev->req_lock, flags); |
| 99 | 98 | ||
| 100 | drbd_queue_work(&mdev->data.work, &e->w); | 99 | drbd_queue_work(&mdev->data.work, &e->w); |
| @@ -137,7 +136,7 @@ static void drbd_endio_write_sec_final(struct drbd_epoch_entry *e) __releases(lo | |||
| 137 | : list_empty(&mdev->active_ee); | 136 | : list_empty(&mdev->active_ee); |
| 138 | 137 | ||
| 139 | if (test_bit(__EE_WAS_ERROR, &e->flags)) | 138 | if (test_bit(__EE_WAS_ERROR, &e->flags)) |
| 140 | __drbd_chk_io_error(mdev, FALSE); | 139 | __drbd_chk_io_error(mdev, false); |
| 141 | spin_unlock_irqrestore(&mdev->req_lock, flags); | 140 | spin_unlock_irqrestore(&mdev->req_lock, flags); |
| 142 | 141 | ||
| 143 | if (is_syncer_req) | 142 | if (is_syncer_req) |
| @@ -163,14 +162,15 @@ void drbd_endio_sec(struct bio *bio, int error) | |||
| 163 | int uptodate = bio_flagged(bio, BIO_UPTODATE); | 162 | int uptodate = bio_flagged(bio, BIO_UPTODATE); |
| 164 | int is_write = bio_data_dir(bio) == WRITE; | 163 | int is_write = bio_data_dir(bio) == WRITE; |
| 165 | 164 | ||
| 166 | if (error) | 165 | if (error && __ratelimit(&drbd_ratelimit_state)) |
| 167 | dev_warn(DEV, "%s: error=%d s=%llus\n", | 166 | dev_warn(DEV, "%s: error=%d s=%llus\n", |
| 168 | is_write ? "write" : "read", error, | 167 | is_write ? "write" : "read", error, |
| 169 | (unsigned long long)e->sector); | 168 | (unsigned long long)e->sector); |
| 170 | if (!error && !uptodate) { | 169 | if (!error && !uptodate) { |
| 171 | dev_warn(DEV, "%s: setting error to -EIO s=%llus\n", | 170 | if (__ratelimit(&drbd_ratelimit_state)) |
| 172 | is_write ? "write" : "read", | 171 | dev_warn(DEV, "%s: setting error to -EIO s=%llus\n", |
| 173 | (unsigned long long)e->sector); | 172 | is_write ? "write" : "read", |
| 173 | (unsigned long long)e->sector); | ||
| 174 | /* strange behavior of some lower level drivers... | 174 | /* strange behavior of some lower level drivers... |
| 175 | * fail the request by clearing the uptodate flag, | 175 | * fail the request by clearing the uptodate flag, |
| 176 | * but do not return any error?! */ | 176 | * but do not return any error?! */ |
| @@ -250,13 +250,6 @@ int w_read_retry_remote(struct drbd_conf *mdev, struct drbd_work *w, int cancel) | |||
| 250 | return w_send_read_req(mdev, w, 0); | 250 | return w_send_read_req(mdev, w, 0); |
| 251 | } | 251 | } |
| 252 | 252 | ||
| 253 | int w_resync_inactive(struct drbd_conf *mdev, struct drbd_work *w, int cancel) | ||
| 254 | { | ||
| 255 | ERR_IF(cancel) return 1; | ||
| 256 | dev_err(DEV, "resync inactive, but callback triggered??\n"); | ||
| 257 | return 1; /* Simply ignore this! */ | ||
| 258 | } | ||
| 259 | |||
| 260 | void drbd_csum_ee(struct drbd_conf *mdev, struct crypto_hash *tfm, struct drbd_epoch_entry *e, void *digest) | 253 | void drbd_csum_ee(struct drbd_conf *mdev, struct crypto_hash *tfm, struct drbd_epoch_entry *e, void *digest) |
| 261 | { | 254 | { |
| 262 | struct hash_desc desc; | 255 | struct hash_desc desc; |
| @@ -355,7 +348,7 @@ static int read_for_csum(struct drbd_conf *mdev, sector_t sector, int size) | |||
| 355 | if (!get_ldev(mdev)) | 348 | if (!get_ldev(mdev)) |
| 356 | return -EIO; | 349 | return -EIO; |
| 357 | 350 | ||
| 358 | if (drbd_rs_should_slow_down(mdev)) | 351 | if (drbd_rs_should_slow_down(mdev, sector)) |
| 359 | goto defer; | 352 | goto defer; |
| 360 | 353 | ||
| 361 | /* GFP_TRY, because if there is no memory available right now, this may | 354 | /* GFP_TRY, because if there is no memory available right now, this may |
| @@ -373,9 +366,10 @@ static int read_for_csum(struct drbd_conf *mdev, sector_t sector, int size) | |||
| 373 | if (drbd_submit_ee(mdev, e, READ, DRBD_FAULT_RS_RD) == 0) | 366 | if (drbd_submit_ee(mdev, e, READ, DRBD_FAULT_RS_RD) == 0) |
| 374 | return 0; | 367 | return 0; |
| 375 | 368 | ||
| 376 | /* drbd_submit_ee currently fails for one reason only: | 369 | /* If it failed because of ENOMEM, retry should help. If it failed |
| 377 | * not being able to allocate enough bios. | 370 | * because bio_add_page failed (probably broken lower level driver), |
| 378 | * Is dropping the connection going to help? */ | 371 | * retry may or may not help. |
| 372 | * If it does not, you may need to force disconnect. */ | ||
| 379 | spin_lock_irq(&mdev->req_lock); | 373 | spin_lock_irq(&mdev->req_lock); |
| 380 | list_del(&e->w.list); | 374 | list_del(&e->w.list); |
| 381 | spin_unlock_irq(&mdev->req_lock); | 375 | spin_unlock_irq(&mdev->req_lock); |
| @@ -386,26 +380,25 @@ defer: | |||
| 386 | return -EAGAIN; | 380 | return -EAGAIN; |
| 387 | } | 381 | } |
| 388 | 382 | ||
| 389 | void resync_timer_fn(unsigned long data) | 383 | int w_resync_timer(struct drbd_conf *mdev, struct drbd_work *w, int cancel) |
| 390 | { | 384 | { |
| 391 | struct drbd_conf *mdev = (struct drbd_conf *) data; | ||
| 392 | int queue; | ||
| 393 | |||
| 394 | queue = 1; | ||
| 395 | switch (mdev->state.conn) { | 385 | switch (mdev->state.conn) { |
| 396 | case C_VERIFY_S: | 386 | case C_VERIFY_S: |
| 397 | mdev->resync_work.cb = w_make_ov_request; | 387 | w_make_ov_request(mdev, w, cancel); |
| 398 | break; | 388 | break; |
| 399 | case C_SYNC_TARGET: | 389 | case C_SYNC_TARGET: |
| 400 | mdev->resync_work.cb = w_make_resync_request; | 390 | w_make_resync_request(mdev, w, cancel); |
| 401 | break; | 391 | break; |
| 402 | default: | ||
| 403 | queue = 0; | ||
| 404 | mdev->resync_work.cb = w_resync_inactive; | ||
| 405 | } | 392 | } |
| 406 | 393 | ||
| 407 | /* harmless race: list_empty outside data.work.q_lock */ | 394 | return 1; |
| 408 | if (list_empty(&mdev->resync_work.list) && queue) | 395 | } |
| 396 | |||
| 397 | void resync_timer_fn(unsigned long data) | ||
| 398 | { | ||
| 399 | struct drbd_conf *mdev = (struct drbd_conf *) data; | ||
| 400 | |||
| 401 | if (list_empty(&mdev->resync_work.list)) | ||
| 409 | drbd_queue_work(&mdev->data.work, &mdev->resync_work); | 402 | drbd_queue_work(&mdev->data.work, &mdev->resync_work); |
| 410 | } | 403 | } |
| 411 | 404 | ||
| @@ -438,7 +431,7 @@ static void fifo_add_val(struct fifo_buffer *fb, int value) | |||
| 438 | fb->values[i] += value; | 431 | fb->values[i] += value; |
| 439 | } | 432 | } |
| 440 | 433 | ||
| 441 | int drbd_rs_controller(struct drbd_conf *mdev) | 434 | static int drbd_rs_controller(struct drbd_conf *mdev) |
| 442 | { | 435 | { |
| 443 | unsigned int sect_in; /* Number of sectors that came in since the last turn */ | 436 | unsigned int sect_in; /* Number of sectors that came in since the last turn */ |
| 444 | unsigned int want; /* The number of sectors we want in the proxy */ | 437 | unsigned int want; /* The number of sectors we want in the proxy */ |
| @@ -492,29 +485,36 @@ int drbd_rs_controller(struct drbd_conf *mdev) | |||
| 492 | return req_sect; | 485 | return req_sect; |
| 493 | } | 486 | } |
| 494 | 487 | ||
| 495 | int w_make_resync_request(struct drbd_conf *mdev, | 488 | static int drbd_rs_number_requests(struct drbd_conf *mdev) |
| 496 | struct drbd_work *w, int cancel) | 489 | { |
| 490 | int number; | ||
| 491 | if (mdev->rs_plan_s.size) { /* mdev->sync_conf.c_plan_ahead */ | ||
| 492 | number = drbd_rs_controller(mdev) >> (BM_BLOCK_SHIFT - 9); | ||
| 493 | mdev->c_sync_rate = number * HZ * (BM_BLOCK_SIZE / 1024) / SLEEP_TIME; | ||
| 494 | } else { | ||
| 495 | mdev->c_sync_rate = mdev->sync_conf.rate; | ||
| 496 | number = SLEEP_TIME * mdev->c_sync_rate / ((BM_BLOCK_SIZE / 1024) * HZ); | ||
| 497 | } | ||
| 498 | |||
| 499 | /* ignore the amount of pending requests, the resync controller should | ||
| 500 | * throttle down to incoming reply rate soon enough anyways. */ | ||
| 501 | return number; | ||
| 502 | } | ||
| 503 | |||
| 504 | static int w_make_resync_request(struct drbd_conf *mdev, | ||
| 505 | struct drbd_work *w, int cancel) | ||
| 497 | { | 506 | { |
| 498 | unsigned long bit; | 507 | unsigned long bit; |
| 499 | sector_t sector; | 508 | sector_t sector; |
| 500 | const sector_t capacity = drbd_get_capacity(mdev->this_bdev); | 509 | const sector_t capacity = drbd_get_capacity(mdev->this_bdev); |
| 501 | int max_segment_size; | 510 | int max_bio_size; |
| 502 | int number, rollback_i, size, pe, mx; | 511 | int number, rollback_i, size; |
| 503 | int align, queued, sndbuf; | 512 | int align, queued, sndbuf; |
| 504 | int i = 0; | 513 | int i = 0; |
| 505 | 514 | ||
| 506 | if (unlikely(cancel)) | 515 | if (unlikely(cancel)) |
| 507 | return 1; | 516 | return 1; |
| 508 | 517 | ||
| 509 | if (unlikely(mdev->state.conn < C_CONNECTED)) { | ||
| 510 | dev_err(DEV, "Confused in w_make_resync_request()! cstate < Connected"); | ||
| 511 | return 0; | ||
| 512 | } | ||
| 513 | |||
| 514 | if (mdev->state.conn != C_SYNC_TARGET) | ||
| 515 | dev_err(DEV, "%s in w_make_resync_request\n", | ||
| 516 | drbd_conn_str(mdev->state.conn)); | ||
| 517 | |||
| 518 | if (mdev->rs_total == 0) { | 518 | if (mdev->rs_total == 0) { |
| 519 | /* empty resync? */ | 519 | /* empty resync? */ |
| 520 | drbd_resync_finished(mdev); | 520 | drbd_resync_finished(mdev); |
| @@ -527,49 +527,19 @@ int w_make_resync_request(struct drbd_conf *mdev, | |||
| 527 | to continue resync with a broken disk makes no sense at | 527 | to continue resync with a broken disk makes no sense at |
| 528 | all */ | 528 | all */ |
| 529 | dev_err(DEV, "Disk broke down during resync!\n"); | 529 | dev_err(DEV, "Disk broke down during resync!\n"); |
| 530 | mdev->resync_work.cb = w_resync_inactive; | ||
| 531 | return 1; | 530 | return 1; |
| 532 | } | 531 | } |
| 533 | 532 | ||
| 534 | /* starting with drbd 8.3.8, we can handle multi-bio EEs, | 533 | /* starting with drbd 8.3.8, we can handle multi-bio EEs, |
| 535 | * if it should be necessary */ | 534 | * if it should be necessary */ |
| 536 | max_segment_size = | 535 | max_bio_size = |
| 537 | mdev->agreed_pro_version < 94 ? queue_max_segment_size(mdev->rq_queue) : | 536 | mdev->agreed_pro_version < 94 ? queue_max_hw_sectors(mdev->rq_queue) << 9 : |
| 538 | mdev->agreed_pro_version < 95 ? DRBD_MAX_SIZE_H80_PACKET : DRBD_MAX_SEGMENT_SIZE; | 537 | mdev->agreed_pro_version < 95 ? DRBD_MAX_SIZE_H80_PACKET : DRBD_MAX_BIO_SIZE; |
| 539 | 538 | ||
| 540 | if (mdev->rs_plan_s.size) { /* mdev->sync_conf.c_plan_ahead */ | 539 | number = drbd_rs_number_requests(mdev); |
| 541 | number = drbd_rs_controller(mdev) >> (BM_BLOCK_SHIFT - 9); | 540 | if (number == 0) |
| 542 | mdev->c_sync_rate = number * HZ * (BM_BLOCK_SIZE / 1024) / SLEEP_TIME; | ||
| 543 | } else { | ||
| 544 | mdev->c_sync_rate = mdev->sync_conf.rate; | ||
| 545 | number = SLEEP_TIME * mdev->c_sync_rate / ((BM_BLOCK_SIZE / 1024) * HZ); | ||
| 546 | } | ||
| 547 | |||
| 548 | /* Throttle resync on lower level disk activity, which may also be | ||
| 549 | * caused by application IO on Primary/SyncTarget. | ||
| 550 | * Keep this after the call to drbd_rs_controller, as that assumes | ||
| 551 | * to be called as precisely as possible every SLEEP_TIME, | ||
| 552 | * and would be confused otherwise. */ | ||
| 553 | if (drbd_rs_should_slow_down(mdev)) | ||
| 554 | goto requeue; | 541 | goto requeue; |
| 555 | 542 | ||
| 556 | mutex_lock(&mdev->data.mutex); | ||
| 557 | if (mdev->data.socket) | ||
| 558 | mx = mdev->data.socket->sk->sk_rcvbuf / sizeof(struct p_block_req); | ||
| 559 | else | ||
| 560 | mx = 1; | ||
| 561 | mutex_unlock(&mdev->data.mutex); | ||
| 562 | |||
| 563 | /* For resync rates >160MB/sec, allow more pending RS requests */ | ||
| 564 | if (number > mx) | ||
| 565 | mx = number; | ||
| 566 | |||
| 567 | /* Limit the number of pending RS requests to no more than the peer's receive buffer */ | ||
| 568 | pe = atomic_read(&mdev->rs_pending_cnt); | ||
| 569 | if ((pe + number) > mx) { | ||
| 570 | number = mx - pe; | ||
| 571 | } | ||
| 572 | |||
| 573 | for (i = 0; i < number; i++) { | 543 | for (i = 0; i < number; i++) { |
| 574 | /* Stop generating RS requests, when half of the send buffer is filled */ | 544 | /* Stop generating RS requests, when half of the send buffer is filled */ |
| 575 | mutex_lock(&mdev->data.mutex); | 545 | mutex_lock(&mdev->data.mutex); |
| @@ -588,16 +558,16 @@ next_sector: | |||
| 588 | size = BM_BLOCK_SIZE; | 558 | size = BM_BLOCK_SIZE; |
| 589 | bit = drbd_bm_find_next(mdev, mdev->bm_resync_fo); | 559 | bit = drbd_bm_find_next(mdev, mdev->bm_resync_fo); |
| 590 | 560 | ||
| 591 | if (bit == -1UL) { | 561 | if (bit == DRBD_END_OF_BITMAP) { |
| 592 | mdev->bm_resync_fo = drbd_bm_bits(mdev); | 562 | mdev->bm_resync_fo = drbd_bm_bits(mdev); |
| 593 | mdev->resync_work.cb = w_resync_inactive; | ||
| 594 | put_ldev(mdev); | 563 | put_ldev(mdev); |
| 595 | return 1; | 564 | return 1; |
| 596 | } | 565 | } |
| 597 | 566 | ||
| 598 | sector = BM_BIT_TO_SECT(bit); | 567 | sector = BM_BIT_TO_SECT(bit); |
| 599 | 568 | ||
| 600 | if (drbd_try_rs_begin_io(mdev, sector)) { | 569 | if (drbd_rs_should_slow_down(mdev, sector) || |
| 570 | drbd_try_rs_begin_io(mdev, sector)) { | ||
| 601 | mdev->bm_resync_fo = bit; | 571 | mdev->bm_resync_fo = bit; |
| 602 | goto requeue; | 572 | goto requeue; |
| 603 | } | 573 | } |
| @@ -608,7 +578,7 @@ next_sector: | |||
| 608 | goto next_sector; | 578 | goto next_sector; |
| 609 | } | 579 | } |
| 610 | 580 | ||
| 611 | #if DRBD_MAX_SEGMENT_SIZE > BM_BLOCK_SIZE | 581 | #if DRBD_MAX_BIO_SIZE > BM_BLOCK_SIZE |
| 612 | /* try to find some adjacent bits. | 582 | /* try to find some adjacent bits. |
| 613 | * we stop if we have already the maximum req size. | 583 | * we stop if we have already the maximum req size. |
| 614 | * | 584 | * |
| @@ -618,7 +588,7 @@ next_sector: | |||
| 618 | align = 1; | 588 | align = 1; |
| 619 | rollback_i = i; | 589 | rollback_i = i; |
| 620 | for (;;) { | 590 | for (;;) { |
| 621 | if (size + BM_BLOCK_SIZE > max_segment_size) | 591 | if (size + BM_BLOCK_SIZE > max_bio_size) |
| 622 | break; | 592 | break; |
| 623 | 593 | ||
| 624 | /* Be always aligned */ | 594 | /* Be always aligned */ |
| @@ -685,7 +655,6 @@ next_sector: | |||
| 685 | * resync data block, and the last bit is cleared. | 655 | * resync data block, and the last bit is cleared. |
| 686 | * until then resync "work" is "inactive" ... | 656 | * until then resync "work" is "inactive" ... |
| 687 | */ | 657 | */ |
| 688 | mdev->resync_work.cb = w_resync_inactive; | ||
| 689 | put_ldev(mdev); | 658 | put_ldev(mdev); |
| 690 | return 1; | 659 | return 1; |
| 691 | } | 660 | } |
| @@ -706,27 +675,18 @@ static int w_make_ov_request(struct drbd_conf *mdev, struct drbd_work *w, int ca | |||
| 706 | if (unlikely(cancel)) | 675 | if (unlikely(cancel)) |
| 707 | return 1; | 676 | return 1; |
| 708 | 677 | ||
| 709 | if (unlikely(mdev->state.conn < C_CONNECTED)) { | 678 | number = drbd_rs_number_requests(mdev); |
| 710 | dev_err(DEV, "Confused in w_make_ov_request()! cstate < Connected"); | ||
| 711 | return 0; | ||
| 712 | } | ||
| 713 | |||
| 714 | number = SLEEP_TIME*mdev->sync_conf.rate / ((BM_BLOCK_SIZE/1024)*HZ); | ||
| 715 | if (atomic_read(&mdev->rs_pending_cnt) > number) | ||
| 716 | goto requeue; | ||
| 717 | |||
| 718 | number -= atomic_read(&mdev->rs_pending_cnt); | ||
| 719 | 679 | ||
| 720 | sector = mdev->ov_position; | 680 | sector = mdev->ov_position; |
| 721 | for (i = 0; i < number; i++) { | 681 | for (i = 0; i < number; i++) { |
| 722 | if (sector >= capacity) { | 682 | if (sector >= capacity) { |
| 723 | mdev->resync_work.cb = w_resync_inactive; | ||
| 724 | return 1; | 683 | return 1; |
| 725 | } | 684 | } |
| 726 | 685 | ||
| 727 | size = BM_BLOCK_SIZE; | 686 | size = BM_BLOCK_SIZE; |
| 728 | 687 | ||
| 729 | if (drbd_try_rs_begin_io(mdev, sector)) { | 688 | if (drbd_rs_should_slow_down(mdev, sector) || |
| 689 | drbd_try_rs_begin_io(mdev, sector)) { | ||
| 730 | mdev->ov_position = sector; | 690 | mdev->ov_position = sector; |
| 731 | goto requeue; | 691 | goto requeue; |
| 732 | } | 692 | } |
| @@ -744,11 +704,33 @@ static int w_make_ov_request(struct drbd_conf *mdev, struct drbd_work *w, int ca | |||
| 744 | mdev->ov_position = sector; | 704 | mdev->ov_position = sector; |
| 745 | 705 | ||
| 746 | requeue: | 706 | requeue: |
| 707 | mdev->rs_in_flight += (i << (BM_BLOCK_SHIFT - 9)); | ||
| 747 | mod_timer(&mdev->resync_timer, jiffies + SLEEP_TIME); | 708 | mod_timer(&mdev->resync_timer, jiffies + SLEEP_TIME); |
| 748 | return 1; | 709 | return 1; |
| 749 | } | 710 | } |
| 750 | 711 | ||
| 751 | 712 | ||
| 713 | void start_resync_timer_fn(unsigned long data) | ||
| 714 | { | ||
| 715 | struct drbd_conf *mdev = (struct drbd_conf *) data; | ||
| 716 | |||
| 717 | drbd_queue_work(&mdev->data.work, &mdev->start_resync_work); | ||
| 718 | } | ||
| 719 | |||
| 720 | int w_start_resync(struct drbd_conf *mdev, struct drbd_work *w, int cancel) | ||
| 721 | { | ||
| 722 | if (atomic_read(&mdev->unacked_cnt) || atomic_read(&mdev->rs_pending_cnt)) { | ||
| 723 | dev_warn(DEV, "w_start_resync later...\n"); | ||
| 724 | mdev->start_resync_timer.expires = jiffies + HZ/10; | ||
| 725 | add_timer(&mdev->start_resync_timer); | ||
| 726 | return 1; | ||
| 727 | } | ||
| 728 | |||
| 729 | drbd_start_resync(mdev, C_SYNC_SOURCE); | ||
| 730 | clear_bit(AHEAD_TO_SYNC_SOURCE, &mdev->current_epoch->flags); | ||
| 731 | return 1; | ||
| 732 | } | ||
| 733 | |||
| 752 | int w_ov_finished(struct drbd_conf *mdev, struct drbd_work *w, int cancel) | 734 | int w_ov_finished(struct drbd_conf *mdev, struct drbd_work *w, int cancel) |
| 753 | { | 735 | { |
| 754 | kfree(w); | 736 | kfree(w); |
| @@ -782,6 +764,7 @@ int drbd_resync_finished(struct drbd_conf *mdev) | |||
| 782 | union drbd_state os, ns; | 764 | union drbd_state os, ns; |
| 783 | struct drbd_work *w; | 765 | struct drbd_work *w; |
| 784 | char *khelper_cmd = NULL; | 766 | char *khelper_cmd = NULL; |
| 767 | int verify_done = 0; | ||
| 785 | 768 | ||
| 786 | /* Remove all elements from the resync LRU. Since future actions | 769 | /* Remove all elements from the resync LRU. Since future actions |
| 787 | * might set bits in the (main) bitmap, then the entries in the | 770 | * might set bits in the (main) bitmap, then the entries in the |
| @@ -792,8 +775,7 @@ int drbd_resync_finished(struct drbd_conf *mdev) | |||
| 792 | * queue (or even the read operations for those packets | 775 | * queue (or even the read operations for those packets |
| 793 | * is not finished by now). Retry in 100ms. */ | 776 | * is not finished by now). Retry in 100ms. */ |
| 794 | 777 | ||
| 795 | __set_current_state(TASK_INTERRUPTIBLE); | 778 | schedule_timeout_interruptible(HZ / 10); |
| 796 | schedule_timeout(HZ / 10); | ||
| 797 | w = kmalloc(sizeof(struct drbd_work), GFP_ATOMIC); | 779 | w = kmalloc(sizeof(struct drbd_work), GFP_ATOMIC); |
| 798 | if (w) { | 780 | if (w) { |
| 799 | w->cb = w_resync_finished; | 781 | w->cb = w_resync_finished; |
| @@ -818,6 +800,8 @@ int drbd_resync_finished(struct drbd_conf *mdev) | |||
| 818 | spin_lock_irq(&mdev->req_lock); | 800 | spin_lock_irq(&mdev->req_lock); |
| 819 | os = mdev->state; | 801 | os = mdev->state; |
| 820 | 802 | ||
| 803 | verify_done = (os.conn == C_VERIFY_S || os.conn == C_VERIFY_T); | ||
| 804 | |||
| 821 | /* This protects us against multiple calls (that can happen in the presence | 805 | /* This protects us against multiple calls (that can happen in the presence |
| 822 | of application IO), and against connectivity loss just before we arrive here. */ | 806 | of application IO), and against connectivity loss just before we arrive here. */ |
| 823 | if (os.conn <= C_CONNECTED) | 807 | if (os.conn <= C_CONNECTED) |
| @@ -827,8 +811,7 @@ int drbd_resync_finished(struct drbd_conf *mdev) | |||
| 827 | ns.conn = C_CONNECTED; | 811 | ns.conn = C_CONNECTED; |
| 828 | 812 | ||
| 829 | dev_info(DEV, "%s done (total %lu sec; paused %lu sec; %lu K/sec)\n", | 813 | dev_info(DEV, "%s done (total %lu sec; paused %lu sec; %lu K/sec)\n", |
| 830 | (os.conn == C_VERIFY_S || os.conn == C_VERIFY_T) ? | 814 | verify_done ? "Online verify " : "Resync", |
| 831 | "Online verify " : "Resync", | ||
| 832 | dt + mdev->rs_paused, mdev->rs_paused, dbdt); | 815 | dt + mdev->rs_paused, mdev->rs_paused, dbdt); |
| 833 | 816 | ||
| 834 | n_oos = drbd_bm_total_weight(mdev); | 817 | n_oos = drbd_bm_total_weight(mdev); |
| @@ -886,14 +869,18 @@ int drbd_resync_finished(struct drbd_conf *mdev) | |||
| 886 | } | 869 | } |
| 887 | } | 870 | } |
| 888 | 871 | ||
| 889 | drbd_uuid_set_bm(mdev, 0UL); | 872 | if (!(os.conn == C_VERIFY_S || os.conn == C_VERIFY_T)) { |
| 890 | 873 | /* for verify runs, we don't update uuids here, | |
| 891 | if (mdev->p_uuid) { | 874 | * so there would be nothing to report. */ |
| 892 | /* Now the two UUID sets are equal, update what we | 875 | drbd_uuid_set_bm(mdev, 0UL); |
| 893 | * know of the peer. */ | 876 | drbd_print_uuids(mdev, "updated UUIDs"); |
| 894 | int i; | 877 | if (mdev->p_uuid) { |
| 895 | for (i = UI_CURRENT ; i <= UI_HISTORY_END ; i++) | 878 | /* Now the two UUID sets are equal, update what we |
| 896 | mdev->p_uuid[i] = mdev->ldev->md.uuid[i]; | 879 | * know of the peer. */ |
| 880 | int i; | ||
| 881 | for (i = UI_CURRENT ; i <= UI_HISTORY_END ; i++) | ||
| 882 | mdev->p_uuid[i] = mdev->ldev->md.uuid[i]; | ||
| 883 | } | ||
| 897 | } | 884 | } |
| 898 | } | 885 | } |
| 899 | 886 | ||
| @@ -905,15 +892,11 @@ out: | |||
| 905 | mdev->rs_total = 0; | 892 | mdev->rs_total = 0; |
| 906 | mdev->rs_failed = 0; | 893 | mdev->rs_failed = 0; |
| 907 | mdev->rs_paused = 0; | 894 | mdev->rs_paused = 0; |
| 908 | mdev->ov_start_sector = 0; | 895 | if (verify_done) |
| 896 | mdev->ov_start_sector = 0; | ||
| 909 | 897 | ||
| 910 | drbd_md_sync(mdev); | 898 | drbd_md_sync(mdev); |
| 911 | 899 | ||
| 912 | if (test_and_clear_bit(WRITE_BM_AFTER_RESYNC, &mdev->flags)) { | ||
| 913 | dev_info(DEV, "Writing the whole bitmap\n"); | ||
| 914 | drbd_queue_bitmap_io(mdev, &drbd_bm_write, NULL, "write from resync_finished"); | ||
| 915 | } | ||
| 916 | |||
| 917 | if (khelper_cmd) | 900 | if (khelper_cmd) |
| 918 | drbd_khelper(mdev, khelper_cmd); | 901 | drbd_khelper(mdev, khelper_cmd); |
| 919 | 902 | ||
| @@ -994,7 +977,9 @@ int w_e_end_rsdata_req(struct drbd_conf *mdev, struct drbd_work *w, int cancel) | |||
| 994 | put_ldev(mdev); | 977 | put_ldev(mdev); |
| 995 | } | 978 | } |
| 996 | 979 | ||
| 997 | if (likely((e->flags & EE_WAS_ERROR) == 0)) { | 980 | if (mdev->state.conn == C_AHEAD) { |
| 981 | ok = drbd_send_ack(mdev, P_RS_CANCEL, e); | ||
| 982 | } else if (likely((e->flags & EE_WAS_ERROR) == 0)) { | ||
| 998 | if (likely(mdev->state.pdsk >= D_INCONSISTENT)) { | 983 | if (likely(mdev->state.pdsk >= D_INCONSISTENT)) { |
| 999 | inc_rs_pending(mdev); | 984 | inc_rs_pending(mdev); |
| 1000 | ok = drbd_send_block(mdev, P_RS_DATA_REPLY, e); | 985 | ok = drbd_send_block(mdev, P_RS_DATA_REPLY, e); |
| @@ -1096,25 +1081,27 @@ int w_e_end_ov_req(struct drbd_conf *mdev, struct drbd_work *w, int cancel) | |||
| 1096 | if (unlikely(cancel)) | 1081 | if (unlikely(cancel)) |
| 1097 | goto out; | 1082 | goto out; |
| 1098 | 1083 | ||
| 1099 | if (unlikely((e->flags & EE_WAS_ERROR) != 0)) | ||
| 1100 | goto out; | ||
| 1101 | |||
| 1102 | digest_size = crypto_hash_digestsize(mdev->verify_tfm); | 1084 | digest_size = crypto_hash_digestsize(mdev->verify_tfm); |
| 1103 | /* FIXME if this allocation fails, online verify will not terminate! */ | ||
| 1104 | digest = kmalloc(digest_size, GFP_NOIO); | 1085 | digest = kmalloc(digest_size, GFP_NOIO); |
| 1105 | if (digest) { | 1086 | if (!digest) { |
| 1106 | drbd_csum_ee(mdev, mdev->verify_tfm, e, digest); | 1087 | ok = 0; /* terminate the connection in case the allocation failed */ |
| 1107 | inc_rs_pending(mdev); | 1088 | goto out; |
| 1108 | ok = drbd_send_drequest_csum(mdev, e->sector, e->size, | ||
| 1109 | digest, digest_size, P_OV_REPLY); | ||
| 1110 | if (!ok) | ||
| 1111 | dec_rs_pending(mdev); | ||
| 1112 | kfree(digest); | ||
| 1113 | } | 1089 | } |
| 1114 | 1090 | ||
| 1091 | if (likely(!(e->flags & EE_WAS_ERROR))) | ||
| 1092 | drbd_csum_ee(mdev, mdev->verify_tfm, e, digest); | ||
| 1093 | else | ||
| 1094 | memset(digest, 0, digest_size); | ||
| 1095 | |||
| 1096 | inc_rs_pending(mdev); | ||
| 1097 | ok = drbd_send_drequest_csum(mdev, e->sector, e->size, | ||
| 1098 | digest, digest_size, P_OV_REPLY); | ||
| 1099 | if (!ok) | ||
| 1100 | dec_rs_pending(mdev); | ||
| 1101 | kfree(digest); | ||
| 1102 | |||
| 1115 | out: | 1103 | out: |
| 1116 | drbd_free_ee(mdev, e); | 1104 | drbd_free_ee(mdev, e); |
| 1117 | |||
| 1118 | dec_unacked(mdev); | 1105 | dec_unacked(mdev); |
| 1119 | 1106 | ||
| 1120 | return ok; | 1107 | return ok; |
| @@ -1129,7 +1116,6 @@ void drbd_ov_oos_found(struct drbd_conf *mdev, sector_t sector, int size) | |||
| 1129 | mdev->ov_last_oos_size = size>>9; | 1116 | mdev->ov_last_oos_size = size>>9; |
| 1130 | } | 1117 | } |
| 1131 | drbd_set_out_of_sync(mdev, sector, size); | 1118 | drbd_set_out_of_sync(mdev, sector, size); |
| 1132 | set_bit(WRITE_BM_AFTER_RESYNC, &mdev->flags); | ||
| 1133 | } | 1119 | } |
| 1134 | 1120 | ||
| 1135 | int w_e_end_ov_reply(struct drbd_conf *mdev, struct drbd_work *w, int cancel) | 1121 | int w_e_end_ov_reply(struct drbd_conf *mdev, struct drbd_work *w, int cancel) |
| @@ -1165,10 +1151,6 @@ int w_e_end_ov_reply(struct drbd_conf *mdev, struct drbd_work *w, int cancel) | |||
| 1165 | eq = !memcmp(digest, di->digest, digest_size); | 1151 | eq = !memcmp(digest, di->digest, digest_size); |
| 1166 | kfree(digest); | 1152 | kfree(digest); |
| 1167 | } | 1153 | } |
| 1168 | } else { | ||
| 1169 | ok = drbd_send_ack(mdev, P_NEG_RS_DREPLY, e); | ||
| 1170 | if (__ratelimit(&drbd_ratelimit_state)) | ||
| 1171 | dev_err(DEV, "Sending NegDReply. I guess it gets messy.\n"); | ||
| 1172 | } | 1154 | } |
| 1173 | 1155 | ||
| 1174 | dec_unacked(mdev); | 1156 | dec_unacked(mdev); |
| @@ -1182,7 +1164,13 @@ int w_e_end_ov_reply(struct drbd_conf *mdev, struct drbd_work *w, int cancel) | |||
| 1182 | 1164 | ||
| 1183 | drbd_free_ee(mdev, e); | 1165 | drbd_free_ee(mdev, e); |
| 1184 | 1166 | ||
| 1185 | if (--mdev->ov_left == 0) { | 1167 | --mdev->ov_left; |
| 1168 | |||
| 1169 | /* let's advance progress step marks only for every other megabyte */ | ||
| 1170 | if ((mdev->ov_left & 0x200) == 0x200) | ||
| 1171 | drbd_advance_rs_marks(mdev, mdev->ov_left); | ||
| 1172 | |||
| 1173 | if (mdev->ov_left == 0) { | ||
| 1186 | ov_oos_print(mdev); | 1174 | ov_oos_print(mdev); |
| 1187 | drbd_resync_finished(mdev); | 1175 | drbd_resync_finished(mdev); |
| 1188 | } | 1176 | } |
| @@ -1235,6 +1223,22 @@ int w_send_write_hint(struct drbd_conf *mdev, struct drbd_work *w, int cancel) | |||
| 1235 | return drbd_send_short_cmd(mdev, P_UNPLUG_REMOTE); | 1223 | return drbd_send_short_cmd(mdev, P_UNPLUG_REMOTE); |
| 1236 | } | 1224 | } |
| 1237 | 1225 | ||
| 1226 | int w_send_oos(struct drbd_conf *mdev, struct drbd_work *w, int cancel) | ||
| 1227 | { | ||
| 1228 | struct drbd_request *req = container_of(w, struct drbd_request, w); | ||
| 1229 | int ok; | ||
| 1230 | |||
| 1231 | if (unlikely(cancel)) { | ||
| 1232 | req_mod(req, send_canceled); | ||
| 1233 | return 1; | ||
| 1234 | } | ||
| 1235 | |||
| 1236 | ok = drbd_send_oos(mdev, req); | ||
| 1237 | req_mod(req, oos_handed_to_network); | ||
| 1238 | |||
| 1239 | return ok; | ||
| 1240 | } | ||
| 1241 | |||
| 1238 | /** | 1242 | /** |
| 1239 | * w_send_dblock() - Worker callback to send a P_DATA packet in order to mirror a write request | 1243 | * w_send_dblock() - Worker callback to send a P_DATA packet in order to mirror a write request |
| 1240 | * @mdev: DRBD device. | 1244 | * @mdev: DRBD device. |
| @@ -1430,6 +1434,17 @@ int drbd_alter_sa(struct drbd_conf *mdev, int na) | |||
| 1430 | return retcode; | 1434 | return retcode; |
| 1431 | } | 1435 | } |
| 1432 | 1436 | ||
| 1437 | void drbd_rs_controller_reset(struct drbd_conf *mdev) | ||
| 1438 | { | ||
| 1439 | atomic_set(&mdev->rs_sect_in, 0); | ||
| 1440 | atomic_set(&mdev->rs_sect_ev, 0); | ||
| 1441 | mdev->rs_in_flight = 0; | ||
| 1442 | mdev->rs_planed = 0; | ||
| 1443 | spin_lock(&mdev->peer_seq_lock); | ||
| 1444 | fifo_set(&mdev->rs_plan_s, 0); | ||
| 1445 | spin_unlock(&mdev->peer_seq_lock); | ||
| 1446 | } | ||
| 1447 | |||
| 1433 | /** | 1448 | /** |
| 1434 | * drbd_start_resync() - Start the resync process | 1449 | * drbd_start_resync() - Start the resync process |
| 1435 | * @mdev: DRBD device. | 1450 | * @mdev: DRBD device. |
| @@ -1443,13 +1458,18 @@ void drbd_start_resync(struct drbd_conf *mdev, enum drbd_conns side) | |||
| 1443 | union drbd_state ns; | 1458 | union drbd_state ns; |
| 1444 | int r; | 1459 | int r; |
| 1445 | 1460 | ||
| 1446 | if (mdev->state.conn >= C_SYNC_SOURCE) { | 1461 | if (mdev->state.conn >= C_SYNC_SOURCE && mdev->state.conn < C_AHEAD) { |
| 1447 | dev_err(DEV, "Resync already running!\n"); | 1462 | dev_err(DEV, "Resync already running!\n"); |
| 1448 | return; | 1463 | return; |
| 1449 | } | 1464 | } |
| 1450 | 1465 | ||
| 1451 | /* In case a previous resync run was aborted by an IO error/detach on the peer. */ | 1466 | if (mdev->state.conn < C_AHEAD) { |
| 1452 | drbd_rs_cancel_all(mdev); | 1467 | /* In case a previous resync run was aborted by an IO error/detach on the peer. */ |
| 1468 | drbd_rs_cancel_all(mdev); | ||
| 1469 | /* This should be done when we abort the resync. We definitely do not | ||
| 1470 | want to have this for connections going back and forth between | ||
| 1471 | Ahead/Behind and SyncSource/SyncTarget */ | ||
| 1472 | } | ||
| 1453 | 1473 | ||
| 1454 | if (side == C_SYNC_TARGET) { | 1474 | if (side == C_SYNC_TARGET) { |
| 1455 | /* Since application IO was locked out during C_WF_BITMAP_T and | 1475 | /* Since application IO was locked out during C_WF_BITMAP_T and |
| @@ -1463,6 +1483,20 @@ void drbd_start_resync(struct drbd_conf *mdev, enum drbd_conns side) | |||
| 1463 | drbd_force_state(mdev, NS(conn, C_DISCONNECTING)); | 1483 | drbd_force_state(mdev, NS(conn, C_DISCONNECTING)); |
| 1464 | return; | 1484 | return; |
| 1465 | } | 1485 | } |
| 1486 | } else /* C_SYNC_SOURCE */ { | ||
| 1487 | r = drbd_khelper(mdev, "before-resync-source"); | ||
| 1488 | r = (r >> 8) & 0xff; | ||
| 1489 | if (r > 0) { | ||
| 1490 | if (r == 3) { | ||
| 1491 | dev_info(DEV, "before-resync-source handler returned %d, " | ||
| 1492 | "ignoring. Old userland tools?", r); | ||
| 1493 | } else { | ||
| 1494 | dev_info(DEV, "before-resync-source handler returned %d, " | ||
| 1495 | "dropping connection.\n", r); | ||
| 1496 | drbd_force_state(mdev, NS(conn, C_DISCONNECTING)); | ||
| 1497 | return; | ||
| 1498 | } | ||
| 1499 | } | ||
| 1466 | } | 1500 | } |
| 1467 | 1501 | ||
| 1468 | drbd_state_lock(mdev); | 1502 | drbd_state_lock(mdev); |
| @@ -1472,18 +1506,6 @@ void drbd_start_resync(struct drbd_conf *mdev, enum drbd_conns side) | |||
| 1472 | return; | 1506 | return; |
| 1473 | } | 1507 | } |
| 1474 | 1508 | ||
| 1475 | if (side == C_SYNC_TARGET) { | ||
| 1476 | mdev->bm_resync_fo = 0; | ||
| 1477 | } else /* side == C_SYNC_SOURCE */ { | ||
| 1478 | u64 uuid; | ||
| 1479 | |||
| 1480 | get_random_bytes(&uuid, sizeof(u64)); | ||
| 1481 | drbd_uuid_set(mdev, UI_BITMAP, uuid); | ||
| 1482 | drbd_send_sync_uuid(mdev, uuid); | ||
| 1483 | |||
| 1484 | D_ASSERT(mdev->state.disk == D_UP_TO_DATE); | ||
| 1485 | } | ||
| 1486 | |||
| 1487 | write_lock_irq(&global_state_lock); | 1509 | write_lock_irq(&global_state_lock); |
| 1488 | ns = mdev->state; | 1510 | ns = mdev->state; |
| 1489 | 1511 | ||
| @@ -1521,13 +1543,24 @@ void drbd_start_resync(struct drbd_conf *mdev, enum drbd_conns side) | |||
| 1521 | _drbd_pause_after(mdev); | 1543 | _drbd_pause_after(mdev); |
| 1522 | } | 1544 | } |
| 1523 | write_unlock_irq(&global_state_lock); | 1545 | write_unlock_irq(&global_state_lock); |
| 1524 | put_ldev(mdev); | ||
| 1525 | 1546 | ||
| 1526 | if (r == SS_SUCCESS) { | 1547 | if (r == SS_SUCCESS) { |
| 1527 | dev_info(DEV, "Began resync as %s (will sync %lu KB [%lu bits set]).\n", | 1548 | dev_info(DEV, "Began resync as %s (will sync %lu KB [%lu bits set]).\n", |
| 1528 | drbd_conn_str(ns.conn), | 1549 | drbd_conn_str(ns.conn), |
| 1529 | (unsigned long) mdev->rs_total << (BM_BLOCK_SHIFT-10), | 1550 | (unsigned long) mdev->rs_total << (BM_BLOCK_SHIFT-10), |
| 1530 | (unsigned long) mdev->rs_total); | 1551 | (unsigned long) mdev->rs_total); |
| 1552 | if (side == C_SYNC_TARGET) | ||
| 1553 | mdev->bm_resync_fo = 0; | ||
| 1554 | |||
| 1555 | /* Since protocol 96, we must serialize drbd_gen_and_send_sync_uuid | ||
| 1556 | * with w_send_oos, or the sync target will get confused as to | ||
| 1557 | * how much bits to resync. We cannot do that always, because for an | ||
| 1558 | * empty resync and protocol < 95, we need to do it here, as we call | ||
| 1559 | * drbd_resync_finished from here in that case. | ||
| 1560 | * We drbd_gen_and_send_sync_uuid here for protocol < 96, | ||
| 1561 | * and from after_state_ch otherwise. */ | ||
| 1562 | if (side == C_SYNC_SOURCE && mdev->agreed_pro_version < 96) | ||
| 1563 | drbd_gen_and_send_sync_uuid(mdev); | ||
| 1531 | 1564 | ||
| 1532 | if (mdev->agreed_pro_version < 95 && mdev->rs_total == 0) { | 1565 | if (mdev->agreed_pro_version < 95 && mdev->rs_total == 0) { |
| 1533 | /* This still has a race (about when exactly the peers | 1566 | /* This still has a race (about when exactly the peers |
| @@ -1547,13 +1580,7 @@ void drbd_start_resync(struct drbd_conf *mdev, enum drbd_conns side) | |||
| 1547 | drbd_resync_finished(mdev); | 1580 | drbd_resync_finished(mdev); |
| 1548 | } | 1581 | } |
| 1549 | 1582 | ||
| 1550 | atomic_set(&mdev->rs_sect_in, 0); | 1583 | drbd_rs_controller_reset(mdev); |
| 1551 | atomic_set(&mdev->rs_sect_ev, 0); | ||
| 1552 | mdev->rs_in_flight = 0; | ||
| 1553 | mdev->rs_planed = 0; | ||
| 1554 | spin_lock(&mdev->peer_seq_lock); | ||
| 1555 | fifo_set(&mdev->rs_plan_s, 0); | ||
| 1556 | spin_unlock(&mdev->peer_seq_lock); | ||
| 1557 | /* ns.conn may already be != mdev->state.conn, | 1584 | /* ns.conn may already be != mdev->state.conn, |
| 1558 | * we may have been paused in between, or become paused until | 1585 | * we may have been paused in between, or become paused until |
| 1559 | * the timer triggers. | 1586 | * the timer triggers. |
| @@ -1563,6 +1590,7 @@ void drbd_start_resync(struct drbd_conf *mdev, enum drbd_conns side) | |||
| 1563 | 1590 | ||
| 1564 | drbd_md_sync(mdev); | 1591 | drbd_md_sync(mdev); |
| 1565 | } | 1592 | } |
| 1593 | put_ldev(mdev); | ||
| 1566 | drbd_state_unlock(mdev); | 1594 | drbd_state_unlock(mdev); |
| 1567 | } | 1595 | } |
| 1568 | 1596 | ||
diff --git a/drivers/block/drbd/drbd_wrappers.h b/drivers/block/drbd/drbd_wrappers.h index 53586fa5ae1..151f1a37478 100644 --- a/drivers/block/drbd/drbd_wrappers.h +++ b/drivers/block/drbd/drbd_wrappers.h | |||
| @@ -39,7 +39,7 @@ static inline void drbd_generic_make_request(struct drbd_conf *mdev, | |||
| 39 | return; | 39 | return; |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | if (FAULT_ACTIVE(mdev, fault_type)) | 42 | if (drbd_insert_fault(mdev, fault_type)) |
| 43 | bio_endio(bio, -EIO); | 43 | bio_endio(bio, -EIO); |
| 44 | else | 44 | else |
| 45 | generic_make_request(bio); | 45 | generic_make_request(bio); |
diff --git a/drivers/dma/ipu/ipu_irq.c b/drivers/dma/ipu/ipu_irq.c index dd8ebc75b66..ab8a4eff072 100644 --- a/drivers/dma/ipu/ipu_irq.c +++ b/drivers/dma/ipu/ipu_irq.c | |||
| @@ -94,9 +94,9 @@ static struct ipu_irq_map *src2map(unsigned int src) | |||
| 94 | return NULL; | 94 | return NULL; |
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | static void ipu_irq_unmask(unsigned int irq) | 97 | static void ipu_irq_unmask(struct irq_data *d) |
| 98 | { | 98 | { |
| 99 | struct ipu_irq_map *map = get_irq_chip_data(irq); | 99 | struct ipu_irq_map *map = irq_data_get_irq_chip_data(d); |
| 100 | struct ipu_irq_bank *bank; | 100 | struct ipu_irq_bank *bank; |
| 101 | uint32_t reg; | 101 | uint32_t reg; |
| 102 | unsigned long lock_flags; | 102 | unsigned long lock_flags; |
| @@ -106,7 +106,7 @@ static void ipu_irq_unmask(unsigned int irq) | |||
| 106 | bank = map->bank; | 106 | bank = map->bank; |
| 107 | if (!bank) { | 107 | if (!bank) { |
| 108 | spin_unlock_irqrestore(&bank_lock, lock_flags); | 108 | spin_unlock_irqrestore(&bank_lock, lock_flags); |
| 109 | pr_err("IPU: %s(%u) - unmapped!\n", __func__, irq); | 109 | pr_err("IPU: %s(%u) - unmapped!\n", __func__, d->irq); |
| 110 | return; | 110 | return; |
| 111 | } | 111 | } |
| 112 | 112 | ||
| @@ -117,9 +117,9 @@ static void ipu_irq_unmask(unsigned int irq) | |||
| 117 | spin_unlock_irqrestore(&bank_lock, lock_flags); | 117 | spin_unlock_irqrestore(&bank_lock, lock_flags); |
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | static void ipu_irq_mask(unsigned int irq) | 120 | static void ipu_irq_mask(struct irq_data *d) |
| 121 | { | 121 | { |
| 122 | struct ipu_irq_map *map = get_irq_chip_data(irq); | 122 | struct ipu_irq_map *map = irq_data_get_irq_chip_data(d); |
| 123 | struct ipu_irq_bank *bank; | 123 | struct ipu_irq_bank *bank; |
| 124 | uint32_t reg; | 124 | uint32_t reg; |
| 125 | unsigned long lock_flags; | 125 | unsigned long lock_flags; |
| @@ -129,7 +129,7 @@ static void ipu_irq_mask(unsigned int irq) | |||
| 129 | bank = map->bank; | 129 | bank = map->bank; |
| 130 | if (!bank) { | 130 | if (!bank) { |
| 131 | spin_unlock_irqrestore(&bank_lock, lock_flags); | 131 | spin_unlock_irqrestore(&bank_lock, lock_flags); |
| 132 | pr_err("IPU: %s(%u) - unmapped!\n", __func__, irq); | 132 | pr_err("IPU: %s(%u) - unmapped!\n", __func__, d->irq); |
| 133 | return; | 133 | return; |
| 134 | } | 134 | } |
| 135 | 135 | ||
| @@ -140,9 +140,9 @@ static void ipu_irq_mask(unsigned int irq) | |||
| 140 | spin_unlock_irqrestore(&bank_lock, lock_flags); | 140 | spin_unlock_irqrestore(&bank_lock, lock_flags); |
| 141 | } | 141 | } |
| 142 | 142 | ||
| 143 | static void ipu_irq_ack(unsigned int irq) | 143 | static void ipu_irq_ack(struct irq_data *d) |
| 144 | { | 144 | { |
| 145 | struct ipu_irq_map *map = get_irq_chip_data(irq); | 145 | struct ipu_irq_map *map = irq_data_get_irq_chip_data(d); |
| 146 | struct ipu_irq_bank *bank; | 146 | struct ipu_irq_bank *bank; |
| 147 | unsigned long lock_flags; | 147 | unsigned long lock_flags; |
| 148 | 148 | ||
| @@ -151,7 +151,7 @@ static void ipu_irq_ack(unsigned int irq) | |||
| 151 | bank = map->bank; | 151 | bank = map->bank; |
| 152 | if (!bank) { | 152 | if (!bank) { |
| 153 | spin_unlock_irqrestore(&bank_lock, lock_flags); | 153 | spin_unlock_irqrestore(&bank_lock, lock_flags); |
| 154 | pr_err("IPU: %s(%u) - unmapped!\n", __func__, irq); | 154 | pr_err("IPU: %s(%u) - unmapped!\n", __func__, d->irq); |
| 155 | return; | 155 | return; |
| 156 | } | 156 | } |
| 157 | 157 | ||
| @@ -167,7 +167,7 @@ static void ipu_irq_ack(unsigned int irq) | |||
| 167 | */ | 167 | */ |
| 168 | bool ipu_irq_status(unsigned int irq) | 168 | bool ipu_irq_status(unsigned int irq) |
| 169 | { | 169 | { |
| 170 | struct ipu_irq_map *map = get_irq_chip_data(irq); | 170 | struct ipu_irq_map *map = irq_get_chip_data(irq); |
| 171 | struct ipu_irq_bank *bank; | 171 | struct ipu_irq_bank *bank; |
| 172 | unsigned long lock_flags; | 172 | unsigned long lock_flags; |
| 173 | bool ret; | 173 | bool ret; |
| @@ -269,7 +269,7 @@ int ipu_irq_unmap(unsigned int source) | |||
| 269 | /* Chained IRQ handler for IPU error interrupt */ | 269 | /* Chained IRQ handler for IPU error interrupt */ |
| 270 | static void ipu_irq_err(unsigned int irq, struct irq_desc *desc) | 270 | static void ipu_irq_err(unsigned int irq, struct irq_desc *desc) |
| 271 | { | 271 | { |
| 272 | struct ipu *ipu = get_irq_data(irq); | 272 | struct ipu *ipu = irq_get_handler_data(irq); |
| 273 | u32 status; | 273 | u32 status; |
| 274 | int i, line; | 274 | int i, line; |
| 275 | 275 | ||
| @@ -310,7 +310,7 @@ static void ipu_irq_err(unsigned int irq, struct irq_desc *desc) | |||
| 310 | /* Chained IRQ handler for IPU function interrupt */ | 310 | /* Chained IRQ handler for IPU function interrupt */ |
| 311 | static void ipu_irq_fn(unsigned int irq, struct irq_desc *desc) | 311 | static void ipu_irq_fn(unsigned int irq, struct irq_desc *desc) |
| 312 | { | 312 | { |
| 313 | struct ipu *ipu = get_irq_data(irq); | 313 | struct ipu *ipu = irq_desc_get_handler_data(desc); |
| 314 | u32 status; | 314 | u32 status; |
| 315 | int i, line; | 315 | int i, line; |
| 316 | 316 | ||
| @@ -345,10 +345,10 @@ static void ipu_irq_fn(unsigned int irq, struct irq_desc *desc) | |||
| 345 | } | 345 | } |
| 346 | 346 | ||
| 347 | static struct irq_chip ipu_irq_chip = { | 347 | static struct irq_chip ipu_irq_chip = { |
| 348 | .name = "ipu_irq", | 348 | .name = "ipu_irq", |
| 349 | .ack = ipu_irq_ack, | 349 | .irq_ack = ipu_irq_ack, |
| 350 | .mask = ipu_irq_mask, | 350 | .irq_mask = ipu_irq_mask, |
| 351 | .unmask = ipu_irq_unmask, | 351 | .irq_unmask = ipu_irq_unmask, |
| 352 | }; | 352 | }; |
| 353 | 353 | ||
| 354 | /* Install the IRQ handler */ | 354 | /* Install the IRQ handler */ |
| @@ -366,26 +366,26 @@ int __init ipu_irq_attach_irq(struct ipu *ipu, struct platform_device *dev) | |||
| 366 | int ret; | 366 | int ret; |
| 367 | 367 | ||
| 368 | irq = irq_base + i; | 368 | irq = irq_base + i; |
| 369 | ret = set_irq_chip(irq, &ipu_irq_chip); | 369 | ret = irq_set_chip(irq, &ipu_irq_chip); |
| 370 | if (ret < 0) | 370 | if (ret < 0) |
| 371 | return ret; | 371 | return ret; |
| 372 | ret = set_irq_chip_data(irq, irq_map + i); | 372 | ret = irq_set_chip_data(irq, irq_map + i); |
| 373 | if (ret < 0) | 373 | if (ret < 0) |
| 374 | return ret; | 374 | return ret; |
| 375 | irq_map[i].ipu = ipu; | 375 | irq_map[i].ipu = ipu; |
| 376 | irq_map[i].irq = irq; | 376 | irq_map[i].irq = irq; |
| 377 | irq_map[i].source = -EINVAL; | 377 | irq_map[i].source = -EINVAL; |
| 378 | set_irq_handler(irq, handle_level_irq); | 378 | irq_set_handler(irq, handle_level_irq); |
| 379 | #ifdef CONFIG_ARM | 379 | #ifdef CONFIG_ARM |
| 380 | set_irq_flags(irq, IRQF_VALID | IRQF_PROBE); | 380 | set_irq_flags(irq, IRQF_VALID | IRQF_PROBE); |
| 381 | #endif | 381 | #endif |
| 382 | } | 382 | } |
| 383 | 383 | ||
| 384 | set_irq_data(ipu->irq_fn, ipu); | 384 | irq_set_handler_data(ipu->irq_fn, ipu); |
| 385 | set_irq_chained_handler(ipu->irq_fn, ipu_irq_fn); | 385 | irq_set_chained_handler(ipu->irq_fn, ipu_irq_fn); |
| 386 | 386 | ||
| 387 | set_irq_data(ipu->irq_err, ipu); | 387 | irq_set_handler_data(ipu->irq_err, ipu); |
| 388 | set_irq_chained_handler(ipu->irq_err, ipu_irq_err); | 388 | irq_set_chained_handler(ipu->irq_err, ipu_irq_err); |
| 389 | 389 | ||
| 390 | return 0; | 390 | return 0; |
| 391 | } | 391 | } |
| @@ -397,17 +397,17 @@ void ipu_irq_detach_irq(struct ipu *ipu, struct platform_device *dev) | |||
| 397 | 397 | ||
| 398 | irq_base = pdata->irq_base; | 398 | irq_base = pdata->irq_base; |
| 399 | 399 | ||
| 400 | set_irq_chained_handler(ipu->irq_fn, NULL); | 400 | irq_set_chained_handler(ipu->irq_fn, NULL); |
| 401 | set_irq_data(ipu->irq_fn, NULL); | 401 | irq_set_handler_data(ipu->irq_fn, NULL); |
| 402 | 402 | ||
| 403 | set_irq_chained_handler(ipu->irq_err, NULL); | 403 | irq_set_chained_handler(ipu->irq_err, NULL); |
| 404 | set_irq_data(ipu->irq_err, NULL); | 404 | irq_set_handler_data(ipu->irq_err, NULL); |
| 405 | 405 | ||
| 406 | for (irq = irq_base; irq < irq_base + CONFIG_MX3_IPU_IRQS; irq++) { | 406 | for (irq = irq_base; irq < irq_base + CONFIG_MX3_IPU_IRQS; irq++) { |
| 407 | #ifdef CONFIG_ARM | 407 | #ifdef CONFIG_ARM |
| 408 | set_irq_flags(irq, 0); | 408 | set_irq_flags(irq, 0); |
| 409 | #endif | 409 | #endif |
| 410 | set_irq_chip(irq, NULL); | 410 | irq_set_chip(irq, NULL); |
| 411 | set_irq_chip_data(irq, NULL); | 411 | irq_set_chip_data(irq, NULL); |
| 412 | } | 412 | } |
| 413 | } | 413 | } |
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 81131eda554..060ef632787 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig | |||
| @@ -315,11 +315,22 @@ config SENSORS_F71805F | |||
| 315 | will be called f71805f. | 315 | will be called f71805f. |
| 316 | 316 | ||
| 317 | config SENSORS_F71882FG | 317 | config SENSORS_F71882FG |
| 318 | tristate "Fintek F71858FG, F71862FG, F71882FG, F71889FG and F8000" | 318 | tristate "Fintek F71882FG and compatibles" |
| 319 | help | 319 | help |
| 320 | If you say yes here you get support for hardware monitoring | 320 | If you say yes here you get support for hardware monitoring |
| 321 | features of the Fintek F71858FG, F71862FG/71863FG, F71882FG/F71883FG, | 321 | features of many Fintek Super-I/O (LPC) chips. The currently |
| 322 | F71889FG and F8000 Super-I/O chips. | 322 | supported chips are: |
| 323 | F71808E | ||
| 324 | F71858FG | ||
| 325 | F71862FG | ||
| 326 | F71863FG | ||
| 327 | F71869F/E | ||
| 328 | F71882FG | ||
| 329 | F71883FG | ||
| 330 | F71889FG/ED/A | ||
| 331 | F8000 | ||
| 332 | F81801U | ||
| 333 | F81865F | ||
| 323 | 334 | ||
| 324 | This driver can also be built as a module. If so, the module | 335 | This driver can also be built as a module. If so, the module |
| 325 | will be called f71882fg. | 336 | will be called f71882fg. |
diff --git a/drivers/hwmon/f71882fg.c b/drivers/hwmon/f71882fg.c index a4d430ee7e2..ca07a32447c 100644 --- a/drivers/hwmon/f71882fg.c +++ b/drivers/hwmon/f71882fg.c | |||
| @@ -54,7 +54,9 @@ | |||
| 54 | #define SIO_F71882_ID 0x0541 /* Chipset ID */ | 54 | #define SIO_F71882_ID 0x0541 /* Chipset ID */ |
| 55 | #define SIO_F71889_ID 0x0723 /* Chipset ID */ | 55 | #define SIO_F71889_ID 0x0723 /* Chipset ID */ |
| 56 | #define SIO_F71889E_ID 0x0909 /* Chipset ID */ | 56 | #define SIO_F71889E_ID 0x0909 /* Chipset ID */ |
| 57 | #define SIO_F71889A_ID 0x1005 /* Chipset ID */ | ||
| 57 | #define SIO_F8000_ID 0x0581 /* Chipset ID */ | 58 | #define SIO_F8000_ID 0x0581 /* Chipset ID */ |
| 59 | #define SIO_F81865_ID 0x0704 /* Chipset ID */ | ||
| 58 | 60 | ||
| 59 | #define REGION_LENGTH 8 | 61 | #define REGION_LENGTH 8 |
| 60 | #define ADDR_REG_OFFSET 5 | 62 | #define ADDR_REG_OFFSET 5 |
| @@ -106,7 +108,7 @@ module_param(force_id, ushort, 0); | |||
| 106 | MODULE_PARM_DESC(force_id, "Override the detected device ID"); | 108 | MODULE_PARM_DESC(force_id, "Override the detected device ID"); |
| 107 | 109 | ||
| 108 | enum chips { f71808e, f71858fg, f71862fg, f71869, f71882fg, f71889fg, | 110 | enum chips { f71808e, f71858fg, f71862fg, f71869, f71882fg, f71889fg, |
| 109 | f71889ed, f8000 }; | 111 | f71889ed, f71889a, f8000, f81865f }; |
| 110 | 112 | ||
| 111 | static const char *f71882fg_names[] = { | 113 | static const char *f71882fg_names[] = { |
| 112 | "f71808e", | 114 | "f71808e", |
| @@ -114,42 +116,76 @@ static const char *f71882fg_names[] = { | |||
| 114 | "f71862fg", | 116 | "f71862fg", |
| 115 | "f71869", /* Both f71869f and f71869e, reg. compatible and same id */ | 117 | "f71869", /* Both f71869f and f71869e, reg. compatible and same id */ |
| 116 | "f71882fg", | 118 | "f71882fg", |
| 117 | "f71889fg", | 119 | "f71889fg", /* f81801u too, same id */ |
| 118 | "f71889ed", | 120 | "f71889ed", |
| 121 | "f71889a", | ||
| 119 | "f8000", | 122 | "f8000", |
| 123 | "f81865f", | ||
| 120 | }; | 124 | }; |
| 121 | 125 | ||
| 122 | static const char f71882fg_has_in[8][F71882FG_MAX_INS] = { | 126 | static const char f71882fg_has_in[][F71882FG_MAX_INS] = { |
| 123 | { 1, 1, 1, 1, 1, 1, 0, 1, 1 }, /* f71808e */ | 127 | [f71808e] = { 1, 1, 1, 1, 1, 1, 0, 1, 1 }, |
| 124 | { 1, 1, 1, 0, 0, 0, 0, 0, 0 }, /* f71858fg */ | 128 | [f71858fg] = { 1, 1, 1, 0, 0, 0, 0, 0, 0 }, |
| 125 | { 1, 1, 1, 1, 1, 1, 1, 1, 1 }, /* f71862fg */ | 129 | [f71862fg] = { 1, 1, 1, 1, 1, 1, 1, 1, 1 }, |
| 126 | { 1, 1, 1, 1, 1, 1, 1, 1, 1 }, /* f71869 */ | 130 | [f71869] = { 1, 1, 1, 1, 1, 1, 1, 1, 1 }, |
| 127 | { 1, 1, 1, 1, 1, 1, 1, 1, 1 }, /* f71882fg */ | 131 | [f71882fg] = { 1, 1, 1, 1, 1, 1, 1, 1, 1 }, |
| 128 | { 1, 1, 1, 1, 1, 1, 1, 1, 1 }, /* f71889fg */ | 132 | [f71889fg] = { 1, 1, 1, 1, 1, 1, 1, 1, 1 }, |
| 129 | { 1, 1, 1, 1, 1, 1, 1, 1, 1 }, /* f71889ed */ | 133 | [f71889ed] = { 1, 1, 1, 1, 1, 1, 1, 1, 1 }, |
| 130 | { 1, 1, 1, 0, 0, 0, 0, 0, 0 }, /* f8000 */ | 134 | [f71889a] = { 1, 1, 1, 1, 1, 1, 1, 1, 1 }, |
| 135 | [f8000] = { 1, 1, 1, 0, 0, 0, 0, 0, 0 }, | ||
| 136 | [f81865f] = { 1, 1, 1, 1, 1, 1, 1, 0, 0 }, | ||
| 131 | }; | 137 | }; |
| 132 | 138 | ||
| 133 | static const char f71882fg_has_in1_alarm[8] = { | 139 | static const char f71882fg_has_in1_alarm[] = { |
| 134 | 0, /* f71808e */ | 140 | [f71808e] = 0, |
| 135 | 0, /* f71858fg */ | 141 | [f71858fg] = 0, |
| 136 | 0, /* f71862fg */ | 142 | [f71862fg] = 0, |
| 137 | 0, /* f71869 */ | 143 | [f71869] = 0, |
| 138 | 1, /* f71882fg */ | 144 | [f71882fg] = 1, |
| 139 | 1, /* f71889fg */ | 145 | [f71889fg] = 1, |
| 140 | 1, /* f71889ed */ | 146 | [f71889ed] = 1, |
| 141 | 0, /* f8000 */ | 147 | [f71889a] = 1, |
| 148 | [f8000] = 0, | ||
| 149 | [f81865f] = 1, | ||
| 142 | }; | 150 | }; |
| 143 | 151 | ||
| 144 | static const char f71882fg_has_beep[8] = { | 152 | static const char f71882fg_has_beep[] = { |
| 145 | 0, /* f71808e */ | 153 | [f71808e] = 0, |
| 146 | 0, /* f71858fg */ | 154 | [f71858fg] = 0, |
| 147 | 1, /* f71862fg */ | 155 | [f71862fg] = 1, |
| 148 | 1, /* f71869 */ | 156 | [f71869] = 1, |
| 149 | 1, /* f71882fg */ | 157 | [f71882fg] = 1, |
| 150 | 1, /* f71889fg */ | 158 | [f71889fg] = 1, |
| 151 | 1, /* f71889ed */ | 159 | [f71889ed] = 1, |
| 152 | 0, /* f8000 */ | 160 | [f71889a] = 1, |
| 161 | [f8000] = 0, | ||
| 162 | [f81865f] = 1, | ||
| 163 | }; | ||
| 164 | |||
| 165 | static const char f71882fg_nr_fans[] = { | ||
| 166 | [f71808e] = 3, | ||
| 167 | [f71858fg] = 3, | ||
| 168 | [f71862fg] = 3, | ||
| 169 | [f71869] = 3, | ||
| 170 | [f71882fg] = 4, | ||
| 171 | [f71889fg] = 3, | ||
| 172 | [f71889ed] = 3, | ||
| 173 | [f71889a] = 3, | ||
| 174 | [f8000] = 3, | ||
| 175 | [f81865f] = 2, | ||
| 176 | }; | ||
| 177 | |||
| 178 | static const char f71882fg_nr_temps[] = { | ||
| 179 | [f71808e] = 2, | ||
| 180 | [f71858fg] = 3, | ||
| 181 | [f71862fg] = 3, | ||
| 182 | [f71869] = 3, | ||
| 183 | [f71882fg] = 3, | ||
| 184 | [f71889fg] = 3, | ||
| 185 | [f71889ed] = 3, | ||
| 186 | [f71889a] = 3, | ||
| 187 | [f8000] = 3, | ||
| 188 | [f81865f] = 2, | ||
| 153 | }; | 189 | }; |
| 154 | 190 | ||
| 155 | static struct platform_device *f71882fg_pdev; | 191 | static struct platform_device *f71882fg_pdev; |
| @@ -1071,9 +1107,9 @@ static u16 f71882fg_read_temp(struct f71882fg_data *data, int nr) | |||
| 1071 | static struct f71882fg_data *f71882fg_update_device(struct device *dev) | 1107 | static struct f71882fg_data *f71882fg_update_device(struct device *dev) |
| 1072 | { | 1108 | { |
| 1073 | struct f71882fg_data *data = dev_get_drvdata(dev); | 1109 | struct f71882fg_data *data = dev_get_drvdata(dev); |
| 1110 | int nr_fans = f71882fg_nr_fans[data->type]; | ||
| 1111 | int nr_temps = f71882fg_nr_temps[data->type]; | ||
| 1074 | int nr, reg, point; | 1112 | int nr, reg, point; |
| 1075 | int nr_fans = (data->type == f71882fg) ? 4 : 3; | ||
| 1076 | int nr_temps = (data->type == f71808e) ? 2 : 3; | ||
| 1077 | 1113 | ||
| 1078 | mutex_lock(&data->update_lock); | 1114 | mutex_lock(&data->update_lock); |
| 1079 | 1115 | ||
| @@ -2042,8 +2078,9 @@ static int __devinit f71882fg_probe(struct platform_device *pdev) | |||
| 2042 | { | 2078 | { |
| 2043 | struct f71882fg_data *data; | 2079 | struct f71882fg_data *data; |
| 2044 | struct f71882fg_sio_data *sio_data = pdev->dev.platform_data; | 2080 | struct f71882fg_sio_data *sio_data = pdev->dev.platform_data; |
| 2045 | int err, i, nr_fans = (sio_data->type == f71882fg) ? 4 : 3; | 2081 | int nr_fans = f71882fg_nr_fans[sio_data->type]; |
| 2046 | int nr_temps = (sio_data->type == f71808e) ? 2 : 3; | 2082 | int nr_temps = f71882fg_nr_temps[sio_data->type]; |
| 2083 | int err, i; | ||
| 2047 | u8 start_reg, reg; | 2084 | u8 start_reg, reg; |
| 2048 | 2085 | ||
| 2049 | data = kzalloc(sizeof(struct f71882fg_data), GFP_KERNEL); | 2086 | data = kzalloc(sizeof(struct f71882fg_data), GFP_KERNEL); |
| @@ -2138,6 +2175,7 @@ static int __devinit f71882fg_probe(struct platform_device *pdev) | |||
| 2138 | /* Fall through to select correct fan/pwm reg bank! */ | 2175 | /* Fall through to select correct fan/pwm reg bank! */ |
| 2139 | case f71889fg: | 2176 | case f71889fg: |
| 2140 | case f71889ed: | 2177 | case f71889ed: |
| 2178 | case f71889a: | ||
| 2141 | reg = f71882fg_read8(data, F71882FG_REG_FAN_FAULT_T); | 2179 | reg = f71882fg_read8(data, F71882FG_REG_FAN_FAULT_T); |
| 2142 | if (reg & F71882FG_FAN_NEG_TEMP_EN) | 2180 | if (reg & F71882FG_FAN_NEG_TEMP_EN) |
| 2143 | data->auto_point_temp_signed = 1; | 2181 | data->auto_point_temp_signed = 1; |
| @@ -2163,16 +2201,12 @@ static int __devinit f71882fg_probe(struct platform_device *pdev) | |||
| 2163 | case f71862fg: | 2201 | case f71862fg: |
| 2164 | err = (data->pwm_enable & 0x15) != 0x15; | 2202 | err = (data->pwm_enable & 0x15) != 0x15; |
| 2165 | break; | 2203 | break; |
| 2166 | case f71808e: | ||
| 2167 | case f71869: | ||
| 2168 | case f71882fg: | ||
| 2169 | case f71889fg: | ||
| 2170 | case f71889ed: | ||
| 2171 | err = 0; | ||
| 2172 | break; | ||
| 2173 | case f8000: | 2204 | case f8000: |
| 2174 | err = data->pwm_enable & 0x20; | 2205 | err = data->pwm_enable & 0x20; |
| 2175 | break; | 2206 | break; |
| 2207 | default: | ||
| 2208 | err = 0; | ||
| 2209 | break; | ||
| 2176 | } | 2210 | } |
| 2177 | if (err) { | 2211 | if (err) { |
| 2178 | dev_err(&pdev->dev, | 2212 | dev_err(&pdev->dev, |
| @@ -2199,6 +2233,7 @@ static int __devinit f71882fg_probe(struct platform_device *pdev) | |||
| 2199 | case f71869: | 2233 | case f71869: |
| 2200 | case f71889fg: | 2234 | case f71889fg: |
| 2201 | case f71889ed: | 2235 | case f71889ed: |
| 2236 | case f71889a: | ||
| 2202 | for (i = 0; i < nr_fans; i++) { | 2237 | for (i = 0; i < nr_fans; i++) { |
| 2203 | data->pwm_auto_point_mapping[i] = | 2238 | data->pwm_auto_point_mapping[i] = |
| 2204 | f71882fg_read8(data, | 2239 | f71882fg_read8(data, |
| @@ -2276,8 +2311,9 @@ exit_free: | |||
| 2276 | static int f71882fg_remove(struct platform_device *pdev) | 2311 | static int f71882fg_remove(struct platform_device *pdev) |
| 2277 | { | 2312 | { |
| 2278 | struct f71882fg_data *data = platform_get_drvdata(pdev); | 2313 | struct f71882fg_data *data = platform_get_drvdata(pdev); |
| 2279 | int i, nr_fans = (data->type == f71882fg) ? 4 : 3; | 2314 | int nr_fans = f71882fg_nr_fans[data->type]; |
| 2280 | int nr_temps = (data->type == f71808e) ? 2 : 3; | 2315 | int nr_temps = f71882fg_nr_temps[data->type]; |
| 2316 | int i; | ||
| 2281 | u8 start_reg = f71882fg_read8(data, F71882FG_REG_START); | 2317 | u8 start_reg = f71882fg_read8(data, F71882FG_REG_START); |
| 2282 | 2318 | ||
| 2283 | if (data->hwmon_dev) | 2319 | if (data->hwmon_dev) |
| @@ -2406,9 +2442,15 @@ static int __init f71882fg_find(int sioaddr, unsigned short *address, | |||
| 2406 | case SIO_F71889E_ID: | 2442 | case SIO_F71889E_ID: |
| 2407 | sio_data->type = f71889ed; | 2443 | sio_data->type = f71889ed; |
| 2408 | break; | 2444 | break; |
| 2445 | case SIO_F71889A_ID: | ||
| 2446 | sio_data->type = f71889a; | ||
| 2447 | break; | ||
| 2409 | case SIO_F8000_ID: | 2448 | case SIO_F8000_ID: |
| 2410 | sio_data->type = f8000; | 2449 | sio_data->type = f8000; |
| 2411 | break; | 2450 | break; |
| 2451 | case SIO_F81865_ID: | ||
| 2452 | sio_data->type = f81865f; | ||
| 2453 | break; | ||
| 2412 | default: | 2454 | default: |
| 2413 | pr_info("Unsupported Fintek device: %04x\n", | 2455 | pr_info("Unsupported Fintek device: %04x\n", |
| 2414 | (unsigned int)devid); | 2456 | (unsigned int)devid); |
diff --git a/drivers/hwmon/pmbus_core.c b/drivers/hwmon/pmbus_core.c index 6474512f49b..edfb92e4173 100644 --- a/drivers/hwmon/pmbus_core.c +++ b/drivers/hwmon/pmbus_core.c | |||
| @@ -752,7 +752,7 @@ static void pmbus_add_boolean_cmp(struct pmbus_data *data, | |||
| 752 | static void pmbus_add_sensor(struct pmbus_data *data, | 752 | static void pmbus_add_sensor(struct pmbus_data *data, |
| 753 | const char *name, const char *type, int seq, | 753 | const char *name, const char *type, int seq, |
| 754 | int page, int reg, enum pmbus_sensor_classes class, | 754 | int page, int reg, enum pmbus_sensor_classes class, |
| 755 | bool update) | 755 | bool update, bool readonly) |
| 756 | { | 756 | { |
| 757 | struct pmbus_sensor *sensor; | 757 | struct pmbus_sensor *sensor; |
| 758 | 758 | ||
| @@ -765,7 +765,7 @@ static void pmbus_add_sensor(struct pmbus_data *data, | |||
| 765 | sensor->reg = reg; | 765 | sensor->reg = reg; |
| 766 | sensor->class = class; | 766 | sensor->class = class; |
| 767 | sensor->update = update; | 767 | sensor->update = update; |
| 768 | if (update) | 768 | if (readonly) |
| 769 | PMBUS_ADD_GET_ATTR(data, sensor->name, sensor, | 769 | PMBUS_ADD_GET_ATTR(data, sensor->name, sensor, |
| 770 | data->num_sensors); | 770 | data->num_sensors); |
| 771 | else | 771 | else |
| @@ -916,14 +916,14 @@ static void pmbus_find_attributes(struct i2c_client *client, | |||
| 916 | 916 | ||
| 917 | i0 = data->num_sensors; | 917 | i0 = data->num_sensors; |
| 918 | pmbus_add_label(data, "in", in_index, "vin", 0); | 918 | pmbus_add_label(data, "in", in_index, "vin", 0); |
| 919 | pmbus_add_sensor(data, "in", "input", in_index, | 919 | pmbus_add_sensor(data, "in", "input", in_index, 0, |
| 920 | 0, PMBUS_READ_VIN, PSC_VOLTAGE_IN, true); | 920 | PMBUS_READ_VIN, PSC_VOLTAGE_IN, true, true); |
| 921 | if (pmbus_check_word_register(client, 0, | 921 | if (pmbus_check_word_register(client, 0, |
| 922 | PMBUS_VIN_UV_WARN_LIMIT)) { | 922 | PMBUS_VIN_UV_WARN_LIMIT)) { |
| 923 | i1 = data->num_sensors; | 923 | i1 = data->num_sensors; |
| 924 | pmbus_add_sensor(data, "in", "min", in_index, | 924 | pmbus_add_sensor(data, "in", "min", in_index, |
| 925 | 0, PMBUS_VIN_UV_WARN_LIMIT, | 925 | 0, PMBUS_VIN_UV_WARN_LIMIT, |
| 926 | PSC_VOLTAGE_IN, false); | 926 | PSC_VOLTAGE_IN, false, false); |
| 927 | if (info->func[0] & PMBUS_HAVE_STATUS_INPUT) { | 927 | if (info->func[0] & PMBUS_HAVE_STATUS_INPUT) { |
| 928 | pmbus_add_boolean_reg(data, "in", "min_alarm", | 928 | pmbus_add_boolean_reg(data, "in", "min_alarm", |
| 929 | in_index, | 929 | in_index, |
| @@ -937,7 +937,7 @@ static void pmbus_find_attributes(struct i2c_client *client, | |||
| 937 | i1 = data->num_sensors; | 937 | i1 = data->num_sensors; |
| 938 | pmbus_add_sensor(data, "in", "lcrit", in_index, | 938 | pmbus_add_sensor(data, "in", "lcrit", in_index, |
| 939 | 0, PMBUS_VIN_UV_FAULT_LIMIT, | 939 | 0, PMBUS_VIN_UV_FAULT_LIMIT, |
| 940 | PSC_VOLTAGE_IN, false); | 940 | PSC_VOLTAGE_IN, false, false); |
| 941 | if (info->func[0] & PMBUS_HAVE_STATUS_INPUT) { | 941 | if (info->func[0] & PMBUS_HAVE_STATUS_INPUT) { |
| 942 | pmbus_add_boolean_reg(data, "in", "lcrit_alarm", | 942 | pmbus_add_boolean_reg(data, "in", "lcrit_alarm", |
| 943 | in_index, | 943 | in_index, |
| @@ -951,7 +951,7 @@ static void pmbus_find_attributes(struct i2c_client *client, | |||
| 951 | i1 = data->num_sensors; | 951 | i1 = data->num_sensors; |
| 952 | pmbus_add_sensor(data, "in", "max", in_index, | 952 | pmbus_add_sensor(data, "in", "max", in_index, |
| 953 | 0, PMBUS_VIN_OV_WARN_LIMIT, | 953 | 0, PMBUS_VIN_OV_WARN_LIMIT, |
| 954 | PSC_VOLTAGE_IN, false); | 954 | PSC_VOLTAGE_IN, false, false); |
| 955 | if (info->func[0] & PMBUS_HAVE_STATUS_INPUT) { | 955 | if (info->func[0] & PMBUS_HAVE_STATUS_INPUT) { |
| 956 | pmbus_add_boolean_reg(data, "in", "max_alarm", | 956 | pmbus_add_boolean_reg(data, "in", "max_alarm", |
| 957 | in_index, | 957 | in_index, |
| @@ -965,7 +965,7 @@ static void pmbus_find_attributes(struct i2c_client *client, | |||
| 965 | i1 = data->num_sensors; | 965 | i1 = data->num_sensors; |
| 966 | pmbus_add_sensor(data, "in", "crit", in_index, | 966 | pmbus_add_sensor(data, "in", "crit", in_index, |
| 967 | 0, PMBUS_VIN_OV_FAULT_LIMIT, | 967 | 0, PMBUS_VIN_OV_FAULT_LIMIT, |
| 968 | PSC_VOLTAGE_IN, false); | 968 | PSC_VOLTAGE_IN, false, false); |
| 969 | if (info->func[0] & PMBUS_HAVE_STATUS_INPUT) { | 969 | if (info->func[0] & PMBUS_HAVE_STATUS_INPUT) { |
| 970 | pmbus_add_boolean_reg(data, "in", "crit_alarm", | 970 | pmbus_add_boolean_reg(data, "in", "crit_alarm", |
| 971 | in_index, | 971 | in_index, |
| @@ -988,7 +988,7 @@ static void pmbus_find_attributes(struct i2c_client *client, | |||
| 988 | if (info->func[0] & PMBUS_HAVE_VCAP) { | 988 | if (info->func[0] & PMBUS_HAVE_VCAP) { |
| 989 | pmbus_add_label(data, "in", in_index, "vcap", 0); | 989 | pmbus_add_label(data, "in", in_index, "vcap", 0); |
| 990 | pmbus_add_sensor(data, "in", "input", in_index, 0, | 990 | pmbus_add_sensor(data, "in", "input", in_index, 0, |
| 991 | PMBUS_READ_VCAP, PSC_VOLTAGE_IN, true); | 991 | PMBUS_READ_VCAP, PSC_VOLTAGE_IN, true, true); |
| 992 | in_index++; | 992 | in_index++; |
| 993 | } | 993 | } |
| 994 | 994 | ||
| @@ -1004,13 +1004,13 @@ static void pmbus_find_attributes(struct i2c_client *client, | |||
| 1004 | i0 = data->num_sensors; | 1004 | i0 = data->num_sensors; |
| 1005 | pmbus_add_label(data, "in", in_index, "vout", page + 1); | 1005 | pmbus_add_label(data, "in", in_index, "vout", page + 1); |
| 1006 | pmbus_add_sensor(data, "in", "input", in_index, page, | 1006 | pmbus_add_sensor(data, "in", "input", in_index, page, |
| 1007 | PMBUS_READ_VOUT, PSC_VOLTAGE_OUT, true); | 1007 | PMBUS_READ_VOUT, PSC_VOLTAGE_OUT, true, true); |
| 1008 | if (pmbus_check_word_register(client, page, | 1008 | if (pmbus_check_word_register(client, page, |
| 1009 | PMBUS_VOUT_UV_WARN_LIMIT)) { | 1009 | PMBUS_VOUT_UV_WARN_LIMIT)) { |
| 1010 | i1 = data->num_sensors; | 1010 | i1 = data->num_sensors; |
| 1011 | pmbus_add_sensor(data, "in", "min", in_index, page, | 1011 | pmbus_add_sensor(data, "in", "min", in_index, page, |
| 1012 | PMBUS_VOUT_UV_WARN_LIMIT, | 1012 | PMBUS_VOUT_UV_WARN_LIMIT, |
| 1013 | PSC_VOLTAGE_OUT, false); | 1013 | PSC_VOLTAGE_OUT, false, false); |
| 1014 | if (info->func[page] & PMBUS_HAVE_STATUS_VOUT) { | 1014 | if (info->func[page] & PMBUS_HAVE_STATUS_VOUT) { |
| 1015 | pmbus_add_boolean_reg(data, "in", "min_alarm", | 1015 | pmbus_add_boolean_reg(data, "in", "min_alarm", |
| 1016 | in_index, | 1016 | in_index, |
| @@ -1025,7 +1025,7 @@ static void pmbus_find_attributes(struct i2c_client *client, | |||
| 1025 | i1 = data->num_sensors; | 1025 | i1 = data->num_sensors; |
| 1026 | pmbus_add_sensor(data, "in", "lcrit", in_index, page, | 1026 | pmbus_add_sensor(data, "in", "lcrit", in_index, page, |
| 1027 | PMBUS_VOUT_UV_FAULT_LIMIT, | 1027 | PMBUS_VOUT_UV_FAULT_LIMIT, |
| 1028 | PSC_VOLTAGE_OUT, false); | 1028 | PSC_VOLTAGE_OUT, false, false); |
| 1029 | if (info->func[page] & PMBUS_HAVE_STATUS_VOUT) { | 1029 | if (info->func[page] & PMBUS_HAVE_STATUS_VOUT) { |
| 1030 | pmbus_add_boolean_reg(data, "in", "lcrit_alarm", | 1030 | pmbus_add_boolean_reg(data, "in", "lcrit_alarm", |
| 1031 | in_index, | 1031 | in_index, |
| @@ -1040,7 +1040,7 @@ static void pmbus_find_attributes(struct i2c_client *client, | |||
| 1040 | i1 = data->num_sensors; | 1040 | i1 = data->num_sensors; |
| 1041 | pmbus_add_sensor(data, "in", "max", in_index, page, | 1041 | pmbus_add_sensor(data, "in", "max", in_index, page, |
| 1042 | PMBUS_VOUT_OV_WARN_LIMIT, | 1042 | PMBUS_VOUT_OV_WARN_LIMIT, |
| 1043 | PSC_VOLTAGE_OUT, false); | 1043 | PSC_VOLTAGE_OUT, false, false); |
| 1044 | if (info->func[page] & PMBUS_HAVE_STATUS_VOUT) { | 1044 | if (info->func[page] & PMBUS_HAVE_STATUS_VOUT) { |
| 1045 | pmbus_add_boolean_reg(data, "in", "max_alarm", | 1045 | pmbus_add_boolean_reg(data, "in", "max_alarm", |
| 1046 | in_index, | 1046 | in_index, |
| @@ -1055,7 +1055,7 @@ static void pmbus_find_attributes(struct i2c_client *client, | |||
| 1055 | i1 = data->num_sensors; | 1055 | i1 = data->num_sensors; |
| 1056 | pmbus_add_sensor(data, "in", "crit", in_index, page, | 1056 | pmbus_add_sensor(data, "in", "crit", in_index, page, |
| 1057 | PMBUS_VOUT_OV_FAULT_LIMIT, | 1057 | PMBUS_VOUT_OV_FAULT_LIMIT, |
| 1058 | PSC_VOLTAGE_OUT, false); | 1058 | PSC_VOLTAGE_OUT, false, false); |
| 1059 | if (info->func[page] & PMBUS_HAVE_STATUS_VOUT) { | 1059 | if (info->func[page] & PMBUS_HAVE_STATUS_VOUT) { |
| 1060 | pmbus_add_boolean_reg(data, "in", "crit_alarm", | 1060 | pmbus_add_boolean_reg(data, "in", "crit_alarm", |
| 1061 | in_index, | 1061 | in_index, |
| @@ -1088,14 +1088,14 @@ static void pmbus_find_attributes(struct i2c_client *client, | |||
| 1088 | if (info->func[0] & PMBUS_HAVE_IIN) { | 1088 | if (info->func[0] & PMBUS_HAVE_IIN) { |
| 1089 | i0 = data->num_sensors; | 1089 | i0 = data->num_sensors; |
| 1090 | pmbus_add_label(data, "curr", in_index, "iin", 0); | 1090 | pmbus_add_label(data, "curr", in_index, "iin", 0); |
| 1091 | pmbus_add_sensor(data, "curr", "input", in_index, | 1091 | pmbus_add_sensor(data, "curr", "input", in_index, 0, |
| 1092 | 0, PMBUS_READ_IIN, PSC_CURRENT_IN, true); | 1092 | PMBUS_READ_IIN, PSC_CURRENT_IN, true, true); |
| 1093 | if (pmbus_check_word_register(client, 0, | 1093 | if (pmbus_check_word_register(client, 0, |
| 1094 | PMBUS_IIN_OC_WARN_LIMIT)) { | 1094 | PMBUS_IIN_OC_WARN_LIMIT)) { |
| 1095 | i1 = data->num_sensors; | 1095 | i1 = data->num_sensors; |
| 1096 | pmbus_add_sensor(data, "curr", "max", in_index, | 1096 | pmbus_add_sensor(data, "curr", "max", in_index, |
| 1097 | 0, PMBUS_IIN_OC_WARN_LIMIT, | 1097 | 0, PMBUS_IIN_OC_WARN_LIMIT, |
| 1098 | PSC_CURRENT_IN, false); | 1098 | PSC_CURRENT_IN, false, false); |
| 1099 | if (info->func[0] & PMBUS_HAVE_STATUS_INPUT) { | 1099 | if (info->func[0] & PMBUS_HAVE_STATUS_INPUT) { |
| 1100 | pmbus_add_boolean_reg(data, "curr", "max_alarm", | 1100 | pmbus_add_boolean_reg(data, "curr", "max_alarm", |
| 1101 | in_index, | 1101 | in_index, |
| @@ -1108,7 +1108,7 @@ static void pmbus_find_attributes(struct i2c_client *client, | |||
| 1108 | i1 = data->num_sensors; | 1108 | i1 = data->num_sensors; |
| 1109 | pmbus_add_sensor(data, "curr", "crit", in_index, | 1109 | pmbus_add_sensor(data, "curr", "crit", in_index, |
| 1110 | 0, PMBUS_IIN_OC_FAULT_LIMIT, | 1110 | 0, PMBUS_IIN_OC_FAULT_LIMIT, |
| 1111 | PSC_CURRENT_IN, false); | 1111 | PSC_CURRENT_IN, false, false); |
| 1112 | if (info->func[0] & PMBUS_HAVE_STATUS_INPUT) | 1112 | if (info->func[0] & PMBUS_HAVE_STATUS_INPUT) |
| 1113 | pmbus_add_boolean_reg(data, "curr", | 1113 | pmbus_add_boolean_reg(data, "curr", |
| 1114 | "crit_alarm", | 1114 | "crit_alarm", |
| @@ -1131,13 +1131,13 @@ static void pmbus_find_attributes(struct i2c_client *client, | |||
| 1131 | i0 = data->num_sensors; | 1131 | i0 = data->num_sensors; |
| 1132 | pmbus_add_label(data, "curr", in_index, "iout", page + 1); | 1132 | pmbus_add_label(data, "curr", in_index, "iout", page + 1); |
| 1133 | pmbus_add_sensor(data, "curr", "input", in_index, page, | 1133 | pmbus_add_sensor(data, "curr", "input", in_index, page, |
| 1134 | PMBUS_READ_IOUT, PSC_CURRENT_OUT, true); | 1134 | PMBUS_READ_IOUT, PSC_CURRENT_OUT, true, true); |
| 1135 | if (pmbus_check_word_register(client, page, | 1135 | if (pmbus_check_word_register(client, page, |
| 1136 | PMBUS_IOUT_OC_WARN_LIMIT)) { | 1136 | PMBUS_IOUT_OC_WARN_LIMIT)) { |
| 1137 | i1 = data->num_sensors; | 1137 | i1 = data->num_sensors; |
| 1138 | pmbus_add_sensor(data, "curr", "max", in_index, page, | 1138 | pmbus_add_sensor(data, "curr", "max", in_index, page, |
| 1139 | PMBUS_IOUT_OC_WARN_LIMIT, | 1139 | PMBUS_IOUT_OC_WARN_LIMIT, |
| 1140 | PSC_CURRENT_OUT, false); | 1140 | PSC_CURRENT_OUT, false, false); |
| 1141 | if (info->func[page] & PMBUS_HAVE_STATUS_IOUT) { | 1141 | if (info->func[page] & PMBUS_HAVE_STATUS_IOUT) { |
| 1142 | pmbus_add_boolean_reg(data, "curr", "max_alarm", | 1142 | pmbus_add_boolean_reg(data, "curr", "max_alarm", |
| 1143 | in_index, | 1143 | in_index, |
| @@ -1151,7 +1151,7 @@ static void pmbus_find_attributes(struct i2c_client *client, | |||
| 1151 | i1 = data->num_sensors; | 1151 | i1 = data->num_sensors; |
| 1152 | pmbus_add_sensor(data, "curr", "lcrit", in_index, page, | 1152 | pmbus_add_sensor(data, "curr", "lcrit", in_index, page, |
| 1153 | PMBUS_IOUT_UC_FAULT_LIMIT, | 1153 | PMBUS_IOUT_UC_FAULT_LIMIT, |
| 1154 | PSC_CURRENT_OUT, false); | 1154 | PSC_CURRENT_OUT, false, false); |
| 1155 | if (info->func[page] & PMBUS_HAVE_STATUS_IOUT) { | 1155 | if (info->func[page] & PMBUS_HAVE_STATUS_IOUT) { |
| 1156 | pmbus_add_boolean_reg(data, "curr", | 1156 | pmbus_add_boolean_reg(data, "curr", |
| 1157 | "lcrit_alarm", | 1157 | "lcrit_alarm", |
| @@ -1166,7 +1166,7 @@ static void pmbus_find_attributes(struct i2c_client *client, | |||
| 1166 | i1 = data->num_sensors; | 1166 | i1 = data->num_sensors; |
| 1167 | pmbus_add_sensor(data, "curr", "crit", in_index, page, | 1167 | pmbus_add_sensor(data, "curr", "crit", in_index, page, |
| 1168 | PMBUS_IOUT_OC_FAULT_LIMIT, | 1168 | PMBUS_IOUT_OC_FAULT_LIMIT, |
| 1169 | PSC_CURRENT_OUT, false); | 1169 | PSC_CURRENT_OUT, false, false); |
| 1170 | if (info->func[page] & PMBUS_HAVE_STATUS_IOUT) { | 1170 | if (info->func[page] & PMBUS_HAVE_STATUS_IOUT) { |
| 1171 | pmbus_add_boolean_reg(data, "curr", | 1171 | pmbus_add_boolean_reg(data, "curr", |
| 1172 | "crit_alarm", | 1172 | "crit_alarm", |
| @@ -1199,13 +1199,13 @@ static void pmbus_find_attributes(struct i2c_client *client, | |||
| 1199 | i0 = data->num_sensors; | 1199 | i0 = data->num_sensors; |
| 1200 | pmbus_add_label(data, "power", in_index, "pin", 0); | 1200 | pmbus_add_label(data, "power", in_index, "pin", 0); |
| 1201 | pmbus_add_sensor(data, "power", "input", in_index, | 1201 | pmbus_add_sensor(data, "power", "input", in_index, |
| 1202 | 0, PMBUS_READ_PIN, PSC_POWER, true); | 1202 | 0, PMBUS_READ_PIN, PSC_POWER, true, true); |
| 1203 | if (pmbus_check_word_register(client, 0, | 1203 | if (pmbus_check_word_register(client, 0, |
| 1204 | PMBUS_PIN_OP_WARN_LIMIT)) { | 1204 | PMBUS_PIN_OP_WARN_LIMIT)) { |
| 1205 | i1 = data->num_sensors; | 1205 | i1 = data->num_sensors; |
| 1206 | pmbus_add_sensor(data, "power", "max", in_index, | 1206 | pmbus_add_sensor(data, "power", "max", in_index, |
| 1207 | 0, PMBUS_PIN_OP_WARN_LIMIT, PSC_POWER, | 1207 | 0, PMBUS_PIN_OP_WARN_LIMIT, PSC_POWER, |
| 1208 | false); | 1208 | false, false); |
| 1209 | if (info->func[0] & PMBUS_HAVE_STATUS_INPUT) | 1209 | if (info->func[0] & PMBUS_HAVE_STATUS_INPUT) |
| 1210 | pmbus_add_boolean_reg(data, "power", | 1210 | pmbus_add_boolean_reg(data, "power", |
| 1211 | "alarm", | 1211 | "alarm", |
| @@ -1228,7 +1228,7 @@ static void pmbus_find_attributes(struct i2c_client *client, | |||
| 1228 | i0 = data->num_sensors; | 1228 | i0 = data->num_sensors; |
| 1229 | pmbus_add_label(data, "power", in_index, "pout", page + 1); | 1229 | pmbus_add_label(data, "power", in_index, "pout", page + 1); |
| 1230 | pmbus_add_sensor(data, "power", "input", in_index, page, | 1230 | pmbus_add_sensor(data, "power", "input", in_index, page, |
| 1231 | PMBUS_READ_POUT, PSC_POWER, true); | 1231 | PMBUS_READ_POUT, PSC_POWER, true, true); |
| 1232 | /* | 1232 | /* |
| 1233 | * Per hwmon sysfs API, power_cap is to be used to limit output | 1233 | * Per hwmon sysfs API, power_cap is to be used to limit output |
| 1234 | * power. | 1234 | * power. |
| @@ -1241,7 +1241,8 @@ static void pmbus_find_attributes(struct i2c_client *client, | |||
| 1241 | if (pmbus_check_word_register(client, page, PMBUS_POUT_MAX)) { | 1241 | if (pmbus_check_word_register(client, page, PMBUS_POUT_MAX)) { |
| 1242 | i1 = data->num_sensors; | 1242 | i1 = data->num_sensors; |
| 1243 | pmbus_add_sensor(data, "power", "cap", in_index, page, | 1243 | pmbus_add_sensor(data, "power", "cap", in_index, page, |
| 1244 | PMBUS_POUT_MAX, PSC_POWER, false); | 1244 | PMBUS_POUT_MAX, PSC_POWER, |
| 1245 | false, false); | ||
| 1245 | need_alarm = true; | 1246 | need_alarm = true; |
| 1246 | } | 1247 | } |
| 1247 | if (pmbus_check_word_register(client, page, | 1248 | if (pmbus_check_word_register(client, page, |
| @@ -1249,7 +1250,7 @@ static void pmbus_find_attributes(struct i2c_client *client, | |||
| 1249 | i1 = data->num_sensors; | 1250 | i1 = data->num_sensors; |
| 1250 | pmbus_add_sensor(data, "power", "max", in_index, page, | 1251 | pmbus_add_sensor(data, "power", "max", in_index, page, |
| 1251 | PMBUS_POUT_OP_WARN_LIMIT, PSC_POWER, | 1252 | PMBUS_POUT_OP_WARN_LIMIT, PSC_POWER, |
| 1252 | false); | 1253 | false, false); |
| 1253 | need_alarm = true; | 1254 | need_alarm = true; |
| 1254 | } | 1255 | } |
| 1255 | if (need_alarm && (info->func[page] & PMBUS_HAVE_STATUS_IOUT)) | 1256 | if (need_alarm && (info->func[page] & PMBUS_HAVE_STATUS_IOUT)) |
| @@ -1264,7 +1265,7 @@ static void pmbus_find_attributes(struct i2c_client *client, | |||
| 1264 | i1 = data->num_sensors; | 1265 | i1 = data->num_sensors; |
| 1265 | pmbus_add_sensor(data, "power", "crit", in_index, page, | 1266 | pmbus_add_sensor(data, "power", "crit", in_index, page, |
| 1266 | PMBUS_POUT_OP_FAULT_LIMIT, PSC_POWER, | 1267 | PMBUS_POUT_OP_FAULT_LIMIT, PSC_POWER, |
| 1267 | false); | 1268 | false, false); |
| 1268 | if (info->func[page] & PMBUS_HAVE_STATUS_IOUT) | 1269 | if (info->func[page] & PMBUS_HAVE_STATUS_IOUT) |
| 1269 | pmbus_add_boolean_reg(data, "power", | 1270 | pmbus_add_boolean_reg(data, "power", |
| 1270 | "crit_alarm", | 1271 | "crit_alarm", |
| @@ -1302,7 +1303,7 @@ static void pmbus_find_attributes(struct i2c_client *client, | |||
| 1302 | i0 = data->num_sensors; | 1303 | i0 = data->num_sensors; |
| 1303 | pmbus_add_sensor(data, "temp", "input", in_index, page, | 1304 | pmbus_add_sensor(data, "temp", "input", in_index, page, |
| 1304 | pmbus_temp_registers[t], | 1305 | pmbus_temp_registers[t], |
| 1305 | PSC_TEMPERATURE, true); | 1306 | PSC_TEMPERATURE, true, true); |
| 1306 | 1307 | ||
| 1307 | /* | 1308 | /* |
| 1308 | * PMBus provides only one status register for TEMP1-3. | 1309 | * PMBus provides only one status register for TEMP1-3. |
| @@ -1323,7 +1324,7 @@ static void pmbus_find_attributes(struct i2c_client *client, | |||
| 1323 | i1 = data->num_sensors; | 1324 | i1 = data->num_sensors; |
| 1324 | pmbus_add_sensor(data, "temp", "min", in_index, | 1325 | pmbus_add_sensor(data, "temp", "min", in_index, |
| 1325 | page, PMBUS_UT_WARN_LIMIT, | 1326 | page, PMBUS_UT_WARN_LIMIT, |
| 1326 | PSC_TEMPERATURE, true); | 1327 | PSC_TEMPERATURE, true, false); |
| 1327 | if (info->func[page] & PMBUS_HAVE_STATUS_TEMP) { | 1328 | if (info->func[page] & PMBUS_HAVE_STATUS_TEMP) { |
| 1328 | pmbus_add_boolean_cmp(data, "temp", | 1329 | pmbus_add_boolean_cmp(data, "temp", |
| 1329 | "min_alarm", in_index, i1, i0, | 1330 | "min_alarm", in_index, i1, i0, |
| @@ -1338,7 +1339,7 @@ static void pmbus_find_attributes(struct i2c_client *client, | |||
| 1338 | pmbus_add_sensor(data, "temp", "lcrit", | 1339 | pmbus_add_sensor(data, "temp", "lcrit", |
| 1339 | in_index, page, | 1340 | in_index, page, |
| 1340 | PMBUS_UT_FAULT_LIMIT, | 1341 | PMBUS_UT_FAULT_LIMIT, |
| 1341 | PSC_TEMPERATURE, true); | 1342 | PSC_TEMPERATURE, true, false); |
| 1342 | if (info->func[page] & PMBUS_HAVE_STATUS_TEMP) { | 1343 | if (info->func[page] & PMBUS_HAVE_STATUS_TEMP) { |
| 1343 | pmbus_add_boolean_cmp(data, "temp", | 1344 | pmbus_add_boolean_cmp(data, "temp", |
| 1344 | "lcrit_alarm", in_index, i1, i0, | 1345 | "lcrit_alarm", in_index, i1, i0, |
| @@ -1352,7 +1353,7 @@ static void pmbus_find_attributes(struct i2c_client *client, | |||
| 1352 | i1 = data->num_sensors; | 1353 | i1 = data->num_sensors; |
| 1353 | pmbus_add_sensor(data, "temp", "max", in_index, | 1354 | pmbus_add_sensor(data, "temp", "max", in_index, |
| 1354 | page, PMBUS_OT_WARN_LIMIT, | 1355 | page, PMBUS_OT_WARN_LIMIT, |
| 1355 | PSC_TEMPERATURE, true); | 1356 | PSC_TEMPERATURE, true, false); |
| 1356 | if (info->func[page] & PMBUS_HAVE_STATUS_TEMP) { | 1357 | if (info->func[page] & PMBUS_HAVE_STATUS_TEMP) { |
| 1357 | pmbus_add_boolean_cmp(data, "temp", | 1358 | pmbus_add_boolean_cmp(data, "temp", |
| 1358 | "max_alarm", in_index, i0, i1, | 1359 | "max_alarm", in_index, i0, i1, |
| @@ -1366,7 +1367,7 @@ static void pmbus_find_attributes(struct i2c_client *client, | |||
| 1366 | i1 = data->num_sensors; | 1367 | i1 = data->num_sensors; |
| 1367 | pmbus_add_sensor(data, "temp", "crit", in_index, | 1368 | pmbus_add_sensor(data, "temp", "crit", in_index, |
| 1368 | page, PMBUS_OT_FAULT_LIMIT, | 1369 | page, PMBUS_OT_FAULT_LIMIT, |
| 1369 | PSC_TEMPERATURE, true); | 1370 | PSC_TEMPERATURE, true, false); |
| 1370 | if (info->func[page] & PMBUS_HAVE_STATUS_TEMP) { | 1371 | if (info->func[page] & PMBUS_HAVE_STATUS_TEMP) { |
| 1371 | pmbus_add_boolean_cmp(data, "temp", | 1372 | pmbus_add_boolean_cmp(data, "temp", |
| 1372 | "crit_alarm", in_index, i0, i1, | 1373 | "crit_alarm", in_index, i0, i1, |
| @@ -1421,7 +1422,8 @@ static void pmbus_find_attributes(struct i2c_client *client, | |||
| 1421 | 1422 | ||
| 1422 | i0 = data->num_sensors; | 1423 | i0 = data->num_sensors; |
| 1423 | pmbus_add_sensor(data, "fan", "input", in_index, page, | 1424 | pmbus_add_sensor(data, "fan", "input", in_index, page, |
| 1424 | pmbus_fan_registers[f], PSC_FAN, true); | 1425 | pmbus_fan_registers[f], PSC_FAN, true, |
| 1426 | true); | ||
| 1425 | 1427 | ||
| 1426 | /* | 1428 | /* |
| 1427 | * Each fan status register covers multiple fans, | 1429 | * Each fan status register covers multiple fans, |
diff --git a/drivers/hwspinlock/Kconfig b/drivers/hwspinlock/Kconfig index eb4af28f856..1f29bab6b3e 100644 --- a/drivers/hwspinlock/Kconfig +++ b/drivers/hwspinlock/Kconfig | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | config HWSPINLOCK | 5 | config HWSPINLOCK |
| 6 | tristate "Generic Hardware Spinlock framework" | 6 | tristate "Generic Hardware Spinlock framework" |
| 7 | depends on ARCH_OMAP4 | ||
| 7 | help | 8 | help |
| 8 | Say y here to support the generic hardware spinlock framework. | 9 | Say y here to support the generic hardware spinlock framework. |
| 9 | You only need to enable this if you have hardware spinlock module | 10 | You only need to enable this if you have hardware spinlock module |
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index f4077840d3a..0e406d73b2c 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c | |||
| @@ -440,6 +440,7 @@ void do_ide_request(struct request_queue *q) | |||
| 440 | struct ide_host *host = hwif->host; | 440 | struct ide_host *host = hwif->host; |
| 441 | struct request *rq = NULL; | 441 | struct request *rq = NULL; |
| 442 | ide_startstop_t startstop; | 442 | ide_startstop_t startstop; |
| 443 | unsigned long queue_run_ms = 3; /* old plug delay */ | ||
| 443 | 444 | ||
| 444 | spin_unlock_irq(q->queue_lock); | 445 | spin_unlock_irq(q->queue_lock); |
| 445 | 446 | ||
| @@ -459,6 +460,9 @@ repeat: | |||
| 459 | prev_port = hwif->host->cur_port; | 460 | prev_port = hwif->host->cur_port; |
| 460 | if (drive->dev_flags & IDE_DFLAG_SLEEPING && | 461 | if (drive->dev_flags & IDE_DFLAG_SLEEPING && |
| 461 | time_after(drive->sleep, jiffies)) { | 462 | time_after(drive->sleep, jiffies)) { |
| 463 | unsigned long left = jiffies - drive->sleep; | ||
| 464 | |||
| 465 | queue_run_ms = jiffies_to_msecs(left + 1); | ||
| 462 | ide_unlock_port(hwif); | 466 | ide_unlock_port(hwif); |
| 463 | goto plug_device; | 467 | goto plug_device; |
| 464 | } | 468 | } |
| @@ -547,8 +551,10 @@ plug_device: | |||
| 547 | plug_device_2: | 551 | plug_device_2: |
| 548 | spin_lock_irq(q->queue_lock); | 552 | spin_lock_irq(q->queue_lock); |
| 549 | 553 | ||
| 550 | if (rq) | 554 | if (rq) { |
| 551 | blk_requeue_request(q, rq); | 555 | blk_requeue_request(q, rq); |
| 556 | blk_delay_queue(q, queue_run_ms); | ||
| 557 | } | ||
| 552 | } | 558 | } |
| 553 | 559 | ||
| 554 | void ide_requeue_and_plug(ide_drive_t *drive, struct request *rq) | 560 | void ide_requeue_and_plug(ide_drive_t *drive, struct request *rq) |
| @@ -562,6 +568,10 @@ void ide_requeue_and_plug(ide_drive_t *drive, struct request *rq) | |||
| 562 | blk_requeue_request(q, rq); | 568 | blk_requeue_request(q, rq); |
| 563 | 569 | ||
| 564 | spin_unlock_irqrestore(q->queue_lock, flags); | 570 | spin_unlock_irqrestore(q->queue_lock, flags); |
| 571 | |||
| 572 | /* Use 3ms as that was the old plug delay */ | ||
| 573 | if (rq) | ||
| 574 | blk_delay_queue(q, 3); | ||
| 565 | } | 575 | } |
| 566 | 576 | ||
| 567 | static int drive_is_ready(ide_drive_t *drive) | 577 | static int drive_is_ready(ide_drive_t *drive) |
diff --git a/drivers/mfd/88pm860x-core.c b/drivers/mfd/88pm860x-core.c index 9c511c1604a..011cb6ce861 100644 --- a/drivers/mfd/88pm860x-core.c +++ b/drivers/mfd/88pm860x-core.c | |||
| @@ -416,7 +416,6 @@ static int __devinit device_irq_init(struct pm860x_chip *chip, | |||
| 416 | : chip->companion; | 416 | : chip->companion; |
| 417 | unsigned char status_buf[INT_STATUS_NUM]; | 417 | unsigned char status_buf[INT_STATUS_NUM]; |
| 418 | unsigned long flags = IRQF_TRIGGER_FALLING | IRQF_ONESHOT; | 418 | unsigned long flags = IRQF_TRIGGER_FALLING | IRQF_ONESHOT; |
| 419 | struct irq_desc *desc; | ||
| 420 | int i, data, mask, ret = -EINVAL; | 419 | int i, data, mask, ret = -EINVAL; |
| 421 | int __irq; | 420 | int __irq; |
| 422 | 421 | ||
| @@ -468,19 +467,17 @@ static int __devinit device_irq_init(struct pm860x_chip *chip, | |||
| 468 | if (!chip->core_irq) | 467 | if (!chip->core_irq) |
| 469 | goto out; | 468 | goto out; |
| 470 | 469 | ||
| 471 | desc = irq_to_desc(chip->core_irq); | ||
| 472 | |||
| 473 | /* register IRQ by genirq */ | 470 | /* register IRQ by genirq */ |
| 474 | for (i = 0; i < ARRAY_SIZE(pm860x_irqs); i++) { | 471 | for (i = 0; i < ARRAY_SIZE(pm860x_irqs); i++) { |
| 475 | __irq = i + chip->irq_base; | 472 | __irq = i + chip->irq_base; |
| 476 | set_irq_chip_data(__irq, chip); | 473 | irq_set_chip_data(__irq, chip); |
| 477 | set_irq_chip_and_handler(__irq, &pm860x_irq_chip, | 474 | irq_set_chip_and_handler(__irq, &pm860x_irq_chip, |
| 478 | handle_edge_irq); | 475 | handle_edge_irq); |
| 479 | set_irq_nested_thread(__irq, 1); | 476 | irq_set_nested_thread(__irq, 1); |
| 480 | #ifdef CONFIG_ARM | 477 | #ifdef CONFIG_ARM |
| 481 | set_irq_flags(__irq, IRQF_VALID); | 478 | set_irq_flags(__irq, IRQF_VALID); |
| 482 | #else | 479 | #else |
| 483 | set_irq_noprobe(__irq); | 480 | irq_set_noprobe(__irq); |
| 484 | #endif | 481 | #endif |
| 485 | } | 482 | } |
| 486 | 483 | ||
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index a9a1af49281..9a46d64996a 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig | |||
| @@ -133,6 +133,7 @@ config TPS6105X | |||
| 133 | tristate "TPS61050/61052 Boost Converters" | 133 | tristate "TPS61050/61052 Boost Converters" |
| 134 | depends on I2C | 134 | depends on I2C |
| 135 | select REGULATOR | 135 | select REGULATOR |
| 136 | select MFD_CORE | ||
| 136 | select REGULATOR_FIXED_VOLTAGE | 137 | select REGULATOR_FIXED_VOLTAGE |
| 137 | help | 138 | help |
| 138 | This option enables a driver for the TP61050/TPS61052 | 139 | This option enables a driver for the TP61050/TPS61052 |
| @@ -591,7 +592,7 @@ config AB3550_CORE | |||
| 591 | config MFD_CS5535 | 592 | config MFD_CS5535 |
| 592 | tristate "Support for CS5535 and CS5536 southbridge core functions" | 593 | tristate "Support for CS5535 and CS5536 southbridge core functions" |
| 593 | select MFD_CORE | 594 | select MFD_CORE |
| 594 | depends on PCI | 595 | depends on PCI && X86 |
| 595 | ---help--- | 596 | ---help--- |
| 596 | This is the core driver for CS5535/CS5536 MFD functions. This is | 597 | This is the core driver for CS5535/CS5536 MFD functions. This is |
| 597 | necessary for using the board's GPIO and MFGPT functionality. | 598 | necessary for using the board's GPIO and MFGPT functionality. |
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 47f5709f382..ef489f25340 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile | |||
| @@ -63,7 +63,7 @@ obj-$(CONFIG_UCB1400_CORE) += ucb1400_core.o | |||
| 63 | obj-$(CONFIG_PMIC_DA903X) += da903x.o | 63 | obj-$(CONFIG_PMIC_DA903X) += da903x.o |
| 64 | max8925-objs := max8925-core.o max8925-i2c.o | 64 | max8925-objs := max8925-core.o max8925-i2c.o |
| 65 | obj-$(CONFIG_MFD_MAX8925) += max8925.o | 65 | obj-$(CONFIG_MFD_MAX8925) += max8925.o |
| 66 | obj-$(CONFIG_MFD_MAX8997) += max8997.o | 66 | obj-$(CONFIG_MFD_MAX8997) += max8997.o max8997-irq.o |
| 67 | obj-$(CONFIG_MFD_MAX8998) += max8998.o max8998-irq.o | 67 | obj-$(CONFIG_MFD_MAX8998) += max8998.o max8998-irq.o |
| 68 | 68 | ||
| 69 | pcf50633-objs := pcf50633-core.o pcf50633-irq.o | 69 | pcf50633-objs := pcf50633-core.o pcf50633-irq.o |
diff --git a/drivers/mfd/ab3550-core.c b/drivers/mfd/ab3550-core.c index c12d0428522..ff86acf3e6b 100644 --- a/drivers/mfd/ab3550-core.c +++ b/drivers/mfd/ab3550-core.c | |||
| @@ -668,7 +668,7 @@ static int ab3550_startup_irq_enabled(struct device *dev, unsigned int irq) | |||
| 668 | struct ab3550_platform_data *plf_data; | 668 | struct ab3550_platform_data *plf_data; |
| 669 | bool val; | 669 | bool val; |
| 670 | 670 | ||
| 671 | ab = get_irq_chip_data(irq); | 671 | ab = irq_get_chip_data(irq); |
| 672 | plf_data = ab->i2c_client[0]->dev.platform_data; | 672 | plf_data = ab->i2c_client[0]->dev.platform_data; |
| 673 | irq -= plf_data->irq.base; | 673 | irq -= plf_data->irq.base; |
| 674 | val = ((ab->startup_events[irq / 8] & BIT(irq % 8)) != 0); | 674 | val = ((ab->startup_events[irq / 8] & BIT(irq % 8)) != 0); |
| @@ -1296,14 +1296,14 @@ static int __init ab3550_probe(struct i2c_client *client, | |||
| 1296 | unsigned int irq; | 1296 | unsigned int irq; |
| 1297 | 1297 | ||
| 1298 | irq = ab3550_plf_data->irq.base + i; | 1298 | irq = ab3550_plf_data->irq.base + i; |
| 1299 | set_irq_chip_data(irq, ab); | 1299 | irq_set_chip_data(irq, ab); |
| 1300 | set_irq_chip_and_handler(irq, &ab3550_irq_chip, | 1300 | irq_set_chip_and_handler(irq, &ab3550_irq_chip, |
| 1301 | handle_simple_irq); | 1301 | handle_simple_irq); |
| 1302 | set_irq_nested_thread(irq, 1); | 1302 | irq_set_nested_thread(irq, 1); |
| 1303 | #ifdef CONFIG_ARM | 1303 | #ifdef CONFIG_ARM |
| 1304 | set_irq_flags(irq, IRQF_VALID); | 1304 | set_irq_flags(irq, IRQF_VALID); |
| 1305 | #else | 1305 | #else |
| 1306 | set_irq_noprobe(irq); | 1306 | irq_set_noprobe(irq); |
| 1307 | #endif | 1307 | #endif |
| 1308 | } | 1308 | } |
| 1309 | 1309 | ||
diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c index 6e185b272d0..62e33e2258d 100644 --- a/drivers/mfd/ab8500-core.c +++ b/drivers/mfd/ab8500-core.c | |||
| @@ -334,14 +334,14 @@ static int ab8500_irq_init(struct ab8500 *ab8500) | |||
| 334 | int irq; | 334 | int irq; |
| 335 | 335 | ||
| 336 | for (irq = base; irq < base + AB8500_NR_IRQS; irq++) { | 336 | for (irq = base; irq < base + AB8500_NR_IRQS; irq++) { |
| 337 | set_irq_chip_data(irq, ab8500); | 337 | irq_set_chip_data(irq, ab8500); |
| 338 | set_irq_chip_and_handler(irq, &ab8500_irq_chip, | 338 | irq_set_chip_and_handler(irq, &ab8500_irq_chip, |
| 339 | handle_simple_irq); | 339 | handle_simple_irq); |
| 340 | set_irq_nested_thread(irq, 1); | 340 | irq_set_nested_thread(irq, 1); |
| 341 | #ifdef CONFIG_ARM | 341 | #ifdef CONFIG_ARM |
| 342 | set_irq_flags(irq, IRQF_VALID); | 342 | set_irq_flags(irq, IRQF_VALID); |
| 343 | #else | 343 | #else |
| 344 | set_irq_noprobe(irq); | 344 | irq_set_noprobe(irq); |
| 345 | #endif | 345 | #endif |
| 346 | } | 346 | } |
| 347 | 347 | ||
| @@ -357,8 +357,8 @@ static void ab8500_irq_remove(struct ab8500 *ab8500) | |||
| 357 | #ifdef CONFIG_ARM | 357 | #ifdef CONFIG_ARM |
| 358 | set_irq_flags(irq, 0); | 358 | set_irq_flags(irq, 0); |
| 359 | #endif | 359 | #endif |
| 360 | set_irq_chip_and_handler(irq, NULL, NULL); | 360 | irq_set_chip_and_handler(irq, NULL, NULL); |
| 361 | set_irq_chip_data(irq, NULL); | 361 | irq_set_chip_data(irq, NULL); |
| 362 | } | 362 | } |
| 363 | } | 363 | } |
| 364 | 364 | ||
diff --git a/drivers/mfd/asic3.c b/drivers/mfd/asic3.c index 0241f08fc00..d4a851c6b5b 100644 --- a/drivers/mfd/asic3.c +++ b/drivers/mfd/asic3.c | |||
| @@ -139,13 +139,12 @@ static void asic3_irq_flip_edge(struct asic3 *asic, | |||
| 139 | 139 | ||
| 140 | static void asic3_irq_demux(unsigned int irq, struct irq_desc *desc) | 140 | static void asic3_irq_demux(unsigned int irq, struct irq_desc *desc) |
| 141 | { | 141 | { |
| 142 | struct asic3 *asic = irq_desc_get_handler_data(desc); | ||
| 143 | struct irq_data *data = irq_desc_get_irq_data(desc); | ||
| 142 | int iter, i; | 144 | int iter, i; |
| 143 | unsigned long flags; | 145 | unsigned long flags; |
| 144 | struct asic3 *asic; | ||
| 145 | |||
| 146 | desc->irq_data.chip->irq_ack(&desc->irq_data); | ||
| 147 | 146 | ||
| 148 | asic = get_irq_data(irq); | 147 | data->chip->irq_ack(irq_data); |
| 149 | 148 | ||
| 150 | for (iter = 0 ; iter < MAX_ASIC_ISR_LOOPS; iter++) { | 149 | for (iter = 0 ; iter < MAX_ASIC_ISR_LOOPS; iter++) { |
| 151 | u32 status; | 150 | u32 status; |
| @@ -188,8 +187,7 @@ static void asic3_irq_demux(unsigned int irq, struct irq_desc *desc) | |||
| 188 | irqnr = asic->irq_base + | 187 | irqnr = asic->irq_base + |
| 189 | (ASIC3_GPIOS_PER_BANK * bank) | 188 | (ASIC3_GPIOS_PER_BANK * bank) |
| 190 | + i; | 189 | + i; |
| 191 | desc = irq_to_desc(irqnr); | 190 | generic_handle_irq(irqnr); |
| 192 | desc->handle_irq(irqnr, desc); | ||
| 193 | if (asic->irq_bothedge[bank] & bit) | 191 | if (asic->irq_bothedge[bank] & bit) |
| 194 | asic3_irq_flip_edge(asic, base, | 192 | asic3_irq_flip_edge(asic, base, |
| 195 | bit); | 193 | bit); |
| @@ -200,11 +198,8 @@ static void asic3_irq_demux(unsigned int irq, struct irq_desc *desc) | |||
| 200 | /* Handle remaining IRQs in the status register */ | 198 | /* Handle remaining IRQs in the status register */ |
| 201 | for (i = ASIC3_NUM_GPIOS; i < ASIC3_NR_IRQS; i++) { | 199 | for (i = ASIC3_NUM_GPIOS; i < ASIC3_NR_IRQS; i++) { |
| 202 | /* They start at bit 4 and go up */ | 200 | /* They start at bit 4 and go up */ |
| 203 | if (status & (1 << (i - ASIC3_NUM_GPIOS + 4))) { | 201 | if (status & (1 << (i - ASIC3_NUM_GPIOS + 4))) |
| 204 | desc = irq_to_desc(asic->irq_base + i); | 202 | generic_handle_irq(asic->irq_base + i); |
| 205 | desc->handle_irq(asic->irq_base + i, | ||
| 206 | desc); | ||
| 207 | } | ||
| 208 | } | 203 | } |
| 209 | } | 204 | } |
| 210 | 205 | ||
| @@ -393,21 +388,21 @@ static int __init asic3_irq_probe(struct platform_device *pdev) | |||
| 393 | 388 | ||
| 394 | for (irq = irq_base; irq < irq_base + ASIC3_NR_IRQS; irq++) { | 389 | for (irq = irq_base; irq < irq_base + ASIC3_NR_IRQS; irq++) { |
| 395 | if (irq < asic->irq_base + ASIC3_NUM_GPIOS) | 390 | if (irq < asic->irq_base + ASIC3_NUM_GPIOS) |
| 396 | set_irq_chip(irq, &asic3_gpio_irq_chip); | 391 | irq_set_chip(irq, &asic3_gpio_irq_chip); |
| 397 | else | 392 | else |
| 398 | set_irq_chip(irq, &asic3_irq_chip); | 393 | irq_set_chip(irq, &asic3_irq_chip); |
| 399 | 394 | ||
| 400 | set_irq_chip_data(irq, asic); | 395 | irq_set_chip_data(irq, asic); |
| 401 | set_irq_handler(irq, handle_level_irq); | 396 | irq_set_handler(irq, handle_level_irq); |
| 402 | set_irq_flags(irq, IRQF_VALID | IRQF_PROBE); | 397 | set_irq_flags(irq, IRQF_VALID | IRQF_PROBE); |
| 403 | } | 398 | } |
| 404 | 399 | ||
| 405 | asic3_write_register(asic, ASIC3_OFFSET(INTR, INT_MASK), | 400 | asic3_write_register(asic, ASIC3_OFFSET(INTR, INT_MASK), |
| 406 | ASIC3_INTMASK_GINTMASK); | 401 | ASIC3_INTMASK_GINTMASK); |
| 407 | 402 | ||
| 408 | set_irq_chained_handler(asic->irq_nr, asic3_irq_demux); | 403 | irq_set_chained_handler(asic->irq_nr, asic3_irq_demux); |
| 409 | set_irq_type(asic->irq_nr, IRQ_TYPE_EDGE_RISING); | 404 | irq_set_irq_type(asic->irq_nr, IRQ_TYPE_EDGE_RISING); |
| 410 | set_irq_data(asic->irq_nr, asic); | 405 | irq_set_handler_data(asic->irq_nr, asic); |
| 411 | 406 | ||
| 412 | return 0; | 407 | return 0; |
| 413 | } | 408 | } |
| @@ -421,11 +416,10 @@ static void asic3_irq_remove(struct platform_device *pdev) | |||
| 421 | 416 | ||
| 422 | for (irq = irq_base; irq < irq_base + ASIC3_NR_IRQS; irq++) { | 417 | for (irq = irq_base; irq < irq_base + ASIC3_NR_IRQS; irq++) { |
| 423 | set_irq_flags(irq, 0); | 418 | set_irq_flags(irq, 0); |
| 424 | set_irq_handler(irq, NULL); | 419 | irq_set_chip_and_handler(irq, NULL, NULL); |
| 425 | set_irq_chip(irq, NULL); | 420 | irq_set_chip_data(irq, NULL); |
| 426 | set_irq_chip_data(irq, NULL); | ||
| 427 | } | 421 | } |
| 428 | set_irq_chained_handler(asic->irq_nr, NULL); | 422 | irq_set_chained_handler(asic->irq_nr, NULL); |
| 429 | } | 423 | } |
| 430 | 424 | ||
| 431 | /* GPIOs */ | 425 | /* GPIOs */ |
diff --git a/drivers/mfd/cs5535-mfd.c b/drivers/mfd/cs5535-mfd.c index 886a0687106..155fa040788 100644 --- a/drivers/mfd/cs5535-mfd.c +++ b/drivers/mfd/cs5535-mfd.c | |||
| @@ -27,6 +27,7 @@ | |||
| 27 | #include <linux/mfd/core.h> | 27 | #include <linux/mfd/core.h> |
| 28 | #include <linux/module.h> | 28 | #include <linux/module.h> |
| 29 | #include <linux/pci.h> | 29 | #include <linux/pci.h> |
| 30 | #include <asm/olpc.h> | ||
| 30 | 31 | ||
| 31 | #define DRV_NAME "cs5535-mfd" | 32 | #define DRV_NAME "cs5535-mfd" |
| 32 | 33 | ||
| @@ -111,6 +112,20 @@ static __devinitdata struct mfd_cell cs5535_mfd_cells[] = { | |||
| 111 | }, | 112 | }, |
| 112 | }; | 113 | }; |
| 113 | 114 | ||
| 115 | #ifdef CONFIG_OLPC | ||
| 116 | static void __devinit cs5535_clone_olpc_cells(void) | ||
| 117 | { | ||
| 118 | const char *acpi_clones[] = { "olpc-xo1-pm-acpi", "olpc-xo1-sci-acpi" }; | ||
| 119 | |||
| 120 | if (!machine_is_olpc()) | ||
| 121 | return; | ||
| 122 | |||
| 123 | mfd_clone_cell("cs5535-acpi", acpi_clones, ARRAY_SIZE(acpi_clones)); | ||
| 124 | } | ||
| 125 | #else | ||
| 126 | static void cs5535_clone_olpc_cells(void) { } | ||
| 127 | #endif | ||
| 128 | |||
| 114 | static int __devinit cs5535_mfd_probe(struct pci_dev *pdev, | 129 | static int __devinit cs5535_mfd_probe(struct pci_dev *pdev, |
| 115 | const struct pci_device_id *id) | 130 | const struct pci_device_id *id) |
| 116 | { | 131 | { |
| @@ -139,6 +154,7 @@ static int __devinit cs5535_mfd_probe(struct pci_dev *pdev, | |||
| 139 | dev_err(&pdev->dev, "MFD add devices failed: %d\n", err); | 154 | dev_err(&pdev->dev, "MFD add devices failed: %d\n", err); |
| 140 | goto err_disable; | 155 | goto err_disable; |
| 141 | } | 156 | } |
| 157 | cs5535_clone_olpc_cells(); | ||
| 142 | 158 | ||
| 143 | dev_info(&pdev->dev, "%zu devices registered.\n", | 159 | dev_info(&pdev->dev, "%zu devices registered.\n", |
| 144 | ARRAY_SIZE(cs5535_mfd_cells)); | 160 | ARRAY_SIZE(cs5535_mfd_cells)); |
diff --git a/drivers/mfd/ezx-pcap.c b/drivers/mfd/ezx-pcap.c index 9e2d8dd5f9e..f2f4029e21a 100644 --- a/drivers/mfd/ezx-pcap.c +++ b/drivers/mfd/ezx-pcap.c | |||
| @@ -162,6 +162,7 @@ static void pcap_unmask_irq(struct irq_data *d) | |||
| 162 | 162 | ||
| 163 | static struct irq_chip pcap_irq_chip = { | 163 | static struct irq_chip pcap_irq_chip = { |
| 164 | .name = "pcap", | 164 | .name = "pcap", |
| 165 | .irq_disable = pcap_mask_irq, | ||
| 165 | .irq_mask = pcap_mask_irq, | 166 | .irq_mask = pcap_mask_irq, |
| 166 | .irq_unmask = pcap_unmask_irq, | 167 | .irq_unmask = pcap_unmask_irq, |
| 167 | }; | 168 | }; |
| @@ -196,17 +197,8 @@ static void pcap_isr_work(struct work_struct *work) | |||
| 196 | local_irq_disable(); | 197 | local_irq_disable(); |
| 197 | service = isr & ~msr; | 198 | service = isr & ~msr; |
| 198 | for (irq = pcap->irq_base; service; service >>= 1, irq++) { | 199 | for (irq = pcap->irq_base; service; service >>= 1, irq++) { |
| 199 | if (service & 1) { | 200 | if (service & 1) |
| 200 | struct irq_desc *desc = irq_to_desc(irq); | 201 | generic_handle_irq(irq); |
| 201 | |||
| 202 | if (WARN(!desc, "Invalid PCAP IRQ %d\n", irq)) | ||
| 203 | break; | ||
| 204 | |||
| 205 | if (desc->status & IRQ_DISABLED) | ||
| 206 | note_interrupt(irq, desc, IRQ_NONE); | ||
| 207 | else | ||
| 208 | desc->handle_irq(irq, desc); | ||
| 209 | } | ||
| 210 | } | 202 | } |
| 211 | local_irq_enable(); | 203 | local_irq_enable(); |
| 212 | ezx_pcap_write(pcap, PCAP_REG_MSR, pcap->msr); | 204 | ezx_pcap_write(pcap, PCAP_REG_MSR, pcap->msr); |
| @@ -215,7 +207,7 @@ static void pcap_isr_work(struct work_struct *work) | |||
| 215 | 207 | ||
| 216 | static void pcap_irq_handler(unsigned int irq, struct irq_desc *desc) | 208 | static void pcap_irq_handler(unsigned int irq, struct irq_desc *desc) |
| 217 | { | 209 | { |
| 218 | struct pcap_chip *pcap = get_irq_data(irq); | 210 | struct pcap_chip *pcap = irq_get_handler_data(irq); |
| 219 | 211 | ||
| 220 | desc->irq_data.chip->irq_ack(&desc->irq_data); | 212 | desc->irq_data.chip->irq_ack(&desc->irq_data); |
| 221 | queue_work(pcap->workqueue, &pcap->isr_work); | 213 | queue_work(pcap->workqueue, &pcap->isr_work); |
| @@ -419,7 +411,7 @@ static int __devexit ezx_pcap_remove(struct spi_device *spi) | |||
| 419 | 411 | ||
| 420 | /* cleanup irqchip */ | 412 | /* cleanup irqchip */ |
| 421 | for (i = pcap->irq_base; i < (pcap->irq_base + PCAP_NIRQS); i++) | 413 | for (i = pcap->irq_base; i < (pcap->irq_base + PCAP_NIRQS); i++) |
| 422 | set_irq_chip_and_handler(i, NULL, NULL); | 414 | irq_set_chip_and_handler(i, NULL, NULL); |
| 423 | 415 | ||
| 424 | destroy_workqueue(pcap->workqueue); | 416 | destroy_workqueue(pcap->workqueue); |
| 425 | 417 | ||
| @@ -476,12 +468,12 @@ static int __devinit ezx_pcap_probe(struct spi_device *spi) | |||
| 476 | 468 | ||
| 477 | /* setup irq chip */ | 469 | /* setup irq chip */ |
| 478 | for (i = pcap->irq_base; i < (pcap->irq_base + PCAP_NIRQS); i++) { | 470 | for (i = pcap->irq_base; i < (pcap->irq_base + PCAP_NIRQS); i++) { |
| 479 | set_irq_chip_and_handler(i, &pcap_irq_chip, handle_simple_irq); | 471 | irq_set_chip_and_handler(i, &pcap_irq_chip, handle_simple_irq); |
| 480 | set_irq_chip_data(i, pcap); | 472 | irq_set_chip_data(i, pcap); |
| 481 | #ifdef CONFIG_ARM | 473 | #ifdef CONFIG_ARM |
| 482 | set_irq_flags(i, IRQF_VALID); | 474 | set_irq_flags(i, IRQF_VALID); |
| 483 | #else | 475 | #else |
| 484 | set_irq_noprobe(i); | 476 | irq_set_noprobe(i); |
| 485 | #endif | 477 | #endif |
| 486 | } | 478 | } |
| 487 | 479 | ||
| @@ -490,10 +482,10 @@ static int __devinit ezx_pcap_probe(struct spi_device *spi) | |||
| 490 | ezx_pcap_write(pcap, PCAP_REG_ISR, PCAP_CLEAR_INTERRUPT_REGISTER); | 482 | ezx_pcap_write(pcap, PCAP_REG_ISR, PCAP_CLEAR_INTERRUPT_REGISTER); |
| 491 | pcap->msr = PCAP_MASK_ALL_INTERRUPT; | 483 | pcap->msr = PCAP_MASK_ALL_INTERRUPT; |
| 492 | 484 | ||
| 493 | set_irq_type(spi->irq, IRQ_TYPE_EDGE_RISING); | 485 | irq_set_irq_type(spi->irq, IRQ_TYPE_EDGE_RISING); |
| 494 | set_irq_data(spi->irq, pcap); | 486 | irq_set_handler_data(spi->irq, pcap); |
| 495 | set_irq_chained_handler(spi->irq, pcap_irq_handler); | 487 | irq_set_chained_handler(spi->irq, pcap_irq_handler); |
| 496 | set_irq_wake(spi->irq, 1); | 488 | irq_set_irq_wake(spi->irq, 1); |
| 497 | 489 | ||
| 498 | /* ADC */ | 490 | /* ADC */ |
| 499 | adc_irq = pcap_to_irq(pcap, (pdata->config & PCAP_SECOND_PORT) ? | 491 | adc_irq = pcap_to_irq(pcap, (pdata->config & PCAP_SECOND_PORT) ? |
| @@ -522,7 +514,7 @@ remove_subdevs: | |||
| 522 | free_irq(adc_irq, pcap); | 514 | free_irq(adc_irq, pcap); |
| 523 | free_irqchip: | 515 | free_irqchip: |
| 524 | for (i = pcap->irq_base; i < (pcap->irq_base + PCAP_NIRQS); i++) | 516 | for (i = pcap->irq_base; i < (pcap->irq_base + PCAP_NIRQS); i++) |
| 525 | set_irq_chip_and_handler(i, NULL, NULL); | 517 | irq_set_chip_and_handler(i, NULL, NULL); |
| 526 | /* destroy_workqueue: */ | 518 | /* destroy_workqueue: */ |
| 527 | destroy_workqueue(pcap->workqueue); | 519 | destroy_workqueue(pcap->workqueue); |
| 528 | free_pcap: | 520 | free_pcap: |
diff --git a/drivers/mfd/htc-egpio.c b/drivers/mfd/htc-egpio.c index d00b6d1a69e..bbaec0ccba8 100644 --- a/drivers/mfd/htc-egpio.c +++ b/drivers/mfd/htc-egpio.c | |||
| @@ -100,7 +100,7 @@ static struct irq_chip egpio_muxed_chip = { | |||
| 100 | 100 | ||
| 101 | static void egpio_handler(unsigned int irq, struct irq_desc *desc) | 101 | static void egpio_handler(unsigned int irq, struct irq_desc *desc) |
| 102 | { | 102 | { |
| 103 | struct egpio_info *ei = get_irq_data(irq); | 103 | struct egpio_info *ei = irq_desc_get_handler_data(desc); |
| 104 | int irqpin; | 104 | int irqpin; |
| 105 | 105 | ||
| 106 | /* Read current pins. */ | 106 | /* Read current pins. */ |
| @@ -113,9 +113,7 @@ static void egpio_handler(unsigned int irq, struct irq_desc *desc) | |||
| 113 | for_each_set_bit(irqpin, &readval, ei->nirqs) { | 113 | for_each_set_bit(irqpin, &readval, ei->nirqs) { |
| 114 | /* Run irq handler */ | 114 | /* Run irq handler */ |
| 115 | pr_debug("got IRQ %d\n", irqpin); | 115 | pr_debug("got IRQ %d\n", irqpin); |
| 116 | irq = ei->irq_start + irqpin; | 116 | generic_handle_irq(ei->irq_start + irqpin); |
| 117 | desc = irq_to_desc(irq); | ||
| 118 | desc->handle_irq(irq, desc); | ||
| 119 | } | 117 | } |
| 120 | } | 118 | } |
| 121 | 119 | ||
| @@ -346,14 +344,14 @@ static int __init egpio_probe(struct platform_device *pdev) | |||
| 346 | ei->ack_write = 0; | 344 | ei->ack_write = 0; |
| 347 | irq_end = ei->irq_start + ei->nirqs; | 345 | irq_end = ei->irq_start + ei->nirqs; |
| 348 | for (irq = ei->irq_start; irq < irq_end; irq++) { | 346 | for (irq = ei->irq_start; irq < irq_end; irq++) { |
| 349 | set_irq_chip(irq, &egpio_muxed_chip); | 347 | irq_set_chip_and_handler(irq, &egpio_muxed_chip, |
| 350 | set_irq_chip_data(irq, ei); | 348 | handle_simple_irq); |
| 351 | set_irq_handler(irq, handle_simple_irq); | 349 | irq_set_chip_data(irq, ei); |
| 352 | set_irq_flags(irq, IRQF_VALID | IRQF_PROBE); | 350 | set_irq_flags(irq, IRQF_VALID | IRQF_PROBE); |
| 353 | } | 351 | } |
| 354 | set_irq_type(ei->chained_irq, IRQ_TYPE_EDGE_RISING); | 352 | irq_set_irq_type(ei->chained_irq, IRQ_TYPE_EDGE_RISING); |
| 355 | set_irq_data(ei->chained_irq, ei); | 353 | irq_set_handler_data(ei->chained_irq, ei); |
| 356 | set_irq_chained_handler(ei->chained_irq, egpio_handler); | 354 | irq_set_chained_handler(ei->chained_irq, egpio_handler); |
| 357 | ack_irqs(ei); | 355 | ack_irqs(ei); |
| 358 | 356 | ||
| 359 | device_init_wakeup(&pdev->dev, 1); | 357 | device_init_wakeup(&pdev->dev, 1); |
| @@ -375,11 +373,10 @@ static int __exit egpio_remove(struct platform_device *pdev) | |||
| 375 | if (ei->chained_irq) { | 373 | if (ei->chained_irq) { |
| 376 | irq_end = ei->irq_start + ei->nirqs; | 374 | irq_end = ei->irq_start + ei->nirqs; |
| 377 | for (irq = ei->irq_start; irq < irq_end; irq++) { | 375 | for (irq = ei->irq_start; irq < irq_end; irq++) { |
| 378 | set_irq_chip(irq, NULL); | 376 | irq_set_chip_and_handler(irq, NULL, NULL); |
| 379 | set_irq_handler(irq, NULL); | ||
| 380 | set_irq_flags(irq, 0); | 377 | set_irq_flags(irq, 0); |
| 381 | } | 378 | } |
| 382 | set_irq_chained_handler(ei->chained_irq, NULL); | 379 | irq_set_chained_handler(ei->chained_irq, NULL); |
| 383 | device_init_wakeup(&pdev->dev, 0); | 380 | device_init_wakeup(&pdev->dev, 0); |
| 384 | } | 381 | } |
| 385 | iounmap(ei->base_addr); | 382 | iounmap(ei->base_addr); |
diff --git a/drivers/mfd/htc-i2cpld.c b/drivers/mfd/htc-i2cpld.c index 296ad1562f6..d55065cc324 100644 --- a/drivers/mfd/htc-i2cpld.c +++ b/drivers/mfd/htc-i2cpld.c | |||
| @@ -58,6 +58,7 @@ struct htcpld_chip { | |||
| 58 | uint irq_start; | 58 | uint irq_start; |
| 59 | int nirqs; | 59 | int nirqs; |
| 60 | 60 | ||
| 61 | unsigned int flow_type; | ||
| 61 | /* | 62 | /* |
| 62 | * Work structure to allow for setting values outside of any | 63 | * Work structure to allow for setting values outside of any |
| 63 | * possible interrupt context | 64 | * possible interrupt context |
| @@ -97,12 +98,7 @@ static void htcpld_unmask(struct irq_data *data) | |||
| 97 | 98 | ||
| 98 | static int htcpld_set_type(struct irq_data *data, unsigned int flags) | 99 | static int htcpld_set_type(struct irq_data *data, unsigned int flags) |
| 99 | { | 100 | { |
| 100 | struct irq_desc *d = irq_to_desc(data->irq); | 101 | struct htcpld_chip *chip = irq_data_get_irq_chip_data(data); |
| 101 | |||
| 102 | if (!d) { | ||
| 103 | pr_err("HTCPLD invalid IRQ: %d\n", data->irq); | ||
| 104 | return -EINVAL; | ||
| 105 | } | ||
| 106 | 102 | ||
| 107 | if (flags & ~IRQ_TYPE_SENSE_MASK) | 103 | if (flags & ~IRQ_TYPE_SENSE_MASK) |
| 108 | return -EINVAL; | 104 | return -EINVAL; |
| @@ -111,9 +107,7 @@ static int htcpld_set_type(struct irq_data *data, unsigned int flags) | |||
| 111 | if (flags & (IRQ_TYPE_LEVEL_LOW|IRQ_TYPE_LEVEL_HIGH)) | 107 | if (flags & (IRQ_TYPE_LEVEL_LOW|IRQ_TYPE_LEVEL_HIGH)) |
| 112 | return -EINVAL; | 108 | return -EINVAL; |
| 113 | 109 | ||
| 114 | d->status &= ~IRQ_TYPE_SENSE_MASK; | 110 | chip->flow_type = flags; |
| 115 | d->status |= flags; | ||
| 116 | |||
| 117 | return 0; | 111 | return 0; |
| 118 | } | 112 | } |
| 119 | 113 | ||
| @@ -135,7 +129,6 @@ static irqreturn_t htcpld_handler(int irq, void *dev) | |||
| 135 | unsigned int i; | 129 | unsigned int i; |
| 136 | unsigned long flags; | 130 | unsigned long flags; |
| 137 | int irqpin; | 131 | int irqpin; |
| 138 | struct irq_desc *desc; | ||
| 139 | 132 | ||
| 140 | if (!htcpld) { | 133 | if (!htcpld) { |
| 141 | pr_debug("htcpld is null in ISR\n"); | 134 | pr_debug("htcpld is null in ISR\n"); |
| @@ -195,23 +188,19 @@ static irqreturn_t htcpld_handler(int irq, void *dev) | |||
| 195 | * associated interrupts. | 188 | * associated interrupts. |
| 196 | */ | 189 | */ |
| 197 | for (irqpin = 0; irqpin < chip->nirqs; irqpin++) { | 190 | for (irqpin = 0; irqpin < chip->nirqs; irqpin++) { |
| 198 | unsigned oldb, newb; | 191 | unsigned oldb, newb, type = chip->flow_type; |
| 199 | int flags; | ||
| 200 | 192 | ||
| 201 | irq = chip->irq_start + irqpin; | 193 | irq = chip->irq_start + irqpin; |
| 202 | desc = irq_to_desc(irq); | ||
| 203 | flags = desc->status; | ||
| 204 | 194 | ||
| 205 | /* Run the IRQ handler, but only if the bit value | 195 | /* Run the IRQ handler, but only if the bit value |
| 206 | * changed, and the proper flags are set */ | 196 | * changed, and the proper flags are set */ |
| 207 | oldb = (old_val >> irqpin) & 1; | 197 | oldb = (old_val >> irqpin) & 1; |
| 208 | newb = (uval >> irqpin) & 1; | 198 | newb = (uval >> irqpin) & 1; |
| 209 | 199 | ||
| 210 | if ((!oldb && newb && (flags & IRQ_TYPE_EDGE_RISING)) || | 200 | if ((!oldb && newb && (type & IRQ_TYPE_EDGE_RISING)) || |
| 211 | (oldb && !newb && | 201 | (oldb && !newb && (type & IRQ_TYPE_EDGE_FALLING))) { |
| 212 | (flags & IRQ_TYPE_EDGE_FALLING))) { | ||
| 213 | pr_debug("fire IRQ %d\n", irqpin); | 202 | pr_debug("fire IRQ %d\n", irqpin); |
| 214 | desc->handle_irq(irq, desc); | 203 | generic_handle_irq(irq); |
| 215 | } | 204 | } |
| 216 | } | 205 | } |
| 217 | } | 206 | } |
| @@ -359,13 +348,13 @@ static int __devinit htcpld_setup_chip_irq( | |||
| 359 | /* Setup irq handlers */ | 348 | /* Setup irq handlers */ |
| 360 | irq_end = chip->irq_start + chip->nirqs; | 349 | irq_end = chip->irq_start + chip->nirqs; |
| 361 | for (irq = chip->irq_start; irq < irq_end; irq++) { | 350 | for (irq = chip->irq_start; irq < irq_end; irq++) { |
| 362 | set_irq_chip(irq, &htcpld_muxed_chip); | 351 | irq_set_chip_and_handler(irq, &htcpld_muxed_chip, |
| 363 | set_irq_chip_data(irq, chip); | 352 | handle_simple_irq); |
| 364 | set_irq_handler(irq, handle_simple_irq); | 353 | irq_set_chip_data(irq, chip); |
| 365 | #ifdef CONFIG_ARM | 354 | #ifdef CONFIG_ARM |
| 366 | set_irq_flags(irq, IRQF_VALID | IRQF_PROBE); | 355 | set_irq_flags(irq, IRQF_VALID | IRQF_PROBE); |
| 367 | #else | 356 | #else |
| 368 | set_irq_probe(irq); | 357 | irq_set_probe(irq); |
| 369 | #endif | 358 | #endif |
| 370 | } | 359 | } |
| 371 | 360 | ||
diff --git a/drivers/mfd/jz4740-adc.c b/drivers/mfd/jz4740-adc.c index aa518b9beaf..a0bd0cf05af 100644 --- a/drivers/mfd/jz4740-adc.c +++ b/drivers/mfd/jz4740-adc.c | |||
| @@ -112,7 +112,7 @@ static struct irq_chip jz4740_adc_irq_chip = { | |||
| 112 | 112 | ||
| 113 | static void jz4740_adc_irq_demux(unsigned int irq, struct irq_desc *desc) | 113 | static void jz4740_adc_irq_demux(unsigned int irq, struct irq_desc *desc) |
| 114 | { | 114 | { |
| 115 | struct jz4740_adc *adc = get_irq_desc_data(desc); | 115 | struct jz4740_adc *adc = irq_desc_get_handler_data(desc); |
| 116 | uint8_t status; | 116 | uint8_t status; |
| 117 | unsigned int i; | 117 | unsigned int i; |
| 118 | 118 | ||
| @@ -310,13 +310,13 @@ static int __devinit jz4740_adc_probe(struct platform_device *pdev) | |||
| 310 | platform_set_drvdata(pdev, adc); | 310 | platform_set_drvdata(pdev, adc); |
| 311 | 311 | ||
| 312 | for (irq = adc->irq_base; irq < adc->irq_base + 5; ++irq) { | 312 | for (irq = adc->irq_base; irq < adc->irq_base + 5; ++irq) { |
| 313 | set_irq_chip_data(irq, adc); | 313 | irq_set_chip_data(irq, adc); |
| 314 | set_irq_chip_and_handler(irq, &jz4740_adc_irq_chip, | 314 | irq_set_chip_and_handler(irq, &jz4740_adc_irq_chip, |
| 315 | handle_level_irq); | 315 | handle_level_irq); |
| 316 | } | 316 | } |
| 317 | 317 | ||
| 318 | set_irq_data(adc->irq, adc); | 318 | irq_set_handler_data(adc->irq, adc); |
| 319 | set_irq_chained_handler(adc->irq, jz4740_adc_irq_demux); | 319 | irq_set_chained_handler(adc->irq, jz4740_adc_irq_demux); |
| 320 | 320 | ||
| 321 | writeb(0x00, adc->base + JZ_REG_ADC_ENABLE); | 321 | writeb(0x00, adc->base + JZ_REG_ADC_ENABLE); |
| 322 | writeb(0xff, adc->base + JZ_REG_ADC_CTRL); | 322 | writeb(0xff, adc->base + JZ_REG_ADC_CTRL); |
| @@ -347,8 +347,8 @@ static int __devexit jz4740_adc_remove(struct platform_device *pdev) | |||
| 347 | 347 | ||
| 348 | mfd_remove_devices(&pdev->dev); | 348 | mfd_remove_devices(&pdev->dev); |
| 349 | 349 | ||
| 350 | set_irq_data(adc->irq, NULL); | 350 | irq_set_handler_data(adc->irq, NULL); |
| 351 | set_irq_chained_handler(adc->irq, NULL); | 351 | irq_set_chained_handler(adc->irq, NULL); |
| 352 | 352 | ||
| 353 | iounmap(adc->base); | 353 | iounmap(adc->base); |
| 354 | release_mem_region(adc->mem->start, resource_size(adc->mem)); | 354 | release_mem_region(adc->mem->start, resource_size(adc->mem)); |
diff --git a/drivers/mfd/max8925-core.c b/drivers/mfd/max8925-core.c index 0e998dc4e7d..58cc5fdde01 100644 --- a/drivers/mfd/max8925-core.c +++ b/drivers/mfd/max8925-core.c | |||
| @@ -517,7 +517,6 @@ static int max8925_irq_init(struct max8925_chip *chip, int irq, | |||
| 517 | struct max8925_platform_data *pdata) | 517 | struct max8925_platform_data *pdata) |
| 518 | { | 518 | { |
| 519 | unsigned long flags = IRQF_TRIGGER_FALLING | IRQF_ONESHOT; | 519 | unsigned long flags = IRQF_TRIGGER_FALLING | IRQF_ONESHOT; |
| 520 | struct irq_desc *desc; | ||
| 521 | int i, ret; | 520 | int i, ret; |
| 522 | int __irq; | 521 | int __irq; |
| 523 | 522 | ||
| @@ -544,19 +543,18 @@ static int max8925_irq_init(struct max8925_chip *chip, int irq, | |||
| 544 | mutex_init(&chip->irq_lock); | 543 | mutex_init(&chip->irq_lock); |
| 545 | chip->core_irq = irq; | 544 | chip->core_irq = irq; |
| 546 | chip->irq_base = pdata->irq_base; | 545 | chip->irq_base = pdata->irq_base; |
| 547 | desc = irq_to_desc(chip->core_irq); | ||
| 548 | 546 | ||
| 549 | /* register with genirq */ | 547 | /* register with genirq */ |
| 550 | for (i = 0; i < ARRAY_SIZE(max8925_irqs); i++) { | 548 | for (i = 0; i < ARRAY_SIZE(max8925_irqs); i++) { |
| 551 | __irq = i + chip->irq_base; | 549 | __irq = i + chip->irq_base; |
| 552 | set_irq_chip_data(__irq, chip); | 550 | irq_set_chip_data(__irq, chip); |
| 553 | set_irq_chip_and_handler(__irq, &max8925_irq_chip, | 551 | irq_set_chip_and_handler(__irq, &max8925_irq_chip, |
| 554 | handle_edge_irq); | 552 | handle_edge_irq); |
| 555 | set_irq_nested_thread(__irq, 1); | 553 | irq_set_nested_thread(__irq, 1); |
| 556 | #ifdef CONFIG_ARM | 554 | #ifdef CONFIG_ARM |
| 557 | set_irq_flags(__irq, IRQF_VALID); | 555 | set_irq_flags(__irq, IRQF_VALID); |
| 558 | #else | 556 | #else |
| 559 | set_irq_noprobe(__irq); | 557 | irq_set_noprobe(__irq); |
| 560 | #endif | 558 | #endif |
| 561 | } | 559 | } |
| 562 | if (!irq) { | 560 | if (!irq) { |
diff --git a/drivers/mfd/max8997-irq.c b/drivers/mfd/max8997-irq.c new file mode 100644 index 00000000000..638bf7e4d3b --- /dev/null +++ b/drivers/mfd/max8997-irq.c | |||
| @@ -0,0 +1,377 @@ | |||
| 1 | /* | ||
| 2 | * max8997-irq.c - Interrupt controller support for MAX8997 | ||
| 3 | * | ||
| 4 | * Copyright (C) 2011 Samsung Electronics Co.Ltd | ||
| 5 | * MyungJoo Ham <myungjoo.ham@samsung.com> | ||
| 6 | * | ||
| 7 | * This program is free software; you can redistribute it and/or modify | ||
| 8 | * it under the terms of the GNU General Public License as published by | ||
| 9 | * the Free Software Foundation; either version 2 of the License, or | ||
| 10 | * (at your option) any later version. | ||
| 11 | * | ||
| 12 | * This program is distributed in the hope that it will be useful, | ||
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | * GNU General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License | ||
| 18 | * along with this program; if not, write to the Free Software | ||
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 20 | * | ||
| 21 | * This driver is based on max8998-irq.c | ||
| 22 | */ | ||
| 23 | |||
| 24 | #include <linux/err.h> | ||
| 25 | #include <linux/irq.h> | ||
| 26 | #include <linux/interrupt.h> | ||
| 27 | #include <linux/mfd/max8997.h> | ||
| 28 | #include <linux/mfd/max8997-private.h> | ||
| 29 | |||
| 30 | static const u8 max8997_mask_reg[] = { | ||
| 31 | [PMIC_INT1] = MAX8997_REG_INT1MSK, | ||
| 32 | [PMIC_INT2] = MAX8997_REG_INT2MSK, | ||
| 33 | [PMIC_INT3] = MAX8997_REG_INT3MSK, | ||
| 34 | [PMIC_INT4] = MAX8997_REG_INT4MSK, | ||
| 35 | [FUEL_GAUGE] = MAX8997_REG_INVALID, | ||
| 36 | [MUIC_INT1] = MAX8997_MUIC_REG_INTMASK1, | ||
| 37 | [MUIC_INT2] = MAX8997_MUIC_REG_INTMASK2, | ||
| 38 | [MUIC_INT3] = MAX8997_MUIC_REG_INTMASK3, | ||
| 39 | [GPIO_LOW] = MAX8997_REG_INVALID, | ||
| 40 | [GPIO_HI] = MAX8997_REG_INVALID, | ||
| 41 | [FLASH_STATUS] = MAX8997_REG_INVALID, | ||
| 42 | }; | ||
| 43 | |||
| 44 | static struct i2c_client *get_i2c(struct max8997_dev *max8997, | ||
| 45 | enum max8997_irq_source src) | ||
| 46 | { | ||
| 47 | switch (src) { | ||
| 48 | case PMIC_INT1 ... PMIC_INT4: | ||
| 49 | return max8997->i2c; | ||
| 50 | case FUEL_GAUGE: | ||
| 51 | return NULL; | ||
| 52 | case MUIC_INT1 ... MUIC_INT3: | ||
| 53 | return max8997->muic; | ||
| 54 | case GPIO_LOW ... GPIO_HI: | ||
| 55 | return max8997->i2c; | ||
| 56 | case FLASH_STATUS: | ||
| 57 | return max8997->i2c; | ||
| 58 | default: | ||
| 59 | return ERR_PTR(-EINVAL); | ||
| 60 | } | ||
| 61 | |||
| 62 | return ERR_PTR(-EINVAL); | ||
| 63 | } | ||
| 64 | |||
| 65 | struct max8997_irq_data { | ||
| 66 | int mask; | ||
| 67 | enum max8997_irq_source group; | ||
| 68 | }; | ||
| 69 | |||
| 70 | #define DECLARE_IRQ(idx, _group, _mask) \ | ||
| 71 | [(idx)] = { .group = (_group), .mask = (_mask) } | ||
| 72 | static const struct max8997_irq_data max8997_irqs[] = { | ||
| 73 | DECLARE_IRQ(MAX8997_PMICIRQ_PWRONR, PMIC_INT1, 1 << 0), | ||
| 74 | DECLARE_IRQ(MAX8997_PMICIRQ_PWRONF, PMIC_INT1, 1 << 1), | ||
| 75 | DECLARE_IRQ(MAX8997_PMICIRQ_PWRON1SEC, PMIC_INT1, 1 << 3), | ||
| 76 | DECLARE_IRQ(MAX8997_PMICIRQ_JIGONR, PMIC_INT1, 1 << 4), | ||
| 77 | DECLARE_IRQ(MAX8997_PMICIRQ_JIGONF, PMIC_INT1, 1 << 5), | ||
| 78 | DECLARE_IRQ(MAX8997_PMICIRQ_LOWBAT2, PMIC_INT1, 1 << 6), | ||
| 79 | DECLARE_IRQ(MAX8997_PMICIRQ_LOWBAT1, PMIC_INT1, 1 << 7), | ||
| 80 | |||
| 81 | DECLARE_IRQ(MAX8997_PMICIRQ_JIGR, PMIC_INT2, 1 << 0), | ||
| 82 | DECLARE_IRQ(MAX8997_PMICIRQ_JIGF, PMIC_INT2, 1 << 1), | ||
| 83 | DECLARE_IRQ(MAX8997_PMICIRQ_MR, PMIC_INT2, 1 << 2), | ||
| 84 | DECLARE_IRQ(MAX8997_PMICIRQ_DVS1OK, PMIC_INT2, 1 << 3), | ||
| 85 | DECLARE_IRQ(MAX8997_PMICIRQ_DVS2OK, PMIC_INT2, 1 << 4), | ||
| 86 | DECLARE_IRQ(MAX8997_PMICIRQ_DVS3OK, PMIC_INT2, 1 << 5), | ||
| 87 | DECLARE_IRQ(MAX8997_PMICIRQ_DVS4OK, PMIC_INT2, 1 << 6), | ||
| 88 | |||
| 89 | DECLARE_IRQ(MAX8997_PMICIRQ_CHGINS, PMIC_INT3, 1 << 0), | ||
| 90 | DECLARE_IRQ(MAX8997_PMICIRQ_CHGRM, PMIC_INT3, 1 << 1), | ||
| 91 | DECLARE_IRQ(MAX8997_PMICIRQ_DCINOVP, PMIC_INT3, 1 << 2), | ||
| 92 | DECLARE_IRQ(MAX8997_PMICIRQ_TOPOFFR, PMIC_INT3, 1 << 3), | ||
| 93 | DECLARE_IRQ(MAX8997_PMICIRQ_CHGRSTF, PMIC_INT3, 1 << 5), | ||
| 94 | DECLARE_IRQ(MAX8997_PMICIRQ_MBCHGTMEXPD, PMIC_INT3, 1 << 7), | ||
| 95 | |||
| 96 | DECLARE_IRQ(MAX8997_PMICIRQ_RTC60S, PMIC_INT4, 1 << 0), | ||
| 97 | DECLARE_IRQ(MAX8997_PMICIRQ_RTCA1, PMIC_INT4, 1 << 1), | ||
| 98 | DECLARE_IRQ(MAX8997_PMICIRQ_RTCA2, PMIC_INT4, 1 << 2), | ||
| 99 | DECLARE_IRQ(MAX8997_PMICIRQ_SMPL_INT, PMIC_INT4, 1 << 3), | ||
| 100 | DECLARE_IRQ(MAX8997_PMICIRQ_RTC1S, PMIC_INT4, 1 << 4), | ||
| 101 | DECLARE_IRQ(MAX8997_PMICIRQ_WTSR, PMIC_INT4, 1 << 5), | ||
| 102 | |||
| 103 | DECLARE_IRQ(MAX8997_MUICIRQ_ADCError, MUIC_INT1, 1 << 2), | ||
| 104 | DECLARE_IRQ(MAX8997_MUICIRQ_ADCLow, MUIC_INT1, 1 << 1), | ||
| 105 | DECLARE_IRQ(MAX8997_MUICIRQ_ADC, MUIC_INT1, 1 << 0), | ||
| 106 | |||
| 107 | DECLARE_IRQ(MAX8997_MUICIRQ_VBVolt, MUIC_INT2, 1 << 4), | ||
| 108 | DECLARE_IRQ(MAX8997_MUICIRQ_DBChg, MUIC_INT2, 1 << 3), | ||
| 109 | DECLARE_IRQ(MAX8997_MUICIRQ_DCDTmr, MUIC_INT2, 1 << 2), | ||
| 110 | DECLARE_IRQ(MAX8997_MUICIRQ_ChgDetRun, MUIC_INT2, 1 << 1), | ||
| 111 | DECLARE_IRQ(MAX8997_MUICIRQ_ChgTyp, MUIC_INT2, 1 << 0), | ||
| 112 | |||
| 113 | DECLARE_IRQ(MAX8997_MUICIRQ_OVP, MUIC_INT3, 1 << 2), | ||
| 114 | }; | ||
| 115 | |||
| 116 | static void max8997_irq_lock(struct irq_data *data) | ||
| 117 | { | ||
| 118 | struct max8997_dev *max8997 = irq_get_chip_data(data->irq); | ||
| 119 | |||
| 120 | mutex_lock(&max8997->irqlock); | ||
| 121 | } | ||
| 122 | |||
| 123 | static void max8997_irq_sync_unlock(struct irq_data *data) | ||
| 124 | { | ||
| 125 | struct max8997_dev *max8997 = irq_get_chip_data(data->irq); | ||
| 126 | int i; | ||
| 127 | |||
| 128 | for (i = 0; i < MAX8997_IRQ_GROUP_NR; i++) { | ||
| 129 | u8 mask_reg = max8997_mask_reg[i]; | ||
| 130 | struct i2c_client *i2c = get_i2c(max8997, i); | ||
| 131 | |||
| 132 | if (mask_reg == MAX8997_REG_INVALID || | ||
| 133 | IS_ERR_OR_NULL(i2c)) | ||
| 134 | continue; | ||
| 135 | max8997->irq_masks_cache[i] = max8997->irq_masks_cur[i]; | ||
| 136 | |||
| 137 | max8997_write_reg(i2c, max8997_mask_reg[i], | ||
| 138 | max8997->irq_masks_cur[i]); | ||
| 139 | } | ||
| 140 | |||
| 141 | mutex_unlock(&max8997->irqlock); | ||
| 142 | } | ||
| 143 | |||
| 144 | static const inline struct max8997_irq_data * | ||
| 145 | irq_to_max8997_irq(struct max8997_dev *max8997, int irq) | ||
| 146 | { | ||
| 147 | return &max8997_irqs[irq - max8997->irq_base]; | ||
| 148 | } | ||
| 149 | |||
| 150 | static void max8997_irq_mask(struct irq_data *data) | ||
| 151 | { | ||
| 152 | struct max8997_dev *max8997 = irq_get_chip_data(data->irq); | ||
| 153 | const struct max8997_irq_data *irq_data = irq_to_max8997_irq(max8997, | ||
| 154 | data->irq); | ||
| 155 | |||
| 156 | max8997->irq_masks_cur[irq_data->group] |= irq_data->mask; | ||
| 157 | } | ||
| 158 | |||
| 159 | static void max8997_irq_unmask(struct irq_data *data) | ||
| 160 | { | ||
| 161 | struct max8997_dev *max8997 = irq_get_chip_data(data->irq); | ||
| 162 | const struct max8997_irq_data *irq_data = irq_to_max8997_irq(max8997, | ||
| 163 | data->irq); | ||
| 164 | |||
| 165 | max8997->irq_masks_cur[irq_data->group] &= ~irq_data->mask; | ||
| 166 | } | ||
| 167 | |||
| 168 | static struct irq_chip max8997_irq_chip = { | ||
| 169 | .name = "max8997", | ||
| 170 | .irq_bus_lock = max8997_irq_lock, | ||
| 171 | .irq_bus_sync_unlock = max8997_irq_sync_unlock, | ||
| 172 | .irq_mask = max8997_irq_mask, | ||
| 173 | .irq_unmask = max8997_irq_unmask, | ||
| 174 | }; | ||
| 175 | |||
| 176 | #define MAX8997_IRQSRC_PMIC (1 << 1) | ||
| 177 | #define MAX8997_IRQSRC_FUELGAUGE (1 << 2) | ||
| 178 | #define MAX8997_IRQSRC_MUIC (1 << 3) | ||
| 179 | #define MAX8997_IRQSRC_GPIO (1 << 4) | ||
| 180 | #define MAX8997_IRQSRC_FLASH (1 << 5) | ||
| 181 | static irqreturn_t max8997_irq_thread(int irq, void *data) | ||
| 182 | { | ||
| 183 | struct max8997_dev *max8997 = data; | ||
| 184 | u8 irq_reg[MAX8997_IRQ_GROUP_NR] = {}; | ||
| 185 | u8 irq_src; | ||
| 186 | int ret; | ||
| 187 | int i; | ||
| 188 | |||
| 189 | ret = max8997_read_reg(max8997->i2c, MAX8997_REG_INTSRC, &irq_src); | ||
| 190 | if (ret < 0) { | ||
| 191 | dev_err(max8997->dev, "Failed to read interrupt source: %d\n", | ||
| 192 | ret); | ||
| 193 | return IRQ_NONE; | ||
| 194 | } | ||
| 195 | |||
| 196 | if (irq_src & MAX8997_IRQSRC_PMIC) { | ||
| 197 | /* PMIC INT1 ~ INT4 */ | ||
| 198 | max8997_bulk_read(max8997->i2c, MAX8997_REG_INT1, 4, | ||
| 199 | &irq_reg[PMIC_INT1]); | ||
| 200 | } | ||
| 201 | if (irq_src & MAX8997_IRQSRC_FUELGAUGE) { | ||
| 202 | /* | ||
| 203 | * TODO: FUEL GAUGE | ||
| 204 | * | ||
| 205 | * This is to be supported by Max17042 driver. When | ||
| 206 | * an interrupt incurs here, it should be relayed to a | ||
| 207 | * Max17042 device that is connected (probably by | ||
| 208 | * platform-data). However, we do not have interrupt | ||
| 209 | * handling in Max17042 driver currently. The Max17042 IRQ | ||
| 210 | * driver should be ready to be used as a stand-alone device and | ||
| 211 | * a Max8997-dependent device. Because it is not ready in | ||
| 212 | * Max17042-side and it is not too critical in operating | ||
| 213 | * Max8997, we do not implement this in initial releases. | ||
| 214 | */ | ||
| 215 | irq_reg[FUEL_GAUGE] = 0; | ||
| 216 | } | ||
| 217 | if (irq_src & MAX8997_IRQSRC_MUIC) { | ||
| 218 | /* MUIC INT1 ~ INT3 */ | ||
| 219 | max8997_bulk_read(max8997->muic, MAX8997_MUIC_REG_INT1, 3, | ||
| 220 | &irq_reg[MUIC_INT1]); | ||
| 221 | } | ||
| 222 | if (irq_src & MAX8997_IRQSRC_GPIO) { | ||
| 223 | /* GPIO Interrupt */ | ||
| 224 | u8 gpio_info[MAX8997_NUM_GPIO]; | ||
| 225 | |||
| 226 | irq_reg[GPIO_LOW] = 0; | ||
| 227 | irq_reg[GPIO_HI] = 0; | ||
| 228 | |||
| 229 | max8997_bulk_read(max8997->i2c, MAX8997_REG_GPIOCNTL1, | ||
| 230 | MAX8997_NUM_GPIO, gpio_info); | ||
| 231 | for (i = 0; i < MAX8997_NUM_GPIO; i++) { | ||
| 232 | bool interrupt = false; | ||
| 233 | |||
| 234 | switch (gpio_info[i] & MAX8997_GPIO_INT_MASK) { | ||
| 235 | case MAX8997_GPIO_INT_BOTH: | ||
| 236 | if (max8997->gpio_status[i] != gpio_info[i]) | ||
| 237 | interrupt = true; | ||
| 238 | break; | ||
| 239 | case MAX8997_GPIO_INT_RISE: | ||
| 240 | if ((max8997->gpio_status[i] != gpio_info[i]) && | ||
| 241 | (gpio_info[i] & MAX8997_GPIO_DATA_MASK)) | ||
| 242 | interrupt = true; | ||
| 243 | break; | ||
| 244 | case MAX8997_GPIO_INT_FALL: | ||
| 245 | if ((max8997->gpio_status[i] != gpio_info[i]) && | ||
| 246 | !(gpio_info[i] & MAX8997_GPIO_DATA_MASK)) | ||
| 247 | interrupt = true; | ||
| 248 | break; | ||
| 249 | default: | ||
| 250 | break; | ||
| 251 | } | ||
| 252 | |||
| 253 | if (interrupt) { | ||
| 254 | if (i < 8) | ||
| 255 | irq_reg[GPIO_LOW] |= (1 << i); | ||
| 256 | else | ||
| 257 | irq_reg[GPIO_HI] |= (1 << (i - 8)); | ||
| 258 | } | ||
| 259 | |||
| 260 | } | ||
| 261 | } | ||
| 262 | if (irq_src & MAX8997_IRQSRC_FLASH) { | ||
| 263 | /* Flash Status Interrupt */ | ||
| 264 | ret = max8997_read_reg(max8997->i2c, MAX8997_REG_FLASHSTATUS, | ||
| 265 | &irq_reg[FLASH_STATUS]); | ||
| 266 | } | ||
| 267 | |||
| 268 | /* Apply masking */ | ||
| 269 | for (i = 0; i < MAX8997_IRQ_GROUP_NR; i++) | ||
| 270 | irq_reg[i] &= ~max8997->irq_masks_cur[i]; | ||
| 271 | |||
| 272 | /* Report */ | ||
| 273 | for (i = 0; i < MAX8997_IRQ_NR; i++) { | ||
| 274 | if (irq_reg[max8997_irqs[i].group] & max8997_irqs[i].mask) | ||
| 275 | handle_nested_irq(max8997->irq_base + i); | ||
| 276 | } | ||
| 277 | |||
| 278 | return IRQ_HANDLED; | ||
| 279 | } | ||
| 280 | |||
| 281 | int max8997_irq_resume(struct max8997_dev *max8997) | ||
| 282 | { | ||
| 283 | if (max8997->irq && max8997->irq_base) | ||
| 284 | max8997_irq_thread(max8997->irq_base, max8997); | ||
| 285 | return 0; | ||
| 286 | } | ||
| 287 | |||
| 288 | int max8997_irq_init(struct max8997_dev *max8997) | ||
| 289 | { | ||
| 290 | int i; | ||
| 291 | int cur_irq; | ||
| 292 | int ret; | ||
| 293 | u8 val; | ||
| 294 | |||
| 295 | if (!max8997->irq) { | ||
| 296 | dev_warn(max8997->dev, "No interrupt specified.\n"); | ||
| 297 | max8997->irq_base = 0; | ||
| 298 | return 0; | ||
| 299 | } | ||
| 300 | |||
| 301 | if (!max8997->irq_base) { | ||
| 302 | dev_err(max8997->dev, "No interrupt base specified.\n"); | ||
| 303 | return 0; | ||
| 304 | } | ||
| 305 | |||
| 306 | mutex_init(&max8997->irqlock); | ||
| 307 | |||
| 308 | /* Mask individual interrupt sources */ | ||
| 309 | for (i = 0; i < MAX8997_IRQ_GROUP_NR; i++) { | ||
| 310 | struct i2c_client *i2c; | ||
| 311 | |||
| 312 | max8997->irq_masks_cur[i] = 0xff; | ||
| 313 | max8997->irq_masks_cache[i] = 0xff; | ||
| 314 | i2c = get_i2c(max8997, i); | ||
| 315 | |||
| 316 | if (IS_ERR_OR_NULL(i2c)) | ||
| 317 | continue; | ||
| 318 | if (max8997_mask_reg[i] == MAX8997_REG_INVALID) | ||
| 319 | continue; | ||
| 320 | |||
| 321 | max8997_write_reg(i2c, max8997_mask_reg[i], 0xff); | ||
| 322 | } | ||
| 323 | |||
| 324 | for (i = 0; i < MAX8997_NUM_GPIO; i++) { | ||
| 325 | max8997->gpio_status[i] = (max8997_read_reg(max8997->i2c, | ||
| 326 | MAX8997_REG_GPIOCNTL1 + i, | ||
| 327 | &val) | ||
| 328 | & MAX8997_GPIO_DATA_MASK) ? | ||
| 329 | true : false; | ||
| 330 | } | ||
| 331 | |||
| 332 | /* Register with genirq */ | ||
| 333 | for (i = 0; i < MAX8997_IRQ_NR; i++) { | ||
| 334 | cur_irq = i + max8997->irq_base; | ||
| 335 | irq_set_chip_data(cur_irq, max8997); | ||
| 336 | irq_set_chip_and_handler(cur_irq, &max8997_irq_chip, | ||
| 337 | handle_edge_irq); | ||
| 338 | irq_set_nested_thread(cur_irq, 1); | ||
| 339 | #ifdef CONFIG_ARM | ||
| 340 | set_irq_flags(cur_irq, IRQF_VALID); | ||
| 341 | #else | ||
| 342 | irq_set_noprobe(cur_irq); | ||
| 343 | #endif | ||
| 344 | } | ||
| 345 | |||
| 346 | ret = request_threaded_irq(max8997->irq, NULL, max8997_irq_thread, | ||
| 347 | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, | ||
| 348 | "max8997-irq", max8997); | ||
| 349 | |||
| 350 | if (ret) { | ||
| 351 | dev_err(max8997->dev, "Failed to request IRQ %d: %d\n", | ||
| 352 | max8997->irq, ret); | ||
| 353 | return ret; | ||
| 354 | } | ||
| 355 | |||
| 356 | if (!max8997->ono) | ||
| 357 | return 0; | ||
| 358 | |||
| 359 | ret = request_threaded_irq(max8997->ono, NULL, max8997_irq_thread, | ||
| 360 | IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING | | ||
| 361 | IRQF_ONESHOT, "max8997-ono", max8997); | ||
| 362 | |||
| 363 | if (ret) | ||
| 364 | dev_err(max8997->dev, "Failed to request ono-IRQ %d: %d\n", | ||
| 365 | max8997->ono, ret); | ||
| 366 | |||
| 367 | return 0; | ||
| 368 | } | ||
| 369 | |||
| 370 | void max8997_irq_exit(struct max8997_dev *max8997) | ||
| 371 | { | ||
| 372 | if (max8997->ono) | ||
| 373 | free_irq(max8997->ono, max8997); | ||
| 374 | |||
| 375 | if (max8997->irq) | ||
| 376 | free_irq(max8997->irq, max8997); | ||
| 377 | } | ||
diff --git a/drivers/mfd/max8998-irq.c b/drivers/mfd/max8998-irq.c index 3903e1fbb33..5919710dc9e 100644 --- a/drivers/mfd/max8998-irq.c +++ b/drivers/mfd/max8998-irq.c | |||
| @@ -224,14 +224,14 @@ int max8998_irq_init(struct max8998_dev *max8998) | |||
| 224 | /* register with genirq */ | 224 | /* register with genirq */ |
| 225 | for (i = 0; i < MAX8998_IRQ_NR; i++) { | 225 | for (i = 0; i < MAX8998_IRQ_NR; i++) { |
| 226 | cur_irq = i + max8998->irq_base; | 226 | cur_irq = i + max8998->irq_base; |
| 227 | set_irq_chip_data(cur_irq, max8998); | 227 | irq_set_chip_data(cur_irq, max8998); |
| 228 | set_irq_chip_and_handler(cur_irq, &max8998_irq_chip, | 228 | irq_set_chip_and_handler(cur_irq, &max8998_irq_chip, |
| 229 | handle_edge_irq); | 229 | handle_edge_irq); |
| 230 | set_irq_nested_thread(cur_irq, 1); | 230 | irq_set_nested_thread(cur_irq, 1); |
| 231 | #ifdef CONFIG_ARM | 231 | #ifdef CONFIG_ARM |
| 232 | set_irq_flags(cur_irq, IRQF_VALID); | 232 | set_irq_flags(cur_irq, IRQF_VALID); |
| 233 | #else | 233 | #else |
| 234 | set_irq_noprobe(cur_irq); | 234 | irq_set_noprobe(cur_irq); |
| 235 | #endif | 235 | #endif |
| 236 | } | 236 | } |
| 237 | 237 | ||
diff --git a/drivers/mfd/max8998.c b/drivers/mfd/max8998.c index c00214257da..9ec7570f5b8 100644 --- a/drivers/mfd/max8998.c +++ b/drivers/mfd/max8998.c | |||
| @@ -209,7 +209,7 @@ static int max8998_suspend(struct device *dev) | |||
| 209 | struct max8998_dev *max8998 = i2c_get_clientdata(i2c); | 209 | struct max8998_dev *max8998 = i2c_get_clientdata(i2c); |
| 210 | 210 | ||
| 211 | if (max8998->wakeup) | 211 | if (max8998->wakeup) |
| 212 | set_irq_wake(max8998->irq, 1); | 212 | irq_set_irq_wake(max8998->irq, 1); |
| 213 | return 0; | 213 | return 0; |
| 214 | } | 214 | } |
| 215 | 215 | ||
| @@ -219,7 +219,7 @@ static int max8998_resume(struct device *dev) | |||
| 219 | struct max8998_dev *max8998 = i2c_get_clientdata(i2c); | 219 | struct max8998_dev *max8998 = i2c_get_clientdata(i2c); |
| 220 | 220 | ||
| 221 | if (max8998->wakeup) | 221 | if (max8998->wakeup) |
| 222 | set_irq_wake(max8998->irq, 0); | 222 | irq_set_irq_wake(max8998->irq, 0); |
| 223 | /* | 223 | /* |
| 224 | * In LP3974, if IRQ registers are not "read & clear" | 224 | * In LP3974, if IRQ registers are not "read & clear" |
| 225 | * when it's set during sleep, the interrupt becomes | 225 | * when it's set during sleep, the interrupt becomes |
diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c index 79eda0264fb..d01574d9887 100644 --- a/drivers/mfd/mfd-core.c +++ b/drivers/mfd/mfd-core.c | |||
| @@ -184,16 +184,12 @@ void mfd_remove_devices(struct device *parent) | |||
| 184 | } | 184 | } |
| 185 | EXPORT_SYMBOL(mfd_remove_devices); | 185 | EXPORT_SYMBOL(mfd_remove_devices); |
| 186 | 186 | ||
| 187 | static int add_shared_platform_device(const char *cell, const char *name) | 187 | int mfd_clone_cell(const char *cell, const char **clones, size_t n_clones) |
| 188 | { | 188 | { |
| 189 | struct mfd_cell cell_entry; | 189 | struct mfd_cell cell_entry; |
| 190 | struct device *dev; | 190 | struct device *dev; |
| 191 | struct platform_device *pdev; | 191 | struct platform_device *pdev; |
| 192 | int err; | 192 | int i; |
| 193 | |||
| 194 | /* check if we've already registered a device (don't fail if we have) */ | ||
| 195 | if (bus_find_device_by_name(&platform_bus_type, NULL, name)) | ||
| 196 | return 0; | ||
| 197 | 193 | ||
| 198 | /* fetch the parent cell's device (should already be registered!) */ | 194 | /* fetch the parent cell's device (should already be registered!) */ |
| 199 | dev = bus_find_device_by_name(&platform_bus_type, NULL, cell); | 195 | dev = bus_find_device_by_name(&platform_bus_type, NULL, cell); |
| @@ -206,44 +202,17 @@ static int add_shared_platform_device(const char *cell, const char *name) | |||
| 206 | 202 | ||
| 207 | WARN_ON(!cell_entry.enable); | 203 | WARN_ON(!cell_entry.enable); |
| 208 | 204 | ||
| 209 | cell_entry.name = name; | 205 | for (i = 0; i < n_clones; i++) { |
| 210 | err = mfd_add_device(pdev->dev.parent, -1, &cell_entry, NULL, 0); | 206 | cell_entry.name = clones[i]; |
| 211 | if (err) | 207 | /* don't give up if a single call fails; just report error */ |
| 212 | dev_err(dev, "MFD add devices failed: %d\n", err); | 208 | if (mfd_add_device(pdev->dev.parent, -1, &cell_entry, NULL, 0)) |
| 213 | return err; | 209 | dev_err(dev, "failed to create platform device '%s'\n", |
| 214 | } | 210 | clones[i]); |
| 215 | 211 | } | |
| 216 | int mfd_shared_platform_driver_register(struct platform_driver *drv, | ||
| 217 | const char *cellname) | ||
| 218 | { | ||
| 219 | int err; | ||
| 220 | |||
| 221 | err = add_shared_platform_device(cellname, drv->driver.name); | ||
| 222 | if (err) | ||
| 223 | printk(KERN_ERR "failed to add platform device %s\n", | ||
| 224 | drv->driver.name); | ||
| 225 | |||
| 226 | err = platform_driver_register(drv); | ||
| 227 | if (err) | ||
| 228 | printk(KERN_ERR "failed to add platform driver %s\n", | ||
| 229 | drv->driver.name); | ||
| 230 | |||
| 231 | return err; | ||
| 232 | } | ||
| 233 | EXPORT_SYMBOL(mfd_shared_platform_driver_register); | ||
| 234 | |||
| 235 | void mfd_shared_platform_driver_unregister(struct platform_driver *drv) | ||
| 236 | { | ||
| 237 | struct device *dev; | ||
| 238 | |||
| 239 | dev = bus_find_device_by_name(&platform_bus_type, NULL, | ||
| 240 | drv->driver.name); | ||
| 241 | if (dev) | ||
| 242 | platform_device_unregister(to_platform_device(dev)); | ||
| 243 | 212 | ||
| 244 | platform_driver_unregister(drv); | 213 | return 0; |
| 245 | } | 214 | } |
| 246 | EXPORT_SYMBOL(mfd_shared_platform_driver_unregister); | 215 | EXPORT_SYMBOL(mfd_clone_cell); |
| 247 | 216 | ||
| 248 | MODULE_LICENSE("GPL"); | 217 | MODULE_LICENSE("GPL"); |
| 249 | MODULE_AUTHOR("Ian Molton, Dmitry Baryshkov"); | 218 | MODULE_AUTHOR("Ian Molton, Dmitry Baryshkov"); |
diff --git a/drivers/mfd/pcf50633-core.c b/drivers/mfd/pcf50633-core.c index c1306ed43e3..c7687f6a78a 100644 --- a/drivers/mfd/pcf50633-core.c +++ b/drivers/mfd/pcf50633-core.c | |||
| @@ -356,7 +356,7 @@ static int __devexit pcf50633_remove(struct i2c_client *client) | |||
| 356 | return 0; | 356 | return 0; |
| 357 | } | 357 | } |
| 358 | 358 | ||
| 359 | static struct i2c_device_id pcf50633_id_table[] = { | 359 | static const struct i2c_device_id pcf50633_id_table[] = { |
| 360 | {"pcf50633", 0x73}, | 360 | {"pcf50633", 0x73}, |
| 361 | {/* end of list */} | 361 | {/* end of list */} |
| 362 | }; | 362 | }; |
diff --git a/drivers/mfd/rdc321x-southbridge.c b/drivers/mfd/rdc321x-southbridge.c index 193c940225b..10dbe6374a8 100644 --- a/drivers/mfd/rdc321x-southbridge.c +++ b/drivers/mfd/rdc321x-southbridge.c | |||
| @@ -97,6 +97,7 @@ static DEFINE_PCI_DEVICE_TABLE(rdc321x_sb_table) = { | |||
| 97 | { PCI_DEVICE(PCI_VENDOR_ID_RDC, PCI_DEVICE_ID_RDC_R6030) }, | 97 | { PCI_DEVICE(PCI_VENDOR_ID_RDC, PCI_DEVICE_ID_RDC_R6030) }, |
| 98 | {} | 98 | {} |
| 99 | }; | 99 | }; |
| 100 | MODULE_DEVICE_TABLE(pci, rdc321x_sb_table); | ||
| 100 | 101 | ||
| 101 | static struct pci_driver rdc321x_sb_driver = { | 102 | static struct pci_driver rdc321x_sb_driver = { |
| 102 | .name = "RDC321x Southbridge", | 103 | .name = "RDC321x Southbridge", |
diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c index 3e5732b58c4..7ab7746631d 100644 --- a/drivers/mfd/stmpe.c +++ b/drivers/mfd/stmpe.c | |||
| @@ -762,14 +762,14 @@ static int __devinit stmpe_irq_init(struct stmpe *stmpe) | |||
| 762 | int irq; | 762 | int irq; |
| 763 | 763 | ||
| 764 | for (irq = base; irq < base + num_irqs; irq++) { | 764 | for (irq = base; irq < base + num_irqs; irq++) { |
| 765 | set_irq_chip_data(irq, stmpe); | 765 | irq_set_chip_data(irq, stmpe); |
| 766 | set_irq_chip_and_handler(irq, &stmpe_irq_chip, | 766 | irq_set_chip_and_handler(irq, &stmpe_irq_chip, |
| 767 | handle_edge_irq); | 767 | handle_edge_irq); |
| 768 | set_irq_nested_thread(irq, 1); | 768 | irq_set_nested_thread(irq, 1); |
| 769 | #ifdef CONFIG_ARM | 769 | #ifdef CONFIG_ARM |
| 770 | set_irq_flags(irq, IRQF_VALID); | 770 | set_irq_flags(irq, IRQF_VALID); |
| 771 | #else | 771 | #else |
| 772 | set_irq_noprobe(irq); | 772 | irq_set_noprobe(irq); |
| 773 | #endif | 773 | #endif |
| 774 | } | 774 | } |
| 775 | 775 | ||
| @@ -786,8 +786,8 @@ static void stmpe_irq_remove(struct stmpe *stmpe) | |||
| 786 | #ifdef CONFIG_ARM | 786 | #ifdef CONFIG_ARM |
| 787 | set_irq_flags(irq, 0); | 787 | set_irq_flags(irq, 0); |
| 788 | #endif | 788 | #endif |
| 789 | set_irq_chip_and_handler(irq, NULL, NULL); | 789 | irq_set_chip_and_handler(irq, NULL, NULL); |
| 790 | set_irq_chip_data(irq, NULL); | 790 | irq_set_chip_data(irq, NULL); |
| 791 | } | 791 | } |
| 792 | } | 792 | } |
| 793 | 793 | ||
diff --git a/drivers/mfd/t7l66xb.c b/drivers/mfd/t7l66xb.c index af57fc706a4..42830e69296 100644 --- a/drivers/mfd/t7l66xb.c +++ b/drivers/mfd/t7l66xb.c | |||
| @@ -186,7 +186,7 @@ static struct mfd_cell t7l66xb_cells[] = { | |||
| 186 | /* Handle the T7L66XB interrupt mux */ | 186 | /* Handle the T7L66XB interrupt mux */ |
| 187 | static void t7l66xb_irq(unsigned int irq, struct irq_desc *desc) | 187 | static void t7l66xb_irq(unsigned int irq, struct irq_desc *desc) |
| 188 | { | 188 | { |
| 189 | struct t7l66xb *t7l66xb = get_irq_data(irq); | 189 | struct t7l66xb *t7l66xb = irq_get_handler_data(irq); |
| 190 | unsigned int isr; | 190 | unsigned int isr; |
| 191 | unsigned int i, irq_base; | 191 | unsigned int i, irq_base; |
| 192 | 192 | ||
| @@ -243,17 +243,16 @@ static void t7l66xb_attach_irq(struct platform_device *dev) | |||
| 243 | irq_base = t7l66xb->irq_base; | 243 | irq_base = t7l66xb->irq_base; |
| 244 | 244 | ||
| 245 | for (irq = irq_base; irq < irq_base + T7L66XB_NR_IRQS; irq++) { | 245 | for (irq = irq_base; irq < irq_base + T7L66XB_NR_IRQS; irq++) { |
| 246 | set_irq_chip(irq, &t7l66xb_chip); | 246 | irq_set_chip_and_handler(irq, &t7l66xb_chip, handle_level_irq); |
| 247 | set_irq_chip_data(irq, t7l66xb); | 247 | irq_set_chip_data(irq, t7l66xb); |
| 248 | set_irq_handler(irq, handle_level_irq); | ||
| 249 | #ifdef CONFIG_ARM | 248 | #ifdef CONFIG_ARM |
| 250 | set_irq_flags(irq, IRQF_VALID | IRQF_PROBE); | 249 | set_irq_flags(irq, IRQF_VALID | IRQF_PROBE); |
| 251 | #endif | 250 | #endif |
| 252 | } | 251 | } |
| 253 | 252 | ||
| 254 | set_irq_type(t7l66xb->irq, IRQ_TYPE_EDGE_FALLING); | 253 | irq_set_irq_type(t7l66xb->irq, IRQ_TYPE_EDGE_FALLING); |
| 255 | set_irq_data(t7l66xb->irq, t7l66xb); | 254 | irq_set_handler_data(t7l66xb->irq, t7l66xb); |
| 256 | set_irq_chained_handler(t7l66xb->irq, t7l66xb_irq); | 255 | irq_set_chained_handler(t7l66xb->irq, t7l66xb_irq); |
| 257 | } | 256 | } |
| 258 | 257 | ||
| 259 | static void t7l66xb_detach_irq(struct platform_device *dev) | 258 | static void t7l66xb_detach_irq(struct platform_device *dev) |
| @@ -263,15 +262,15 @@ static void t7l66xb_detach_irq(struct platform_device *dev) | |||
| 263 | 262 | ||
| 264 | irq_base = t7l66xb->irq_base; | 263 | irq_base = t7l66xb->irq_base; |
| 265 | 264 | ||
| 266 | set_irq_chained_handler(t7l66xb->irq, NULL); | 265 | irq_set_chained_handler(t7l66xb->irq, NULL); |
| 267 | set_irq_data(t7l66xb->irq, NULL); | 266 | irq_set_handler_data(t7l66xb->irq, NULL); |
| 268 | 267 | ||
| 269 | for (irq = irq_base; irq < irq_base + T7L66XB_NR_IRQS; irq++) { | 268 | for (irq = irq_base; irq < irq_base + T7L66XB_NR_IRQS; irq++) { |
| 270 | #ifdef CONFIG_ARM | 269 | #ifdef CONFIG_ARM |
| 271 | set_irq_flags(irq, 0); | 270 | set_irq_flags(irq, 0); |
| 272 | #endif | 271 | #endif |
| 273 | set_irq_chip(irq, NULL); | 272 | irq_set_chip(irq, NULL); |
| 274 | set_irq_chip_data(irq, NULL); | 273 | irq_set_chip_data(irq, NULL); |
| 275 | } | 274 | } |
| 276 | } | 275 | } |
| 277 | 276 | ||
diff --git a/drivers/mfd/tc3589x.c b/drivers/mfd/tc3589x.c index 729dbeed2ce..c27e515b072 100644 --- a/drivers/mfd/tc3589x.c +++ b/drivers/mfd/tc3589x.c | |||
| @@ -192,14 +192,14 @@ static int tc3589x_irq_init(struct tc3589x *tc3589x) | |||
| 192 | int irq; | 192 | int irq; |
| 193 | 193 | ||
| 194 | for (irq = base; irq < base + TC3589x_NR_INTERNAL_IRQS; irq++) { | 194 | for (irq = base; irq < base + TC3589x_NR_INTERNAL_IRQS; irq++) { |
| 195 | set_irq_chip_data(irq, tc3589x); | 195 | irq_set_chip_data(irq, tc3589x); |
| 196 | set_irq_chip_and_handler(irq, &dummy_irq_chip, | 196 | irq_set_chip_and_handler(irq, &dummy_irq_chip, |
| 197 | handle_edge_irq); | 197 | handle_edge_irq); |
| 198 | set_irq_nested_thread(irq, 1); | 198 | irq_set_nested_thread(irq, 1); |
| 199 | #ifdef CONFIG_ARM | 199 | #ifdef CONFIG_ARM |
| 200 | set_irq_flags(irq, IRQF_VALID); | 200 | set_irq_flags(irq, IRQF_VALID); |
| 201 | #else | 201 | #else |
| 202 | set_irq_noprobe(irq); | 202 | irq_set_noprobe(irq); |
| 203 | #endif | 203 | #endif |
| 204 | } | 204 | } |
| 205 | 205 | ||
| @@ -215,8 +215,8 @@ static void tc3589x_irq_remove(struct tc3589x *tc3589x) | |||
| 215 | #ifdef CONFIG_ARM | 215 | #ifdef CONFIG_ARM |
| 216 | set_irq_flags(irq, 0); | 216 | set_irq_flags(irq, 0); |
| 217 | #endif | 217 | #endif |
| 218 | set_irq_chip_and_handler(irq, NULL, NULL); | 218 | irq_set_chip_and_handler(irq, NULL, NULL); |
| 219 | set_irq_chip_data(irq, NULL); | 219 | irq_set_chip_data(irq, NULL); |
| 220 | } | 220 | } |
| 221 | } | 221 | } |
| 222 | 222 | ||
diff --git a/drivers/mfd/tc6393xb.c b/drivers/mfd/tc6393xb.c index 3d62ded86a8..fc53ce28760 100644 --- a/drivers/mfd/tc6393xb.c +++ b/drivers/mfd/tc6393xb.c | |||
| @@ -513,7 +513,7 @@ static int tc6393xb_register_gpio(struct tc6393xb *tc6393xb, int gpio_base) | |||
| 513 | static void | 513 | static void |
| 514 | tc6393xb_irq(unsigned int irq, struct irq_desc *desc) | 514 | tc6393xb_irq(unsigned int irq, struct irq_desc *desc) |
| 515 | { | 515 | { |
| 516 | struct tc6393xb *tc6393xb = get_irq_data(irq); | 516 | struct tc6393xb *tc6393xb = irq_get_handler_data(irq); |
| 517 | unsigned int isr; | 517 | unsigned int isr; |
| 518 | unsigned int i, irq_base; | 518 | unsigned int i, irq_base; |
| 519 | 519 | ||
| @@ -572,15 +572,14 @@ static void tc6393xb_attach_irq(struct platform_device *dev) | |||
| 572 | irq_base = tc6393xb->irq_base; | 572 | irq_base = tc6393xb->irq_base; |
| 573 | 573 | ||
| 574 | for (irq = irq_base; irq < irq_base + TC6393XB_NR_IRQS; irq++) { | 574 | for (irq = irq_base; irq < irq_base + TC6393XB_NR_IRQS; irq++) { |
| 575 | set_irq_chip(irq, &tc6393xb_chip); | 575 | irq_set_chip_and_handler(irq, &tc6393xb_chip, handle_edge_irq); |
| 576 | set_irq_chip_data(irq, tc6393xb); | 576 | irq_set_chip_data(irq, tc6393xb); |
| 577 | set_irq_handler(irq, handle_edge_irq); | ||
| 578 | set_irq_flags(irq, IRQF_VALID | IRQF_PROBE); | 577 | set_irq_flags(irq, IRQF_VALID | IRQF_PROBE); |
| 579 | } | 578 | } |
| 580 | 579 | ||
| 581 | set_irq_type(tc6393xb->irq, IRQ_TYPE_EDGE_FALLING); | 580 | irq_set_irq_type(tc6393xb->irq, IRQ_TYPE_EDGE_FALLING); |
| 582 | set_irq_data(tc6393xb->irq, tc6393xb); | 581 | irq_set_handler_data(tc6393xb->irq, tc6393xb); |
| 583 | set_irq_chained_handler(tc6393xb->irq, tc6393xb_irq); | 582 | irq_set_chained_handler(tc6393xb->irq, tc6393xb_irq); |
| 584 | } | 583 | } |
| 585 | 584 | ||
| 586 | static void tc6393xb_detach_irq(struct platform_device *dev) | 585 | static void tc6393xb_detach_irq(struct platform_device *dev) |
| @@ -588,15 +587,15 @@ static void tc6393xb_detach_irq(struct platform_device *dev) | |||
| 588 | struct tc6393xb *tc6393xb = platform_get_drvdata(dev); | 587 | struct tc6393xb *tc6393xb = platform_get_drvdata(dev); |
| 589 | unsigned int irq, irq_base; | 588 | unsigned int irq, irq_base; |
| 590 | 589 | ||
| 591 | set_irq_chained_handler(tc6393xb->irq, NULL); | 590 | irq_set_chained_handler(tc6393xb->irq, NULL); |
| 592 | set_irq_data(tc6393xb->irq, NULL); | 591 | irq_set_handler_data(tc6393xb->irq, NULL); |
| 593 | 592 | ||
| 594 | irq_base = tc6393xb->irq_base; | 593 | irq_base = tc6393xb->irq_base; |
| 595 | 594 | ||
| 596 | for (irq = irq_base; irq < irq_base + TC6393XB_NR_IRQS; irq++) { | 595 | for (irq = irq_base; irq < irq_base + TC6393XB_NR_IRQS; irq++) { |
| 597 | set_irq_flags(irq, 0); | 596 | set_irq_flags(irq, 0); |
| 598 | set_irq_chip(irq, NULL); | 597 | irq_set_chip(irq, NULL); |
| 599 | set_irq_chip_data(irq, NULL); | 598 | irq_set_chip_data(irq, NULL); |
| 600 | } | 599 | } |
| 601 | } | 600 | } |
| 602 | 601 | ||
diff --git a/drivers/mfd/tps6586x.c b/drivers/mfd/tps6586x.c index 0aa9186aec1..b600808690c 100644 --- a/drivers/mfd/tps6586x.c +++ b/drivers/mfd/tps6586x.c | |||
| @@ -422,10 +422,10 @@ static int __devinit tps6586x_irq_init(struct tps6586x *tps6586x, int irq, | |||
| 422 | 422 | ||
| 423 | for (i = 0; i < ARRAY_SIZE(tps6586x_irqs); i++) { | 423 | for (i = 0; i < ARRAY_SIZE(tps6586x_irqs); i++) { |
| 424 | int __irq = i + tps6586x->irq_base; | 424 | int __irq = i + tps6586x->irq_base; |
| 425 | set_irq_chip_data(__irq, tps6586x); | 425 | irq_set_chip_data(__irq, tps6586x); |
| 426 | set_irq_chip_and_handler(__irq, &tps6586x->irq_chip, | 426 | irq_set_chip_and_handler(__irq, &tps6586x->irq_chip, |
| 427 | handle_simple_irq); | 427 | handle_simple_irq); |
| 428 | set_irq_nested_thread(__irq, 1); | 428 | irq_set_nested_thread(__irq, 1); |
| 429 | #ifdef CONFIG_ARM | 429 | #ifdef CONFIG_ARM |
| 430 | set_irq_flags(__irq, IRQF_VALID); | 430 | set_irq_flags(__irq, IRQF_VALID); |
| 431 | #endif | 431 | #endif |
diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c index 63a30e88908..8a7ee3139b8 100644 --- a/drivers/mfd/twl4030-irq.c +++ b/drivers/mfd/twl4030-irq.c | |||
| @@ -320,24 +320,8 @@ static int twl4030_irq_thread(void *data) | |||
| 320 | for (module_irq = twl4030_irq_base; | 320 | for (module_irq = twl4030_irq_base; |
| 321 | pih_isr; | 321 | pih_isr; |
| 322 | pih_isr >>= 1, module_irq++) { | 322 | pih_isr >>= 1, module_irq++) { |
| 323 | if (pih_isr & 0x1) { | 323 | if (pih_isr & 0x1) |
| 324 | struct irq_desc *d = irq_to_desc(module_irq); | 324 | generic_handle_irq(module_irq); |
| 325 | |||
| 326 | if (!d) { | ||
| 327 | pr_err("twl4030: Invalid SIH IRQ: %d\n", | ||
| 328 | module_irq); | ||
| 329 | return -EINVAL; | ||
| 330 | } | ||
| 331 | |||
| 332 | /* These can't be masked ... always warn | ||
| 333 | * if we get any surprises. | ||
| 334 | */ | ||
| 335 | if (d->status & IRQ_DISABLED) | ||
| 336 | note_interrupt(module_irq, d, | ||
| 337 | IRQ_NONE); | ||
| 338 | else | ||
| 339 | d->handle_irq(module_irq, d); | ||
| 340 | } | ||
| 341 | } | 325 | } |
| 342 | local_irq_enable(); | 326 | local_irq_enable(); |
| 343 | 327 | ||
| @@ -470,7 +454,7 @@ static inline void activate_irq(int irq) | |||
| 470 | set_irq_flags(irq, IRQF_VALID); | 454 | set_irq_flags(irq, IRQF_VALID); |
| 471 | #else | 455 | #else |
| 472 | /* same effect on other architectures */ | 456 | /* same effect on other architectures */ |
| 473 | set_irq_noprobe(irq); | 457 | irq_set_noprobe(irq); |
| 474 | #endif | 458 | #endif |
| 475 | } | 459 | } |
| 476 | 460 | ||
| @@ -560,24 +544,18 @@ static void twl4030_sih_do_edge(struct work_struct *work) | |||
| 560 | /* Modify only the bits we know must change */ | 544 | /* Modify only the bits we know must change */ |
| 561 | while (edge_change) { | 545 | while (edge_change) { |
| 562 | int i = fls(edge_change) - 1; | 546 | int i = fls(edge_change) - 1; |
| 563 | struct irq_desc *d = irq_to_desc(i + agent->irq_base); | 547 | struct irq_data *idata = irq_get_irq_data(i + agent->irq_base); |
| 564 | int byte = 1 + (i >> 2); | 548 | int byte = 1 + (i >> 2); |
| 565 | int off = (i & 0x3) * 2; | 549 | int off = (i & 0x3) * 2; |
| 566 | 550 | unsigned int type; | |
| 567 | if (!d) { | ||
| 568 | pr_err("twl4030: Invalid IRQ: %d\n", | ||
| 569 | i + agent->irq_base); | ||
| 570 | return; | ||
| 571 | } | ||
| 572 | 551 | ||
| 573 | bytes[byte] &= ~(0x03 << off); | 552 | bytes[byte] &= ~(0x03 << off); |
| 574 | 553 | ||
| 575 | raw_spin_lock_irq(&d->lock); | 554 | type = irqd_get_trigger_type(idata); |
| 576 | if (d->status & IRQ_TYPE_EDGE_RISING) | 555 | if (type & IRQ_TYPE_EDGE_RISING) |
| 577 | bytes[byte] |= BIT(off + 1); | 556 | bytes[byte] |= BIT(off + 1); |
| 578 | if (d->status & IRQ_TYPE_EDGE_FALLING) | 557 | if (type & IRQ_TYPE_EDGE_FALLING) |
| 579 | bytes[byte] |= BIT(off + 0); | 558 | bytes[byte] |= BIT(off + 0); |
| 580 | raw_spin_unlock_irq(&d->lock); | ||
| 581 | 559 | ||
| 582 | edge_change &= ~BIT(i); | 560 | edge_change &= ~BIT(i); |
| 583 | } | 561 | } |
| @@ -626,21 +604,13 @@ static void twl4030_sih_unmask(struct irq_data *data) | |||
| 626 | static int twl4030_sih_set_type(struct irq_data *data, unsigned trigger) | 604 | static int twl4030_sih_set_type(struct irq_data *data, unsigned trigger) |
| 627 | { | 605 | { |
| 628 | struct sih_agent *sih = irq_data_get_irq_chip_data(data); | 606 | struct sih_agent *sih = irq_data_get_irq_chip_data(data); |
| 629 | struct irq_desc *desc = irq_to_desc(data->irq); | ||
| 630 | unsigned long flags; | 607 | unsigned long flags; |
| 631 | 608 | ||
| 632 | if (!desc) { | ||
| 633 | pr_err("twl4030: Invalid IRQ: %d\n", data->irq); | ||
| 634 | return -EINVAL; | ||
| 635 | } | ||
| 636 | |||
| 637 | if (trigger & ~(IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING)) | 609 | if (trigger & ~(IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING)) |
| 638 | return -EINVAL; | 610 | return -EINVAL; |
| 639 | 611 | ||
| 640 | spin_lock_irqsave(&sih_agent_lock, flags); | 612 | spin_lock_irqsave(&sih_agent_lock, flags); |
| 641 | if ((desc->status & IRQ_TYPE_SENSE_MASK) != trigger) { | 613 | if (irqd_get_trigger_type(data) != trigger) { |
| 642 | desc->status &= ~IRQ_TYPE_SENSE_MASK; | ||
| 643 | desc->status |= trigger; | ||
| 644 | sih->edge_change |= BIT(data->irq - sih->irq_base); | 614 | sih->edge_change |= BIT(data->irq - sih->irq_base); |
| 645 | queue_work(wq, &sih->edge_work); | 615 | queue_work(wq, &sih->edge_work); |
| 646 | } | 616 | } |
| @@ -680,7 +650,7 @@ static inline int sih_read_isr(const struct sih *sih) | |||
| 680 | */ | 650 | */ |
| 681 | static void handle_twl4030_sih(unsigned irq, struct irq_desc *desc) | 651 | static void handle_twl4030_sih(unsigned irq, struct irq_desc *desc) |
| 682 | { | 652 | { |
| 683 | struct sih_agent *agent = get_irq_data(irq); | 653 | struct sih_agent *agent = irq_get_handler_data(irq); |
| 684 | const struct sih *sih = agent->sih; | 654 | const struct sih *sih = agent->sih; |
| 685 | int isr; | 655 | int isr; |
| 686 | 656 | ||
| @@ -754,9 +724,9 @@ int twl4030_sih_setup(int module) | |||
| 754 | for (i = 0; i < sih->bits; i++) { | 724 | for (i = 0; i < sih->bits; i++) { |
| 755 | irq = irq_base + i; | 725 | irq = irq_base + i; |
| 756 | 726 | ||
| 757 | set_irq_chip_and_handler(irq, &twl4030_sih_irq_chip, | 727 | irq_set_chip_and_handler(irq, &twl4030_sih_irq_chip, |
| 758 | handle_edge_irq); | 728 | handle_edge_irq); |
| 759 | set_irq_chip_data(irq, agent); | 729 | irq_set_chip_data(irq, agent); |
| 760 | activate_irq(irq); | 730 | activate_irq(irq); |
| 761 | } | 731 | } |
| 762 | 732 | ||
| @@ -765,8 +735,8 @@ int twl4030_sih_setup(int module) | |||
| 765 | 735 | ||
| 766 | /* replace generic PIH handler (handle_simple_irq) */ | 736 | /* replace generic PIH handler (handle_simple_irq) */ |
| 767 | irq = sih_mod + twl4030_irq_base; | 737 | irq = sih_mod + twl4030_irq_base; |
| 768 | set_irq_data(irq, agent); | 738 | irq_set_handler_data(irq, agent); |
| 769 | set_irq_chained_handler(irq, handle_twl4030_sih); | 739 | irq_set_chained_handler(irq, handle_twl4030_sih); |
| 770 | 740 | ||
| 771 | pr_info("twl4030: %s (irq %d) chaining IRQs %d..%d\n", sih->name, | 741 | pr_info("twl4030: %s (irq %d) chaining IRQs %d..%d\n", sih->name, |
| 772 | irq, irq_base, twl4030_irq_next - 1); | 742 | irq, irq_base, twl4030_irq_next - 1); |
| @@ -815,8 +785,8 @@ int twl4030_init_irq(int irq_num, unsigned irq_base, unsigned irq_end) | |||
| 815 | twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack; | 785 | twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack; |
| 816 | 786 | ||
| 817 | for (i = irq_base; i < irq_end; i++) { | 787 | for (i = irq_base; i < irq_end; i++) { |
| 818 | set_irq_chip_and_handler(i, &twl4030_irq_chip, | 788 | irq_set_chip_and_handler(i, &twl4030_irq_chip, |
| 819 | handle_simple_irq); | 789 | handle_simple_irq); |
| 820 | activate_irq(i); | 790 | activate_irq(i); |
| 821 | } | 791 | } |
| 822 | twl4030_irq_next = i; | 792 | twl4030_irq_next = i; |
| @@ -856,7 +826,7 @@ fail_rqirq: | |||
| 856 | /* clean up twl4030_sih_setup */ | 826 | /* clean up twl4030_sih_setup */ |
| 857 | fail: | 827 | fail: |
| 858 | for (i = irq_base; i < irq_end; i++) | 828 | for (i = irq_base; i < irq_end; i++) |
| 859 | set_irq_chip_and_handler(i, NULL, NULL); | 829 | irq_set_chip_and_handler(i, NULL, NULL); |
| 860 | destroy_workqueue(wq); | 830 | destroy_workqueue(wq); |
| 861 | wq = NULL; | 831 | wq = NULL; |
| 862 | return status; | 832 | return status; |
diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c index 4082ed73613..fa937052fba 100644 --- a/drivers/mfd/twl6030-irq.c +++ b/drivers/mfd/twl6030-irq.c | |||
| @@ -140,22 +140,7 @@ static int twl6030_irq_thread(void *data) | |||
| 140 | if (sts.int_sts & 0x1) { | 140 | if (sts.int_sts & 0x1) { |
| 141 | int module_irq = twl6030_irq_base + | 141 | int module_irq = twl6030_irq_base + |
| 142 | twl6030_interrupt_mapping[i]; | 142 | twl6030_interrupt_mapping[i]; |
| 143 | struct irq_desc *d = irq_to_desc(module_irq); | 143 | generic_handle_irq(module_irq); |
| 144 | |||
| 145 | if (!d) { | ||
| 146 | pr_err("twl6030: Invalid SIH IRQ: %d\n", | ||
| 147 | module_irq); | ||
| 148 | return -EINVAL; | ||
| 149 | } | ||
| 150 | |||
| 151 | /* These can't be masked ... always warn | ||
| 152 | * if we get any surprises. | ||
| 153 | */ | ||
| 154 | if (d->status & IRQ_DISABLED) | ||
| 155 | note_interrupt(module_irq, d, | ||
| 156 | IRQ_NONE); | ||
| 157 | else | ||
| 158 | d->handle_irq(module_irq, d); | ||
| 159 | 144 | ||
| 160 | } | 145 | } |
| 161 | local_irq_enable(); | 146 | local_irq_enable(); |
| @@ -198,7 +183,7 @@ static inline void activate_irq(int irq) | |||
| 198 | set_irq_flags(irq, IRQF_VALID); | 183 | set_irq_flags(irq, IRQF_VALID); |
| 199 | #else | 184 | #else |
| 200 | /* same effect on other architectures */ | 185 | /* same effect on other architectures */ |
| 201 | set_irq_noprobe(irq); | 186 | irq_set_noprobe(irq); |
| 202 | #endif | 187 | #endif |
| 203 | } | 188 | } |
| 204 | 189 | ||
| @@ -335,8 +320,8 @@ int twl6030_init_irq(int irq_num, unsigned irq_base, unsigned irq_end) | |||
| 335 | twl6030_irq_chip.irq_set_type = NULL; | 320 | twl6030_irq_chip.irq_set_type = NULL; |
| 336 | 321 | ||
| 337 | for (i = irq_base; i < irq_end; i++) { | 322 | for (i = irq_base; i < irq_end; i++) { |
| 338 | set_irq_chip_and_handler(i, &twl6030_irq_chip, | 323 | irq_set_chip_and_handler(i, &twl6030_irq_chip, |
| 339 | handle_simple_irq); | 324 | handle_simple_irq); |
| 340 | activate_irq(i); | 325 | activate_irq(i); |
| 341 | } | 326 | } |
| 342 | 327 | ||
| @@ -365,7 +350,7 @@ fail_irq: | |||
| 365 | 350 | ||
| 366 | fail_kthread: | 351 | fail_kthread: |
| 367 | for (i = irq_base; i < irq_end; i++) | 352 | for (i = irq_base; i < irq_end; i++) |
| 368 | set_irq_chip_and_handler(i, NULL, NULL); | 353 | irq_set_chip_and_handler(i, NULL, NULL); |
| 369 | return status; | 354 | return status; |
| 370 | } | 355 | } |
| 371 | 356 | ||
diff --git a/drivers/mfd/wl1273-core.c b/drivers/mfd/wl1273-core.c index f76f6c79804..04914f2836c 100644 --- a/drivers/mfd/wl1273-core.c +++ b/drivers/mfd/wl1273-core.c | |||
| @@ -25,7 +25,7 @@ | |||
| 25 | 25 | ||
| 26 | #define DRIVER_DESC "WL1273 FM Radio Core" | 26 | #define DRIVER_DESC "WL1273 FM Radio Core" |
| 27 | 27 | ||
| 28 | static struct i2c_device_id wl1273_driver_id_table[] = { | 28 | static const struct i2c_device_id wl1273_driver_id_table[] = { |
| 29 | { WL1273_FM_DRIVER_NAME, 0 }, | 29 | { WL1273_FM_DRIVER_NAME, 0 }, |
| 30 | { } | 30 | { } |
| 31 | }; | 31 | }; |
diff --git a/drivers/mfd/wm831x-irq.c b/drivers/mfd/wm831x-irq.c index a5cd17e18d0..23e66af89de 100644 --- a/drivers/mfd/wm831x-irq.c +++ b/drivers/mfd/wm831x-irq.c | |||
| @@ -553,17 +553,17 @@ int wm831x_irq_init(struct wm831x *wm831x, int irq) | |||
| 553 | for (cur_irq = wm831x->irq_base; | 553 | for (cur_irq = wm831x->irq_base; |
| 554 | cur_irq < ARRAY_SIZE(wm831x_irqs) + wm831x->irq_base; | 554 | cur_irq < ARRAY_SIZE(wm831x_irqs) + wm831x->irq_base; |
| 555 | cur_irq++) { | 555 | cur_irq++) { |
| 556 | set_irq_chip_data(cur_irq, wm831x); | 556 | irq_set_chip_data(cur_irq, wm831x); |
| 557 | set_irq_chip_and_handler(cur_irq, &wm831x_irq_chip, | 557 | irq_set_chip_and_handler(cur_irq, &wm831x_irq_chip, |
| 558 | handle_edge_irq); | 558 | handle_edge_irq); |
| 559 | set_irq_nested_thread(cur_irq, 1); | 559 | irq_set_nested_thread(cur_irq, 1); |
| 560 | 560 | ||
| 561 | /* ARM needs us to explicitly flag the IRQ as valid | 561 | /* ARM needs us to explicitly flag the IRQ as valid |
| 562 | * and will set them noprobe when we do so. */ | 562 | * and will set them noprobe when we do so. */ |
| 563 | #ifdef CONFIG_ARM | 563 | #ifdef CONFIG_ARM |
| 564 | set_irq_flags(cur_irq, IRQF_VALID); | 564 | set_irq_flags(cur_irq, IRQF_VALID); |
| 565 | #else | 565 | #else |
| 566 | set_irq_noprobe(cur_irq); | 566 | irq_set_noprobe(cur_irq); |
| 567 | #endif | 567 | #endif |
| 568 | } | 568 | } |
| 569 | 569 | ||
diff --git a/drivers/mfd/wm8350-irq.c b/drivers/mfd/wm8350-irq.c index 5839966ebd8..ed4b22a167b 100644 --- a/drivers/mfd/wm8350-irq.c +++ b/drivers/mfd/wm8350-irq.c | |||
| @@ -518,17 +518,17 @@ int wm8350_irq_init(struct wm8350 *wm8350, int irq, | |||
| 518 | for (cur_irq = wm8350->irq_base; | 518 | for (cur_irq = wm8350->irq_base; |
| 519 | cur_irq < ARRAY_SIZE(wm8350_irqs) + wm8350->irq_base; | 519 | cur_irq < ARRAY_SIZE(wm8350_irqs) + wm8350->irq_base; |
| 520 | cur_irq++) { | 520 | cur_irq++) { |
| 521 | set_irq_chip_data(cur_irq, wm8350); | 521 | irq_set_chip_data(cur_irq, wm8350); |
| 522 | set_irq_chip_and_handler(cur_irq, &wm8350_irq_chip, | 522 | irq_set_chip_and_handler(cur_irq, &wm8350_irq_chip, |
| 523 | handle_edge_irq); | 523 | handle_edge_irq); |
| 524 | set_irq_nested_thread(cur_irq, 1); | 524 | irq_set_nested_thread(cur_irq, 1); |
| 525 | 525 | ||
| 526 | /* ARM needs us to explicitly flag the IRQ as valid | 526 | /* ARM needs us to explicitly flag the IRQ as valid |
| 527 | * and will set them noprobe when we do so. */ | 527 | * and will set them noprobe when we do so. */ |
| 528 | #ifdef CONFIG_ARM | 528 | #ifdef CONFIG_ARM |
| 529 | set_irq_flags(cur_irq, IRQF_VALID); | 529 | set_irq_flags(cur_irq, IRQF_VALID); |
| 530 | #else | 530 | #else |
| 531 | set_irq_noprobe(cur_irq); | 531 | irq_set_noprobe(cur_irq); |
| 532 | #endif | 532 | #endif |
| 533 | } | 533 | } |
| 534 | 534 | ||
diff --git a/drivers/mfd/wm8994-irq.c b/drivers/mfd/wm8994-irq.c index 1e3bf4a2ff8..71c6e8f9aed 100644 --- a/drivers/mfd/wm8994-irq.c +++ b/drivers/mfd/wm8994-irq.c | |||
| @@ -278,17 +278,17 @@ int wm8994_irq_init(struct wm8994 *wm8994) | |||
| 278 | for (cur_irq = wm8994->irq_base; | 278 | for (cur_irq = wm8994->irq_base; |
| 279 | cur_irq < ARRAY_SIZE(wm8994_irqs) + wm8994->irq_base; | 279 | cur_irq < ARRAY_SIZE(wm8994_irqs) + wm8994->irq_base; |
| 280 | cur_irq++) { | 280 | cur_irq++) { |
| 281 | set_irq_chip_data(cur_irq, wm8994); | 281 | irq_set_chip_data(cur_irq, wm8994); |
| 282 | set_irq_chip_and_handler(cur_irq, &wm8994_irq_chip, | 282 | irq_set_chip_and_handler(cur_irq, &wm8994_irq_chip, |
| 283 | handle_edge_irq); | 283 | handle_edge_irq); |
| 284 | set_irq_nested_thread(cur_irq, 1); | 284 | irq_set_nested_thread(cur_irq, 1); |
| 285 | 285 | ||
| 286 | /* ARM needs us to explicitly flag the IRQ as valid | 286 | /* ARM needs us to explicitly flag the IRQ as valid |
| 287 | * and will set them noprobe when we do so. */ | 287 | * and will set them noprobe when we do so. */ |
| 288 | #ifdef CONFIG_ARM | 288 | #ifdef CONFIG_ARM |
| 289 | set_irq_flags(cur_irq, IRQF_VALID); | 289 | set_irq_flags(cur_irq, IRQF_VALID); |
| 290 | #else | 290 | #else |
| 291 | set_irq_noprobe(cur_irq); | 291 | irq_set_noprobe(cur_irq); |
| 292 | #endif | 292 | #endif |
| 293 | } | 293 | } |
| 294 | 294 | ||
diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig index 77414702cb0..b4567c35a32 100644 --- a/drivers/mtd/Kconfig +++ b/drivers/mtd/Kconfig | |||
| @@ -33,14 +33,6 @@ config MTD_TESTS | |||
| 33 | should normally be compiled as kernel modules. The modules perform | 33 | should normally be compiled as kernel modules. The modules perform |
| 34 | various checks and verifications when loaded. | 34 | various checks and verifications when loaded. |
| 35 | 35 | ||
| 36 | config MTD_CONCAT | ||
| 37 | tristate "MTD concatenating support" | ||
| 38 | help | ||
| 39 | Support for concatenating several MTD devices into a single | ||
| 40 | (virtual) one. This allows you to have -for example- a JFFS(2) | ||
| 41 | file system spanning multiple physical flash chips. If unsure, | ||
| 42 | say 'Y'. | ||
| 43 | |||
| 44 | config MTD_PARTITIONS | 36 | config MTD_PARTITIONS |
| 45 | bool "MTD partitioning support" | 37 | bool "MTD partitioning support" |
| 46 | help | 38 | help |
| @@ -333,6 +325,16 @@ config MTD_OOPS | |||
| 333 | To use, add console=ttyMTDx to the kernel command line, | 325 | To use, add console=ttyMTDx to the kernel command line, |
| 334 | where x is the MTD device number to use. | 326 | where x is the MTD device number to use. |
| 335 | 327 | ||
| 328 | config MTD_SWAP | ||
| 329 | tristate "Swap on MTD device support" | ||
| 330 | depends on MTD && SWAP | ||
| 331 | select MTD_BLKDEVS | ||
| 332 | help | ||
| 333 | Provides volatile block device driver on top of mtd partition | ||
| 334 | suitable for swapping. The mapping of written blocks is not saved. | ||
| 335 | The driver provides wear leveling by storing erase counter into the | ||
| 336 | OOB. | ||
| 337 | |||
| 336 | source "drivers/mtd/chips/Kconfig" | 338 | source "drivers/mtd/chips/Kconfig" |
| 337 | 339 | ||
| 338 | source "drivers/mtd/maps/Kconfig" | 340 | source "drivers/mtd/maps/Kconfig" |
diff --git a/drivers/mtd/Makefile b/drivers/mtd/Makefile index d4e7f25b1eb..d578095fb25 100644 --- a/drivers/mtd/Makefile +++ b/drivers/mtd/Makefile | |||
| @@ -4,11 +4,10 @@ | |||
| 4 | 4 | ||
| 5 | # Core functionality. | 5 | # Core functionality. |
| 6 | obj-$(CONFIG_MTD) += mtd.o | 6 | obj-$(CONFIG_MTD) += mtd.o |
| 7 | mtd-y := mtdcore.o mtdsuper.o | 7 | mtd-y := mtdcore.o mtdsuper.o mtdconcat.o |
| 8 | mtd-$(CONFIG_MTD_PARTITIONS) += mtdpart.o | 8 | mtd-$(CONFIG_MTD_PARTITIONS) += mtdpart.o |
| 9 | mtd-$(CONFIG_MTD_OF_PARTS) += ofpart.o | 9 | mtd-$(CONFIG_MTD_OF_PARTS) += ofpart.o |
| 10 | 10 | ||
| 11 | obj-$(CONFIG_MTD_CONCAT) += mtdconcat.o | ||
| 12 | obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o | 11 | obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o |
| 13 | obj-$(CONFIG_MTD_CMDLINE_PARTS) += cmdlinepart.o | 12 | obj-$(CONFIG_MTD_CMDLINE_PARTS) += cmdlinepart.o |
| 14 | obj-$(CONFIG_MTD_AFS_PARTS) += afs.o | 13 | obj-$(CONFIG_MTD_AFS_PARTS) += afs.o |
| @@ -26,6 +25,7 @@ obj-$(CONFIG_RFD_FTL) += rfd_ftl.o | |||
| 26 | obj-$(CONFIG_SSFDC) += ssfdc.o | 25 | obj-$(CONFIG_SSFDC) += ssfdc.o |
| 27 | obj-$(CONFIG_SM_FTL) += sm_ftl.o | 26 | obj-$(CONFIG_SM_FTL) += sm_ftl.o |
| 28 | obj-$(CONFIG_MTD_OOPS) += mtdoops.o | 27 | obj-$(CONFIG_MTD_OOPS) += mtdoops.o |
| 28 | obj-$(CONFIG_MTD_SWAP) += mtdswap.o | ||
| 29 | 29 | ||
| 30 | nftl-objs := nftlcore.o nftlmount.o | 30 | nftl-objs := nftlcore.o nftlmount.o |
| 31 | inftl-objs := inftlcore.o inftlmount.o | 31 | inftl-objs := inftlcore.o inftlmount.o |
diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c index 4aaa88f8ab5..092aef11120 100644 --- a/drivers/mtd/chips/cfi_cmdset_0001.c +++ b/drivers/mtd/chips/cfi_cmdset_0001.c | |||
| @@ -455,7 +455,7 @@ struct mtd_info *cfi_cmdset_0001(struct map_info *map, int primary) | |||
| 455 | mtd->flags = MTD_CAP_NORFLASH; | 455 | mtd->flags = MTD_CAP_NORFLASH; |
| 456 | mtd->name = map->name; | 456 | mtd->name = map->name; |
| 457 | mtd->writesize = 1; | 457 | mtd->writesize = 1; |
| 458 | mtd->writebufsize = 1 << cfi->cfiq->MaxBufWriteSize; | 458 | mtd->writebufsize = cfi_interleave(cfi) << cfi->cfiq->MaxBufWriteSize; |
| 459 | 459 | ||
| 460 | mtd->reboot_notifier.notifier_call = cfi_intelext_reboot; | 460 | mtd->reboot_notifier.notifier_call = cfi_intelext_reboot; |
| 461 | 461 | ||
diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c index f072fcfde04..f9a5331e944 100644 --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c | |||
| @@ -349,6 +349,7 @@ static struct cfi_fixup cfi_fixup_table[] = { | |||
| 349 | { CFI_MFR_ATMEL, CFI_ID_ANY, fixup_convert_atmel_pri }, | 349 | { CFI_MFR_ATMEL, CFI_ID_ANY, fixup_convert_atmel_pri }, |
| 350 | #ifdef AMD_BOOTLOC_BUG | 350 | #ifdef AMD_BOOTLOC_BUG |
| 351 | { CFI_MFR_AMD, CFI_ID_ANY, fixup_amd_bootblock }, | 351 | { CFI_MFR_AMD, CFI_ID_ANY, fixup_amd_bootblock }, |
| 352 | { CFI_MFR_AMIC, CFI_ID_ANY, fixup_amd_bootblock }, | ||
| 352 | { CFI_MFR_MACRONIX, CFI_ID_ANY, fixup_amd_bootblock }, | 353 | { CFI_MFR_MACRONIX, CFI_ID_ANY, fixup_amd_bootblock }, |
| 353 | #endif | 354 | #endif |
| 354 | { CFI_MFR_AMD, 0x0050, fixup_use_secsi }, | 355 | { CFI_MFR_AMD, 0x0050, fixup_use_secsi }, |
| @@ -440,7 +441,7 @@ struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary) | |||
| 440 | mtd->flags = MTD_CAP_NORFLASH; | 441 | mtd->flags = MTD_CAP_NORFLASH; |
| 441 | mtd->name = map->name; | 442 | mtd->name = map->name; |
| 442 | mtd->writesize = 1; | 443 | mtd->writesize = 1; |
| 443 | mtd->writebufsize = 1 << cfi->cfiq->MaxBufWriteSize; | 444 | mtd->writebufsize = cfi_interleave(cfi) << cfi->cfiq->MaxBufWriteSize; |
| 444 | 445 | ||
| 445 | DEBUG(MTD_DEBUG_LEVEL3, "MTD %s(): write buffer size %d\n", | 446 | DEBUG(MTD_DEBUG_LEVEL3, "MTD %s(): write buffer size %d\n", |
| 446 | __func__, mtd->writebufsize); | 447 | __func__, mtd->writebufsize); |
diff --git a/drivers/mtd/chips/cfi_cmdset_0020.c b/drivers/mtd/chips/cfi_cmdset_0020.c index c04b7658abe..ed56ad3884f 100644 --- a/drivers/mtd/chips/cfi_cmdset_0020.c +++ b/drivers/mtd/chips/cfi_cmdset_0020.c | |||
| @@ -238,7 +238,7 @@ static struct mtd_info *cfi_staa_setup(struct map_info *map) | |||
| 238 | mtd->resume = cfi_staa_resume; | 238 | mtd->resume = cfi_staa_resume; |
| 239 | mtd->flags = MTD_CAP_NORFLASH & ~MTD_BIT_WRITEABLE; | 239 | mtd->flags = MTD_CAP_NORFLASH & ~MTD_BIT_WRITEABLE; |
| 240 | mtd->writesize = 8; /* FIXME: Should be 0 for STMicro flashes w/out ECC */ | 240 | mtd->writesize = 8; /* FIXME: Should be 0 for STMicro flashes w/out ECC */ |
| 241 | mtd->writebufsize = 1 << cfi->cfiq->MaxBufWriteSize; | 241 | mtd->writebufsize = cfi_interleave(cfi) << cfi->cfiq->MaxBufWriteSize; |
| 242 | map->fldrv = &cfi_staa_chipdrv; | 242 | map->fldrv = &cfi_staa_chipdrv; |
| 243 | __module_get(THIS_MODULE); | 243 | __module_get(THIS_MODULE); |
| 244 | mtd->name = map->name; | 244 | mtd->name = map->name; |
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c index e4eba6cc1b2..3fb981d4bb5 100644 --- a/drivers/mtd/devices/m25p80.c +++ b/drivers/mtd/devices/m25p80.c | |||
| @@ -655,7 +655,8 @@ static const struct spi_device_id m25p_ids[] = { | |||
| 655 | { "at26df161a", INFO(0x1f4601, 0, 64 * 1024, 32, SECT_4K) }, | 655 | { "at26df161a", INFO(0x1f4601, 0, 64 * 1024, 32, SECT_4K) }, |
| 656 | { "at26df321", INFO(0x1f4700, 0, 64 * 1024, 64, SECT_4K) }, | 656 | { "at26df321", INFO(0x1f4700, 0, 64 * 1024, 64, SECT_4K) }, |
| 657 | 657 | ||
| 658 | /* EON -- en25pxx */ | 658 | /* EON -- en25xxx */ |
| 659 | { "en25f32", INFO(0x1c3116, 0, 64 * 1024, 64, SECT_4K) }, | ||
| 659 | { "en25p32", INFO(0x1c2016, 0, 64 * 1024, 64, 0) }, | 660 | { "en25p32", INFO(0x1c2016, 0, 64 * 1024, 64, 0) }, |
| 660 | { "en25p64", INFO(0x1c2017, 0, 64 * 1024, 128, 0) }, | 661 | { "en25p64", INFO(0x1c2017, 0, 64 * 1024, 128, 0) }, |
| 661 | 662 | ||
| @@ -728,6 +729,8 @@ static const struct spi_device_id m25p_ids[] = { | |||
| 728 | { "m25pe80", INFO(0x208014, 0, 64 * 1024, 16, 0) }, | 729 | { "m25pe80", INFO(0x208014, 0, 64 * 1024, 16, 0) }, |
| 729 | { "m25pe16", INFO(0x208015, 0, 64 * 1024, 32, SECT_4K) }, | 730 | { "m25pe16", INFO(0x208015, 0, 64 * 1024, 32, SECT_4K) }, |
| 730 | 731 | ||
| 732 | { "m25px64", INFO(0x207117, 0, 64 * 1024, 128, 0) }, | ||
| 733 | |||
| 731 | /* Winbond -- w25x "blocks" are 64K, "sectors" are 4KiB */ | 734 | /* Winbond -- w25x "blocks" are 64K, "sectors" are 4KiB */ |
| 732 | { "w25x10", INFO(0xef3011, 0, 64 * 1024, 2, SECT_4K) }, | 735 | { "w25x10", INFO(0xef3011, 0, 64 * 1024, 2, SECT_4K) }, |
| 733 | { "w25x20", INFO(0xef3012, 0, 64 * 1024, 4, SECT_4K) }, | 736 | { "w25x20", INFO(0xef3012, 0, 64 * 1024, 4, SECT_4K) }, |
diff --git a/drivers/mtd/devices/mtdram.c b/drivers/mtd/devices/mtdram.c index 26a6e809013..1483e18971c 100644 --- a/drivers/mtd/devices/mtdram.c +++ b/drivers/mtd/devices/mtdram.c | |||
| @@ -121,6 +121,7 @@ int mtdram_init_device(struct mtd_info *mtd, void *mapped_address, | |||
| 121 | mtd->flags = MTD_CAP_RAM; | 121 | mtd->flags = MTD_CAP_RAM; |
| 122 | mtd->size = size; | 122 | mtd->size = size; |
| 123 | mtd->writesize = 1; | 123 | mtd->writesize = 1; |
| 124 | mtd->writebufsize = 64; /* Mimic CFI NOR flashes */ | ||
| 124 | mtd->erasesize = MTDRAM_ERASE_SIZE; | 125 | mtd->erasesize = MTDRAM_ERASE_SIZE; |
| 125 | mtd->priv = mapped_address; | 126 | mtd->priv = mapped_address; |
| 126 | 127 | ||
diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c index 52393282eaf..8d28fa02a5a 100644 --- a/drivers/mtd/devices/phram.c +++ b/drivers/mtd/devices/phram.c | |||
| @@ -117,6 +117,7 @@ static void unregister_devices(void) | |||
| 117 | list_for_each_entry_safe(this, safe, &phram_list, list) { | 117 | list_for_each_entry_safe(this, safe, &phram_list, list) { |
| 118 | del_mtd_device(&this->mtd); | 118 | del_mtd_device(&this->mtd); |
| 119 | iounmap(this->mtd.priv); | 119 | iounmap(this->mtd.priv); |
| 120 | kfree(this->mtd.name); | ||
| 120 | kfree(this); | 121 | kfree(this); |
| 121 | } | 122 | } |
| 122 | } | 123 | } |
| @@ -275,6 +276,8 @@ static int phram_setup(const char *val, struct kernel_param *kp) | |||
| 275 | ret = register_device(name, start, len); | 276 | ret = register_device(name, start, len); |
| 276 | if (!ret) | 277 | if (!ret) |
| 277 | pr_info("%s device: %#x at %#x\n", name, len, start); | 278 | pr_info("%s device: %#x at %#x\n", name, len, start); |
| 279 | else | ||
| 280 | kfree(name); | ||
| 278 | 281 | ||
| 279 | return ret; | 282 | return ret; |
| 280 | } | 283 | } |
diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig index 5d37d315fa9..44b1f46458c 100644 --- a/drivers/mtd/maps/Kconfig +++ b/drivers/mtd/maps/Kconfig | |||
| @@ -114,7 +114,7 @@ config MTD_SUN_UFLASH | |||
| 114 | 114 | ||
| 115 | config MTD_SC520CDP | 115 | config MTD_SC520CDP |
| 116 | tristate "CFI Flash device mapped on AMD SC520 CDP" | 116 | tristate "CFI Flash device mapped on AMD SC520 CDP" |
| 117 | depends on X86 && MTD_CFI && MTD_CONCAT | 117 | depends on X86 && MTD_CFI |
| 118 | help | 118 | help |
| 119 | The SC520 CDP board has two banks of CFI-compliant chips and one | 119 | The SC520 CDP board has two banks of CFI-compliant chips and one |
| 120 | Dual-in-line JEDEC chip. This 'mapping' driver supports that | 120 | Dual-in-line JEDEC chip. This 'mapping' driver supports that |
| @@ -262,7 +262,7 @@ config MTD_BCM963XX | |||
| 262 | 262 | ||
| 263 | config MTD_DILNETPC | 263 | config MTD_DILNETPC |
| 264 | tristate "CFI Flash device mapped on DIL/Net PC" | 264 | tristate "CFI Flash device mapped on DIL/Net PC" |
| 265 | depends on X86 && MTD_CONCAT && MTD_PARTITIONS && MTD_CFI_INTELEXT && BROKEN | 265 | depends on X86 && MTD_PARTITIONS && MTD_CFI_INTELEXT && BROKEN |
| 266 | help | 266 | help |
| 267 | MTD map driver for SSV DIL/Net PC Boards "DNP" and "ADNP". | 267 | MTD map driver for SSV DIL/Net PC Boards "DNP" and "ADNP". |
| 268 | For details, see <http://www.ssv-embedded.de/ssv/pc104/p169.htm> | 268 | For details, see <http://www.ssv-embedded.de/ssv/pc104/p169.htm> |
| @@ -552,4 +552,13 @@ config MTD_PISMO | |||
| 552 | 552 | ||
| 553 | When built as a module, it will be called pismo.ko | 553 | When built as a module, it will be called pismo.ko |
| 554 | 554 | ||
| 555 | config MTD_LATCH_ADDR | ||
| 556 | tristate "Latch-assisted Flash Chip Support" | ||
| 557 | depends on MTD_COMPLEX_MAPPINGS | ||
| 558 | help | ||
| 559 | Map driver which allows flashes to be partially physically addressed | ||
| 560 | and have the upper address lines set by a board specific code. | ||
| 561 | |||
| 562 | If compiled as a module, it will be called latch-addr-flash. | ||
| 563 | |||
| 555 | endmenu | 564 | endmenu |
diff --git a/drivers/mtd/maps/Makefile b/drivers/mtd/maps/Makefile index c7869c7a6b1..08533bd5cba 100644 --- a/drivers/mtd/maps/Makefile +++ b/drivers/mtd/maps/Makefile | |||
| @@ -59,3 +59,4 @@ obj-$(CONFIG_MTD_RBTX4939) += rbtx4939-flash.o | |||
| 59 | obj-$(CONFIG_MTD_VMU) += vmu-flash.o | 59 | obj-$(CONFIG_MTD_VMU) += vmu-flash.o |
| 60 | obj-$(CONFIG_MTD_GPIO_ADDR) += gpio-addr-flash.o | 60 | obj-$(CONFIG_MTD_GPIO_ADDR) += gpio-addr-flash.o |
| 61 | obj-$(CONFIG_MTD_BCM963XX) += bcm963xx-flash.o | 61 | obj-$(CONFIG_MTD_BCM963XX) += bcm963xx-flash.o |
| 62 | obj-$(CONFIG_MTD_LATCH_ADDR) += latch-addr-flash.o | ||
diff --git a/drivers/mtd/maps/ceiva.c b/drivers/mtd/maps/ceiva.c index c09f4f57093..e5f645b775a 100644 --- a/drivers/mtd/maps/ceiva.c +++ b/drivers/mtd/maps/ceiva.c | |||
| @@ -194,16 +194,10 @@ static int __init clps_setup_mtd(struct clps_info *clps, int nr, struct mtd_info | |||
| 194 | * We detected multiple devices. Concatenate | 194 | * We detected multiple devices. Concatenate |
| 195 | * them together. | 195 | * them together. |
| 196 | */ | 196 | */ |
| 197 | #ifdef CONFIG_MTD_CONCAT | ||
| 198 | *rmtd = mtd_concat_create(subdev, found, | 197 | *rmtd = mtd_concat_create(subdev, found, |
| 199 | "clps flash"); | 198 | "clps flash"); |
| 200 | if (*rmtd == NULL) | 199 | if (*rmtd == NULL) |
| 201 | ret = -ENXIO; | 200 | ret = -ENXIO; |
| 202 | #else | ||
| 203 | printk(KERN_ERR "clps flash: multiple devices " | ||
| 204 | "found but MTD concat support disabled.\n"); | ||
| 205 | ret = -ENXIO; | ||
| 206 | #endif | ||
| 207 | } | 201 | } |
| 208 | } | 202 | } |
| 209 | 203 | ||
diff --git a/drivers/mtd/maps/integrator-flash.c b/drivers/mtd/maps/integrator-flash.c index 2aac41bde8b..e22ff5adbbf 100644 --- a/drivers/mtd/maps/integrator-flash.c +++ b/drivers/mtd/maps/integrator-flash.c | |||
| @@ -202,7 +202,6 @@ static int armflash_probe(struct platform_device *dev) | |||
| 202 | if (info->nr_subdev == 1) | 202 | if (info->nr_subdev == 1) |
| 203 | info->mtd = info->subdev[0].mtd; | 203 | info->mtd = info->subdev[0].mtd; |
| 204 | else if (info->nr_subdev > 1) { | 204 | else if (info->nr_subdev > 1) { |
| 205 | #ifdef CONFIG_MTD_CONCAT | ||
| 206 | struct mtd_info *cdev[info->nr_subdev]; | 205 | struct mtd_info *cdev[info->nr_subdev]; |
| 207 | 206 | ||
| 208 | /* | 207 | /* |
| @@ -215,11 +214,6 @@ static int armflash_probe(struct platform_device *dev) | |||
| 215 | dev_name(&dev->dev)); | 214 | dev_name(&dev->dev)); |
| 216 | if (info->mtd == NULL) | 215 | if (info->mtd == NULL) |
| 217 | err = -ENXIO; | 216 | err = -ENXIO; |
| 218 | #else | ||
| 219 | printk(KERN_ERR "armflash: multiple devices found but " | ||
| 220 | "MTD concat support disabled.\n"); | ||
| 221 | err = -ENXIO; | ||
| 222 | #endif | ||
| 223 | } | 217 | } |
| 224 | 218 | ||
| 225 | if (err < 0) | 219 | if (err < 0) |
| @@ -244,10 +238,8 @@ static int armflash_probe(struct platform_device *dev) | |||
| 244 | cleanup: | 238 | cleanup: |
| 245 | if (info->mtd) { | 239 | if (info->mtd) { |
| 246 | del_mtd_partitions(info->mtd); | 240 | del_mtd_partitions(info->mtd); |
| 247 | #ifdef CONFIG_MTD_CONCAT | ||
| 248 | if (info->mtd != info->subdev[0].mtd) | 241 | if (info->mtd != info->subdev[0].mtd) |
| 249 | mtd_concat_destroy(info->mtd); | 242 | mtd_concat_destroy(info->mtd); |
| 250 | #endif | ||
| 251 | } | 243 | } |
| 252 | kfree(info->parts); | 244 | kfree(info->parts); |
| 253 | subdev_err: | 245 | subdev_err: |
| @@ -272,10 +264,8 @@ static int armflash_remove(struct platform_device *dev) | |||
| 272 | if (info) { | 264 | if (info) { |
| 273 | if (info->mtd) { | 265 | if (info->mtd) { |
| 274 | del_mtd_partitions(info->mtd); | 266 | del_mtd_partitions(info->mtd); |
| 275 | #ifdef CONFIG_MTD_CONCAT | ||
| 276 | if (info->mtd != info->subdev[0].mtd) | 267 | if (info->mtd != info->subdev[0].mtd) |
| 277 | mtd_concat_destroy(info->mtd); | 268 | mtd_concat_destroy(info->mtd); |
| 278 | #endif | ||
| 279 | } | 269 | } |
| 280 | kfree(info->parts); | 270 | kfree(info->parts); |
| 281 | 271 | ||
diff --git a/drivers/mtd/maps/latch-addr-flash.c b/drivers/mtd/maps/latch-addr-flash.c new file mode 100644 index 00000000000..ee254808533 --- /dev/null +++ b/drivers/mtd/maps/latch-addr-flash.c | |||
| @@ -0,0 +1,272 @@ | |||
| 1 | /* | ||
| 2 | * Interface for NOR flash driver whose high address lines are latched | ||
| 3 | * | ||
| 4 | * Copyright © 2000 Nicolas Pitre <nico@cam.org> | ||
| 5 | * Copyright © 2005-2008 Analog Devices Inc. | ||
| 6 | * Copyright © 2008 MontaVista Software, Inc. <source@mvista.com> | ||
| 7 | * | ||
| 8 | * This file is licensed under the terms of the GNU General Public License | ||
| 9 | * version 2. This program is licensed "as is" without any warranty of any | ||
| 10 | * kind, whether express or implied. | ||
| 11 | */ | ||
| 12 | |||
| 13 | #include <linux/init.h> | ||
| 14 | #include <linux/kernel.h> | ||
| 15 | #include <linux/module.h> | ||
| 16 | #include <linux/mtd/mtd.h> | ||
| 17 | #include <linux/mtd/map.h> | ||
| 18 | #include <linux/mtd/partitions.h> | ||
| 19 | #include <linux/platform_device.h> | ||
| 20 | #include <linux/mtd/latch-addr-flash.h> | ||
| 21 | #include <linux/slab.h> | ||
| 22 | |||
| 23 | #define DRIVER_NAME "latch-addr-flash" | ||
| 24 | |||
| 25 | struct latch_addr_flash_info { | ||
| 26 | struct mtd_info *mtd; | ||
| 27 | struct map_info map; | ||
| 28 | struct resource *res; | ||
| 29 | |||
| 30 | void (*set_window)(unsigned long offset, void *data); | ||
| 31 | void *data; | ||
| 32 | |||
| 33 | /* cache; could be found out of res */ | ||
| 34 | unsigned long win_mask; | ||
| 35 | |||
| 36 | int nr_parts; | ||
| 37 | struct mtd_partition *parts; | ||
| 38 | |||
| 39 | spinlock_t lock; | ||
| 40 | }; | ||
| 41 | |||
| 42 | static map_word lf_read(struct map_info *map, unsigned long ofs) | ||
| 43 | { | ||
| 44 | struct latch_addr_flash_info *info; | ||
| 45 | map_word datum; | ||
| 46 | |||
| 47 | info = (struct latch_addr_flash_info *)map->map_priv_1; | ||
| 48 | |||
| 49 | spin_lock(&info->lock); | ||
| 50 | |||
| 51 | info->set_window(ofs, info->data); | ||
| 52 | datum = inline_map_read(map, info->win_mask & ofs); | ||
| 53 | |||
| 54 | spin_unlock(&info->lock); | ||
| 55 | |||
| 56 | return datum; | ||
| 57 | } | ||
| 58 | |||
| 59 | static void lf_write(struct map_info *map, map_word datum, unsigned long ofs) | ||
| 60 | { | ||
| 61 | struct latch_addr_flash_info *info; | ||
| 62 | |||
| 63 | info = (struct latch_addr_flash_info *)map->map_priv_1; | ||
| 64 | |||
| 65 | spin_lock(&info->lock); | ||
| 66 | |||
| 67 | info->set_window(ofs, info->data); | ||
| 68 | inline_map_write(map, datum, info->win_mask & ofs); | ||
| 69 | |||
| 70 | spin_unlock(&info->lock); | ||
| 71 | } | ||
| 72 | |||
| 73 | static void lf_copy_from(struct map_info *map, void *to, | ||
| 74 | unsigned long from, ssize_t len) | ||
| 75 | { | ||
| 76 | struct latch_addr_flash_info *info = | ||
| 77 | (struct latch_addr_flash_info *) map->map_priv_1; | ||
| 78 | unsigned n; | ||
| 79 | |||
| 80 | while (len > 0) { | ||
| 81 | n = info->win_mask + 1 - (from & info->win_mask); | ||
| 82 | if (n > len) | ||
| 83 | n = len; | ||
| 84 | |||
| 85 | spin_lock(&info->lock); | ||
| 86 | |||
| 87 | info->set_window(from, info->data); | ||
| 88 | memcpy_fromio(to, map->virt + (from & info->win_mask), n); | ||
| 89 | |||
| 90 | spin_unlock(&info->lock); | ||
| 91 | |||
| 92 | to += n; | ||
| 93 | from += n; | ||
| 94 | len -= n; | ||
| 95 | } | ||
| 96 | } | ||
| 97 | |||
| 98 | static char *rom_probe_types[] = { "cfi_probe", NULL }; | ||
| 99 | |||
| 100 | static char *part_probe_types[] = { "cmdlinepart", NULL }; | ||
| 101 | |||
| 102 | static int latch_addr_flash_remove(struct platform_device *dev) | ||
| 103 | { | ||
| 104 | struct latch_addr_flash_info *info; | ||
| 105 | struct latch_addr_flash_data *latch_addr_data; | ||
| 106 | |||
| 107 | info = platform_get_drvdata(dev); | ||
| 108 | if (info == NULL) | ||
| 109 | return 0; | ||
| 110 | platform_set_drvdata(dev, NULL); | ||
| 111 | |||
| 112 | latch_addr_data = dev->dev.platform_data; | ||
| 113 | |||
| 114 | if (info->mtd != NULL) { | ||
| 115 | if (mtd_has_partitions()) { | ||
| 116 | if (info->nr_parts) { | ||
| 117 | del_mtd_partitions(info->mtd); | ||
| 118 | kfree(info->parts); | ||
| 119 | } else if (latch_addr_data->nr_parts) { | ||
| 120 | del_mtd_partitions(info->mtd); | ||
| 121 | } else { | ||
| 122 | del_mtd_device(info->mtd); | ||
| 123 | } | ||
| 124 | } else { | ||
| 125 | del_mtd_device(info->mtd); | ||
| 126 | } | ||
| 127 | map_destroy(info->mtd); | ||
| 128 | } | ||
| 129 | |||
| 130 | if (info->map.virt != NULL) | ||
| 131 | iounmap(info->map.virt); | ||
| 132 | |||
| 133 | if (info->res != NULL) | ||
| 134 | release_mem_region(info->res->start, resource_size(info->res)); | ||
| 135 | |||
| 136 | kfree(info); | ||
| 137 | |||
| 138 | if (latch_addr_data->done) | ||
| 139 | latch_addr_data->done(latch_addr_data->data); | ||
| 140 | |||
| 141 | return 0; | ||
| 142 | } | ||
| 143 | |||
| 144 | static int __devinit latch_addr_flash_probe(struct platform_device *dev) | ||
| 145 | { | ||
| 146 | struct latch_addr_flash_data *latch_addr_data; | ||
| 147 | struct latch_addr_flash_info *info; | ||
| 148 | resource_size_t win_base = dev->resource->start; | ||
| 149 | resource_size_t win_size = resource_size(dev->resource); | ||
| 150 | char **probe_type; | ||
| 151 | int chipsel; | ||
| 152 | int err; | ||
| 153 | |||
| 154 | latch_addr_data = dev->dev.platform_data; | ||
| 155 | if (latch_addr_data == NULL) | ||
| 156 | return -ENODEV; | ||
| 157 | |||
| 158 | pr_notice("latch-addr platform flash device: %#llx byte " | ||
| 159 | "window at %#.8llx\n", | ||
| 160 | (unsigned long long)win_size, (unsigned long long)win_base); | ||
| 161 | |||
| 162 | chipsel = dev->id; | ||
| 163 | |||
| 164 | if (latch_addr_data->init) { | ||
| 165 | err = latch_addr_data->init(latch_addr_data->data, chipsel); | ||
| 166 | if (err != 0) | ||
| 167 | return err; | ||
| 168 | } | ||
| 169 | |||
| 170 | info = kzalloc(sizeof(struct latch_addr_flash_info), GFP_KERNEL); | ||
| 171 | if (info == NULL) { | ||
| 172 | err = -ENOMEM; | ||
| 173 | goto done; | ||
| 174 | } | ||
| 175 | |||
| 176 | platform_set_drvdata(dev, info); | ||
| 177 | |||
| 178 | info->res = request_mem_region(win_base, win_size, DRIVER_NAME); | ||
| 179 | if (info->res == NULL) { | ||
| 180 | dev_err(&dev->dev, "Could not reserve memory region\n"); | ||
| 181 | err = -EBUSY; | ||
| 182 | goto free_info; | ||
| 183 | } | ||
| 184 | |||
| 185 | info->map.name = DRIVER_NAME; | ||
| 186 | info->map.size = latch_addr_data->size; | ||
| 187 | info->map.bankwidth = latch_addr_data->width; | ||
| 188 | |||
| 189 | info->map.phys = NO_XIP; | ||
| 190 | info->map.virt = ioremap(win_base, win_size); | ||
| 191 | if (!info->map.virt) { | ||
| 192 | err = -ENOMEM; | ||
| 193 | goto free_res; | ||
| 194 | } | ||
| 195 | |||
| 196 | info->map.map_priv_1 = (unsigned long)info; | ||
| 197 | |||
| 198 | info->map.read = lf_read; | ||
| 199 | info->map.copy_from = lf_copy_from; | ||
| 200 | info->map.write = lf_write; | ||
| 201 | info->set_window = latch_addr_data->set_window; | ||
| 202 | info->data = latch_addr_data->data; | ||
| 203 | info->win_mask = win_size - 1; | ||
| 204 | |||
| 205 | spin_lock_init(&info->lock); | ||
| 206 | |||
| 207 | for (probe_type = rom_probe_types; !info->mtd && *probe_type; | ||
| 208 | probe_type++) | ||
| 209 | info->mtd = do_map_probe(*probe_type, &info->map); | ||
| 210 | |||
| 211 | if (info->mtd == NULL) { | ||
| 212 | dev_err(&dev->dev, "map_probe failed\n"); | ||
| 213 | err = -ENODEV; | ||
| 214 | goto iounmap; | ||
| 215 | } | ||
| 216 | info->mtd->owner = THIS_MODULE; | ||
| 217 | |||
| 218 | if (mtd_has_partitions()) { | ||
| 219 | |||
| 220 | err = parse_mtd_partitions(info->mtd, | ||
| 221 | (const char **)part_probe_types, | ||
| 222 | &info->parts, 0); | ||
| 223 | if (err > 0) { | ||
| 224 | add_mtd_partitions(info->mtd, info->parts, err); | ||
| 225 | return 0; | ||
| 226 | } | ||
| 227 | if (latch_addr_data->nr_parts) { | ||
| 228 | pr_notice("Using latch-addr-flash partition information\n"); | ||
| 229 | add_mtd_partitions(info->mtd, latch_addr_data->parts, | ||
| 230 | latch_addr_data->nr_parts); | ||
| 231 | return 0; | ||
| 232 | } | ||
| 233 | } | ||
| 234 | add_mtd_device(info->mtd); | ||
| 235 | return 0; | ||
| 236 | |||
| 237 | iounmap: | ||
| 238 | iounmap(info->map.virt); | ||
| 239 | free_res: | ||
| 240 | release_mem_region(info->res->start, resource_size(info->res)); | ||
| 241 | free_info: | ||
| 242 | kfree(info); | ||
| 243 | done: | ||
| 244 | if (latch_addr_data->done) | ||
| 245 | latch_addr_data->done(latch_addr_data->data); | ||
| 246 | return err; | ||
| 247 | } | ||
| 248 | |||
| 249 | static struct platform_driver latch_addr_flash_driver = { | ||
| 250 | .probe = latch_addr_flash_probe, | ||
| 251 | .remove = __devexit_p(latch_addr_flash_remove), | ||
| 252 | .driver = { | ||
| 253 | .name = DRIVER_NAME, | ||
| 254 | }, | ||
| 255 | }; | ||
| 256 | |||
| 257 | static int __init latch_addr_flash_init(void) | ||
| 258 | { | ||
| 259 | return platform_driver_register(&latch_addr_flash_driver); | ||
| 260 | } | ||
| 261 | module_init(latch_addr_flash_init); | ||
| 262 | |||
| 263 | static void __exit latch_addr_flash_exit(void) | ||
| 264 | { | ||
| 265 | platform_driver_unregister(&latch_addr_flash_driver); | ||
| 266 | } | ||
| 267 | module_exit(latch_addr_flash_exit); | ||
| 268 | |||
| 269 | MODULE_AUTHOR("David Griego <dgriego@mvista.com>"); | ||
| 270 | MODULE_DESCRIPTION("MTD map driver for flashes addressed physically with upper " | ||
| 271 | "address lines being set board specifically"); | ||
| 272 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c index 4c18b98a311..7522df4f71f 100644 --- a/drivers/mtd/maps/physmap.c +++ b/drivers/mtd/maps/physmap.c | |||
| @@ -59,10 +59,8 @@ static int physmap_flash_remove(struct platform_device *dev) | |||
| 59 | #else | 59 | #else |
| 60 | del_mtd_device(info->cmtd); | 60 | del_mtd_device(info->cmtd); |
| 61 | #endif | 61 | #endif |
| 62 | #ifdef CONFIG_MTD_CONCAT | ||
| 63 | if (info->cmtd != info->mtd[0]) | 62 | if (info->cmtd != info->mtd[0]) |
| 64 | mtd_concat_destroy(info->cmtd); | 63 | mtd_concat_destroy(info->cmtd); |
| 65 | #endif | ||
| 66 | } | 64 | } |
| 67 | 65 | ||
| 68 | for (i = 0; i < MAX_RESOURCES; i++) { | 66 | for (i = 0; i < MAX_RESOURCES; i++) { |
| @@ -159,15 +157,9 @@ static int physmap_flash_probe(struct platform_device *dev) | |||
| 159 | /* | 157 | /* |
| 160 | * We detected multiple devices. Concatenate them together. | 158 | * We detected multiple devices. Concatenate them together. |
| 161 | */ | 159 | */ |
| 162 | #ifdef CONFIG_MTD_CONCAT | ||
| 163 | info->cmtd = mtd_concat_create(info->mtd, devices_found, dev_name(&dev->dev)); | 160 | info->cmtd = mtd_concat_create(info->mtd, devices_found, dev_name(&dev->dev)); |
| 164 | if (info->cmtd == NULL) | 161 | if (info->cmtd == NULL) |
| 165 | err = -ENXIO; | 162 | err = -ENXIO; |
| 166 | #else | ||
| 167 | printk(KERN_ERR "physmap-flash: multiple devices " | ||
| 168 | "found but MTD concat support disabled.\n"); | ||
| 169 | err = -ENXIO; | ||
| 170 | #endif | ||
| 171 | } | 163 | } |
| 172 | if (err) | 164 | if (err) |
| 173 | goto err_out; | 165 | goto err_out; |
diff --git a/drivers/mtd/maps/physmap_of.c b/drivers/mtd/maps/physmap_of.c index 3db0cb083d3..bd483f0c57e 100644 --- a/drivers/mtd/maps/physmap_of.c +++ b/drivers/mtd/maps/physmap_of.c | |||
| @@ -104,12 +104,10 @@ static int of_flash_remove(struct platform_device *dev) | |||
| 104 | return 0; | 104 | return 0; |
| 105 | dev_set_drvdata(&dev->dev, NULL); | 105 | dev_set_drvdata(&dev->dev, NULL); |
| 106 | 106 | ||
| 107 | #ifdef CONFIG_MTD_CONCAT | ||
| 108 | if (info->cmtd != info->list[0].mtd) { | 107 | if (info->cmtd != info->list[0].mtd) { |
| 109 | del_mtd_device(info->cmtd); | 108 | del_mtd_device(info->cmtd); |
| 110 | mtd_concat_destroy(info->cmtd); | 109 | mtd_concat_destroy(info->cmtd); |
| 111 | } | 110 | } |
| 112 | #endif | ||
| 113 | 111 | ||
| 114 | if (info->cmtd) { | 112 | if (info->cmtd) { |
| 115 | if (OF_FLASH_PARTS(info)) { | 113 | if (OF_FLASH_PARTS(info)) { |
| @@ -337,16 +335,10 @@ static int __devinit of_flash_probe(struct platform_device *dev) | |||
| 337 | /* | 335 | /* |
| 338 | * We detected multiple devices. Concatenate them together. | 336 | * We detected multiple devices. Concatenate them together. |
| 339 | */ | 337 | */ |
| 340 | #ifdef CONFIG_MTD_CONCAT | ||
| 341 | info->cmtd = mtd_concat_create(mtd_list, info->list_size, | 338 | info->cmtd = mtd_concat_create(mtd_list, info->list_size, |
| 342 | dev_name(&dev->dev)); | 339 | dev_name(&dev->dev)); |
| 343 | if (info->cmtd == NULL) | 340 | if (info->cmtd == NULL) |
| 344 | err = -ENXIO; | 341 | err = -ENXIO; |
| 345 | #else | ||
| 346 | printk(KERN_ERR "physmap_of: multiple devices " | ||
| 347 | "found but MTD concat support disabled.\n"); | ||
| 348 | err = -ENXIO; | ||
| 349 | #endif | ||
| 350 | } | 342 | } |
| 351 | if (err) | 343 | if (err) |
| 352 | goto err_out; | 344 | goto err_out; |
diff --git a/drivers/mtd/maps/sa1100-flash.c b/drivers/mtd/maps/sa1100-flash.c index f3af87e08ec..da875908ea8 100644 --- a/drivers/mtd/maps/sa1100-flash.c +++ b/drivers/mtd/maps/sa1100-flash.c | |||
| @@ -232,10 +232,8 @@ static void sa1100_destroy(struct sa_info *info, struct flash_platform_data *pla | |||
| 232 | else | 232 | else |
| 233 | del_mtd_partitions(info->mtd); | 233 | del_mtd_partitions(info->mtd); |
| 234 | #endif | 234 | #endif |
| 235 | #ifdef CONFIG_MTD_CONCAT | ||
| 236 | if (info->mtd != info->subdev[0].mtd) | 235 | if (info->mtd != info->subdev[0].mtd) |
| 237 | mtd_concat_destroy(info->mtd); | 236 | mtd_concat_destroy(info->mtd); |
| 238 | #endif | ||
| 239 | } | 237 | } |
| 240 | 238 | ||
| 241 | kfree(info->parts); | 239 | kfree(info->parts); |
| @@ -321,7 +319,6 @@ sa1100_setup_mtd(struct platform_device *pdev, struct flash_platform_data *plat) | |||
| 321 | info->mtd = info->subdev[0].mtd; | 319 | info->mtd = info->subdev[0].mtd; |
| 322 | ret = 0; | 320 | ret = 0; |
| 323 | } else if (info->num_subdev > 1) { | 321 | } else if (info->num_subdev > 1) { |
| 324 | #ifdef CONFIG_MTD_CONCAT | ||
| 325 | struct mtd_info *cdev[nr]; | 322 | struct mtd_info *cdev[nr]; |
| 326 | /* | 323 | /* |
| 327 | * We detected multiple devices. Concatenate them together. | 324 | * We detected multiple devices. Concatenate them together. |
| @@ -333,11 +330,6 @@ sa1100_setup_mtd(struct platform_device *pdev, struct flash_platform_data *plat) | |||
| 333 | plat->name); | 330 | plat->name); |
| 334 | if (info->mtd == NULL) | 331 | if (info->mtd == NULL) |
| 335 | ret = -ENXIO; | 332 | ret = -ENXIO; |
| 336 | #else | ||
| 337 | printk(KERN_ERR "SA1100 flash: multiple devices " | ||
| 338 | "found but MTD concat support disabled.\n"); | ||
| 339 | ret = -ENXIO; | ||
| 340 | #endif | ||
| 341 | } | 333 | } |
| 342 | 334 | ||
| 343 | if (ret == 0) | 335 | if (ret == 0) |
diff --git a/drivers/mtd/maps/ts5500_flash.c b/drivers/mtd/maps/ts5500_flash.c index e2147bf11c8..e02dfa9d4dd 100644 --- a/drivers/mtd/maps/ts5500_flash.c +++ b/drivers/mtd/maps/ts5500_flash.c | |||
| @@ -94,7 +94,6 @@ static int __init init_ts5500_map(void) | |||
| 94 | return 0; | 94 | return 0; |
| 95 | 95 | ||
| 96 | err1: | 96 | err1: |
| 97 | map_destroy(mymtd); | ||
| 98 | iounmap(ts5500_map.virt); | 97 | iounmap(ts5500_map.virt); |
| 99 | err2: | 98 | err2: |
| 100 | return rc; | 99 | return rc; |
diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c index e0a2373bf0e..a534e1f0c34 100644 --- a/drivers/mtd/mtd_blkdevs.c +++ b/drivers/mtd/mtd_blkdevs.c | |||
| @@ -40,7 +40,7 @@ | |||
| 40 | static LIST_HEAD(blktrans_majors); | 40 | static LIST_HEAD(blktrans_majors); |
| 41 | static DEFINE_MUTEX(blktrans_ref_mutex); | 41 | static DEFINE_MUTEX(blktrans_ref_mutex); |
| 42 | 42 | ||
| 43 | void blktrans_dev_release(struct kref *kref) | 43 | static void blktrans_dev_release(struct kref *kref) |
| 44 | { | 44 | { |
| 45 | struct mtd_blktrans_dev *dev = | 45 | struct mtd_blktrans_dev *dev = |
| 46 | container_of(kref, struct mtd_blktrans_dev, ref); | 46 | container_of(kref, struct mtd_blktrans_dev, ref); |
| @@ -67,7 +67,7 @@ unlock: | |||
| 67 | return dev; | 67 | return dev; |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | void blktrans_dev_put(struct mtd_blktrans_dev *dev) | 70 | static void blktrans_dev_put(struct mtd_blktrans_dev *dev) |
| 71 | { | 71 | { |
| 72 | mutex_lock(&blktrans_ref_mutex); | 72 | mutex_lock(&blktrans_ref_mutex); |
| 73 | kref_put(&dev->ref, blktrans_dev_release); | 73 | kref_put(&dev->ref, blktrans_dev_release); |
| @@ -119,18 +119,43 @@ static int do_blktrans_request(struct mtd_blktrans_ops *tr, | |||
| 119 | } | 119 | } |
| 120 | } | 120 | } |
| 121 | 121 | ||
| 122 | int mtd_blktrans_cease_background(struct mtd_blktrans_dev *dev) | ||
| 123 | { | ||
| 124 | if (kthread_should_stop()) | ||
| 125 | return 1; | ||
| 126 | |||
| 127 | return dev->bg_stop; | ||
| 128 | } | ||
| 129 | EXPORT_SYMBOL_GPL(mtd_blktrans_cease_background); | ||
| 130 | |||
| 122 | static int mtd_blktrans_thread(void *arg) | 131 | static int mtd_blktrans_thread(void *arg) |
| 123 | { | 132 | { |
| 124 | struct mtd_blktrans_dev *dev = arg; | 133 | struct mtd_blktrans_dev *dev = arg; |
| 134 | struct mtd_blktrans_ops *tr = dev->tr; | ||
| 125 | struct request_queue *rq = dev->rq; | 135 | struct request_queue *rq = dev->rq; |
| 126 | struct request *req = NULL; | 136 | struct request *req = NULL; |
| 137 | int background_done = 0; | ||
| 127 | 138 | ||
| 128 | spin_lock_irq(rq->queue_lock); | 139 | spin_lock_irq(rq->queue_lock); |
| 129 | 140 | ||
| 130 | while (!kthread_should_stop()) { | 141 | while (!kthread_should_stop()) { |
| 131 | int res; | 142 | int res; |
| 132 | 143 | ||
| 144 | dev->bg_stop = false; | ||
| 133 | if (!req && !(req = blk_fetch_request(rq))) { | 145 | if (!req && !(req = blk_fetch_request(rq))) { |
| 146 | if (tr->background && !background_done) { | ||
| 147 | spin_unlock_irq(rq->queue_lock); | ||
| 148 | mutex_lock(&dev->lock); | ||
| 149 | tr->background(dev); | ||
| 150 | mutex_unlock(&dev->lock); | ||
| 151 | spin_lock_irq(rq->queue_lock); | ||
| 152 | /* | ||
| 153 | * Do background processing just once per idle | ||
| 154 | * period. | ||
| 155 | */ | ||
| 156 | background_done = !dev->bg_stop; | ||
| 157 | continue; | ||
| 158 | } | ||
| 134 | set_current_state(TASK_INTERRUPTIBLE); | 159 | set_current_state(TASK_INTERRUPTIBLE); |
| 135 | 160 | ||
| 136 | if (kthread_should_stop()) | 161 | if (kthread_should_stop()) |
| @@ -152,6 +177,8 @@ static int mtd_blktrans_thread(void *arg) | |||
| 152 | 177 | ||
| 153 | if (!__blk_end_request_cur(req, res)) | 178 | if (!__blk_end_request_cur(req, res)) |
| 154 | req = NULL; | 179 | req = NULL; |
| 180 | |||
| 181 | background_done = 0; | ||
| 155 | } | 182 | } |
| 156 | 183 | ||
| 157 | if (req) | 184 | if (req) |
| @@ -172,8 +199,10 @@ static void mtd_blktrans_request(struct request_queue *rq) | |||
| 172 | if (!dev) | 199 | if (!dev) |
| 173 | while ((req = blk_fetch_request(rq)) != NULL) | 200 | while ((req = blk_fetch_request(rq)) != NULL) |
| 174 | __blk_end_request_all(req, -ENODEV); | 201 | __blk_end_request_all(req, -ENODEV); |
| 175 | else | 202 | else { |
| 203 | dev->bg_stop = true; | ||
| 176 | wake_up_process(dev->thread); | 204 | wake_up_process(dev->thread); |
| 205 | } | ||
| 177 | } | 206 | } |
| 178 | 207 | ||
| 179 | static int blktrans_open(struct block_device *bdev, fmode_t mode) | 208 | static int blktrans_open(struct block_device *bdev, fmode_t mode) |
| @@ -379,9 +408,10 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new) | |||
| 379 | new->rq->queuedata = new; | 408 | new->rq->queuedata = new; |
| 380 | blk_queue_logical_block_size(new->rq, tr->blksize); | 409 | blk_queue_logical_block_size(new->rq, tr->blksize); |
| 381 | 410 | ||
| 382 | if (tr->discard) | 411 | if (tr->discard) { |
| 383 | queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, | 412 | queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, new->rq); |
| 384 | new->rq); | 413 | new->rq->limits.max_discard_sectors = UINT_MAX; |
| 414 | } | ||
| 385 | 415 | ||
| 386 | gd->queue = new->rq; | 416 | gd->queue = new->rq; |
| 387 | 417 | ||
diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c index 5f5777bd3f7..5060e608ea5 100644 --- a/drivers/mtd/mtdconcat.c +++ b/drivers/mtd/mtdconcat.c | |||
| @@ -750,6 +750,7 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c | |||
| 750 | struct mtd_concat *concat; | 750 | struct mtd_concat *concat; |
| 751 | uint32_t max_erasesize, curr_erasesize; | 751 | uint32_t max_erasesize, curr_erasesize; |
| 752 | int num_erase_region; | 752 | int num_erase_region; |
| 753 | int max_writebufsize = 0; | ||
| 753 | 754 | ||
| 754 | printk(KERN_NOTICE "Concatenating MTD devices:\n"); | 755 | printk(KERN_NOTICE "Concatenating MTD devices:\n"); |
| 755 | for (i = 0; i < num_devs; i++) | 756 | for (i = 0; i < num_devs; i++) |
| @@ -776,7 +777,12 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c | |||
| 776 | concat->mtd.size = subdev[0]->size; | 777 | concat->mtd.size = subdev[0]->size; |
| 777 | concat->mtd.erasesize = subdev[0]->erasesize; | 778 | concat->mtd.erasesize = subdev[0]->erasesize; |
| 778 | concat->mtd.writesize = subdev[0]->writesize; | 779 | concat->mtd.writesize = subdev[0]->writesize; |
| 779 | concat->mtd.writebufsize = subdev[0]->writebufsize; | 780 | |
| 781 | for (i = 0; i < num_devs; i++) | ||
| 782 | if (max_writebufsize < subdev[i]->writebufsize) | ||
| 783 | max_writebufsize = subdev[i]->writebufsize; | ||
| 784 | concat->mtd.writebufsize = max_writebufsize; | ||
| 785 | |||
| 780 | concat->mtd.subpage_sft = subdev[0]->subpage_sft; | 786 | concat->mtd.subpage_sft = subdev[0]->subpage_sft; |
| 781 | concat->mtd.oobsize = subdev[0]->oobsize; | 787 | concat->mtd.oobsize = subdev[0]->oobsize; |
| 782 | concat->mtd.oobavail = subdev[0]->oobavail; | 788 | concat->mtd.oobavail = subdev[0]->oobavail; |
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index 527cebf58da..da69bc8a5a7 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c | |||
| @@ -43,7 +43,7 @@ | |||
| 43 | * backing device capabilities for non-mappable devices (such as NAND flash) | 43 | * backing device capabilities for non-mappable devices (such as NAND flash) |
| 44 | * - permits private mappings, copies are taken of the data | 44 | * - permits private mappings, copies are taken of the data |
| 45 | */ | 45 | */ |
| 46 | struct backing_dev_info mtd_bdi_unmappable = { | 46 | static struct backing_dev_info mtd_bdi_unmappable = { |
| 47 | .capabilities = BDI_CAP_MAP_COPY, | 47 | .capabilities = BDI_CAP_MAP_COPY, |
| 48 | }; | 48 | }; |
| 49 | 49 | ||
| @@ -52,7 +52,7 @@ struct backing_dev_info mtd_bdi_unmappable = { | |||
| 52 | * - permits private mappings, copies are taken of the data | 52 | * - permits private mappings, copies are taken of the data |
| 53 | * - permits non-writable shared mappings | 53 | * - permits non-writable shared mappings |
| 54 | */ | 54 | */ |
| 55 | struct backing_dev_info mtd_bdi_ro_mappable = { | 55 | static struct backing_dev_info mtd_bdi_ro_mappable = { |
| 56 | .capabilities = (BDI_CAP_MAP_COPY | BDI_CAP_MAP_DIRECT | | 56 | .capabilities = (BDI_CAP_MAP_COPY | BDI_CAP_MAP_DIRECT | |
| 57 | BDI_CAP_EXEC_MAP | BDI_CAP_READ_MAP), | 57 | BDI_CAP_EXEC_MAP | BDI_CAP_READ_MAP), |
| 58 | }; | 58 | }; |
| @@ -62,7 +62,7 @@ struct backing_dev_info mtd_bdi_ro_mappable = { | |||
| 62 | * - permits private mappings, copies are taken of the data | 62 | * - permits private mappings, copies are taken of the data |
| 63 | * - permits non-writable shared mappings | 63 | * - permits non-writable shared mappings |
| 64 | */ | 64 | */ |
| 65 | struct backing_dev_info mtd_bdi_rw_mappable = { | 65 | static struct backing_dev_info mtd_bdi_rw_mappable = { |
| 66 | .capabilities = (BDI_CAP_MAP_COPY | BDI_CAP_MAP_DIRECT | | 66 | .capabilities = (BDI_CAP_MAP_COPY | BDI_CAP_MAP_DIRECT | |
| 67 | BDI_CAP_EXEC_MAP | BDI_CAP_READ_MAP | | 67 | BDI_CAP_EXEC_MAP | BDI_CAP_READ_MAP | |
| 68 | BDI_CAP_WRITE_MAP), | 68 | BDI_CAP_WRITE_MAP), |
diff --git a/drivers/mtd/mtdswap.c b/drivers/mtd/mtdswap.c new file mode 100644 index 00000000000..237913c5c92 --- /dev/null +++ b/drivers/mtd/mtdswap.c | |||
| @@ -0,0 +1,1587 @@ | |||
| 1 | /* | ||
| 2 | * Swap block device support for MTDs | ||
| 3 | * Turns an MTD device into a swap device with block wear leveling | ||
| 4 | * | ||
| 5 | * Copyright © 2007,2011 Nokia Corporation. All rights reserved. | ||
| 6 | * | ||
| 7 | * Authors: Jarkko Lavinen <jarkko.lavinen@nokia.com> | ||
| 8 | * | ||
| 9 | * Based on Richard Purdie's earlier implementation in 2007. Background | ||
| 10 | * support and lock-less operation written by Adrian Hunter. | ||
| 11 | * | ||
| 12 | * This program is free software; you can redistribute it and/or | ||
| 13 | * modify it under the terms of the GNU General Public License | ||
| 14 | * version 2 as published by the Free Software Foundation. | ||
| 15 | * | ||
| 16 | * This program is distributed in the hope that it will be useful, but | ||
| 17 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 19 | * General Public License for more details. | ||
| 20 | * | ||
| 21 | * You should have received a copy of the GNU General Public License | ||
| 22 | * along with this program; if not, write to the Free Software | ||
| 23 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
| 24 | * 02110-1301 USA | ||
| 25 | */ | ||
| 26 | |||
| 27 | #include <linux/kernel.h> | ||
| 28 | #include <linux/module.h> | ||
| 29 | #include <linux/mtd/mtd.h> | ||
| 30 | #include <linux/mtd/blktrans.h> | ||
| 31 | #include <linux/rbtree.h> | ||
| 32 | #include <linux/sched.h> | ||
| 33 | #include <linux/slab.h> | ||
| 34 | #include <linux/vmalloc.h> | ||
| 35 | #include <linux/genhd.h> | ||
| 36 | #include <linux/swap.h> | ||
| 37 | #include <linux/debugfs.h> | ||
| 38 | #include <linux/seq_file.h> | ||
| 39 | #include <linux/device.h> | ||
| 40 | #include <linux/math64.h> | ||
| 41 | |||
| 42 | #define MTDSWAP_PREFIX "mtdswap" | ||
| 43 | |||
| 44 | /* | ||
| 45 | * The number of free eraseblocks when GC should stop | ||
| 46 | */ | ||
| 47 | #define CLEAN_BLOCK_THRESHOLD 20 | ||
| 48 | |||
| 49 | /* | ||
| 50 | * Number of free eraseblocks below which GC can also collect low frag | ||
| 51 | * blocks. | ||
| 52 | */ | ||
| 53 | #define LOW_FRAG_GC_TRESHOLD 5 | ||
| 54 | |||
| 55 | /* | ||
| 56 | * Wear level cost amortization. We want to do wear leveling on the background | ||
| 57 | * without disturbing gc too much. This is made by defining max GC frequency. | ||
| 58 | * Frequency value 6 means 1/6 of the GC passes will pick an erase block based | ||
| 59 | * on the biggest wear difference rather than the biggest dirtiness. | ||
| 60 | * | ||
| 61 | * The lower freq2 should be chosen so that it makes sure the maximum erase | ||
| 62 | * difference will decrease even if a malicious application is deliberately | ||
| 63 | * trying to make erase differences large. | ||
| 64 | */ | ||
| 65 | #define MAX_ERASE_DIFF 4000 | ||
| 66 | #define COLLECT_NONDIRTY_BASE MAX_ERASE_DIFF | ||
| 67 | #define COLLECT_NONDIRTY_FREQ1 6 | ||
| 68 | #define COLLECT_NONDIRTY_FREQ2 4 | ||
| 69 | |||
| 70 | #define PAGE_UNDEF UINT_MAX | ||
| 71 | #define BLOCK_UNDEF UINT_MAX | ||
| 72 | #define BLOCK_ERROR (UINT_MAX - 1) | ||
| 73 | #define BLOCK_MAX (UINT_MAX - 2) | ||
| 74 | |||
| 75 | #define EBLOCK_BAD (1 << 0) | ||
| 76 | #define EBLOCK_NOMAGIC (1 << 1) | ||
| 77 | #define EBLOCK_BITFLIP (1 << 2) | ||
| 78 | #define EBLOCK_FAILED (1 << 3) | ||
| 79 | #define EBLOCK_READERR (1 << 4) | ||
| 80 | #define EBLOCK_IDX_SHIFT 5 | ||
| 81 | |||
| 82 | struct swap_eb { | ||
| 83 | struct rb_node rb; | ||
| 84 | struct rb_root *root; | ||
| 85 | |||
| 86 | unsigned int flags; | ||
| 87 | unsigned int active_count; | ||
| 88 | unsigned int erase_count; | ||
| 89 | unsigned int pad; /* speeds up pointer decremtnt */ | ||
| 90 | }; | ||
| 91 | |||
| 92 | #define MTDSWAP_ECNT_MIN(rbroot) (rb_entry(rb_first(rbroot), struct swap_eb, \ | ||
| 93 | rb)->erase_count) | ||
| 94 | #define MTDSWAP_ECNT_MAX(rbroot) (rb_entry(rb_last(rbroot), struct swap_eb, \ | ||
| 95 | rb)->erase_count) | ||
| 96 | |||
| 97 | struct mtdswap_tree { | ||
| 98 | struct rb_root root; | ||
| 99 | unsigned int count; | ||
| 100 | }; | ||
| 101 | |||
| 102 | enum { | ||
| 103 | MTDSWAP_CLEAN, | ||
| 104 | MTDSWAP_USED, | ||
| 105 | MTDSWAP_LOWFRAG, | ||
| 106 | MTDSWAP_HIFRAG, | ||
| 107 | MTDSWAP_DIRTY, | ||
| 108 | MTDSWAP_BITFLIP, | ||
| 109 | MTDSWAP_FAILING, | ||
| 110 | MTDSWAP_TREE_CNT, | ||
| 111 | }; | ||
| 112 | |||
| 113 | struct mtdswap_dev { | ||
| 114 | struct mtd_blktrans_dev *mbd_dev; | ||
| 115 | struct mtd_info *mtd; | ||
| 116 | struct device *dev; | ||
| 117 | |||
| 118 | unsigned int *page_data; | ||
| 119 | unsigned int *revmap; | ||
| 120 | |||
| 121 | unsigned int eblks; | ||
| 122 | unsigned int spare_eblks; | ||
| 123 | unsigned int pages_per_eblk; | ||
| 124 | unsigned int max_erase_count; | ||
| 125 | struct swap_eb *eb_data; | ||
| 126 | |||
| 127 | struct mtdswap_tree trees[MTDSWAP_TREE_CNT]; | ||
| 128 | |||
| 129 | unsigned long long sect_read_count; | ||
| 130 | unsigned long long sect_write_count; | ||
| 131 | unsigned long long mtd_write_count; | ||
| 132 | unsigned long long mtd_read_count; | ||
| 133 | unsigned long long discard_count; | ||
| 134 | unsigned long long discard_page_count; | ||
| 135 | |||
| 136 | unsigned int curr_write_pos; | ||
| 137 | struct swap_eb *curr_write; | ||
| 138 | |||
| 139 | char *page_buf; | ||
| 140 | char *oob_buf; | ||
| 141 | |||
| 142 | struct dentry *debugfs_root; | ||
| 143 | }; | ||
| 144 | |||
| 145 | struct mtdswap_oobdata { | ||
| 146 | __le16 magic; | ||
| 147 | __le32 count; | ||
| 148 | } __attribute__((packed)); | ||
| 149 | |||
| 150 | #define MTDSWAP_MAGIC_CLEAN 0x2095 | ||
| 151 | #define MTDSWAP_MAGIC_DIRTY (MTDSWAP_MAGIC_CLEAN + 1) | ||
| 152 | #define MTDSWAP_TYPE_CLEAN 0 | ||
| 153 | #define MTDSWAP_TYPE_DIRTY 1 | ||
| 154 | #define MTDSWAP_OOBSIZE sizeof(struct mtdswap_oobdata) | ||
| 155 | |||
| 156 | #define MTDSWAP_ERASE_RETRIES 3 /* Before marking erase block bad */ | ||
| 157 | #define MTDSWAP_IO_RETRIES 3 | ||
| 158 | |||
| 159 | enum { | ||
| 160 | MTDSWAP_SCANNED_CLEAN, | ||
| 161 | MTDSWAP_SCANNED_DIRTY, | ||
| 162 | MTDSWAP_SCANNED_BITFLIP, | ||
| 163 | MTDSWAP_SCANNED_BAD, | ||
| 164 | }; | ||
| 165 | |||
| 166 | /* | ||
| 167 | * In the worst case mtdswap_writesect() has allocated the last clean | ||
| 168 | * page from the current block and is then pre-empted by the GC | ||
| 169 | * thread. The thread can consume a full erase block when moving a | ||
| 170 | * block. | ||
| 171 | */ | ||
| 172 | #define MIN_SPARE_EBLOCKS 2 | ||
| 173 | #define MIN_ERASE_BLOCKS (MIN_SPARE_EBLOCKS + 1) | ||
| 174 | |||
| 175 | #define TREE_ROOT(d, name) (&d->trees[MTDSWAP_ ## name].root) | ||
| 176 | #define TREE_EMPTY(d, name) (TREE_ROOT(d, name)->rb_node == NULL) | ||
| 177 | #define TREE_NONEMPTY(d, name) (!TREE_EMPTY(d, name)) | ||
| 178 | #define TREE_COUNT(d, name) (d->trees[MTDSWAP_ ## name].count) | ||
| 179 | |||
| 180 | #define MTDSWAP_MBD_TO_MTDSWAP(dev) ((struct mtdswap_dev *)dev->priv) | ||
| 181 | |||
| 182 | static char partitions[128] = ""; | ||
| 183 | module_param_string(partitions, partitions, sizeof(partitions), 0444); | ||
| 184 | MODULE_PARM_DESC(partitions, "MTD partition numbers to use as swap " | ||
| 185 | "partitions=\"1,3,5\""); | ||
| 186 | |||
| 187 | static unsigned int spare_eblocks = 10; | ||
| 188 | module_param(spare_eblocks, uint, 0444); | ||
| 189 | MODULE_PARM_DESC(spare_eblocks, "Percentage of spare erase blocks for " | ||
| 190 | "garbage collection (default 10%)"); | ||
| 191 | |||
| 192 | static bool header; /* false */ | ||
| 193 | module_param(header, bool, 0444); | ||
| 194 | MODULE_PARM_DESC(header, | ||
| 195 | "Include builtin swap header (default 0, without header)"); | ||
| 196 | |||
| 197 | static int mtdswap_gc(struct mtdswap_dev *d, unsigned int background); | ||
| 198 | |||
| 199 | static loff_t mtdswap_eb_offset(struct mtdswap_dev *d, struct swap_eb *eb) | ||
| 200 | { | ||
| 201 | return (loff_t)(eb - d->eb_data) * d->mtd->erasesize; | ||
| 202 | } | ||
| 203 | |||
| 204 | static void mtdswap_eb_detach(struct mtdswap_dev *d, struct swap_eb *eb) | ||
| 205 | { | ||
| 206 | unsigned int oldidx; | ||
| 207 | struct mtdswap_tree *tp; | ||
| 208 | |||
| 209 | if (eb->root) { | ||
| 210 | tp = container_of(eb->root, struct mtdswap_tree, root); | ||
| 211 | oldidx = tp - &d->trees[0]; | ||
| 212 | |||
| 213 | d->trees[oldidx].count--; | ||
| 214 | rb_erase(&eb->rb, eb->root); | ||
| 215 | } | ||
| 216 | } | ||
| 217 | |||
| 218 | static void __mtdswap_rb_add(struct rb_root *root, struct swap_eb *eb) | ||
| 219 | { | ||
| 220 | struct rb_node **p, *parent = NULL; | ||
| 221 | struct swap_eb *cur; | ||
| 222 | |||
| 223 | p = &root->rb_node; | ||
| 224 | while (*p) { | ||
| 225 | parent = *p; | ||
| 226 | cur = rb_entry(parent, struct swap_eb, rb); | ||
| 227 | if (eb->erase_count > cur->erase_count) | ||
| 228 | p = &(*p)->rb_right; | ||
| 229 | else | ||
| 230 | p = &(*p)->rb_left; | ||
| 231 | } | ||
| 232 | |||
| 233 | rb_link_node(&eb->rb, parent, p); | ||
| 234 | rb_insert_color(&eb->rb, root); | ||
| 235 | } | ||
| 236 | |||
| 237 | static void mtdswap_rb_add(struct mtdswap_dev *d, struct swap_eb *eb, int idx) | ||
| 238 | { | ||
| 239 | struct rb_root *root; | ||
| 240 | |||
| 241 | if (eb->root == &d->trees[idx].root) | ||
| 242 | return; | ||
| 243 | |||
| 244 | mtdswap_eb_detach(d, eb); | ||
| 245 | root = &d->trees[idx].root; | ||
| 246 | __mtdswap_rb_add(root, eb); | ||
| 247 | eb->root = root; | ||
| 248 | d->trees[idx].count++; | ||
| 249 | } | ||
| 250 | |||
| 251 | static struct rb_node *mtdswap_rb_index(struct rb_root *root, unsigned int idx) | ||
| 252 | { | ||
| 253 | struct rb_node *p; | ||
| 254 | unsigned int i; | ||
| 255 | |||
| 256 | p = rb_first(root); | ||
| 257 | i = 0; | ||
| 258 | while (i < idx && p) { | ||
| 259 | p = rb_next(p); | ||
| 260 | i++; | ||
| 261 | } | ||
| 262 | |||
| 263 | return p; | ||
| 264 | } | ||
| 265 | |||
| 266 | static int mtdswap_handle_badblock(struct mtdswap_dev *d, struct swap_eb *eb) | ||
| 267 | { | ||
| 268 | int ret; | ||
| 269 | loff_t offset; | ||
| 270 | |||
| 271 | d->spare_eblks--; | ||
| 272 | eb->flags |= EBLOCK_BAD; | ||
| 273 | mtdswap_eb_detach(d, eb); | ||
| 274 | eb->root = NULL; | ||
| 275 | |||
| 276 | /* badblocks not supported */ | ||
| 277 | if (!d->mtd->block_markbad) | ||
| 278 | return 1; | ||
| 279 | |||
| 280 | offset = mtdswap_eb_offset(d, eb); | ||
| 281 | dev_warn(d->dev, "Marking bad block at %08llx\n", offset); | ||
| 282 | ret = d->mtd->block_markbad(d->mtd, offset); | ||
| 283 | |||
| 284 | if (ret) { | ||
| 285 | dev_warn(d->dev, "Mark block bad failed for block at %08llx " | ||
| 286 | "error %d\n", offset, ret); | ||
| 287 | return ret; | ||
| 288 | } | ||
| 289 | |||
| 290 | return 1; | ||
| 291 | |||
| 292 | } | ||
| 293 | |||
| 294 | static int mtdswap_handle_write_error(struct mtdswap_dev *d, struct swap_eb *eb) | ||
| 295 | { | ||
| 296 | unsigned int marked = eb->flags & EBLOCK_FAILED; | ||
| 297 | struct swap_eb *curr_write = d->curr_write; | ||
| 298 | |||
| 299 | eb->flags |= EBLOCK_FAILED; | ||
| 300 | if (curr_write == eb) { | ||
| 301 | d->curr_write = NULL; | ||
| 302 | |||
| 303 | if (!marked && d->curr_write_pos != 0) { | ||
| 304 | mtdswap_rb_add(d, eb, MTDSWAP_FAILING); | ||
| 305 | return 0; | ||
| 306 | } | ||
| 307 | } | ||
| 308 | |||
| 309 | return mtdswap_handle_badblock(d, eb); | ||
| 310 | } | ||
| 311 | |||
| 312 | static int mtdswap_read_oob(struct mtdswap_dev *d, loff_t from, | ||
| 313 | struct mtd_oob_ops *ops) | ||
| 314 | { | ||
| 315 | int ret = d->mtd->read_oob(d->mtd, from, ops); | ||
| 316 | |||
| 317 | if (ret == -EUCLEAN) | ||
| 318 | return ret; | ||
| 319 | |||
| 320 | if (ret) { | ||
| 321 | dev_warn(d->dev, "Read OOB failed %d for block at %08llx\n", | ||
| 322 | ret, from); | ||
| 323 | return ret; | ||
| 324 | } | ||
| 325 | |||
| 326 | if (ops->oobretlen < ops->ooblen) { | ||
| 327 | dev_warn(d->dev, "Read OOB return short read (%zd bytes not " | ||
| 328 | "%zd) for block at %08llx\n", | ||
| 329 | ops->oobretlen, ops->ooblen, from); | ||
| 330 | return -EIO; | ||
| 331 | } | ||
| 332 | |||
| 333 | return 0; | ||
| 334 | } | ||
| 335 | |||
| 336 | static int mtdswap_read_markers(struct mtdswap_dev *d, struct swap_eb *eb) | ||
| 337 | { | ||
| 338 | struct mtdswap_oobdata *data, *data2; | ||
| 339 | int ret; | ||
| 340 | loff_t offset; | ||
| 341 | struct mtd_oob_ops ops; | ||
| 342 | |||
| 343 | offset = mtdswap_eb_offset(d, eb); | ||
| 344 | |||
| 345 | /* Check first if the block is bad. */ | ||
| 346 | if (d->mtd->block_isbad && d->mtd->block_isbad(d->mtd, offset)) | ||
| 347 | return MTDSWAP_SCANNED_BAD; | ||
| 348 | |||
| 349 | ops.ooblen = 2 * d->mtd->ecclayout->oobavail; | ||
| 350 | ops.oobbuf = d->oob_buf; | ||
| 351 | ops.ooboffs = 0; | ||
| 352 | ops.datbuf = NULL; | ||
| 353 | ops.mode = MTD_OOB_AUTO; | ||
| 354 | |||
| 355 | ret = mtdswap_read_oob(d, offset, &ops); | ||
| 356 | |||
| 357 | if (ret && ret != -EUCLEAN) | ||
| 358 | return ret; | ||
| 359 | |||
| 360 | data = (struct mtdswap_oobdata *)d->oob_buf; | ||
| 361 | data2 = (struct mtdswap_oobdata *) | ||
| 362 | (d->oob_buf + d->mtd->ecclayout->oobavail); | ||
| 363 | |||
| 364 | if (le16_to_cpu(data->magic) == MTDSWAP_MAGIC_CLEAN) { | ||
| 365 | eb->erase_count = le32_to_cpu(data->count); | ||
| 366 | if (ret == -EUCLEAN) | ||
| 367 | ret = MTDSWAP_SCANNED_BITFLIP; | ||
| 368 | else { | ||
| 369 | if (le16_to_cpu(data2->magic) == MTDSWAP_MAGIC_DIRTY) | ||
| 370 | ret = MTDSWAP_SCANNED_DIRTY; | ||
| 371 | else | ||
| 372 | ret = MTDSWAP_SCANNED_CLEAN; | ||
| 373 | } | ||
| 374 | } else { | ||
| 375 | eb->flags |= EBLOCK_NOMAGIC; | ||
| 376 | ret = MTDSWAP_SCANNED_DIRTY; | ||
| 377 | } | ||
| 378 | |||
| 379 | return ret; | ||
| 380 | } | ||
| 381 | |||
| 382 | static int mtdswap_write_marker(struct mtdswap_dev *d, struct swap_eb *eb, | ||
| 383 | u16 marker) | ||
| 384 | { | ||
| 385 | struct mtdswap_oobdata n; | ||
| 386 | int ret; | ||
| 387 | loff_t offset; | ||
| 388 | struct mtd_oob_ops ops; | ||
| 389 | |||
| 390 | ops.ooboffs = 0; | ||
| 391 | ops.oobbuf = (uint8_t *)&n; | ||
| 392 | ops.mode = MTD_OOB_AUTO; | ||
| 393 | ops.datbuf = NULL; | ||
| 394 | |||
| 395 | if (marker == MTDSWAP_TYPE_CLEAN) { | ||
| 396 | n.magic = cpu_to_le16(MTDSWAP_MAGIC_CLEAN); | ||
| 397 | n.count = cpu_to_le32(eb->erase_count); | ||
| 398 | ops.ooblen = MTDSWAP_OOBSIZE; | ||
| 399 | offset = mtdswap_eb_offset(d, eb); | ||
| 400 | } else { | ||
| 401 | n.magic = cpu_to_le16(MTDSWAP_MAGIC_DIRTY); | ||
| 402 | ops.ooblen = sizeof(n.magic); | ||
| 403 | offset = mtdswap_eb_offset(d, eb) + d->mtd->writesize; | ||
| 404 | } | ||
| 405 | |||
| 406 | ret = d->mtd->write_oob(d->mtd, offset , &ops); | ||
| 407 | |||
| 408 | if (ret) { | ||
| 409 | dev_warn(d->dev, "Write OOB failed for block at %08llx " | ||
| 410 | "error %d\n", offset, ret); | ||
| 411 | if (ret == -EIO || ret == -EBADMSG) | ||
| 412 | mtdswap_handle_write_error(d, eb); | ||
| 413 | return ret; | ||
| 414 | } | ||
| 415 | |||
| 416 | if (ops.oobretlen != ops.ooblen) { | ||
| 417 | dev_warn(d->dev, "Short OOB write for block at %08llx: " | ||
| 418 | "%zd not %zd\n", | ||
| 419 | offset, ops.oobretlen, ops.ooblen); | ||
| 420 | return ret; | ||
| 421 | } | ||
| 422 | |||
| 423 | return 0; | ||
| 424 | } | ||
| 425 | |||
| 426 | /* | ||
| 427 | * Are there any erase blocks without MAGIC_CLEAN header, presumably | ||
| 428 | * because power was cut off after erase but before header write? We | ||
| 429 | * need to guestimate the erase count. | ||
| 430 | */ | ||
| 431 | static void mtdswap_check_counts(struct mtdswap_dev *d) | ||
| 432 | { | ||
| 433 | struct rb_root hist_root = RB_ROOT; | ||
| 434 | struct rb_node *medrb; | ||
| 435 | struct swap_eb *eb; | ||
| 436 | unsigned int i, cnt, median; | ||
| 437 | |||
| 438 | cnt = 0; | ||
| 439 | for (i = 0; i < d->eblks; i++) { | ||
| 440 | eb = d->eb_data + i; | ||
| 441 | |||
| 442 | if (eb->flags & (EBLOCK_NOMAGIC | EBLOCK_BAD | EBLOCK_READERR)) | ||
| 443 | continue; | ||
| 444 | |||
| 445 | __mtdswap_rb_add(&hist_root, eb); | ||
| 446 | cnt++; | ||
| 447 | } | ||
| 448 | |||
| 449 | if (cnt == 0) | ||
| 450 | return; | ||
| 451 | |||
| 452 | medrb = mtdswap_rb_index(&hist_root, cnt / 2); | ||
| 453 | median = rb_entry(medrb, struct swap_eb, rb)->erase_count; | ||
| 454 | |||
| 455 | d->max_erase_count = MTDSWAP_ECNT_MAX(&hist_root); | ||
| 456 | |||
| 457 | for (i = 0; i < d->eblks; i++) { | ||
| 458 | eb = d->eb_data + i; | ||
| 459 | |||
| 460 | if (eb->flags & (EBLOCK_NOMAGIC | EBLOCK_READERR)) | ||
| 461 | eb->erase_count = median; | ||
| 462 | |||
| 463 | if (eb->flags & (EBLOCK_NOMAGIC | EBLOCK_BAD | EBLOCK_READERR)) | ||
| 464 | continue; | ||
| 465 | |||
| 466 | rb_erase(&eb->rb, &hist_root); | ||
| 467 | } | ||
| 468 | } | ||
| 469 | |||
| 470 | static void mtdswap_scan_eblks(struct mtdswap_dev *d) | ||
| 471 | { | ||
| 472 | int status; | ||
| 473 | unsigned int i, idx; | ||
| 474 | struct swap_eb *eb; | ||
| 475 | |||
| 476 | for (i = 0; i < d->eblks; i++) { | ||
| 477 | eb = d->eb_data + i; | ||
| 478 | |||
| 479 | status = mtdswap_read_markers(d, eb); | ||
| 480 | if (status < 0) | ||
| 481 | eb->flags |= EBLOCK_READERR; | ||
| 482 | else if (status == MTDSWAP_SCANNED_BAD) { | ||
| 483 | eb->flags |= EBLOCK_BAD; | ||
| 484 | continue; | ||
| 485 | } | ||
| 486 | |||
| 487 | switch (status) { | ||
| 488 | case MTDSWAP_SCANNED_CLEAN: | ||
| 489 | idx = MTDSWAP_CLEAN; | ||
| 490 | break; | ||
| 491 | case MTDSWAP_SCANNED_DIRTY: | ||
| 492 | case MTDSWAP_SCANNED_BITFLIP: | ||
| 493 | idx = MTDSWAP_DIRTY; | ||
| 494 | break; | ||
| 495 | default: | ||
| 496 | idx = MTDSWAP_FAILING; | ||
| 497 | } | ||
| 498 | |||
| 499 | eb->flags |= (idx << EBLOCK_IDX_SHIFT); | ||
| 500 | } | ||
| 501 | |||
| 502 | mtdswap_check_counts(d); | ||
| 503 | |||
| 504 | for (i = 0; i < d->eblks; i++) { | ||
| 505 | eb = d->eb_data + i; | ||
| 506 | |||
| 507 | if (eb->flags & EBLOCK_BAD) | ||
| 508 | continue; | ||
| 509 | |||
| 510 | idx = eb->flags >> EBLOCK_IDX_SHIFT; | ||
| 511 | mtdswap_rb_add(d, eb, idx); | ||
| 512 | } | ||
| 513 | } | ||
| 514 | |||
| 515 | /* | ||
| 516 | * Place eblk into a tree corresponding to its number of active blocks | ||
| 517 | * it contains. | ||
| 518 | */ | ||
| 519 | static void mtdswap_store_eb(struct mtdswap_dev *d, struct swap_eb *eb) | ||
| 520 | { | ||
| 521 | unsigned int weight = eb->active_count; | ||
| 522 | unsigned int maxweight = d->pages_per_eblk; | ||
| 523 | |||
| 524 | if (eb == d->curr_write) | ||
| 525 | return; | ||
| 526 | |||
| 527 | if (eb->flags & EBLOCK_BITFLIP) | ||
| 528 | mtdswap_rb_add(d, eb, MTDSWAP_BITFLIP); | ||
| 529 | else if (eb->flags & (EBLOCK_READERR | EBLOCK_FAILED)) | ||
| 530 | mtdswap_rb_add(d, eb, MTDSWAP_FAILING); | ||
| 531 | if (weight == maxweight) | ||
| 532 | mtdswap_rb_add(d, eb, MTDSWAP_USED); | ||
| 533 | else if (weight == 0) | ||
| 534 | mtdswap_rb_add(d, eb, MTDSWAP_DIRTY); | ||
| 535 | else if (weight > (maxweight/2)) | ||
| 536 | mtdswap_rb_add(d, eb, MTDSWAP_LOWFRAG); | ||
| 537 | else | ||
| 538 | mtdswap_rb_add(d, eb, MTDSWAP_HIFRAG); | ||
| 539 | } | ||
| 540 | |||
| 541 | |||
| 542 | static void mtdswap_erase_callback(struct erase_info *done) | ||
| 543 | { | ||
| 544 | wait_queue_head_t *wait_q = (wait_queue_head_t *)done->priv; | ||
| 545 | wake_up(wait_q); | ||
| 546 | } | ||
| 547 | |||
| 548 | static int mtdswap_erase_block(struct mtdswap_dev *d, struct swap_eb *eb) | ||
| 549 | { | ||
| 550 | struct mtd_info *mtd = d->mtd; | ||
| 551 | struct erase_info erase; | ||
| 552 | wait_queue_head_t wq; | ||
| 553 | unsigned int retries = 0; | ||
| 554 | int ret; | ||
| 555 | |||
| 556 | eb->erase_count++; | ||
| 557 | if (eb->erase_count > d->max_erase_count) | ||
| 558 | d->max_erase_count = eb->erase_count; | ||
| 559 | |||
| 560 | retry: | ||
| 561 | init_waitqueue_head(&wq); | ||
| 562 | memset(&erase, 0, sizeof(struct erase_info)); | ||
| 563 | |||
| 564 | erase.mtd = mtd; | ||
| 565 | erase.callback = mtdswap_erase_callback; | ||
| 566 | erase.addr = mtdswap_eb_offset(d, eb); | ||
| 567 | erase.len = mtd->erasesize; | ||
| 568 | erase.priv = (u_long)&wq; | ||
| 569 | |||
| 570 | ret = mtd->erase(mtd, &erase); | ||
| 571 | if (ret) { | ||
| 572 | if (retries++ < MTDSWAP_ERASE_RETRIES) { | ||
| 573 | dev_warn(d->dev, | ||
| 574 | "erase of erase block %#llx on %s failed", | ||
| 575 | erase.addr, mtd->name); | ||
| 576 | yield(); | ||
| 577 | goto retry; | ||
| 578 | } | ||
| 579 | |||
| 580 | dev_err(d->dev, "Cannot erase erase block %#llx on %s\n", | ||
| 581 | erase.addr, mtd->name); | ||
| 582 | |||
| 583 | mtdswap_handle_badblock(d, eb); | ||
| 584 | return -EIO; | ||
| 585 | } | ||
| 586 | |||
| 587 | ret = wait_event_interruptible(wq, erase.state == MTD_ERASE_DONE || | ||
| 588 | erase.state == MTD_ERASE_FAILED); | ||
| 589 | if (ret) { | ||
| 590 | dev_err(d->dev, "Interrupted erase block %#llx erassure on %s", | ||
| 591 | erase.addr, mtd->name); | ||
| 592 | return -EINTR; | ||
| 593 | } | ||
| 594 | |||
| 595 | if (erase.state == MTD_ERASE_FAILED) { | ||
| 596 | if (retries++ < MTDSWAP_ERASE_RETRIES) { | ||
| 597 | dev_warn(d->dev, | ||
| 598 | "erase of erase block %#llx on %s failed", | ||
| 599 | erase.addr, mtd->name); | ||
| 600 | yield(); | ||
| 601 | goto retry; | ||
| 602 | } | ||
| 603 | |||
| 604 | mtdswap_handle_badblock(d, eb); | ||
| 605 | return -EIO; | ||
| 606 | } | ||
| 607 | |||
| 608 | return 0; | ||
| 609 | } | ||
| 610 | |||
| 611 | static int mtdswap_map_free_block(struct mtdswap_dev *d, unsigned int page, | ||
| 612 | unsigned int *block) | ||
| 613 | { | ||
| 614 | int ret; | ||
| 615 | struct swap_eb *old_eb = d->curr_write; | ||
| 616 | struct rb_root *clean_root; | ||
| 617 | struct swap_eb *eb; | ||
| 618 | |||
| 619 | if (old_eb == NULL || d->curr_write_pos >= d->pages_per_eblk) { | ||
| 620 | do { | ||
| 621 | if (TREE_EMPTY(d, CLEAN)) | ||
| 622 | return -ENOSPC; | ||
| 623 | |||
| 624 | clean_root = TREE_ROOT(d, CLEAN); | ||
| 625 | eb = rb_entry(rb_first(clean_root), struct swap_eb, rb); | ||
| 626 | rb_erase(&eb->rb, clean_root); | ||
| 627 | eb->root = NULL; | ||
| 628 | TREE_COUNT(d, CLEAN)--; | ||
| 629 | |||
| 630 | ret = mtdswap_write_marker(d, eb, MTDSWAP_TYPE_DIRTY); | ||
| 631 | } while (ret == -EIO || ret == -EBADMSG); | ||
| 632 | |||
| 633 | if (ret) | ||
| 634 | return ret; | ||
| 635 | |||
| 636 | d->curr_write_pos = 0; | ||
| 637 | d->curr_write = eb; | ||
| 638 | if (old_eb) | ||
| 639 | mtdswap_store_eb(d, old_eb); | ||
| 640 | } | ||
| 641 | |||
| 642 | *block = (d->curr_write - d->eb_data) * d->pages_per_eblk + | ||
| 643 | d->curr_write_pos; | ||
| 644 | |||
| 645 | d->curr_write->active_count++; | ||
| 646 | d->revmap[*block] = page; | ||
| 647 | d->curr_write_pos++; | ||
| 648 | |||
| 649 | return 0; | ||
| 650 | } | ||
| 651 | |||
| 652 | static unsigned int mtdswap_free_page_cnt(struct mtdswap_dev *d) | ||
| 653 | { | ||
| 654 | return TREE_COUNT(d, CLEAN) * d->pages_per_eblk + | ||
| 655 | d->pages_per_eblk - d->curr_write_pos; | ||
| 656 | } | ||
| 657 | |||
| 658 | static unsigned int mtdswap_enough_free_pages(struct mtdswap_dev *d) | ||
| 659 | { | ||
| 660 | return mtdswap_free_page_cnt(d) > d->pages_per_eblk; | ||
| 661 | } | ||
| 662 | |||
| 663 | static int mtdswap_write_block(struct mtdswap_dev *d, char *buf, | ||
| 664 | unsigned int page, unsigned int *bp, int gc_context) | ||
| 665 | { | ||
| 666 | struct mtd_info *mtd = d->mtd; | ||
| 667 | struct swap_eb *eb; | ||
| 668 | size_t retlen; | ||
| 669 | loff_t writepos; | ||
| 670 | int ret; | ||
| 671 | |||
| 672 | retry: | ||
| 673 | if (!gc_context) | ||
| 674 | while (!mtdswap_enough_free_pages(d)) | ||
| 675 | if (mtdswap_gc(d, 0) > 0) | ||
| 676 | return -ENOSPC; | ||
| 677 | |||
| 678 | ret = mtdswap_map_free_block(d, page, bp); | ||
| 679 | eb = d->eb_data + (*bp / d->pages_per_eblk); | ||
| 680 | |||
| 681 | if (ret == -EIO || ret == -EBADMSG) { | ||
| 682 | d->curr_write = NULL; | ||
| 683 | eb->active_count--; | ||
| 684 | d->revmap[*bp] = PAGE_UNDEF; | ||
| 685 | goto retry; | ||
| 686 | } | ||
| 687 | |||
| 688 | if (ret < 0) | ||
| 689 | return ret; | ||
| 690 | |||
| 691 | writepos = (loff_t)*bp << PAGE_SHIFT; | ||
| 692 | ret = mtd->write(mtd, writepos, PAGE_SIZE, &retlen, buf); | ||
| 693 | if (ret == -EIO || ret == -EBADMSG) { | ||
| 694 | d->curr_write_pos--; | ||
| 695 | eb->active_count--; | ||
| 696 | d->revmap[*bp] = PAGE_UNDEF; | ||
| 697 | mtdswap_handle_write_error(d, eb); | ||
| 698 | goto retry; | ||
| 699 | } | ||
| 700 | |||
| 701 | if (ret < 0) { | ||
| 702 | dev_err(d->dev, "Write to MTD device failed: %d (%zd written)", | ||
| 703 | ret, retlen); | ||
| 704 | goto err; | ||
| 705 | } | ||
| 706 | |||
| 707 | if (retlen != PAGE_SIZE) { | ||
| 708 | dev_err(d->dev, "Short write to MTD device: %zd written", | ||
| 709 | retlen); | ||
| 710 | ret = -EIO; | ||
| 711 | goto err; | ||
| 712 | } | ||
| 713 | |||
| 714 | return ret; | ||
| 715 | |||
| 716 | err: | ||
| 717 | d->curr_write_pos--; | ||
| 718 | eb->active_count--; | ||
| 719 | d->revmap[*bp] = PAGE_UNDEF; | ||
| 720 | |||
| 721 | return ret; | ||
| 722 | } | ||
| 723 | |||
| 724 | static int mtdswap_move_block(struct mtdswap_dev *d, unsigned int oldblock, | ||
| 725 | unsigned int *newblock) | ||
| 726 | { | ||
| 727 | struct mtd_info *mtd = d->mtd; | ||
| 728 | struct swap_eb *eb, *oldeb; | ||
| 729 | int ret; | ||
| 730 | size_t retlen; | ||
| 731 | unsigned int page, retries; | ||
| 732 | loff_t readpos; | ||
| 733 | |||
| 734 | page = d->revmap[oldblock]; | ||
| 735 | readpos = (loff_t) oldblock << PAGE_SHIFT; | ||
| 736 | retries = 0; | ||
| 737 | |||
| 738 | retry: | ||
| 739 | ret = mtd->read(mtd, readpos, PAGE_SIZE, &retlen, d->page_buf); | ||
| 740 | |||
| 741 | if (ret < 0 && ret != -EUCLEAN) { | ||
| 742 | oldeb = d->eb_data + oldblock / d->pages_per_eblk; | ||
| 743 | oldeb->flags |= EBLOCK_READERR; | ||
| 744 | |||
| 745 | dev_err(d->dev, "Read Error: %d (block %u)\n", ret, | ||
| 746 | oldblock); | ||
| 747 | retries++; | ||
| 748 | if (retries < MTDSWAP_IO_RETRIES) | ||
| 749 | goto retry; | ||
| 750 | |||
| 751 | goto read_error; | ||
| 752 | } | ||
| 753 | |||
| 754 | if (retlen != PAGE_SIZE) { | ||
| 755 | dev_err(d->dev, "Short read: %zd (block %u)\n", retlen, | ||
| 756 | oldblock); | ||
| 757 | ret = -EIO; | ||
| 758 | goto read_error; | ||
| 759 | } | ||
| 760 | |||
| 761 | ret = mtdswap_write_block(d, d->page_buf, page, newblock, 1); | ||
| 762 | if (ret < 0) { | ||
| 763 | d->page_data[page] = BLOCK_ERROR; | ||
| 764 | dev_err(d->dev, "Write error: %d\n", ret); | ||
| 765 | return ret; | ||
| 766 | } | ||
| 767 | |||
| 768 | eb = d->eb_data + *newblock / d->pages_per_eblk; | ||
| 769 | d->page_data[page] = *newblock; | ||
| 770 | d->revmap[oldblock] = PAGE_UNDEF; | ||
| 771 | eb = d->eb_data + oldblock / d->pages_per_eblk; | ||
| 772 | eb->active_count--; | ||
| 773 | |||
| 774 | return 0; | ||
| 775 | |||
| 776 | read_error: | ||
| 777 | d->page_data[page] = BLOCK_ERROR; | ||
| 778 | d->revmap[oldblock] = PAGE_UNDEF; | ||
| 779 | return ret; | ||
| 780 | } | ||
| 781 | |||
| 782 | static int mtdswap_gc_eblock(struct mtdswap_dev *d, struct swap_eb *eb) | ||
| 783 | { | ||
| 784 | unsigned int i, block, eblk_base, newblock; | ||
| 785 | int ret, errcode; | ||
| 786 | |||
| 787 | errcode = 0; | ||
| 788 | eblk_base = (eb - d->eb_data) * d->pages_per_eblk; | ||
| 789 | |||
| 790 | for (i = 0; i < d->pages_per_eblk; i++) { | ||
| 791 | if (d->spare_eblks < MIN_SPARE_EBLOCKS) | ||
| 792 | return -ENOSPC; | ||
| 793 | |||
| 794 | block = eblk_base + i; | ||
| 795 | if (d->revmap[block] == PAGE_UNDEF) | ||
| 796 | continue; | ||
| 797 | |||
| 798 | ret = mtdswap_move_block(d, block, &newblock); | ||
| 799 | if (ret < 0 && !errcode) | ||
| 800 | errcode = ret; | ||
| 801 | } | ||
| 802 | |||
| 803 | return errcode; | ||
| 804 | } | ||
| 805 | |||
| 806 | static int __mtdswap_choose_gc_tree(struct mtdswap_dev *d) | ||
| 807 | { | ||
| 808 | int idx, stopat; | ||
| 809 | |||
| 810 | if (TREE_COUNT(d, CLEAN) < LOW_FRAG_GC_TRESHOLD) | ||
| 811 | stopat = MTDSWAP_LOWFRAG; | ||
| 812 | else | ||
| 813 | stopat = MTDSWAP_HIFRAG; | ||
| 814 | |||
| 815 | for (idx = MTDSWAP_BITFLIP; idx >= stopat; idx--) | ||
| 816 | if (d->trees[idx].root.rb_node != NULL) | ||
| 817 | return idx; | ||
| 818 | |||
| 819 | return -1; | ||
| 820 | } | ||
| 821 | |||
| 822 | static int mtdswap_wlfreq(unsigned int maxdiff) | ||
| 823 | { | ||
| 824 | unsigned int h, x, y, dist, base; | ||
| 825 | |||
| 826 | /* | ||
| 827 | * Calculate linear ramp down from f1 to f2 when maxdiff goes from | ||
| 828 | * MAX_ERASE_DIFF to MAX_ERASE_DIFF + COLLECT_NONDIRTY_BASE. Similar | ||
| 829 | * to triangle with height f1 - f1 and width COLLECT_NONDIRTY_BASE. | ||
| 830 | */ | ||
| 831 | |||
| 832 | dist = maxdiff - MAX_ERASE_DIFF; | ||
| 833 | if (dist > COLLECT_NONDIRTY_BASE) | ||
| 834 | dist = COLLECT_NONDIRTY_BASE; | ||
| 835 | |||
| 836 | /* | ||
| 837 | * Modelling the slop as right angular triangle with base | ||
| 838 | * COLLECT_NONDIRTY_BASE and height freq1 - freq2. The ratio y/x is | ||
| 839 | * equal to the ratio h/base. | ||
| 840 | */ | ||
| 841 | h = COLLECT_NONDIRTY_FREQ1 - COLLECT_NONDIRTY_FREQ2; | ||
| 842 | base = COLLECT_NONDIRTY_BASE; | ||
| 843 | |||
| 844 | x = dist - base; | ||
| 845 | y = (x * h + base / 2) / base; | ||
| 846 | |||
| 847 | return COLLECT_NONDIRTY_FREQ2 + y; | ||
| 848 | } | ||
| 849 | |||
| 850 | static int mtdswap_choose_wl_tree(struct mtdswap_dev *d) | ||
| 851 | { | ||
| 852 | static unsigned int pick_cnt; | ||
| 853 | unsigned int i, idx = -1, wear, max; | ||
| 854 | struct rb_root *root; | ||
| 855 | |||
| 856 | max = 0; | ||
| 857 | for (i = 0; i <= MTDSWAP_DIRTY; i++) { | ||
| 858 | root = &d->trees[i].root; | ||
| 859 | if (root->rb_node == NULL) | ||
| 860 | continue; | ||
| 861 | |||
| 862 | wear = d->max_erase_count - MTDSWAP_ECNT_MIN(root); | ||
| 863 | if (wear > max) { | ||
| 864 | max = wear; | ||
| 865 | idx = i; | ||
| 866 | } | ||
| 867 | } | ||
| 868 | |||
| 869 | if (max > MAX_ERASE_DIFF && pick_cnt >= mtdswap_wlfreq(max) - 1) { | ||
| 870 | pick_cnt = 0; | ||
| 871 | return idx; | ||
| 872 | } | ||
| 873 | |||
| 874 | pick_cnt++; | ||
| 875 | return -1; | ||
| 876 | } | ||
| 877 | |||
| 878 | static int mtdswap_choose_gc_tree(struct mtdswap_dev *d, | ||
| 879 | unsigned int background) | ||
| 880 | { | ||
| 881 | int idx; | ||
| 882 | |||
| 883 | if (TREE_NONEMPTY(d, FAILING) && | ||
| 884 | (background || (TREE_EMPTY(d, CLEAN) && TREE_EMPTY(d, DIRTY)))) | ||
| 885 | return MTDSWAP_FAILING; | ||
| 886 | |||
| 887 | idx = mtdswap_choose_wl_tree(d); | ||
| 888 | if (idx >= MTDSWAP_CLEAN) | ||
| 889 | return idx; | ||
| 890 | |||
| 891 | return __mtdswap_choose_gc_tree(d); | ||
| 892 | } | ||
| 893 | |||
| 894 | static struct swap_eb *mtdswap_pick_gc_eblk(struct mtdswap_dev *d, | ||
| 895 | unsigned int background) | ||
| 896 | { | ||
| 897 | struct rb_root *rp = NULL; | ||
| 898 | struct swap_eb *eb = NULL; | ||
| 899 | int idx; | ||
| 900 | |||
| 901 | if (background && TREE_COUNT(d, CLEAN) > CLEAN_BLOCK_THRESHOLD && | ||
| 902 | TREE_EMPTY(d, DIRTY) && TREE_EMPTY(d, FAILING)) | ||
| 903 | return NULL; | ||
| 904 | |||
| 905 | idx = mtdswap_choose_gc_tree(d, background); | ||
| 906 | if (idx < 0) | ||
| 907 | return NULL; | ||
| 908 | |||
| 909 | rp = &d->trees[idx].root; | ||
| 910 | eb = rb_entry(rb_first(rp), struct swap_eb, rb); | ||
| 911 | |||
| 912 | rb_erase(&eb->rb, rp); | ||
| 913 | eb->root = NULL; | ||
| 914 | d->trees[idx].count--; | ||
| 915 | return eb; | ||
| 916 | } | ||
| 917 | |||
| 918 | static unsigned int mtdswap_test_patt(unsigned int i) | ||
| 919 | { | ||
| 920 | return i % 2 ? 0x55555555 : 0xAAAAAAAA; | ||
| 921 | } | ||
| 922 | |||
| 923 | static unsigned int mtdswap_eblk_passes(struct mtdswap_dev *d, | ||
| 924 | struct swap_eb *eb) | ||
| 925 | { | ||
| 926 | struct mtd_info *mtd = d->mtd; | ||
| 927 | unsigned int test, i, j, patt, mtd_pages; | ||
| 928 | loff_t base, pos; | ||
| 929 | unsigned int *p1 = (unsigned int *)d->page_buf; | ||
| 930 | unsigned char *p2 = (unsigned char *)d->oob_buf; | ||
| 931 | struct mtd_oob_ops ops; | ||
| 932 | int ret; | ||
| 933 | |||
| 934 | ops.mode = MTD_OOB_AUTO; | ||
| 935 | ops.len = mtd->writesize; | ||
| 936 | ops.ooblen = mtd->ecclayout->oobavail; | ||
| 937 | ops.ooboffs = 0; | ||
| 938 | ops.datbuf = d->page_buf; | ||
| 939 | ops.oobbuf = d->oob_buf; | ||
| 940 | base = mtdswap_eb_offset(d, eb); | ||
| 941 | mtd_pages = d->pages_per_eblk * PAGE_SIZE / mtd->writesize; | ||
| 942 | |||
| 943 | for (test = 0; test < 2; test++) { | ||
| 944 | pos = base; | ||
| 945 | for (i = 0; i < mtd_pages; i++) { | ||
| 946 | patt = mtdswap_test_patt(test + i); | ||
| 947 | memset(d->page_buf, patt, mtd->writesize); | ||
| 948 | memset(d->oob_buf, patt, mtd->ecclayout->oobavail); | ||
| 949 | ret = mtd->write_oob(mtd, pos, &ops); | ||
| 950 | if (ret) | ||
| 951 | goto error; | ||
| 952 | |||
| 953 | pos += mtd->writesize; | ||
| 954 | } | ||
| 955 | |||
| 956 | pos = base; | ||
| 957 | for (i = 0; i < mtd_pages; i++) { | ||
| 958 | ret = mtd->read_oob(mtd, pos, &ops); | ||
| 959 | if (ret) | ||
| 960 | goto error; | ||
| 961 | |||
| 962 | patt = mtdswap_test_patt(test + i); | ||
| 963 | for (j = 0; j < mtd->writesize/sizeof(int); j++) | ||
| 964 | if (p1[j] != patt) | ||
| 965 | goto error; | ||
| 966 | |||
| 967 | for (j = 0; j < mtd->ecclayout->oobavail; j++) | ||
| 968 | if (p2[j] != (unsigned char)patt) | ||
| 969 | goto error; | ||
| 970 | |||
| 971 | pos += mtd->writesize; | ||
| 972 | } | ||
| 973 | |||
| 974 | ret = mtdswap_erase_block(d, eb); | ||
| 975 | if (ret) | ||
| 976 | goto error; | ||
| 977 | } | ||
| 978 | |||
| 979 | eb->flags &= ~EBLOCK_READERR; | ||
| 980 | return 1; | ||
| 981 | |||
| 982 | error: | ||
| 983 | mtdswap_handle_badblock(d, eb); | ||
| 984 | return 0; | ||
| 985 | } | ||
| 986 | |||
| 987 | static int mtdswap_gc(struct mtdswap_dev *d, unsigned int background) | ||
| 988 | { | ||
| 989 | struct swap_eb *eb; | ||
| 990 | int ret; | ||
| 991 | |||
| 992 | if (d->spare_eblks < MIN_SPARE_EBLOCKS) | ||
| 993 | return 1; | ||
| 994 | |||
| 995 | eb = mtdswap_pick_gc_eblk(d, background); | ||
| 996 | if (!eb) | ||
| 997 | return 1; | ||
| 998 | |||
| 999 | ret = mtdswap_gc_eblock(d, eb); | ||
| 1000 | if (ret == -ENOSPC) | ||
| 1001 | return 1; | ||
| 1002 | |||
| 1003 | if (eb->flags & EBLOCK_FAILED) { | ||
| 1004 | mtdswap_handle_badblock(d, eb); | ||
| 1005 | return 0; | ||
| 1006 | } | ||
| 1007 | |||
| 1008 | eb->flags &= ~EBLOCK_BITFLIP; | ||
| 1009 | ret = mtdswap_erase_block(d, eb); | ||
| 1010 | if ((eb->flags & EBLOCK_READERR) && | ||
| 1011 | (ret || !mtdswap_eblk_passes(d, eb))) | ||
| 1012 | return 0; | ||
| 1013 | |||
| 1014 | if (ret == 0) | ||
| 1015 | ret = mtdswap_write_marker(d, eb, MTDSWAP_TYPE_CLEAN); | ||
| 1016 | |||
| 1017 | if (ret == 0) | ||
| 1018 | mtdswap_rb_add(d, eb, MTDSWAP_CLEAN); | ||
| 1019 | else if (ret != -EIO && ret != -EBADMSG) | ||
| 1020 | mtdswap_rb_add(d, eb, MTDSWAP_DIRTY); | ||
| 1021 | |||
| 1022 | return 0; | ||
| 1023 | } | ||
| 1024 | |||
| 1025 | static void mtdswap_background(struct mtd_blktrans_dev *dev) | ||
| 1026 | { | ||
| 1027 | struct mtdswap_dev *d = MTDSWAP_MBD_TO_MTDSWAP(dev); | ||
| 1028 | int ret; | ||
| 1029 | |||
| 1030 | while (1) { | ||
| 1031 | ret = mtdswap_gc(d, 1); | ||
| 1032 | if (ret || mtd_blktrans_cease_background(dev)) | ||
| 1033 | return; | ||
| 1034 | } | ||
| 1035 | } | ||
| 1036 | |||
| 1037 | static void mtdswap_cleanup(struct mtdswap_dev *d) | ||
| 1038 | { | ||
| 1039 | vfree(d->eb_data); | ||
| 1040 | vfree(d->revmap); | ||
| 1041 | vfree(d->page_data); | ||
| 1042 | kfree(d->oob_buf); | ||
| 1043 | kfree(d->page_buf); | ||
| 1044 | } | ||
| 1045 | |||
| 1046 | static int mtdswap_flush(struct mtd_blktrans_dev *dev) | ||
| 1047 | { | ||
| 1048 | struct mtdswap_dev *d = MTDSWAP_MBD_TO_MTDSWAP(dev); | ||
| 1049 | |||
| 1050 | if (d->mtd->sync) | ||
| 1051 | d->mtd->sync(d->mtd); | ||
| 1052 | return 0; | ||
| 1053 | } | ||
| 1054 | |||
| 1055 | static unsigned int mtdswap_badblocks(struct mtd_info *mtd, uint64_t size) | ||
| 1056 | { | ||
| 1057 | loff_t offset; | ||
| 1058 | unsigned int badcnt; | ||
| 1059 | |||
| 1060 | badcnt = 0; | ||
| 1061 | |||
| 1062 | if (mtd->block_isbad) | ||
| 1063 | for (offset = 0; offset < size; offset += mtd->erasesize) | ||
| 1064 | if (mtd->block_isbad(mtd, offset)) | ||
| 1065 | badcnt++; | ||
| 1066 | |||
| 1067 | return badcnt; | ||
| 1068 | } | ||
| 1069 | |||
| 1070 | static int mtdswap_writesect(struct mtd_blktrans_dev *dev, | ||
| 1071 | unsigned long page, char *buf) | ||
| 1072 | { | ||
| 1073 | struct mtdswap_dev *d = MTDSWAP_MBD_TO_MTDSWAP(dev); | ||
| 1074 | unsigned int newblock, mapped; | ||
| 1075 | struct swap_eb *eb; | ||
| 1076 | int ret; | ||
| 1077 | |||
| 1078 | d->sect_write_count++; | ||
| 1079 | |||
| 1080 | if (d->spare_eblks < MIN_SPARE_EBLOCKS) | ||
| 1081 | return -ENOSPC; | ||
| 1082 | |||
| 1083 | if (header) { | ||
| 1084 | /* Ignore writes to the header page */ | ||
| 1085 | if (unlikely(page == 0)) | ||
| 1086 | return 0; | ||
| 1087 | |||
| 1088 | page--; | ||
| 1089 | } | ||
| 1090 | |||
| 1091 | mapped = d->page_data[page]; | ||
| 1092 | if (mapped <= BLOCK_MAX) { | ||
| 1093 | eb = d->eb_data + (mapped / d->pages_per_eblk); | ||
| 1094 | eb->active_count--; | ||
| 1095 | mtdswap_store_eb(d, eb); | ||
| 1096 | d->page_data[page] = BLOCK_UNDEF; | ||
| 1097 | d->revmap[mapped] = PAGE_UNDEF; | ||
| 1098 | } | ||
| 1099 | |||
| 1100 | ret = mtdswap_write_block(d, buf, page, &newblock, 0); | ||
| 1101 | d->mtd_write_count++; | ||
| 1102 | |||
| 1103 | if (ret < 0) | ||
| 1104 | return ret; | ||
| 1105 | |||
| 1106 | eb = d->eb_data + (newblock / d->pages_per_eblk); | ||
| 1107 | d->page_data[page] = newblock; | ||
| 1108 | |||
| 1109 | return 0; | ||
| 1110 | } | ||
| 1111 | |||
| 1112 | /* Provide a dummy swap header for the kernel */ | ||
| 1113 | static int mtdswap_auto_header(struct mtdswap_dev *d, char *buf) | ||
| 1114 | { | ||
| 1115 | union swap_header *hd = (union swap_header *)(buf); | ||
| 1116 | |||
| 1117 | memset(buf, 0, PAGE_SIZE - 10); | ||
| 1118 | |||
| 1119 | hd->info.version = 1; | ||
| 1120 | hd->info.last_page = d->mbd_dev->size - 1; | ||
| 1121 | hd->info.nr_badpages = 0; | ||
| 1122 | |||
| 1123 | memcpy(buf + PAGE_SIZE - 10, "SWAPSPACE2", 10); | ||
| 1124 | |||
| 1125 | return 0; | ||
| 1126 | } | ||
| 1127 | |||
| 1128 | static int mtdswap_readsect(struct mtd_blktrans_dev *dev, | ||
| 1129 | unsigned long page, char *buf) | ||
| 1130 | { | ||
| 1131 | struct mtdswap_dev *d = MTDSWAP_MBD_TO_MTDSWAP(dev); | ||
| 1132 | struct mtd_info *mtd = d->mtd; | ||
| 1133 | unsigned int realblock, retries; | ||
| 1134 | loff_t readpos; | ||
| 1135 | struct swap_eb *eb; | ||
| 1136 | size_t retlen; | ||
| 1137 | int ret; | ||
| 1138 | |||
| 1139 | d->sect_read_count++; | ||
| 1140 | |||
| 1141 | if (header) { | ||
| 1142 | if (unlikely(page == 0)) | ||
| 1143 | return mtdswap_auto_header(d, buf); | ||
| 1144 | |||
| 1145 | page--; | ||
| 1146 | } | ||
| 1147 | |||
| 1148 | realblock = d->page_data[page]; | ||
| 1149 | if (realblock > BLOCK_MAX) { | ||
| 1150 | memset(buf, 0x0, PAGE_SIZE); | ||
| 1151 | if (realblock == BLOCK_UNDEF) | ||
| 1152 | return 0; | ||
| 1153 | else | ||
| 1154 | return -EIO; | ||
| 1155 | } | ||
| 1156 | |||
| 1157 | eb = d->eb_data + (realblock / d->pages_per_eblk); | ||
| 1158 | BUG_ON(d->revmap[realblock] == PAGE_UNDEF); | ||
| 1159 | |||
| 1160 | readpos = (loff_t)realblock << PAGE_SHIFT; | ||
| 1161 | retries = 0; | ||
| 1162 | |||
| 1163 | retry: | ||
| 1164 | ret = mtd->read(mtd, readpos, PAGE_SIZE, &retlen, buf); | ||
| 1165 | |||
| 1166 | d->mtd_read_count++; | ||
| 1167 | if (ret == -EUCLEAN) { | ||
| 1168 | eb->flags |= EBLOCK_BITFLIP; | ||
| 1169 | mtdswap_rb_add(d, eb, MTDSWAP_BITFLIP); | ||
| 1170 | ret = 0; | ||
| 1171 | } | ||
| 1172 | |||
| 1173 | if (ret < 0) { | ||
| 1174 | dev_err(d->dev, "Read error %d\n", ret); | ||
| 1175 | eb->flags |= EBLOCK_READERR; | ||
| 1176 | mtdswap_rb_add(d, eb, MTDSWAP_FAILING); | ||
| 1177 | retries++; | ||
| 1178 | if (retries < MTDSWAP_IO_RETRIES) | ||
| 1179 | goto retry; | ||
| 1180 | |||
| 1181 | return ret; | ||
| 1182 | } | ||
| 1183 | |||
| 1184 | if (retlen != PAGE_SIZE) { | ||
| 1185 | dev_err(d->dev, "Short read %zd\n", retlen); | ||
| 1186 | return -EIO; | ||
| 1187 | } | ||
| 1188 | |||
| 1189 | return 0; | ||
| 1190 | } | ||
| 1191 | |||
| 1192 | static int mtdswap_discard(struct mtd_blktrans_dev *dev, unsigned long first, | ||
| 1193 | unsigned nr_pages) | ||
| 1194 | { | ||
| 1195 | struct mtdswap_dev *d = MTDSWAP_MBD_TO_MTDSWAP(dev); | ||
| 1196 | unsigned long page; | ||
| 1197 | struct swap_eb *eb; | ||
| 1198 | unsigned int mapped; | ||
| 1199 | |||
| 1200 | d->discard_count++; | ||
| 1201 | |||
| 1202 | for (page = first; page < first + nr_pages; page++) { | ||
| 1203 | mapped = d->page_data[page]; | ||
| 1204 | if (mapped <= BLOCK_MAX) { | ||
| 1205 | eb = d->eb_data + (mapped / d->pages_per_eblk); | ||
| 1206 | eb->active_count--; | ||
| 1207 | mtdswap_store_eb(d, eb); | ||
| 1208 | d->page_data[page] = BLOCK_UNDEF; | ||
| 1209 | d->revmap[mapped] = PAGE_UNDEF; | ||
| 1210 | d->discard_page_count++; | ||
| 1211 | } else if (mapped == BLOCK_ERROR) { | ||
| 1212 | d->page_data[page] = BLOCK_UNDEF; | ||
| 1213 | d->discard_page_count++; | ||
| 1214 | } | ||
| 1215 | } | ||
| 1216 | |||
| 1217 | return 0; | ||
| 1218 | } | ||
| 1219 | |||
| 1220 | static int mtdswap_show(struct seq_file *s, void *data) | ||
| 1221 | { | ||
| 1222 | struct mtdswap_dev *d = (struct mtdswap_dev *) s->private; | ||
| 1223 | unsigned long sum; | ||
| 1224 | unsigned int count[MTDSWAP_TREE_CNT]; | ||
| 1225 | unsigned int min[MTDSWAP_TREE_CNT]; | ||
| 1226 | unsigned int max[MTDSWAP_TREE_CNT]; | ||
| 1227 | unsigned int i, cw = 0, cwp = 0, cwecount = 0, bb_cnt, mapped, pages; | ||
| 1228 | uint64_t use_size; | ||
| 1229 | char *name[] = {"clean", "used", "low", "high", "dirty", "bitflip", | ||
| 1230 | "failing"}; | ||
| 1231 | |||
| 1232 | mutex_lock(&d->mbd_dev->lock); | ||
| 1233 | |||
| 1234 | for (i = 0; i < MTDSWAP_TREE_CNT; i++) { | ||
| 1235 | struct rb_root *root = &d->trees[i].root; | ||
| 1236 | |||
| 1237 | if (root->rb_node) { | ||
| 1238 | count[i] = d->trees[i].count; | ||
| 1239 | min[i] = rb_entry(rb_first(root), struct swap_eb, | ||
| 1240 | rb)->erase_count; | ||
| 1241 | max[i] = rb_entry(rb_last(root), struct swap_eb, | ||
| 1242 | rb)->erase_count; | ||
| 1243 | } else | ||
| 1244 | count[i] = 0; | ||
| 1245 | } | ||
| 1246 | |||
| 1247 | if (d->curr_write) { | ||
| 1248 | cw = 1; | ||
| 1249 | cwp = d->curr_write_pos; | ||
| 1250 | cwecount = d->curr_write->erase_count; | ||
| 1251 | } | ||
| 1252 | |||
| 1253 | sum = 0; | ||
| 1254 | for (i = 0; i < d->eblks; i++) | ||
| 1255 | sum += d->eb_data[i].erase_count; | ||
| 1256 | |||
| 1257 | use_size = (uint64_t)d->eblks * d->mtd->erasesize; | ||
| 1258 | bb_cnt = mtdswap_badblocks(d->mtd, use_size); | ||
| 1259 | |||
| 1260 | mapped = 0; | ||
| 1261 | pages = d->mbd_dev->size; | ||
| 1262 | for (i = 0; i < pages; i++) | ||
| 1263 | if (d->page_data[i] != BLOCK_UNDEF) | ||
| 1264 | mapped++; | ||
| 1265 | |||
| 1266 | mutex_unlock(&d->mbd_dev->lock); | ||
| 1267 | |||
| 1268 | for (i = 0; i < MTDSWAP_TREE_CNT; i++) { | ||
| 1269 | if (!count[i]) | ||
| 1270 | continue; | ||
| 1271 | |||
| 1272 | if (min[i] != max[i]) | ||
| 1273 | seq_printf(s, "%s:\t%5d erase blocks, erased min %d, " | ||
| 1274 | "max %d times\n", | ||
| 1275 | name[i], count[i], min[i], max[i]); | ||
| 1276 | else | ||
| 1277 | seq_printf(s, "%s:\t%5d erase blocks, all erased %d " | ||
| 1278 | "times\n", name[i], count[i], min[i]); | ||
| 1279 | } | ||
| 1280 | |||
| 1281 | if (bb_cnt) | ||
| 1282 | seq_printf(s, "bad:\t%5u erase blocks\n", bb_cnt); | ||
| 1283 | |||
| 1284 | if (cw) | ||
| 1285 | seq_printf(s, "current erase block: %u pages used, %u free, " | ||
| 1286 | "erased %u times\n", | ||
| 1287 | cwp, d->pages_per_eblk - cwp, cwecount); | ||
| 1288 | |||
| 1289 | seq_printf(s, "total erasures: %lu\n", sum); | ||
| 1290 | |||
| 1291 | seq_printf(s, "\n"); | ||
| 1292 | |||
| 1293 | seq_printf(s, "mtdswap_readsect count: %llu\n", d->sect_read_count); | ||
| 1294 | seq_printf(s, "mtdswap_writesect count: %llu\n", d->sect_write_count); | ||
| 1295 | seq_printf(s, "mtdswap_discard count: %llu\n", d->discard_count); | ||
| 1296 | seq_printf(s, "mtd read count: %llu\n", d->mtd_read_count); | ||
| 1297 | seq_printf(s, "mtd write count: %llu\n", d->mtd_write_count); | ||
| 1298 | seq_printf(s, "discarded pages count: %llu\n", d->discard_page_count); | ||
| 1299 | |||
| 1300 | seq_printf(s, "\n"); | ||
| 1301 | seq_printf(s, "total pages: %u\n", pages); | ||
| 1302 | seq_printf(s, "pages mapped: %u\n", mapped); | ||
| 1303 | |||
| 1304 | return 0; | ||
| 1305 | } | ||
| 1306 | |||
| 1307 | static int mtdswap_open(struct inode *inode, struct file *file) | ||
| 1308 | { | ||
| 1309 | return single_open(file, mtdswap_show, inode->i_private); | ||
| 1310 | } | ||
| 1311 | |||
| 1312 | static const struct file_operations mtdswap_fops = { | ||
| 1313 | .open = mtdswap_open, | ||
| 1314 | .read = seq_read, | ||
| 1315 | .llseek = seq_lseek, | ||
| 1316 | .release = single_release, | ||
| 1317 | }; | ||
| 1318 | |||
| 1319 | static int mtdswap_add_debugfs(struct mtdswap_dev *d) | ||
| 1320 | { | ||
| 1321 | struct gendisk *gd = d->mbd_dev->disk; | ||
| 1322 | struct device *dev = disk_to_dev(gd); | ||
| 1323 | |||
| 1324 | struct dentry *root; | ||
| 1325 | struct dentry *dent; | ||
| 1326 | |||
| 1327 | root = debugfs_create_dir(gd->disk_name, NULL); | ||
| 1328 | if (IS_ERR(root)) | ||
| 1329 | return 0; | ||
| 1330 | |||
| 1331 | if (!root) { | ||
| 1332 | dev_err(dev, "failed to initialize debugfs\n"); | ||
| 1333 | return -1; | ||
| 1334 | } | ||
| 1335 | |||
| 1336 | d->debugfs_root = root; | ||
| 1337 | |||
| 1338 | dent = debugfs_create_file("stats", S_IRUSR, root, d, | ||
| 1339 | &mtdswap_fops); | ||
| 1340 | if (!dent) { | ||
| 1341 | dev_err(d->dev, "debugfs_create_file failed\n"); | ||
| 1342 | debugfs_remove_recursive(root); | ||
| 1343 | d->debugfs_root = NULL; | ||
| 1344 | return -1; | ||
| 1345 | } | ||
| 1346 | |||
| 1347 | return 0; | ||
| 1348 | } | ||
| 1349 | |||
| 1350 | static int mtdswap_init(struct mtdswap_dev *d, unsigned int eblocks, | ||
| 1351 | unsigned int spare_cnt) | ||
| 1352 | { | ||
| 1353 | struct mtd_info *mtd = d->mbd_dev->mtd; | ||
| 1354 | unsigned int i, eblk_bytes, pages, blocks; | ||
| 1355 | int ret = -ENOMEM; | ||
| 1356 | |||
| 1357 | d->mtd = mtd; | ||
| 1358 | d->eblks = eblocks; | ||
| 1359 | d->spare_eblks = spare_cnt; | ||
| 1360 | d->pages_per_eblk = mtd->erasesize >> PAGE_SHIFT; | ||
| 1361 | |||
| 1362 | pages = d->mbd_dev->size; | ||
| 1363 | blocks = eblocks * d->pages_per_eblk; | ||
| 1364 | |||
| 1365 | for (i = 0; i < MTDSWAP_TREE_CNT; i++) | ||
| 1366 | d->trees[i].root = RB_ROOT; | ||
| 1367 | |||
| 1368 | d->page_data = vmalloc(sizeof(int)*pages); | ||
| 1369 | if (!d->page_data) | ||
| 1370 | goto page_data_fail; | ||
| 1371 | |||
| 1372 | d->revmap = vmalloc(sizeof(int)*blocks); | ||
| 1373 | if (!d->revmap) | ||
| 1374 | goto revmap_fail; | ||
| 1375 | |||
| 1376 | eblk_bytes = sizeof(struct swap_eb)*d->eblks; | ||
| 1377 | d->eb_data = vmalloc(eblk_bytes); | ||
| 1378 | if (!d->eb_data) | ||
| 1379 | goto eb_data_fail; | ||
| 1380 | |||
| 1381 | memset(d->eb_data, 0, eblk_bytes); | ||
| 1382 | for (i = 0; i < pages; i++) | ||
| 1383 | d->page_data[i] = BLOCK_UNDEF; | ||
| 1384 | |||
| 1385 | for (i = 0; i < blocks; i++) | ||
| 1386 | d->revmap[i] = PAGE_UNDEF; | ||
| 1387 | |||
| 1388 | d->page_buf = kmalloc(PAGE_SIZE, GFP_KERNEL); | ||
| 1389 | if (!d->page_buf) | ||
| 1390 | goto page_buf_fail; | ||
| 1391 | |||
| 1392 | d->oob_buf = kmalloc(2 * mtd->ecclayout->oobavail, GFP_KERNEL); | ||
| 1393 | if (!d->oob_buf) | ||
| 1394 | goto oob_buf_fail; | ||
| 1395 | |||
| 1396 | mtdswap_scan_eblks(d); | ||
| 1397 | |||
| 1398 | return 0; | ||
| 1399 | |||
| 1400 | oob_buf_fail: | ||
| 1401 | kfree(d->page_buf); | ||
| 1402 | page_buf_fail: | ||
| 1403 | vfree(d->eb_data); | ||
| 1404 | eb_data_fail: | ||
| 1405 | vfree(d->revmap); | ||
| 1406 | revmap_fail: | ||
| 1407 | vfree(d->page_data); | ||
| 1408 | page_data_fail: | ||
| 1409 | printk(KERN_ERR "%s: init failed (%d)\n", MTDSWAP_PREFIX, ret); | ||
| 1410 | return ret; | ||
| 1411 | } | ||
| 1412 | |||
| 1413 | static void mtdswap_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) | ||
| 1414 | { | ||
| 1415 | struct mtdswap_dev *d; | ||
| 1416 | struct mtd_blktrans_dev *mbd_dev; | ||
| 1417 | char *parts; | ||
| 1418 | char *this_opt; | ||
| 1419 | unsigned long part; | ||
| 1420 | unsigned int eblocks, eavailable, bad_blocks, spare_cnt; | ||
| 1421 | uint64_t swap_size, use_size, size_limit; | ||
| 1422 | struct nand_ecclayout *oinfo; | ||
| 1423 | int ret; | ||
| 1424 | |||
| 1425 | parts = &partitions[0]; | ||
| 1426 | if (!*parts) | ||
| 1427 | return; | ||
| 1428 | |||
| 1429 | while ((this_opt = strsep(&parts, ",")) != NULL) { | ||
| 1430 | if (strict_strtoul(this_opt, 0, &part) < 0) | ||
| 1431 | return; | ||
| 1432 | |||
| 1433 | if (mtd->index == part) | ||
| 1434 | break; | ||
| 1435 | } | ||
| 1436 | |||
| 1437 | if (mtd->index != part) | ||
| 1438 | return; | ||
| 1439 | |||
| 1440 | if (mtd->erasesize < PAGE_SIZE || mtd->erasesize % PAGE_SIZE) { | ||
| 1441 | printk(KERN_ERR "%s: Erase size %u not multiple of PAGE_SIZE " | ||
| 1442 | "%lu\n", MTDSWAP_PREFIX, mtd->erasesize, PAGE_SIZE); | ||
| 1443 | return; | ||
| 1444 | } | ||
| 1445 | |||
| 1446 | if (PAGE_SIZE % mtd->writesize || mtd->writesize > PAGE_SIZE) { | ||
| 1447 | printk(KERN_ERR "%s: PAGE_SIZE %lu not multiple of write size" | ||
| 1448 | " %u\n", MTDSWAP_PREFIX, PAGE_SIZE, mtd->writesize); | ||
| 1449 | return; | ||
| 1450 | } | ||
| 1451 | |||
| 1452 | oinfo = mtd->ecclayout; | ||
| 1453 | if (!mtd->oobsize || !oinfo || oinfo->oobavail < MTDSWAP_OOBSIZE) { | ||
| 1454 | printk(KERN_ERR "%s: Not enough free bytes in OOB, " | ||
| 1455 | "%d available, %lu needed.\n", | ||
| 1456 | MTDSWAP_PREFIX, oinfo->oobavail, MTDSWAP_OOBSIZE); | ||
| 1457 | return; | ||
| 1458 | } | ||
| 1459 | |||
| 1460 | if (spare_eblocks > 100) | ||
| 1461 | spare_eblocks = 100; | ||
| 1462 | |||
| 1463 | use_size = mtd->size; | ||
| 1464 | size_limit = (uint64_t) BLOCK_MAX * PAGE_SIZE; | ||
| 1465 | |||
| 1466 | if (mtd->size > size_limit) { | ||
| 1467 | printk(KERN_WARNING "%s: Device too large. Limiting size to " | ||
| 1468 | "%llu bytes\n", MTDSWAP_PREFIX, size_limit); | ||
| 1469 | use_size = size_limit; | ||
| 1470 | } | ||
| 1471 | |||
| 1472 | eblocks = mtd_div_by_eb(use_size, mtd); | ||
| 1473 | use_size = eblocks * mtd->erasesize; | ||
| 1474 | bad_blocks = mtdswap_badblocks(mtd, use_size); | ||
| 1475 | eavailable = eblocks - bad_blocks; | ||
| 1476 | |||
| 1477 | if (eavailable < MIN_ERASE_BLOCKS) { | ||
| 1478 | printk(KERN_ERR "%s: Not enough erase blocks. %u available, " | ||
| 1479 | "%d needed\n", MTDSWAP_PREFIX, eavailable, | ||
| 1480 | MIN_ERASE_BLOCKS); | ||
| 1481 | return; | ||
| 1482 | } | ||
| 1483 | |||
| 1484 | spare_cnt = div_u64((uint64_t)eavailable * spare_eblocks, 100); | ||
| 1485 | |||
| 1486 | if (spare_cnt < MIN_SPARE_EBLOCKS) | ||
| 1487 | spare_cnt = MIN_SPARE_EBLOCKS; | ||
| 1488 | |||
| 1489 | if (spare_cnt > eavailable - 1) | ||
| 1490 | spare_cnt = eavailable - 1; | ||
| 1491 | |||
| 1492 | swap_size = (uint64_t)(eavailable - spare_cnt) * mtd->erasesize + | ||
| 1493 | (header ? PAGE_SIZE : 0); | ||
| 1494 | |||
| 1495 | printk(KERN_INFO "%s: Enabling MTD swap on device %lu, size %llu KB, " | ||
| 1496 | "%u spare, %u bad blocks\n", | ||
| 1497 | MTDSWAP_PREFIX, part, swap_size / 1024, spare_cnt, bad_blocks); | ||
| 1498 | |||
| 1499 | d = kzalloc(sizeof(struct mtdswap_dev), GFP_KERNEL); | ||
| 1500 | if (!d) | ||
| 1501 | return; | ||
| 1502 | |||
| 1503 | mbd_dev = kzalloc(sizeof(struct mtd_blktrans_dev), GFP_KERNEL); | ||
| 1504 | if (!mbd_dev) { | ||
| 1505 | kfree(d); | ||
| 1506 | return; | ||
| 1507 | } | ||
| 1508 | |||
| 1509 | d->mbd_dev = mbd_dev; | ||
| 1510 | mbd_dev->priv = d; | ||
| 1511 | |||
| 1512 | mbd_dev->mtd = mtd; | ||
| 1513 | mbd_dev->devnum = mtd->index; | ||
| 1514 | mbd_dev->size = swap_size >> PAGE_SHIFT; | ||
| 1515 | mbd_dev->tr = tr; | ||
| 1516 | |||
| 1517 | if (!(mtd->flags & MTD_WRITEABLE)) | ||
| 1518 | mbd_dev->readonly = 1; | ||
| 1519 | |||
| 1520 | if (mtdswap_init(d, eblocks, spare_cnt) < 0) | ||
| 1521 | goto init_failed; | ||
| 1522 | |||
| 1523 | if (add_mtd_blktrans_dev(mbd_dev) < 0) | ||
| 1524 | goto cleanup; | ||
| 1525 | |||
| 1526 | d->dev = disk_to_dev(mbd_dev->disk); | ||
| 1527 | |||
| 1528 | ret = mtdswap_add_debugfs(d); | ||
| 1529 | if (ret < 0) | ||
| 1530 | goto debugfs_failed; | ||
| 1531 | |||
| 1532 | return; | ||
| 1533 | |||
| 1534 | debugfs_failed: | ||
| 1535 | del_mtd_blktrans_dev(mbd_dev); | ||
| 1536 | |||
| 1537 | cleanup: | ||
| 1538 | mtdswap_cleanup(d); | ||
| 1539 | |||
| 1540 | init_failed: | ||
| 1541 | kfree(mbd_dev); | ||
| 1542 | kfree(d); | ||
| 1543 | } | ||
| 1544 | |||
| 1545 | static void mtdswap_remove_dev(struct mtd_blktrans_dev *dev) | ||
| 1546 | { | ||
| 1547 | struct mtdswap_dev *d = MTDSWAP_MBD_TO_MTDSWAP(dev); | ||
| 1548 | |||
| 1549 | debugfs_remove_recursive(d->debugfs_root); | ||
| 1550 | del_mtd_blktrans_dev(dev); | ||
| 1551 | mtdswap_cleanup(d); | ||
| 1552 | kfree(d); | ||
| 1553 | } | ||
| 1554 | |||
| 1555 | static struct mtd_blktrans_ops mtdswap_ops = { | ||
| 1556 | .name = "mtdswap", | ||
| 1557 | .major = 0, | ||
| 1558 | .part_bits = 0, | ||
| 1559 | .blksize = PAGE_SIZE, | ||
| 1560 | .flush = mtdswap_flush, | ||
| 1561 | .readsect = mtdswap_readsect, | ||
| 1562 | .writesect = mtdswap_writesect, | ||
| 1563 | .discard = mtdswap_discard, | ||
| 1564 | .background = mtdswap_background, | ||
| 1565 | .add_mtd = mtdswap_add_mtd, | ||
| 1566 | .remove_dev = mtdswap_remove_dev, | ||
| 1567 | .owner = THIS_MODULE, | ||
| 1568 | }; | ||
| 1569 | |||
| 1570 | static int __init mtdswap_modinit(void) | ||
| 1571 | { | ||
| 1572 | return register_mtd_blktrans(&mtdswap_ops); | ||
| 1573 | } | ||
| 1574 | |||
| 1575 | static void __exit mtdswap_modexit(void) | ||
| 1576 | { | ||
| 1577 | deregister_mtd_blktrans(&mtdswap_ops); | ||
| 1578 | } | ||
| 1579 | |||
| 1580 | module_init(mtdswap_modinit); | ||
| 1581 | module_exit(mtdswap_modexit); | ||
| 1582 | |||
| 1583 | |||
| 1584 | MODULE_LICENSE("GPL"); | ||
| 1585 | MODULE_AUTHOR("Jarkko Lavinen <jarkko.lavinen@nokia.com>"); | ||
| 1586 | MODULE_DESCRIPTION("Block device access to an MTD suitable for using as " | ||
| 1587 | "swap space"); | ||
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig index 4f6c06f1632..a92054e945e 100644 --- a/drivers/mtd/nand/Kconfig +++ b/drivers/mtd/nand/Kconfig | |||
| @@ -31,6 +31,21 @@ config MTD_NAND_VERIFY_WRITE | |||
| 31 | device thinks the write was successful, a bit could have been | 31 | device thinks the write was successful, a bit could have been |
| 32 | flipped accidentally due to device wear or something else. | 32 | flipped accidentally due to device wear or something else. |
| 33 | 33 | ||
| 34 | config MTD_NAND_BCH | ||
| 35 | tristate | ||
| 36 | select BCH | ||
| 37 | depends on MTD_NAND_ECC_BCH | ||
| 38 | default MTD_NAND | ||
| 39 | |||
| 40 | config MTD_NAND_ECC_BCH | ||
| 41 | bool "Support software BCH ECC" | ||
| 42 | default n | ||
| 43 | help | ||
| 44 | This enables support for software BCH error correction. Binary BCH | ||
| 45 | codes are more powerful and cpu intensive than traditional Hamming | ||
| 46 | ECC codes. They are used with NAND devices requiring more than 1 bit | ||
| 47 | of error correction. | ||
| 48 | |||
| 34 | config MTD_SM_COMMON | 49 | config MTD_SM_COMMON |
| 35 | tristate | 50 | tristate |
| 36 | default n | 51 | default n |
diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile index 8ad6faec72c..5745d831168 100644 --- a/drivers/mtd/nand/Makefile +++ b/drivers/mtd/nand/Makefile | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | obj-$(CONFIG_MTD_NAND) += nand.o | 5 | obj-$(CONFIG_MTD_NAND) += nand.o |
| 6 | obj-$(CONFIG_MTD_NAND_ECC) += nand_ecc.o | 6 | obj-$(CONFIG_MTD_NAND_ECC) += nand_ecc.o |
| 7 | obj-$(CONFIG_MTD_NAND_BCH) += nand_bch.o | ||
| 7 | obj-$(CONFIG_MTD_NAND_IDS) += nand_ids.o | 8 | obj-$(CONFIG_MTD_NAND_IDS) += nand_ids.o |
| 8 | obj-$(CONFIG_MTD_SM_COMMON) += sm_common.o | 9 | obj-$(CONFIG_MTD_SM_COMMON) += sm_common.o |
| 9 | 10 | ||
diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c index ccce0f03b5d..6fae04b3fc6 100644 --- a/drivers/mtd/nand/atmel_nand.c +++ b/drivers/mtd/nand/atmel_nand.c | |||
| @@ -48,6 +48,9 @@ | |||
| 48 | #define no_ecc 0 | 48 | #define no_ecc 0 |
| 49 | #endif | 49 | #endif |
| 50 | 50 | ||
| 51 | static int use_dma = 1; | ||
| 52 | module_param(use_dma, int, 0); | ||
| 53 | |||
| 51 | static int on_flash_bbt = 0; | 54 | static int on_flash_bbt = 0; |
| 52 | module_param(on_flash_bbt, int, 0); | 55 | module_param(on_flash_bbt, int, 0); |
| 53 | 56 | ||
| @@ -89,11 +92,20 @@ struct atmel_nand_host { | |||
| 89 | struct nand_chip nand_chip; | 92 | struct nand_chip nand_chip; |
| 90 | struct mtd_info mtd; | 93 | struct mtd_info mtd; |
| 91 | void __iomem *io_base; | 94 | void __iomem *io_base; |
| 95 | dma_addr_t io_phys; | ||
| 92 | struct atmel_nand_data *board; | 96 | struct atmel_nand_data *board; |
| 93 | struct device *dev; | 97 | struct device *dev; |
| 94 | void __iomem *ecc; | 98 | void __iomem *ecc; |
| 99 | |||
| 100 | struct completion comp; | ||
| 101 | struct dma_chan *dma_chan; | ||
| 95 | }; | 102 | }; |
| 96 | 103 | ||
| 104 | static int cpu_has_dma(void) | ||
| 105 | { | ||
| 106 | return cpu_is_at91sam9rl() || cpu_is_at91sam9g45(); | ||
| 107 | } | ||
| 108 | |||
| 97 | /* | 109 | /* |
| 98 | * Enable NAND. | 110 | * Enable NAND. |
| 99 | */ | 111 | */ |
| @@ -150,7 +162,7 @@ static int atmel_nand_device_ready(struct mtd_info *mtd) | |||
| 150 | /* | 162 | /* |
| 151 | * Minimal-overhead PIO for data access. | 163 | * Minimal-overhead PIO for data access. |
| 152 | */ | 164 | */ |
| 153 | static void atmel_read_buf(struct mtd_info *mtd, u8 *buf, int len) | 165 | static void atmel_read_buf8(struct mtd_info *mtd, u8 *buf, int len) |
| 154 | { | 166 | { |
| 155 | struct nand_chip *nand_chip = mtd->priv; | 167 | struct nand_chip *nand_chip = mtd->priv; |
| 156 | 168 | ||
| @@ -164,7 +176,7 @@ static void atmel_read_buf16(struct mtd_info *mtd, u8 *buf, int len) | |||
| 164 | __raw_readsw(nand_chip->IO_ADDR_R, buf, len / 2); | 176 | __raw_readsw(nand_chip->IO_ADDR_R, buf, len / 2); |
| 165 | } | 177 | } |
| 166 | 178 | ||
| 167 | static void atmel_write_buf(struct mtd_info *mtd, const u8 *buf, int len) | 179 | static void atmel_write_buf8(struct mtd_info *mtd, const u8 *buf, int len) |
| 168 | { | 180 | { |
| 169 | struct nand_chip *nand_chip = mtd->priv; | 181 | struct nand_chip *nand_chip = mtd->priv; |
| 170 | 182 | ||
| @@ -178,6 +190,121 @@ static void atmel_write_buf16(struct mtd_info *mtd, const u8 *buf, int len) | |||
| 178 | __raw_writesw(nand_chip->IO_ADDR_W, buf, len / 2); | 190 | __raw_writesw(nand_chip->IO_ADDR_W, buf, len / 2); |
| 179 | } | 191 | } |
| 180 | 192 | ||
| 193 | static void dma_complete_func(void *completion) | ||
| 194 | { | ||
| 195 | complete(completion); | ||
| 196 | } | ||
| 197 | |||
| 198 | static int atmel_nand_dma_op(struct mtd_info *mtd, void *buf, int len, | ||
| 199 | int is_read) | ||
| 200 | { | ||
| 201 | struct dma_device *dma_dev; | ||
| 202 | enum dma_ctrl_flags flags; | ||
| 203 | dma_addr_t dma_src_addr, dma_dst_addr, phys_addr; | ||
| 204 | struct dma_async_tx_descriptor *tx = NULL; | ||
| 205 | dma_cookie_t cookie; | ||
| 206 | struct nand_chip *chip = mtd->priv; | ||
| 207 | struct atmel_nand_host *host = chip->priv; | ||
| 208 | void *p = buf; | ||
| 209 | int err = -EIO; | ||
| 210 | enum dma_data_direction dir = is_read ? DMA_FROM_DEVICE : DMA_TO_DEVICE; | ||
| 211 | |||
| 212 | if (buf >= high_memory) { | ||
| 213 | struct page *pg; | ||
| 214 | |||
| 215 | if (((size_t)buf & PAGE_MASK) != | ||
| 216 | ((size_t)(buf + len - 1) & PAGE_MASK)) { | ||
| 217 | dev_warn(host->dev, "Buffer not fit in one page\n"); | ||
| 218 | goto err_buf; | ||
| 219 | } | ||
| 220 | |||
| 221 | pg = vmalloc_to_page(buf); | ||
| 222 | if (pg == 0) { | ||
| 223 | dev_err(host->dev, "Failed to vmalloc_to_page\n"); | ||
| 224 | goto err_buf; | ||
| 225 | } | ||
| 226 | p = page_address(pg) + ((size_t)buf & ~PAGE_MASK); | ||
| 227 | } | ||
| 228 | |||
| 229 | dma_dev = host->dma_chan->device; | ||
| 230 | |||
| 231 | flags = DMA_CTRL_ACK | DMA_PREP_INTERRUPT | DMA_COMPL_SKIP_SRC_UNMAP | | ||
| 232 | DMA_COMPL_SKIP_DEST_UNMAP; | ||
| 233 | |||
| 234 | phys_addr = dma_map_single(dma_dev->dev, p, len, dir); | ||
| 235 | if (dma_mapping_error(dma_dev->dev, phys_addr)) { | ||
| 236 | dev_err(host->dev, "Failed to dma_map_single\n"); | ||
| 237 | goto err_buf; | ||
| 238 | } | ||
| 239 | |||
| 240 | if (is_read) { | ||
| 241 | dma_src_addr = host->io_phys; | ||
| 242 | dma_dst_addr = phys_addr; | ||
| 243 | } else { | ||
| 244 | dma_src_addr = phys_addr; | ||
| 245 | dma_dst_addr = host->io_phys; | ||
| 246 | } | ||
| 247 | |||
| 248 | tx = dma_dev->device_prep_dma_memcpy(host->dma_chan, dma_dst_addr, | ||
| 249 | dma_src_addr, len, flags); | ||
| 250 | if (!tx) { | ||
| 251 | dev_err(host->dev, "Failed to prepare DMA memcpy\n"); | ||
| 252 | goto err_dma; | ||
| 253 | } | ||
| 254 | |||
| 255 | init_completion(&host->comp); | ||
| 256 | tx->callback = dma_complete_func; | ||
| 257 | tx->callback_param = &host->comp; | ||
| 258 | |||
| 259 | cookie = tx->tx_submit(tx); | ||
| 260 | if (dma_submit_error(cookie)) { | ||
| 261 | dev_err(host->dev, "Failed to do DMA tx_submit\n"); | ||
| 262 | goto err_dma; | ||
| 263 | } | ||
| 264 | |||
| 265 | dma_async_issue_pending(host->dma_chan); | ||
| 266 | wait_for_completion(&host->comp); | ||
| 267 | |||
| 268 | err = 0; | ||
| 269 | |||
| 270 | err_dma: | ||
| 271 | dma_unmap_single(dma_dev->dev, phys_addr, len, dir); | ||
| 272 | err_buf: | ||
| 273 | if (err != 0) | ||
| 274 | dev_warn(host->dev, "Fall back to CPU I/O\n"); | ||
| 275 | return err; | ||
| 276 | } | ||
| 277 | |||
| 278 | static void atmel_read_buf(struct mtd_info *mtd, u8 *buf, int len) | ||
| 279 | { | ||
| 280 | struct nand_chip *chip = mtd->priv; | ||
| 281 | struct atmel_nand_host *host = chip->priv; | ||
| 282 | |||
| 283 | if (use_dma && len >= mtd->oobsize) | ||
| 284 | if (atmel_nand_dma_op(mtd, buf, len, 1) == 0) | ||
| 285 | return; | ||
| 286 | |||
| 287 | if (host->board->bus_width_16) | ||
| 288 | atmel_read_buf16(mtd, buf, len); | ||
| 289 | else | ||
| 290 | atmel_read_buf8(mtd, buf, len); | ||
| 291 | } | ||
| 292 | |||
| 293 | static void atmel_write_buf(struct mtd_info *mtd, const u8 *buf, int len) | ||
| 294 | { | ||
| 295 | struct nand_chip *chip = mtd->priv; | ||
| 296 | struct atmel_nand_host *host = chip->priv; | ||
| 297 | |||
| 298 | if (use_dma && len >= mtd->oobsize) | ||
| 299 | if (atmel_nand_dma_op(mtd, (void *)buf, len, 0) == 0) | ||
| 300 | return; | ||
| 301 | |||
| 302 | if (host->board->bus_width_16) | ||
| 303 | atmel_write_buf16(mtd, buf, len); | ||
| 304 | else | ||
| 305 | atmel_write_buf8(mtd, buf, len); | ||
| 306 | } | ||
| 307 | |||
| 181 | /* | 308 | /* |
| 182 | * Calculate HW ECC | 309 | * Calculate HW ECC |
| 183 | * | 310 | * |
| @@ -398,6 +525,8 @@ static int __init atmel_nand_probe(struct platform_device *pdev) | |||
| 398 | return -ENOMEM; | 525 | return -ENOMEM; |
| 399 | } | 526 | } |
| 400 | 527 | ||
| 528 | host->io_phys = (dma_addr_t)mem->start; | ||
| 529 | |||
| 401 | host->io_base = ioremap(mem->start, mem->end - mem->start + 1); | 530 | host->io_base = ioremap(mem->start, mem->end - mem->start + 1); |
| 402 | if (host->io_base == NULL) { | 531 | if (host->io_base == NULL) { |
| 403 | printk(KERN_ERR "atmel_nand: ioremap failed\n"); | 532 | printk(KERN_ERR "atmel_nand: ioremap failed\n"); |
| @@ -448,14 +577,11 @@ static int __init atmel_nand_probe(struct platform_device *pdev) | |||
| 448 | 577 | ||
| 449 | nand_chip->chip_delay = 20; /* 20us command delay time */ | 578 | nand_chip->chip_delay = 20; /* 20us command delay time */ |
| 450 | 579 | ||
| 451 | if (host->board->bus_width_16) { /* 16-bit bus width */ | 580 | if (host->board->bus_width_16) /* 16-bit bus width */ |
| 452 | nand_chip->options |= NAND_BUSWIDTH_16; | 581 | nand_chip->options |= NAND_BUSWIDTH_16; |
| 453 | nand_chip->read_buf = atmel_read_buf16; | 582 | |
| 454 | nand_chip->write_buf = atmel_write_buf16; | 583 | nand_chip->read_buf = atmel_read_buf; |
| 455 | } else { | 584 | nand_chip->write_buf = atmel_write_buf; |
| 456 | nand_chip->read_buf = atmel_read_buf; | ||
| 457 | nand_chip->write_buf = atmel_write_buf; | ||
| 458 | } | ||
| 459 | 585 | ||
| 460 | platform_set_drvdata(pdev, host); | 586 | platform_set_drvdata(pdev, host); |
| 461 | atmel_nand_enable(host); | 587 | atmel_nand_enable(host); |
| @@ -473,6 +599,22 @@ static int __init atmel_nand_probe(struct platform_device *pdev) | |||
| 473 | nand_chip->options |= NAND_USE_FLASH_BBT; | 599 | nand_chip->options |= NAND_USE_FLASH_BBT; |
| 474 | } | 600 | } |
| 475 | 601 | ||
| 602 | if (cpu_has_dma() && use_dma) { | ||
| 603 | dma_cap_mask_t mask; | ||
| 604 | |||
| 605 | dma_cap_zero(mask); | ||
| 606 | dma_cap_set(DMA_MEMCPY, mask); | ||
| 607 | host->dma_chan = dma_request_channel(mask, 0, NULL); | ||
| 608 | if (!host->dma_chan) { | ||
| 609 | dev_err(host->dev, "Failed to request DMA channel\n"); | ||
| 610 | use_dma = 0; | ||
| 611 | } | ||
| 612 | } | ||
| 613 | if (use_dma) | ||
| 614 | dev_info(host->dev, "Using DMA for NAND access.\n"); | ||
| 615 | else | ||
| 616 | dev_info(host->dev, "No DMA support for NAND access.\n"); | ||
| 617 | |||
| 476 | /* first scan to find the device and get the page size */ | 618 | /* first scan to find the device and get the page size */ |
| 477 | if (nand_scan_ident(mtd, 1, NULL)) { | 619 | if (nand_scan_ident(mtd, 1, NULL)) { |
| 478 | res = -ENXIO; | 620 | res = -ENXIO; |
| @@ -555,6 +697,8 @@ err_scan_ident: | |||
| 555 | err_no_card: | 697 | err_no_card: |
| 556 | atmel_nand_disable(host); | 698 | atmel_nand_disable(host); |
| 557 | platform_set_drvdata(pdev, NULL); | 699 | platform_set_drvdata(pdev, NULL); |
| 700 | if (host->dma_chan) | ||
| 701 | dma_release_channel(host->dma_chan); | ||
| 558 | if (host->ecc) | 702 | if (host->ecc) |
| 559 | iounmap(host->ecc); | 703 | iounmap(host->ecc); |
| 560 | err_ecc_ioremap: | 704 | err_ecc_ioremap: |
| @@ -578,6 +722,10 @@ static int __exit atmel_nand_remove(struct platform_device *pdev) | |||
| 578 | 722 | ||
| 579 | if (host->ecc) | 723 | if (host->ecc) |
| 580 | iounmap(host->ecc); | 724 | iounmap(host->ecc); |
| 725 | |||
| 726 | if (host->dma_chan) | ||
| 727 | dma_release_channel(host->dma_chan); | ||
| 728 | |||
| 581 | iounmap(host->io_base); | 729 | iounmap(host->io_base); |
| 582 | kfree(host); | 730 | kfree(host); |
| 583 | 731 | ||
diff --git a/drivers/mtd/nand/davinci_nand.c b/drivers/mtd/nand/davinci_nand.c index a90fde3ede2..aff3468867a 100644 --- a/drivers/mtd/nand/davinci_nand.c +++ b/drivers/mtd/nand/davinci_nand.c | |||
| @@ -37,9 +37,6 @@ | |||
| 37 | #include <mach/nand.h> | 37 | #include <mach/nand.h> |
| 38 | #include <mach/aemif.h> | 38 | #include <mach/aemif.h> |
| 39 | 39 | ||
| 40 | #include <asm/mach-types.h> | ||
| 41 | |||
| 42 | |||
| 43 | /* | 40 | /* |
| 44 | * This is a device driver for the NAND flash controller found on the | 41 | * This is a device driver for the NAND flash controller found on the |
| 45 | * various DaVinci family chips. It handles up to four SoC chipselects, | 42 | * various DaVinci family chips. It handles up to four SoC chipselects, |
diff --git a/drivers/mtd/nand/mpc5121_nfc.c b/drivers/mtd/nand/mpc5121_nfc.c index c2f95437e5e..0b81b5b499d 100644 --- a/drivers/mtd/nand/mpc5121_nfc.c +++ b/drivers/mtd/nand/mpc5121_nfc.c | |||
| @@ -29,6 +29,7 @@ | |||
| 29 | #include <linux/clk.h> | 29 | #include <linux/clk.h> |
| 30 | #include <linux/gfp.h> | 30 | #include <linux/gfp.h> |
| 31 | #include <linux/delay.h> | 31 | #include <linux/delay.h> |
| 32 | #include <linux/err.h> | ||
| 32 | #include <linux/init.h> | 33 | #include <linux/init.h> |
| 33 | #include <linux/interrupt.h> | 34 | #include <linux/interrupt.h> |
| 34 | #include <linux/io.h> | 35 | #include <linux/io.h> |
| @@ -757,9 +758,9 @@ static int __devinit mpc5121_nfc_probe(struct platform_device *op) | |||
| 757 | 758 | ||
| 758 | /* Enable NFC clock */ | 759 | /* Enable NFC clock */ |
| 759 | prv->clk = clk_get(dev, "nfc_clk"); | 760 | prv->clk = clk_get(dev, "nfc_clk"); |
| 760 | if (!prv->clk) { | 761 | if (IS_ERR(prv->clk)) { |
| 761 | dev_err(dev, "Unable to acquire NFC clock!\n"); | 762 | dev_err(dev, "Unable to acquire NFC clock!\n"); |
| 762 | retval = -ENODEV; | 763 | retval = PTR_ERR(prv->clk); |
| 763 | goto error; | 764 | goto error; |
| 764 | } | 765 | } |
| 765 | 766 | ||
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c index 5ae1d9ee2cf..42a95fb4150 100644 --- a/drivers/mtd/nand/mxc_nand.c +++ b/drivers/mtd/nand/mxc_nand.c | |||
| @@ -211,6 +211,31 @@ static struct nand_ecclayout nandv2_hw_eccoob_largepage = { | |||
| 211 | } | 211 | } |
| 212 | }; | 212 | }; |
| 213 | 213 | ||
| 214 | /* OOB description for 4096 byte pages with 128 byte OOB */ | ||
| 215 | static struct nand_ecclayout nandv2_hw_eccoob_4k = { | ||
| 216 | .eccbytes = 8 * 9, | ||
| 217 | .eccpos = { | ||
| 218 | 7, 8, 9, 10, 11, 12, 13, 14, 15, | ||
| 219 | 23, 24, 25, 26, 27, 28, 29, 30, 31, | ||
| 220 | 39, 40, 41, 42, 43, 44, 45, 46, 47, | ||
| 221 | 55, 56, 57, 58, 59, 60, 61, 62, 63, | ||
| 222 | 71, 72, 73, 74, 75, 76, 77, 78, 79, | ||
| 223 | 87, 88, 89, 90, 91, 92, 93, 94, 95, | ||
| 224 | 103, 104, 105, 106, 107, 108, 109, 110, 111, | ||
| 225 | 119, 120, 121, 122, 123, 124, 125, 126, 127, | ||
| 226 | }, | ||
| 227 | .oobfree = { | ||
| 228 | {.offset = 2, .length = 4}, | ||
| 229 | {.offset = 16, .length = 7}, | ||
| 230 | {.offset = 32, .length = 7}, | ||
| 231 | {.offset = 48, .length = 7}, | ||
| 232 | {.offset = 64, .length = 7}, | ||
| 233 | {.offset = 80, .length = 7}, | ||
| 234 | {.offset = 96, .length = 7}, | ||
| 235 | {.offset = 112, .length = 7}, | ||
| 236 | } | ||
| 237 | }; | ||
| 238 | |||
| 214 | #ifdef CONFIG_MTD_PARTITIONS | 239 | #ifdef CONFIG_MTD_PARTITIONS |
| 215 | static const char *part_probes[] = { "RedBoot", "cmdlinepart", NULL }; | 240 | static const char *part_probes[] = { "RedBoot", "cmdlinepart", NULL }; |
| 216 | #endif | 241 | #endif |
| @@ -641,9 +666,9 @@ static void mxc_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len) | |||
| 641 | 666 | ||
| 642 | n = min(n, len); | 667 | n = min(n, len); |
| 643 | 668 | ||
| 644 | memcpy(buf, host->data_buf + col, len); | 669 | memcpy(buf, host->data_buf + col, n); |
| 645 | 670 | ||
| 646 | host->buf_start += len; | 671 | host->buf_start += n; |
| 647 | } | 672 | } |
| 648 | 673 | ||
| 649 | /* Used by the upper layer to verify the data in NAND Flash | 674 | /* Used by the upper layer to verify the data in NAND Flash |
| @@ -1185,6 +1210,8 @@ static int __init mxcnd_probe(struct platform_device *pdev) | |||
| 1185 | 1210 | ||
| 1186 | if (mtd->writesize == 2048) | 1211 | if (mtd->writesize == 2048) |
| 1187 | this->ecc.layout = oob_largepage; | 1212 | this->ecc.layout = oob_largepage; |
| 1213 | if (nfc_is_v21() && mtd->writesize == 4096) | ||
| 1214 | this->ecc.layout = &nandv2_hw_eccoob_4k; | ||
| 1188 | 1215 | ||
| 1189 | /* second phase scan */ | 1216 | /* second phase scan */ |
| 1190 | if (nand_scan_tail(mtd)) { | 1217 | if (nand_scan_tail(mtd)) { |
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index a9c6ce74576..85cfc061d41 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c | |||
| @@ -42,6 +42,7 @@ | |||
| 42 | #include <linux/mtd/mtd.h> | 42 | #include <linux/mtd/mtd.h> |
| 43 | #include <linux/mtd/nand.h> | 43 | #include <linux/mtd/nand.h> |
| 44 | #include <linux/mtd/nand_ecc.h> | 44 | #include <linux/mtd/nand_ecc.h> |
| 45 | #include <linux/mtd/nand_bch.h> | ||
| 45 | #include <linux/interrupt.h> | 46 | #include <linux/interrupt.h> |
| 46 | #include <linux/bitops.h> | 47 | #include <linux/bitops.h> |
| 47 | #include <linux/leds.h> | 48 | #include <linux/leds.h> |
| @@ -2377,7 +2378,7 @@ static int nand_do_write_oob(struct mtd_info *mtd, loff_t to, | |||
| 2377 | return -EINVAL; | 2378 | return -EINVAL; |
| 2378 | } | 2379 | } |
| 2379 | 2380 | ||
| 2380 | /* Do not allow reads past end of device */ | 2381 | /* Do not allow write past end of device */ |
| 2381 | if (unlikely(to >= mtd->size || | 2382 | if (unlikely(to >= mtd->size || |
| 2382 | ops->ooboffs + ops->ooblen > | 2383 | ops->ooboffs + ops->ooblen > |
| 2383 | ((mtd->size >> chip->page_shift) - | 2384 | ((mtd->size >> chip->page_shift) - |
| @@ -3248,7 +3249,7 @@ int nand_scan_tail(struct mtd_info *mtd) | |||
| 3248 | /* | 3249 | /* |
| 3249 | * If no default placement scheme is given, select an appropriate one | 3250 | * If no default placement scheme is given, select an appropriate one |
| 3250 | */ | 3251 | */ |
| 3251 | if (!chip->ecc.layout) { | 3252 | if (!chip->ecc.layout && (chip->ecc.mode != NAND_ECC_SOFT_BCH)) { |
| 3252 | switch (mtd->oobsize) { | 3253 | switch (mtd->oobsize) { |
| 3253 | case 8: | 3254 | case 8: |
| 3254 | chip->ecc.layout = &nand_oob_8; | 3255 | chip->ecc.layout = &nand_oob_8; |
| @@ -3351,6 +3352,40 @@ int nand_scan_tail(struct mtd_info *mtd) | |||
| 3351 | chip->ecc.bytes = 3; | 3352 | chip->ecc.bytes = 3; |
| 3352 | break; | 3353 | break; |
| 3353 | 3354 | ||
| 3355 | case NAND_ECC_SOFT_BCH: | ||
| 3356 | if (!mtd_nand_has_bch()) { | ||
| 3357 | printk(KERN_WARNING "CONFIG_MTD_ECC_BCH not enabled\n"); | ||
| 3358 | BUG(); | ||
| 3359 | } | ||
| 3360 | chip->ecc.calculate = nand_bch_calculate_ecc; | ||
| 3361 | chip->ecc.correct = nand_bch_correct_data; | ||
| 3362 | chip->ecc.read_page = nand_read_page_swecc; | ||
| 3363 | chip->ecc.read_subpage = nand_read_subpage; | ||
| 3364 | chip->ecc.write_page = nand_write_page_swecc; | ||
| 3365 | chip->ecc.read_page_raw = nand_read_page_raw; | ||
| 3366 | chip->ecc.write_page_raw = nand_write_page_raw; | ||
| 3367 | chip->ecc.read_oob = nand_read_oob_std; | ||
| 3368 | chip->ecc.write_oob = nand_write_oob_std; | ||
| 3369 | /* | ||
| 3370 | * Board driver should supply ecc.size and ecc.bytes values to | ||
| 3371 | * select how many bits are correctable; see nand_bch_init() | ||
| 3372 | * for details. | ||
| 3373 | * Otherwise, default to 4 bits for large page devices | ||
| 3374 | */ | ||
| 3375 | if (!chip->ecc.size && (mtd->oobsize >= 64)) { | ||
| 3376 | chip->ecc.size = 512; | ||
| 3377 | chip->ecc.bytes = 7; | ||
| 3378 | } | ||
| 3379 | chip->ecc.priv = nand_bch_init(mtd, | ||
| 3380 | chip->ecc.size, | ||
| 3381 | chip->ecc.bytes, | ||
| 3382 | &chip->ecc.layout); | ||
| 3383 | if (!chip->ecc.priv) { | ||
| 3384 | printk(KERN_WARNING "BCH ECC initialization failed!\n"); | ||
| 3385 | BUG(); | ||
| 3386 | } | ||
| 3387 | break; | ||
| 3388 | |||
| 3354 | case NAND_ECC_NONE: | 3389 | case NAND_ECC_NONE: |
| 3355 | printk(KERN_WARNING "NAND_ECC_NONE selected by board driver. " | 3390 | printk(KERN_WARNING "NAND_ECC_NONE selected by board driver. " |
| 3356 | "This is not recommended !!\n"); | 3391 | "This is not recommended !!\n"); |
| @@ -3501,6 +3536,9 @@ void nand_release(struct mtd_info *mtd) | |||
| 3501 | { | 3536 | { |
| 3502 | struct nand_chip *chip = mtd->priv; | 3537 | struct nand_chip *chip = mtd->priv; |
| 3503 | 3538 | ||
| 3539 | if (chip->ecc.mode == NAND_ECC_SOFT_BCH) | ||
| 3540 | nand_bch_free((struct nand_bch_control *)chip->ecc.priv); | ||
| 3541 | |||
| 3504 | #ifdef CONFIG_MTD_PARTITIONS | 3542 | #ifdef CONFIG_MTD_PARTITIONS |
| 3505 | /* Deregister partitions */ | 3543 | /* Deregister partitions */ |
| 3506 | del_mtd_partitions(mtd); | 3544 | del_mtd_partitions(mtd); |
diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c index 6ebd869993a..a1e8b30078d 100644 --- a/drivers/mtd/nand/nand_bbt.c +++ b/drivers/mtd/nand/nand_bbt.c | |||
| @@ -1101,12 +1101,16 @@ static void mark_bbt_region(struct mtd_info *mtd, struct nand_bbt_descr *td) | |||
| 1101 | static void verify_bbt_descr(struct mtd_info *mtd, struct nand_bbt_descr *bd) | 1101 | static void verify_bbt_descr(struct mtd_info *mtd, struct nand_bbt_descr *bd) |
| 1102 | { | 1102 | { |
| 1103 | struct nand_chip *this = mtd->priv; | 1103 | struct nand_chip *this = mtd->priv; |
| 1104 | u32 pattern_len = bd->len; | 1104 | u32 pattern_len; |
| 1105 | u32 bits = bd->options & NAND_BBT_NRBITS_MSK; | 1105 | u32 bits; |
| 1106 | u32 table_size; | 1106 | u32 table_size; |
| 1107 | 1107 | ||
| 1108 | if (!bd) | 1108 | if (!bd) |
| 1109 | return; | 1109 | return; |
| 1110 | |||
| 1111 | pattern_len = bd->len; | ||
| 1112 | bits = bd->options & NAND_BBT_NRBITS_MSK; | ||
| 1113 | |||
| 1110 | BUG_ON((this->options & NAND_USE_FLASH_BBT_NO_OOB) && | 1114 | BUG_ON((this->options & NAND_USE_FLASH_BBT_NO_OOB) && |
| 1111 | !(this->options & NAND_USE_FLASH_BBT)); | 1115 | !(this->options & NAND_USE_FLASH_BBT)); |
| 1112 | BUG_ON(!bits); | 1116 | BUG_ON(!bits); |
diff --git a/drivers/mtd/nand/nand_bch.c b/drivers/mtd/nand/nand_bch.c new file mode 100644 index 00000000000..0f931e75711 --- /dev/null +++ b/drivers/mtd/nand/nand_bch.c | |||
| @@ -0,0 +1,243 @@ | |||
| 1 | /* | ||
| 2 | * This file provides ECC correction for more than 1 bit per block of data, | ||
| 3 | * using binary BCH codes. It relies on the generic BCH library lib/bch.c. | ||
| 4 | * | ||
| 5 | * Copyright © 2011 Ivan Djelic <ivan.djelic@parrot.com> | ||
| 6 | * | ||
| 7 | * This file is free software; you can redistribute it and/or modify it | ||
| 8 | * under the terms of the GNU General Public License as published by the | ||
| 9 | * Free Software Foundation; either version 2 or (at your option) any | ||
| 10 | * later version. | ||
| 11 | * | ||
| 12 | * This file is distributed in the hope that it will be useful, but WITHOUT | ||
| 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
| 15 | * for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License along | ||
| 18 | * with this file; if not, write to the Free Software Foundation, Inc., | ||
| 19 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include <linux/types.h> | ||
| 23 | #include <linux/kernel.h> | ||
| 24 | #include <linux/module.h> | ||
| 25 | #include <linux/slab.h> | ||
| 26 | #include <linux/bitops.h> | ||
| 27 | #include <linux/mtd/mtd.h> | ||
| 28 | #include <linux/mtd/nand.h> | ||
| 29 | #include <linux/mtd/nand_bch.h> | ||
| 30 | #include <linux/bch.h> | ||
| 31 | |||
| 32 | /** | ||
| 33 | * struct nand_bch_control - private NAND BCH control structure | ||
| 34 | * @bch: BCH control structure | ||
| 35 | * @ecclayout: private ecc layout for this BCH configuration | ||
| 36 | * @errloc: error location array | ||
| 37 | * @eccmask: XOR ecc mask, allows erased pages to be decoded as valid | ||
| 38 | */ | ||
| 39 | struct nand_bch_control { | ||
| 40 | struct bch_control *bch; | ||
| 41 | struct nand_ecclayout ecclayout; | ||
| 42 | unsigned int *errloc; | ||
| 43 | unsigned char *eccmask; | ||
| 44 | }; | ||
| 45 | |||
| 46 | /** | ||
| 47 | * nand_bch_calculate_ecc - [NAND Interface] Calculate ECC for data block | ||
| 48 | * @mtd: MTD block structure | ||
| 49 | * @buf: input buffer with raw data | ||
| 50 | * @code: output buffer with ECC | ||
| 51 | */ | ||
| 52 | int nand_bch_calculate_ecc(struct mtd_info *mtd, const unsigned char *buf, | ||
| 53 | unsigned char *code) | ||
| 54 | { | ||
| 55 | const struct nand_chip *chip = mtd->priv; | ||
| 56 | struct nand_bch_control *nbc = chip->ecc.priv; | ||
| 57 | unsigned int i; | ||
| 58 | |||
| 59 | memset(code, 0, chip->ecc.bytes); | ||
| 60 | encode_bch(nbc->bch, buf, chip->ecc.size, code); | ||
| 61 | |||
| 62 | /* apply mask so that an erased page is a valid codeword */ | ||
| 63 | for (i = 0; i < chip->ecc.bytes; i++) | ||
| 64 | code[i] ^= nbc->eccmask[i]; | ||
| 65 | |||
| 66 | return 0; | ||
| 67 | } | ||
| 68 | EXPORT_SYMBOL(nand_bch_calculate_ecc); | ||
| 69 | |||
| 70 | /** | ||
| 71 | * nand_bch_correct_data - [NAND Interface] Detect and correct bit error(s) | ||
| 72 | * @mtd: MTD block structure | ||
| 73 | * @buf: raw data read from the chip | ||
| 74 | * @read_ecc: ECC from the chip | ||
| 75 | * @calc_ecc: the ECC calculated from raw data | ||
| 76 | * | ||
| 77 | * Detect and correct bit errors for a data byte block | ||
| 78 | */ | ||
| 79 | int nand_bch_correct_data(struct mtd_info *mtd, unsigned char *buf, | ||
| 80 | unsigned char *read_ecc, unsigned char *calc_ecc) | ||
| 81 | { | ||
| 82 | const struct nand_chip *chip = mtd->priv; | ||
| 83 | struct nand_bch_control *nbc = chip->ecc.priv; | ||
| 84 | unsigned int *errloc = nbc->errloc; | ||
| 85 | int i, count; | ||
| 86 | |||
| 87 | count = decode_bch(nbc->bch, NULL, chip->ecc.size, read_ecc, calc_ecc, | ||
| 88 | NULL, errloc); | ||
| 89 | if (count > 0) { | ||
| 90 | for (i = 0; i < count; i++) { | ||
| 91 | if (errloc[i] < (chip->ecc.size*8)) | ||
| 92 | /* error is located in data, correct it */ | ||
| 93 | buf[errloc[i] >> 3] ^= (1 << (errloc[i] & 7)); | ||
| 94 | /* else error in ecc, no action needed */ | ||
| 95 | |||
| 96 | DEBUG(MTD_DEBUG_LEVEL0, "%s: corrected bitflip %u\n", | ||
| 97 | __func__, errloc[i]); | ||
| 98 | } | ||
| 99 | } else if (count < 0) { | ||
| 100 | printk(KERN_ERR "ecc unrecoverable error\n"); | ||
| 101 | count = -1; | ||
| 102 | } | ||
| 103 | return count; | ||
| 104 | } | ||
| 105 | EXPORT_SYMBOL(nand_bch_correct_data); | ||
| 106 | |||
| 107 | /** | ||
| 108 | * nand_bch_init - [NAND Interface] Initialize NAND BCH error correction | ||
| 109 | * @mtd: MTD block structure | ||
| 110 | * @eccsize: ecc block size in bytes | ||
| 111 | * @eccbytes: ecc length in bytes | ||
| 112 | * @ecclayout: output default layout | ||
| 113 | * | ||
| 114 | * Returns: | ||
| 115 | * a pointer to a new NAND BCH control structure, or NULL upon failure | ||
| 116 | * | ||
| 117 | * Initialize NAND BCH error correction. Parameters @eccsize and @eccbytes | ||
| 118 | * are used to compute BCH parameters m (Galois field order) and t (error | ||
| 119 | * correction capability). @eccbytes should be equal to the number of bytes | ||
| 120 | * required to store m*t bits, where m is such that 2^m-1 > @eccsize*8. | ||
| 121 | * | ||
| 122 | * Example: to configure 4 bit correction per 512 bytes, you should pass | ||
| 123 | * @eccsize = 512 (thus, m=13 is the smallest integer such that 2^m-1 > 512*8) | ||
| 124 | * @eccbytes = 7 (7 bytes are required to store m*t = 13*4 = 52 bits) | ||
| 125 | */ | ||
| 126 | struct nand_bch_control * | ||
| 127 | nand_bch_init(struct mtd_info *mtd, unsigned int eccsize, unsigned int eccbytes, | ||
| 128 | struct nand_ecclayout **ecclayout) | ||
| 129 | { | ||
| 130 | unsigned int m, t, eccsteps, i; | ||
| 131 | struct nand_ecclayout *layout; | ||
| 132 | struct nand_bch_control *nbc = NULL; | ||
| 133 | unsigned char *erased_page; | ||
| 134 | |||
| 135 | if (!eccsize || !eccbytes) { | ||
| 136 | printk(KERN_WARNING "ecc parameters not supplied\n"); | ||
| 137 | goto fail; | ||
| 138 | } | ||
| 139 | |||
| 140 | m = fls(1+8*eccsize); | ||
| 141 | t = (eccbytes*8)/m; | ||
| 142 | |||
| 143 | nbc = kzalloc(sizeof(*nbc), GFP_KERNEL); | ||
| 144 | if (!nbc) | ||
| 145 | goto fail; | ||
| 146 | |||
| 147 | nbc->bch = init_bch(m, t, 0); | ||
| 148 | if (!nbc->bch) | ||
| 149 | goto fail; | ||
| 150 | |||
| 151 | /* verify that eccbytes has the expected value */ | ||
| 152 | if (nbc->bch->ecc_bytes != eccbytes) { | ||
| 153 | printk(KERN_WARNING "invalid eccbytes %u, should be %u\n", | ||
| 154 | eccbytes, nbc->bch->ecc_bytes); | ||
| 155 | goto fail; | ||
| 156 | } | ||
| 157 | |||
| 158 | eccsteps = mtd->writesize/eccsize; | ||
| 159 | |||
| 160 | /* if no ecc placement scheme was provided, build one */ | ||
| 161 | if (!*ecclayout) { | ||
| 162 | |||
| 163 | /* handle large page devices only */ | ||
| 164 | if (mtd->oobsize < 64) { | ||
| 165 | printk(KERN_WARNING "must provide an oob scheme for " | ||
| 166 | "oobsize %d\n", mtd->oobsize); | ||
| 167 | goto fail; | ||
| 168 | } | ||
| 169 | |||
| 170 | layout = &nbc->ecclayout; | ||
| 171 | layout->eccbytes = eccsteps*eccbytes; | ||
| 172 | |||
| 173 | /* reserve 2 bytes for bad block marker */ | ||
| 174 | if (layout->eccbytes+2 > mtd->oobsize) { | ||
| 175 | printk(KERN_WARNING "no suitable oob scheme available " | ||
| 176 | "for oobsize %d eccbytes %u\n", mtd->oobsize, | ||
| 177 | eccbytes); | ||
| 178 | goto fail; | ||
| 179 | } | ||
| 180 | /* put ecc bytes at oob tail */ | ||
| 181 | for (i = 0; i < layout->eccbytes; i++) | ||
| 182 | layout->eccpos[i] = mtd->oobsize-layout->eccbytes+i; | ||
| 183 | |||
| 184 | layout->oobfree[0].offset = 2; | ||
| 185 | layout->oobfree[0].length = mtd->oobsize-2-layout->eccbytes; | ||
| 186 | |||
| 187 | *ecclayout = layout; | ||
| 188 | } | ||
| 189 | |||
| 190 | /* sanity checks */ | ||
| 191 | if (8*(eccsize+eccbytes) >= (1 << m)) { | ||
| 192 | printk(KERN_WARNING "eccsize %u is too large\n", eccsize); | ||
| 193 | goto fail; | ||
| 194 | } | ||
| 195 | if ((*ecclayout)->eccbytes != (eccsteps*eccbytes)) { | ||
| 196 | printk(KERN_WARNING "invalid ecc layout\n"); | ||
| 197 | goto fail; | ||
| 198 | } | ||
| 199 | |||
| 200 | nbc->eccmask = kmalloc(eccbytes, GFP_KERNEL); | ||
| 201 | nbc->errloc = kmalloc(t*sizeof(*nbc->errloc), GFP_KERNEL); | ||
| 202 | if (!nbc->eccmask || !nbc->errloc) | ||
| 203 | goto fail; | ||
| 204 | /* | ||
| 205 | * compute and store the inverted ecc of an erased ecc block | ||
| 206 | */ | ||
| 207 | erased_page = kmalloc(eccsize, GFP_KERNEL); | ||
| 208 | if (!erased_page) | ||
| 209 | goto fail; | ||
| 210 | |||
| 211 | memset(erased_page, 0xff, eccsize); | ||
| 212 | memset(nbc->eccmask, 0, eccbytes); | ||
| 213 | encode_bch(nbc->bch, erased_page, eccsize, nbc->eccmask); | ||
| 214 | kfree(erased_page); | ||
| 215 | |||
| 216 | for (i = 0; i < eccbytes; i++) | ||
| 217 | nbc->eccmask[i] ^= 0xff; | ||
| 218 | |||
| 219 | return nbc; | ||
| 220 | fail: | ||
| 221 | nand_bch_free(nbc); | ||
| 222 | return NULL; | ||
| 223 | } | ||
| 224 | EXPORT_SYMBOL(nand_bch_init); | ||
| 225 | |||
| 226 | /** | ||
| 227 | * nand_bch_free - [NAND Interface] Release NAND BCH ECC resources | ||
| 228 | * @nbc: NAND BCH control structure | ||
| 229 | */ | ||
| 230 | void nand_bch_free(struct nand_bch_control *nbc) | ||
| 231 | { | ||
| 232 | if (nbc) { | ||
| 233 | free_bch(nbc->bch); | ||
| 234 | kfree(nbc->errloc); | ||
| 235 | kfree(nbc->eccmask); | ||
| 236 | kfree(nbc); | ||
| 237 | } | ||
| 238 | } | ||
| 239 | EXPORT_SYMBOL(nand_bch_free); | ||
| 240 | |||
| 241 | MODULE_LICENSE("GPL"); | ||
| 242 | MODULE_AUTHOR("Ivan Djelic <ivan.djelic@parrot.com>"); | ||
| 243 | MODULE_DESCRIPTION("NAND software BCH ECC support"); | ||
diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c index a5aa99f014b..213181be0d9 100644 --- a/drivers/mtd/nand/nandsim.c +++ b/drivers/mtd/nand/nandsim.c | |||
| @@ -34,6 +34,7 @@ | |||
| 34 | #include <linux/string.h> | 34 | #include <linux/string.h> |
| 35 | #include <linux/mtd/mtd.h> | 35 | #include <linux/mtd/mtd.h> |
| 36 | #include <linux/mtd/nand.h> | 36 | #include <linux/mtd/nand.h> |
| 37 | #include <linux/mtd/nand_bch.h> | ||
| 37 | #include <linux/mtd/partitions.h> | 38 | #include <linux/mtd/partitions.h> |
| 38 | #include <linux/delay.h> | 39 | #include <linux/delay.h> |
| 39 | #include <linux/list.h> | 40 | #include <linux/list.h> |
| @@ -108,6 +109,7 @@ static unsigned int rptwear = 0; | |||
| 108 | static unsigned int overridesize = 0; | 109 | static unsigned int overridesize = 0; |
| 109 | static char *cache_file = NULL; | 110 | static char *cache_file = NULL; |
| 110 | static unsigned int bbt; | 111 | static unsigned int bbt; |
| 112 | static unsigned int bch; | ||
| 111 | 113 | ||
| 112 | module_param(first_id_byte, uint, 0400); | 114 | module_param(first_id_byte, uint, 0400); |
| 113 | module_param(second_id_byte, uint, 0400); | 115 | module_param(second_id_byte, uint, 0400); |
| @@ -132,6 +134,7 @@ module_param(rptwear, uint, 0400); | |||
| 132 | module_param(overridesize, uint, 0400); | 134 | module_param(overridesize, uint, 0400); |
| 133 | module_param(cache_file, charp, 0400); | 135 | module_param(cache_file, charp, 0400); |
| 134 | module_param(bbt, uint, 0400); | 136 | module_param(bbt, uint, 0400); |
| 137 | module_param(bch, uint, 0400); | ||
| 135 | 138 | ||
| 136 | MODULE_PARM_DESC(first_id_byte, "The first byte returned by NAND Flash 'read ID' command (manufacturer ID)"); | 139 | MODULE_PARM_DESC(first_id_byte, "The first byte returned by NAND Flash 'read ID' command (manufacturer ID)"); |
| 137 | MODULE_PARM_DESC(second_id_byte, "The second byte returned by NAND Flash 'read ID' command (chip ID)"); | 140 | MODULE_PARM_DESC(second_id_byte, "The second byte returned by NAND Flash 'read ID' command (chip ID)"); |
| @@ -165,6 +168,8 @@ MODULE_PARM_DESC(overridesize, "Specifies the NAND Flash size overriding the I | |||
| 165 | " e.g. 5 means a size of 32 erase blocks"); | 168 | " e.g. 5 means a size of 32 erase blocks"); |
| 166 | MODULE_PARM_DESC(cache_file, "File to use to cache nand pages instead of memory"); | 169 | MODULE_PARM_DESC(cache_file, "File to use to cache nand pages instead of memory"); |
| 167 | MODULE_PARM_DESC(bbt, "0 OOB, 1 BBT with marker in OOB, 2 BBT with marker in data area"); | 170 | MODULE_PARM_DESC(bbt, "0 OOB, 1 BBT with marker in OOB, 2 BBT with marker in data area"); |
| 171 | MODULE_PARM_DESC(bch, "Enable BCH ecc and set how many bits should " | ||
| 172 | "be correctable in 512-byte blocks"); | ||
| 168 | 173 | ||
| 169 | /* The largest possible page size */ | 174 | /* The largest possible page size */ |
| 170 | #define NS_LARGEST_PAGE_SIZE 4096 | 175 | #define NS_LARGEST_PAGE_SIZE 4096 |
| @@ -2309,7 +2314,43 @@ static int __init ns_init_module(void) | |||
| 2309 | if ((retval = parse_gravepages()) != 0) | 2314 | if ((retval = parse_gravepages()) != 0) |
| 2310 | goto error; | 2315 | goto error; |
| 2311 | 2316 | ||
| 2312 | if ((retval = nand_scan(nsmtd, 1)) != 0) { | 2317 | retval = nand_scan_ident(nsmtd, 1, NULL); |
| 2318 | if (retval) { | ||
| 2319 | NS_ERR("cannot scan NAND Simulator device\n"); | ||
| 2320 | if (retval > 0) | ||
| 2321 | retval = -ENXIO; | ||
| 2322 | goto error; | ||
| 2323 | } | ||
| 2324 | |||
| 2325 | if (bch) { | ||
| 2326 | unsigned int eccsteps, eccbytes; | ||
| 2327 | if (!mtd_nand_has_bch()) { | ||
| 2328 | NS_ERR("BCH ECC support is disabled\n"); | ||
| 2329 | retval = -EINVAL; | ||
| 2330 | goto error; | ||
| 2331 | } | ||
| 2332 | /* use 512-byte ecc blocks */ | ||
| 2333 | eccsteps = nsmtd->writesize/512; | ||
| 2334 | eccbytes = (bch*13+7)/8; | ||
| 2335 | /* do not bother supporting small page devices */ | ||
| 2336 | if ((nsmtd->oobsize < 64) || !eccsteps) { | ||
| 2337 | NS_ERR("bch not available on small page devices\n"); | ||
| 2338 | retval = -EINVAL; | ||
| 2339 | goto error; | ||
| 2340 | } | ||
| 2341 | if ((eccbytes*eccsteps+2) > nsmtd->oobsize) { | ||
| 2342 | NS_ERR("invalid bch value %u\n", bch); | ||
| 2343 | retval = -EINVAL; | ||
| 2344 | goto error; | ||
| 2345 | } | ||
| 2346 | chip->ecc.mode = NAND_ECC_SOFT_BCH; | ||
| 2347 | chip->ecc.size = 512; | ||
| 2348 | chip->ecc.bytes = eccbytes; | ||
| 2349 | NS_INFO("using %u-bit/%u bytes BCH ECC\n", bch, chip->ecc.size); | ||
| 2350 | } | ||
| 2351 | |||
| 2352 | retval = nand_scan_tail(nsmtd); | ||
| 2353 | if (retval) { | ||
| 2313 | NS_ERR("can't register NAND Simulator\n"); | 2354 | NS_ERR("can't register NAND Simulator\n"); |
| 2314 | if (retval > 0) | 2355 | if (retval > 0) |
| 2315 | retval = -ENXIO; | 2356 | retval = -ENXIO; |
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c index 7b8f1fffc52..da9a351c9d7 100644 --- a/drivers/mtd/nand/omap2.c +++ b/drivers/mtd/nand/omap2.c | |||
| @@ -668,6 +668,8 @@ static void gen_true_ecc(u8 *ecc_buf) | |||
| 668 | * | 668 | * |
| 669 | * This function compares two ECC's and indicates if there is an error. | 669 | * This function compares two ECC's and indicates if there is an error. |
| 670 | * If the error can be corrected it will be corrected to the buffer. | 670 | * If the error can be corrected it will be corrected to the buffer. |
| 671 | * If there is no error, %0 is returned. If there is an error but it | ||
| 672 | * was corrected, %1 is returned. Otherwise, %-1 is returned. | ||
| 671 | */ | 673 | */ |
| 672 | static int omap_compare_ecc(u8 *ecc_data1, /* read from NAND memory */ | 674 | static int omap_compare_ecc(u8 *ecc_data1, /* read from NAND memory */ |
| 673 | u8 *ecc_data2, /* read from register */ | 675 | u8 *ecc_data2, /* read from register */ |
| @@ -773,7 +775,7 @@ static int omap_compare_ecc(u8 *ecc_data1, /* read from NAND memory */ | |||
| 773 | 775 | ||
| 774 | page_data[find_byte] ^= (1 << find_bit); | 776 | page_data[find_byte] ^= (1 << find_bit); |
| 775 | 777 | ||
| 776 | return 0; | 778 | return 1; |
| 777 | default: | 779 | default: |
| 778 | if (isEccFF) { | 780 | if (isEccFF) { |
| 779 | if (ecc_data2[0] == 0 && | 781 | if (ecc_data2[0] == 0 && |
| @@ -794,8 +796,11 @@ static int omap_compare_ecc(u8 *ecc_data1, /* read from NAND memory */ | |||
| 794 | * @calc_ecc: ecc read from HW ECC registers | 796 | * @calc_ecc: ecc read from HW ECC registers |
| 795 | * | 797 | * |
| 796 | * Compares the ecc read from nand spare area with ECC registers values | 798 | * Compares the ecc read from nand spare area with ECC registers values |
| 797 | * and if ECC's mismached, it will call 'omap_compare_ecc' for error detection | 799 | * and if ECC's mismatched, it will call 'omap_compare_ecc' for error |
| 798 | * and correction. | 800 | * detection and correction. If there are no errors, %0 is returned. If |
| 801 | * there were errors and all of the errors were corrected, the number of | ||
| 802 | * corrected errors is returned. If uncorrectable errors exist, %-1 is | ||
| 803 | * returned. | ||
| 799 | */ | 804 | */ |
| 800 | static int omap_correct_data(struct mtd_info *mtd, u_char *dat, | 805 | static int omap_correct_data(struct mtd_info *mtd, u_char *dat, |
| 801 | u_char *read_ecc, u_char *calc_ecc) | 806 | u_char *read_ecc, u_char *calc_ecc) |
| @@ -803,6 +808,7 @@ static int omap_correct_data(struct mtd_info *mtd, u_char *dat, | |||
| 803 | struct omap_nand_info *info = container_of(mtd, struct omap_nand_info, | 808 | struct omap_nand_info *info = container_of(mtd, struct omap_nand_info, |
| 804 | mtd); | 809 | mtd); |
| 805 | int blockCnt = 0, i = 0, ret = 0; | 810 | int blockCnt = 0, i = 0, ret = 0; |
| 811 | int stat = 0; | ||
| 806 | 812 | ||
| 807 | /* Ex NAND_ECC_HW12_2048 */ | 813 | /* Ex NAND_ECC_HW12_2048 */ |
| 808 | if ((info->nand.ecc.mode == NAND_ECC_HW) && | 814 | if ((info->nand.ecc.mode == NAND_ECC_HW) && |
| @@ -816,12 +822,14 @@ static int omap_correct_data(struct mtd_info *mtd, u_char *dat, | |||
| 816 | ret = omap_compare_ecc(read_ecc, calc_ecc, dat); | 822 | ret = omap_compare_ecc(read_ecc, calc_ecc, dat); |
| 817 | if (ret < 0) | 823 | if (ret < 0) |
| 818 | return ret; | 824 | return ret; |
| 825 | /* keep track of the number of corrected errors */ | ||
| 826 | stat += ret; | ||
| 819 | } | 827 | } |
| 820 | read_ecc += 3; | 828 | read_ecc += 3; |
| 821 | calc_ecc += 3; | 829 | calc_ecc += 3; |
| 822 | dat += 512; | 830 | dat += 512; |
| 823 | } | 831 | } |
| 824 | return 0; | 832 | return stat; |
| 825 | } | 833 | } |
| 826 | 834 | ||
| 827 | /** | 835 | /** |
diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c index ea2c288df3f..ab7f4c33ced 100644 --- a/drivers/mtd/nand/pxa3xx_nand.c +++ b/drivers/mtd/nand/pxa3xx_nand.c | |||
| @@ -27,6 +27,8 @@ | |||
| 27 | #include <plat/pxa3xx_nand.h> | 27 | #include <plat/pxa3xx_nand.h> |
| 28 | 28 | ||
| 29 | #define CHIP_DELAY_TIMEOUT (2 * HZ/10) | 29 | #define CHIP_DELAY_TIMEOUT (2 * HZ/10) |
| 30 | #define NAND_STOP_DELAY (2 * HZ/50) | ||
| 31 | #define PAGE_CHUNK_SIZE (2048) | ||
| 30 | 32 | ||
| 31 | /* registers and bit definitions */ | 33 | /* registers and bit definitions */ |
| 32 | #define NDCR (0x00) /* Control register */ | 34 | #define NDCR (0x00) /* Control register */ |
| @@ -52,16 +54,18 @@ | |||
| 52 | #define NDCR_ND_MODE (0x3 << 21) | 54 | #define NDCR_ND_MODE (0x3 << 21) |
| 53 | #define NDCR_NAND_MODE (0x0) | 55 | #define NDCR_NAND_MODE (0x0) |
| 54 | #define NDCR_CLR_PG_CNT (0x1 << 20) | 56 | #define NDCR_CLR_PG_CNT (0x1 << 20) |
| 55 | #define NDCR_CLR_ECC (0x1 << 19) | 57 | #define NDCR_STOP_ON_UNCOR (0x1 << 19) |
| 56 | #define NDCR_RD_ID_CNT_MASK (0x7 << 16) | 58 | #define NDCR_RD_ID_CNT_MASK (0x7 << 16) |
| 57 | #define NDCR_RD_ID_CNT(x) (((x) << 16) & NDCR_RD_ID_CNT_MASK) | 59 | #define NDCR_RD_ID_CNT(x) (((x) << 16) & NDCR_RD_ID_CNT_MASK) |
| 58 | 60 | ||
| 59 | #define NDCR_RA_START (0x1 << 15) | 61 | #define NDCR_RA_START (0x1 << 15) |
| 60 | #define NDCR_PG_PER_BLK (0x1 << 14) | 62 | #define NDCR_PG_PER_BLK (0x1 << 14) |
| 61 | #define NDCR_ND_ARB_EN (0x1 << 12) | 63 | #define NDCR_ND_ARB_EN (0x1 << 12) |
| 64 | #define NDCR_INT_MASK (0xFFF) | ||
| 62 | 65 | ||
| 63 | #define NDSR_MASK (0xfff) | 66 | #define NDSR_MASK (0xfff) |
| 64 | #define NDSR_RDY (0x1 << 11) | 67 | #define NDSR_RDY (0x1 << 12) |
| 68 | #define NDSR_FLASH_RDY (0x1 << 11) | ||
| 65 | #define NDSR_CS0_PAGED (0x1 << 10) | 69 | #define NDSR_CS0_PAGED (0x1 << 10) |
| 66 | #define NDSR_CS1_PAGED (0x1 << 9) | 70 | #define NDSR_CS1_PAGED (0x1 << 9) |
| 67 | #define NDSR_CS0_CMDD (0x1 << 8) | 71 | #define NDSR_CS0_CMDD (0x1 << 8) |
| @@ -74,6 +78,7 @@ | |||
| 74 | #define NDSR_RDDREQ (0x1 << 1) | 78 | #define NDSR_RDDREQ (0x1 << 1) |
| 75 | #define NDSR_WRCMDREQ (0x1) | 79 | #define NDSR_WRCMDREQ (0x1) |
| 76 | 80 | ||
| 81 | #define NDCB0_ST_ROW_EN (0x1 << 26) | ||
| 77 | #define NDCB0_AUTO_RS (0x1 << 25) | 82 | #define NDCB0_AUTO_RS (0x1 << 25) |
| 78 | #define NDCB0_CSEL (0x1 << 24) | 83 | #define NDCB0_CSEL (0x1 << 24) |
| 79 | #define NDCB0_CMD_TYPE_MASK (0x7 << 21) | 84 | #define NDCB0_CMD_TYPE_MASK (0x7 << 21) |
| @@ -104,18 +109,21 @@ enum { | |||
| 104 | }; | 109 | }; |
| 105 | 110 | ||
| 106 | enum { | 111 | enum { |
| 107 | STATE_READY = 0, | 112 | STATE_IDLE = 0, |
| 108 | STATE_CMD_HANDLE, | 113 | STATE_CMD_HANDLE, |
| 109 | STATE_DMA_READING, | 114 | STATE_DMA_READING, |
| 110 | STATE_DMA_WRITING, | 115 | STATE_DMA_WRITING, |
| 111 | STATE_DMA_DONE, | 116 | STATE_DMA_DONE, |
| 112 | STATE_PIO_READING, | 117 | STATE_PIO_READING, |
| 113 | STATE_PIO_WRITING, | 118 | STATE_PIO_WRITING, |
| 119 | STATE_CMD_DONE, | ||
| 120 | STATE_READY, | ||
| 114 | }; | 121 | }; |
| 115 | 122 | ||
| 116 | struct pxa3xx_nand_info { | 123 | struct pxa3xx_nand_info { |
| 117 | struct nand_chip nand_chip; | 124 | struct nand_chip nand_chip; |
| 118 | 125 | ||
| 126 | struct nand_hw_control controller; | ||
| 119 | struct platform_device *pdev; | 127 | struct platform_device *pdev; |
| 120 | struct pxa3xx_nand_cmdset *cmdset; | 128 | struct pxa3xx_nand_cmdset *cmdset; |
| 121 | 129 | ||
| @@ -126,6 +134,7 @@ struct pxa3xx_nand_info { | |||
| 126 | unsigned int buf_start; | 134 | unsigned int buf_start; |
| 127 | unsigned int buf_count; | 135 | unsigned int buf_count; |
| 128 | 136 | ||
| 137 | struct mtd_info *mtd; | ||
| 129 | /* DMA information */ | 138 | /* DMA information */ |
| 130 | int drcmr_dat; | 139 | int drcmr_dat; |
| 131 | int drcmr_cmd; | 140 | int drcmr_cmd; |
| @@ -149,6 +158,7 @@ struct pxa3xx_nand_info { | |||
| 149 | 158 | ||
| 150 | int use_ecc; /* use HW ECC ? */ | 159 | int use_ecc; /* use HW ECC ? */ |
| 151 | int use_dma; /* use DMA ? */ | 160 | int use_dma; /* use DMA ? */ |
| 161 | int is_ready; | ||
| 152 | 162 | ||
| 153 | unsigned int page_size; /* page size of attached chip */ | 163 | unsigned int page_size; /* page size of attached chip */ |
| 154 | unsigned int data_size; /* data size in FIFO */ | 164 | unsigned int data_size; /* data size in FIFO */ |
| @@ -201,20 +211,22 @@ static struct pxa3xx_nand_timing timing[] = { | |||
| 201 | }; | 211 | }; |
| 202 | 212 | ||
| 203 | static struct pxa3xx_nand_flash builtin_flash_types[] = { | 213 | static struct pxa3xx_nand_flash builtin_flash_types[] = { |
| 204 | { 0, 0, 2048, 8, 8, 0, &default_cmdset, &timing[0] }, | 214 | { "DEFAULT FLASH", 0, 0, 2048, 8, 8, 0, &timing[0] }, |
| 205 | { 0x46ec, 32, 512, 16, 16, 4096, &default_cmdset, &timing[1] }, | 215 | { "64MiB 16-bit", 0x46ec, 32, 512, 16, 16, 4096, &timing[1] }, |
| 206 | { 0xdaec, 64, 2048, 8, 8, 2048, &default_cmdset, &timing[1] }, | 216 | { "256MiB 8-bit", 0xdaec, 64, 2048, 8, 8, 2048, &timing[1] }, |
| 207 | { 0xd7ec, 128, 4096, 8, 8, 8192, &default_cmdset, &timing[1] }, | 217 | { "4GiB 8-bit", 0xd7ec, 128, 4096, 8, 8, 8192, &timing[1] }, |
| 208 | { 0xa12c, 64, 2048, 8, 8, 1024, &default_cmdset, &timing[2] }, | 218 | { "128MiB 8-bit", 0xa12c, 64, 2048, 8, 8, 1024, &timing[2] }, |
| 209 | { 0xb12c, 64, 2048, 16, 16, 1024, &default_cmdset, &timing[2] }, | 219 | { "128MiB 16-bit", 0xb12c, 64, 2048, 16, 16, 1024, &timing[2] }, |
| 210 | { 0xdc2c, 64, 2048, 8, 8, 4096, &default_cmdset, &timing[2] }, | 220 | { "512MiB 8-bit", 0xdc2c, 64, 2048, 8, 8, 4096, &timing[2] }, |
| 211 | { 0xcc2c, 64, 2048, 16, 16, 4096, &default_cmdset, &timing[2] }, | 221 | { "512MiB 16-bit", 0xcc2c, 64, 2048, 16, 16, 4096, &timing[2] }, |
| 212 | { 0xba20, 64, 2048, 16, 16, 2048, &default_cmdset, &timing[3] }, | 222 | { "256MiB 16-bit", 0xba20, 64, 2048, 16, 16, 2048, &timing[3] }, |
| 213 | }; | 223 | }; |
| 214 | 224 | ||
| 215 | /* Define a default flash type setting serve as flash detecting only */ | 225 | /* Define a default flash type setting serve as flash detecting only */ |
| 216 | #define DEFAULT_FLASH_TYPE (&builtin_flash_types[0]) | 226 | #define DEFAULT_FLASH_TYPE (&builtin_flash_types[0]) |
| 217 | 227 | ||
| 228 | const char *mtd_names[] = {"pxa3xx_nand-0", NULL}; | ||
| 229 | |||
| 218 | #define NDTR0_tCH(c) (min((c), 7) << 19) | 230 | #define NDTR0_tCH(c) (min((c), 7) << 19) |
| 219 | #define NDTR0_tCS(c) (min((c), 7) << 16) | 231 | #define NDTR0_tCS(c) (min((c), 7) << 16) |
| 220 | #define NDTR0_tWH(c) (min((c), 7) << 11) | 232 | #define NDTR0_tWH(c) (min((c), 7) << 11) |
| @@ -252,25 +264,6 @@ static void pxa3xx_nand_set_timing(struct pxa3xx_nand_info *info, | |||
| 252 | nand_writel(info, NDTR1CS0, ndtr1); | 264 | nand_writel(info, NDTR1CS0, ndtr1); |
| 253 | } | 265 | } |
| 254 | 266 | ||
| 255 | #define WAIT_EVENT_TIMEOUT 10 | ||
| 256 | |||
| 257 | static int wait_for_event(struct pxa3xx_nand_info *info, uint32_t event) | ||
| 258 | { | ||
| 259 | int timeout = WAIT_EVENT_TIMEOUT; | ||
| 260 | uint32_t ndsr; | ||
| 261 | |||
| 262 | while (timeout--) { | ||
| 263 | ndsr = nand_readl(info, NDSR) & NDSR_MASK; | ||
| 264 | if (ndsr & event) { | ||
| 265 | nand_writel(info, NDSR, ndsr); | ||
| 266 | return 0; | ||
| 267 | } | ||
| 268 | udelay(10); | ||
| 269 | } | ||
| 270 | |||
| 271 | return -ETIMEDOUT; | ||
| 272 | } | ||
| 273 | |||
| 274 | static void pxa3xx_set_datasize(struct pxa3xx_nand_info *info) | 267 | static void pxa3xx_set_datasize(struct pxa3xx_nand_info *info) |
| 275 | { | 268 | { |
| 276 | int oob_enable = info->reg_ndcr & NDCR_SPARE_EN; | 269 | int oob_enable = info->reg_ndcr & NDCR_SPARE_EN; |
| @@ -291,69 +284,45 @@ static void pxa3xx_set_datasize(struct pxa3xx_nand_info *info) | |||
| 291 | } | 284 | } |
| 292 | } | 285 | } |
| 293 | 286 | ||
| 294 | static int prepare_read_prog_cmd(struct pxa3xx_nand_info *info, | 287 | /** |
| 295 | uint16_t cmd, int column, int page_addr) | 288 | * NOTE: it is a must to set ND_RUN firstly, then write |
| 289 | * command buffer, otherwise, it does not work. | ||
| 290 | * We enable all the interrupt at the same time, and | ||
| 291 | * let pxa3xx_nand_irq to handle all logic. | ||
| 292 | */ | ||
| 293 | static void pxa3xx_nand_start(struct pxa3xx_nand_info *info) | ||
| 296 | { | 294 | { |
| 297 | const struct pxa3xx_nand_cmdset *cmdset = info->cmdset; | 295 | uint32_t ndcr; |
| 298 | pxa3xx_set_datasize(info); | ||
| 299 | |||
| 300 | /* generate values for NDCBx registers */ | ||
| 301 | info->ndcb0 = cmd | ((cmd & 0xff00) ? NDCB0_DBC : 0); | ||
| 302 | info->ndcb1 = 0; | ||
| 303 | info->ndcb2 = 0; | ||
| 304 | info->ndcb0 |= NDCB0_ADDR_CYC(info->row_addr_cycles + info->col_addr_cycles); | ||
| 305 | |||
| 306 | if (info->col_addr_cycles == 2) { | ||
| 307 | /* large block, 2 cycles for column address | ||
| 308 | * row address starts from 3rd cycle | ||
| 309 | */ | ||
| 310 | info->ndcb1 |= page_addr << 16; | ||
| 311 | if (info->row_addr_cycles == 3) | ||
| 312 | info->ndcb2 = (page_addr >> 16) & 0xff; | ||
| 313 | } else | ||
| 314 | /* small block, 1 cycles for column address | ||
| 315 | * row address starts from 2nd cycle | ||
| 316 | */ | ||
| 317 | info->ndcb1 = page_addr << 8; | ||
| 318 | |||
| 319 | if (cmd == cmdset->program) | ||
| 320 | info->ndcb0 |= NDCB0_CMD_TYPE(1) | NDCB0_AUTO_RS; | ||
| 321 | 296 | ||
| 322 | return 0; | 297 | ndcr = info->reg_ndcr; |
| 323 | } | 298 | ndcr |= info->use_ecc ? NDCR_ECC_EN : 0; |
| 299 | ndcr |= info->use_dma ? NDCR_DMA_EN : 0; | ||
| 300 | ndcr |= NDCR_ND_RUN; | ||
| 324 | 301 | ||
| 325 | static int prepare_erase_cmd(struct pxa3xx_nand_info *info, | 302 | /* clear status bits and run */ |
| 326 | uint16_t cmd, int page_addr) | 303 | nand_writel(info, NDCR, 0); |
| 327 | { | 304 | nand_writel(info, NDSR, NDSR_MASK); |
| 328 | info->ndcb0 = cmd | ((cmd & 0xff00) ? NDCB0_DBC : 0); | 305 | nand_writel(info, NDCR, ndcr); |
| 329 | info->ndcb0 |= NDCB0_CMD_TYPE(2) | NDCB0_AUTO_RS | NDCB0_ADDR_CYC(3); | ||
| 330 | info->ndcb1 = page_addr; | ||
| 331 | info->ndcb2 = 0; | ||
| 332 | return 0; | ||
| 333 | } | 306 | } |
| 334 | 307 | ||
| 335 | static int prepare_other_cmd(struct pxa3xx_nand_info *info, uint16_t cmd) | 308 | static void pxa3xx_nand_stop(struct pxa3xx_nand_info *info) |
| 336 | { | 309 | { |
| 337 | const struct pxa3xx_nand_cmdset *cmdset = info->cmdset; | 310 | uint32_t ndcr; |
| 338 | 311 | int timeout = NAND_STOP_DELAY; | |
| 339 | info->ndcb0 = cmd | ((cmd & 0xff00) ? NDCB0_DBC : 0); | ||
| 340 | info->ndcb1 = 0; | ||
| 341 | info->ndcb2 = 0; | ||
| 342 | 312 | ||
| 343 | info->oob_size = 0; | 313 | /* wait RUN bit in NDCR become 0 */ |
| 344 | if (cmd == cmdset->read_id) { | 314 | ndcr = nand_readl(info, NDCR); |
| 345 | info->ndcb0 |= NDCB0_CMD_TYPE(3); | 315 | while ((ndcr & NDCR_ND_RUN) && (timeout-- > 0)) { |
| 346 | info->data_size = 8; | 316 | ndcr = nand_readl(info, NDCR); |
| 347 | } else if (cmd == cmdset->read_status) { | 317 | udelay(1); |
| 348 | info->ndcb0 |= NDCB0_CMD_TYPE(4); | 318 | } |
| 349 | info->data_size = 8; | ||
| 350 | } else if (cmd == cmdset->reset || cmd == cmdset->lock || | ||
| 351 | cmd == cmdset->unlock) { | ||
| 352 | info->ndcb0 |= NDCB0_CMD_TYPE(5); | ||
| 353 | } else | ||
| 354 | return -EINVAL; | ||
| 355 | 319 | ||
| 356 | return 0; | 320 | if (timeout <= 0) { |
| 321 | ndcr &= ~NDCR_ND_RUN; | ||
| 322 | nand_writel(info, NDCR, ndcr); | ||
| 323 | } | ||
| 324 | /* clear status bits */ | ||
| 325 | nand_writel(info, NDSR, NDSR_MASK); | ||
| 357 | } | 326 | } |
| 358 | 327 | ||
| 359 | static void enable_int(struct pxa3xx_nand_info *info, uint32_t int_mask) | 328 | static void enable_int(struct pxa3xx_nand_info *info, uint32_t int_mask) |
| @@ -372,39 +341,8 @@ static void disable_int(struct pxa3xx_nand_info *info, uint32_t int_mask) | |||
| 372 | nand_writel(info, NDCR, ndcr | int_mask); | 341 | nand_writel(info, NDCR, ndcr | int_mask); |
| 373 | } | 342 | } |
| 374 | 343 | ||
| 375 | /* NOTE: it is a must to set ND_RUN firstly, then write command buffer | 344 | static void handle_data_pio(struct pxa3xx_nand_info *info) |
| 376 | * otherwise, it does not work | ||
| 377 | */ | ||
| 378 | static int write_cmd(struct pxa3xx_nand_info *info) | ||
| 379 | { | 345 | { |
| 380 | uint32_t ndcr; | ||
| 381 | |||
| 382 | /* clear status bits and run */ | ||
| 383 | nand_writel(info, NDSR, NDSR_MASK); | ||
| 384 | |||
| 385 | ndcr = info->reg_ndcr; | ||
| 386 | |||
| 387 | ndcr |= info->use_ecc ? NDCR_ECC_EN : 0; | ||
| 388 | ndcr |= info->use_dma ? NDCR_DMA_EN : 0; | ||
| 389 | ndcr |= NDCR_ND_RUN; | ||
| 390 | |||
| 391 | nand_writel(info, NDCR, ndcr); | ||
| 392 | |||
| 393 | if (wait_for_event(info, NDSR_WRCMDREQ)) { | ||
| 394 | printk(KERN_ERR "timed out writing command\n"); | ||
| 395 | return -ETIMEDOUT; | ||
| 396 | } | ||
| 397 | |||
| 398 | nand_writel(info, NDCB0, info->ndcb0); | ||
| 399 | nand_writel(info, NDCB0, info->ndcb1); | ||
| 400 | nand_writel(info, NDCB0, info->ndcb2); | ||
| 401 | return 0; | ||
| 402 | } | ||
| 403 | |||
| 404 | static int handle_data_pio(struct pxa3xx_nand_info *info) | ||
| 405 | { | ||
| 406 | int ret, timeout = CHIP_DELAY_TIMEOUT; | ||
| 407 | |||
| 408 | switch (info->state) { | 346 | switch (info->state) { |
| 409 | case STATE_PIO_WRITING: | 347 | case STATE_PIO_WRITING: |
| 410 | __raw_writesl(info->mmio_base + NDDB, info->data_buff, | 348 | __raw_writesl(info->mmio_base + NDDB, info->data_buff, |
| @@ -412,14 +350,6 @@ static int handle_data_pio(struct pxa3xx_nand_info *info) | |||
| 412 | if (info->oob_size > 0) | 350 | if (info->oob_size > 0) |
| 413 | __raw_writesl(info->mmio_base + NDDB, info->oob_buff, | 351 | __raw_writesl(info->mmio_base + NDDB, info->oob_buff, |
| 414 | DIV_ROUND_UP(info->oob_size, 4)); | 352 | DIV_ROUND_UP(info->oob_size, 4)); |
| 415 | |||
| 416 | enable_int(info, NDSR_CS0_BBD | NDSR_CS0_CMDD); | ||
| 417 | |||
| 418 | ret = wait_for_completion_timeout(&info->cmd_complete, timeout); | ||
| 419 | if (!ret) { | ||
| 420 | printk(KERN_ERR "program command time out\n"); | ||
| 421 | return -1; | ||
| 422 | } | ||
| 423 | break; | 353 | break; |
| 424 | case STATE_PIO_READING: | 354 | case STATE_PIO_READING: |
| 425 | __raw_readsl(info->mmio_base + NDDB, info->data_buff, | 355 | __raw_readsl(info->mmio_base + NDDB, info->data_buff, |
| @@ -431,14 +361,11 @@ static int handle_data_pio(struct pxa3xx_nand_info *info) | |||
| 431 | default: | 361 | default: |
| 432 | printk(KERN_ERR "%s: invalid state %d\n", __func__, | 362 | printk(KERN_ERR "%s: invalid state %d\n", __func__, |
| 433 | info->state); | 363 | info->state); |
| 434 | return -EINVAL; | 364 | BUG(); |
| 435 | } | 365 | } |
| 436 | |||
| 437 | info->state = STATE_READY; | ||
| 438 | return 0; | ||
| 439 | } | 366 | } |
| 440 | 367 | ||
| 441 | static void start_data_dma(struct pxa3xx_nand_info *info, int dir_out) | 368 | static void start_data_dma(struct pxa3xx_nand_info *info) |
| 442 | { | 369 | { |
| 443 | struct pxa_dma_desc *desc = info->data_desc; | 370 | struct pxa_dma_desc *desc = info->data_desc; |
| 444 | int dma_len = ALIGN(info->data_size + info->oob_size, 32); | 371 | int dma_len = ALIGN(info->data_size + info->oob_size, 32); |
| @@ -446,14 +373,21 @@ static void start_data_dma(struct pxa3xx_nand_info *info, int dir_out) | |||
| 446 | desc->ddadr = DDADR_STOP; | 373 | desc->ddadr = DDADR_STOP; |
| 447 | desc->dcmd = DCMD_ENDIRQEN | DCMD_WIDTH4 | DCMD_BURST32 | dma_len; | 374 | desc->dcmd = DCMD_ENDIRQEN | DCMD_WIDTH4 | DCMD_BURST32 | dma_len; |
| 448 | 375 | ||
| 449 | if (dir_out) { | 376 | switch (info->state) { |
| 377 | case STATE_DMA_WRITING: | ||
| 450 | desc->dsadr = info->data_buff_phys; | 378 | desc->dsadr = info->data_buff_phys; |
| 451 | desc->dtadr = info->mmio_phys + NDDB; | 379 | desc->dtadr = info->mmio_phys + NDDB; |
| 452 | desc->dcmd |= DCMD_INCSRCADDR | DCMD_FLOWTRG; | 380 | desc->dcmd |= DCMD_INCSRCADDR | DCMD_FLOWTRG; |
| 453 | } else { | 381 | break; |
| 382 | case STATE_DMA_READING: | ||
| 454 | desc->dtadr = info->data_buff_phys; | 383 | desc->dtadr = info->data_buff_phys; |
| 455 | desc->dsadr = info->mmio_phys + NDDB; | 384 | desc->dsadr = info->mmio_phys + NDDB; |
| 456 | desc->dcmd |= DCMD_INCTRGADDR | DCMD_FLOWSRC; | 385 | desc->dcmd |= DCMD_INCTRGADDR | DCMD_FLOWSRC; |
| 386 | break; | ||
| 387 | default: | ||
| 388 | printk(KERN_ERR "%s: invalid state %d\n", __func__, | ||
| 389 | info->state); | ||
| 390 | BUG(); | ||
| 457 | } | 391 | } |
| 458 | 392 | ||
| 459 | DRCMR(info->drcmr_dat) = DRCMR_MAPVLD | info->data_dma_ch; | 393 | DRCMR(info->drcmr_dat) = DRCMR_MAPVLD | info->data_dma_ch; |
| @@ -471,93 +405,62 @@ static void pxa3xx_nand_data_dma_irq(int channel, void *data) | |||
| 471 | 405 | ||
| 472 | if (dcsr & DCSR_BUSERR) { | 406 | if (dcsr & DCSR_BUSERR) { |
| 473 | info->retcode = ERR_DMABUSERR; | 407 | info->retcode = ERR_DMABUSERR; |
| 474 | complete(&info->cmd_complete); | ||
| 475 | } | 408 | } |
| 476 | 409 | ||
| 477 | if (info->state == STATE_DMA_WRITING) { | 410 | info->state = STATE_DMA_DONE; |
| 478 | info->state = STATE_DMA_DONE; | 411 | enable_int(info, NDCR_INT_MASK); |
| 479 | enable_int(info, NDSR_CS0_BBD | NDSR_CS0_CMDD); | 412 | nand_writel(info, NDSR, NDSR_WRDREQ | NDSR_RDDREQ); |
| 480 | } else { | ||
| 481 | info->state = STATE_READY; | ||
| 482 | complete(&info->cmd_complete); | ||
| 483 | } | ||
| 484 | } | 413 | } |
| 485 | 414 | ||
| 486 | static irqreturn_t pxa3xx_nand_irq(int irq, void *devid) | 415 | static irqreturn_t pxa3xx_nand_irq(int irq, void *devid) |
| 487 | { | 416 | { |
| 488 | struct pxa3xx_nand_info *info = devid; | 417 | struct pxa3xx_nand_info *info = devid; |
| 489 | unsigned int status; | 418 | unsigned int status, is_completed = 0; |
| 490 | 419 | ||
| 491 | status = nand_readl(info, NDSR); | 420 | status = nand_readl(info, NDSR); |
| 492 | 421 | ||
| 493 | if (status & (NDSR_RDDREQ | NDSR_DBERR | NDSR_SBERR)) { | 422 | if (status & NDSR_DBERR) |
| 494 | if (status & NDSR_DBERR) | 423 | info->retcode = ERR_DBERR; |
| 495 | info->retcode = ERR_DBERR; | 424 | if (status & NDSR_SBERR) |
| 496 | else if (status & NDSR_SBERR) | 425 | info->retcode = ERR_SBERR; |
| 497 | info->retcode = ERR_SBERR; | 426 | if (status & (NDSR_RDDREQ | NDSR_WRDREQ)) { |
| 498 | 427 | /* whether use dma to transfer data */ | |
| 499 | disable_int(info, NDSR_RDDREQ | NDSR_DBERR | NDSR_SBERR); | ||
| 500 | |||
| 501 | if (info->use_dma) { | ||
| 502 | info->state = STATE_DMA_READING; | ||
| 503 | start_data_dma(info, 0); | ||
| 504 | } else { | ||
| 505 | info->state = STATE_PIO_READING; | ||
| 506 | complete(&info->cmd_complete); | ||
| 507 | } | ||
| 508 | } else if (status & NDSR_WRDREQ) { | ||
| 509 | disable_int(info, NDSR_WRDREQ); | ||
| 510 | if (info->use_dma) { | 428 | if (info->use_dma) { |
| 511 | info->state = STATE_DMA_WRITING; | 429 | disable_int(info, NDCR_INT_MASK); |
| 512 | start_data_dma(info, 1); | 430 | info->state = (status & NDSR_RDDREQ) ? |
| 431 | STATE_DMA_READING : STATE_DMA_WRITING; | ||
| 432 | start_data_dma(info); | ||
| 433 | goto NORMAL_IRQ_EXIT; | ||
| 513 | } else { | 434 | } else { |
| 514 | info->state = STATE_PIO_WRITING; | 435 | info->state = (status & NDSR_RDDREQ) ? |
| 515 | complete(&info->cmd_complete); | 436 | STATE_PIO_READING : STATE_PIO_WRITING; |
| 437 | handle_data_pio(info); | ||
| 516 | } | 438 | } |
| 517 | } else if (status & (NDSR_CS0_BBD | NDSR_CS0_CMDD)) { | ||
| 518 | if (status & NDSR_CS0_BBD) | ||
| 519 | info->retcode = ERR_BBERR; | ||
| 520 | |||
| 521 | disable_int(info, NDSR_CS0_BBD | NDSR_CS0_CMDD); | ||
| 522 | info->state = STATE_READY; | ||
| 523 | complete(&info->cmd_complete); | ||
| 524 | } | 439 | } |
| 525 | nand_writel(info, NDSR, status); | 440 | if (status & NDSR_CS0_CMDD) { |
| 526 | return IRQ_HANDLED; | 441 | info->state = STATE_CMD_DONE; |
| 527 | } | 442 | is_completed = 1; |
| 528 | |||
| 529 | static int pxa3xx_nand_do_cmd(struct pxa3xx_nand_info *info, uint32_t event) | ||
| 530 | { | ||
| 531 | uint32_t ndcr; | ||
| 532 | int ret, timeout = CHIP_DELAY_TIMEOUT; | ||
| 533 | |||
| 534 | if (write_cmd(info)) { | ||
| 535 | info->retcode = ERR_SENDCMD; | ||
| 536 | goto fail_stop; | ||
| 537 | } | 443 | } |
| 538 | 444 | if (status & NDSR_FLASH_RDY) { | |
| 539 | info->state = STATE_CMD_HANDLE; | 445 | info->is_ready = 1; |
| 540 | 446 | info->state = STATE_READY; | |
| 541 | enable_int(info, event); | ||
| 542 | |||
| 543 | ret = wait_for_completion_timeout(&info->cmd_complete, timeout); | ||
| 544 | if (!ret) { | ||
| 545 | printk(KERN_ERR "command execution timed out\n"); | ||
| 546 | info->retcode = ERR_SENDCMD; | ||
| 547 | goto fail_stop; | ||
| 548 | } | 447 | } |
| 549 | 448 | ||
| 550 | if (info->use_dma == 0 && info->data_size > 0) | 449 | if (status & NDSR_WRCMDREQ) { |
| 551 | if (handle_data_pio(info)) | 450 | nand_writel(info, NDSR, NDSR_WRCMDREQ); |
| 552 | goto fail_stop; | 451 | status &= ~NDSR_WRCMDREQ; |
| 553 | 452 | info->state = STATE_CMD_HANDLE; | |
| 554 | return 0; | 453 | nand_writel(info, NDCB0, info->ndcb0); |
| 454 | nand_writel(info, NDCB0, info->ndcb1); | ||
| 455 | nand_writel(info, NDCB0, info->ndcb2); | ||
| 456 | } | ||
| 555 | 457 | ||
| 556 | fail_stop: | 458 | /* clear NDSR to let the controller exit the IRQ */ |
| 557 | ndcr = nand_readl(info, NDCR); | 459 | nand_writel(info, NDSR, status); |
| 558 | nand_writel(info, NDCR, ndcr & ~NDCR_ND_RUN); | 460 | if (is_completed) |
| 559 | udelay(10); | 461 | complete(&info->cmd_complete); |
| 560 | return -ETIMEDOUT; | 462 | NORMAL_IRQ_EXIT: |
| 463 | return IRQ_HANDLED; | ||
| 561 | } | 464 | } |
| 562 | 465 | ||
| 563 | static int pxa3xx_nand_dev_ready(struct mtd_info *mtd) | 466 | static int pxa3xx_nand_dev_ready(struct mtd_info *mtd) |
| @@ -574,125 +477,218 @@ static inline int is_buf_blank(uint8_t *buf, size_t len) | |||
| 574 | return 1; | 477 | return 1; |
| 575 | } | 478 | } |
| 576 | 479 | ||
| 577 | static void pxa3xx_nand_cmdfunc(struct mtd_info *mtd, unsigned command, | 480 | static int prepare_command_pool(struct pxa3xx_nand_info *info, int command, |
| 578 | int column, int page_addr) | 481 | uint16_t column, int page_addr) |
| 579 | { | 482 | { |
| 580 | struct pxa3xx_nand_info *info = mtd->priv; | 483 | uint16_t cmd; |
| 581 | const struct pxa3xx_nand_cmdset *cmdset = info->cmdset; | 484 | int addr_cycle, exec_cmd, ndcb0; |
| 582 | int ret; | 485 | struct mtd_info *mtd = info->mtd; |
| 486 | |||
| 487 | ndcb0 = 0; | ||
| 488 | addr_cycle = 0; | ||
| 489 | exec_cmd = 1; | ||
| 490 | |||
| 491 | /* reset data and oob column point to handle data */ | ||
| 492 | info->buf_start = 0; | ||
| 493 | info->buf_count = 0; | ||
| 494 | info->oob_size = 0; | ||
| 495 | info->use_ecc = 0; | ||
| 496 | info->is_ready = 0; | ||
| 497 | info->retcode = ERR_NONE; | ||
| 583 | 498 | ||
| 584 | info->use_dma = (use_dma) ? 1 : 0; | 499 | switch (command) { |
| 585 | info->use_ecc = 0; | 500 | case NAND_CMD_READ0: |
| 586 | info->data_size = 0; | 501 | case NAND_CMD_PAGEPROG: |
| 587 | info->state = STATE_READY; | 502 | info->use_ecc = 1; |
| 503 | case NAND_CMD_READOOB: | ||
| 504 | pxa3xx_set_datasize(info); | ||
| 505 | break; | ||
| 506 | case NAND_CMD_SEQIN: | ||
| 507 | exec_cmd = 0; | ||
| 508 | break; | ||
| 509 | default: | ||
| 510 | info->ndcb1 = 0; | ||
| 511 | info->ndcb2 = 0; | ||
| 512 | break; | ||
| 513 | } | ||
| 588 | 514 | ||
| 589 | init_completion(&info->cmd_complete); | 515 | info->ndcb0 = ndcb0; |
| 516 | addr_cycle = NDCB0_ADDR_CYC(info->row_addr_cycles | ||
| 517 | + info->col_addr_cycles); | ||
| 590 | 518 | ||
| 591 | switch (command) { | 519 | switch (command) { |
| 592 | case NAND_CMD_READOOB: | 520 | case NAND_CMD_READOOB: |
| 593 | /* disable HW ECC to get all the OOB data */ | 521 | case NAND_CMD_READ0: |
| 594 | info->buf_count = mtd->writesize + mtd->oobsize; | 522 | cmd = info->cmdset->read1; |
| 595 | info->buf_start = mtd->writesize + column; | 523 | if (command == NAND_CMD_READOOB) |
| 596 | memset(info->data_buff, 0xFF, info->buf_count); | 524 | info->buf_start = mtd->writesize + column; |
| 525 | else | ||
| 526 | info->buf_start = column; | ||
| 597 | 527 | ||
| 598 | if (prepare_read_prog_cmd(info, cmdset->read1, column, page_addr)) | 528 | if (unlikely(info->page_size < PAGE_CHUNK_SIZE)) |
| 599 | break; | 529 | info->ndcb0 |= NDCB0_CMD_TYPE(0) |
| 530 | | addr_cycle | ||
| 531 | | (cmd & NDCB0_CMD1_MASK); | ||
| 532 | else | ||
| 533 | info->ndcb0 |= NDCB0_CMD_TYPE(0) | ||
| 534 | | NDCB0_DBC | ||
| 535 | | addr_cycle | ||
| 536 | | cmd; | ||
| 600 | 537 | ||
| 601 | pxa3xx_nand_do_cmd(info, NDSR_RDDREQ | NDSR_DBERR | NDSR_SBERR); | 538 | case NAND_CMD_SEQIN: |
| 539 | /* small page addr setting */ | ||
| 540 | if (unlikely(info->page_size < PAGE_CHUNK_SIZE)) { | ||
| 541 | info->ndcb1 = ((page_addr & 0xFFFFFF) << 8) | ||
| 542 | | (column & 0xFF); | ||
| 602 | 543 | ||
| 603 | /* We only are OOB, so if the data has error, does not matter */ | 544 | info->ndcb2 = 0; |
| 604 | if (info->retcode == ERR_DBERR) | 545 | } else { |
| 605 | info->retcode = ERR_NONE; | 546 | info->ndcb1 = ((page_addr & 0xFFFF) << 16) |
| 606 | break; | 547 | | (column & 0xFFFF); |
| 548 | |||
| 549 | if (page_addr & 0xFF0000) | ||
| 550 | info->ndcb2 = (page_addr & 0xFF0000) >> 16; | ||
| 551 | else | ||
| 552 | info->ndcb2 = 0; | ||
| 553 | } | ||
| 607 | 554 | ||
| 608 | case NAND_CMD_READ0: | ||
| 609 | info->use_ecc = 1; | ||
| 610 | info->retcode = ERR_NONE; | ||
| 611 | info->buf_start = column; | ||
| 612 | info->buf_count = mtd->writesize + mtd->oobsize; | 555 | info->buf_count = mtd->writesize + mtd->oobsize; |
| 613 | memset(info->data_buff, 0xFF, info->buf_count); | 556 | memset(info->data_buff, 0xFF, info->buf_count); |
| 614 | 557 | ||
| 615 | if (prepare_read_prog_cmd(info, cmdset->read1, column, page_addr)) | 558 | break; |
| 559 | |||
| 560 | case NAND_CMD_PAGEPROG: | ||
| 561 | if (is_buf_blank(info->data_buff, | ||
| 562 | (mtd->writesize + mtd->oobsize))) { | ||
| 563 | exec_cmd = 0; | ||
| 616 | break; | 564 | break; |
| 565 | } | ||
| 617 | 566 | ||
| 618 | pxa3xx_nand_do_cmd(info, NDSR_RDDREQ | NDSR_DBERR | NDSR_SBERR); | 567 | cmd = info->cmdset->program; |
| 568 | info->ndcb0 |= NDCB0_CMD_TYPE(0x1) | ||
| 569 | | NDCB0_AUTO_RS | ||
| 570 | | NDCB0_ST_ROW_EN | ||
| 571 | | NDCB0_DBC | ||
| 572 | | cmd | ||
| 573 | | addr_cycle; | ||
| 574 | break; | ||
| 619 | 575 | ||
| 620 | if (info->retcode == ERR_DBERR) { | 576 | case NAND_CMD_READID: |
| 621 | /* for blank page (all 0xff), HW will calculate its ECC as | 577 | cmd = info->cmdset->read_id; |
| 622 | * 0, which is different from the ECC information within | 578 | info->buf_count = info->read_id_bytes; |
| 623 | * OOB, ignore such double bit errors | 579 | info->ndcb0 |= NDCB0_CMD_TYPE(3) |
| 624 | */ | 580 | | NDCB0_ADDR_CYC(1) |
| 625 | if (is_buf_blank(info->data_buff, mtd->writesize)) | 581 | | cmd; |
| 626 | info->retcode = ERR_NONE; | 582 | |
| 627 | } | 583 | info->data_size = 8; |
| 628 | break; | 584 | break; |
| 629 | case NAND_CMD_SEQIN: | 585 | case NAND_CMD_STATUS: |
| 630 | info->buf_start = column; | 586 | cmd = info->cmdset->read_status; |
| 631 | info->buf_count = mtd->writesize + mtd->oobsize; | 587 | info->buf_count = 1; |
| 632 | memset(info->data_buff, 0xff, info->buf_count); | 588 | info->ndcb0 |= NDCB0_CMD_TYPE(4) |
| 589 | | NDCB0_ADDR_CYC(1) | ||
| 590 | | cmd; | ||
| 633 | 591 | ||
| 634 | /* save column/page_addr for next CMD_PAGEPROG */ | 592 | info->data_size = 8; |
| 635 | info->seqin_column = column; | ||
| 636 | info->seqin_page_addr = page_addr; | ||
| 637 | break; | 593 | break; |
| 638 | case NAND_CMD_PAGEPROG: | ||
| 639 | info->use_ecc = (info->seqin_column >= mtd->writesize) ? 0 : 1; | ||
| 640 | 594 | ||
| 641 | if (prepare_read_prog_cmd(info, cmdset->program, | 595 | case NAND_CMD_ERASE1: |
| 642 | info->seqin_column, info->seqin_page_addr)) | 596 | cmd = info->cmdset->erase; |
| 643 | break; | 597 | info->ndcb0 |= NDCB0_CMD_TYPE(2) |
| 598 | | NDCB0_AUTO_RS | ||
| 599 | | NDCB0_ADDR_CYC(3) | ||
| 600 | | NDCB0_DBC | ||
| 601 | | cmd; | ||
| 602 | info->ndcb1 = page_addr; | ||
| 603 | info->ndcb2 = 0; | ||
| 644 | 604 | ||
| 645 | pxa3xx_nand_do_cmd(info, NDSR_WRDREQ); | ||
| 646 | break; | 605 | break; |
| 647 | case NAND_CMD_ERASE1: | 606 | case NAND_CMD_RESET: |
| 648 | if (prepare_erase_cmd(info, cmdset->erase, page_addr)) | 607 | cmd = info->cmdset->reset; |
| 649 | break; | 608 | info->ndcb0 |= NDCB0_CMD_TYPE(5) |
| 609 | | cmd; | ||
| 650 | 610 | ||
| 651 | pxa3xx_nand_do_cmd(info, NDSR_CS0_BBD | NDSR_CS0_CMDD); | ||
| 652 | break; | 611 | break; |
| 612 | |||
| 653 | case NAND_CMD_ERASE2: | 613 | case NAND_CMD_ERASE2: |
| 614 | exec_cmd = 0; | ||
| 654 | break; | 615 | break; |
| 655 | case NAND_CMD_READID: | ||
| 656 | case NAND_CMD_STATUS: | ||
| 657 | info->use_dma = 0; /* force PIO read */ | ||
| 658 | info->buf_start = 0; | ||
| 659 | info->buf_count = (command == NAND_CMD_READID) ? | ||
| 660 | info->read_id_bytes : 1; | ||
| 661 | |||
| 662 | if (prepare_other_cmd(info, (command == NAND_CMD_READID) ? | ||
| 663 | cmdset->read_id : cmdset->read_status)) | ||
| 664 | break; | ||
| 665 | 616 | ||
| 666 | pxa3xx_nand_do_cmd(info, NDSR_RDDREQ); | 617 | default: |
| 618 | exec_cmd = 0; | ||
| 619 | printk(KERN_ERR "pxa3xx-nand: non-supported" | ||
| 620 | " command %x\n", command); | ||
| 667 | break; | 621 | break; |
| 668 | case NAND_CMD_RESET: | 622 | } |
| 669 | if (prepare_other_cmd(info, cmdset->reset)) | ||
| 670 | break; | ||
| 671 | 623 | ||
| 672 | ret = pxa3xx_nand_do_cmd(info, NDSR_CS0_CMDD); | 624 | return exec_cmd; |
| 673 | if (ret == 0) { | 625 | } |
| 674 | int timeout = 2; | ||
| 675 | uint32_t ndcr; | ||
| 676 | 626 | ||
| 677 | while (timeout--) { | 627 | static void pxa3xx_nand_cmdfunc(struct mtd_info *mtd, unsigned command, |
| 678 | if (nand_readl(info, NDSR) & NDSR_RDY) | 628 | int column, int page_addr) |
| 679 | break; | 629 | { |
| 680 | msleep(10); | 630 | struct pxa3xx_nand_info *info = mtd->priv; |
| 681 | } | 631 | int ret, exec_cmd; |
| 682 | 632 | ||
| 683 | ndcr = nand_readl(info, NDCR); | 633 | /* |
| 684 | nand_writel(info, NDCR, ndcr & ~NDCR_ND_RUN); | 634 | * if this is a x16 device ,then convert the input |
| 635 | * "byte" address into a "word" address appropriate | ||
| 636 | * for indexing a word-oriented device | ||
| 637 | */ | ||
| 638 | if (info->reg_ndcr & NDCR_DWIDTH_M) | ||
| 639 | column /= 2; | ||
| 640 | |||
| 641 | exec_cmd = prepare_command_pool(info, command, column, page_addr); | ||
| 642 | if (exec_cmd) { | ||
| 643 | init_completion(&info->cmd_complete); | ||
| 644 | pxa3xx_nand_start(info); | ||
| 645 | |||
| 646 | ret = wait_for_completion_timeout(&info->cmd_complete, | ||
| 647 | CHIP_DELAY_TIMEOUT); | ||
| 648 | if (!ret) { | ||
| 649 | printk(KERN_ERR "Wait time out!!!\n"); | ||
| 650 | /* Stop State Machine for next command cycle */ | ||
| 651 | pxa3xx_nand_stop(info); | ||
| 685 | } | 652 | } |
| 686 | break; | 653 | info->state = STATE_IDLE; |
| 687 | default: | ||
| 688 | printk(KERN_ERR "non-supported command.\n"); | ||
| 689 | break; | ||
| 690 | } | 654 | } |
| 655 | } | ||
| 656 | |||
| 657 | static void pxa3xx_nand_write_page_hwecc(struct mtd_info *mtd, | ||
| 658 | struct nand_chip *chip, const uint8_t *buf) | ||
| 659 | { | ||
| 660 | chip->write_buf(mtd, buf, mtd->writesize); | ||
| 661 | chip->write_buf(mtd, chip->oob_poi, mtd->oobsize); | ||
| 662 | } | ||
| 691 | 663 | ||
| 692 | if (info->retcode == ERR_DBERR) { | 664 | static int pxa3xx_nand_read_page_hwecc(struct mtd_info *mtd, |
| 693 | printk(KERN_ERR "double bit error @ page %08x\n", page_addr); | 665 | struct nand_chip *chip, uint8_t *buf, int page) |
| 694 | info->retcode = ERR_NONE; | 666 | { |
| 667 | struct pxa3xx_nand_info *info = mtd->priv; | ||
| 668 | |||
| 669 | chip->read_buf(mtd, buf, mtd->writesize); | ||
| 670 | chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); | ||
| 671 | |||
| 672 | if (info->retcode == ERR_SBERR) { | ||
| 673 | switch (info->use_ecc) { | ||
| 674 | case 1: | ||
| 675 | mtd->ecc_stats.corrected++; | ||
| 676 | break; | ||
| 677 | case 0: | ||
| 678 | default: | ||
| 679 | break; | ||
| 680 | } | ||
| 681 | } else if (info->retcode == ERR_DBERR) { | ||
| 682 | /* | ||
| 683 | * for blank page (all 0xff), HW will calculate its ECC as | ||
| 684 | * 0, which is different from the ECC information within | ||
| 685 | * OOB, ignore such double bit errors | ||
| 686 | */ | ||
| 687 | if (is_buf_blank(buf, mtd->writesize)) | ||
| 688 | mtd->ecc_stats.failed++; | ||
| 695 | } | 689 | } |
| 690 | |||
| 691 | return 0; | ||
| 696 | } | 692 | } |
| 697 | 693 | ||
| 698 | static uint8_t pxa3xx_nand_read_byte(struct mtd_info *mtd) | 694 | static uint8_t pxa3xx_nand_read_byte(struct mtd_info *mtd) |
| @@ -769,73 +765,12 @@ static int pxa3xx_nand_waitfunc(struct mtd_info *mtd, struct nand_chip *this) | |||
| 769 | return 0; | 765 | return 0; |
| 770 | } | 766 | } |
| 771 | 767 | ||
| 772 | static void pxa3xx_nand_ecc_hwctl(struct mtd_info *mtd, int mode) | ||
| 773 | { | ||
| 774 | return; | ||
| 775 | } | ||
| 776 | |||
| 777 | static int pxa3xx_nand_ecc_calculate(struct mtd_info *mtd, | ||
| 778 | const uint8_t *dat, uint8_t *ecc_code) | ||
| 779 | { | ||
| 780 | return 0; | ||
| 781 | } | ||
| 782 | |||
| 783 | static int pxa3xx_nand_ecc_correct(struct mtd_info *mtd, | ||
| 784 | uint8_t *dat, uint8_t *read_ecc, uint8_t *calc_ecc) | ||
| 785 | { | ||
| 786 | struct pxa3xx_nand_info *info = mtd->priv; | ||
| 787 | /* | ||
| 788 | * Any error include ERR_SEND_CMD, ERR_DBERR, ERR_BUSERR, we | ||
| 789 | * consider it as a ecc error which will tell the caller the | ||
| 790 | * read fail We have distinguish all the errors, but the | ||
| 791 | * nand_read_ecc only check this function return value | ||
| 792 | * | ||
| 793 | * Corrected (single-bit) errors must also be noted. | ||
| 794 | */ | ||
| 795 | if (info->retcode == ERR_SBERR) | ||
| 796 | return 1; | ||
| 797 | else if (info->retcode != ERR_NONE) | ||
| 798 | return -1; | ||
| 799 | |||
| 800 | return 0; | ||
| 801 | } | ||
| 802 | |||
| 803 | static int __readid(struct pxa3xx_nand_info *info, uint32_t *id) | ||
| 804 | { | ||
| 805 | const struct pxa3xx_nand_cmdset *cmdset = info->cmdset; | ||
| 806 | uint32_t ndcr; | ||
| 807 | uint8_t id_buff[8]; | ||
| 808 | |||
| 809 | if (prepare_other_cmd(info, cmdset->read_id)) { | ||
| 810 | printk(KERN_ERR "failed to prepare command\n"); | ||
| 811 | return -EINVAL; | ||
| 812 | } | ||
| 813 | |||
| 814 | /* Send command */ | ||
| 815 | if (write_cmd(info)) | ||
| 816 | goto fail_timeout; | ||
| 817 | |||
| 818 | /* Wait for CMDDM(command done successfully) */ | ||
| 819 | if (wait_for_event(info, NDSR_RDDREQ)) | ||
| 820 | goto fail_timeout; | ||
| 821 | |||
| 822 | __raw_readsl(info->mmio_base + NDDB, id_buff, 2); | ||
| 823 | *id = id_buff[0] | (id_buff[1] << 8); | ||
| 824 | return 0; | ||
| 825 | |||
| 826 | fail_timeout: | ||
| 827 | ndcr = nand_readl(info, NDCR); | ||
| 828 | nand_writel(info, NDCR, ndcr & ~NDCR_ND_RUN); | ||
| 829 | udelay(10); | ||
| 830 | return -ETIMEDOUT; | ||
| 831 | } | ||
| 832 | |||
| 833 | static int pxa3xx_nand_config_flash(struct pxa3xx_nand_info *info, | 768 | static int pxa3xx_nand_config_flash(struct pxa3xx_nand_info *info, |
| 834 | const struct pxa3xx_nand_flash *f) | 769 | const struct pxa3xx_nand_flash *f) |
| 835 | { | 770 | { |
| 836 | struct platform_device *pdev = info->pdev; | 771 | struct platform_device *pdev = info->pdev; |
| 837 | struct pxa3xx_nand_platform_data *pdata = pdev->dev.platform_data; | 772 | struct pxa3xx_nand_platform_data *pdata = pdev->dev.platform_data; |
| 838 | uint32_t ndcr = 0x00000FFF; /* disable all interrupts */ | 773 | uint32_t ndcr = 0x0; /* enable all interrupts */ |
| 839 | 774 | ||
| 840 | if (f->page_size != 2048 && f->page_size != 512) | 775 | if (f->page_size != 2048 && f->page_size != 512) |
| 841 | return -EINVAL; | 776 | return -EINVAL; |
| @@ -844,9 +779,8 @@ static int pxa3xx_nand_config_flash(struct pxa3xx_nand_info *info, | |||
| 844 | return -EINVAL; | 779 | return -EINVAL; |
| 845 | 780 | ||
| 846 | /* calculate flash information */ | 781 | /* calculate flash information */ |
| 847 | info->cmdset = f->cmdset; | 782 | info->cmdset = &default_cmdset; |
| 848 | info->page_size = f->page_size; | 783 | info->page_size = f->page_size; |
| 849 | info->oob_buff = info->data_buff + f->page_size; | ||
| 850 | info->read_id_bytes = (f->page_size == 2048) ? 4 : 2; | 784 | info->read_id_bytes = (f->page_size == 2048) ? 4 : 2; |
| 851 | 785 | ||
| 852 | /* calculate addressing information */ | 786 | /* calculate addressing information */ |
| @@ -876,87 +810,18 @@ static int pxa3xx_nand_config_flash(struct pxa3xx_nand_info *info, | |||
| 876 | static int pxa3xx_nand_detect_config(struct pxa3xx_nand_info *info) | 810 | static int pxa3xx_nand_detect_config(struct pxa3xx_nand_info *info) |
| 877 | { | 811 | { |
| 878 | uint32_t ndcr = nand_readl(info, NDCR); | 812 | uint32_t ndcr = nand_readl(info, NDCR); |
| 879 | struct nand_flash_dev *type = NULL; | ||
| 880 | uint32_t id = -1, page_per_block, num_blocks; | ||
| 881 | int i; | ||
| 882 | |||
| 883 | page_per_block = ndcr & NDCR_PG_PER_BLK ? 64 : 32; | ||
| 884 | info->page_size = ndcr & NDCR_PAGE_SZ ? 2048 : 512; | 813 | info->page_size = ndcr & NDCR_PAGE_SZ ? 2048 : 512; |
| 885 | /* set info fields needed to __readid */ | 814 | /* set info fields needed to read id */ |
| 886 | info->read_id_bytes = (info->page_size == 2048) ? 4 : 2; | 815 | info->read_id_bytes = (info->page_size == 2048) ? 4 : 2; |
| 887 | info->reg_ndcr = ndcr; | 816 | info->reg_ndcr = ndcr; |
| 888 | info->cmdset = &default_cmdset; | 817 | info->cmdset = &default_cmdset; |
| 889 | 818 | ||
| 890 | if (__readid(info, &id)) | ||
| 891 | return -ENODEV; | ||
| 892 | |||
| 893 | /* Lookup the flash id */ | ||
| 894 | id = (id >> 8) & 0xff; /* device id is byte 2 */ | ||
| 895 | for (i = 0; nand_flash_ids[i].name != NULL; i++) { | ||
| 896 | if (id == nand_flash_ids[i].id) { | ||
| 897 | type = &nand_flash_ids[i]; | ||
| 898 | break; | ||
| 899 | } | ||
| 900 | } | ||
| 901 | |||
| 902 | if (!type) | ||
| 903 | return -ENODEV; | ||
| 904 | |||
| 905 | /* fill the missing flash information */ | ||
| 906 | i = __ffs(page_per_block * info->page_size); | ||
| 907 | num_blocks = type->chipsize << (20 - i); | ||
| 908 | |||
| 909 | /* calculate addressing information */ | ||
| 910 | info->col_addr_cycles = (info->page_size == 2048) ? 2 : 1; | ||
| 911 | |||
| 912 | if (num_blocks * page_per_block > 65536) | ||
| 913 | info->row_addr_cycles = 3; | ||
| 914 | else | ||
| 915 | info->row_addr_cycles = 2; | ||
| 916 | |||
| 917 | info->ndtr0cs0 = nand_readl(info, NDTR0CS0); | 819 | info->ndtr0cs0 = nand_readl(info, NDTR0CS0); |
| 918 | info->ndtr1cs0 = nand_readl(info, NDTR1CS0); | 820 | info->ndtr1cs0 = nand_readl(info, NDTR1CS0); |
| 919 | 821 | ||
| 920 | return 0; | 822 | return 0; |
| 921 | } | 823 | } |
| 922 | 824 | ||
| 923 | static int pxa3xx_nand_detect_flash(struct pxa3xx_nand_info *info, | ||
| 924 | const struct pxa3xx_nand_platform_data *pdata) | ||
| 925 | { | ||
| 926 | const struct pxa3xx_nand_flash *f; | ||
| 927 | uint32_t id = -1; | ||
| 928 | int i; | ||
| 929 | |||
| 930 | if (pdata->keep_config) | ||
| 931 | if (pxa3xx_nand_detect_config(info) == 0) | ||
| 932 | return 0; | ||
| 933 | |||
| 934 | /* we use default timing to detect id */ | ||
| 935 | f = DEFAULT_FLASH_TYPE; | ||
| 936 | pxa3xx_nand_config_flash(info, f); | ||
| 937 | if (__readid(info, &id)) | ||
| 938 | goto fail_detect; | ||
| 939 | |||
| 940 | for (i=0; i<ARRAY_SIZE(builtin_flash_types) + pdata->num_flash - 1; i++) { | ||
| 941 | /* we first choose the flash definition from platfrom */ | ||
| 942 | if (i < pdata->num_flash) | ||
| 943 | f = pdata->flash + i; | ||
| 944 | else | ||
| 945 | f = &builtin_flash_types[i - pdata->num_flash + 1]; | ||
| 946 | if (f->chip_id == id) { | ||
| 947 | dev_info(&info->pdev->dev, "detect chip id: 0x%x\n", id); | ||
| 948 | pxa3xx_nand_config_flash(info, f); | ||
| 949 | return 0; | ||
| 950 | } | ||
| 951 | } | ||
| 952 | |||
| 953 | dev_warn(&info->pdev->dev, | ||
| 954 | "failed to detect configured nand flash; found %04x instead of\n", | ||
| 955 | id); | ||
| 956 | fail_detect: | ||
| 957 | return -ENODEV; | ||
| 958 | } | ||
| 959 | |||
| 960 | /* the maximum possible buffer size for large page with OOB data | 825 | /* the maximum possible buffer size for large page with OOB data |
| 961 | * is: 2048 + 64 = 2112 bytes, allocate a page here for both the | 826 | * is: 2048 + 64 = 2112 bytes, allocate a page here for both the |
| 962 | * data buffer and the DMA descriptor | 827 | * data buffer and the DMA descriptor |
| @@ -998,82 +863,144 @@ static int pxa3xx_nand_init_buff(struct pxa3xx_nand_info *info) | |||
| 998 | return 0; | 863 | return 0; |
| 999 | } | 864 | } |
| 1000 | 865 | ||
| 1001 | static struct nand_ecclayout hw_smallpage_ecclayout = { | 866 | static int pxa3xx_nand_sensing(struct pxa3xx_nand_info *info) |
| 1002 | .eccbytes = 6, | 867 | { |
| 1003 | .eccpos = {8, 9, 10, 11, 12, 13 }, | 868 | struct mtd_info *mtd = info->mtd; |
| 1004 | .oobfree = { {2, 6} } | 869 | struct nand_chip *chip = mtd->priv; |
| 1005 | }; | ||
| 1006 | 870 | ||
| 1007 | static struct nand_ecclayout hw_largepage_ecclayout = { | 871 | /* use the common timing to make a try */ |
| 1008 | .eccbytes = 24, | 872 | pxa3xx_nand_config_flash(info, &builtin_flash_types[0]); |
| 1009 | .eccpos = { | 873 | chip->cmdfunc(mtd, NAND_CMD_RESET, 0, 0); |
| 1010 | 40, 41, 42, 43, 44, 45, 46, 47, | 874 | if (info->is_ready) |
| 1011 | 48, 49, 50, 51, 52, 53, 54, 55, | 875 | return 1; |
| 1012 | 56, 57, 58, 59, 60, 61, 62, 63}, | 876 | else |
| 1013 | .oobfree = { {2, 38} } | 877 | return 0; |
| 1014 | }; | 878 | } |
| 1015 | 879 | ||
| 1016 | static void pxa3xx_nand_init_mtd(struct mtd_info *mtd, | 880 | static int pxa3xx_nand_scan(struct mtd_info *mtd) |
| 1017 | struct pxa3xx_nand_info *info) | ||
| 1018 | { | 881 | { |
| 1019 | struct nand_chip *this = &info->nand_chip; | 882 | struct pxa3xx_nand_info *info = mtd->priv; |
| 1020 | 883 | struct platform_device *pdev = info->pdev; | |
| 1021 | this->options = (info->reg_ndcr & NDCR_DWIDTH_C) ? NAND_BUSWIDTH_16: 0; | 884 | struct pxa3xx_nand_platform_data *pdata = pdev->dev.platform_data; |
| 1022 | 885 | struct nand_flash_dev pxa3xx_flash_ids[2] = { {NULL,}, {NULL,} }; | |
| 1023 | this->waitfunc = pxa3xx_nand_waitfunc; | 886 | const struct pxa3xx_nand_flash *f = NULL; |
| 1024 | this->select_chip = pxa3xx_nand_select_chip; | 887 | struct nand_chip *chip = mtd->priv; |
| 1025 | this->dev_ready = pxa3xx_nand_dev_ready; | 888 | uint32_t id = -1; |
| 1026 | this->cmdfunc = pxa3xx_nand_cmdfunc; | 889 | uint64_t chipsize; |
| 1027 | this->read_word = pxa3xx_nand_read_word; | 890 | int i, ret, num; |
| 1028 | this->read_byte = pxa3xx_nand_read_byte; | 891 | |
| 1029 | this->read_buf = pxa3xx_nand_read_buf; | 892 | if (pdata->keep_config && !pxa3xx_nand_detect_config(info)) |
| 1030 | this->write_buf = pxa3xx_nand_write_buf; | 893 | goto KEEP_CONFIG; |
| 1031 | this->verify_buf = pxa3xx_nand_verify_buf; | 894 | |
| 1032 | 895 | ret = pxa3xx_nand_sensing(info); | |
| 1033 | this->ecc.mode = NAND_ECC_HW; | 896 | if (!ret) { |
| 1034 | this->ecc.hwctl = pxa3xx_nand_ecc_hwctl; | 897 | kfree(mtd); |
| 1035 | this->ecc.calculate = pxa3xx_nand_ecc_calculate; | 898 | info->mtd = NULL; |
| 1036 | this->ecc.correct = pxa3xx_nand_ecc_correct; | 899 | printk(KERN_INFO "There is no nand chip on cs 0!\n"); |
| 1037 | this->ecc.size = info->page_size; | 900 | |
| 1038 | 901 | return -EINVAL; | |
| 1039 | if (info->page_size == 2048) | 902 | } |
| 1040 | this->ecc.layout = &hw_largepage_ecclayout; | 903 | |
| 904 | chip->cmdfunc(mtd, NAND_CMD_READID, 0, 0); | ||
| 905 | id = *((uint16_t *)(info->data_buff)); | ||
| 906 | if (id != 0) | ||
| 907 | printk(KERN_INFO "Detect a flash id %x\n", id); | ||
| 908 | else { | ||
| 909 | kfree(mtd); | ||
| 910 | info->mtd = NULL; | ||
| 911 | printk(KERN_WARNING "Read out ID 0, potential timing set wrong!!\n"); | ||
| 912 | |||
| 913 | return -EINVAL; | ||
| 914 | } | ||
| 915 | |||
| 916 | num = ARRAY_SIZE(builtin_flash_types) + pdata->num_flash - 1; | ||
| 917 | for (i = 0; i < num; i++) { | ||
| 918 | if (i < pdata->num_flash) | ||
| 919 | f = pdata->flash + i; | ||
| 920 | else | ||
| 921 | f = &builtin_flash_types[i - pdata->num_flash + 1]; | ||
| 922 | |||
| 923 | /* find the chip in default list */ | ||
| 924 | if (f->chip_id == id) | ||
| 925 | break; | ||
| 926 | } | ||
| 927 | |||
| 928 | if (i >= (ARRAY_SIZE(builtin_flash_types) + pdata->num_flash - 1)) { | ||
| 929 | kfree(mtd); | ||
| 930 | info->mtd = NULL; | ||
| 931 | printk(KERN_ERR "ERROR!! flash not defined!!!\n"); | ||
| 932 | |||
| 933 | return -EINVAL; | ||
| 934 | } | ||
| 935 | |||
| 936 | pxa3xx_nand_config_flash(info, f); | ||
| 937 | pxa3xx_flash_ids[0].name = f->name; | ||
| 938 | pxa3xx_flash_ids[0].id = (f->chip_id >> 8) & 0xffff; | ||
| 939 | pxa3xx_flash_ids[0].pagesize = f->page_size; | ||
| 940 | chipsize = (uint64_t)f->num_blocks * f->page_per_block * f->page_size; | ||
| 941 | pxa3xx_flash_ids[0].chipsize = chipsize >> 20; | ||
| 942 | pxa3xx_flash_ids[0].erasesize = f->page_size * f->page_per_block; | ||
| 943 | if (f->flash_width == 16) | ||
| 944 | pxa3xx_flash_ids[0].options = NAND_BUSWIDTH_16; | ||
| 945 | KEEP_CONFIG: | ||
| 946 | if (nand_scan_ident(mtd, 1, pxa3xx_flash_ids)) | ||
| 947 | return -ENODEV; | ||
| 948 | /* calculate addressing information */ | ||
| 949 | info->col_addr_cycles = (mtd->writesize >= 2048) ? 2 : 1; | ||
| 950 | info->oob_buff = info->data_buff + mtd->writesize; | ||
| 951 | if ((mtd->size >> chip->page_shift) > 65536) | ||
| 952 | info->row_addr_cycles = 3; | ||
| 1041 | else | 953 | else |
| 1042 | this->ecc.layout = &hw_smallpage_ecclayout; | 954 | info->row_addr_cycles = 2; |
| 955 | mtd->name = mtd_names[0]; | ||
| 956 | chip->ecc.mode = NAND_ECC_HW; | ||
| 957 | chip->ecc.size = f->page_size; | ||
| 958 | |||
| 959 | chip->options = (f->flash_width == 16) ? NAND_BUSWIDTH_16 : 0; | ||
| 960 | chip->options |= NAND_NO_AUTOINCR; | ||
| 961 | chip->options |= NAND_NO_READRDY; | ||
| 1043 | 962 | ||
| 1044 | this->chip_delay = 25; | 963 | return nand_scan_tail(mtd); |
| 1045 | } | 964 | } |
| 1046 | 965 | ||
| 1047 | static int pxa3xx_nand_probe(struct platform_device *pdev) | 966 | static |
| 967 | struct pxa3xx_nand_info *alloc_nand_resource(struct platform_device *pdev) | ||
| 1048 | { | 968 | { |
| 1049 | struct pxa3xx_nand_platform_data *pdata; | ||
| 1050 | struct pxa3xx_nand_info *info; | 969 | struct pxa3xx_nand_info *info; |
| 1051 | struct nand_chip *this; | 970 | struct nand_chip *chip; |
| 1052 | struct mtd_info *mtd; | 971 | struct mtd_info *mtd; |
| 1053 | struct resource *r; | 972 | struct resource *r; |
| 1054 | int ret = 0, irq; | 973 | int ret, irq; |
| 1055 | |||
| 1056 | pdata = pdev->dev.platform_data; | ||
| 1057 | |||
| 1058 | if (!pdata) { | ||
| 1059 | dev_err(&pdev->dev, "no platform data defined\n"); | ||
| 1060 | return -ENODEV; | ||
| 1061 | } | ||
| 1062 | 974 | ||
| 1063 | mtd = kzalloc(sizeof(struct mtd_info) + sizeof(struct pxa3xx_nand_info), | 975 | mtd = kzalloc(sizeof(struct mtd_info) + sizeof(struct pxa3xx_nand_info), |
| 1064 | GFP_KERNEL); | 976 | GFP_KERNEL); |
| 1065 | if (!mtd) { | 977 | if (!mtd) { |
| 1066 | dev_err(&pdev->dev, "failed to allocate memory\n"); | 978 | dev_err(&pdev->dev, "failed to allocate memory\n"); |
| 1067 | return -ENOMEM; | 979 | return NULL; |
| 1068 | } | 980 | } |
| 1069 | 981 | ||
| 1070 | info = (struct pxa3xx_nand_info *)(&mtd[1]); | 982 | info = (struct pxa3xx_nand_info *)(&mtd[1]); |
| 983 | chip = (struct nand_chip *)(&mtd[1]); | ||
| 1071 | info->pdev = pdev; | 984 | info->pdev = pdev; |
| 1072 | 985 | info->mtd = mtd; | |
| 1073 | this = &info->nand_chip; | ||
| 1074 | mtd->priv = info; | 986 | mtd->priv = info; |
| 1075 | mtd->owner = THIS_MODULE; | 987 | mtd->owner = THIS_MODULE; |
| 1076 | 988 | ||
| 989 | chip->ecc.read_page = pxa3xx_nand_read_page_hwecc; | ||
| 990 | chip->ecc.write_page = pxa3xx_nand_write_page_hwecc; | ||
| 991 | chip->controller = &info->controller; | ||
| 992 | chip->waitfunc = pxa3xx_nand_waitfunc; | ||
| 993 | chip->select_chip = pxa3xx_nand_select_chip; | ||
| 994 | chip->dev_ready = pxa3xx_nand_dev_ready; | ||
| 995 | chip->cmdfunc = pxa3xx_nand_cmdfunc; | ||
| 996 | chip->read_word = pxa3xx_nand_read_word; | ||
| 997 | chip->read_byte = pxa3xx_nand_read_byte; | ||
| 998 | chip->read_buf = pxa3xx_nand_read_buf; | ||
| 999 | chip->write_buf = pxa3xx_nand_write_buf; | ||
| 1000 | chip->verify_buf = pxa3xx_nand_verify_buf; | ||
| 1001 | |||
| 1002 | spin_lock_init(&chip->controller->lock); | ||
| 1003 | init_waitqueue_head(&chip->controller->wq); | ||
| 1077 | info->clk = clk_get(&pdev->dev, NULL); | 1004 | info->clk = clk_get(&pdev->dev, NULL); |
| 1078 | if (IS_ERR(info->clk)) { | 1005 | if (IS_ERR(info->clk)) { |
| 1079 | dev_err(&pdev->dev, "failed to get nand clock\n"); | 1006 | dev_err(&pdev->dev, "failed to get nand clock\n"); |
| @@ -1141,43 +1068,12 @@ static int pxa3xx_nand_probe(struct platform_device *pdev) | |||
| 1141 | goto fail_free_buf; | 1068 | goto fail_free_buf; |
| 1142 | } | 1069 | } |
| 1143 | 1070 | ||
| 1144 | ret = pxa3xx_nand_detect_flash(info, pdata); | 1071 | platform_set_drvdata(pdev, info); |
| 1145 | if (ret) { | ||
| 1146 | dev_err(&pdev->dev, "failed to detect flash\n"); | ||
| 1147 | ret = -ENODEV; | ||
| 1148 | goto fail_free_irq; | ||
| 1149 | } | ||
| 1150 | |||
| 1151 | pxa3xx_nand_init_mtd(mtd, info); | ||
| 1152 | |||
| 1153 | platform_set_drvdata(pdev, mtd); | ||
| 1154 | |||
| 1155 | if (nand_scan(mtd, 1)) { | ||
| 1156 | dev_err(&pdev->dev, "failed to scan nand\n"); | ||
| 1157 | ret = -ENXIO; | ||
| 1158 | goto fail_free_irq; | ||
| 1159 | } | ||
| 1160 | |||
| 1161 | #ifdef CONFIG_MTD_PARTITIONS | ||
| 1162 | if (mtd_has_cmdlinepart()) { | ||
| 1163 | static const char *probes[] = { "cmdlinepart", NULL }; | ||
| 1164 | struct mtd_partition *parts; | ||
| 1165 | int nr_parts; | ||
| 1166 | |||
| 1167 | nr_parts = parse_mtd_partitions(mtd, probes, &parts, 0); | ||
| 1168 | |||
| 1169 | if (nr_parts) | ||
| 1170 | return add_mtd_partitions(mtd, parts, nr_parts); | ||
| 1171 | } | ||
| 1172 | 1072 | ||
| 1173 | return add_mtd_partitions(mtd, pdata->parts, pdata->nr_parts); | 1073 | return info; |
| 1174 | #else | ||
| 1175 | return 0; | ||
| 1176 | #endif | ||
| 1177 | 1074 | ||
| 1178 | fail_free_irq: | ||
| 1179 | free_irq(irq, info); | ||
| 1180 | fail_free_buf: | 1075 | fail_free_buf: |
| 1076 | free_irq(irq, info); | ||
| 1181 | if (use_dma) { | 1077 | if (use_dma) { |
| 1182 | pxa_free_dma(info->data_dma_ch); | 1078 | pxa_free_dma(info->data_dma_ch); |
| 1183 | dma_free_coherent(&pdev->dev, info->data_buff_size, | 1079 | dma_free_coherent(&pdev->dev, info->data_buff_size, |
| @@ -1193,22 +1089,18 @@ fail_put_clk: | |||
| 1193 | clk_put(info->clk); | 1089 | clk_put(info->clk); |
| 1194 | fail_free_mtd: | 1090 | fail_free_mtd: |
| 1195 | kfree(mtd); | 1091 | kfree(mtd); |
| 1196 | return ret; | 1092 | return NULL; |
| 1197 | } | 1093 | } |
| 1198 | 1094 | ||
| 1199 | static int pxa3xx_nand_remove(struct platform_device *pdev) | 1095 | static int pxa3xx_nand_remove(struct platform_device *pdev) |
| 1200 | { | 1096 | { |
| 1201 | struct mtd_info *mtd = platform_get_drvdata(pdev); | 1097 | struct pxa3xx_nand_info *info = platform_get_drvdata(pdev); |
| 1202 | struct pxa3xx_nand_info *info = mtd->priv; | 1098 | struct mtd_info *mtd = info->mtd; |
| 1203 | struct resource *r; | 1099 | struct resource *r; |
| 1204 | int irq; | 1100 | int irq; |
| 1205 | 1101 | ||
| 1206 | platform_set_drvdata(pdev, NULL); | 1102 | platform_set_drvdata(pdev, NULL); |
| 1207 | 1103 | ||
| 1208 | del_mtd_device(mtd); | ||
| 1209 | #ifdef CONFIG_MTD_PARTITIONS | ||
| 1210 | del_mtd_partitions(mtd); | ||
| 1211 | #endif | ||
| 1212 | irq = platform_get_irq(pdev, 0); | 1104 | irq = platform_get_irq(pdev, 0); |
| 1213 | if (irq >= 0) | 1105 | if (irq >= 0) |
| 1214 | free_irq(irq, info); | 1106 | free_irq(irq, info); |
| @@ -1226,17 +1118,62 @@ static int pxa3xx_nand_remove(struct platform_device *pdev) | |||
| 1226 | clk_disable(info->clk); | 1118 | clk_disable(info->clk); |
| 1227 | clk_put(info->clk); | 1119 | clk_put(info->clk); |
| 1228 | 1120 | ||
| 1229 | kfree(mtd); | 1121 | if (mtd) { |
| 1122 | del_mtd_device(mtd); | ||
| 1123 | #ifdef CONFIG_MTD_PARTITIONS | ||
| 1124 | del_mtd_partitions(mtd); | ||
| 1125 | #endif | ||
| 1126 | kfree(mtd); | ||
| 1127 | } | ||
| 1230 | return 0; | 1128 | return 0; |
| 1231 | } | 1129 | } |
| 1232 | 1130 | ||
| 1131 | static int pxa3xx_nand_probe(struct platform_device *pdev) | ||
| 1132 | { | ||
| 1133 | struct pxa3xx_nand_platform_data *pdata; | ||
| 1134 | struct pxa3xx_nand_info *info; | ||
| 1135 | |||
| 1136 | pdata = pdev->dev.platform_data; | ||
| 1137 | if (!pdata) { | ||
| 1138 | dev_err(&pdev->dev, "no platform data defined\n"); | ||
| 1139 | return -ENODEV; | ||
| 1140 | } | ||
| 1141 | |||
| 1142 | info = alloc_nand_resource(pdev); | ||
| 1143 | if (info == NULL) | ||
| 1144 | return -ENOMEM; | ||
| 1145 | |||
| 1146 | if (pxa3xx_nand_scan(info->mtd)) { | ||
| 1147 | dev_err(&pdev->dev, "failed to scan nand\n"); | ||
| 1148 | pxa3xx_nand_remove(pdev); | ||
| 1149 | return -ENODEV; | ||
| 1150 | } | ||
| 1151 | |||
| 1152 | #ifdef CONFIG_MTD_PARTITIONS | ||
| 1153 | if (mtd_has_cmdlinepart()) { | ||
| 1154 | const char *probes[] = { "cmdlinepart", NULL }; | ||
| 1155 | struct mtd_partition *parts; | ||
| 1156 | int nr_parts; | ||
| 1157 | |||
| 1158 | nr_parts = parse_mtd_partitions(info->mtd, probes, &parts, 0); | ||
| 1159 | |||
| 1160 | if (nr_parts) | ||
| 1161 | return add_mtd_partitions(info->mtd, parts, nr_parts); | ||
| 1162 | } | ||
| 1163 | |||
| 1164 | return add_mtd_partitions(info->mtd, pdata->parts, pdata->nr_parts); | ||
| 1165 | #else | ||
| 1166 | return 0; | ||
| 1167 | #endif | ||
| 1168 | } | ||
| 1169 | |||
| 1233 | #ifdef CONFIG_PM | 1170 | #ifdef CONFIG_PM |
| 1234 | static int pxa3xx_nand_suspend(struct platform_device *pdev, pm_message_t state) | 1171 | static int pxa3xx_nand_suspend(struct platform_device *pdev, pm_message_t state) |
| 1235 | { | 1172 | { |
| 1236 | struct mtd_info *mtd = (struct mtd_info *)platform_get_drvdata(pdev); | 1173 | struct pxa3xx_nand_info *info = platform_get_drvdata(pdev); |
| 1237 | struct pxa3xx_nand_info *info = mtd->priv; | 1174 | struct mtd_info *mtd = info->mtd; |
| 1238 | 1175 | ||
| 1239 | if (info->state != STATE_READY) { | 1176 | if (info->state) { |
| 1240 | dev_err(&pdev->dev, "driver busy, state = %d\n", info->state); | 1177 | dev_err(&pdev->dev, "driver busy, state = %d\n", info->state); |
| 1241 | return -EAGAIN; | 1178 | return -EAGAIN; |
| 1242 | } | 1179 | } |
| @@ -1246,8 +1183,8 @@ static int pxa3xx_nand_suspend(struct platform_device *pdev, pm_message_t state) | |||
| 1246 | 1183 | ||
| 1247 | static int pxa3xx_nand_resume(struct platform_device *pdev) | 1184 | static int pxa3xx_nand_resume(struct platform_device *pdev) |
| 1248 | { | 1185 | { |
| 1249 | struct mtd_info *mtd = (struct mtd_info *)platform_get_drvdata(pdev); | 1186 | struct pxa3xx_nand_info *info = platform_get_drvdata(pdev); |
| 1250 | struct pxa3xx_nand_info *info = mtd->priv; | 1187 | struct mtd_info *mtd = info->mtd; |
| 1251 | 1188 | ||
| 1252 | nand_writel(info, NDTR0CS0, info->ndtr0cs0); | 1189 | nand_writel(info, NDTR0CS0, info->ndtr0cs0); |
| 1253 | nand_writel(info, NDTR1CS0, info->ndtr1cs0); | 1190 | nand_writel(info, NDTR1CS0, info->ndtr1cs0); |
diff --git a/drivers/mtd/onenand/omap2.c b/drivers/mtd/onenand/omap2.c index 14a49abe057..f591f615d3f 100644 --- a/drivers/mtd/onenand/omap2.c +++ b/drivers/mtd/onenand/omap2.c | |||
| @@ -629,6 +629,7 @@ static int __devinit omap2_onenand_probe(struct platform_device *pdev) | |||
| 629 | { | 629 | { |
| 630 | struct omap_onenand_platform_data *pdata; | 630 | struct omap_onenand_platform_data *pdata; |
| 631 | struct omap2_onenand *c; | 631 | struct omap2_onenand *c; |
| 632 | struct onenand_chip *this; | ||
| 632 | int r; | 633 | int r; |
| 633 | 634 | ||
| 634 | pdata = pdev->dev.platform_data; | 635 | pdata = pdev->dev.platform_data; |
| @@ -726,9 +727,8 @@ static int __devinit omap2_onenand_probe(struct platform_device *pdev) | |||
| 726 | 727 | ||
| 727 | c->mtd.dev.parent = &pdev->dev; | 728 | c->mtd.dev.parent = &pdev->dev; |
| 728 | 729 | ||
| 730 | this = &c->onenand; | ||
| 729 | if (c->dma_channel >= 0) { | 731 | if (c->dma_channel >= 0) { |
| 730 | struct onenand_chip *this = &c->onenand; | ||
| 731 | |||
| 732 | this->wait = omap2_onenand_wait; | 732 | this->wait = omap2_onenand_wait; |
| 733 | if (cpu_is_omap34xx()) { | 733 | if (cpu_is_omap34xx()) { |
| 734 | this->read_bufferram = omap3_onenand_read_bufferram; | 734 | this->read_bufferram = omap3_onenand_read_bufferram; |
| @@ -749,6 +749,9 @@ static int __devinit omap2_onenand_probe(struct platform_device *pdev) | |||
| 749 | c->onenand.disable = omap2_onenand_disable; | 749 | c->onenand.disable = omap2_onenand_disable; |
| 750 | } | 750 | } |
| 751 | 751 | ||
| 752 | if (pdata->skip_initial_unlocking) | ||
| 753 | this->options |= ONENAND_SKIP_INITIAL_UNLOCKING; | ||
| 754 | |||
| 752 | if ((r = onenand_scan(&c->mtd, 1)) < 0) | 755 | if ((r = onenand_scan(&c->mtd, 1)) < 0) |
| 753 | goto err_release_regulator; | 756 | goto err_release_regulator; |
| 754 | 757 | ||
diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c index bac41caa8df..56a8b2005bd 100644 --- a/drivers/mtd/onenand/onenand_base.c +++ b/drivers/mtd/onenand/onenand_base.c | |||
| @@ -1132,6 +1132,8 @@ static int onenand_mlc_read_ops_nolock(struct mtd_info *mtd, loff_t from, | |||
| 1132 | onenand_update_bufferram(mtd, from, !ret); | 1132 | onenand_update_bufferram(mtd, from, !ret); |
| 1133 | if (ret == -EBADMSG) | 1133 | if (ret == -EBADMSG) |
| 1134 | ret = 0; | 1134 | ret = 0; |
| 1135 | if (ret) | ||
| 1136 | break; | ||
| 1135 | } | 1137 | } |
| 1136 | 1138 | ||
| 1137 | this->read_bufferram(mtd, ONENAND_DATARAM, buf, column, thislen); | 1139 | this->read_bufferram(mtd, ONENAND_DATARAM, buf, column, thislen); |
| @@ -1646,11 +1648,10 @@ static int onenand_verify(struct mtd_info *mtd, const u_char *buf, loff_t addr, | |||
| 1646 | int ret = 0; | 1648 | int ret = 0; |
| 1647 | int thislen, column; | 1649 | int thislen, column; |
| 1648 | 1650 | ||
| 1651 | column = addr & (this->writesize - 1); | ||
| 1652 | |||
| 1649 | while (len != 0) { | 1653 | while (len != 0) { |
| 1650 | thislen = min_t(int, this->writesize, len); | 1654 | thislen = min_t(int, this->writesize - column, len); |
| 1651 | column = addr & (this->writesize - 1); | ||
| 1652 | if (column + thislen > this->writesize) | ||
| 1653 | thislen = this->writesize - column; | ||
| 1654 | 1655 | ||
| 1655 | this->command(mtd, ONENAND_CMD_READ, addr, this->writesize); | 1656 | this->command(mtd, ONENAND_CMD_READ, addr, this->writesize); |
| 1656 | 1657 | ||
| @@ -1664,12 +1665,13 @@ static int onenand_verify(struct mtd_info *mtd, const u_char *buf, loff_t addr, | |||
| 1664 | 1665 | ||
| 1665 | this->read_bufferram(mtd, ONENAND_DATARAM, this->verify_buf, 0, mtd->writesize); | 1666 | this->read_bufferram(mtd, ONENAND_DATARAM, this->verify_buf, 0, mtd->writesize); |
| 1666 | 1667 | ||
| 1667 | if (memcmp(buf, this->verify_buf, thislen)) | 1668 | if (memcmp(buf, this->verify_buf + column, thislen)) |
| 1668 | return -EBADMSG; | 1669 | return -EBADMSG; |
| 1669 | 1670 | ||
| 1670 | len -= thislen; | 1671 | len -= thislen; |
| 1671 | buf += thislen; | 1672 | buf += thislen; |
| 1672 | addr += thislen; | 1673 | addr += thislen; |
| 1674 | column = 0; | ||
| 1673 | } | 1675 | } |
| 1674 | 1676 | ||
| 1675 | return 0; | 1677 | return 0; |
| @@ -4083,7 +4085,8 @@ int onenand_scan(struct mtd_info *mtd, int maxchips) | |||
| 4083 | mtd->writebufsize = mtd->writesize; | 4085 | mtd->writebufsize = mtd->writesize; |
| 4084 | 4086 | ||
| 4085 | /* Unlock whole block */ | 4087 | /* Unlock whole block */ |
| 4086 | this->unlock_all(mtd); | 4088 | if (!(this->options & ONENAND_SKIP_INITIAL_UNLOCKING)) |
| 4089 | this->unlock_all(mtd); | ||
| 4087 | 4090 | ||
| 4088 | ret = this->scan_bbt(mtd); | 4091 | ret = this->scan_bbt(mtd); |
| 4089 | if ((!FLEXONENAND(this)) || ret) | 4092 | if ((!FLEXONENAND(this)) || ret) |
diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c index ac0d6a8613b..2b0daae4018 100644 --- a/drivers/mtd/sm_ftl.c +++ b/drivers/mtd/sm_ftl.c | |||
| @@ -64,12 +64,16 @@ struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl) | |||
| 64 | SM_SMALL_PAGE - SM_CIS_VENDOR_OFFSET); | 64 | SM_SMALL_PAGE - SM_CIS_VENDOR_OFFSET); |
| 65 | 65 | ||
| 66 | char *vendor = kmalloc(vendor_len, GFP_KERNEL); | 66 | char *vendor = kmalloc(vendor_len, GFP_KERNEL); |
| 67 | if (!vendor) | ||
| 68 | goto error1; | ||
| 67 | memcpy(vendor, ftl->cis_buffer + SM_CIS_VENDOR_OFFSET, vendor_len); | 69 | memcpy(vendor, ftl->cis_buffer + SM_CIS_VENDOR_OFFSET, vendor_len); |
| 68 | vendor[vendor_len] = 0; | 70 | vendor[vendor_len] = 0; |
| 69 | 71 | ||
| 70 | /* Initialize sysfs attributes */ | 72 | /* Initialize sysfs attributes */ |
| 71 | vendor_attribute = | 73 | vendor_attribute = |
| 72 | kzalloc(sizeof(struct sm_sysfs_attribute), GFP_KERNEL); | 74 | kzalloc(sizeof(struct sm_sysfs_attribute), GFP_KERNEL); |
| 75 | if (!vendor_attribute) | ||
| 76 | goto error2; | ||
| 73 | 77 | ||
| 74 | sysfs_attr_init(&vendor_attribute->dev_attr.attr); | 78 | sysfs_attr_init(&vendor_attribute->dev_attr.attr); |
| 75 | 79 | ||
| @@ -83,12 +87,24 @@ struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl) | |||
| 83 | /* Create array of pointers to the attributes */ | 87 | /* Create array of pointers to the attributes */ |
| 84 | attributes = kzalloc(sizeof(struct attribute *) * (NUM_ATTRIBUTES + 1), | 88 | attributes = kzalloc(sizeof(struct attribute *) * (NUM_ATTRIBUTES + 1), |
| 85 | GFP_KERNEL); | 89 | GFP_KERNEL); |
| 90 | if (!attributes) | ||
| 91 | goto error3; | ||
| 86 | attributes[0] = &vendor_attribute->dev_attr.attr; | 92 | attributes[0] = &vendor_attribute->dev_attr.attr; |
| 87 | 93 | ||
| 88 | /* Finally create the attribute group */ | 94 | /* Finally create the attribute group */ |
| 89 | attr_group = kzalloc(sizeof(struct attribute_group), GFP_KERNEL); | 95 | attr_group = kzalloc(sizeof(struct attribute_group), GFP_KERNEL); |
| 96 | if (!attr_group) | ||
| 97 | goto error4; | ||
| 90 | attr_group->attrs = attributes; | 98 | attr_group->attrs = attributes; |
| 91 | return attr_group; | 99 | return attr_group; |
| 100 | error4: | ||
| 101 | kfree(attributes); | ||
| 102 | error3: | ||
| 103 | kfree(vendor_attribute); | ||
| 104 | error2: | ||
| 105 | kfree(vendor); | ||
| 106 | error1: | ||
| 107 | return NULL; | ||
| 92 | } | 108 | } |
| 93 | 109 | ||
| 94 | void sm_delete_sysfs_attributes(struct sm_ftl *ftl) | 110 | void sm_delete_sysfs_attributes(struct sm_ftl *ftl) |
| @@ -1178,6 +1194,8 @@ static void sm_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) | |||
| 1178 | } | 1194 | } |
| 1179 | 1195 | ||
| 1180 | ftl->disk_attributes = sm_create_sysfs_attributes(ftl); | 1196 | ftl->disk_attributes = sm_create_sysfs_attributes(ftl); |
| 1197 | if (!ftl->disk_attributes) | ||
| 1198 | goto error6; | ||
| 1181 | trans->disk_attributes = ftl->disk_attributes; | 1199 | trans->disk_attributes = ftl->disk_attributes; |
| 1182 | 1200 | ||
| 1183 | sm_printk("Found %d MiB xD/SmartMedia FTL on mtd%d", | 1201 | sm_printk("Found %d MiB xD/SmartMedia FTL on mtd%d", |
diff --git a/drivers/mtd/tests/mtd_speedtest.c b/drivers/mtd/tests/mtd_speedtest.c index 161feeb7b8b..627d4e2466a 100644 --- a/drivers/mtd/tests/mtd_speedtest.c +++ b/drivers/mtd/tests/mtd_speedtest.c | |||
| @@ -16,7 +16,7 @@ | |||
| 16 | * | 16 | * |
| 17 | * Test read and write speed of a MTD device. | 17 | * Test read and write speed of a MTD device. |
| 18 | * | 18 | * |
| 19 | * Author: Adrian Hunter <ext-adrian.hunter@nokia.com> | 19 | * Author: Adrian Hunter <adrian.hunter@nokia.com> |
| 20 | */ | 20 | */ |
| 21 | 21 | ||
| 22 | #include <linux/init.h> | 22 | #include <linux/init.h> |
| @@ -33,6 +33,11 @@ static int dev; | |||
| 33 | module_param(dev, int, S_IRUGO); | 33 | module_param(dev, int, S_IRUGO); |
| 34 | MODULE_PARM_DESC(dev, "MTD device number to use"); | 34 | MODULE_PARM_DESC(dev, "MTD device number to use"); |
| 35 | 35 | ||
| 36 | static int count; | ||
| 37 | module_param(count, int, S_IRUGO); | ||
| 38 | MODULE_PARM_DESC(count, "Maximum number of eraseblocks to use " | ||
| 39 | "(0 means use all)"); | ||
| 40 | |||
| 36 | static struct mtd_info *mtd; | 41 | static struct mtd_info *mtd; |
| 37 | static unsigned char *iobuf; | 42 | static unsigned char *iobuf; |
| 38 | static unsigned char *bbt; | 43 | static unsigned char *bbt; |
| @@ -89,6 +94,33 @@ static int erase_eraseblock(int ebnum) | |||
| 89 | return 0; | 94 | return 0; |
| 90 | } | 95 | } |
| 91 | 96 | ||
| 97 | static int multiblock_erase(int ebnum, int blocks) | ||
| 98 | { | ||
| 99 | int err; | ||
| 100 | struct erase_info ei; | ||
| 101 | loff_t addr = ebnum * mtd->erasesize; | ||
| 102 | |||
| 103 | memset(&ei, 0, sizeof(struct erase_info)); | ||
| 104 | ei.mtd = mtd; | ||
| 105 | ei.addr = addr; | ||
| 106 | ei.len = mtd->erasesize * blocks; | ||
| 107 | |||
| 108 | err = mtd->erase(mtd, &ei); | ||
| 109 | if (err) { | ||
| 110 | printk(PRINT_PREF "error %d while erasing EB %d, blocks %d\n", | ||
| 111 | err, ebnum, blocks); | ||
| 112 | return err; | ||
| 113 | } | ||
| 114 | |||
| 115 | if (ei.state == MTD_ERASE_FAILED) { | ||
| 116 | printk(PRINT_PREF "some erase error occurred at EB %d," | ||
| 117 | "blocks %d\n", ebnum, blocks); | ||
| 118 | return -EIO; | ||
| 119 | } | ||
| 120 | |||
| 121 | return 0; | ||
| 122 | } | ||
| 123 | |||
| 92 | static int erase_whole_device(void) | 124 | static int erase_whole_device(void) |
| 93 | { | 125 | { |
| 94 | int err; | 126 | int err; |
| @@ -282,13 +314,16 @@ static inline void stop_timing(void) | |||
| 282 | 314 | ||
| 283 | static long calc_speed(void) | 315 | static long calc_speed(void) |
| 284 | { | 316 | { |
| 285 | long ms, k, speed; | 317 | uint64_t k; |
| 318 | long ms; | ||
| 286 | 319 | ||
| 287 | ms = (finish.tv_sec - start.tv_sec) * 1000 + | 320 | ms = (finish.tv_sec - start.tv_sec) * 1000 + |
| 288 | (finish.tv_usec - start.tv_usec) / 1000; | 321 | (finish.tv_usec - start.tv_usec) / 1000; |
| 289 | k = goodebcnt * mtd->erasesize / 1024; | 322 | if (ms == 0) |
| 290 | speed = (k * 1000) / ms; | 323 | return 0; |
| 291 | return speed; | 324 | k = goodebcnt * (mtd->erasesize / 1024) * 1000; |
| 325 | do_div(k, ms); | ||
| 326 | return k; | ||
| 292 | } | 327 | } |
| 293 | 328 | ||
| 294 | static int scan_for_bad_eraseblocks(void) | 329 | static int scan_for_bad_eraseblocks(void) |
| @@ -320,13 +355,16 @@ out: | |||
| 320 | 355 | ||
| 321 | static int __init mtd_speedtest_init(void) | 356 | static int __init mtd_speedtest_init(void) |
| 322 | { | 357 | { |
| 323 | int err, i; | 358 | int err, i, blocks, j, k; |
| 324 | long speed; | 359 | long speed; |
| 325 | uint64_t tmp; | 360 | uint64_t tmp; |
| 326 | 361 | ||
| 327 | printk(KERN_INFO "\n"); | 362 | printk(KERN_INFO "\n"); |
| 328 | printk(KERN_INFO "=================================================\n"); | 363 | printk(KERN_INFO "=================================================\n"); |
| 329 | printk(PRINT_PREF "MTD device: %d\n", dev); | 364 | if (count) |
| 365 | printk(PRINT_PREF "MTD device: %d count: %d\n", dev, count); | ||
| 366 | else | ||
| 367 | printk(PRINT_PREF "MTD device: %d\n", dev); | ||
| 330 | 368 | ||
| 331 | mtd = get_mtd_device(NULL, dev); | 369 | mtd = get_mtd_device(NULL, dev); |
| 332 | if (IS_ERR(mtd)) { | 370 | if (IS_ERR(mtd)) { |
| @@ -353,6 +391,9 @@ static int __init mtd_speedtest_init(void) | |||
| 353 | (unsigned long long)mtd->size, mtd->erasesize, | 391 | (unsigned long long)mtd->size, mtd->erasesize, |
| 354 | pgsize, ebcnt, pgcnt, mtd->oobsize); | 392 | pgsize, ebcnt, pgcnt, mtd->oobsize); |
| 355 | 393 | ||
| 394 | if (count > 0 && count < ebcnt) | ||
| 395 | ebcnt = count; | ||
| 396 | |||
| 356 | err = -ENOMEM; | 397 | err = -ENOMEM; |
| 357 | iobuf = kmalloc(mtd->erasesize, GFP_KERNEL); | 398 | iobuf = kmalloc(mtd->erasesize, GFP_KERNEL); |
| 358 | if (!iobuf) { | 399 | if (!iobuf) { |
| @@ -484,6 +525,31 @@ static int __init mtd_speedtest_init(void) | |||
| 484 | speed = calc_speed(); | 525 | speed = calc_speed(); |
| 485 | printk(PRINT_PREF "erase speed is %ld KiB/s\n", speed); | 526 | printk(PRINT_PREF "erase speed is %ld KiB/s\n", speed); |
| 486 | 527 | ||
| 528 | /* Multi-block erase all eraseblocks */ | ||
| 529 | for (k = 1; k < 7; k++) { | ||
| 530 | blocks = 1 << k; | ||
| 531 | printk(PRINT_PREF "Testing %dx multi-block erase speed\n", | ||
| 532 | blocks); | ||
| 533 | start_timing(); | ||
| 534 | for (i = 0; i < ebcnt; ) { | ||
| 535 | for (j = 0; j < blocks && (i + j) < ebcnt; j++) | ||
| 536 | if (bbt[i + j]) | ||
| 537 | break; | ||
| 538 | if (j < 1) { | ||
| 539 | i++; | ||
| 540 | continue; | ||
| 541 | } | ||
| 542 | err = multiblock_erase(i, j); | ||
| 543 | if (err) | ||
| 544 | goto out; | ||
| 545 | cond_resched(); | ||
| 546 | i += j; | ||
| 547 | } | ||
| 548 | stop_timing(); | ||
| 549 | speed = calc_speed(); | ||
| 550 | printk(PRINT_PREF "%dx multi-block erase speed is %ld KiB/s\n", | ||
| 551 | blocks, speed); | ||
| 552 | } | ||
| 487 | printk(PRINT_PREF "finished\n"); | 553 | printk(PRINT_PREF "finished\n"); |
| 488 | out: | 554 | out: |
| 489 | kfree(iobuf); | 555 | kfree(iobuf); |
diff --git a/drivers/mtd/tests/mtd_subpagetest.c b/drivers/mtd/tests/mtd_subpagetest.c index 11204e8aab5..334eae53a3d 100644 --- a/drivers/mtd/tests/mtd_subpagetest.c +++ b/drivers/mtd/tests/mtd_subpagetest.c | |||
| @@ -394,6 +394,11 @@ static int __init mtd_subpagetest_init(void) | |||
| 394 | } | 394 | } |
| 395 | 395 | ||
| 396 | subpgsize = mtd->writesize >> mtd->subpage_sft; | 396 | subpgsize = mtd->writesize >> mtd->subpage_sft; |
| 397 | tmp = mtd->size; | ||
| 398 | do_div(tmp, mtd->erasesize); | ||
| 399 | ebcnt = tmp; | ||
| 400 | pgcnt = mtd->erasesize / mtd->writesize; | ||
| 401 | |||
| 397 | printk(PRINT_PREF "MTD device size %llu, eraseblock size %u, " | 402 | printk(PRINT_PREF "MTD device size %llu, eraseblock size %u, " |
| 398 | "page size %u, subpage size %u, count of eraseblocks %u, " | 403 | "page size %u, subpage size %u, count of eraseblocks %u, " |
| 399 | "pages per eraseblock %u, OOB size %u\n", | 404 | "pages per eraseblock %u, OOB size %u\n", |
| @@ -413,11 +418,6 @@ static int __init mtd_subpagetest_init(void) | |||
| 413 | goto out; | 418 | goto out; |
| 414 | } | 419 | } |
| 415 | 420 | ||
| 416 | tmp = mtd->size; | ||
| 417 | do_div(tmp, mtd->erasesize); | ||
| 418 | ebcnt = tmp; | ||
| 419 | pgcnt = mtd->erasesize / mtd->writesize; | ||
| 420 | |||
| 421 | err = scan_for_bad_eraseblocks(); | 421 | err = scan_for_bad_eraseblocks(); |
| 422 | if (err) | 422 | if (err) |
| 423 | goto out; | 423 | goto out; |
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index de75f67f4cc..b9f29e0d429 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig | |||
| @@ -126,7 +126,7 @@ config REGULATOR_MAX8998 | |||
| 126 | and S5PC1XX chips to control VCC_CORE and VCC_USIM voltages. | 126 | and S5PC1XX chips to control VCC_CORE and VCC_USIM voltages. |
| 127 | 127 | ||
| 128 | config REGULATOR_TWL4030 | 128 | config REGULATOR_TWL4030 |
| 129 | bool "TI TWL4030/TWL5030/TWL6030/TPS695x0 PMIC" | 129 | bool "TI TWL4030/TWL5030/TWL6030/TPS659x0 PMIC" |
| 130 | depends on TWL4030_CORE | 130 | depends on TWL4030_CORE |
| 131 | help | 131 | help |
| 132 | This driver supports the voltage regulators provided by | 132 | This driver supports the voltage regulators provided by |
diff --git a/drivers/regulator/ab3100.c b/drivers/regulator/ab3100.c index 2dec589a890..b1d77946e9c 100644 --- a/drivers/regulator/ab3100.c +++ b/drivers/regulator/ab3100.c | |||
| @@ -206,29 +206,6 @@ static int ab3100_enable_regulator(struct regulator_dev *reg) | |||
| 206 | return err; | 206 | return err; |
| 207 | } | 207 | } |
| 208 | 208 | ||
| 209 | /* Per-regulator power on delay from spec */ | ||
| 210 | switch (abreg->regreg) { | ||
| 211 | case AB3100_LDO_A: /* Fallthrough */ | ||
| 212 | case AB3100_LDO_C: /* Fallthrough */ | ||
| 213 | case AB3100_LDO_D: /* Fallthrough */ | ||
| 214 | case AB3100_LDO_E: /* Fallthrough */ | ||
| 215 | case AB3100_LDO_H: /* Fallthrough */ | ||
| 216 | case AB3100_LDO_K: | ||
| 217 | udelay(200); | ||
| 218 | break; | ||
| 219 | case AB3100_LDO_F: | ||
| 220 | udelay(600); | ||
| 221 | break; | ||
| 222 | case AB3100_LDO_G: | ||
| 223 | udelay(400); | ||
| 224 | break; | ||
| 225 | case AB3100_BUCK: | ||
| 226 | mdelay(1); | ||
| 227 | break; | ||
| 228 | default: | ||
| 229 | break; | ||
| 230 | } | ||
| 231 | |||
| 232 | return 0; | 209 | return 0; |
| 233 | } | 210 | } |
| 234 | 211 | ||
| @@ -450,11 +427,37 @@ static int ab3100_get_voltage_regulator_external(struct regulator_dev *reg) | |||
| 450 | return abreg->plfdata->external_voltage; | 427 | return abreg->plfdata->external_voltage; |
| 451 | } | 428 | } |
| 452 | 429 | ||
| 430 | static int ab3100_enable_time_regulator(struct regulator_dev *reg) | ||
| 431 | { | ||
| 432 | struct ab3100_regulator *abreg = reg->reg_data; | ||
| 433 | |||
| 434 | /* Per-regulator power on delay from spec */ | ||
| 435 | switch (abreg->regreg) { | ||
| 436 | case AB3100_LDO_A: /* Fallthrough */ | ||
| 437 | case AB3100_LDO_C: /* Fallthrough */ | ||
| 438 | case AB3100_LDO_D: /* Fallthrough */ | ||
| 439 | case AB3100_LDO_E: /* Fallthrough */ | ||
| 440 | case AB3100_LDO_H: /* Fallthrough */ | ||
| 441 | case AB3100_LDO_K: | ||
| 442 | return 200; | ||
| 443 | case AB3100_LDO_F: | ||
| 444 | return 600; | ||
| 445 | case AB3100_LDO_G: | ||
| 446 | return 400; | ||
| 447 | case AB3100_BUCK: | ||
| 448 | return 1000; | ||
| 449 | default: | ||
| 450 | break; | ||
| 451 | } | ||
| 452 | return 0; | ||
| 453 | } | ||
| 454 | |||
| 453 | static struct regulator_ops regulator_ops_fixed = { | 455 | static struct regulator_ops regulator_ops_fixed = { |
| 454 | .enable = ab3100_enable_regulator, | 456 | .enable = ab3100_enable_regulator, |
| 455 | .disable = ab3100_disable_regulator, | 457 | .disable = ab3100_disable_regulator, |
| 456 | .is_enabled = ab3100_is_enabled_regulator, | 458 | .is_enabled = ab3100_is_enabled_regulator, |
| 457 | .get_voltage = ab3100_get_voltage_regulator, | 459 | .get_voltage = ab3100_get_voltage_regulator, |
| 460 | .enable_time = ab3100_enable_time_regulator, | ||
| 458 | }; | 461 | }; |
| 459 | 462 | ||
| 460 | static struct regulator_ops regulator_ops_variable = { | 463 | static struct regulator_ops regulator_ops_variable = { |
| @@ -464,6 +467,7 @@ static struct regulator_ops regulator_ops_variable = { | |||
| 464 | .get_voltage = ab3100_get_voltage_regulator, | 467 | .get_voltage = ab3100_get_voltage_regulator, |
| 465 | .set_voltage = ab3100_set_voltage_regulator, | 468 | .set_voltage = ab3100_set_voltage_regulator, |
| 466 | .list_voltage = ab3100_list_voltage_regulator, | 469 | .list_voltage = ab3100_list_voltage_regulator, |
| 470 | .enable_time = ab3100_enable_time_regulator, | ||
| 467 | }; | 471 | }; |
| 468 | 472 | ||
| 469 | static struct regulator_ops regulator_ops_variable_sleepable = { | 473 | static struct regulator_ops regulator_ops_variable_sleepable = { |
| @@ -474,6 +478,7 @@ static struct regulator_ops regulator_ops_variable_sleepable = { | |||
| 474 | .set_voltage = ab3100_set_voltage_regulator, | 478 | .set_voltage = ab3100_set_voltage_regulator, |
| 475 | .set_suspend_voltage = ab3100_set_suspend_voltage_regulator, | 479 | .set_suspend_voltage = ab3100_set_suspend_voltage_regulator, |
| 476 | .list_voltage = ab3100_list_voltage_regulator, | 480 | .list_voltage = ab3100_list_voltage_regulator, |
| 481 | .enable_time = ab3100_enable_time_regulator, | ||
| 477 | }; | 482 | }; |
| 478 | 483 | ||
| 479 | /* | 484 | /* |
diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c index d9a052c53ae..02f3c2333c8 100644 --- a/drivers/regulator/ab8500.c +++ b/drivers/regulator/ab8500.c | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | * AB8500 peripheral regulators | 9 | * AB8500 peripheral regulators |
| 10 | * | 10 | * |
| 11 | * AB8500 supports the following regulators: | 11 | * AB8500 supports the following regulators: |
| 12 | * VAUX1/2/3, VINTCORE, VTVOUT, VAUDIO, VAMIC1/2, VDMIC, VANA | 12 | * VAUX1/2/3, VINTCORE, VTVOUT, VUSB, VAUDIO, VAMIC1/2, VDMIC, VANA |
| 13 | */ | 13 | */ |
| 14 | #include <linux/init.h> | 14 | #include <linux/init.h> |
| 15 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
| @@ -38,6 +38,7 @@ | |||
| 38 | * @voltage_mask: mask to control regulator voltage | 38 | * @voltage_mask: mask to control regulator voltage |
| 39 | * @voltages: supported voltage table | 39 | * @voltages: supported voltage table |
| 40 | * @voltages_len: number of supported voltages for the regulator | 40 | * @voltages_len: number of supported voltages for the regulator |
| 41 | * @delay: startup/set voltage delay in us | ||
| 41 | */ | 42 | */ |
| 42 | struct ab8500_regulator_info { | 43 | struct ab8500_regulator_info { |
| 43 | struct device *dev; | 44 | struct device *dev; |
| @@ -55,6 +56,7 @@ struct ab8500_regulator_info { | |||
| 55 | u8 voltage_mask; | 56 | u8 voltage_mask; |
| 56 | int const *voltages; | 57 | int const *voltages; |
| 57 | int voltages_len; | 58 | int voltages_len; |
| 59 | unsigned int delay; | ||
| 58 | }; | 60 | }; |
| 59 | 61 | ||
| 60 | /* voltage tables for the vauxn/vintcore supplies */ | 62 | /* voltage tables for the vauxn/vintcore supplies */ |
| @@ -290,6 +292,29 @@ static int ab8500_regulator_set_voltage(struct regulator_dev *rdev, | |||
| 290 | return ret; | 292 | return ret; |
| 291 | } | 293 | } |
| 292 | 294 | ||
| 295 | static int ab8500_regulator_enable_time(struct regulator_dev *rdev) | ||
| 296 | { | ||
| 297 | struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); | ||
| 298 | |||
| 299 | return info->delay; | ||
| 300 | } | ||
| 301 | |||
| 302 | static int ab8500_regulator_set_voltage_time_sel(struct regulator_dev *rdev, | ||
| 303 | unsigned int old_sel, | ||
| 304 | unsigned int new_sel) | ||
| 305 | { | ||
| 306 | struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); | ||
| 307 | int ret; | ||
| 308 | |||
| 309 | /* If the regulator isn't on, it won't take time here */ | ||
| 310 | ret = ab8500_regulator_is_enabled(rdev); | ||
| 311 | if (ret < 0) | ||
| 312 | return ret; | ||
| 313 | if (!ret) | ||
| 314 | return 0; | ||
| 315 | return info->delay; | ||
| 316 | } | ||
| 317 | |||
| 293 | static struct regulator_ops ab8500_regulator_ops = { | 318 | static struct regulator_ops ab8500_regulator_ops = { |
| 294 | .enable = ab8500_regulator_enable, | 319 | .enable = ab8500_regulator_enable, |
| 295 | .disable = ab8500_regulator_disable, | 320 | .disable = ab8500_regulator_disable, |
| @@ -297,6 +322,8 @@ static struct regulator_ops ab8500_regulator_ops = { | |||
| 297 | .get_voltage = ab8500_regulator_get_voltage, | 322 | .get_voltage = ab8500_regulator_get_voltage, |
| 298 | .set_voltage = ab8500_regulator_set_voltage, | 323 | .set_voltage = ab8500_regulator_set_voltage, |
| 299 | .list_voltage = ab8500_list_voltage, | 324 | .list_voltage = ab8500_list_voltage, |
| 325 | .enable_time = ab8500_regulator_enable_time, | ||
| 326 | .set_voltage_time_sel = ab8500_regulator_set_voltage_time_sel, | ||
| 300 | }; | 327 | }; |
| 301 | 328 | ||
| 302 | static int ab8500_fixed_get_voltage(struct regulator_dev *rdev) | 329 | static int ab8500_fixed_get_voltage(struct regulator_dev *rdev) |
| @@ -317,6 +344,8 @@ static struct regulator_ops ab8500_regulator_fixed_ops = { | |||
| 317 | .is_enabled = ab8500_regulator_is_enabled, | 344 | .is_enabled = ab8500_regulator_is_enabled, |
| 318 | .get_voltage = ab8500_fixed_get_voltage, | 345 | .get_voltage = ab8500_fixed_get_voltage, |
| 319 | .list_voltage = ab8500_list_voltage, | 346 | .list_voltage = ab8500_list_voltage, |
| 347 | .enable_time = ab8500_regulator_enable_time, | ||
| 348 | .set_voltage_time_sel = ab8500_regulator_set_voltage_time_sel, | ||
| 320 | }; | 349 | }; |
| 321 | 350 | ||
| 322 | static struct ab8500_regulator_info | 351 | static struct ab8500_regulator_info |
| @@ -426,12 +455,28 @@ static struct ab8500_regulator_info | |||
| 426 | .owner = THIS_MODULE, | 455 | .owner = THIS_MODULE, |
| 427 | .n_voltages = 1, | 456 | .n_voltages = 1, |
| 428 | }, | 457 | }, |
| 458 | .delay = 10000, | ||
| 429 | .fixed_uV = 2000000, | 459 | .fixed_uV = 2000000, |
| 430 | .update_bank = 0x03, | 460 | .update_bank = 0x03, |
| 431 | .update_reg = 0x80, | 461 | .update_reg = 0x80, |
| 432 | .update_mask = 0x82, | 462 | .update_mask = 0x82, |
| 433 | .update_val_enable = 0x02, | 463 | .update_val_enable = 0x02, |
| 434 | }, | 464 | }, |
| 465 | [AB8500_LDO_USB] = { | ||
| 466 | .desc = { | ||
| 467 | .name = "LDO-USB", | ||
| 468 | .ops = &ab8500_regulator_fixed_ops, | ||
| 469 | .type = REGULATOR_VOLTAGE, | ||
| 470 | .id = AB8500_LDO_USB, | ||
| 471 | .owner = THIS_MODULE, | ||
| 472 | .n_voltages = 1, | ||
| 473 | }, | ||
| 474 | .fixed_uV = 3300000, | ||
| 475 | .update_bank = 0x03, | ||
| 476 | .update_reg = 0x82, | ||
| 477 | .update_mask = 0x03, | ||
| 478 | .update_val_enable = 0x01, | ||
| 479 | }, | ||
| 435 | [AB8500_LDO_AUDIO] = { | 480 | [AB8500_LDO_AUDIO] = { |
| 436 | .desc = { | 481 | .desc = { |
| 437 | .name = "LDO-AUDIO", | 482 | .name = "LDO-AUDIO", |
| @@ -511,6 +556,186 @@ static struct ab8500_regulator_info | |||
| 511 | 556 | ||
| 512 | }; | 557 | }; |
| 513 | 558 | ||
| 559 | struct ab8500_reg_init { | ||
| 560 | u8 bank; | ||
| 561 | u8 addr; | ||
| 562 | u8 mask; | ||
| 563 | }; | ||
| 564 | |||
| 565 | #define REG_INIT(_id, _bank, _addr, _mask) \ | ||
| 566 | [_id] = { \ | ||
| 567 | .bank = _bank, \ | ||
| 568 | .addr = _addr, \ | ||
| 569 | .mask = _mask, \ | ||
| 570 | } | ||
| 571 | |||
| 572 | static struct ab8500_reg_init ab8500_reg_init[] = { | ||
| 573 | /* | ||
| 574 | * 0x30, VanaRequestCtrl | ||
| 575 | * 0x0C, VpllRequestCtrl | ||
| 576 | * 0xc0, VextSupply1RequestCtrl | ||
| 577 | */ | ||
| 578 | REG_INIT(AB8500_REGUREQUESTCTRL2, 0x03, 0x04, 0xfc), | ||
| 579 | /* | ||
| 580 | * 0x03, VextSupply2RequestCtrl | ||
| 581 | * 0x0c, VextSupply3RequestCtrl | ||
| 582 | * 0x30, Vaux1RequestCtrl | ||
| 583 | * 0xc0, Vaux2RequestCtrl | ||
| 584 | */ | ||
| 585 | REG_INIT(AB8500_REGUREQUESTCTRL3, 0x03, 0x05, 0xff), | ||
| 586 | /* | ||
| 587 | * 0x03, Vaux3RequestCtrl | ||
| 588 | * 0x04, SwHPReq | ||
| 589 | */ | ||
| 590 | REG_INIT(AB8500_REGUREQUESTCTRL4, 0x03, 0x06, 0x07), | ||
| 591 | /* | ||
| 592 | * 0x08, VanaSysClkReq1HPValid | ||
| 593 | * 0x20, Vaux1SysClkReq1HPValid | ||
| 594 | * 0x40, Vaux2SysClkReq1HPValid | ||
| 595 | * 0x80, Vaux3SysClkReq1HPValid | ||
| 596 | */ | ||
| 597 | REG_INIT(AB8500_REGUSYSCLKREQ1HPVALID1, 0x03, 0x07, 0xe8), | ||
| 598 | /* | ||
| 599 | * 0x10, VextSupply1SysClkReq1HPValid | ||
| 600 | * 0x20, VextSupply2SysClkReq1HPValid | ||
| 601 | * 0x40, VextSupply3SysClkReq1HPValid | ||
| 602 | */ | ||
| 603 | REG_INIT(AB8500_REGUSYSCLKREQ1HPVALID2, 0x03, 0x08, 0x70), | ||
| 604 | /* | ||
| 605 | * 0x08, VanaHwHPReq1Valid | ||
| 606 | * 0x20, Vaux1HwHPReq1Valid | ||
| 607 | * 0x40, Vaux2HwHPReq1Valid | ||
| 608 | * 0x80, Vaux3HwHPReq1Valid | ||
| 609 | */ | ||
| 610 | REG_INIT(AB8500_REGUHWHPREQ1VALID1, 0x03, 0x09, 0xe8), | ||
| 611 | /* | ||
| 612 | * 0x01, VextSupply1HwHPReq1Valid | ||
| 613 | * 0x02, VextSupply2HwHPReq1Valid | ||
| 614 | * 0x04, VextSupply3HwHPReq1Valid | ||
| 615 | */ | ||
| 616 | REG_INIT(AB8500_REGUHWHPREQ1VALID2, 0x03, 0x0a, 0x07), | ||
| 617 | /* | ||
| 618 | * 0x08, VanaHwHPReq2Valid | ||
| 619 | * 0x20, Vaux1HwHPReq2Valid | ||
| 620 | * 0x40, Vaux2HwHPReq2Valid | ||
| 621 | * 0x80, Vaux3HwHPReq2Valid | ||
| 622 | */ | ||
| 623 | REG_INIT(AB8500_REGUHWHPREQ2VALID1, 0x03, 0x0b, 0xe8), | ||
| 624 | /* | ||
| 625 | * 0x01, VextSupply1HwHPReq2Valid | ||
| 626 | * 0x02, VextSupply2HwHPReq2Valid | ||
| 627 | * 0x04, VextSupply3HwHPReq2Valid | ||
| 628 | */ | ||
| 629 | REG_INIT(AB8500_REGUHWHPREQ2VALID2, 0x03, 0x0c, 0x07), | ||
| 630 | /* | ||
| 631 | * 0x20, VanaSwHPReqValid | ||
| 632 | * 0x80, Vaux1SwHPReqValid | ||
| 633 | */ | ||
| 634 | REG_INIT(AB8500_REGUSWHPREQVALID1, 0x03, 0x0d, 0xa0), | ||
| 635 | /* | ||
| 636 | * 0x01, Vaux2SwHPReqValid | ||
| 637 | * 0x02, Vaux3SwHPReqValid | ||
| 638 | * 0x04, VextSupply1SwHPReqValid | ||
| 639 | * 0x08, VextSupply2SwHPReqValid | ||
| 640 | * 0x10, VextSupply3SwHPReqValid | ||
| 641 | */ | ||
| 642 | REG_INIT(AB8500_REGUSWHPREQVALID2, 0x03, 0x0e, 0x1f), | ||
| 643 | /* | ||
| 644 | * 0x02, SysClkReq2Valid1 | ||
| 645 | * ... | ||
| 646 | * 0x80, SysClkReq8Valid1 | ||
| 647 | */ | ||
| 648 | REG_INIT(AB8500_REGUSYSCLKREQVALID1, 0x03, 0x0f, 0xfe), | ||
| 649 | /* | ||
| 650 | * 0x02, SysClkReq2Valid2 | ||
| 651 | * ... | ||
| 652 | * 0x80, SysClkReq8Valid2 | ||
| 653 | */ | ||
| 654 | REG_INIT(AB8500_REGUSYSCLKREQVALID2, 0x03, 0x10, 0xfe), | ||
| 655 | /* | ||
| 656 | * 0x02, VTVoutEna | ||
| 657 | * 0x04, Vintcore12Ena | ||
| 658 | * 0x38, Vintcore12Sel | ||
| 659 | * 0x40, Vintcore12LP | ||
| 660 | * 0x80, VTVoutLP | ||
| 661 | */ | ||
| 662 | REG_INIT(AB8500_REGUMISC1, 0x03, 0x80, 0xfe), | ||
| 663 | /* | ||
| 664 | * 0x02, VaudioEna | ||
| 665 | * 0x04, VdmicEna | ||
| 666 | * 0x08, Vamic1Ena | ||
| 667 | * 0x10, Vamic2Ena | ||
| 668 | */ | ||
| 669 | REG_INIT(AB8500_VAUDIOSUPPLY, 0x03, 0x83, 0x1e), | ||
| 670 | /* | ||
| 671 | * 0x01, Vamic1_dzout | ||
| 672 | * 0x02, Vamic2_dzout | ||
| 673 | */ | ||
| 674 | REG_INIT(AB8500_REGUCTRL1VAMIC, 0x03, 0x84, 0x03), | ||
| 675 | /* | ||
| 676 | * 0x0c, VanaRegu | ||
| 677 | * 0x03, VpllRegu | ||
| 678 | */ | ||
| 679 | REG_INIT(AB8500_VPLLVANAREGU, 0x04, 0x06, 0x0f), | ||
| 680 | /* | ||
| 681 | * 0x01, VrefDDREna | ||
| 682 | * 0x02, VrefDDRSleepMode | ||
| 683 | */ | ||
| 684 | REG_INIT(AB8500_VREFDDR, 0x04, 0x07, 0x03), | ||
| 685 | /* | ||
| 686 | * 0x03, VextSupply1Regu | ||
| 687 | * 0x0c, VextSupply2Regu | ||
| 688 | * 0x30, VextSupply3Regu | ||
| 689 | * 0x40, ExtSupply2Bypass | ||
| 690 | * 0x80, ExtSupply3Bypass | ||
| 691 | */ | ||
| 692 | REG_INIT(AB8500_EXTSUPPLYREGU, 0x04, 0x08, 0xff), | ||
| 693 | /* | ||
| 694 | * 0x03, Vaux1Regu | ||
| 695 | * 0x0c, Vaux2Regu | ||
| 696 | */ | ||
| 697 | REG_INIT(AB8500_VAUX12REGU, 0x04, 0x09, 0x0f), | ||
| 698 | /* | ||
| 699 | * 0x03, Vaux3Regu | ||
| 700 | */ | ||
| 701 | REG_INIT(AB8500_VRF1VAUX3REGU, 0x04, 0x0a, 0x03), | ||
| 702 | /* | ||
| 703 | * 0x3f, Vsmps1Sel1 | ||
| 704 | */ | ||
| 705 | REG_INIT(AB8500_VSMPS1SEL1, 0x04, 0x13, 0x3f), | ||
| 706 | /* | ||
| 707 | * 0x0f, Vaux1Sel | ||
| 708 | */ | ||
| 709 | REG_INIT(AB8500_VAUX1SEL, 0x04, 0x1f, 0x0f), | ||
| 710 | /* | ||
| 711 | * 0x0f, Vaux2Sel | ||
| 712 | */ | ||
| 713 | REG_INIT(AB8500_VAUX2SEL, 0x04, 0x20, 0x0f), | ||
| 714 | /* | ||
| 715 | * 0x07, Vaux3Sel | ||
| 716 | */ | ||
| 717 | REG_INIT(AB8500_VRF1VAUX3SEL, 0x04, 0x21, 0x07), | ||
| 718 | /* | ||
| 719 | * 0x01, VextSupply12LP | ||
| 720 | */ | ||
| 721 | REG_INIT(AB8500_REGUCTRL2SPARE, 0x04, 0x22, 0x01), | ||
| 722 | /* | ||
| 723 | * 0x04, Vaux1Disch | ||
| 724 | * 0x08, Vaux2Disch | ||
| 725 | * 0x10, Vaux3Disch | ||
| 726 | * 0x20, Vintcore12Disch | ||
| 727 | * 0x40, VTVoutDisch | ||
| 728 | * 0x80, VaudioDisch | ||
| 729 | */ | ||
| 730 | REG_INIT(AB8500_REGUCTRLDISCH, 0x04, 0x43, 0xfc), | ||
| 731 | /* | ||
| 732 | * 0x02, VanaDisch | ||
| 733 | * 0x04, VdmicPullDownEna | ||
| 734 | * 0x10, VdmicDisch | ||
| 735 | */ | ||
| 736 | REG_INIT(AB8500_REGUCTRLDISCH2, 0x04, 0x44, 0x16), | ||
| 737 | }; | ||
| 738 | |||
| 514 | static __devinit int ab8500_regulator_probe(struct platform_device *pdev) | 739 | static __devinit int ab8500_regulator_probe(struct platform_device *pdev) |
| 515 | { | 740 | { |
| 516 | struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent); | 741 | struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent); |
| @@ -529,10 +754,51 @@ static __devinit int ab8500_regulator_probe(struct platform_device *pdev) | |||
| 529 | 754 | ||
| 530 | /* make sure the platform data has the correct size */ | 755 | /* make sure the platform data has the correct size */ |
| 531 | if (pdata->num_regulator != ARRAY_SIZE(ab8500_regulator_info)) { | 756 | if (pdata->num_regulator != ARRAY_SIZE(ab8500_regulator_info)) { |
| 532 | dev_err(&pdev->dev, "platform configuration error\n"); | 757 | dev_err(&pdev->dev, "Configuration error: size mismatch.\n"); |
| 533 | return -EINVAL; | 758 | return -EINVAL; |
| 534 | } | 759 | } |
| 535 | 760 | ||
| 761 | /* initialize registers */ | ||
| 762 | for (i = 0; i < pdata->num_regulator_reg_init; i++) { | ||
| 763 | int id; | ||
| 764 | u8 value; | ||
| 765 | |||
| 766 | id = pdata->regulator_reg_init[i].id; | ||
| 767 | value = pdata->regulator_reg_init[i].value; | ||
| 768 | |||
| 769 | /* check for configuration errors */ | ||
| 770 | if (id >= AB8500_NUM_REGULATOR_REGISTERS) { | ||
| 771 | dev_err(&pdev->dev, | ||
| 772 | "Configuration error: id outside range.\n"); | ||
| 773 | return -EINVAL; | ||
| 774 | } | ||
| 775 | if (value & ~ab8500_reg_init[id].mask) { | ||
| 776 | dev_err(&pdev->dev, | ||
| 777 | "Configuration error: value outside mask.\n"); | ||
| 778 | return -EINVAL; | ||
| 779 | } | ||
| 780 | |||
| 781 | /* initialize register */ | ||
| 782 | err = abx500_mask_and_set_register_interruptible(&pdev->dev, | ||
| 783 | ab8500_reg_init[id].bank, | ||
| 784 | ab8500_reg_init[id].addr, | ||
| 785 | ab8500_reg_init[id].mask, | ||
| 786 | value); | ||
| 787 | if (err < 0) { | ||
| 788 | dev_err(&pdev->dev, | ||
| 789 | "Failed to initialize 0x%02x, 0x%02x.\n", | ||
| 790 | ab8500_reg_init[id].bank, | ||
| 791 | ab8500_reg_init[id].addr); | ||
| 792 | return err; | ||
| 793 | } | ||
| 794 | dev_vdbg(&pdev->dev, | ||
| 795 | " init: 0x%02x, 0x%02x, 0x%02x, 0x%02x\n", | ||
| 796 | ab8500_reg_init[id].bank, | ||
| 797 | ab8500_reg_init[id].addr, | ||
| 798 | ab8500_reg_init[id].mask, | ||
| 799 | value); | ||
| 800 | } | ||
| 801 | |||
| 536 | /* register all regulators */ | 802 | /* register all regulators */ |
| 537 | for (i = 0; i < ARRAY_SIZE(ab8500_regulator_info); i++) { | 803 | for (i = 0; i < ARRAY_SIZE(ab8500_regulator_info); i++) { |
| 538 | struct ab8500_regulator_info *info = NULL; | 804 | struct ab8500_regulator_info *info = NULL; |
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 9fa20957847..3ffc6979d16 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
| @@ -1629,6 +1629,7 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev, | |||
| 1629 | int min_uV, int max_uV) | 1629 | int min_uV, int max_uV) |
| 1630 | { | 1630 | { |
| 1631 | int ret; | 1631 | int ret; |
| 1632 | int delay = 0; | ||
| 1632 | unsigned int selector; | 1633 | unsigned int selector; |
| 1633 | 1634 | ||
| 1634 | trace_regulator_set_voltage(rdev_get_name(rdev), min_uV, max_uV); | 1635 | trace_regulator_set_voltage(rdev_get_name(rdev), min_uV, max_uV); |
| @@ -1662,6 +1663,22 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev, | |||
| 1662 | } | 1663 | } |
| 1663 | } | 1664 | } |
| 1664 | 1665 | ||
| 1666 | /* | ||
| 1667 | * If we can't obtain the old selector there is not enough | ||
| 1668 | * info to call set_voltage_time_sel(). | ||
| 1669 | */ | ||
| 1670 | if (rdev->desc->ops->set_voltage_time_sel && | ||
| 1671 | rdev->desc->ops->get_voltage_sel) { | ||
| 1672 | unsigned int old_selector = 0; | ||
| 1673 | |||
| 1674 | ret = rdev->desc->ops->get_voltage_sel(rdev); | ||
| 1675 | if (ret < 0) | ||
| 1676 | return ret; | ||
| 1677 | old_selector = ret; | ||
| 1678 | delay = rdev->desc->ops->set_voltage_time_sel(rdev, | ||
| 1679 | old_selector, selector); | ||
| 1680 | } | ||
| 1681 | |||
| 1665 | if (best_val != INT_MAX) { | 1682 | if (best_val != INT_MAX) { |
| 1666 | ret = rdev->desc->ops->set_voltage_sel(rdev, selector); | 1683 | ret = rdev->desc->ops->set_voltage_sel(rdev, selector); |
| 1667 | selector = best_val; | 1684 | selector = best_val; |
| @@ -1672,6 +1689,14 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev, | |||
| 1672 | ret = -EINVAL; | 1689 | ret = -EINVAL; |
| 1673 | } | 1690 | } |
| 1674 | 1691 | ||
| 1692 | /* Insert any necessary delays */ | ||
| 1693 | if (delay >= 1000) { | ||
| 1694 | mdelay(delay / 1000); | ||
| 1695 | udelay(delay % 1000); | ||
| 1696 | } else if (delay) { | ||
| 1697 | udelay(delay); | ||
| 1698 | } | ||
| 1699 | |||
| 1675 | if (ret == 0) | 1700 | if (ret == 0) |
| 1676 | _notifier_call_chain(rdev, REGULATOR_EVENT_VOLTAGE_CHANGE, | 1701 | _notifier_call_chain(rdev, REGULATOR_EVENT_VOLTAGE_CHANGE, |
| 1677 | NULL); | 1702 | NULL); |
| @@ -1740,6 +1765,51 @@ out: | |||
| 1740 | EXPORT_SYMBOL_GPL(regulator_set_voltage); | 1765 | EXPORT_SYMBOL_GPL(regulator_set_voltage); |
| 1741 | 1766 | ||
| 1742 | /** | 1767 | /** |
| 1768 | * regulator_set_voltage_time - get raise/fall time | ||
| 1769 | * @regulator: regulator source | ||
| 1770 | * @old_uV: starting voltage in microvolts | ||
| 1771 | * @new_uV: target voltage in microvolts | ||
| 1772 | * | ||
| 1773 | * Provided with the starting and ending voltage, this function attempts to | ||
| 1774 | * calculate the time in microseconds required to rise or fall to this new | ||
| 1775 | * voltage. | ||
| 1776 | */ | ||
| 1777 | int regulator_set_voltage_time(struct regulator *regulator, | ||
| 1778 | int old_uV, int new_uV) | ||
| 1779 | { | ||
| 1780 | struct regulator_dev *rdev = regulator->rdev; | ||
| 1781 | struct regulator_ops *ops = rdev->desc->ops; | ||
| 1782 | int old_sel = -1; | ||
| 1783 | int new_sel = -1; | ||
| 1784 | int voltage; | ||
| 1785 | int i; | ||
| 1786 | |||
| 1787 | /* Currently requires operations to do this */ | ||
| 1788 | if (!ops->list_voltage || !ops->set_voltage_time_sel | ||
| 1789 | || !rdev->desc->n_voltages) | ||
| 1790 | return -EINVAL; | ||
| 1791 | |||
| 1792 | for (i = 0; i < rdev->desc->n_voltages; i++) { | ||
| 1793 | /* We only look for exact voltage matches here */ | ||
| 1794 | voltage = regulator_list_voltage(regulator, i); | ||
| 1795 | if (voltage < 0) | ||
| 1796 | return -EINVAL; | ||
| 1797 | if (voltage == 0) | ||
| 1798 | continue; | ||
| 1799 | if (voltage == old_uV) | ||
| 1800 | old_sel = i; | ||
| 1801 | if (voltage == new_uV) | ||
| 1802 | new_sel = i; | ||
| 1803 | } | ||
| 1804 | |||
| 1805 | if (old_sel < 0 || new_sel < 0) | ||
| 1806 | return -EINVAL; | ||
| 1807 | |||
| 1808 | return ops->set_voltage_time_sel(rdev, old_sel, new_sel); | ||
| 1809 | } | ||
| 1810 | EXPORT_SYMBOL_GPL(regulator_set_voltage_time); | ||
| 1811 | |||
| 1812 | /** | ||
| 1743 | * regulator_sync_voltage - re-apply last regulator output voltage | 1813 | * regulator_sync_voltage - re-apply last regulator output voltage |
| 1744 | * @regulator: regulator source | 1814 | * @regulator: regulator source |
| 1745 | * | 1815 | * |
| @@ -2565,8 +2635,11 @@ struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc, | |||
| 2565 | init_data->consumer_supplies[i].dev, | 2635 | init_data->consumer_supplies[i].dev, |
| 2566 | init_data->consumer_supplies[i].dev_name, | 2636 | init_data->consumer_supplies[i].dev_name, |
| 2567 | init_data->consumer_supplies[i].supply); | 2637 | init_data->consumer_supplies[i].supply); |
| 2568 | if (ret < 0) | 2638 | if (ret < 0) { |
| 2639 | dev_err(dev, "Failed to set supply %s\n", | ||
| 2640 | init_data->consumer_supplies[i].supply); | ||
| 2569 | goto unset_supplies; | 2641 | goto unset_supplies; |
| 2642 | } | ||
| 2570 | } | 2643 | } |
| 2571 | 2644 | ||
| 2572 | list_add(&rdev->list, ®ulator_list); | 2645 | list_add(&rdev->list, ®ulator_list); |
| @@ -2653,6 +2726,47 @@ out: | |||
| 2653 | EXPORT_SYMBOL_GPL(regulator_suspend_prepare); | 2726 | EXPORT_SYMBOL_GPL(regulator_suspend_prepare); |
| 2654 | 2727 | ||
| 2655 | /** | 2728 | /** |
| 2729 | * regulator_suspend_finish - resume regulators from system wide suspend | ||
| 2730 | * | ||
| 2731 | * Turn on regulators that might be turned off by regulator_suspend_prepare | ||
| 2732 | * and that should be turned on according to the regulators properties. | ||
| 2733 | */ | ||
| 2734 | int regulator_suspend_finish(void) | ||
| 2735 | { | ||
| 2736 | struct regulator_dev *rdev; | ||
| 2737 | int ret = 0, error; | ||
| 2738 | |||
| 2739 | mutex_lock(®ulator_list_mutex); | ||
| 2740 | list_for_each_entry(rdev, ®ulator_list, list) { | ||
| 2741 | struct regulator_ops *ops = rdev->desc->ops; | ||
| 2742 | |||
| 2743 | mutex_lock(&rdev->mutex); | ||
| 2744 | if ((rdev->use_count > 0 || rdev->constraints->always_on) && | ||
| 2745 | ops->enable) { | ||
| 2746 | error = ops->enable(rdev); | ||
| 2747 | if (error) | ||
| 2748 | ret = error; | ||
| 2749 | } else { | ||
| 2750 | if (!has_full_constraints) | ||
| 2751 | goto unlock; | ||
| 2752 | if (!ops->disable) | ||
| 2753 | goto unlock; | ||
| 2754 | if (ops->is_enabled && !ops->is_enabled(rdev)) | ||
| 2755 | goto unlock; | ||
| 2756 | |||
| 2757 | error = ops->disable(rdev); | ||
| 2758 | if (error) | ||
| 2759 | ret = error; | ||
| 2760 | } | ||
| 2761 | unlock: | ||
| 2762 | mutex_unlock(&rdev->mutex); | ||
| 2763 | } | ||
| 2764 | mutex_unlock(®ulator_list_mutex); | ||
| 2765 | return ret; | ||
| 2766 | } | ||
| 2767 | EXPORT_SYMBOL_GPL(regulator_suspend_finish); | ||
| 2768 | |||
| 2769 | /** | ||
| 2656 | * regulator_has_full_constraints - the system has fully specified constraints | 2770 | * regulator_has_full_constraints - the system has fully specified constraints |
| 2657 | * | 2771 | * |
| 2658 | * Calling this function will cause the regulator API to disable all | 2772 | * Calling this function will cause the regulator API to disable all |
diff --git a/drivers/regulator/max8997.c b/drivers/regulator/max8997.c index 01ef7e9903b..77e0cfb30b2 100644 --- a/drivers/regulator/max8997.c +++ b/drivers/regulator/max8997.c | |||
| @@ -1185,6 +1185,7 @@ static const struct platform_device_id max8997_pmic_id[] = { | |||
| 1185 | { "max8997-pmic", 0}, | 1185 | { "max8997-pmic", 0}, |
| 1186 | { }, | 1186 | { }, |
| 1187 | }; | 1187 | }; |
| 1188 | MODULE_DEVICE_TABLE(platform, max8997_pmic_id); | ||
| 1188 | 1189 | ||
| 1189 | static struct platform_driver max8997_pmic_driver = { | 1190 | static struct platform_driver max8997_pmic_driver = { |
| 1190 | .driver = { | 1191 | .driver = { |
diff --git a/drivers/regulator/max8998.c b/drivers/regulator/max8998.c index 0ec49ca527a..43410266f99 100644 --- a/drivers/regulator/max8998.c +++ b/drivers/regulator/max8998.c | |||
| @@ -887,6 +887,7 @@ static const struct platform_device_id max8998_pmic_id[] = { | |||
| 887 | { "lp3974-pmic", TYPE_LP3974 }, | 887 | { "lp3974-pmic", TYPE_LP3974 }, |
| 888 | { } | 888 | { } |
| 889 | }; | 889 | }; |
| 890 | MODULE_DEVICE_TABLE(platform, max8998_pmic_id); | ||
| 890 | 891 | ||
| 891 | static struct platform_driver max8998_pmic_driver = { | 892 | static struct platform_driver max8998_pmic_driver = { |
| 892 | .driver = { | 893 | .driver = { |
diff --git a/drivers/regulator/tps6524x-regulator.c b/drivers/regulator/tps6524x-regulator.c index 176a6be5a8c..9166aa0a9df 100644 --- a/drivers/regulator/tps6524x-regulator.c +++ b/drivers/regulator/tps6524x-regulator.c | |||
| @@ -596,7 +596,7 @@ static struct regulator_ops regulator_ops = { | |||
| 596 | .get_current_limit = get_current_limit, | 596 | .get_current_limit = get_current_limit, |
| 597 | }; | 597 | }; |
| 598 | 598 | ||
| 599 | static int __devexit pmic_remove(struct spi_device *spi) | 599 | static int pmic_remove(struct spi_device *spi) |
| 600 | { | 600 | { |
| 601 | struct tps6524x *hw = spi_get_drvdata(spi); | 601 | struct tps6524x *hw = spi_get_drvdata(spi); |
| 602 | int i; | 602 | int i; |
diff --git a/drivers/regulator/wm831x-dcdc.c b/drivers/regulator/wm831x-dcdc.c index 06df898842c..e93453b1b97 100644 --- a/drivers/regulator/wm831x-dcdc.c +++ b/drivers/regulator/wm831x-dcdc.c | |||
| @@ -565,9 +565,8 @@ static __devinit int wm831x_buckv_probe(struct platform_device *pdev) | |||
| 565 | } | 565 | } |
| 566 | 566 | ||
| 567 | irq = platform_get_irq_byname(pdev, "UV"); | 567 | irq = platform_get_irq_byname(pdev, "UV"); |
| 568 | ret = wm831x_request_irq(wm831x, irq, wm831x_dcdc_uv_irq, | 568 | ret = request_threaded_irq(irq, NULL, wm831x_dcdc_uv_irq, |
| 569 | IRQF_TRIGGER_RISING, dcdc->name, | 569 | IRQF_TRIGGER_RISING, dcdc->name, dcdc); |
| 570 | dcdc); | ||
| 571 | if (ret != 0) { | 570 | if (ret != 0) { |
| 572 | dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", | 571 | dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", |
| 573 | irq, ret); | 572 | irq, ret); |
| @@ -575,9 +574,8 @@ static __devinit int wm831x_buckv_probe(struct platform_device *pdev) | |||
| 575 | } | 574 | } |
| 576 | 575 | ||
| 577 | irq = platform_get_irq_byname(pdev, "HC"); | 576 | irq = platform_get_irq_byname(pdev, "HC"); |
| 578 | ret = wm831x_request_irq(wm831x, irq, wm831x_dcdc_oc_irq, | 577 | ret = request_threaded_irq(irq, NULL, wm831x_dcdc_oc_irq, |
| 579 | IRQF_TRIGGER_RISING, dcdc->name, | 578 | IRQF_TRIGGER_RISING, dcdc->name, dcdc); |
| 580 | dcdc); | ||
| 581 | if (ret != 0) { | 579 | if (ret != 0) { |
| 582 | dev_err(&pdev->dev, "Failed to request HC IRQ %d: %d\n", | 580 | dev_err(&pdev->dev, "Failed to request HC IRQ %d: %d\n", |
| 583 | irq, ret); | 581 | irq, ret); |
| @@ -589,7 +587,7 @@ static __devinit int wm831x_buckv_probe(struct platform_device *pdev) | |||
| 589 | return 0; | 587 | return 0; |
| 590 | 588 | ||
| 591 | err_uv: | 589 | err_uv: |
| 592 | wm831x_free_irq(wm831x, platform_get_irq_byname(pdev, "UV"), dcdc); | 590 | free_irq(platform_get_irq_byname(pdev, "UV"), dcdc); |
| 593 | err_regulator: | 591 | err_regulator: |
| 594 | regulator_unregister(dcdc->regulator); | 592 | regulator_unregister(dcdc->regulator); |
| 595 | err: | 593 | err: |
| @@ -606,8 +604,8 @@ static __devexit int wm831x_buckv_remove(struct platform_device *pdev) | |||
| 606 | 604 | ||
| 607 | platform_set_drvdata(pdev, NULL); | 605 | platform_set_drvdata(pdev, NULL); |
| 608 | 606 | ||
| 609 | wm831x_free_irq(wm831x, platform_get_irq_byname(pdev, "HC"), dcdc); | 607 | free_irq(platform_get_irq_byname(pdev, "HC"), dcdc); |
| 610 | wm831x_free_irq(wm831x, platform_get_irq_byname(pdev, "UV"), dcdc); | 608 | free_irq(platform_get_irq_byname(pdev, "UV"), dcdc); |
| 611 | regulator_unregister(dcdc->regulator); | 609 | regulator_unregister(dcdc->regulator); |
| 612 | if (dcdc->dvs_gpio) | 610 | if (dcdc->dvs_gpio) |
| 613 | gpio_free(dcdc->dvs_gpio); | 611 | gpio_free(dcdc->dvs_gpio); |
| @@ -756,9 +754,8 @@ static __devinit int wm831x_buckp_probe(struct platform_device *pdev) | |||
| 756 | } | 754 | } |
| 757 | 755 | ||
| 758 | irq = platform_get_irq_byname(pdev, "UV"); | 756 | irq = platform_get_irq_byname(pdev, "UV"); |
| 759 | ret = wm831x_request_irq(wm831x, irq, wm831x_dcdc_uv_irq, | 757 | ret = request_threaded_irq(irq, NULL, wm831x_dcdc_uv_irq, |
| 760 | IRQF_TRIGGER_RISING, dcdc->name, | 758 | IRQF_TRIGGER_RISING, dcdc->name, dcdc); |
| 761 | dcdc); | ||
| 762 | if (ret != 0) { | 759 | if (ret != 0) { |
| 763 | dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", | 760 | dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", |
| 764 | irq, ret); | 761 | irq, ret); |
| @@ -783,7 +780,7 @@ static __devexit int wm831x_buckp_remove(struct platform_device *pdev) | |||
| 783 | 780 | ||
| 784 | platform_set_drvdata(pdev, NULL); | 781 | platform_set_drvdata(pdev, NULL); |
| 785 | 782 | ||
| 786 | wm831x_free_irq(wm831x, platform_get_irq_byname(pdev, "UV"), dcdc); | 783 | free_irq(platform_get_irq_byname(pdev, "UV"), dcdc); |
| 787 | regulator_unregister(dcdc->regulator); | 784 | regulator_unregister(dcdc->regulator); |
| 788 | kfree(dcdc); | 785 | kfree(dcdc); |
| 789 | 786 | ||
| @@ -885,9 +882,9 @@ static __devinit int wm831x_boostp_probe(struct platform_device *pdev) | |||
| 885 | } | 882 | } |
| 886 | 883 | ||
| 887 | irq = platform_get_irq_byname(pdev, "UV"); | 884 | irq = platform_get_irq_byname(pdev, "UV"); |
| 888 | ret = wm831x_request_irq(wm831x, irq, wm831x_dcdc_uv_irq, | 885 | ret = request_threaded_irq(irq, NULL, wm831x_dcdc_uv_irq, |
| 889 | IRQF_TRIGGER_RISING, dcdc->name, | 886 | IRQF_TRIGGER_RISING, dcdc->name, |
| 890 | dcdc); | 887 | dcdc); |
| 891 | if (ret != 0) { | 888 | if (ret != 0) { |
| 892 | dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", | 889 | dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", |
| 893 | irq, ret); | 890 | irq, ret); |
| @@ -908,11 +905,10 @@ err: | |||
| 908 | static __devexit int wm831x_boostp_remove(struct platform_device *pdev) | 905 | static __devexit int wm831x_boostp_remove(struct platform_device *pdev) |
| 909 | { | 906 | { |
| 910 | struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev); | 907 | struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev); |
| 911 | struct wm831x *wm831x = dcdc->wm831x; | ||
| 912 | 908 | ||
| 913 | platform_set_drvdata(pdev, NULL); | 909 | platform_set_drvdata(pdev, NULL); |
| 914 | 910 | ||
| 915 | wm831x_free_irq(wm831x, platform_get_irq_byname(pdev, "UV"), dcdc); | 911 | free_irq(platform_get_irq_byname(pdev, "UV"), dcdc); |
| 916 | regulator_unregister(dcdc->regulator); | 912 | regulator_unregister(dcdc->regulator); |
| 917 | kfree(dcdc); | 913 | kfree(dcdc); |
| 918 | 914 | ||
diff --git a/drivers/regulator/wm831x-isink.c b/drivers/regulator/wm831x-isink.c index 6c446cd6ad5..01f27c7f423 100644 --- a/drivers/regulator/wm831x-isink.c +++ b/drivers/regulator/wm831x-isink.c | |||
| @@ -198,9 +198,8 @@ static __devinit int wm831x_isink_probe(struct platform_device *pdev) | |||
| 198 | } | 198 | } |
| 199 | 199 | ||
| 200 | irq = platform_get_irq(pdev, 0); | 200 | irq = platform_get_irq(pdev, 0); |
| 201 | ret = wm831x_request_irq(wm831x, irq, wm831x_isink_irq, | 201 | ret = request_threaded_irq(irq, NULL, wm831x_isink_irq, |
| 202 | IRQF_TRIGGER_RISING, isink->name, | 202 | IRQF_TRIGGER_RISING, isink->name, isink); |
| 203 | isink); | ||
| 204 | if (ret != 0) { | 203 | if (ret != 0) { |
| 205 | dev_err(&pdev->dev, "Failed to request ISINK IRQ %d: %d\n", | 204 | dev_err(&pdev->dev, "Failed to request ISINK IRQ %d: %d\n", |
| 206 | irq, ret); | 205 | irq, ret); |
| @@ -221,11 +220,10 @@ err: | |||
| 221 | static __devexit int wm831x_isink_remove(struct platform_device *pdev) | 220 | static __devexit int wm831x_isink_remove(struct platform_device *pdev) |
| 222 | { | 221 | { |
| 223 | struct wm831x_isink *isink = platform_get_drvdata(pdev); | 222 | struct wm831x_isink *isink = platform_get_drvdata(pdev); |
| 224 | struct wm831x *wm831x = isink->wm831x; | ||
| 225 | 223 | ||
| 226 | platform_set_drvdata(pdev, NULL); | 224 | platform_set_drvdata(pdev, NULL); |
| 227 | 225 | ||
| 228 | wm831x_free_irq(wm831x, platform_get_irq(pdev, 0), isink); | 226 | free_irq(platform_get_irq(pdev, 0), isink); |
| 229 | 227 | ||
| 230 | regulator_unregister(isink->regulator); | 228 | regulator_unregister(isink->regulator); |
| 231 | kfree(isink); | 229 | kfree(isink); |
diff --git a/drivers/regulator/wm831x-ldo.c b/drivers/regulator/wm831x-ldo.c index c94fc5b7cd5..2220cf8defb 100644 --- a/drivers/regulator/wm831x-ldo.c +++ b/drivers/regulator/wm831x-ldo.c | |||
| @@ -354,9 +354,9 @@ static __devinit int wm831x_gp_ldo_probe(struct platform_device *pdev) | |||
| 354 | } | 354 | } |
| 355 | 355 | ||
| 356 | irq = platform_get_irq_byname(pdev, "UV"); | 356 | irq = platform_get_irq_byname(pdev, "UV"); |
| 357 | ret = wm831x_request_irq(wm831x, irq, wm831x_ldo_uv_irq, | 357 | ret = request_threaded_irq(irq, NULL, wm831x_ldo_uv_irq, |
| 358 | IRQF_TRIGGER_RISING, ldo->name, | 358 | IRQF_TRIGGER_RISING, ldo->name, |
| 359 | ldo); | 359 | ldo); |
| 360 | if (ret != 0) { | 360 | if (ret != 0) { |
| 361 | dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", | 361 | dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", |
| 362 | irq, ret); | 362 | irq, ret); |
| @@ -377,11 +377,10 @@ err: | |||
| 377 | static __devexit int wm831x_gp_ldo_remove(struct platform_device *pdev) | 377 | static __devexit int wm831x_gp_ldo_remove(struct platform_device *pdev) |
| 378 | { | 378 | { |
| 379 | struct wm831x_ldo *ldo = platform_get_drvdata(pdev); | 379 | struct wm831x_ldo *ldo = platform_get_drvdata(pdev); |
| 380 | struct wm831x *wm831x = ldo->wm831x; | ||
| 381 | 380 | ||
| 382 | platform_set_drvdata(pdev, NULL); | 381 | platform_set_drvdata(pdev, NULL); |
| 383 | 382 | ||
| 384 | wm831x_free_irq(wm831x, platform_get_irq_byname(pdev, "UV"), ldo); | 383 | free_irq(platform_get_irq_byname(pdev, "UV"), ldo); |
| 385 | regulator_unregister(ldo->regulator); | 384 | regulator_unregister(ldo->regulator); |
| 386 | kfree(ldo); | 385 | kfree(ldo); |
| 387 | 386 | ||
| @@ -619,9 +618,8 @@ static __devinit int wm831x_aldo_probe(struct platform_device *pdev) | |||
| 619 | } | 618 | } |
| 620 | 619 | ||
| 621 | irq = platform_get_irq_byname(pdev, "UV"); | 620 | irq = platform_get_irq_byname(pdev, "UV"); |
| 622 | ret = wm831x_request_irq(wm831x, irq, wm831x_ldo_uv_irq, | 621 | ret = request_threaded_irq(irq, NULL, wm831x_ldo_uv_irq, |
| 623 | IRQF_TRIGGER_RISING, ldo->name, | 622 | IRQF_TRIGGER_RISING, ldo->name, ldo); |
| 624 | ldo); | ||
| 625 | if (ret != 0) { | 623 | if (ret != 0) { |
| 626 | dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", | 624 | dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", |
| 627 | irq, ret); | 625 | irq, ret); |
| @@ -642,9 +640,8 @@ err: | |||
| 642 | static __devexit int wm831x_aldo_remove(struct platform_device *pdev) | 640 | static __devexit int wm831x_aldo_remove(struct platform_device *pdev) |
| 643 | { | 641 | { |
| 644 | struct wm831x_ldo *ldo = platform_get_drvdata(pdev); | 642 | struct wm831x_ldo *ldo = platform_get_drvdata(pdev); |
| 645 | struct wm831x *wm831x = ldo->wm831x; | ||
| 646 | 643 | ||
| 647 | wm831x_free_irq(wm831x, platform_get_irq_byname(pdev, "UV"), ldo); | 644 | free_irq(platform_get_irq_byname(pdev, "UV"), ldo); |
| 648 | regulator_unregister(ldo->regulator); | 645 | regulator_unregister(ldo->regulator); |
| 649 | kfree(ldo); | 646 | kfree(ldo); |
| 650 | 647 | ||
diff --git a/drivers/staging/westbridge/astoria/block/cyasblkdev_block.c b/drivers/staging/westbridge/astoria/block/cyasblkdev_block.c index 842cd9214a5..289729daba8 100644 --- a/drivers/staging/westbridge/astoria/block/cyasblkdev_block.c +++ b/drivers/staging/westbridge/astoria/block/cyasblkdev_block.c | |||
| @@ -1191,7 +1191,7 @@ static int cyasblkdev_add_disks(int bus_num, | |||
| 1191 | bd->user_disk_1->first_minor = (devidx + 1) << CYASBLKDEV_SHIFT; | 1191 | bd->user_disk_1->first_minor = (devidx + 1) << CYASBLKDEV_SHIFT; |
| 1192 | bd->user_disk_1->minors = 8; | 1192 | bd->user_disk_1->minors = 8; |
| 1193 | bd->user_disk_1->fops = &cyasblkdev_bdops; | 1193 | bd->user_disk_1->fops = &cyasblkdev_bdops; |
| 1194 | bd->user_disk_0->events = DISK_EVENT_MEDIA_CHANGE; | 1194 | bd->user_disk_1->events = DISK_EVENT_MEDIA_CHANGE; |
| 1195 | bd->user_disk_1->private_data = bd; | 1195 | bd->user_disk_1->private_data = bd; |
| 1196 | bd->user_disk_1->queue = bd->queue.queue; | 1196 | bd->user_disk_1->queue = bd->queue.queue; |
| 1197 | bd->dbgprn_flags = DBGPRN_RD_RQ; | 1197 | bd->dbgprn_flags = DBGPRN_RD_RQ; |
diff --git a/fs/inode.c b/fs/inode.c index 05a1f75ae79..5f4e11aaeb5 100644 --- a/fs/inode.c +++ b/fs/inode.c | |||
| @@ -1167,7 +1167,7 @@ EXPORT_SYMBOL(igrab); | |||
| 1167 | * Note: I_NEW is not waited upon so you have to be very careful what you do | 1167 | * Note: I_NEW is not waited upon so you have to be very careful what you do |
| 1168 | * with the returned inode. You probably should be using ilookup5() instead. | 1168 | * with the returned inode. You probably should be using ilookup5() instead. |
| 1169 | * | 1169 | * |
| 1170 | * Note: @test is called with the inode_hash_lock held, so can't sleep. | 1170 | * Note2: @test is called with the inode_hash_lock held, so can't sleep. |
| 1171 | */ | 1171 | */ |
| 1172 | struct inode *ilookup5_nowait(struct super_block *sb, unsigned long hashval, | 1172 | struct inode *ilookup5_nowait(struct super_block *sb, unsigned long hashval, |
| 1173 | int (*test)(struct inode *, void *), void *data) | 1173 | int (*test)(struct inode *, void *), void *data) |
diff --git a/fs/jffs2/xattr.c b/fs/jffs2/xattr.c index 4f9cc048294..3e93cdd1900 100644 --- a/fs/jffs2/xattr.c +++ b/fs/jffs2/xattr.c | |||
| @@ -31,7 +31,7 @@ | |||
| 31 | * is used to release xattr name/value pair and detach from c->xattrindex. | 31 | * is used to release xattr name/value pair and detach from c->xattrindex. |
| 32 | * reclaim_xattr_datum(c) | 32 | * reclaim_xattr_datum(c) |
| 33 | * is used to reclaim xattr name/value pairs on the xattr name/value pair cache when | 33 | * is used to reclaim xattr name/value pairs on the xattr name/value pair cache when |
| 34 | * memory usage by cache is over c->xdatum_mem_threshold. Currently, this threshold | 34 | * memory usage by cache is over c->xdatum_mem_threshold. Currently, this threshold |
| 35 | * is hard coded as 32KiB. | 35 | * is hard coded as 32KiB. |
| 36 | * do_verify_xattr_datum(c, xd) | 36 | * do_verify_xattr_datum(c, xd) |
| 37 | * is used to load the xdatum informations without name/value pair from the medium. | 37 | * is used to load the xdatum informations without name/value pair from the medium. |
diff --git a/fs/nfs/namespace.c b/fs/nfs/namespace.c index ad92bf731ff..9166fcb66da 100644 --- a/fs/nfs/namespace.c +++ b/fs/nfs/namespace.c | |||
| @@ -192,13 +192,15 @@ static rpc_authflavor_t nfs_lookup_with_sec(struct nfs_server *server, struct de | |||
| 192 | auth = rpcauth_create(flavor, clone); | 192 | auth = rpcauth_create(flavor, clone); |
| 193 | if (!auth) { | 193 | if (!auth) { |
| 194 | flavor = -EIO; | 194 | flavor = -EIO; |
| 195 | goto out; | 195 | goto out_shutdown; |
| 196 | } | 196 | } |
| 197 | err = server->nfs_client->rpc_ops->lookup(clone, parent->d_inode, | 197 | err = server->nfs_client->rpc_ops->lookup(clone, parent->d_inode, |
| 198 | &path->dentry->d_name, | 198 | &path->dentry->d_name, |
| 199 | fh, fattr); | 199 | fh, fattr); |
| 200 | if (err < 0) | 200 | if (err < 0) |
| 201 | flavor = err; | 201 | flavor = err; |
| 202 | out_shutdown: | ||
| 203 | rpc_shutdown_client(clone); | ||
| 202 | out: | 204 | out: |
| 203 | return flavor; | 205 | return flavor; |
| 204 | } | 206 | } |
diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c index 87a593c2b05..c80add6e221 100644 --- a/fs/nfs/pagelist.c +++ b/fs/nfs/pagelist.c | |||
| @@ -135,14 +135,14 @@ void nfs_clear_page_tag_locked(struct nfs_page *req) | |||
| 135 | nfs_unlock_request(req); | 135 | nfs_unlock_request(req); |
| 136 | } | 136 | } |
| 137 | 137 | ||
| 138 | /** | 138 | /* |
| 139 | * nfs_clear_request - Free up all resources allocated to the request | 139 | * nfs_clear_request - Free up all resources allocated to the request |
| 140 | * @req: | 140 | * @req: |
| 141 | * | 141 | * |
| 142 | * Release page and open context resources associated with a read/write | 142 | * Release page and open context resources associated with a read/write |
| 143 | * request after it has completed. | 143 | * request after it has completed. |
| 144 | */ | 144 | */ |
| 145 | void nfs_clear_request(struct nfs_page *req) | 145 | static void nfs_clear_request(struct nfs_page *req) |
| 146 | { | 146 | { |
| 147 | struct page *page = req->wb_page; | 147 | struct page *page = req->wb_page; |
| 148 | struct nfs_open_context *ctx = req->wb_context; | 148 | struct nfs_open_context *ctx = req->wb_context; |
diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 85d75254328..af0c6279a4a 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c | |||
| @@ -389,11 +389,8 @@ static int nfs_inode_add_request(struct inode *inode, struct nfs_page *req) | |||
| 389 | spin_lock(&inode->i_lock); | 389 | spin_lock(&inode->i_lock); |
| 390 | error = radix_tree_insert(&nfsi->nfs_page_tree, req->wb_index, req); | 390 | error = radix_tree_insert(&nfsi->nfs_page_tree, req->wb_index, req); |
| 391 | BUG_ON(error); | 391 | BUG_ON(error); |
| 392 | if (!nfsi->npages) { | 392 | if (!nfsi->npages && nfs_have_delegation(inode, FMODE_WRITE)) |
| 393 | igrab(inode); | 393 | nfsi->change_attr++; |
| 394 | if (nfs_have_delegation(inode, FMODE_WRITE)) | ||
| 395 | nfsi->change_attr++; | ||
| 396 | } | ||
| 397 | set_bit(PG_MAPPED, &req->wb_flags); | 394 | set_bit(PG_MAPPED, &req->wb_flags); |
| 398 | SetPagePrivate(req->wb_page); | 395 | SetPagePrivate(req->wb_page); |
| 399 | set_page_private(req->wb_page, (unsigned long)req); | 396 | set_page_private(req->wb_page, (unsigned long)req); |
| @@ -423,11 +420,7 @@ static void nfs_inode_remove_request(struct nfs_page *req) | |||
| 423 | clear_bit(PG_MAPPED, &req->wb_flags); | 420 | clear_bit(PG_MAPPED, &req->wb_flags); |
| 424 | radix_tree_delete(&nfsi->nfs_page_tree, req->wb_index); | 421 | radix_tree_delete(&nfsi->nfs_page_tree, req->wb_index); |
| 425 | nfsi->npages--; | 422 | nfsi->npages--; |
| 426 | if (!nfsi->npages) { | 423 | spin_unlock(&inode->i_lock); |
| 427 | spin_unlock(&inode->i_lock); | ||
| 428 | iput(inode); | ||
| 429 | } else | ||
| 430 | spin_unlock(&inode->i_lock); | ||
| 431 | nfs_release_request(req); | 424 | nfs_release_request(req); |
| 432 | } | 425 | } |
| 433 | 426 | ||
diff --git a/fs/ocfs2/acl.c b/fs/ocfs2/acl.c index 90f2729b7a5..e913ad130fd 100644 --- a/fs/ocfs2/acl.c +++ b/fs/ocfs2/acl.c | |||
| @@ -24,7 +24,6 @@ | |||
| 24 | #include <linux/slab.h> | 24 | #include <linux/slab.h> |
| 25 | #include <linux/string.h> | 25 | #include <linux/string.h> |
| 26 | 26 | ||
| 27 | #define MLOG_MASK_PREFIX ML_INODE | ||
| 28 | #include <cluster/masklog.h> | 27 | #include <cluster/masklog.h> |
| 29 | 28 | ||
| 30 | #include "ocfs2.h" | 29 | #include "ocfs2.h" |
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index e4984e259cb..b27a0d86f8c 100644 --- a/fs/ocfs2/alloc.c +++ b/fs/ocfs2/alloc.c | |||
| @@ -30,7 +30,6 @@ | |||
| 30 | #include <linux/swap.h> | 30 | #include <linux/swap.h> |
| 31 | #include <linux/quotaops.h> | 31 | #include <linux/quotaops.h> |
| 32 | 32 | ||
| 33 | #define MLOG_MASK_PREFIX ML_DISK_ALLOC | ||
| 34 | #include <cluster/masklog.h> | 33 | #include <cluster/masklog.h> |
| 35 | 34 | ||
| 36 | #include "ocfs2.h" | 35 | #include "ocfs2.h" |
| @@ -50,6 +49,7 @@ | |||
| 50 | #include "uptodate.h" | 49 | #include "uptodate.h" |
| 51 | #include "xattr.h" | 50 | #include "xattr.h" |
| 52 | #include "refcounttree.h" | 51 | #include "refcounttree.h" |
| 52 | #include "ocfs2_trace.h" | ||
| 53 | 53 | ||
| 54 | #include "buffer_head_io.h" | 54 | #include "buffer_head_io.h" |
| 55 | 55 | ||
| @@ -886,8 +886,7 @@ static int ocfs2_validate_extent_block(struct super_block *sb, | |||
| 886 | struct ocfs2_extent_block *eb = | 886 | struct ocfs2_extent_block *eb = |
| 887 | (struct ocfs2_extent_block *)bh->b_data; | 887 | (struct ocfs2_extent_block *)bh->b_data; |
| 888 | 888 | ||
| 889 | mlog(0, "Validating extent block %llu\n", | 889 | trace_ocfs2_validate_extent_block((unsigned long long)bh->b_blocknr); |
| 890 | (unsigned long long)bh->b_blocknr); | ||
| 891 | 890 | ||
| 892 | BUG_ON(!buffer_uptodate(bh)); | 891 | BUG_ON(!buffer_uptodate(bh)); |
| 893 | 892 | ||
| @@ -965,8 +964,6 @@ int ocfs2_num_free_extents(struct ocfs2_super *osb, | |||
| 965 | struct buffer_head *eb_bh = NULL; | 964 | struct buffer_head *eb_bh = NULL; |
| 966 | u64 last_eb_blk = 0; | 965 | u64 last_eb_blk = 0; |
| 967 | 966 | ||
| 968 | mlog_entry_void(); | ||
| 969 | |||
| 970 | el = et->et_root_el; | 967 | el = et->et_root_el; |
| 971 | last_eb_blk = ocfs2_et_get_last_eb_blk(et); | 968 | last_eb_blk = ocfs2_et_get_last_eb_blk(et); |
| 972 | 969 | ||
| @@ -987,7 +984,7 @@ int ocfs2_num_free_extents(struct ocfs2_super *osb, | |||
| 987 | bail: | 984 | bail: |
| 988 | brelse(eb_bh); | 985 | brelse(eb_bh); |
| 989 | 986 | ||
| 990 | mlog_exit(retval); | 987 | trace_ocfs2_num_free_extents(retval); |
| 991 | return retval; | 988 | return retval; |
| 992 | } | 989 | } |
| 993 | 990 | ||
| @@ -1010,8 +1007,6 @@ static int ocfs2_create_new_meta_bhs(handle_t *handle, | |||
| 1010 | OCFS2_SB(ocfs2_metadata_cache_get_super(et->et_ci)); | 1007 | OCFS2_SB(ocfs2_metadata_cache_get_super(et->et_ci)); |
| 1011 | struct ocfs2_extent_block *eb; | 1008 | struct ocfs2_extent_block *eb; |
| 1012 | 1009 | ||
| 1013 | mlog_entry_void(); | ||
| 1014 | |||
| 1015 | count = 0; | 1010 | count = 0; |
| 1016 | while (count < wanted) { | 1011 | while (count < wanted) { |
| 1017 | status = ocfs2_claim_metadata(handle, | 1012 | status = ocfs2_claim_metadata(handle, |
| @@ -1074,8 +1069,8 @@ bail: | |||
| 1074 | brelse(bhs[i]); | 1069 | brelse(bhs[i]); |
| 1075 | bhs[i] = NULL; | 1070 | bhs[i] = NULL; |
| 1076 | } | 1071 | } |
| 1072 | mlog_errno(status); | ||
| 1077 | } | 1073 | } |
| 1078 | mlog_exit(status); | ||
| 1079 | return status; | 1074 | return status; |
| 1080 | } | 1075 | } |
| 1081 | 1076 | ||
| @@ -1173,8 +1168,6 @@ static int ocfs2_add_branch(handle_t *handle, | |||
| 1173 | struct ocfs2_extent_list *el; | 1168 | struct ocfs2_extent_list *el; |
| 1174 | u32 new_cpos, root_end; | 1169 | u32 new_cpos, root_end; |
| 1175 | 1170 | ||
| 1176 | mlog_entry_void(); | ||
| 1177 | |||
| 1178 | BUG_ON(!last_eb_bh || !*last_eb_bh); | 1171 | BUG_ON(!last_eb_bh || !*last_eb_bh); |
| 1179 | 1172 | ||
| 1180 | if (eb_bh) { | 1173 | if (eb_bh) { |
| @@ -1200,8 +1193,11 @@ static int ocfs2_add_branch(handle_t *handle, | |||
| 1200 | * from new_cpos). | 1193 | * from new_cpos). |
| 1201 | */ | 1194 | */ |
| 1202 | if (root_end > new_cpos) { | 1195 | if (root_end > new_cpos) { |
| 1203 | mlog(0, "adjust the cluster end from %u to %u\n", | 1196 | trace_ocfs2_adjust_rightmost_branch( |
| 1204 | root_end, new_cpos); | 1197 | (unsigned long long) |
| 1198 | ocfs2_metadata_cache_owner(et->et_ci), | ||
| 1199 | root_end, new_cpos); | ||
| 1200 | |||
| 1205 | status = ocfs2_adjust_rightmost_branch(handle, et); | 1201 | status = ocfs2_adjust_rightmost_branch(handle, et); |
| 1206 | if (status) { | 1202 | if (status) { |
| 1207 | mlog_errno(status); | 1203 | mlog_errno(status); |
| @@ -1332,7 +1328,6 @@ bail: | |||
| 1332 | kfree(new_eb_bhs); | 1328 | kfree(new_eb_bhs); |
| 1333 | } | 1329 | } |
| 1334 | 1330 | ||
| 1335 | mlog_exit(status); | ||
| 1336 | return status; | 1331 | return status; |
| 1337 | } | 1332 | } |
| 1338 | 1333 | ||
| @@ -1353,8 +1348,6 @@ static int ocfs2_shift_tree_depth(handle_t *handle, | |||
| 1353 | struct ocfs2_extent_list *root_el; | 1348 | struct ocfs2_extent_list *root_el; |
| 1354 | struct ocfs2_extent_list *eb_el; | 1349 | struct ocfs2_extent_list *eb_el; |
| 1355 | 1350 | ||
| 1356 | mlog_entry_void(); | ||
| 1357 | |||
| 1358 | status = ocfs2_create_new_meta_bhs(handle, et, 1, meta_ac, | 1351 | status = ocfs2_create_new_meta_bhs(handle, et, 1, meta_ac, |
| 1359 | &new_eb_bh); | 1352 | &new_eb_bh); |
| 1360 | if (status < 0) { | 1353 | if (status < 0) { |
| @@ -1415,7 +1408,6 @@ static int ocfs2_shift_tree_depth(handle_t *handle, | |||
| 1415 | bail: | 1408 | bail: |
| 1416 | brelse(new_eb_bh); | 1409 | brelse(new_eb_bh); |
| 1417 | 1410 | ||
| 1418 | mlog_exit(status); | ||
| 1419 | return status; | 1411 | return status; |
| 1420 | } | 1412 | } |
| 1421 | 1413 | ||
| @@ -1446,8 +1438,6 @@ static int ocfs2_find_branch_target(struct ocfs2_extent_tree *et, | |||
| 1446 | struct buffer_head *bh = NULL; | 1438 | struct buffer_head *bh = NULL; |
| 1447 | struct buffer_head *lowest_bh = NULL; | 1439 | struct buffer_head *lowest_bh = NULL; |
| 1448 | 1440 | ||
| 1449 | mlog_entry_void(); | ||
| 1450 | |||
| 1451 | *target_bh = NULL; | 1441 | *target_bh = NULL; |
| 1452 | 1442 | ||
| 1453 | el = et->et_root_el; | 1443 | el = et->et_root_el; |
| @@ -1503,7 +1493,6 @@ static int ocfs2_find_branch_target(struct ocfs2_extent_tree *et, | |||
| 1503 | bail: | 1493 | bail: |
| 1504 | brelse(bh); | 1494 | brelse(bh); |
| 1505 | 1495 | ||
| 1506 | mlog_exit(status); | ||
| 1507 | return status; | 1496 | return status; |
| 1508 | } | 1497 | } |
| 1509 | 1498 | ||
| @@ -1540,7 +1529,10 @@ static int ocfs2_grow_tree(handle_t *handle, struct ocfs2_extent_tree *et, | |||
| 1540 | * another tree level */ | 1529 | * another tree level */ |
| 1541 | if (shift) { | 1530 | if (shift) { |
| 1542 | BUG_ON(bh); | 1531 | BUG_ON(bh); |
| 1543 | mlog(0, "need to shift tree depth (current = %d)\n", depth); | 1532 | trace_ocfs2_grow_tree( |
| 1533 | (unsigned long long) | ||
| 1534 | ocfs2_metadata_cache_owner(et->et_ci), | ||
| 1535 | depth); | ||
| 1544 | 1536 | ||
| 1545 | /* ocfs2_shift_tree_depth will return us a buffer with | 1537 | /* ocfs2_shift_tree_depth will return us a buffer with |
| 1546 | * the new extent block (so we can pass that to | 1538 | * the new extent block (so we can pass that to |
| @@ -1570,7 +1562,6 @@ static int ocfs2_grow_tree(handle_t *handle, struct ocfs2_extent_tree *et, | |||
| 1570 | 1562 | ||
| 1571 | /* call ocfs2_add_branch to add the final part of the tree with | 1563 | /* call ocfs2_add_branch to add the final part of the tree with |
| 1572 | * the new data. */ | 1564 | * the new data. */ |
| 1573 | mlog(0, "add branch. bh = %p\n", bh); | ||
| 1574 | ret = ocfs2_add_branch(handle, et, bh, last_eb_bh, | 1565 | ret = ocfs2_add_branch(handle, et, bh, last_eb_bh, |
| 1575 | meta_ac); | 1566 | meta_ac); |
| 1576 | if (ret < 0) { | 1567 | if (ret < 0) { |
| @@ -1645,8 +1636,9 @@ static void ocfs2_rotate_leaf(struct ocfs2_extent_list *el, | |||
| 1645 | } | 1636 | } |
| 1646 | insert_index = i; | 1637 | insert_index = i; |
| 1647 | 1638 | ||
| 1648 | mlog(0, "ins %u: index %d, has_empty %d, next_free %d, count %d\n", | 1639 | trace_ocfs2_rotate_leaf(insert_cpos, insert_index, |
| 1649 | insert_cpos, insert_index, has_empty, next_free, le16_to_cpu(el->l_count)); | 1640 | has_empty, next_free, |
| 1641 | le16_to_cpu(el->l_count)); | ||
| 1650 | 1642 | ||
| 1651 | BUG_ON(insert_index < 0); | 1643 | BUG_ON(insert_index < 0); |
| 1652 | BUG_ON(insert_index >= le16_to_cpu(el->l_count)); | 1644 | BUG_ON(insert_index >= le16_to_cpu(el->l_count)); |
| @@ -2059,7 +2051,7 @@ static void ocfs2_complete_edge_insert(handle_t *handle, | |||
| 2059 | left_el = path_leaf_el(left_path); | 2051 | left_el = path_leaf_el(left_path); |
| 2060 | right_el = path_leaf_el(right_path); | 2052 | right_el = path_leaf_el(right_path); |
| 2061 | for(i = left_path->p_tree_depth - 1; i > subtree_index; i--) { | 2053 | for(i = left_path->p_tree_depth - 1; i > subtree_index; i--) { |
| 2062 | mlog(0, "Adjust records at index %u\n", i); | 2054 | trace_ocfs2_complete_edge_insert(i); |
| 2063 | 2055 | ||
| 2064 | /* | 2056 | /* |
| 2065 | * One nice property of knowing that all of these | 2057 | * One nice property of knowing that all of these |
| @@ -2389,7 +2381,9 @@ static int ocfs2_rotate_tree_right(handle_t *handle, | |||
| 2389 | goto out; | 2381 | goto out; |
| 2390 | } | 2382 | } |
| 2391 | 2383 | ||
| 2392 | mlog(0, "Insert: %u, first left path cpos: %u\n", insert_cpos, cpos); | 2384 | trace_ocfs2_rotate_tree_right( |
| 2385 | (unsigned long long)ocfs2_metadata_cache_owner(et->et_ci), | ||
| 2386 | insert_cpos, cpos); | ||
| 2393 | 2387 | ||
| 2394 | /* | 2388 | /* |
| 2395 | * What we want to do here is: | 2389 | * What we want to do here is: |
| @@ -2418,8 +2412,10 @@ static int ocfs2_rotate_tree_right(handle_t *handle, | |||
| 2418 | * rotating subtrees. | 2412 | * rotating subtrees. |
| 2419 | */ | 2413 | */ |
| 2420 | while (cpos && insert_cpos <= cpos) { | 2414 | while (cpos && insert_cpos <= cpos) { |
| 2421 | mlog(0, "Rotating a tree: ins. cpos: %u, left path cpos: %u\n", | 2415 | trace_ocfs2_rotate_tree_right( |
| 2422 | insert_cpos, cpos); | 2416 | (unsigned long long) |
| 2417 | ocfs2_metadata_cache_owner(et->et_ci), | ||
| 2418 | insert_cpos, cpos); | ||
| 2423 | 2419 | ||
| 2424 | ret = ocfs2_find_path(et->et_ci, left_path, cpos); | 2420 | ret = ocfs2_find_path(et->et_ci, left_path, cpos); |
| 2425 | if (ret) { | 2421 | if (ret) { |
| @@ -2461,10 +2457,10 @@ static int ocfs2_rotate_tree_right(handle_t *handle, | |||
| 2461 | 2457 | ||
| 2462 | start = ocfs2_find_subtree_root(et, left_path, right_path); | 2458 | start = ocfs2_find_subtree_root(et, left_path, right_path); |
| 2463 | 2459 | ||
| 2464 | mlog(0, "Subtree root at index %d (blk %llu, depth %d)\n", | 2460 | trace_ocfs2_rotate_subtree(start, |
| 2465 | start, | 2461 | (unsigned long long) |
| 2466 | (unsigned long long) right_path->p_node[start].bh->b_blocknr, | 2462 | right_path->p_node[start].bh->b_blocknr, |
| 2467 | right_path->p_tree_depth); | 2463 | right_path->p_tree_depth); |
| 2468 | 2464 | ||
| 2469 | ret = ocfs2_extend_rotate_transaction(handle, start, | 2465 | ret = ocfs2_extend_rotate_transaction(handle, start, |
| 2470 | orig_credits, right_path); | 2466 | orig_credits, right_path); |
| @@ -2964,8 +2960,7 @@ static int __ocfs2_rotate_tree_left(handle_t *handle, | |||
| 2964 | subtree_root = ocfs2_find_subtree_root(et, left_path, | 2960 | subtree_root = ocfs2_find_subtree_root(et, left_path, |
| 2965 | right_path); | 2961 | right_path); |
| 2966 | 2962 | ||
| 2967 | mlog(0, "Subtree root at index %d (blk %llu, depth %d)\n", | 2963 | trace_ocfs2_rotate_subtree(subtree_root, |
| 2968 | subtree_root, | ||
| 2969 | (unsigned long long) | 2964 | (unsigned long long) |
| 2970 | right_path->p_node[subtree_root].bh->b_blocknr, | 2965 | right_path->p_node[subtree_root].bh->b_blocknr, |
| 2971 | right_path->p_tree_depth); | 2966 | right_path->p_tree_depth); |
| @@ -3989,9 +3984,11 @@ static int ocfs2_append_rec_to_path(handle_t *handle, | |||
| 3989 | goto out; | 3984 | goto out; |
| 3990 | } | 3985 | } |
| 3991 | 3986 | ||
| 3992 | mlog(0, "Append may need a left path update. cpos: %u, " | 3987 | trace_ocfs2_append_rec_to_path( |
| 3993 | "left_cpos: %u\n", le32_to_cpu(insert_rec->e_cpos), | 3988 | (unsigned long long) |
| 3994 | left_cpos); | 3989 | ocfs2_metadata_cache_owner(et->et_ci), |
| 3990 | le32_to_cpu(insert_rec->e_cpos), | ||
| 3991 | left_cpos); | ||
| 3995 | 3992 | ||
| 3996 | /* | 3993 | /* |
| 3997 | * No need to worry if the append is already in the | 3994 | * No need to worry if the append is already in the |
| @@ -4562,7 +4559,7 @@ static int ocfs2_figure_insert_type(struct ocfs2_extent_tree *et, | |||
| 4562 | ocfs2_et_get_last_eb_blk(et), | 4559 | ocfs2_et_get_last_eb_blk(et), |
| 4563 | &bh); | 4560 | &bh); |
| 4564 | if (ret) { | 4561 | if (ret) { |
| 4565 | mlog_exit(ret); | 4562 | mlog_errno(ret); |
| 4566 | goto out; | 4563 | goto out; |
| 4567 | } | 4564 | } |
| 4568 | eb = (struct ocfs2_extent_block *) bh->b_data; | 4565 | eb = (struct ocfs2_extent_block *) bh->b_data; |
| @@ -4678,9 +4675,9 @@ int ocfs2_insert_extent(handle_t *handle, | |||
| 4678 | struct ocfs2_insert_type insert = {0, }; | 4675 | struct ocfs2_insert_type insert = {0, }; |
| 4679 | struct ocfs2_extent_rec rec; | 4676 | struct ocfs2_extent_rec rec; |
| 4680 | 4677 | ||
| 4681 | mlog(0, "add %u clusters at position %u to owner %llu\n", | 4678 | trace_ocfs2_insert_extent_start( |
| 4682 | new_clusters, cpos, | 4679 | (unsigned long long)ocfs2_metadata_cache_owner(et->et_ci), |
| 4683 | (unsigned long long)ocfs2_metadata_cache_owner(et->et_ci)); | 4680 | cpos, new_clusters); |
| 4684 | 4681 | ||
| 4685 | memset(&rec, 0, sizeof(rec)); | 4682 | memset(&rec, 0, sizeof(rec)); |
| 4686 | rec.e_cpos = cpu_to_le32(cpos); | 4683 | rec.e_cpos = cpu_to_le32(cpos); |
| @@ -4700,11 +4697,9 @@ int ocfs2_insert_extent(handle_t *handle, | |||
| 4700 | goto bail; | 4697 | goto bail; |
| 4701 | } | 4698 | } |
| 4702 | 4699 | ||
| 4703 | mlog(0, "Insert.appending: %u, Insert.Contig: %u, " | 4700 | trace_ocfs2_insert_extent(insert.ins_appending, insert.ins_contig, |
| 4704 | "Insert.contig_index: %d, Insert.free_records: %d, " | 4701 | insert.ins_contig_index, free_records, |
| 4705 | "Insert.tree_depth: %d\n", | 4702 | insert.ins_tree_depth); |
| 4706 | insert.ins_appending, insert.ins_contig, insert.ins_contig_index, | ||
| 4707 | free_records, insert.ins_tree_depth); | ||
| 4708 | 4703 | ||
| 4709 | if (insert.ins_contig == CONTIG_NONE && free_records == 0) { | 4704 | if (insert.ins_contig == CONTIG_NONE && free_records == 0) { |
| 4710 | status = ocfs2_grow_tree(handle, et, | 4705 | status = ocfs2_grow_tree(handle, et, |
| @@ -4726,7 +4721,6 @@ int ocfs2_insert_extent(handle_t *handle, | |||
| 4726 | bail: | 4721 | bail: |
| 4727 | brelse(last_eb_bh); | 4722 | brelse(last_eb_bh); |
| 4728 | 4723 | ||
| 4729 | mlog_exit(status); | ||
| 4730 | return status; | 4724 | return status; |
| 4731 | } | 4725 | } |
| 4732 | 4726 | ||
| @@ -4746,7 +4740,7 @@ int ocfs2_add_clusters_in_btree(handle_t *handle, | |||
| 4746 | struct ocfs2_alloc_context *meta_ac, | 4740 | struct ocfs2_alloc_context *meta_ac, |
| 4747 | enum ocfs2_alloc_restarted *reason_ret) | 4741 | enum ocfs2_alloc_restarted *reason_ret) |
| 4748 | { | 4742 | { |
| 4749 | int status = 0; | 4743 | int status = 0, err = 0; |
| 4750 | int free_extents; | 4744 | int free_extents; |
| 4751 | enum ocfs2_alloc_restarted reason = RESTART_NONE; | 4745 | enum ocfs2_alloc_restarted reason = RESTART_NONE; |
| 4752 | u32 bit_off, num_bits; | 4746 | u32 bit_off, num_bits; |
| @@ -4773,14 +4767,14 @@ int ocfs2_add_clusters_in_btree(handle_t *handle, | |||
| 4773 | * 2) we are so fragmented, we've needed to add metadata too | 4767 | * 2) we are so fragmented, we've needed to add metadata too |
| 4774 | * many times. */ | 4768 | * many times. */ |
| 4775 | if (!free_extents && !meta_ac) { | 4769 | if (!free_extents && !meta_ac) { |
| 4776 | mlog(0, "we haven't reserved any metadata!\n"); | 4770 | err = -1; |
| 4777 | status = -EAGAIN; | 4771 | status = -EAGAIN; |
| 4778 | reason = RESTART_META; | 4772 | reason = RESTART_META; |
| 4779 | goto leave; | 4773 | goto leave; |
| 4780 | } else if ((!free_extents) | 4774 | } else if ((!free_extents) |
| 4781 | && (ocfs2_alloc_context_bits_left(meta_ac) | 4775 | && (ocfs2_alloc_context_bits_left(meta_ac) |
| 4782 | < ocfs2_extend_meta_needed(et->et_root_el))) { | 4776 | < ocfs2_extend_meta_needed(et->et_root_el))) { |
| 4783 | mlog(0, "filesystem is really fragmented...\n"); | 4777 | err = -2; |
| 4784 | status = -EAGAIN; | 4778 | status = -EAGAIN; |
| 4785 | reason = RESTART_META; | 4779 | reason = RESTART_META; |
| 4786 | goto leave; | 4780 | goto leave; |
| @@ -4805,9 +4799,9 @@ int ocfs2_add_clusters_in_btree(handle_t *handle, | |||
| 4805 | } | 4799 | } |
| 4806 | 4800 | ||
| 4807 | block = ocfs2_clusters_to_blocks(osb->sb, bit_off); | 4801 | block = ocfs2_clusters_to_blocks(osb->sb, bit_off); |
| 4808 | mlog(0, "Allocating %u clusters at block %u for owner %llu\n", | 4802 | trace_ocfs2_add_clusters_in_btree( |
| 4809 | num_bits, bit_off, | 4803 | (unsigned long long)ocfs2_metadata_cache_owner(et->et_ci), |
| 4810 | (unsigned long long)ocfs2_metadata_cache_owner(et->et_ci)); | 4804 | bit_off, num_bits); |
| 4811 | status = ocfs2_insert_extent(handle, et, *logical_offset, block, | 4805 | status = ocfs2_insert_extent(handle, et, *logical_offset, block, |
| 4812 | num_bits, flags, meta_ac); | 4806 | num_bits, flags, meta_ac); |
| 4813 | if (status < 0) { | 4807 | if (status < 0) { |
| @@ -4821,16 +4815,15 @@ int ocfs2_add_clusters_in_btree(handle_t *handle, | |||
| 4821 | *logical_offset += num_bits; | 4815 | *logical_offset += num_bits; |
| 4822 | 4816 | ||
| 4823 | if (clusters_to_add) { | 4817 | if (clusters_to_add) { |
| 4824 | mlog(0, "need to alloc once more, wanted = %u\n", | 4818 | err = clusters_to_add; |
| 4825 | clusters_to_add); | ||
| 4826 | status = -EAGAIN; | 4819 | status = -EAGAIN; |
| 4827 | reason = RESTART_TRANS; | 4820 | reason = RESTART_TRANS; |
| 4828 | } | 4821 | } |
| 4829 | 4822 | ||
| 4830 | leave: | 4823 | leave: |
| 4831 | mlog_exit(status); | ||
| 4832 | if (reason_ret) | 4824 | if (reason_ret) |
| 4833 | *reason_ret = reason; | 4825 | *reason_ret = reason; |
| 4826 | trace_ocfs2_add_clusters_in_btree_ret(status, reason, err); | ||
| 4834 | return status; | 4827 | return status; |
| 4835 | } | 4828 | } |
| 4836 | 4829 | ||
| @@ -5039,7 +5032,7 @@ int ocfs2_split_extent(handle_t *handle, | |||
| 5039 | ocfs2_et_get_last_eb_blk(et), | 5032 | ocfs2_et_get_last_eb_blk(et), |
| 5040 | &last_eb_bh); | 5033 | &last_eb_bh); |
| 5041 | if (ret) { | 5034 | if (ret) { |
| 5042 | mlog_exit(ret); | 5035 | mlog_errno(ret); |
| 5043 | goto out; | 5036 | goto out; |
| 5044 | } | 5037 | } |
| 5045 | 5038 | ||
| @@ -5056,9 +5049,9 @@ int ocfs2_split_extent(handle_t *handle, | |||
| 5056 | 5049 | ||
| 5057 | ctxt.c_has_empty_extent = ocfs2_is_empty_extent(&el->l_recs[0]); | 5050 | ctxt.c_has_empty_extent = ocfs2_is_empty_extent(&el->l_recs[0]); |
| 5058 | 5051 | ||
| 5059 | mlog(0, "index: %d, contig: %u, has_empty: %u, split_covers: %u\n", | 5052 | trace_ocfs2_split_extent(split_index, ctxt.c_contig_type, |
| 5060 | split_index, ctxt.c_contig_type, ctxt.c_has_empty_extent, | 5053 | ctxt.c_has_empty_extent, |
| 5061 | ctxt.c_split_covers_rec); | 5054 | ctxt.c_split_covers_rec); |
| 5062 | 5055 | ||
| 5063 | if (ctxt.c_contig_type == CONTIG_NONE) { | 5056 | if (ctxt.c_contig_type == CONTIG_NONE) { |
| 5064 | if (ctxt.c_split_covers_rec) | 5057 | if (ctxt.c_split_covers_rec) |
| @@ -5192,8 +5185,9 @@ int ocfs2_mark_extent_written(struct inode *inode, | |||
| 5192 | { | 5185 | { |
| 5193 | int ret; | 5186 | int ret; |
| 5194 | 5187 | ||
| 5195 | mlog(0, "Inode %lu cpos %u, len %u, phys clusters %u\n", | 5188 | trace_ocfs2_mark_extent_written( |
| 5196 | inode->i_ino, cpos, len, phys); | 5189 | (unsigned long long)OCFS2_I(inode)->ip_blkno, |
| 5190 | cpos, len, phys); | ||
| 5197 | 5191 | ||
| 5198 | if (!ocfs2_writes_unwritten_extents(OCFS2_SB(inode->i_sb))) { | 5192 | if (!ocfs2_writes_unwritten_extents(OCFS2_SB(inode->i_sb))) { |
| 5199 | ocfs2_error(inode->i_sb, "Inode %llu has unwritten extents " | 5193 | ocfs2_error(inode->i_sb, "Inode %llu has unwritten extents " |
| @@ -5512,11 +5506,10 @@ int ocfs2_remove_extent(handle_t *handle, | |||
| 5512 | 5506 | ||
| 5513 | BUG_ON(cpos < le32_to_cpu(rec->e_cpos) || trunc_range > rec_range); | 5507 | BUG_ON(cpos < le32_to_cpu(rec->e_cpos) || trunc_range > rec_range); |
| 5514 | 5508 | ||
| 5515 | mlog(0, "Owner %llu, remove (cpos %u, len %u). Existing index %d " | 5509 | trace_ocfs2_remove_extent( |
| 5516 | "(cpos %u, len %u)\n", | 5510 | (unsigned long long)ocfs2_metadata_cache_owner(et->et_ci), |
| 5517 | (unsigned long long)ocfs2_metadata_cache_owner(et->et_ci), | 5511 | cpos, len, index, le32_to_cpu(rec->e_cpos), |
| 5518 | cpos, len, index, | 5512 | ocfs2_rec_clusters(el, rec)); |
| 5519 | le32_to_cpu(rec->e_cpos), ocfs2_rec_clusters(el, rec)); | ||
| 5520 | 5513 | ||
| 5521 | if (le32_to_cpu(rec->e_cpos) == cpos || rec_range == trunc_range) { | 5514 | if (le32_to_cpu(rec->e_cpos) == cpos || rec_range == trunc_range) { |
| 5522 | ret = ocfs2_truncate_rec(handle, et, path, index, dealloc, | 5515 | ret = ocfs2_truncate_rec(handle, et, path, index, dealloc, |
| @@ -5795,9 +5788,6 @@ int ocfs2_truncate_log_append(struct ocfs2_super *osb, | |||
| 5795 | struct ocfs2_dinode *di; | 5788 | struct ocfs2_dinode *di; |
| 5796 | struct ocfs2_truncate_log *tl; | 5789 | struct ocfs2_truncate_log *tl; |
| 5797 | 5790 | ||
| 5798 | mlog_entry("start_blk = %llu, num_clusters = %u\n", | ||
| 5799 | (unsigned long long)start_blk, num_clusters); | ||
| 5800 | |||
| 5801 | BUG_ON(mutex_trylock(&tl_inode->i_mutex)); | 5791 | BUG_ON(mutex_trylock(&tl_inode->i_mutex)); |
| 5802 | 5792 | ||
| 5803 | start_cluster = ocfs2_blocks_to_clusters(osb->sb, start_blk); | 5793 | start_cluster = ocfs2_blocks_to_clusters(osb->sb, start_blk); |
| @@ -5834,10 +5824,9 @@ int ocfs2_truncate_log_append(struct ocfs2_super *osb, | |||
| 5834 | goto bail; | 5824 | goto bail; |
| 5835 | } | 5825 | } |
| 5836 | 5826 | ||
| 5837 | mlog(0, "Log truncate of %u clusters starting at cluster %u to " | 5827 | trace_ocfs2_truncate_log_append( |
| 5838 | "%llu (index = %d)\n", num_clusters, start_cluster, | 5828 | (unsigned long long)OCFS2_I(tl_inode)->ip_blkno, index, |
| 5839 | (unsigned long long)OCFS2_I(tl_inode)->ip_blkno, index); | 5829 | start_cluster, num_clusters); |
| 5840 | |||
| 5841 | if (ocfs2_truncate_log_can_coalesce(tl, start_cluster)) { | 5830 | if (ocfs2_truncate_log_can_coalesce(tl, start_cluster)) { |
| 5842 | /* | 5831 | /* |
| 5843 | * Move index back to the record we are coalescing with. | 5832 | * Move index back to the record we are coalescing with. |
| @@ -5846,9 +5835,10 @@ int ocfs2_truncate_log_append(struct ocfs2_super *osb, | |||
| 5846 | index--; | 5835 | index--; |
| 5847 | 5836 | ||
| 5848 | num_clusters += le32_to_cpu(tl->tl_recs[index].t_clusters); | 5837 | num_clusters += le32_to_cpu(tl->tl_recs[index].t_clusters); |
| 5849 | mlog(0, "Coalesce with index %u (start = %u, clusters = %u)\n", | 5838 | trace_ocfs2_truncate_log_append( |
| 5850 | index, le32_to_cpu(tl->tl_recs[index].t_start), | 5839 | (unsigned long long)OCFS2_I(tl_inode)->ip_blkno, |
| 5851 | num_clusters); | 5840 | index, le32_to_cpu(tl->tl_recs[index].t_start), |
| 5841 | num_clusters); | ||
| 5852 | } else { | 5842 | } else { |
| 5853 | tl->tl_recs[index].t_start = cpu_to_le32(start_cluster); | 5843 | tl->tl_recs[index].t_start = cpu_to_le32(start_cluster); |
| 5854 | tl->tl_used = cpu_to_le16(index + 1); | 5844 | tl->tl_used = cpu_to_le16(index + 1); |
| @@ -5859,7 +5849,6 @@ int ocfs2_truncate_log_append(struct ocfs2_super *osb, | |||
| 5859 | 5849 | ||
| 5860 | osb->truncated_clusters += num_clusters; | 5850 | osb->truncated_clusters += num_clusters; |
| 5861 | bail: | 5851 | bail: |
| 5862 | mlog_exit(status); | ||
| 5863 | return status; | 5852 | return status; |
| 5864 | } | 5853 | } |
| 5865 | 5854 | ||
| @@ -5878,8 +5867,6 @@ static int ocfs2_replay_truncate_records(struct ocfs2_super *osb, | |||
| 5878 | struct inode *tl_inode = osb->osb_tl_inode; | 5867 | struct inode *tl_inode = osb->osb_tl_inode; |
| 5879 | struct buffer_head *tl_bh = osb->osb_tl_bh; | 5868 | struct buffer_head *tl_bh = osb->osb_tl_bh; |
| 5880 | 5869 | ||
| 5881 | mlog_entry_void(); | ||
| 5882 | |||
| 5883 | di = (struct ocfs2_dinode *) tl_bh->b_data; | 5870 | di = (struct ocfs2_dinode *) tl_bh->b_data; |
| 5884 | tl = &di->id2.i_dealloc; | 5871 | tl = &di->id2.i_dealloc; |
| 5885 | i = le16_to_cpu(tl->tl_used) - 1; | 5872 | i = le16_to_cpu(tl->tl_used) - 1; |
| @@ -5915,8 +5902,9 @@ static int ocfs2_replay_truncate_records(struct ocfs2_super *osb, | |||
| 5915 | /* if start_blk is not set, we ignore the record as | 5902 | /* if start_blk is not set, we ignore the record as |
| 5916 | * invalid. */ | 5903 | * invalid. */ |
| 5917 | if (start_blk) { | 5904 | if (start_blk) { |
| 5918 | mlog(0, "free record %d, start = %u, clusters = %u\n", | 5905 | trace_ocfs2_replay_truncate_records( |
| 5919 | i, le32_to_cpu(rec.t_start), num_clusters); | 5906 | (unsigned long long)OCFS2_I(tl_inode)->ip_blkno, |
| 5907 | i, le32_to_cpu(rec.t_start), num_clusters); | ||
| 5920 | 5908 | ||
| 5921 | status = ocfs2_free_clusters(handle, data_alloc_inode, | 5909 | status = ocfs2_free_clusters(handle, data_alloc_inode, |
| 5922 | data_alloc_bh, start_blk, | 5910 | data_alloc_bh, start_blk, |
| @@ -5932,7 +5920,6 @@ static int ocfs2_replay_truncate_records(struct ocfs2_super *osb, | |||
| 5932 | osb->truncated_clusters = 0; | 5920 | osb->truncated_clusters = 0; |
| 5933 | 5921 | ||
| 5934 | bail: | 5922 | bail: |
| 5935 | mlog_exit(status); | ||
| 5936 | return status; | 5923 | return status; |
| 5937 | } | 5924 | } |
| 5938 | 5925 | ||
| @@ -5949,8 +5936,6 @@ int __ocfs2_flush_truncate_log(struct ocfs2_super *osb) | |||
| 5949 | struct ocfs2_dinode *di; | 5936 | struct ocfs2_dinode *di; |
| 5950 | struct ocfs2_truncate_log *tl; | 5937 | struct ocfs2_truncate_log *tl; |
| 5951 | 5938 | ||
| 5952 | mlog_entry_void(); | ||
| 5953 | |||
| 5954 | BUG_ON(mutex_trylock(&tl_inode->i_mutex)); | 5939 | BUG_ON(mutex_trylock(&tl_inode->i_mutex)); |
| 5955 | 5940 | ||
| 5956 | di = (struct ocfs2_dinode *) tl_bh->b_data; | 5941 | di = (struct ocfs2_dinode *) tl_bh->b_data; |
| @@ -5962,8 +5947,9 @@ int __ocfs2_flush_truncate_log(struct ocfs2_super *osb) | |||
| 5962 | 5947 | ||
| 5963 | tl = &di->id2.i_dealloc; | 5948 | tl = &di->id2.i_dealloc; |
| 5964 | num_to_flush = le16_to_cpu(tl->tl_used); | 5949 | num_to_flush = le16_to_cpu(tl->tl_used); |
| 5965 | mlog(0, "Flush %u records from truncate log #%llu\n", | 5950 | trace_ocfs2_flush_truncate_log( |
| 5966 | num_to_flush, (unsigned long long)OCFS2_I(tl_inode)->ip_blkno); | 5951 | (unsigned long long)OCFS2_I(tl_inode)->ip_blkno, |
| 5952 | num_to_flush); | ||
| 5967 | if (!num_to_flush) { | 5953 | if (!num_to_flush) { |
| 5968 | status = 0; | 5954 | status = 0; |
| 5969 | goto out; | 5955 | goto out; |
| @@ -6009,7 +5995,6 @@ out_mutex: | |||
| 6009 | iput(data_alloc_inode); | 5995 | iput(data_alloc_inode); |
| 6010 | 5996 | ||
| 6011 | out: | 5997 | out: |
| 6012 | mlog_exit(status); | ||
| 6013 | return status; | 5998 | return status; |
| 6014 | } | 5999 | } |
| 6015 | 6000 | ||
| @@ -6032,15 +6017,11 @@ static void ocfs2_truncate_log_worker(struct work_struct *work) | |||
| 6032 | container_of(work, struct ocfs2_super, | 6017 | container_of(work, struct ocfs2_super, |
| 6033 | osb_truncate_log_wq.work); | 6018 | osb_truncate_log_wq.work); |
| 6034 | 6019 | ||
| 6035 | mlog_entry_void(); | ||
| 6036 | |||
| 6037 | status = ocfs2_flush_truncate_log(osb); | 6020 | status = ocfs2_flush_truncate_log(osb); |
| 6038 | if (status < 0) | 6021 | if (status < 0) |
| 6039 | mlog_errno(status); | 6022 | mlog_errno(status); |
| 6040 | else | 6023 | else |
| 6041 | ocfs2_init_steal_slots(osb); | 6024 | ocfs2_init_steal_slots(osb); |
| 6042 | |||
| 6043 | mlog_exit(status); | ||
| 6044 | } | 6025 | } |
| 6045 | 6026 | ||
| 6046 | #define OCFS2_TRUNCATE_LOG_FLUSH_INTERVAL (2 * HZ) | 6027 | #define OCFS2_TRUNCATE_LOG_FLUSH_INTERVAL (2 * HZ) |
| @@ -6086,7 +6067,6 @@ static int ocfs2_get_truncate_log_info(struct ocfs2_super *osb, | |||
| 6086 | *tl_inode = inode; | 6067 | *tl_inode = inode; |
| 6087 | *tl_bh = bh; | 6068 | *tl_bh = bh; |
| 6088 | bail: | 6069 | bail: |
| 6089 | mlog_exit(status); | ||
| 6090 | return status; | 6070 | return status; |
| 6091 | } | 6071 | } |
| 6092 | 6072 | ||
| @@ -6106,7 +6086,7 @@ int ocfs2_begin_truncate_log_recovery(struct ocfs2_super *osb, | |||
| 6106 | 6086 | ||
| 6107 | *tl_copy = NULL; | 6087 | *tl_copy = NULL; |
| 6108 | 6088 | ||
| 6109 | mlog(0, "recover truncate log from slot %d\n", slot_num); | 6089 | trace_ocfs2_begin_truncate_log_recovery(slot_num); |
| 6110 | 6090 | ||
| 6111 | status = ocfs2_get_truncate_log_info(osb, slot_num, &tl_inode, &tl_bh); | 6091 | status = ocfs2_get_truncate_log_info(osb, slot_num, &tl_inode, &tl_bh); |
| 6112 | if (status < 0) { | 6092 | if (status < 0) { |
| @@ -6123,8 +6103,7 @@ int ocfs2_begin_truncate_log_recovery(struct ocfs2_super *osb, | |||
| 6123 | 6103 | ||
| 6124 | tl = &di->id2.i_dealloc; | 6104 | tl = &di->id2.i_dealloc; |
| 6125 | if (le16_to_cpu(tl->tl_used)) { | 6105 | if (le16_to_cpu(tl->tl_used)) { |
| 6126 | mlog(0, "We'll have %u logs to recover\n", | 6106 | trace_ocfs2_truncate_log_recovery_num(le16_to_cpu(tl->tl_used)); |
| 6127 | le16_to_cpu(tl->tl_used)); | ||
| 6128 | 6107 | ||
| 6129 | *tl_copy = kmalloc(tl_bh->b_size, GFP_KERNEL); | 6108 | *tl_copy = kmalloc(tl_bh->b_size, GFP_KERNEL); |
| 6130 | if (!(*tl_copy)) { | 6109 | if (!(*tl_copy)) { |
| @@ -6157,9 +6136,9 @@ bail: | |||
| 6157 | if (status < 0 && (*tl_copy)) { | 6136 | if (status < 0 && (*tl_copy)) { |
| 6158 | kfree(*tl_copy); | 6137 | kfree(*tl_copy); |
| 6159 | *tl_copy = NULL; | 6138 | *tl_copy = NULL; |
| 6139 | mlog_errno(status); | ||
| 6160 | } | 6140 | } |
| 6161 | 6141 | ||
| 6162 | mlog_exit(status); | ||
| 6163 | return status; | 6142 | return status; |
| 6164 | } | 6143 | } |
| 6165 | 6144 | ||
| @@ -6174,8 +6153,6 @@ int ocfs2_complete_truncate_log_recovery(struct ocfs2_super *osb, | |||
| 6174 | struct inode *tl_inode = osb->osb_tl_inode; | 6153 | struct inode *tl_inode = osb->osb_tl_inode; |
| 6175 | struct ocfs2_truncate_log *tl; | 6154 | struct ocfs2_truncate_log *tl; |
| 6176 | 6155 | ||
| 6177 | mlog_entry_void(); | ||
| 6178 | |||
| 6179 | if (OCFS2_I(tl_inode)->ip_blkno == le64_to_cpu(tl_copy->i_blkno)) { | 6156 | if (OCFS2_I(tl_inode)->ip_blkno == le64_to_cpu(tl_copy->i_blkno)) { |
| 6180 | mlog(ML_ERROR, "Asked to recover my own truncate log!\n"); | 6157 | mlog(ML_ERROR, "Asked to recover my own truncate log!\n"); |
| 6181 | return -EINVAL; | 6158 | return -EINVAL; |
| @@ -6183,8 +6160,9 @@ int ocfs2_complete_truncate_log_recovery(struct ocfs2_super *osb, | |||
| 6183 | 6160 | ||
| 6184 | tl = &tl_copy->id2.i_dealloc; | 6161 | tl = &tl_copy->id2.i_dealloc; |
| 6185 | num_recs = le16_to_cpu(tl->tl_used); | 6162 | num_recs = le16_to_cpu(tl->tl_used); |
| 6186 | mlog(0, "cleanup %u records from %llu\n", num_recs, | 6163 | trace_ocfs2_complete_truncate_log_recovery( |
| 6187 | (unsigned long long)le64_to_cpu(tl_copy->i_blkno)); | 6164 | (unsigned long long)le64_to_cpu(tl_copy->i_blkno), |
| 6165 | num_recs); | ||
| 6188 | 6166 | ||
| 6189 | mutex_lock(&tl_inode->i_mutex); | 6167 | mutex_lock(&tl_inode->i_mutex); |
| 6190 | for(i = 0; i < num_recs; i++) { | 6168 | for(i = 0; i < num_recs; i++) { |
| @@ -6219,7 +6197,6 @@ int ocfs2_complete_truncate_log_recovery(struct ocfs2_super *osb, | |||
| 6219 | bail_up: | 6197 | bail_up: |
| 6220 | mutex_unlock(&tl_inode->i_mutex); | 6198 | mutex_unlock(&tl_inode->i_mutex); |
| 6221 | 6199 | ||
| 6222 | mlog_exit(status); | ||
| 6223 | return status; | 6200 | return status; |
| 6224 | } | 6201 | } |
| 6225 | 6202 | ||
| @@ -6228,8 +6205,6 @@ void ocfs2_truncate_log_shutdown(struct ocfs2_super *osb) | |||
| 6228 | int status; | 6205 | int status; |
| 6229 | struct inode *tl_inode = osb->osb_tl_inode; | 6206 | struct inode *tl_inode = osb->osb_tl_inode; |
| 6230 | 6207 | ||
| 6231 | mlog_entry_void(); | ||
| 6232 | |||
| 6233 | if (tl_inode) { | 6208 | if (tl_inode) { |
| 6234 | cancel_delayed_work(&osb->osb_truncate_log_wq); | 6209 | cancel_delayed_work(&osb->osb_truncate_log_wq); |
| 6235 | flush_workqueue(ocfs2_wq); | 6210 | flush_workqueue(ocfs2_wq); |
| @@ -6241,8 +6216,6 @@ void ocfs2_truncate_log_shutdown(struct ocfs2_super *osb) | |||
| 6241 | brelse(osb->osb_tl_bh); | 6216 | brelse(osb->osb_tl_bh); |
| 6242 | iput(osb->osb_tl_inode); | 6217 | iput(osb->osb_tl_inode); |
| 6243 | } | 6218 | } |
| 6244 | |||
| 6245 | mlog_exit_void(); | ||
| 6246 | } | 6219 | } |
| 6247 | 6220 | ||
| 6248 | int ocfs2_truncate_log_init(struct ocfs2_super *osb) | 6221 | int ocfs2_truncate_log_init(struct ocfs2_super *osb) |
| @@ -6251,8 +6224,6 @@ int ocfs2_truncate_log_init(struct ocfs2_super *osb) | |||
| 6251 | struct inode *tl_inode = NULL; | 6224 | struct inode *tl_inode = NULL; |
| 6252 | struct buffer_head *tl_bh = NULL; | 6225 | struct buffer_head *tl_bh = NULL; |
| 6253 | 6226 | ||
| 6254 | mlog_entry_void(); | ||
| 6255 | |||
| 6256 | status = ocfs2_get_truncate_log_info(osb, | 6227 | status = ocfs2_get_truncate_log_info(osb, |
| 6257 | osb->slot_num, | 6228 | osb->slot_num, |
| 6258 | &tl_inode, | 6229 | &tl_inode, |
| @@ -6268,7 +6239,6 @@ int ocfs2_truncate_log_init(struct ocfs2_super *osb) | |||
| 6268 | osb->osb_tl_bh = tl_bh; | 6239 | osb->osb_tl_bh = tl_bh; |
| 6269 | osb->osb_tl_inode = tl_inode; | 6240 | osb->osb_tl_inode = tl_inode; |
| 6270 | 6241 | ||
| 6271 | mlog_exit(status); | ||
| 6272 | return status; | 6242 | return status; |
| 6273 | } | 6243 | } |
| 6274 | 6244 | ||
| @@ -6350,8 +6320,8 @@ static int ocfs2_free_cached_blocks(struct ocfs2_super *osb, | |||
| 6350 | else | 6320 | else |
| 6351 | bg_blkno = ocfs2_which_suballoc_group(head->free_blk, | 6321 | bg_blkno = ocfs2_which_suballoc_group(head->free_blk, |
| 6352 | head->free_bit); | 6322 | head->free_bit); |
| 6353 | mlog(0, "Free bit: (bit %u, blkno %llu)\n", | 6323 | trace_ocfs2_free_cached_blocks( |
| 6354 | head->free_bit, (unsigned long long)head->free_blk); | 6324 | (unsigned long long)head->free_blk, head->free_bit); |
| 6355 | 6325 | ||
| 6356 | ret = ocfs2_free_suballoc_bits(handle, inode, di_bh, | 6326 | ret = ocfs2_free_suballoc_bits(handle, inode, di_bh, |
| 6357 | head->free_bit, bg_blkno, 1); | 6327 | head->free_bit, bg_blkno, 1); |
| @@ -6404,8 +6374,7 @@ int ocfs2_cache_cluster_dealloc(struct ocfs2_cached_dealloc_ctxt *ctxt, | |||
| 6404 | return ret; | 6374 | return ret; |
| 6405 | } | 6375 | } |
| 6406 | 6376 | ||
| 6407 | mlog(0, "Insert clusters: (bit %u, blk %llu)\n", | 6377 | trace_ocfs2_cache_cluster_dealloc((unsigned long long)blkno, bit); |
| 6408 | bit, (unsigned long long)blkno); | ||
| 6409 | 6378 | ||
| 6410 | item->free_blk = blkno; | 6379 | item->free_blk = blkno; |
| 6411 | item->free_bit = bit; | 6380 | item->free_bit = bit; |
| @@ -6480,8 +6449,8 @@ int ocfs2_run_deallocs(struct ocfs2_super *osb, | |||
| 6480 | fl = ctxt->c_first_suballocator; | 6449 | fl = ctxt->c_first_suballocator; |
| 6481 | 6450 | ||
| 6482 | if (fl->f_first) { | 6451 | if (fl->f_first) { |
| 6483 | mlog(0, "Free items: (type %u, slot %d)\n", | 6452 | trace_ocfs2_run_deallocs(fl->f_inode_type, |
| 6484 | fl->f_inode_type, fl->f_slot); | 6453 | fl->f_slot); |
| 6485 | ret2 = ocfs2_free_cached_blocks(osb, | 6454 | ret2 = ocfs2_free_cached_blocks(osb, |
| 6486 | fl->f_inode_type, | 6455 | fl->f_inode_type, |
| 6487 | fl->f_slot, | 6456 | fl->f_slot, |
| @@ -6558,8 +6527,9 @@ int ocfs2_cache_block_dealloc(struct ocfs2_cached_dealloc_ctxt *ctxt, | |||
| 6558 | goto out; | 6527 | goto out; |
| 6559 | } | 6528 | } |
| 6560 | 6529 | ||
| 6561 | mlog(0, "Insert: (type %d, slot %u, bit %u, blk %llu)\n", | 6530 | trace_ocfs2_cache_block_dealloc(type, slot, |
| 6562 | type, slot, bit, (unsigned long long)blkno); | 6531 | (unsigned long long)suballoc, |
| 6532 | (unsigned long long)blkno, bit); | ||
| 6563 | 6533 | ||
| 6564 | item->free_bg = suballoc; | 6534 | item->free_bg = suballoc; |
| 6565 | item->free_blk = blkno; | 6535 | item->free_blk = blkno; |
| @@ -7005,8 +6975,6 @@ int ocfs2_commit_truncate(struct ocfs2_super *osb, | |||
| 7005 | struct ocfs2_extent_tree et; | 6975 | struct ocfs2_extent_tree et; |
| 7006 | struct ocfs2_cached_dealloc_ctxt dealloc; | 6976 | struct ocfs2_cached_dealloc_ctxt dealloc; |
| 7007 | 6977 | ||
| 7008 | mlog_entry_void(); | ||
| 7009 | |||
| 7010 | ocfs2_init_dinode_extent_tree(&et, INODE_CACHE(inode), di_bh); | 6978 | ocfs2_init_dinode_extent_tree(&et, INODE_CACHE(inode), di_bh); |
| 7011 | ocfs2_init_dealloc_ctxt(&dealloc); | 6979 | ocfs2_init_dealloc_ctxt(&dealloc); |
| 7012 | 6980 | ||
| @@ -7041,8 +7009,11 @@ start: | |||
| 7041 | goto bail; | 7009 | goto bail; |
| 7042 | } | 7010 | } |
| 7043 | 7011 | ||
| 7044 | mlog(0, "inode->ip_clusters = %u, tree_depth = %u\n", | 7012 | trace_ocfs2_commit_truncate( |
| 7045 | OCFS2_I(inode)->ip_clusters, path->p_tree_depth); | 7013 | (unsigned long long)OCFS2_I(inode)->ip_blkno, |
| 7014 | new_highest_cpos, | ||
| 7015 | OCFS2_I(inode)->ip_clusters, | ||
| 7016 | path->p_tree_depth); | ||
| 7046 | 7017 | ||
| 7047 | /* | 7018 | /* |
| 7048 | * By now, el will point to the extent list on the bottom most | 7019 | * By now, el will point to the extent list on the bottom most |
| @@ -7136,7 +7107,6 @@ bail: | |||
| 7136 | 7107 | ||
| 7137 | ocfs2_free_path(path); | 7108 | ocfs2_free_path(path); |
| 7138 | 7109 | ||
| 7139 | mlog_exit(status); | ||
| 7140 | return status; | 7110 | return status; |
| 7141 | } | 7111 | } |
| 7142 | 7112 | ||
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index daea0359e97..ac97bca282d 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c | |||
| @@ -29,7 +29,6 @@ | |||
| 29 | #include <linux/mpage.h> | 29 | #include <linux/mpage.h> |
| 30 | #include <linux/quotaops.h> | 30 | #include <linux/quotaops.h> |
| 31 | 31 | ||
| 32 | #define MLOG_MASK_PREFIX ML_FILE_IO | ||
| 33 | #include <cluster/masklog.h> | 32 | #include <cluster/masklog.h> |
| 34 | 33 | ||
| 35 | #include "ocfs2.h" | 34 | #include "ocfs2.h" |
| @@ -45,6 +44,7 @@ | |||
| 45 | #include "super.h" | 44 | #include "super.h" |
| 46 | #include "symlink.h" | 45 | #include "symlink.h" |
| 47 | #include "refcounttree.h" | 46 | #include "refcounttree.h" |
| 47 | #include "ocfs2_trace.h" | ||
| 48 | 48 | ||
| 49 | #include "buffer_head_io.h" | 49 | #include "buffer_head_io.h" |
| 50 | 50 | ||
| @@ -59,8 +59,9 @@ static int ocfs2_symlink_get_block(struct inode *inode, sector_t iblock, | |||
| 59 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 59 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
| 60 | void *kaddr; | 60 | void *kaddr; |
| 61 | 61 | ||
| 62 | mlog_entry("(0x%p, %llu, 0x%p, %d)\n", inode, | 62 | trace_ocfs2_symlink_get_block( |
| 63 | (unsigned long long)iblock, bh_result, create); | 63 | (unsigned long long)OCFS2_I(inode)->ip_blkno, |
| 64 | (unsigned long long)iblock, bh_result, create); | ||
| 64 | 65 | ||
| 65 | BUG_ON(ocfs2_inode_is_fast_symlink(inode)); | 66 | BUG_ON(ocfs2_inode_is_fast_symlink(inode)); |
| 66 | 67 | ||
| @@ -123,7 +124,6 @@ static int ocfs2_symlink_get_block(struct inode *inode, sector_t iblock, | |||
| 123 | bail: | 124 | bail: |
| 124 | brelse(bh); | 125 | brelse(bh); |
| 125 | 126 | ||
| 126 | mlog_exit(err); | ||
| 127 | return err; | 127 | return err; |
| 128 | } | 128 | } |
| 129 | 129 | ||
| @@ -136,8 +136,8 @@ int ocfs2_get_block(struct inode *inode, sector_t iblock, | |||
| 136 | u64 p_blkno, count, past_eof; | 136 | u64 p_blkno, count, past_eof; |
| 137 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 137 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
| 138 | 138 | ||
| 139 | mlog_entry("(0x%p, %llu, 0x%p, %d)\n", inode, | 139 | trace_ocfs2_get_block((unsigned long long)OCFS2_I(inode)->ip_blkno, |
| 140 | (unsigned long long)iblock, bh_result, create); | 140 | (unsigned long long)iblock, bh_result, create); |
| 141 | 141 | ||
| 142 | if (OCFS2_I(inode)->ip_flags & OCFS2_INODE_SYSTEM_FILE) | 142 | if (OCFS2_I(inode)->ip_flags & OCFS2_INODE_SYSTEM_FILE) |
| 143 | mlog(ML_NOTICE, "get_block on system inode 0x%p (%lu)\n", | 143 | mlog(ML_NOTICE, "get_block on system inode 0x%p (%lu)\n", |
| @@ -199,8 +199,9 @@ int ocfs2_get_block(struct inode *inode, sector_t iblock, | |||
| 199 | } | 199 | } |
| 200 | 200 | ||
| 201 | past_eof = ocfs2_blocks_for_bytes(inode->i_sb, i_size_read(inode)); | 201 | past_eof = ocfs2_blocks_for_bytes(inode->i_sb, i_size_read(inode)); |
| 202 | mlog(0, "Inode %lu, past_eof = %llu\n", inode->i_ino, | 202 | |
| 203 | (unsigned long long)past_eof); | 203 | trace_ocfs2_get_block_end((unsigned long long)OCFS2_I(inode)->ip_blkno, |
| 204 | (unsigned long long)past_eof); | ||
| 204 | if (create && (iblock >= past_eof)) | 205 | if (create && (iblock >= past_eof)) |
| 205 | set_buffer_new(bh_result); | 206 | set_buffer_new(bh_result); |
| 206 | 207 | ||
| @@ -208,7 +209,6 @@ bail: | |||
| 208 | if (err < 0) | 209 | if (err < 0) |
| 209 | err = -EIO; | 210 | err = -EIO; |
| 210 | 211 | ||
| 211 | mlog_exit(err); | ||
| 212 | return err; | 212 | return err; |
| 213 | } | 213 | } |
| 214 | 214 | ||
| @@ -278,7 +278,8 @@ static int ocfs2_readpage(struct file *file, struct page *page) | |||
| 278 | loff_t start = (loff_t)page->index << PAGE_CACHE_SHIFT; | 278 | loff_t start = (loff_t)page->index << PAGE_CACHE_SHIFT; |
| 279 | int ret, unlock = 1; | 279 | int ret, unlock = 1; |
| 280 | 280 | ||
| 281 | mlog_entry("(0x%p, %lu)\n", file, (page ? page->index : 0)); | 281 | trace_ocfs2_readpage((unsigned long long)oi->ip_blkno, |
| 282 | (page ? page->index : 0)); | ||
| 282 | 283 | ||
| 283 | ret = ocfs2_inode_lock_with_page(inode, NULL, 0, page); | 284 | ret = ocfs2_inode_lock_with_page(inode, NULL, 0, page); |
| 284 | if (ret != 0) { | 285 | if (ret != 0) { |
| @@ -323,7 +324,6 @@ out_inode_unlock: | |||
| 323 | out: | 324 | out: |
| 324 | if (unlock) | 325 | if (unlock) |
| 325 | unlock_page(page); | 326 | unlock_page(page); |
| 326 | mlog_exit(ret); | ||
| 327 | return ret; | 327 | return ret; |
| 328 | } | 328 | } |
| 329 | 329 | ||
| @@ -396,15 +396,11 @@ out_unlock: | |||
| 396 | */ | 396 | */ |
| 397 | static int ocfs2_writepage(struct page *page, struct writeback_control *wbc) | 397 | static int ocfs2_writepage(struct page *page, struct writeback_control *wbc) |
| 398 | { | 398 | { |
| 399 | int ret; | 399 | trace_ocfs2_writepage( |
| 400 | 400 | (unsigned long long)OCFS2_I(page->mapping->host)->ip_blkno, | |
| 401 | mlog_entry("(0x%p)\n", page); | 401 | page->index); |
| 402 | |||
| 403 | ret = block_write_full_page(page, ocfs2_get_block, wbc); | ||
| 404 | 402 | ||
| 405 | mlog_exit(ret); | 403 | return block_write_full_page(page, ocfs2_get_block, wbc); |
| 406 | |||
| 407 | return ret; | ||
| 408 | } | 404 | } |
| 409 | 405 | ||
| 410 | /* Taken from ext3. We don't necessarily need the full blown | 406 | /* Taken from ext3. We don't necessarily need the full blown |
| @@ -450,7 +446,8 @@ static sector_t ocfs2_bmap(struct address_space *mapping, sector_t block) | |||
| 450 | int err = 0; | 446 | int err = 0; |
| 451 | struct inode *inode = mapping->host; | 447 | struct inode *inode = mapping->host; |
| 452 | 448 | ||
| 453 | mlog_entry("(block = %llu)\n", (unsigned long long)block); | 449 | trace_ocfs2_bmap((unsigned long long)OCFS2_I(inode)->ip_blkno, |
| 450 | (unsigned long long)block); | ||
| 454 | 451 | ||
| 455 | /* We don't need to lock journal system files, since they aren't | 452 | /* We don't need to lock journal system files, since they aren't |
| 456 | * accessed concurrently from multiple nodes. | 453 | * accessed concurrently from multiple nodes. |
| @@ -484,8 +481,6 @@ static sector_t ocfs2_bmap(struct address_space *mapping, sector_t block) | |||
| 484 | bail: | 481 | bail: |
| 485 | status = err ? 0 : p_blkno; | 482 | status = err ? 0 : p_blkno; |
| 486 | 483 | ||
| 487 | mlog_exit((int)status); | ||
| 488 | |||
| 489 | return status; | 484 | return status; |
| 490 | } | 485 | } |
| 491 | 486 | ||
| @@ -616,9 +611,6 @@ static ssize_t ocfs2_direct_IO(int rw, | |||
| 616 | { | 611 | { |
| 617 | struct file *file = iocb->ki_filp; | 612 | struct file *file = iocb->ki_filp; |
| 618 | struct inode *inode = file->f_path.dentry->d_inode->i_mapping->host; | 613 | struct inode *inode = file->f_path.dentry->d_inode->i_mapping->host; |
| 619 | int ret; | ||
| 620 | |||
| 621 | mlog_entry_void(); | ||
| 622 | 614 | ||
| 623 | /* | 615 | /* |
| 624 | * Fallback to buffered I/O if we see an inode without | 616 | * Fallback to buffered I/O if we see an inode without |
| @@ -631,13 +623,10 @@ static ssize_t ocfs2_direct_IO(int rw, | |||
| 631 | if (i_size_read(inode) <= offset) | 623 | if (i_size_read(inode) <= offset) |
| 632 | return 0; | 624 | return 0; |
| 633 | 625 | ||
| 634 | ret = __blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, | 626 | return __blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, |
| 635 | iov, offset, nr_segs, | 627 | iov, offset, nr_segs, |
| 636 | ocfs2_direct_IO_get_blocks, | 628 | ocfs2_direct_IO_get_blocks, |
| 637 | ocfs2_dio_end_io, NULL, 0); | 629 | ocfs2_dio_end_io, NULL, 0); |
| 638 | |||
| 639 | mlog_exit(ret); | ||
| 640 | return ret; | ||
| 641 | } | 630 | } |
| 642 | 631 | ||
| 643 | static void ocfs2_figure_cluster_boundaries(struct ocfs2_super *osb, | 632 | static void ocfs2_figure_cluster_boundaries(struct ocfs2_super *osb, |
| @@ -1026,6 +1015,12 @@ static int ocfs2_prepare_page_for_write(struct inode *inode, u64 *p_blkno, | |||
| 1026 | ocfs2_figure_cluster_boundaries(OCFS2_SB(inode->i_sb), cpos, | 1015 | ocfs2_figure_cluster_boundaries(OCFS2_SB(inode->i_sb), cpos, |
| 1027 | &cluster_start, &cluster_end); | 1016 | &cluster_start, &cluster_end); |
| 1028 | 1017 | ||
| 1018 | /* treat the write as new if the a hole/lseek spanned across | ||
| 1019 | * the page boundary. | ||
| 1020 | */ | ||
| 1021 | new = new | ((i_size_read(inode) <= page_offset(page)) && | ||
| 1022 | (page_offset(page) <= user_pos)); | ||
| 1023 | |||
| 1029 | if (page == wc->w_target_page) { | 1024 | if (page == wc->w_target_page) { |
| 1030 | map_from = user_pos & (PAGE_CACHE_SIZE - 1); | 1025 | map_from = user_pos & (PAGE_CACHE_SIZE - 1); |
| 1031 | map_to = map_from + user_len; | 1026 | map_to = map_from + user_len; |
| @@ -1534,9 +1529,9 @@ static int ocfs2_try_to_write_inline_data(struct address_space *mapping, | |||
| 1534 | struct ocfs2_inode_info *oi = OCFS2_I(inode); | 1529 | struct ocfs2_inode_info *oi = OCFS2_I(inode); |
| 1535 | struct ocfs2_dinode *di = NULL; | 1530 | struct ocfs2_dinode *di = NULL; |
| 1536 | 1531 | ||
| 1537 | mlog(0, "Inode %llu, write of %u bytes at off %llu. features: 0x%x\n", | 1532 | trace_ocfs2_try_to_write_inline_data((unsigned long long)oi->ip_blkno, |
| 1538 | (unsigned long long)oi->ip_blkno, len, (unsigned long long)pos, | 1533 | len, (unsigned long long)pos, |
| 1539 | oi->ip_dyn_features); | 1534 | oi->ip_dyn_features); |
| 1540 | 1535 | ||
| 1541 | /* | 1536 | /* |
| 1542 | * Handle inodes which already have inline data 1st. | 1537 | * Handle inodes which already have inline data 1st. |
| @@ -1739,6 +1734,13 @@ try_again: | |||
| 1739 | 1734 | ||
| 1740 | di = (struct ocfs2_dinode *)wc->w_di_bh->b_data; | 1735 | di = (struct ocfs2_dinode *)wc->w_di_bh->b_data; |
| 1741 | 1736 | ||
| 1737 | trace_ocfs2_write_begin_nolock( | ||
| 1738 | (unsigned long long)OCFS2_I(inode)->ip_blkno, | ||
| 1739 | (long long)i_size_read(inode), | ||
| 1740 | le32_to_cpu(di->i_clusters), | ||
| 1741 | pos, len, flags, mmap_page, | ||
| 1742 | clusters_to_alloc, extents_to_split); | ||
| 1743 | |||
| 1742 | /* | 1744 | /* |
| 1743 | * We set w_target_from, w_target_to here so that | 1745 | * We set w_target_from, w_target_to here so that |
| 1744 | * ocfs2_write_end() knows which range in the target page to | 1746 | * ocfs2_write_end() knows which range in the target page to |
| @@ -1751,12 +1753,6 @@ try_again: | |||
| 1751 | * ocfs2_lock_allocators(). It greatly over-estimates | 1753 | * ocfs2_lock_allocators(). It greatly over-estimates |
| 1752 | * the work to be done. | 1754 | * the work to be done. |
| 1753 | */ | 1755 | */ |
| 1754 | mlog(0, "extend inode %llu, i_size = %lld, di->i_clusters = %u," | ||
| 1755 | " clusters_to_add = %u, extents_to_split = %u\n", | ||
| 1756 | (unsigned long long)OCFS2_I(inode)->ip_blkno, | ||
| 1757 | (long long)i_size_read(inode), le32_to_cpu(di->i_clusters), | ||
| 1758 | clusters_to_alloc, extents_to_split); | ||
| 1759 | |||
| 1760 | ocfs2_init_dinode_extent_tree(&et, INODE_CACHE(inode), | 1756 | ocfs2_init_dinode_extent_tree(&et, INODE_CACHE(inode), |
| 1761 | wc->w_di_bh); | 1757 | wc->w_di_bh); |
| 1762 | ret = ocfs2_lock_allocators(inode, &et, | 1758 | ret = ocfs2_lock_allocators(inode, &et, |
| @@ -1938,8 +1934,8 @@ static void ocfs2_write_end_inline(struct inode *inode, loff_t pos, | |||
| 1938 | memcpy(di->id2.i_data.id_data + pos, kaddr + pos, *copied); | 1934 | memcpy(di->id2.i_data.id_data + pos, kaddr + pos, *copied); |
| 1939 | kunmap_atomic(kaddr, KM_USER0); | 1935 | kunmap_atomic(kaddr, KM_USER0); |
| 1940 | 1936 | ||
| 1941 | mlog(0, "Data written to inode at offset %llu. " | 1937 | trace_ocfs2_write_end_inline( |
| 1942 | "id_count = %u, copied = %u, i_dyn_features = 0x%x\n", | 1938 | (unsigned long long)OCFS2_I(inode)->ip_blkno, |
| 1943 | (unsigned long long)pos, *copied, | 1939 | (unsigned long long)pos, *copied, |
| 1944 | le16_to_cpu(di->id2.i_data.id_count), | 1940 | le16_to_cpu(di->id2.i_data.id_count), |
| 1945 | le16_to_cpu(di->i_dyn_features)); | 1941 | le16_to_cpu(di->i_dyn_features)); |
diff --git a/fs/ocfs2/buffer_head_io.c b/fs/ocfs2/buffer_head_io.c index f9d5d3ffc75..5d18ad10c27 100644 --- a/fs/ocfs2/buffer_head_io.c +++ b/fs/ocfs2/buffer_head_io.c | |||
| @@ -35,8 +35,8 @@ | |||
| 35 | #include "inode.h" | 35 | #include "inode.h" |
| 36 | #include "journal.h" | 36 | #include "journal.h" |
| 37 | #include "uptodate.h" | 37 | #include "uptodate.h" |
| 38 | |||
| 39 | #include "buffer_head_io.h" | 38 | #include "buffer_head_io.h" |
| 39 | #include "ocfs2_trace.h" | ||
| 40 | 40 | ||
| 41 | /* | 41 | /* |
| 42 | * Bits on bh->b_state used by ocfs2. | 42 | * Bits on bh->b_state used by ocfs2. |
| @@ -55,8 +55,7 @@ int ocfs2_write_block(struct ocfs2_super *osb, struct buffer_head *bh, | |||
| 55 | { | 55 | { |
| 56 | int ret = 0; | 56 | int ret = 0; |
| 57 | 57 | ||
| 58 | mlog_entry("(bh->b_blocknr = %llu, ci=%p)\n", | 58 | trace_ocfs2_write_block((unsigned long long)bh->b_blocknr, ci); |
| 59 | (unsigned long long)bh->b_blocknr, ci); | ||
| 60 | 59 | ||
| 61 | BUG_ON(bh->b_blocknr < OCFS2_SUPER_BLOCK_BLKNO); | 60 | BUG_ON(bh->b_blocknr < OCFS2_SUPER_BLOCK_BLKNO); |
| 62 | BUG_ON(buffer_jbd(bh)); | 61 | BUG_ON(buffer_jbd(bh)); |
| @@ -66,6 +65,7 @@ int ocfs2_write_block(struct ocfs2_super *osb, struct buffer_head *bh, | |||
| 66 | * can get modified during recovery even if read-only. */ | 65 | * can get modified during recovery even if read-only. */ |
| 67 | if (ocfs2_is_hard_readonly(osb)) { | 66 | if (ocfs2_is_hard_readonly(osb)) { |
| 68 | ret = -EROFS; | 67 | ret = -EROFS; |
| 68 | mlog_errno(ret); | ||
| 69 | goto out; | 69 | goto out; |
| 70 | } | 70 | } |
| 71 | 71 | ||
| @@ -91,11 +91,11 @@ int ocfs2_write_block(struct ocfs2_super *osb, struct buffer_head *bh, | |||
| 91 | * uptodate. */ | 91 | * uptodate. */ |
| 92 | ret = -EIO; | 92 | ret = -EIO; |
| 93 | put_bh(bh); | 93 | put_bh(bh); |
| 94 | mlog_errno(ret); | ||
| 94 | } | 95 | } |
| 95 | 96 | ||
| 96 | ocfs2_metadata_cache_io_unlock(ci); | 97 | ocfs2_metadata_cache_io_unlock(ci); |
| 97 | out: | 98 | out: |
| 98 | mlog_exit(ret); | ||
| 99 | return ret; | 99 | return ret; |
| 100 | } | 100 | } |
| 101 | 101 | ||
| @@ -106,10 +106,10 @@ int ocfs2_read_blocks_sync(struct ocfs2_super *osb, u64 block, | |||
| 106 | unsigned int i; | 106 | unsigned int i; |
| 107 | struct buffer_head *bh; | 107 | struct buffer_head *bh; |
| 108 | 108 | ||
| 109 | if (!nr) { | 109 | trace_ocfs2_read_blocks_sync((unsigned long long)block, nr); |
| 110 | mlog(ML_BH_IO, "No buffers will be read!\n"); | 110 | |
| 111 | if (!nr) | ||
| 111 | goto bail; | 112 | goto bail; |
| 112 | } | ||
| 113 | 113 | ||
| 114 | for (i = 0 ; i < nr ; i++) { | 114 | for (i = 0 ; i < nr ; i++) { |
| 115 | if (bhs[i] == NULL) { | 115 | if (bhs[i] == NULL) { |
| @@ -123,10 +123,8 @@ int ocfs2_read_blocks_sync(struct ocfs2_super *osb, u64 block, | |||
| 123 | bh = bhs[i]; | 123 | bh = bhs[i]; |
| 124 | 124 | ||
| 125 | if (buffer_jbd(bh)) { | 125 | if (buffer_jbd(bh)) { |
| 126 | mlog(ML_BH_IO, | 126 | trace_ocfs2_read_blocks_sync_jbd( |
| 127 | "trying to sync read a jbd " | 127 | (unsigned long long)bh->b_blocknr); |
| 128 | "managed bh (blocknr = %llu), skipping\n", | ||
| 129 | (unsigned long long)bh->b_blocknr); | ||
| 130 | continue; | 128 | continue; |
| 131 | } | 129 | } |
| 132 | 130 | ||
| @@ -186,8 +184,7 @@ int ocfs2_read_blocks(struct ocfs2_caching_info *ci, u64 block, int nr, | |||
| 186 | struct buffer_head *bh; | 184 | struct buffer_head *bh; |
| 187 | struct super_block *sb = ocfs2_metadata_cache_get_super(ci); | 185 | struct super_block *sb = ocfs2_metadata_cache_get_super(ci); |
| 188 | 186 | ||
| 189 | mlog_entry("(ci=%p, block=(%llu), nr=(%d), flags=%d)\n", | 187 | trace_ocfs2_read_blocks_begin(ci, (unsigned long long)block, nr, flags); |
| 190 | ci, (unsigned long long)block, nr, flags); | ||
| 191 | 188 | ||
| 192 | BUG_ON(!ci); | 189 | BUG_ON(!ci); |
| 193 | BUG_ON((flags & OCFS2_BH_READAHEAD) && | 190 | BUG_ON((flags & OCFS2_BH_READAHEAD) && |
| @@ -207,7 +204,6 @@ int ocfs2_read_blocks(struct ocfs2_caching_info *ci, u64 block, int nr, | |||
| 207 | } | 204 | } |
| 208 | 205 | ||
| 209 | if (nr == 0) { | 206 | if (nr == 0) { |
| 210 | mlog(ML_BH_IO, "No buffers will be read!\n"); | ||
| 211 | status = 0; | 207 | status = 0; |
| 212 | goto bail; | 208 | goto bail; |
| 213 | } | 209 | } |
| @@ -251,8 +247,7 @@ int ocfs2_read_blocks(struct ocfs2_caching_info *ci, u64 block, int nr, | |||
| 251 | */ | 247 | */ |
| 252 | 248 | ||
| 253 | if (!ignore_cache && !ocfs2_buffer_uptodate(ci, bh)) { | 249 | if (!ignore_cache && !ocfs2_buffer_uptodate(ci, bh)) { |
| 254 | mlog(ML_UPTODATE, | 250 | trace_ocfs2_read_blocks_from_disk( |
| 255 | "bh (%llu), owner %llu not uptodate\n", | ||
| 256 | (unsigned long long)bh->b_blocknr, | 251 | (unsigned long long)bh->b_blocknr, |
| 257 | (unsigned long long)ocfs2_metadata_cache_owner(ci)); | 252 | (unsigned long long)ocfs2_metadata_cache_owner(ci)); |
| 258 | /* We're using ignore_cache here to say | 253 | /* We're using ignore_cache here to say |
| @@ -260,11 +255,10 @@ int ocfs2_read_blocks(struct ocfs2_caching_info *ci, u64 block, int nr, | |||
| 260 | ignore_cache = 1; | 255 | ignore_cache = 1; |
| 261 | } | 256 | } |
| 262 | 257 | ||
| 258 | trace_ocfs2_read_blocks_bh((unsigned long long)bh->b_blocknr, | ||
| 259 | ignore_cache, buffer_jbd(bh), buffer_dirty(bh)); | ||
| 260 | |||
| 263 | if (buffer_jbd(bh)) { | 261 | if (buffer_jbd(bh)) { |
| 264 | if (ignore_cache) | ||
| 265 | mlog(ML_BH_IO, "trying to sync read a jbd " | ||
| 266 | "managed bh (blocknr = %llu)\n", | ||
| 267 | (unsigned long long)bh->b_blocknr); | ||
| 268 | continue; | 262 | continue; |
| 269 | } | 263 | } |
| 270 | 264 | ||
| @@ -272,9 +266,6 @@ int ocfs2_read_blocks(struct ocfs2_caching_info *ci, u64 block, int nr, | |||
| 272 | if (buffer_dirty(bh)) { | 266 | if (buffer_dirty(bh)) { |
| 273 | /* This should probably be a BUG, or | 267 | /* This should probably be a BUG, or |
| 274 | * at least return an error. */ | 268 | * at least return an error. */ |
| 275 | mlog(ML_BH_IO, "asking me to sync read a dirty " | ||
| 276 | "buffer! (blocknr = %llu)\n", | ||
| 277 | (unsigned long long)bh->b_blocknr); | ||
| 278 | continue; | 269 | continue; |
| 279 | } | 270 | } |
| 280 | 271 | ||
| @@ -367,14 +358,11 @@ int ocfs2_read_blocks(struct ocfs2_caching_info *ci, u64 block, int nr, | |||
| 367 | } | 358 | } |
| 368 | ocfs2_metadata_cache_io_unlock(ci); | 359 | ocfs2_metadata_cache_io_unlock(ci); |
| 369 | 360 | ||
| 370 | mlog(ML_BH_IO, "block=(%llu), nr=(%d), cached=%s, flags=0x%x\n", | 361 | trace_ocfs2_read_blocks_end((unsigned long long)block, nr, |
| 371 | (unsigned long long)block, nr, | 362 | flags, ignore_cache); |
| 372 | ((flags & OCFS2_BH_IGNORE_CACHE) || ignore_cache) ? "no" : "yes", | ||
| 373 | flags); | ||
| 374 | 363 | ||
| 375 | bail: | 364 | bail: |
| 376 | 365 | ||
| 377 | mlog_exit(status); | ||
| 378 | return status; | 366 | return status; |
| 379 | } | 367 | } |
| 380 | 368 | ||
| @@ -408,13 +396,12 @@ int ocfs2_write_super_or_backup(struct ocfs2_super *osb, | |||
| 408 | int ret = 0; | 396 | int ret = 0; |
| 409 | struct ocfs2_dinode *di = (struct ocfs2_dinode *)bh->b_data; | 397 | struct ocfs2_dinode *di = (struct ocfs2_dinode *)bh->b_data; |
| 410 | 398 | ||
| 411 | mlog_entry_void(); | ||
| 412 | |||
| 413 | BUG_ON(buffer_jbd(bh)); | 399 | BUG_ON(buffer_jbd(bh)); |
| 414 | ocfs2_check_super_or_backup(osb->sb, bh->b_blocknr); | 400 | ocfs2_check_super_or_backup(osb->sb, bh->b_blocknr); |
| 415 | 401 | ||
| 416 | if (ocfs2_is_hard_readonly(osb) || ocfs2_is_soft_readonly(osb)) { | 402 | if (ocfs2_is_hard_readonly(osb) || ocfs2_is_soft_readonly(osb)) { |
| 417 | ret = -EROFS; | 403 | ret = -EROFS; |
| 404 | mlog_errno(ret); | ||
| 418 | goto out; | 405 | goto out; |
| 419 | } | 406 | } |
| 420 | 407 | ||
| @@ -434,9 +421,9 @@ int ocfs2_write_super_or_backup(struct ocfs2_super *osb, | |||
| 434 | if (!buffer_uptodate(bh)) { | 421 | if (!buffer_uptodate(bh)) { |
| 435 | ret = -EIO; | 422 | ret = -EIO; |
| 436 | put_bh(bh); | 423 | put_bh(bh); |
| 424 | mlog_errno(ret); | ||
| 437 | } | 425 | } |
| 438 | 426 | ||
| 439 | out: | 427 | out: |
| 440 | mlog_exit(ret); | ||
| 441 | return ret; | 428 | return ret; |
| 442 | } | 429 | } |
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c index 1adab287bd2..2461eb3272e 100644 --- a/fs/ocfs2/cluster/heartbeat.c +++ b/fs/ocfs2/cluster/heartbeat.c | |||
| @@ -1654,8 +1654,6 @@ static int o2hb_populate_slot_data(struct o2hb_region *reg) | |||
| 1654 | struct o2hb_disk_slot *slot; | 1654 | struct o2hb_disk_slot *slot; |
| 1655 | struct o2hb_disk_heartbeat_block *hb_block; | 1655 | struct o2hb_disk_heartbeat_block *hb_block; |
| 1656 | 1656 | ||
| 1657 | mlog_entry_void(); | ||
| 1658 | |||
| 1659 | ret = o2hb_read_slots(reg, reg->hr_blocks); | 1657 | ret = o2hb_read_slots(reg, reg->hr_blocks); |
| 1660 | if (ret) { | 1658 | if (ret) { |
| 1661 | mlog_errno(ret); | 1659 | mlog_errno(ret); |
| @@ -1677,7 +1675,6 @@ static int o2hb_populate_slot_data(struct o2hb_region *reg) | |||
| 1677 | } | 1675 | } |
| 1678 | 1676 | ||
| 1679 | out: | 1677 | out: |
| 1680 | mlog_exit(ret); | ||
| 1681 | return ret; | 1678 | return ret; |
| 1682 | } | 1679 | } |
| 1683 | 1680 | ||
diff --git a/fs/ocfs2/cluster/masklog.c b/fs/ocfs2/cluster/masklog.c index 6c61771469a..07ac24fd925 100644 --- a/fs/ocfs2/cluster/masklog.c +++ b/fs/ocfs2/cluster/masklog.c | |||
| @@ -30,7 +30,7 @@ | |||
| 30 | 30 | ||
| 31 | struct mlog_bits mlog_and_bits = MLOG_BITS_RHS(MLOG_INITIAL_AND_MASK); | 31 | struct mlog_bits mlog_and_bits = MLOG_BITS_RHS(MLOG_INITIAL_AND_MASK); |
| 32 | EXPORT_SYMBOL_GPL(mlog_and_bits); | 32 | EXPORT_SYMBOL_GPL(mlog_and_bits); |
| 33 | struct mlog_bits mlog_not_bits = MLOG_BITS_RHS(MLOG_INITIAL_NOT_MASK); | 33 | struct mlog_bits mlog_not_bits = MLOG_BITS_RHS(0); |
| 34 | EXPORT_SYMBOL_GPL(mlog_not_bits); | 34 | EXPORT_SYMBOL_GPL(mlog_not_bits); |
| 35 | 35 | ||
| 36 | static ssize_t mlog_mask_show(u64 mask, char *buf) | 36 | static ssize_t mlog_mask_show(u64 mask, char *buf) |
| @@ -80,8 +80,6 @@ struct mlog_attribute { | |||
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | static struct mlog_attribute mlog_attrs[MLOG_MAX_BITS] = { | 82 | static struct mlog_attribute mlog_attrs[MLOG_MAX_BITS] = { |
| 83 | define_mask(ENTRY), | ||
| 84 | define_mask(EXIT), | ||
| 85 | define_mask(TCP), | 83 | define_mask(TCP), |
| 86 | define_mask(MSG), | 84 | define_mask(MSG), |
| 87 | define_mask(SOCKET), | 85 | define_mask(SOCKET), |
| @@ -93,27 +91,11 @@ static struct mlog_attribute mlog_attrs[MLOG_MAX_BITS] = { | |||
| 93 | define_mask(DLM_THREAD), | 91 | define_mask(DLM_THREAD), |
| 94 | define_mask(DLM_MASTER), | 92 | define_mask(DLM_MASTER), |
| 95 | define_mask(DLM_RECOVERY), | 93 | define_mask(DLM_RECOVERY), |
| 96 | define_mask(AIO), | ||
| 97 | define_mask(JOURNAL), | ||
| 98 | define_mask(DISK_ALLOC), | ||
| 99 | define_mask(SUPER), | ||
| 100 | define_mask(FILE_IO), | ||
| 101 | define_mask(EXTENT_MAP), | ||
| 102 | define_mask(DLM_GLUE), | 94 | define_mask(DLM_GLUE), |
| 103 | define_mask(BH_IO), | ||
| 104 | define_mask(UPTODATE), | ||
| 105 | define_mask(NAMEI), | ||
| 106 | define_mask(INODE), | ||
| 107 | define_mask(VOTE), | 95 | define_mask(VOTE), |
| 108 | define_mask(DCACHE), | ||
| 109 | define_mask(CONN), | 96 | define_mask(CONN), |
| 110 | define_mask(QUORUM), | 97 | define_mask(QUORUM), |
| 111 | define_mask(EXPORT), | ||
| 112 | define_mask(XATTR), | ||
| 113 | define_mask(QUOTA), | ||
| 114 | define_mask(REFCOUNT), | ||
| 115 | define_mask(BASTS), | 98 | define_mask(BASTS), |
| 116 | define_mask(RESERVATIONS), | ||
| 117 | define_mask(CLUSTER), | 99 | define_mask(CLUSTER), |
| 118 | define_mask(ERROR), | 100 | define_mask(ERROR), |
| 119 | define_mask(NOTICE), | 101 | define_mask(NOTICE), |
diff --git a/fs/ocfs2/cluster/masklog.h b/fs/ocfs2/cluster/masklog.h index 34d6544357d..baa2b9ef7ee 100644 --- a/fs/ocfs2/cluster/masklog.h +++ b/fs/ocfs2/cluster/masklog.h | |||
| @@ -82,41 +82,23 @@ | |||
| 82 | 82 | ||
| 83 | /* bits that are frequently given and infrequently matched in the low word */ | 83 | /* bits that are frequently given and infrequently matched in the low word */ |
| 84 | /* NOTE: If you add a flag, you need to also update masklog.c! */ | 84 | /* NOTE: If you add a flag, you need to also update masklog.c! */ |
| 85 | #define ML_ENTRY 0x0000000000000001ULL /* func call entry */ | 85 | #define ML_TCP 0x0000000000000001ULL /* net cluster/tcp.c */ |
| 86 | #define ML_EXIT 0x0000000000000002ULL /* func call exit */ | 86 | #define ML_MSG 0x0000000000000002ULL /* net network messages */ |
| 87 | #define ML_TCP 0x0000000000000004ULL /* net cluster/tcp.c */ | 87 | #define ML_SOCKET 0x0000000000000004ULL /* net socket lifetime */ |
| 88 | #define ML_MSG 0x0000000000000008ULL /* net network messages */ | 88 | #define ML_HEARTBEAT 0x0000000000000008ULL /* hb all heartbeat tracking */ |
| 89 | #define ML_SOCKET 0x0000000000000010ULL /* net socket lifetime */ | 89 | #define ML_HB_BIO 0x0000000000000010ULL /* hb io tracing */ |
| 90 | #define ML_HEARTBEAT 0x0000000000000020ULL /* hb all heartbeat tracking */ | 90 | #define ML_DLMFS 0x0000000000000020ULL /* dlm user dlmfs */ |
| 91 | #define ML_HB_BIO 0x0000000000000040ULL /* hb io tracing */ | 91 | #define ML_DLM 0x0000000000000040ULL /* dlm general debugging */ |
| 92 | #define ML_DLMFS 0x0000000000000080ULL /* dlm user dlmfs */ | 92 | #define ML_DLM_DOMAIN 0x0000000000000080ULL /* dlm domain debugging */ |
| 93 | #define ML_DLM 0x0000000000000100ULL /* dlm general debugging */ | 93 | #define ML_DLM_THREAD 0x0000000000000100ULL /* dlm domain thread */ |
| 94 | #define ML_DLM_DOMAIN 0x0000000000000200ULL /* dlm domain debugging */ | 94 | #define ML_DLM_MASTER 0x0000000000000200ULL /* dlm master functions */ |
| 95 | #define ML_DLM_THREAD 0x0000000000000400ULL /* dlm domain thread */ | 95 | #define ML_DLM_RECOVERY 0x0000000000000400ULL /* dlm master functions */ |
| 96 | #define ML_DLM_MASTER 0x0000000000000800ULL /* dlm master functions */ | 96 | #define ML_DLM_GLUE 0x0000000000000800ULL /* ocfs2 dlm glue layer */ |
| 97 | #define ML_DLM_RECOVERY 0x0000000000001000ULL /* dlm master functions */ | 97 | #define ML_VOTE 0x0000000000001000ULL /* ocfs2 node messaging */ |
| 98 | #define ML_AIO 0x0000000000002000ULL /* ocfs2 aio read and write */ | 98 | #define ML_CONN 0x0000000000002000ULL /* net connection management */ |
| 99 | #define ML_JOURNAL 0x0000000000004000ULL /* ocfs2 journalling functions */ | 99 | #define ML_QUORUM 0x0000000000004000ULL /* net connection quorum */ |
| 100 | #define ML_DISK_ALLOC 0x0000000000008000ULL /* ocfs2 disk allocation */ | 100 | #define ML_BASTS 0x0000000000008000ULL /* dlmglue asts and basts */ |
| 101 | #define ML_SUPER 0x0000000000010000ULL /* ocfs2 mount / umount */ | 101 | #define ML_CLUSTER 0x0000000000010000ULL /* cluster stack */ |
| 102 | #define ML_FILE_IO 0x0000000000020000ULL /* ocfs2 file I/O */ | ||
| 103 | #define ML_EXTENT_MAP 0x0000000000040000ULL /* ocfs2 extent map caching */ | ||
| 104 | #define ML_DLM_GLUE 0x0000000000080000ULL /* ocfs2 dlm glue layer */ | ||
| 105 | #define ML_BH_IO 0x0000000000100000ULL /* ocfs2 buffer I/O */ | ||
| 106 | #define ML_UPTODATE 0x0000000000200000ULL /* ocfs2 caching sequence #'s */ | ||
| 107 | #define ML_NAMEI 0x0000000000400000ULL /* ocfs2 directory / namespace */ | ||
| 108 | #define ML_INODE 0x0000000000800000ULL /* ocfs2 inode manipulation */ | ||
| 109 | #define ML_VOTE 0x0000000001000000ULL /* ocfs2 node messaging */ | ||
| 110 | #define ML_DCACHE 0x0000000002000000ULL /* ocfs2 dcache operations */ | ||
| 111 | #define ML_CONN 0x0000000004000000ULL /* net connection management */ | ||
| 112 | #define ML_QUORUM 0x0000000008000000ULL /* net connection quorum */ | ||
| 113 | #define ML_EXPORT 0x0000000010000000ULL /* ocfs2 export operations */ | ||
| 114 | #define ML_XATTR 0x0000000020000000ULL /* ocfs2 extended attributes */ | ||
| 115 | #define ML_QUOTA 0x0000000040000000ULL /* ocfs2 quota operations */ | ||
| 116 | #define ML_REFCOUNT 0x0000000080000000ULL /* refcount tree operations */ | ||
| 117 | #define ML_BASTS 0x0000000100000000ULL /* dlmglue asts and basts */ | ||
| 118 | #define ML_RESERVATIONS 0x0000000200000000ULL /* ocfs2 alloc reservations */ | ||
| 119 | #define ML_CLUSTER 0x0000000400000000ULL /* cluster stack */ | ||
| 120 | 102 | ||
| 121 | /* bits that are infrequently given and frequently matched in the high word */ | 103 | /* bits that are infrequently given and frequently matched in the high word */ |
| 122 | #define ML_ERROR 0x1000000000000000ULL /* sent to KERN_ERR */ | 104 | #define ML_ERROR 0x1000000000000000ULL /* sent to KERN_ERR */ |
| @@ -124,7 +106,6 @@ | |||
| 124 | #define ML_KTHREAD 0x4000000000000000ULL /* kernel thread activity */ | 106 | #define ML_KTHREAD 0x4000000000000000ULL /* kernel thread activity */ |
| 125 | 107 | ||
| 126 | #define MLOG_INITIAL_AND_MASK (ML_ERROR|ML_NOTICE) | 108 | #define MLOG_INITIAL_AND_MASK (ML_ERROR|ML_NOTICE) |
| 127 | #define MLOG_INITIAL_NOT_MASK (ML_ENTRY|ML_EXIT) | ||
| 128 | #ifndef MLOG_MASK_PREFIX | 109 | #ifndef MLOG_MASK_PREFIX |
| 129 | #define MLOG_MASK_PREFIX 0 | 110 | #define MLOG_MASK_PREFIX 0 |
| 130 | #endif | 111 | #endif |
| @@ -222,58 +203,6 @@ extern struct mlog_bits mlog_and_bits, mlog_not_bits; | |||
| 222 | mlog(ML_ERROR, "status = %lld\n", (long long)_st); \ | 203 | mlog(ML_ERROR, "status = %lld\n", (long long)_st); \ |
| 223 | } while (0) | 204 | } while (0) |
| 224 | 205 | ||
| 225 | #if defined(CONFIG_OCFS2_DEBUG_MASKLOG) | ||
| 226 | #define mlog_entry(fmt, args...) do { \ | ||
| 227 | mlog(ML_ENTRY, "ENTRY:" fmt , ##args); \ | ||
| 228 | } while (0) | ||
| 229 | |||
| 230 | #define mlog_entry_void() do { \ | ||
| 231 | mlog(ML_ENTRY, "ENTRY:\n"); \ | ||
| 232 | } while (0) | ||
| 233 | |||
| 234 | /* | ||
| 235 | * We disable this for sparse. | ||
| 236 | */ | ||
| 237 | #if !defined(__CHECKER__) | ||
| 238 | #define mlog_exit(st) do { \ | ||
| 239 | if (__builtin_types_compatible_p(typeof(st), unsigned long)) \ | ||
| 240 | mlog(ML_EXIT, "EXIT: %lu\n", (unsigned long) (st)); \ | ||
| 241 | else if (__builtin_types_compatible_p(typeof(st), signed long)) \ | ||
| 242 | mlog(ML_EXIT, "EXIT: %ld\n", (signed long) (st)); \ | ||
| 243 | else if (__builtin_types_compatible_p(typeof(st), unsigned int) \ | ||
| 244 | || __builtin_types_compatible_p(typeof(st), unsigned short) \ | ||
| 245 | || __builtin_types_compatible_p(typeof(st), unsigned char)) \ | ||
| 246 | mlog(ML_EXIT, "EXIT: %u\n", (unsigned int) (st)); \ | ||
| 247 | else if (__builtin_types_compatible_p(typeof(st), signed int) \ | ||
| 248 | || __builtin_types_compatible_p(typeof(st), signed short) \ | ||
| 249 | || __builtin_types_compatible_p(typeof(st), signed char)) \ | ||
| 250 | mlog(ML_EXIT, "EXIT: %d\n", (signed int) (st)); \ | ||
| 251 | else if (__builtin_types_compatible_p(typeof(st), long long)) \ | ||
| 252 | mlog(ML_EXIT, "EXIT: %lld\n", (long long) (st)); \ | ||
| 253 | else \ | ||
| 254 | mlog(ML_EXIT, "EXIT: %llu\n", (unsigned long long) (st)); \ | ||
| 255 | } while (0) | ||
| 256 | #else | ||
| 257 | #define mlog_exit(st) do { \ | ||
| 258 | mlog(ML_EXIT, "EXIT: %lld\n", (long long) (st)); \ | ||
| 259 | } while (0) | ||
| 260 | #endif | ||
| 261 | |||
| 262 | #define mlog_exit_ptr(ptr) do { \ | ||
| 263 | mlog(ML_EXIT, "EXIT: %p\n", ptr); \ | ||
| 264 | } while (0) | ||
| 265 | |||
| 266 | #define mlog_exit_void() do { \ | ||
| 267 | mlog(ML_EXIT, "EXIT\n"); \ | ||
| 268 | } while (0) | ||
| 269 | #else | ||
| 270 | #define mlog_entry(...) do { } while (0) | ||
| 271 | #define mlog_entry_void(...) do { } while (0) | ||
| 272 | #define mlog_exit(...) do { } while (0) | ||
| 273 | #define mlog_exit_ptr(...) do { } while (0) | ||
| 274 | #define mlog_exit_void(...) do { } while (0) | ||
| 275 | #endif /* defined(CONFIG_OCFS2_DEBUG_MASKLOG) */ | ||
| 276 | |||
| 277 | #define mlog_bug_on_msg(cond, fmt, args...) do { \ | 206 | #define mlog_bug_on_msg(cond, fmt, args...) do { \ |
| 278 | if (cond) { \ | 207 | if (cond) { \ |
| 279 | mlog(ML_ERROR, "bug expression: " #cond "\n"); \ | 208 | mlog(ML_ERROR, "bug expression: " #cond "\n"); \ |
diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c index 3b11cb1e38f..ee04ff5ee60 100644 --- a/fs/ocfs2/cluster/tcp.c +++ b/fs/ocfs2/cluster/tcp.c | |||
| @@ -210,10 +210,6 @@ static inline void o2net_set_func_stop_time(struct o2net_sock_container *sc) | |||
| 210 | sc->sc_tv_func_stop = ktime_get(); | 210 | sc->sc_tv_func_stop = ktime_get(); |
| 211 | } | 211 | } |
| 212 | 212 | ||
| 213 | static ktime_t o2net_get_func_run_time(struct o2net_sock_container *sc) | ||
| 214 | { | ||
| 215 | return ktime_sub(sc->sc_tv_func_stop, sc->sc_tv_func_start); | ||
| 216 | } | ||
| 217 | #else /* CONFIG_DEBUG_FS */ | 213 | #else /* CONFIG_DEBUG_FS */ |
| 218 | # define o2net_init_nst(a, b, c, d, e) | 214 | # define o2net_init_nst(a, b, c, d, e) |
| 219 | # define o2net_set_nst_sock_time(a) | 215 | # define o2net_set_nst_sock_time(a) |
| @@ -227,10 +223,14 @@ static ktime_t o2net_get_func_run_time(struct o2net_sock_container *sc) | |||
| 227 | # define o2net_set_advance_stop_time(a) | 223 | # define o2net_set_advance_stop_time(a) |
| 228 | # define o2net_set_func_start_time(a) | 224 | # define o2net_set_func_start_time(a) |
| 229 | # define o2net_set_func_stop_time(a) | 225 | # define o2net_set_func_stop_time(a) |
| 230 | # define o2net_get_func_run_time(a) (ktime_t)0 | ||
| 231 | #endif /* CONFIG_DEBUG_FS */ | 226 | #endif /* CONFIG_DEBUG_FS */ |
| 232 | 227 | ||
| 233 | #ifdef CONFIG_OCFS2_FS_STATS | 228 | #ifdef CONFIG_OCFS2_FS_STATS |
| 229 | static ktime_t o2net_get_func_run_time(struct o2net_sock_container *sc) | ||
| 230 | { | ||
| 231 | return ktime_sub(sc->sc_tv_func_stop, sc->sc_tv_func_start); | ||
| 232 | } | ||
| 233 | |||
| 234 | static void o2net_update_send_stats(struct o2net_send_tracking *nst, | 234 | static void o2net_update_send_stats(struct o2net_send_tracking *nst, |
| 235 | struct o2net_sock_container *sc) | 235 | struct o2net_sock_container *sc) |
| 236 | { | 236 | { |
diff --git a/fs/ocfs2/dcache.c b/fs/ocfs2/dcache.c index 7eb90403fc8..e5ba3481833 100644 --- a/fs/ocfs2/dcache.c +++ b/fs/ocfs2/dcache.c | |||
| @@ -28,7 +28,6 @@ | |||
| 28 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
| 29 | #include <linux/namei.h> | 29 | #include <linux/namei.h> |
| 30 | 30 | ||
| 31 | #define MLOG_MASK_PREFIX ML_DCACHE | ||
| 32 | #include <cluster/masklog.h> | 31 | #include <cluster/masklog.h> |
| 33 | 32 | ||
| 34 | #include "ocfs2.h" | 33 | #include "ocfs2.h" |
| @@ -39,6 +38,7 @@ | |||
| 39 | #include "file.h" | 38 | #include "file.h" |
| 40 | #include "inode.h" | 39 | #include "inode.h" |
| 41 | #include "super.h" | 40 | #include "super.h" |
| 41 | #include "ocfs2_trace.h" | ||
| 42 | 42 | ||
| 43 | void ocfs2_dentry_attach_gen(struct dentry *dentry) | 43 | void ocfs2_dentry_attach_gen(struct dentry *dentry) |
| 44 | { | 44 | { |
| @@ -62,8 +62,8 @@ static int ocfs2_dentry_revalidate(struct dentry *dentry, | |||
| 62 | inode = dentry->d_inode; | 62 | inode = dentry->d_inode; |
| 63 | osb = OCFS2_SB(dentry->d_sb); | 63 | osb = OCFS2_SB(dentry->d_sb); |
| 64 | 64 | ||
| 65 | mlog_entry("(0x%p, '%.*s')\n", dentry, | 65 | trace_ocfs2_dentry_revalidate(dentry, dentry->d_name.len, |
| 66 | dentry->d_name.len, dentry->d_name.name); | 66 | dentry->d_name.name); |
| 67 | 67 | ||
| 68 | /* For a negative dentry - | 68 | /* For a negative dentry - |
| 69 | * check the generation number of the parent and compare with the | 69 | * check the generation number of the parent and compare with the |
| @@ -73,9 +73,10 @@ static int ocfs2_dentry_revalidate(struct dentry *dentry, | |||
| 73 | unsigned long gen = (unsigned long) dentry->d_fsdata; | 73 | unsigned long gen = (unsigned long) dentry->d_fsdata; |
| 74 | unsigned long pgen = | 74 | unsigned long pgen = |
| 75 | OCFS2_I(dentry->d_parent->d_inode)->ip_dir_lock_gen; | 75 | OCFS2_I(dentry->d_parent->d_inode)->ip_dir_lock_gen; |
| 76 | mlog(0, "negative dentry: %.*s parent gen: %lu " | 76 | |
| 77 | "dentry gen: %lu\n", | 77 | trace_ocfs2_dentry_revalidate_negative(dentry->d_name.len, |
| 78 | dentry->d_name.len, dentry->d_name.name, pgen, gen); | 78 | dentry->d_name.name, |
| 79 | pgen, gen); | ||
| 79 | if (gen != pgen) | 80 | if (gen != pgen) |
| 80 | goto bail; | 81 | goto bail; |
| 81 | goto valid; | 82 | goto valid; |
| @@ -90,8 +91,8 @@ static int ocfs2_dentry_revalidate(struct dentry *dentry, | |||
| 90 | /* did we or someone else delete this inode? */ | 91 | /* did we or someone else delete this inode? */ |
| 91 | if (OCFS2_I(inode)->ip_flags & OCFS2_INODE_DELETED) { | 92 | if (OCFS2_I(inode)->ip_flags & OCFS2_INODE_DELETED) { |
| 92 | spin_unlock(&OCFS2_I(inode)->ip_lock); | 93 | spin_unlock(&OCFS2_I(inode)->ip_lock); |
| 93 | mlog(0, "inode (%llu) deleted, returning false\n", | 94 | trace_ocfs2_dentry_revalidate_delete( |
| 94 | (unsigned long long)OCFS2_I(inode)->ip_blkno); | 95 | (unsigned long long)OCFS2_I(inode)->ip_blkno); |
| 95 | goto bail; | 96 | goto bail; |
| 96 | } | 97 | } |
| 97 | spin_unlock(&OCFS2_I(inode)->ip_lock); | 98 | spin_unlock(&OCFS2_I(inode)->ip_lock); |
| @@ -101,10 +102,9 @@ static int ocfs2_dentry_revalidate(struct dentry *dentry, | |||
| 101 | * inode nlink hits zero, it never goes back. | 102 | * inode nlink hits zero, it never goes back. |
| 102 | */ | 103 | */ |
| 103 | if (inode->i_nlink == 0) { | 104 | if (inode->i_nlink == 0) { |
| 104 | mlog(0, "Inode %llu orphaned, returning false " | 105 | trace_ocfs2_dentry_revalidate_orphaned( |
| 105 | "dir = %d\n", | 106 | (unsigned long long)OCFS2_I(inode)->ip_blkno, |
| 106 | (unsigned long long)OCFS2_I(inode)->ip_blkno, | 107 | S_ISDIR(inode->i_mode)); |
| 107 | S_ISDIR(inode->i_mode)); | ||
| 108 | goto bail; | 108 | goto bail; |
| 109 | } | 109 | } |
| 110 | 110 | ||
| @@ -113,9 +113,8 @@ static int ocfs2_dentry_revalidate(struct dentry *dentry, | |||
| 113 | * redo it. | 113 | * redo it. |
| 114 | */ | 114 | */ |
| 115 | if (!dentry->d_fsdata) { | 115 | if (!dentry->d_fsdata) { |
| 116 | mlog(0, "Inode %llu doesn't have dentry lock, " | 116 | trace_ocfs2_dentry_revalidate_nofsdata( |
| 117 | "returning false\n", | 117 | (unsigned long long)OCFS2_I(inode)->ip_blkno); |
| 118 | (unsigned long long)OCFS2_I(inode)->ip_blkno); | ||
| 119 | goto bail; | 118 | goto bail; |
| 120 | } | 119 | } |
| 121 | 120 | ||
| @@ -123,8 +122,7 @@ valid: | |||
| 123 | ret = 1; | 122 | ret = 1; |
| 124 | 123 | ||
| 125 | bail: | 124 | bail: |
| 126 | mlog_exit(ret); | 125 | trace_ocfs2_dentry_revalidate_ret(ret); |
| 127 | |||
| 128 | return ret; | 126 | return ret; |
| 129 | } | 127 | } |
| 130 | 128 | ||
| @@ -181,8 +179,8 @@ struct dentry *ocfs2_find_local_alias(struct inode *inode, | |||
| 181 | 179 | ||
| 182 | spin_lock(&dentry->d_lock); | 180 | spin_lock(&dentry->d_lock); |
| 183 | if (ocfs2_match_dentry(dentry, parent_blkno, skip_unhashed)) { | 181 | if (ocfs2_match_dentry(dentry, parent_blkno, skip_unhashed)) { |
| 184 | mlog(0, "dentry found: %.*s\n", | 182 | trace_ocfs2_find_local_alias(dentry->d_name.len, |
| 185 | dentry->d_name.len, dentry->d_name.name); | 183 | dentry->d_name.name); |
| 186 | 184 | ||
| 187 | dget_dlock(dentry); | 185 | dget_dlock(dentry); |
| 188 | spin_unlock(&dentry->d_lock); | 186 | spin_unlock(&dentry->d_lock); |
| @@ -240,9 +238,8 @@ int ocfs2_dentry_attach_lock(struct dentry *dentry, | |||
| 240 | struct dentry *alias; | 238 | struct dentry *alias; |
| 241 | struct ocfs2_dentry_lock *dl = dentry->d_fsdata; | 239 | struct ocfs2_dentry_lock *dl = dentry->d_fsdata; |
| 242 | 240 | ||
| 243 | mlog(0, "Attach \"%.*s\", parent %llu, fsdata: %p\n", | 241 | trace_ocfs2_dentry_attach_lock(dentry->d_name.len, dentry->d_name.name, |
| 244 | dentry->d_name.len, dentry->d_name.name, | 242 | (unsigned long long)parent_blkno, dl); |
| 245 | (unsigned long long)parent_blkno, dl); | ||
| 246 | 243 | ||
| 247 | /* | 244 | /* |
| 248 | * Negative dentry. We ignore these for now. | 245 | * Negative dentry. We ignore these for now. |
| @@ -292,7 +289,9 @@ int ocfs2_dentry_attach_lock(struct dentry *dentry, | |||
| 292 | (unsigned long long)parent_blkno, | 289 | (unsigned long long)parent_blkno, |
| 293 | (unsigned long long)dl->dl_parent_blkno); | 290 | (unsigned long long)dl->dl_parent_blkno); |
| 294 | 291 | ||
| 295 | mlog(0, "Found: %s\n", dl->dl_lockres.l_name); | 292 | trace_ocfs2_dentry_attach_lock_found(dl->dl_lockres.l_name, |
| 293 | (unsigned long long)parent_blkno, | ||
| 294 | (unsigned long long)OCFS2_I(inode)->ip_blkno); | ||
| 296 | 295 | ||
| 297 | goto out_attach; | 296 | goto out_attach; |
| 298 | } | 297 | } |
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c index f97b6f1c61d..9fe5b8fd658 100644 --- a/fs/ocfs2/dir.c +++ b/fs/ocfs2/dir.c | |||
| @@ -43,7 +43,6 @@ | |||
| 43 | #include <linux/quotaops.h> | 43 | #include <linux/quotaops.h> |
| 44 | #include <linux/sort.h> | 44 | #include <linux/sort.h> |
| 45 | 45 | ||
| 46 | #define MLOG_MASK_PREFIX ML_NAMEI | ||
| 47 | #include <cluster/masklog.h> | 46 | #include <cluster/masklog.h> |
| 48 | 47 | ||
| 49 | #include "ocfs2.h" | 48 | #include "ocfs2.h" |
| @@ -61,6 +60,7 @@ | |||
| 61 | #include "super.h" | 60 | #include "super.h" |
| 62 | #include "sysfile.h" | 61 | #include "sysfile.h" |
| 63 | #include "uptodate.h" | 62 | #include "uptodate.h" |
| 63 | #include "ocfs2_trace.h" | ||
| 64 | 64 | ||
| 65 | #include "buffer_head_io.h" | 65 | #include "buffer_head_io.h" |
| 66 | 66 | ||
| @@ -322,21 +322,23 @@ static int ocfs2_check_dir_entry(struct inode * dir, | |||
| 322 | const char *error_msg = NULL; | 322 | const char *error_msg = NULL; |
| 323 | const int rlen = le16_to_cpu(de->rec_len); | 323 | const int rlen = le16_to_cpu(de->rec_len); |
| 324 | 324 | ||
| 325 | if (rlen < OCFS2_DIR_REC_LEN(1)) | 325 | if (unlikely(rlen < OCFS2_DIR_REC_LEN(1))) |
| 326 | error_msg = "rec_len is smaller than minimal"; | 326 | error_msg = "rec_len is smaller than minimal"; |
| 327 | else if (rlen % 4 != 0) | 327 | else if (unlikely(rlen % 4 != 0)) |
| 328 | error_msg = "rec_len % 4 != 0"; | 328 | error_msg = "rec_len % 4 != 0"; |
| 329 | else if (rlen < OCFS2_DIR_REC_LEN(de->name_len)) | 329 | else if (unlikely(rlen < OCFS2_DIR_REC_LEN(de->name_len))) |
| 330 | error_msg = "rec_len is too small for name_len"; | 330 | error_msg = "rec_len is too small for name_len"; |
| 331 | else if (((char *) de - bh->b_data) + rlen > dir->i_sb->s_blocksize) | 331 | else if (unlikely( |
| 332 | ((char *) de - bh->b_data) + rlen > dir->i_sb->s_blocksize)) | ||
| 332 | error_msg = "directory entry across blocks"; | 333 | error_msg = "directory entry across blocks"; |
| 333 | 334 | ||
| 334 | if (error_msg != NULL) | 335 | if (unlikely(error_msg != NULL)) |
| 335 | mlog(ML_ERROR, "bad entry in directory #%llu: %s - " | 336 | mlog(ML_ERROR, "bad entry in directory #%llu: %s - " |
| 336 | "offset=%lu, inode=%llu, rec_len=%d, name_len=%d\n", | 337 | "offset=%lu, inode=%llu, rec_len=%d, name_len=%d\n", |
| 337 | (unsigned long long)OCFS2_I(dir)->ip_blkno, error_msg, | 338 | (unsigned long long)OCFS2_I(dir)->ip_blkno, error_msg, |
| 338 | offset, (unsigned long long)le64_to_cpu(de->inode), rlen, | 339 | offset, (unsigned long long)le64_to_cpu(de->inode), rlen, |
| 339 | de->name_len); | 340 | de->name_len); |
| 341 | |||
| 340 | return error_msg == NULL ? 1 : 0; | 342 | return error_msg == NULL ? 1 : 0; |
| 341 | } | 343 | } |
| 342 | 344 | ||
| @@ -367,8 +369,6 @@ static inline int ocfs2_search_dirblock(struct buffer_head *bh, | |||
| 367 | int de_len; | 369 | int de_len; |
| 368 | int ret = 0; | 370 | int ret = 0; |
| 369 | 371 | ||
| 370 | mlog_entry_void(); | ||
| 371 | |||
| 372 | de_buf = first_de; | 372 | de_buf = first_de; |
| 373 | dlimit = de_buf + bytes; | 373 | dlimit = de_buf + bytes; |
| 374 | 374 | ||
| @@ -402,7 +402,7 @@ static inline int ocfs2_search_dirblock(struct buffer_head *bh, | |||
| 402 | } | 402 | } |
| 403 | 403 | ||
| 404 | bail: | 404 | bail: |
| 405 | mlog_exit(ret); | 405 | trace_ocfs2_search_dirblock(ret); |
| 406 | return ret; | 406 | return ret; |
| 407 | } | 407 | } |
| 408 | 408 | ||
| @@ -447,8 +447,7 @@ static int ocfs2_validate_dir_block(struct super_block *sb, | |||
| 447 | * We don't validate dirents here, that's handled | 447 | * We don't validate dirents here, that's handled |
| 448 | * in-place when the code walks them. | 448 | * in-place when the code walks them. |
| 449 | */ | 449 | */ |
| 450 | mlog(0, "Validating dirblock %llu\n", | 450 | trace_ocfs2_validate_dir_block((unsigned long long)bh->b_blocknr); |
| 451 | (unsigned long long)bh->b_blocknr); | ||
| 452 | 451 | ||
| 453 | BUG_ON(!buffer_uptodate(bh)); | 452 | BUG_ON(!buffer_uptodate(bh)); |
| 454 | 453 | ||
| @@ -706,8 +705,6 @@ static struct buffer_head *ocfs2_find_entry_el(const char *name, int namelen, | |||
| 706 | int num = 0; | 705 | int num = 0; |
| 707 | int nblocks, i, err; | 706 | int nblocks, i, err; |
| 708 | 707 | ||
| 709 | mlog_entry_void(); | ||
| 710 | |||
| 711 | sb = dir->i_sb; | 708 | sb = dir->i_sb; |
| 712 | 709 | ||
| 713 | nblocks = i_size_read(dir) >> sb->s_blocksize_bits; | 710 | nblocks = i_size_read(dir) >> sb->s_blocksize_bits; |
| @@ -788,7 +785,7 @@ cleanup_and_exit: | |||
| 788 | for (; ra_ptr < ra_max; ra_ptr++) | 785 | for (; ra_ptr < ra_max; ra_ptr++) |
| 789 | brelse(bh_use[ra_ptr]); | 786 | brelse(bh_use[ra_ptr]); |
| 790 | 787 | ||
| 791 | mlog_exit_ptr(ret); | 788 | trace_ocfs2_find_entry_el(ret); |
| 792 | return ret; | 789 | return ret; |
| 793 | } | 790 | } |
| 794 | 791 | ||
| @@ -950,11 +947,9 @@ static int ocfs2_dx_dir_search(const char *name, int namelen, | |||
| 950 | goto out; | 947 | goto out; |
| 951 | } | 948 | } |
| 952 | 949 | ||
| 953 | mlog(0, "Dir %llu: name: \"%.*s\", lookup of hash: %u.0x%x " | 950 | trace_ocfs2_dx_dir_search((unsigned long long)OCFS2_I(dir)->ip_blkno, |
| 954 | "returns: %llu\n", | 951 | namelen, name, hinfo->major_hash, |
| 955 | (unsigned long long)OCFS2_I(dir)->ip_blkno, | 952 | hinfo->minor_hash, (unsigned long long)phys); |
| 956 | namelen, name, hinfo->major_hash, hinfo->minor_hash, | ||
| 957 | (unsigned long long)phys); | ||
| 958 | 953 | ||
| 959 | ret = ocfs2_read_dx_leaf(dir, phys, &dx_leaf_bh); | 954 | ret = ocfs2_read_dx_leaf(dir, phys, &dx_leaf_bh); |
| 960 | if (ret) { | 955 | if (ret) { |
| @@ -964,9 +959,9 @@ static int ocfs2_dx_dir_search(const char *name, int namelen, | |||
| 964 | 959 | ||
| 965 | dx_leaf = (struct ocfs2_dx_leaf *) dx_leaf_bh->b_data; | 960 | dx_leaf = (struct ocfs2_dx_leaf *) dx_leaf_bh->b_data; |
| 966 | 961 | ||
| 967 | mlog(0, "leaf info: num_used: %d, count: %d\n", | 962 | trace_ocfs2_dx_dir_search_leaf_info( |
| 968 | le16_to_cpu(dx_leaf->dl_list.de_num_used), | 963 | le16_to_cpu(dx_leaf->dl_list.de_num_used), |
| 969 | le16_to_cpu(dx_leaf->dl_list.de_count)); | 964 | le16_to_cpu(dx_leaf->dl_list.de_count)); |
| 970 | 965 | ||
| 971 | entry_list = &dx_leaf->dl_list; | 966 | entry_list = &dx_leaf->dl_list; |
| 972 | 967 | ||
| @@ -1166,8 +1161,6 @@ static int __ocfs2_delete_entry(handle_t *handle, struct inode *dir, | |||
| 1166 | int i, status = -ENOENT; | 1161 | int i, status = -ENOENT; |
| 1167 | ocfs2_journal_access_func access = ocfs2_journal_access_db; | 1162 | ocfs2_journal_access_func access = ocfs2_journal_access_db; |
| 1168 | 1163 | ||
| 1169 | mlog_entry("(0x%p, 0x%p, 0x%p, 0x%p)\n", handle, dir, de_del, bh); | ||
| 1170 | |||
| 1171 | if (OCFS2_I(dir)->ip_dyn_features & OCFS2_INLINE_DATA_FL) | 1164 | if (OCFS2_I(dir)->ip_dyn_features & OCFS2_INLINE_DATA_FL) |
| 1172 | access = ocfs2_journal_access_di; | 1165 | access = ocfs2_journal_access_di; |
| 1173 | 1166 | ||
| @@ -1202,7 +1195,6 @@ static int __ocfs2_delete_entry(handle_t *handle, struct inode *dir, | |||
| 1202 | de = (struct ocfs2_dir_entry *)((char *)de + le16_to_cpu(de->rec_len)); | 1195 | de = (struct ocfs2_dir_entry *)((char *)de + le16_to_cpu(de->rec_len)); |
| 1203 | } | 1196 | } |
| 1204 | bail: | 1197 | bail: |
| 1205 | mlog_exit(status); | ||
| 1206 | return status; | 1198 | return status; |
| 1207 | } | 1199 | } |
| 1208 | 1200 | ||
| @@ -1348,8 +1340,8 @@ static int ocfs2_delete_entry_dx(handle_t *handle, struct inode *dir, | |||
| 1348 | } | 1340 | } |
| 1349 | } | 1341 | } |
| 1350 | 1342 | ||
| 1351 | mlog(0, "Dir %llu: delete entry at index: %d\n", | 1343 | trace_ocfs2_delete_entry_dx((unsigned long long)OCFS2_I(dir)->ip_blkno, |
| 1352 | (unsigned long long)OCFS2_I(dir)->ip_blkno, index); | 1344 | index); |
| 1353 | 1345 | ||
| 1354 | ret = __ocfs2_delete_entry(handle, dir, lookup->dl_entry, | 1346 | ret = __ocfs2_delete_entry(handle, dir, lookup->dl_entry, |
| 1355 | leaf_bh, leaf_bh->b_data, leaf_bh->b_size); | 1347 | leaf_bh, leaf_bh->b_data, leaf_bh->b_size); |
| @@ -1632,8 +1624,6 @@ int __ocfs2_add_entry(handle_t *handle, | |||
| 1632 | struct buffer_head *insert_bh = lookup->dl_leaf_bh; | 1624 | struct buffer_head *insert_bh = lookup->dl_leaf_bh; |
| 1633 | char *data_start = insert_bh->b_data; | 1625 | char *data_start = insert_bh->b_data; |
| 1634 | 1626 | ||
| 1635 | mlog_entry_void(); | ||
| 1636 | |||
| 1637 | if (!namelen) | 1627 | if (!namelen) |
| 1638 | return -EINVAL; | 1628 | return -EINVAL; |
| 1639 | 1629 | ||
| @@ -1765,8 +1755,9 @@ int __ocfs2_add_entry(handle_t *handle, | |||
| 1765 | * from ever getting here. */ | 1755 | * from ever getting here. */ |
| 1766 | retval = -ENOSPC; | 1756 | retval = -ENOSPC; |
| 1767 | bail: | 1757 | bail: |
| 1758 | if (retval) | ||
| 1759 | mlog_errno(retval); | ||
| 1768 | 1760 | ||
| 1769 | mlog_exit(retval); | ||
| 1770 | return retval; | 1761 | return retval; |
| 1771 | } | 1762 | } |
| 1772 | 1763 | ||
| @@ -2028,8 +2019,7 @@ int ocfs2_readdir(struct file * filp, void * dirent, filldir_t filldir) | |||
| 2028 | struct inode *inode = filp->f_path.dentry->d_inode; | 2019 | struct inode *inode = filp->f_path.dentry->d_inode; |
| 2029 | int lock_level = 0; | 2020 | int lock_level = 0; |
| 2030 | 2021 | ||
| 2031 | mlog_entry("dirino=%llu\n", | 2022 | trace_ocfs2_readdir((unsigned long long)OCFS2_I(inode)->ip_blkno); |
| 2032 | (unsigned long long)OCFS2_I(inode)->ip_blkno); | ||
| 2033 | 2023 | ||
| 2034 | error = ocfs2_inode_lock_atime(inode, filp->f_vfsmnt, &lock_level); | 2024 | error = ocfs2_inode_lock_atime(inode, filp->f_vfsmnt, &lock_level); |
| 2035 | if (lock_level && error >= 0) { | 2025 | if (lock_level && error >= 0) { |
| @@ -2051,9 +2041,10 @@ int ocfs2_readdir(struct file * filp, void * dirent, filldir_t filldir) | |||
| 2051 | dirent, filldir, NULL); | 2041 | dirent, filldir, NULL); |
| 2052 | 2042 | ||
| 2053 | ocfs2_inode_unlock(inode, lock_level); | 2043 | ocfs2_inode_unlock(inode, lock_level); |
| 2044 | if (error) | ||
| 2045 | mlog_errno(error); | ||
| 2054 | 2046 | ||
| 2055 | bail_nolock: | 2047 | bail_nolock: |
| 2056 | mlog_exit(error); | ||
| 2057 | 2048 | ||
| 2058 | return error; | 2049 | return error; |
| 2059 | } | 2050 | } |
| @@ -2069,8 +2060,8 @@ int ocfs2_find_files_on_disk(const char *name, | |||
| 2069 | { | 2060 | { |
| 2070 | int status = -ENOENT; | 2061 | int status = -ENOENT; |
| 2071 | 2062 | ||
| 2072 | mlog(0, "name=%.*s, blkno=%p, inode=%llu\n", namelen, name, blkno, | 2063 | trace_ocfs2_find_files_on_disk(namelen, name, blkno, |
| 2073 | (unsigned long long)OCFS2_I(inode)->ip_blkno); | 2064 | (unsigned long long)OCFS2_I(inode)->ip_blkno); |
| 2074 | 2065 | ||
| 2075 | status = ocfs2_find_entry(name, namelen, inode, lookup); | 2066 | status = ocfs2_find_entry(name, namelen, inode, lookup); |
| 2076 | if (status) | 2067 | if (status) |
| @@ -2114,8 +2105,8 @@ int ocfs2_check_dir_for_entry(struct inode *dir, | |||
| 2114 | int ret; | 2105 | int ret; |
| 2115 | struct ocfs2_dir_lookup_result lookup = { NULL, }; | 2106 | struct ocfs2_dir_lookup_result lookup = { NULL, }; |
| 2116 | 2107 | ||
| 2117 | mlog_entry("dir %llu, name '%.*s'\n", | 2108 | trace_ocfs2_check_dir_for_entry( |
| 2118 | (unsigned long long)OCFS2_I(dir)->ip_blkno, namelen, name); | 2109 | (unsigned long long)OCFS2_I(dir)->ip_blkno, namelen, name); |
| 2119 | 2110 | ||
| 2120 | ret = -EEXIST; | 2111 | ret = -EEXIST; |
| 2121 | if (ocfs2_find_entry(name, namelen, dir, &lookup) == 0) | 2112 | if (ocfs2_find_entry(name, namelen, dir, &lookup) == 0) |
| @@ -2125,7 +2116,8 @@ int ocfs2_check_dir_for_entry(struct inode *dir, | |||
| 2125 | bail: | 2116 | bail: |
| 2126 | ocfs2_free_dir_lookup_result(&lookup); | 2117 | ocfs2_free_dir_lookup_result(&lookup); |
| 2127 | 2118 | ||
| 2128 | mlog_exit(ret); | 2119 | if (ret) |
| 2120 | mlog_errno(ret); | ||
| 2129 | return ret; | 2121 | return ret; |
| 2130 | } | 2122 | } |
| 2131 | 2123 | ||
| @@ -2324,8 +2316,6 @@ static int ocfs2_fill_new_dir_el(struct ocfs2_super *osb, | |||
| 2324 | struct buffer_head *new_bh = NULL; | 2316 | struct buffer_head *new_bh = NULL; |
| 2325 | struct ocfs2_dir_entry *de; | 2317 | struct ocfs2_dir_entry *de; |
| 2326 | 2318 | ||
| 2327 | mlog_entry_void(); | ||
| 2328 | |||
| 2329 | if (ocfs2_new_dir_wants_trailer(inode)) | 2319 | if (ocfs2_new_dir_wants_trailer(inode)) |
| 2330 | size = ocfs2_dir_trailer_blk_off(parent->i_sb); | 2320 | size = ocfs2_dir_trailer_blk_off(parent->i_sb); |
| 2331 | 2321 | ||
| @@ -2380,7 +2370,6 @@ static int ocfs2_fill_new_dir_el(struct ocfs2_super *osb, | |||
| 2380 | bail: | 2370 | bail: |
| 2381 | brelse(new_bh); | 2371 | brelse(new_bh); |
| 2382 | 2372 | ||
| 2383 | mlog_exit(status); | ||
| 2384 | return status; | 2373 | return status; |
| 2385 | } | 2374 | } |
| 2386 | 2375 | ||
| @@ -2409,9 +2398,9 @@ static int ocfs2_dx_dir_attach_index(struct ocfs2_super *osb, | |||
| 2409 | goto out; | 2398 | goto out; |
| 2410 | } | 2399 | } |
| 2411 | 2400 | ||
| 2412 | mlog(0, "Dir %llu, attach new index block: %llu\n", | 2401 | trace_ocfs2_dx_dir_attach_index( |
| 2413 | (unsigned long long)OCFS2_I(dir)->ip_blkno, | 2402 | (unsigned long long)OCFS2_I(dir)->ip_blkno, |
| 2414 | (unsigned long long)dr_blkno); | 2403 | (unsigned long long)dr_blkno); |
| 2415 | 2404 | ||
| 2416 | dx_root_bh = sb_getblk(osb->sb, dr_blkno); | 2405 | dx_root_bh = sb_getblk(osb->sb, dr_blkno); |
| 2417 | if (dx_root_bh == NULL) { | 2406 | if (dx_root_bh == NULL) { |
| @@ -2511,11 +2500,10 @@ static int ocfs2_dx_dir_format_cluster(struct ocfs2_super *osb, | |||
| 2511 | dx_leaf->dl_list.de_count = | 2500 | dx_leaf->dl_list.de_count = |
| 2512 | cpu_to_le16(ocfs2_dx_entries_per_leaf(osb->sb)); | 2501 | cpu_to_le16(ocfs2_dx_entries_per_leaf(osb->sb)); |
| 2513 | 2502 | ||
| 2514 | mlog(0, | 2503 | trace_ocfs2_dx_dir_format_cluster( |
| 2515 | "Dir %llu, format dx_leaf: %llu, entry count: %u\n", | 2504 | (unsigned long long)OCFS2_I(dir)->ip_blkno, |
| 2516 | (unsigned long long)OCFS2_I(dir)->ip_blkno, | 2505 | (unsigned long long)bh->b_blocknr, |
| 2517 | (unsigned long long)bh->b_blocknr, | 2506 | le16_to_cpu(dx_leaf->dl_list.de_count)); |
| 2518 | le16_to_cpu(dx_leaf->dl_list.de_count)); | ||
| 2519 | 2507 | ||
| 2520 | ocfs2_journal_dirty(handle, bh); | 2508 | ocfs2_journal_dirty(handle, bh); |
| 2521 | } | 2509 | } |
| @@ -2759,12 +2747,11 @@ static void ocfs2_dx_dir_index_root_block(struct inode *dir, | |||
| 2759 | 2747 | ||
| 2760 | ocfs2_dx_dir_name_hash(dir, de->name, de->name_len, &hinfo); | 2748 | ocfs2_dx_dir_name_hash(dir, de->name, de->name_len, &hinfo); |
| 2761 | 2749 | ||
| 2762 | mlog(0, | 2750 | trace_ocfs2_dx_dir_index_root_block( |
| 2763 | "dir: %llu, major: 0x%x minor: 0x%x, index: %u, name: %.*s\n", | 2751 | (unsigned long long)dir->i_ino, |
| 2764 | (unsigned long long)dir->i_ino, hinfo.major_hash, | 2752 | hinfo.major_hash, hinfo.minor_hash, |
| 2765 | hinfo.minor_hash, | 2753 | de->name_len, de->name, |
| 2766 | le16_to_cpu(dx_root->dr_entries.de_num_used), | 2754 | le16_to_cpu(dx_root->dr_entries.de_num_used)); |
| 2767 | de->name_len, de->name); | ||
| 2768 | 2755 | ||
| 2769 | ocfs2_dx_entry_list_insert(&dx_root->dr_entries, &hinfo, | 2756 | ocfs2_dx_entry_list_insert(&dx_root->dr_entries, &hinfo, |
| 2770 | dirent_blk); | 2757 | dirent_blk); |
| @@ -3235,7 +3222,6 @@ static int ocfs2_do_extend_dir(struct super_block *sb, | |||
| 3235 | bail: | 3222 | bail: |
| 3236 | if (did_quota && status < 0) | 3223 | if (did_quota && status < 0) |
| 3237 | dquot_free_space_nodirty(dir, ocfs2_clusters_to_bytes(sb, 1)); | 3224 | dquot_free_space_nodirty(dir, ocfs2_clusters_to_bytes(sb, 1)); |
| 3238 | mlog_exit(status); | ||
| 3239 | return status; | 3225 | return status; |
| 3240 | } | 3226 | } |
| 3241 | 3227 | ||
| @@ -3270,8 +3256,6 @@ static int ocfs2_extend_dir(struct ocfs2_super *osb, | |||
| 3270 | struct ocfs2_extent_tree et; | 3256 | struct ocfs2_extent_tree et; |
| 3271 | struct buffer_head *dx_root_bh = lookup->dl_dx_root_bh; | 3257 | struct buffer_head *dx_root_bh = lookup->dl_dx_root_bh; |
| 3272 | 3258 | ||
| 3273 | mlog_entry_void(); | ||
| 3274 | |||
| 3275 | if (OCFS2_I(dir)->ip_dyn_features & OCFS2_INLINE_DATA_FL) { | 3259 | if (OCFS2_I(dir)->ip_dyn_features & OCFS2_INLINE_DATA_FL) { |
| 3276 | /* | 3260 | /* |
| 3277 | * This would be a code error as an inline directory should | 3261 | * This would be a code error as an inline directory should |
| @@ -3320,8 +3304,8 @@ static int ocfs2_extend_dir(struct ocfs2_super *osb, | |||
| 3320 | down_write(&OCFS2_I(dir)->ip_alloc_sem); | 3304 | down_write(&OCFS2_I(dir)->ip_alloc_sem); |
| 3321 | drop_alloc_sem = 1; | 3305 | drop_alloc_sem = 1; |
| 3322 | dir_i_size = i_size_read(dir); | 3306 | dir_i_size = i_size_read(dir); |
| 3323 | mlog(0, "extending dir %llu (i_size = %lld)\n", | 3307 | trace_ocfs2_extend_dir((unsigned long long)OCFS2_I(dir)->ip_blkno, |
| 3324 | (unsigned long long)OCFS2_I(dir)->ip_blkno, dir_i_size); | 3308 | dir_i_size); |
| 3325 | 3309 | ||
| 3326 | /* dir->i_size is always block aligned. */ | 3310 | /* dir->i_size is always block aligned. */ |
| 3327 | spin_lock(&OCFS2_I(dir)->ip_lock); | 3311 | spin_lock(&OCFS2_I(dir)->ip_lock); |
| @@ -3436,7 +3420,6 @@ bail: | |||
| 3436 | 3420 | ||
| 3437 | brelse(new_bh); | 3421 | brelse(new_bh); |
| 3438 | 3422 | ||
| 3439 | mlog_exit(status); | ||
| 3440 | return status; | 3423 | return status; |
| 3441 | } | 3424 | } |
| 3442 | 3425 | ||
| @@ -3583,8 +3566,9 @@ next: | |||
| 3583 | status = 0; | 3566 | status = 0; |
| 3584 | bail: | 3567 | bail: |
| 3585 | brelse(bh); | 3568 | brelse(bh); |
| 3569 | if (status) | ||
| 3570 | mlog_errno(status); | ||
| 3586 | 3571 | ||
| 3587 | mlog_exit(status); | ||
| 3588 | return status; | 3572 | return status; |
| 3589 | } | 3573 | } |
| 3590 | 3574 | ||
| @@ -3815,9 +3799,9 @@ static int ocfs2_dx_dir_rebalance(struct ocfs2_super *osb, struct inode *dir, | |||
| 3815 | struct ocfs2_dx_root_block *dx_root; | 3799 | struct ocfs2_dx_root_block *dx_root; |
| 3816 | struct ocfs2_dx_leaf *tmp_dx_leaf = NULL; | 3800 | struct ocfs2_dx_leaf *tmp_dx_leaf = NULL; |
| 3817 | 3801 | ||
| 3818 | mlog(0, "DX Dir: %llu, rebalance leaf leaf_blkno: %llu insert: %u\n", | 3802 | trace_ocfs2_dx_dir_rebalance((unsigned long long)OCFS2_I(dir)->ip_blkno, |
| 3819 | (unsigned long long)OCFS2_I(dir)->ip_blkno, | 3803 | (unsigned long long)leaf_blkno, |
| 3820 | (unsigned long long)leaf_blkno, insert_hash); | 3804 | insert_hash); |
| 3821 | 3805 | ||
| 3822 | ocfs2_init_dx_root_extent_tree(&et, INODE_CACHE(dir), dx_root_bh); | 3806 | ocfs2_init_dx_root_extent_tree(&et, INODE_CACHE(dir), dx_root_bh); |
| 3823 | 3807 | ||
| @@ -3897,8 +3881,7 @@ static int ocfs2_dx_dir_rebalance(struct ocfs2_super *osb, struct inode *dir, | |||
| 3897 | goto out_commit; | 3881 | goto out_commit; |
| 3898 | } | 3882 | } |
| 3899 | 3883 | ||
| 3900 | mlog(0, "Split leaf (%u) at %u, insert major hash is %u\n", | 3884 | trace_ocfs2_dx_dir_rebalance_split(leaf_cpos, split_hash, insert_hash); |
| 3901 | leaf_cpos, split_hash, insert_hash); | ||
| 3902 | 3885 | ||
| 3903 | /* | 3886 | /* |
| 3904 | * We have to carefully order operations here. There are items | 3887 | * We have to carefully order operations here. There are items |
| @@ -4355,8 +4338,8 @@ int ocfs2_prepare_dir_for_insert(struct ocfs2_super *osb, | |||
| 4355 | unsigned int blocks_wanted = 1; | 4338 | unsigned int blocks_wanted = 1; |
| 4356 | struct buffer_head *bh = NULL; | 4339 | struct buffer_head *bh = NULL; |
| 4357 | 4340 | ||
| 4358 | mlog(0, "getting ready to insert namelen %d into dir %llu\n", | 4341 | trace_ocfs2_prepare_dir_for_insert( |
| 4359 | namelen, (unsigned long long)OCFS2_I(dir)->ip_blkno); | 4342 | (unsigned long long)OCFS2_I(dir)->ip_blkno, namelen); |
| 4360 | 4343 | ||
| 4361 | if (!namelen) { | 4344 | if (!namelen) { |
| 4362 | ret = -EINVAL; | 4345 | ret = -EINVAL; |
diff --git a/fs/ocfs2/dlm/dlmconvert.c b/fs/ocfs2/dlm/dlmconvert.c index 9f30491e5e8..29a886d1e82 100644 --- a/fs/ocfs2/dlm/dlmconvert.c +++ b/fs/ocfs2/dlm/dlmconvert.c | |||
| @@ -128,8 +128,8 @@ static enum dlm_status __dlmconvert_master(struct dlm_ctxt *dlm, | |||
| 128 | 128 | ||
| 129 | assert_spin_locked(&res->spinlock); | 129 | assert_spin_locked(&res->spinlock); |
| 130 | 130 | ||
| 131 | mlog_entry("type=%d, convert_type=%d, new convert_type=%d\n", | 131 | mlog(0, "type=%d, convert_type=%d, new convert_type=%d\n", |
| 132 | lock->ml.type, lock->ml.convert_type, type); | 132 | lock->ml.type, lock->ml.convert_type, type); |
| 133 | 133 | ||
| 134 | spin_lock(&lock->spinlock); | 134 | spin_lock(&lock->spinlock); |
| 135 | 135 | ||
| @@ -353,7 +353,7 @@ static enum dlm_status dlm_send_remote_convert_request(struct dlm_ctxt *dlm, | |||
| 353 | struct kvec vec[2]; | 353 | struct kvec vec[2]; |
| 354 | size_t veclen = 1; | 354 | size_t veclen = 1; |
| 355 | 355 | ||
| 356 | mlog_entry("%.*s\n", res->lockname.len, res->lockname.name); | 356 | mlog(0, "%.*s\n", res->lockname.len, res->lockname.name); |
| 357 | 357 | ||
| 358 | memset(&convert, 0, sizeof(struct dlm_convert_lock)); | 358 | memset(&convert, 0, sizeof(struct dlm_convert_lock)); |
| 359 | convert.node_idx = dlm->node_num; | 359 | convert.node_idx = dlm->node_num; |
diff --git a/fs/ocfs2/dlm/dlmdomain.c b/fs/ocfs2/dlm/dlmdomain.c index 7e38a072d72..7540a492eab 100644 --- a/fs/ocfs2/dlm/dlmdomain.c +++ b/fs/ocfs2/dlm/dlmdomain.c | |||
| @@ -188,7 +188,7 @@ struct dlm_lock_resource * __dlm_lookup_lockres_full(struct dlm_ctxt *dlm, | |||
| 188 | struct hlist_head *bucket; | 188 | struct hlist_head *bucket; |
| 189 | struct hlist_node *list; | 189 | struct hlist_node *list; |
| 190 | 190 | ||
| 191 | mlog_entry("%.*s\n", len, name); | 191 | mlog(0, "%.*s\n", len, name); |
| 192 | 192 | ||
| 193 | assert_spin_locked(&dlm->spinlock); | 193 | assert_spin_locked(&dlm->spinlock); |
| 194 | 194 | ||
| @@ -222,7 +222,7 @@ struct dlm_lock_resource * __dlm_lookup_lockres(struct dlm_ctxt *dlm, | |||
| 222 | { | 222 | { |
| 223 | struct dlm_lock_resource *res = NULL; | 223 | struct dlm_lock_resource *res = NULL; |
| 224 | 224 | ||
| 225 | mlog_entry("%.*s\n", len, name); | 225 | mlog(0, "%.*s\n", len, name); |
| 226 | 226 | ||
| 227 | assert_spin_locked(&dlm->spinlock); | 227 | assert_spin_locked(&dlm->spinlock); |
| 228 | 228 | ||
| @@ -531,7 +531,7 @@ static int dlm_exit_domain_handler(struct o2net_msg *msg, u32 len, void *data, | |||
| 531 | unsigned int node; | 531 | unsigned int node; |
| 532 | struct dlm_exit_domain *exit_msg = (struct dlm_exit_domain *) msg->buf; | 532 | struct dlm_exit_domain *exit_msg = (struct dlm_exit_domain *) msg->buf; |
| 533 | 533 | ||
| 534 | mlog_entry("%p %u %p", msg, len, data); | 534 | mlog(0, "%p %u %p", msg, len, data); |
| 535 | 535 | ||
| 536 | if (!dlm_grab(dlm)) | 536 | if (!dlm_grab(dlm)) |
| 537 | return 0; | 537 | return 0; |
| @@ -926,9 +926,10 @@ static int dlm_assert_joined_handler(struct o2net_msg *msg, u32 len, void *data, | |||
| 926 | } | 926 | } |
| 927 | 927 | ||
| 928 | static int dlm_match_regions(struct dlm_ctxt *dlm, | 928 | static int dlm_match_regions(struct dlm_ctxt *dlm, |
| 929 | struct dlm_query_region *qr) | 929 | struct dlm_query_region *qr, |
| 930 | char *local, int locallen) | ||
| 930 | { | 931 | { |
| 931 | char *local = NULL, *remote = qr->qr_regions; | 932 | char *remote = qr->qr_regions; |
| 932 | char *l, *r; | 933 | char *l, *r; |
| 933 | int localnr, i, j, foundit; | 934 | int localnr, i, j, foundit; |
| 934 | int status = 0; | 935 | int status = 0; |
| @@ -957,13 +958,8 @@ static int dlm_match_regions(struct dlm_ctxt *dlm, | |||
| 957 | r += O2HB_MAX_REGION_NAME_LEN; | 958 | r += O2HB_MAX_REGION_NAME_LEN; |
| 958 | } | 959 | } |
| 959 | 960 | ||
| 960 | local = kmalloc(sizeof(qr->qr_regions), GFP_ATOMIC); | 961 | localnr = min(O2NM_MAX_REGIONS, locallen/O2HB_MAX_REGION_NAME_LEN); |
| 961 | if (!local) { | 962 | localnr = o2hb_get_all_regions(local, (u8)localnr); |
| 962 | status = -ENOMEM; | ||
| 963 | goto bail; | ||
| 964 | } | ||
| 965 | |||
| 966 | localnr = o2hb_get_all_regions(local, O2NM_MAX_REGIONS); | ||
| 967 | 963 | ||
| 968 | /* compare local regions with remote */ | 964 | /* compare local regions with remote */ |
| 969 | l = local; | 965 | l = local; |
| @@ -1012,8 +1008,6 @@ static int dlm_match_regions(struct dlm_ctxt *dlm, | |||
| 1012 | } | 1008 | } |
| 1013 | 1009 | ||
| 1014 | bail: | 1010 | bail: |
| 1015 | kfree(local); | ||
| 1016 | |||
| 1017 | return status; | 1011 | return status; |
| 1018 | } | 1012 | } |
| 1019 | 1013 | ||
| @@ -1075,6 +1069,7 @@ static int dlm_query_region_handler(struct o2net_msg *msg, u32 len, | |||
| 1075 | { | 1069 | { |
| 1076 | struct dlm_query_region *qr; | 1070 | struct dlm_query_region *qr; |
| 1077 | struct dlm_ctxt *dlm = NULL; | 1071 | struct dlm_ctxt *dlm = NULL; |
| 1072 | char *local = NULL; | ||
| 1078 | int status = 0; | 1073 | int status = 0; |
| 1079 | int locked = 0; | 1074 | int locked = 0; |
| 1080 | 1075 | ||
| @@ -1083,6 +1078,13 @@ static int dlm_query_region_handler(struct o2net_msg *msg, u32 len, | |||
| 1083 | mlog(0, "Node %u queries hb regions on domain %s\n", qr->qr_node, | 1078 | mlog(0, "Node %u queries hb regions on domain %s\n", qr->qr_node, |
| 1084 | qr->qr_domain); | 1079 | qr->qr_domain); |
| 1085 | 1080 | ||
| 1081 | /* buffer used in dlm_mast_regions() */ | ||
| 1082 | local = kmalloc(sizeof(qr->qr_regions), GFP_KERNEL); | ||
| 1083 | if (!local) { | ||
| 1084 | status = -ENOMEM; | ||
| 1085 | goto bail; | ||
| 1086 | } | ||
| 1087 | |||
| 1086 | status = -EINVAL; | 1088 | status = -EINVAL; |
| 1087 | 1089 | ||
| 1088 | spin_lock(&dlm_domain_lock); | 1090 | spin_lock(&dlm_domain_lock); |
| @@ -1112,13 +1114,15 @@ static int dlm_query_region_handler(struct o2net_msg *msg, u32 len, | |||
| 1112 | goto bail; | 1114 | goto bail; |
| 1113 | } | 1115 | } |
| 1114 | 1116 | ||
| 1115 | status = dlm_match_regions(dlm, qr); | 1117 | status = dlm_match_regions(dlm, qr, local, sizeof(qr->qr_regions)); |
| 1116 | 1118 | ||
| 1117 | bail: | 1119 | bail: |
| 1118 | if (locked) | 1120 | if (locked) |
| 1119 | spin_unlock(&dlm->spinlock); | 1121 | spin_unlock(&dlm->spinlock); |
| 1120 | spin_unlock(&dlm_domain_lock); | 1122 | spin_unlock(&dlm_domain_lock); |
| 1121 | 1123 | ||
| 1124 | kfree(local); | ||
| 1125 | |||
| 1122 | return status; | 1126 | return status; |
| 1123 | } | 1127 | } |
| 1124 | 1128 | ||
| @@ -1553,7 +1557,7 @@ static int dlm_try_to_join_domain(struct dlm_ctxt *dlm) | |||
| 1553 | struct domain_join_ctxt *ctxt; | 1557 | struct domain_join_ctxt *ctxt; |
| 1554 | enum dlm_query_join_response_code response = JOIN_DISALLOW; | 1558 | enum dlm_query_join_response_code response = JOIN_DISALLOW; |
| 1555 | 1559 | ||
| 1556 | mlog_entry("%p", dlm); | 1560 | mlog(0, "%p", dlm); |
| 1557 | 1561 | ||
| 1558 | ctxt = kzalloc(sizeof(*ctxt), GFP_KERNEL); | 1562 | ctxt = kzalloc(sizeof(*ctxt), GFP_KERNEL); |
| 1559 | if (!ctxt) { | 1563 | if (!ctxt) { |
diff --git a/fs/ocfs2/dlm/dlmlock.c b/fs/ocfs2/dlm/dlmlock.c index 7009292aac5..8d39e0fd66f 100644 --- a/fs/ocfs2/dlm/dlmlock.c +++ b/fs/ocfs2/dlm/dlmlock.c | |||
| @@ -128,7 +128,7 @@ static enum dlm_status dlmlock_master(struct dlm_ctxt *dlm, | |||
| 128 | int call_ast = 0, kick_thread = 0; | 128 | int call_ast = 0, kick_thread = 0; |
| 129 | enum dlm_status status = DLM_NORMAL; | 129 | enum dlm_status status = DLM_NORMAL; |
| 130 | 130 | ||
| 131 | mlog_entry("type=%d\n", lock->ml.type); | 131 | mlog(0, "type=%d\n", lock->ml.type); |
| 132 | 132 | ||
| 133 | spin_lock(&res->spinlock); | 133 | spin_lock(&res->spinlock); |
| 134 | /* if called from dlm_create_lock_handler, need to | 134 | /* if called from dlm_create_lock_handler, need to |
| @@ -227,8 +227,8 @@ static enum dlm_status dlmlock_remote(struct dlm_ctxt *dlm, | |||
| 227 | enum dlm_status status = DLM_DENIED; | 227 | enum dlm_status status = DLM_DENIED; |
| 228 | int lockres_changed = 1; | 228 | int lockres_changed = 1; |
| 229 | 229 | ||
| 230 | mlog_entry("type=%d\n", lock->ml.type); | 230 | mlog(0, "type=%d, lockres %.*s, flags = 0x%x\n", |
| 231 | mlog(0, "lockres %.*s, flags = 0x%x\n", res->lockname.len, | 231 | lock->ml.type, res->lockname.len, |
| 232 | res->lockname.name, flags); | 232 | res->lockname.name, flags); |
| 233 | 233 | ||
| 234 | spin_lock(&res->spinlock); | 234 | spin_lock(&res->spinlock); |
| @@ -308,8 +308,6 @@ static enum dlm_status dlm_send_remote_lock_request(struct dlm_ctxt *dlm, | |||
| 308 | int tmpret, status = 0; | 308 | int tmpret, status = 0; |
| 309 | enum dlm_status ret; | 309 | enum dlm_status ret; |
| 310 | 310 | ||
| 311 | mlog_entry_void(); | ||
| 312 | |||
| 313 | memset(&create, 0, sizeof(create)); | 311 | memset(&create, 0, sizeof(create)); |
| 314 | create.node_idx = dlm->node_num; | 312 | create.node_idx = dlm->node_num; |
| 315 | create.requested_type = lock->ml.type; | 313 | create.requested_type = lock->ml.type; |
| @@ -477,8 +475,6 @@ int dlm_create_lock_handler(struct o2net_msg *msg, u32 len, void *data, | |||
| 477 | 475 | ||
| 478 | BUG_ON(!dlm); | 476 | BUG_ON(!dlm); |
| 479 | 477 | ||
| 480 | mlog_entry_void(); | ||
| 481 | |||
| 482 | if (!dlm_grab(dlm)) | 478 | if (!dlm_grab(dlm)) |
| 483 | return DLM_REJECTED; | 479 | return DLM_REJECTED; |
| 484 | 480 | ||
diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c index 59f0f6bdfc6..9d67610dfc7 100644 --- a/fs/ocfs2/dlm/dlmmaster.c +++ b/fs/ocfs2/dlm/dlmmaster.c | |||
| @@ -426,8 +426,6 @@ static void dlm_mle_release(struct kref *kref) | |||
| 426 | struct dlm_master_list_entry *mle; | 426 | struct dlm_master_list_entry *mle; |
| 427 | struct dlm_ctxt *dlm; | 427 | struct dlm_ctxt *dlm; |
| 428 | 428 | ||
| 429 | mlog_entry_void(); | ||
| 430 | |||
| 431 | mle = container_of(kref, struct dlm_master_list_entry, mle_refs); | 429 | mle = container_of(kref, struct dlm_master_list_entry, mle_refs); |
| 432 | dlm = mle->dlm; | 430 | dlm = mle->dlm; |
| 433 | 431 | ||
| @@ -3120,8 +3118,6 @@ static int dlm_add_migration_mle(struct dlm_ctxt *dlm, | |||
| 3120 | 3118 | ||
| 3121 | *oldmle = NULL; | 3119 | *oldmle = NULL; |
| 3122 | 3120 | ||
| 3123 | mlog_entry_void(); | ||
| 3124 | |||
| 3125 | assert_spin_locked(&dlm->spinlock); | 3121 | assert_spin_locked(&dlm->spinlock); |
| 3126 | assert_spin_locked(&dlm->master_lock); | 3122 | assert_spin_locked(&dlm->master_lock); |
| 3127 | 3123 | ||
| @@ -3261,7 +3257,7 @@ void dlm_clean_master_list(struct dlm_ctxt *dlm, u8 dead_node) | |||
| 3261 | struct hlist_node *list; | 3257 | struct hlist_node *list; |
| 3262 | unsigned int i; | 3258 | unsigned int i; |
| 3263 | 3259 | ||
| 3264 | mlog_entry("dlm=%s, dead node=%u\n", dlm->name, dead_node); | 3260 | mlog(0, "dlm=%s, dead node=%u\n", dlm->name, dead_node); |
| 3265 | top: | 3261 | top: |
| 3266 | assert_spin_locked(&dlm->spinlock); | 3262 | assert_spin_locked(&dlm->spinlock); |
| 3267 | 3263 | ||
diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c index aaaffbcbe91..f1beb6fc254 100644 --- a/fs/ocfs2/dlm/dlmrecovery.c +++ b/fs/ocfs2/dlm/dlmrecovery.c | |||
| @@ -727,7 +727,6 @@ static int dlm_remaster_locks(struct dlm_ctxt *dlm, u8 dead_node) | |||
| 727 | if (destroy) | 727 | if (destroy) |
| 728 | dlm_destroy_recovery_area(dlm, dead_node); | 728 | dlm_destroy_recovery_area(dlm, dead_node); |
| 729 | 729 | ||
| 730 | mlog_exit(status); | ||
| 731 | return status; | 730 | return status; |
| 732 | } | 731 | } |
| 733 | 732 | ||
| @@ -1496,9 +1495,9 @@ leave: | |||
| 1496 | kfree(buf); | 1495 | kfree(buf); |
| 1497 | if (item) | 1496 | if (item) |
| 1498 | kfree(item); | 1497 | kfree(item); |
| 1498 | mlog_errno(ret); | ||
| 1499 | } | 1499 | } |
| 1500 | 1500 | ||
| 1501 | mlog_exit(ret); | ||
| 1502 | return ret; | 1501 | return ret; |
| 1503 | } | 1502 | } |
| 1504 | 1503 | ||
| @@ -1567,7 +1566,6 @@ leave: | |||
| 1567 | dlm_lockres_put(res); | 1566 | dlm_lockres_put(res); |
| 1568 | } | 1567 | } |
| 1569 | kfree(data); | 1568 | kfree(data); |
| 1570 | mlog_exit(ret); | ||
| 1571 | } | 1569 | } |
| 1572 | 1570 | ||
| 1573 | 1571 | ||
| @@ -1986,7 +1984,6 @@ leave: | |||
| 1986 | dlm_lock_put(newlock); | 1984 | dlm_lock_put(newlock); |
| 1987 | } | 1985 | } |
| 1988 | 1986 | ||
| 1989 | mlog_exit(ret); | ||
| 1990 | return ret; | 1987 | return ret; |
| 1991 | } | 1988 | } |
| 1992 | 1989 | ||
| @@ -2083,8 +2080,6 @@ static void dlm_finish_local_lockres_recovery(struct dlm_ctxt *dlm, | |||
| 2083 | struct hlist_head *bucket; | 2080 | struct hlist_head *bucket; |
| 2084 | struct dlm_lock_resource *res, *next; | 2081 | struct dlm_lock_resource *res, *next; |
| 2085 | 2082 | ||
| 2086 | mlog_entry_void(); | ||
| 2087 | |||
| 2088 | assert_spin_locked(&dlm->spinlock); | 2083 | assert_spin_locked(&dlm->spinlock); |
| 2089 | 2084 | ||
| 2090 | list_for_each_entry_safe(res, next, &dlm->reco.resources, recovering) { | 2085 | list_for_each_entry_safe(res, next, &dlm->reco.resources, recovering) { |
| @@ -2607,8 +2602,6 @@ static int dlm_send_begin_reco_message(struct dlm_ctxt *dlm, u8 dead_node) | |||
| 2607 | int nodenum; | 2602 | int nodenum; |
| 2608 | int status; | 2603 | int status; |
| 2609 | 2604 | ||
| 2610 | mlog_entry("%u\n", dead_node); | ||
| 2611 | |||
| 2612 | mlog(0, "%s: dead node is %u\n", dlm->name, dead_node); | 2605 | mlog(0, "%s: dead node is %u\n", dlm->name, dead_node); |
| 2613 | 2606 | ||
| 2614 | spin_lock(&dlm->spinlock); | 2607 | spin_lock(&dlm->spinlock); |
diff --git a/fs/ocfs2/dlm/dlmunlock.c b/fs/ocfs2/dlm/dlmunlock.c index 817287c6a6d..850aa7e8753 100644 --- a/fs/ocfs2/dlm/dlmunlock.c +++ b/fs/ocfs2/dlm/dlmunlock.c | |||
| @@ -317,7 +317,7 @@ static enum dlm_status dlm_send_remote_unlock_request(struct dlm_ctxt *dlm, | |||
| 317 | struct kvec vec[2]; | 317 | struct kvec vec[2]; |
| 318 | size_t veclen = 1; | 318 | size_t veclen = 1; |
| 319 | 319 | ||
| 320 | mlog_entry("%.*s\n", res->lockname.len, res->lockname.name); | 320 | mlog(0, "%.*s\n", res->lockname.len, res->lockname.name); |
| 321 | 321 | ||
| 322 | if (owner == dlm->node_num) { | 322 | if (owner == dlm->node_num) { |
| 323 | /* ended up trying to contact ourself. this means | 323 | /* ended up trying to contact ourself. this means |
| @@ -588,8 +588,6 @@ enum dlm_status dlmunlock(struct dlm_ctxt *dlm, struct dlm_lockstatus *lksb, | |||
| 588 | struct dlm_lock *lock = NULL; | 588 | struct dlm_lock *lock = NULL; |
| 589 | int call_ast, is_master; | 589 | int call_ast, is_master; |
| 590 | 590 | ||
| 591 | mlog_entry_void(); | ||
| 592 | |||
| 593 | if (!lksb) { | 591 | if (!lksb) { |
| 594 | dlm_error(DLM_BADARGS); | 592 | dlm_error(DLM_BADARGS); |
| 595 | return DLM_BADARGS; | 593 | return DLM_BADARGS; |
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c index e8d94d722ec..7642d7ca73e 100644 --- a/fs/ocfs2/dlmglue.c +++ b/fs/ocfs2/dlmglue.c | |||
| @@ -64,7 +64,7 @@ struct ocfs2_mask_waiter { | |||
| 64 | unsigned long mw_mask; | 64 | unsigned long mw_mask; |
| 65 | unsigned long mw_goal; | 65 | unsigned long mw_goal; |
| 66 | #ifdef CONFIG_OCFS2_FS_STATS | 66 | #ifdef CONFIG_OCFS2_FS_STATS |
| 67 | unsigned long long mw_lock_start; | 67 | ktime_t mw_lock_start; |
| 68 | #endif | 68 | #endif |
| 69 | }; | 69 | }; |
| 70 | 70 | ||
| @@ -397,8 +397,6 @@ static void ocfs2_build_lock_name(enum ocfs2_lock_type type, | |||
| 397 | { | 397 | { |
| 398 | int len; | 398 | int len; |
| 399 | 399 | ||
| 400 | mlog_entry_void(); | ||
| 401 | |||
| 402 | BUG_ON(type >= OCFS2_NUM_LOCK_TYPES); | 400 | BUG_ON(type >= OCFS2_NUM_LOCK_TYPES); |
| 403 | 401 | ||
| 404 | len = snprintf(name, OCFS2_LOCK_ID_MAX_LEN, "%c%s%016llx%08x", | 402 | len = snprintf(name, OCFS2_LOCK_ID_MAX_LEN, "%c%s%016llx%08x", |
| @@ -408,8 +406,6 @@ static void ocfs2_build_lock_name(enum ocfs2_lock_type type, | |||
| 408 | BUG_ON(len != (OCFS2_LOCK_ID_MAX_LEN - 1)); | 406 | BUG_ON(len != (OCFS2_LOCK_ID_MAX_LEN - 1)); |
| 409 | 407 | ||
| 410 | mlog(0, "built lock resource with name: %s\n", name); | 408 | mlog(0, "built lock resource with name: %s\n", name); |
| 411 | |||
| 412 | mlog_exit_void(); | ||
| 413 | } | 409 | } |
| 414 | 410 | ||
| 415 | static DEFINE_SPINLOCK(ocfs2_dlm_tracking_lock); | 411 | static DEFINE_SPINLOCK(ocfs2_dlm_tracking_lock); |
| @@ -435,44 +431,41 @@ static void ocfs2_remove_lockres_tracking(struct ocfs2_lock_res *res) | |||
| 435 | #ifdef CONFIG_OCFS2_FS_STATS | 431 | #ifdef CONFIG_OCFS2_FS_STATS |
| 436 | static void ocfs2_init_lock_stats(struct ocfs2_lock_res *res) | 432 | static void ocfs2_init_lock_stats(struct ocfs2_lock_res *res) |
| 437 | { | 433 | { |
| 438 | res->l_lock_num_prmode = 0; | ||
| 439 | res->l_lock_num_prmode_failed = 0; | ||
| 440 | res->l_lock_total_prmode = 0; | ||
| 441 | res->l_lock_max_prmode = 0; | ||
| 442 | res->l_lock_num_exmode = 0; | ||
| 443 | res->l_lock_num_exmode_failed = 0; | ||
| 444 | res->l_lock_total_exmode = 0; | ||
| 445 | res->l_lock_max_exmode = 0; | ||
| 446 | res->l_lock_refresh = 0; | 434 | res->l_lock_refresh = 0; |
| 435 | memset(&res->l_lock_prmode, 0, sizeof(struct ocfs2_lock_stats)); | ||
| 436 | memset(&res->l_lock_exmode, 0, sizeof(struct ocfs2_lock_stats)); | ||
| 447 | } | 437 | } |
| 448 | 438 | ||
| 449 | static void ocfs2_update_lock_stats(struct ocfs2_lock_res *res, int level, | 439 | static void ocfs2_update_lock_stats(struct ocfs2_lock_res *res, int level, |
| 450 | struct ocfs2_mask_waiter *mw, int ret) | 440 | struct ocfs2_mask_waiter *mw, int ret) |
| 451 | { | 441 | { |
| 452 | unsigned long long *num, *sum; | 442 | u32 usec; |
| 453 | unsigned int *max, *failed; | 443 | ktime_t kt; |
| 454 | struct timespec ts = current_kernel_time(); | 444 | struct ocfs2_lock_stats *stats; |
| 455 | unsigned long long time = timespec_to_ns(&ts) - mw->mw_lock_start; | 445 | |
| 456 | 446 | if (level == LKM_PRMODE) | |
| 457 | if (level == LKM_PRMODE) { | 447 | stats = &res->l_lock_prmode; |
| 458 | num = &res->l_lock_num_prmode; | 448 | else if (level == LKM_EXMODE) |
| 459 | sum = &res->l_lock_total_prmode; | 449 | stats = &res->l_lock_exmode; |
| 460 | max = &res->l_lock_max_prmode; | 450 | else |
| 461 | failed = &res->l_lock_num_prmode_failed; | ||
| 462 | } else if (level == LKM_EXMODE) { | ||
| 463 | num = &res->l_lock_num_exmode; | ||
| 464 | sum = &res->l_lock_total_exmode; | ||
| 465 | max = &res->l_lock_max_exmode; | ||
| 466 | failed = &res->l_lock_num_exmode_failed; | ||
| 467 | } else | ||
| 468 | return; | 451 | return; |
| 469 | 452 | ||
| 470 | (*num)++; | 453 | kt = ktime_sub(ktime_get(), mw->mw_lock_start); |
| 471 | (*sum) += time; | 454 | usec = ktime_to_us(kt); |
| 472 | if (time > *max) | 455 | |
| 473 | *max = time; | 456 | stats->ls_gets++; |
| 457 | stats->ls_total += ktime_to_ns(kt); | ||
| 458 | /* overflow */ | ||
| 459 | if (unlikely(stats->ls_gets) == 0) { | ||
| 460 | stats->ls_gets++; | ||
| 461 | stats->ls_total = ktime_to_ns(kt); | ||
| 462 | } | ||
| 463 | |||
| 464 | if (stats->ls_max < usec) | ||
| 465 | stats->ls_max = usec; | ||
| 466 | |||
| 474 | if (ret) | 467 | if (ret) |
| 475 | (*failed)++; | 468 | stats->ls_fail++; |
| 476 | } | 469 | } |
| 477 | 470 | ||
| 478 | static inline void ocfs2_track_lock_refresh(struct ocfs2_lock_res *lockres) | 471 | static inline void ocfs2_track_lock_refresh(struct ocfs2_lock_res *lockres) |
| @@ -482,8 +475,7 @@ static inline void ocfs2_track_lock_refresh(struct ocfs2_lock_res *lockres) | |||
| 482 | 475 | ||
| 483 | static inline void ocfs2_init_start_time(struct ocfs2_mask_waiter *mw) | 476 | static inline void ocfs2_init_start_time(struct ocfs2_mask_waiter *mw) |
| 484 | { | 477 | { |
| 485 | struct timespec ts = current_kernel_time(); | 478 | mw->mw_lock_start = ktime_get(); |
| 486 | mw->mw_lock_start = timespec_to_ns(&ts); | ||
| 487 | } | 479 | } |
| 488 | #else | 480 | #else |
| 489 | static inline void ocfs2_init_lock_stats(struct ocfs2_lock_res *res) | 481 | static inline void ocfs2_init_lock_stats(struct ocfs2_lock_res *res) |
| @@ -729,8 +721,6 @@ void ocfs2_refcount_lock_res_init(struct ocfs2_lock_res *lockres, | |||
| 729 | 721 | ||
| 730 | void ocfs2_lock_res_free(struct ocfs2_lock_res *res) | 722 | void ocfs2_lock_res_free(struct ocfs2_lock_res *res) |
| 731 | { | 723 | { |
| 732 | mlog_entry_void(); | ||
| 733 | |||
| 734 | if (!(res->l_flags & OCFS2_LOCK_INITIALIZED)) | 724 | if (!(res->l_flags & OCFS2_LOCK_INITIALIZED)) |
| 735 | return; | 725 | return; |
| 736 | 726 | ||
| @@ -756,14 +746,11 @@ void ocfs2_lock_res_free(struct ocfs2_lock_res *res) | |||
| 756 | memset(&res->l_lksb, 0, sizeof(res->l_lksb)); | 746 | memset(&res->l_lksb, 0, sizeof(res->l_lksb)); |
| 757 | 747 | ||
| 758 | res->l_flags = 0UL; | 748 | res->l_flags = 0UL; |
| 759 | mlog_exit_void(); | ||
| 760 | } | 749 | } |
| 761 | 750 | ||
| 762 | static inline void ocfs2_inc_holders(struct ocfs2_lock_res *lockres, | 751 | static inline void ocfs2_inc_holders(struct ocfs2_lock_res *lockres, |
| 763 | int level) | 752 | int level) |
| 764 | { | 753 | { |
| 765 | mlog_entry_void(); | ||
| 766 | |||
| 767 | BUG_ON(!lockres); | 754 | BUG_ON(!lockres); |
| 768 | 755 | ||
| 769 | switch(level) { | 756 | switch(level) { |
| @@ -776,15 +763,11 @@ static inline void ocfs2_inc_holders(struct ocfs2_lock_res *lockres, | |||
| 776 | default: | 763 | default: |
| 777 | BUG(); | 764 | BUG(); |
| 778 | } | 765 | } |
| 779 | |||
| 780 | mlog_exit_void(); | ||
| 781 | } | 766 | } |
| 782 | 767 | ||
| 783 | static inline void ocfs2_dec_holders(struct ocfs2_lock_res *lockres, | 768 | static inline void ocfs2_dec_holders(struct ocfs2_lock_res *lockres, |
| 784 | int level) | 769 | int level) |
| 785 | { | 770 | { |
| 786 | mlog_entry_void(); | ||
| 787 | |||
| 788 | BUG_ON(!lockres); | 771 | BUG_ON(!lockres); |
| 789 | 772 | ||
| 790 | switch(level) { | 773 | switch(level) { |
| @@ -799,7 +782,6 @@ static inline void ocfs2_dec_holders(struct ocfs2_lock_res *lockres, | |||
| 799 | default: | 782 | default: |
| 800 | BUG(); | 783 | BUG(); |
| 801 | } | 784 | } |
| 802 | mlog_exit_void(); | ||
| 803 | } | 785 | } |
| 804 | 786 | ||
| 805 | /* WARNING: This function lives in a world where the only three lock | 787 | /* WARNING: This function lives in a world where the only three lock |
| @@ -846,8 +828,6 @@ static void lockres_clear_flags(struct ocfs2_lock_res *lockres, | |||
| 846 | 828 | ||
| 847 | static inline void ocfs2_generic_handle_downconvert_action(struct ocfs2_lock_res *lockres) | 829 | static inline void ocfs2_generic_handle_downconvert_action(struct ocfs2_lock_res *lockres) |
| 848 | { | 830 | { |
| 849 | mlog_entry_void(); | ||
| 850 | |||
| 851 | BUG_ON(!(lockres->l_flags & OCFS2_LOCK_BUSY)); | 831 | BUG_ON(!(lockres->l_flags & OCFS2_LOCK_BUSY)); |
| 852 | BUG_ON(!(lockres->l_flags & OCFS2_LOCK_ATTACHED)); | 832 | BUG_ON(!(lockres->l_flags & OCFS2_LOCK_ATTACHED)); |
| 853 | BUG_ON(!(lockres->l_flags & OCFS2_LOCK_BLOCKED)); | 833 | BUG_ON(!(lockres->l_flags & OCFS2_LOCK_BLOCKED)); |
| @@ -860,14 +840,10 @@ static inline void ocfs2_generic_handle_downconvert_action(struct ocfs2_lock_res | |||
| 860 | lockres_clear_flags(lockres, OCFS2_LOCK_BLOCKED); | 840 | lockres_clear_flags(lockres, OCFS2_LOCK_BLOCKED); |
| 861 | } | 841 | } |
| 862 | lockres_clear_flags(lockres, OCFS2_LOCK_BUSY); | 842 | lockres_clear_flags(lockres, OCFS2_LOCK_BUSY); |
| 863 | |||
| 864 | mlog_exit_void(); | ||
| 865 | } | 843 | } |
| 866 | 844 | ||
| 867 | static inline void ocfs2_generic_handle_convert_action(struct ocfs2_lock_res *lockres) | 845 | static inline void ocfs2_generic_handle_convert_action(struct ocfs2_lock_res *lockres) |
| 868 | { | 846 | { |
| 869 | mlog_entry_void(); | ||
| 870 | |||
| 871 | BUG_ON(!(lockres->l_flags & OCFS2_LOCK_BUSY)); | 847 | BUG_ON(!(lockres->l_flags & OCFS2_LOCK_BUSY)); |
| 872 | BUG_ON(!(lockres->l_flags & OCFS2_LOCK_ATTACHED)); | 848 | BUG_ON(!(lockres->l_flags & OCFS2_LOCK_ATTACHED)); |
| 873 | 849 | ||
| @@ -889,14 +865,10 @@ static inline void ocfs2_generic_handle_convert_action(struct ocfs2_lock_res *lo | |||
| 889 | lockres_or_flags(lockres, OCFS2_LOCK_UPCONVERT_FINISHING); | 865 | lockres_or_flags(lockres, OCFS2_LOCK_UPCONVERT_FINISHING); |
| 890 | 866 | ||
| 891 | lockres_clear_flags(lockres, OCFS2_LOCK_BUSY); | 867 | lockres_clear_flags(lockres, OCFS2_LOCK_BUSY); |
| 892 | |||
| 893 | mlog_exit_void(); | ||
| 894 | } | 868 | } |
| 895 | 869 | ||
| 896 | static inline void ocfs2_generic_handle_attach_action(struct ocfs2_lock_res *lockres) | 870 | static inline void ocfs2_generic_handle_attach_action(struct ocfs2_lock_res *lockres) |
| 897 | { | 871 | { |
| 898 | mlog_entry_void(); | ||
| 899 | |||
| 900 | BUG_ON((!(lockres->l_flags & OCFS2_LOCK_BUSY))); | 872 | BUG_ON((!(lockres->l_flags & OCFS2_LOCK_BUSY))); |
| 901 | BUG_ON(lockres->l_flags & OCFS2_LOCK_ATTACHED); | 873 | BUG_ON(lockres->l_flags & OCFS2_LOCK_ATTACHED); |
| 902 | 874 | ||
| @@ -908,15 +880,12 @@ static inline void ocfs2_generic_handle_attach_action(struct ocfs2_lock_res *loc | |||
| 908 | lockres->l_level = lockres->l_requested; | 880 | lockres->l_level = lockres->l_requested; |
| 909 | lockres_or_flags(lockres, OCFS2_LOCK_ATTACHED); | 881 | lockres_or_flags(lockres, OCFS2_LOCK_ATTACHED); |
| 910 | lockres_clear_flags(lockres, OCFS2_LOCK_BUSY); | 882 | lockres_clear_flags(lockres, OCFS2_LOCK_BUSY); |
| 911 | |||
| 912 | mlog_exit_void(); | ||
| 913 | } | 883 | } |
| 914 | 884 | ||
| 915 | static int ocfs2_generic_handle_bast(struct ocfs2_lock_res *lockres, | 885 | static int ocfs2_generic_handle_bast(struct ocfs2_lock_res *lockres, |
| 916 | int level) | 886 | int level) |
| 917 | { | 887 | { |
| 918 | int needs_downconvert = 0; | 888 | int needs_downconvert = 0; |
| 919 | mlog_entry_void(); | ||
| 920 | 889 | ||
| 921 | assert_spin_locked(&lockres->l_lock); | 890 | assert_spin_locked(&lockres->l_lock); |
| 922 | 891 | ||
| @@ -938,8 +907,7 @@ static int ocfs2_generic_handle_bast(struct ocfs2_lock_res *lockres, | |||
| 938 | 907 | ||
| 939 | if (needs_downconvert) | 908 | if (needs_downconvert) |
| 940 | lockres_or_flags(lockres, OCFS2_LOCK_BLOCKED); | 909 | lockres_or_flags(lockres, OCFS2_LOCK_BLOCKED); |
| 941 | 910 | mlog(0, "needs_downconvert = %d\n", needs_downconvert); | |
| 942 | mlog_exit(needs_downconvert); | ||
| 943 | return needs_downconvert; | 911 | return needs_downconvert; |
| 944 | } | 912 | } |
| 945 | 913 | ||
| @@ -1151,8 +1119,6 @@ static void ocfs2_unlock_ast(struct ocfs2_dlm_lksb *lksb, int error) | |||
| 1151 | struct ocfs2_lock_res *lockres = ocfs2_lksb_to_lock_res(lksb); | 1119 | struct ocfs2_lock_res *lockres = ocfs2_lksb_to_lock_res(lksb); |
| 1152 | unsigned long flags; | 1120 | unsigned long flags; |
| 1153 | 1121 | ||
| 1154 | mlog_entry_void(); | ||
| 1155 | |||
| 1156 | mlog(ML_BASTS, "UNLOCK AST fired for lockres %s, action = %d\n", | 1122 | mlog(ML_BASTS, "UNLOCK AST fired for lockres %s, action = %d\n", |
| 1157 | lockres->l_name, lockres->l_unlock_action); | 1123 | lockres->l_name, lockres->l_unlock_action); |
| 1158 | 1124 | ||
| @@ -1162,7 +1128,6 @@ static void ocfs2_unlock_ast(struct ocfs2_dlm_lksb *lksb, int error) | |||
| 1162 | "unlock_action %d\n", error, lockres->l_name, | 1128 | "unlock_action %d\n", error, lockres->l_name, |
| 1163 | lockres->l_unlock_action); | 1129 | lockres->l_unlock_action); |
| 1164 | spin_unlock_irqrestore(&lockres->l_lock, flags); | 1130 | spin_unlock_irqrestore(&lockres->l_lock, flags); |
| 1165 | mlog_exit_void(); | ||
| 1166 | return; | 1131 | return; |
| 1167 | } | 1132 | } |
| 1168 | 1133 | ||
| @@ -1186,8 +1151,6 @@ static void ocfs2_unlock_ast(struct ocfs2_dlm_lksb *lksb, int error) | |||
| 1186 | lockres->l_unlock_action = OCFS2_UNLOCK_INVALID; | 1151 | lockres->l_unlock_action = OCFS2_UNLOCK_INVALID; |
| 1187 | wake_up(&lockres->l_event); | 1152 | wake_up(&lockres->l_event); |
| 1188 | spin_unlock_irqrestore(&lockres->l_lock, flags); | 1153 | spin_unlock_irqrestore(&lockres->l_lock, flags); |
| 1189 | |||
| 1190 | mlog_exit_void(); | ||
| 1191 | } | 1154 | } |
| 1192 | 1155 | ||
| 1193 | /* | 1156 | /* |
| @@ -1233,7 +1196,6 @@ static inline void ocfs2_recover_from_dlm_error(struct ocfs2_lock_res *lockres, | |||
| 1233 | { | 1196 | { |
| 1234 | unsigned long flags; | 1197 | unsigned long flags; |
| 1235 | 1198 | ||
| 1236 | mlog_entry_void(); | ||
| 1237 | spin_lock_irqsave(&lockres->l_lock, flags); | 1199 | spin_lock_irqsave(&lockres->l_lock, flags); |
| 1238 | lockres_clear_flags(lockres, OCFS2_LOCK_BUSY); | 1200 | lockres_clear_flags(lockres, OCFS2_LOCK_BUSY); |
| 1239 | lockres_clear_flags(lockres, OCFS2_LOCK_UPCONVERT_FINISHING); | 1201 | lockres_clear_flags(lockres, OCFS2_LOCK_UPCONVERT_FINISHING); |
| @@ -1244,7 +1206,6 @@ static inline void ocfs2_recover_from_dlm_error(struct ocfs2_lock_res *lockres, | |||
| 1244 | spin_unlock_irqrestore(&lockres->l_lock, flags); | 1206 | spin_unlock_irqrestore(&lockres->l_lock, flags); |
| 1245 | 1207 | ||
| 1246 | wake_up(&lockres->l_event); | 1208 | wake_up(&lockres->l_event); |
| 1247 | mlog_exit_void(); | ||
| 1248 | } | 1209 | } |
| 1249 | 1210 | ||
| 1250 | /* Note: If we detect another process working on the lock (i.e., | 1211 | /* Note: If we detect another process working on the lock (i.e., |
| @@ -1260,8 +1221,6 @@ static int ocfs2_lock_create(struct ocfs2_super *osb, | |||
| 1260 | unsigned long flags; | 1221 | unsigned long flags; |
| 1261 | unsigned int gen; | 1222 | unsigned int gen; |
| 1262 | 1223 | ||
| 1263 | mlog_entry_void(); | ||
| 1264 | |||
| 1265 | mlog(0, "lock %s, level = %d, flags = %u\n", lockres->l_name, level, | 1224 | mlog(0, "lock %s, level = %d, flags = %u\n", lockres->l_name, level, |
| 1266 | dlm_flags); | 1225 | dlm_flags); |
| 1267 | 1226 | ||
| @@ -1293,7 +1252,6 @@ static int ocfs2_lock_create(struct ocfs2_super *osb, | |||
| 1293 | mlog(0, "lock %s, return from ocfs2_dlm_lock\n", lockres->l_name); | 1252 | mlog(0, "lock %s, return from ocfs2_dlm_lock\n", lockres->l_name); |
| 1294 | 1253 | ||
| 1295 | bail: | 1254 | bail: |
| 1296 | mlog_exit(ret); | ||
| 1297 | return ret; | 1255 | return ret; |
| 1298 | } | 1256 | } |
| 1299 | 1257 | ||
| @@ -1416,8 +1374,6 @@ static int __ocfs2_cluster_lock(struct ocfs2_super *osb, | |||
| 1416 | unsigned int gen; | 1374 | unsigned int gen; |
| 1417 | int noqueue_attempted = 0; | 1375 | int noqueue_attempted = 0; |
| 1418 | 1376 | ||
| 1419 | mlog_entry_void(); | ||
| 1420 | |||
| 1421 | ocfs2_init_mask_waiter(&mw); | 1377 | ocfs2_init_mask_waiter(&mw); |
| 1422 | 1378 | ||
| 1423 | if (lockres->l_ops->flags & LOCK_TYPE_USES_LVB) | 1379 | if (lockres->l_ops->flags & LOCK_TYPE_USES_LVB) |
| @@ -1583,7 +1539,6 @@ out: | |||
| 1583 | caller_ip); | 1539 | caller_ip); |
| 1584 | } | 1540 | } |
| 1585 | #endif | 1541 | #endif |
| 1586 | mlog_exit(ret); | ||
| 1587 | return ret; | 1542 | return ret; |
| 1588 | } | 1543 | } |
| 1589 | 1544 | ||
| @@ -1605,7 +1560,6 @@ static void __ocfs2_cluster_unlock(struct ocfs2_super *osb, | |||
| 1605 | { | 1560 | { |
| 1606 | unsigned long flags; | 1561 | unsigned long flags; |
| 1607 | 1562 | ||
| 1608 | mlog_entry_void(); | ||
| 1609 | spin_lock_irqsave(&lockres->l_lock, flags); | 1563 | spin_lock_irqsave(&lockres->l_lock, flags); |
| 1610 | ocfs2_dec_holders(lockres, level); | 1564 | ocfs2_dec_holders(lockres, level); |
| 1611 | ocfs2_downconvert_on_unlock(osb, lockres); | 1565 | ocfs2_downconvert_on_unlock(osb, lockres); |
| @@ -1614,7 +1568,6 @@ static void __ocfs2_cluster_unlock(struct ocfs2_super *osb, | |||
| 1614 | if (lockres->l_lockdep_map.key != NULL) | 1568 | if (lockres->l_lockdep_map.key != NULL) |
| 1615 | rwsem_release(&lockres->l_lockdep_map, 1, caller_ip); | 1569 | rwsem_release(&lockres->l_lockdep_map, 1, caller_ip); |
| 1616 | #endif | 1570 | #endif |
| 1617 | mlog_exit_void(); | ||
| 1618 | } | 1571 | } |
| 1619 | 1572 | ||
| 1620 | static int ocfs2_create_new_lock(struct ocfs2_super *osb, | 1573 | static int ocfs2_create_new_lock(struct ocfs2_super *osb, |
| @@ -1648,8 +1601,6 @@ int ocfs2_create_new_inode_locks(struct inode *inode) | |||
| 1648 | BUG_ON(!inode); | 1601 | BUG_ON(!inode); |
| 1649 | BUG_ON(!ocfs2_inode_is_new(inode)); | 1602 | BUG_ON(!ocfs2_inode_is_new(inode)); |
| 1650 | 1603 | ||
| 1651 | mlog_entry_void(); | ||
| 1652 | |||
| 1653 | mlog(0, "Inode %llu\n", (unsigned long long)OCFS2_I(inode)->ip_blkno); | 1604 | mlog(0, "Inode %llu\n", (unsigned long long)OCFS2_I(inode)->ip_blkno); |
| 1654 | 1605 | ||
| 1655 | /* NOTE: That we don't increment any of the holder counts, nor | 1606 | /* NOTE: That we don't increment any of the holder counts, nor |
| @@ -1683,7 +1634,6 @@ int ocfs2_create_new_inode_locks(struct inode *inode) | |||
| 1683 | } | 1634 | } |
| 1684 | 1635 | ||
| 1685 | bail: | 1636 | bail: |
| 1686 | mlog_exit(ret); | ||
| 1687 | return ret; | 1637 | return ret; |
| 1688 | } | 1638 | } |
| 1689 | 1639 | ||
| @@ -1695,16 +1645,12 @@ int ocfs2_rw_lock(struct inode *inode, int write) | |||
| 1695 | 1645 | ||
| 1696 | BUG_ON(!inode); | 1646 | BUG_ON(!inode); |
| 1697 | 1647 | ||
| 1698 | mlog_entry_void(); | ||
| 1699 | |||
| 1700 | mlog(0, "inode %llu take %s RW lock\n", | 1648 | mlog(0, "inode %llu take %s RW lock\n", |
| 1701 | (unsigned long long)OCFS2_I(inode)->ip_blkno, | 1649 | (unsigned long long)OCFS2_I(inode)->ip_blkno, |
| 1702 | write ? "EXMODE" : "PRMODE"); | 1650 | write ? "EXMODE" : "PRMODE"); |
| 1703 | 1651 | ||
| 1704 | if (ocfs2_mount_local(osb)) { | 1652 | if (ocfs2_mount_local(osb)) |
| 1705 | mlog_exit(0); | ||
| 1706 | return 0; | 1653 | return 0; |
| 1707 | } | ||
| 1708 | 1654 | ||
| 1709 | lockres = &OCFS2_I(inode)->ip_rw_lockres; | 1655 | lockres = &OCFS2_I(inode)->ip_rw_lockres; |
| 1710 | 1656 | ||
| @@ -1715,7 +1661,6 @@ int ocfs2_rw_lock(struct inode *inode, int write) | |||
| 1715 | if (status < 0) | 1661 | if (status < 0) |
| 1716 | mlog_errno(status); | 1662 | mlog_errno(status); |
| 1717 | 1663 | ||
| 1718 | mlog_exit(status); | ||
| 1719 | return status; | 1664 | return status; |
| 1720 | } | 1665 | } |
| 1721 | 1666 | ||
| @@ -1725,16 +1670,12 @@ void ocfs2_rw_unlock(struct inode *inode, int write) | |||
| 1725 | struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_rw_lockres; | 1670 | struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_rw_lockres; |
| 1726 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 1671 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
| 1727 | 1672 | ||
| 1728 | mlog_entry_void(); | ||
| 1729 | |||
| 1730 | mlog(0, "inode %llu drop %s RW lock\n", | 1673 | mlog(0, "inode %llu drop %s RW lock\n", |
| 1731 | (unsigned long long)OCFS2_I(inode)->ip_blkno, | 1674 | (unsigned long long)OCFS2_I(inode)->ip_blkno, |
| 1732 | write ? "EXMODE" : "PRMODE"); | 1675 | write ? "EXMODE" : "PRMODE"); |
| 1733 | 1676 | ||
| 1734 | if (!ocfs2_mount_local(osb)) | 1677 | if (!ocfs2_mount_local(osb)) |
| 1735 | ocfs2_cluster_unlock(OCFS2_SB(inode->i_sb), lockres, level); | 1678 | ocfs2_cluster_unlock(OCFS2_SB(inode->i_sb), lockres, level); |
| 1736 | |||
| 1737 | mlog_exit_void(); | ||
| 1738 | } | 1679 | } |
| 1739 | 1680 | ||
| 1740 | /* | 1681 | /* |
| @@ -1748,8 +1689,6 @@ int ocfs2_open_lock(struct inode *inode) | |||
| 1748 | 1689 | ||
| 1749 | BUG_ON(!inode); | 1690 | BUG_ON(!inode); |
| 1750 | 1691 | ||
| 1751 | mlog_entry_void(); | ||
| 1752 | |||
| 1753 | mlog(0, "inode %llu take PRMODE open lock\n", | 1692 | mlog(0, "inode %llu take PRMODE open lock\n", |
| 1754 | (unsigned long long)OCFS2_I(inode)->ip_blkno); | 1693 | (unsigned long long)OCFS2_I(inode)->ip_blkno); |
| 1755 | 1694 | ||
| @@ -1764,7 +1703,6 @@ int ocfs2_open_lock(struct inode *inode) | |||
| 1764 | mlog_errno(status); | 1703 | mlog_errno(status); |
| 1765 | 1704 | ||
| 1766 | out: | 1705 | out: |
| 1767 | mlog_exit(status); | ||
| 1768 | return status; | 1706 | return status; |
| 1769 | } | 1707 | } |
| 1770 | 1708 | ||
| @@ -1776,8 +1714,6 @@ int ocfs2_try_open_lock(struct inode *inode, int write) | |||
| 1776 | 1714 | ||
| 1777 | BUG_ON(!inode); | 1715 | BUG_ON(!inode); |
| 1778 | 1716 | ||
| 1779 | mlog_entry_void(); | ||
| 1780 | |||
| 1781 | mlog(0, "inode %llu try to take %s open lock\n", | 1717 | mlog(0, "inode %llu try to take %s open lock\n", |
| 1782 | (unsigned long long)OCFS2_I(inode)->ip_blkno, | 1718 | (unsigned long long)OCFS2_I(inode)->ip_blkno, |
| 1783 | write ? "EXMODE" : "PRMODE"); | 1719 | write ? "EXMODE" : "PRMODE"); |
| @@ -1799,7 +1735,6 @@ int ocfs2_try_open_lock(struct inode *inode, int write) | |||
| 1799 | level, DLM_LKF_NOQUEUE, 0); | 1735 | level, DLM_LKF_NOQUEUE, 0); |
| 1800 | 1736 | ||
| 1801 | out: | 1737 | out: |
| 1802 | mlog_exit(status); | ||
| 1803 | return status; | 1738 | return status; |
| 1804 | } | 1739 | } |
| 1805 | 1740 | ||
| @@ -1811,8 +1746,6 @@ void ocfs2_open_unlock(struct inode *inode) | |||
| 1811 | struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_open_lockres; | 1746 | struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_open_lockres; |
| 1812 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 1747 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
| 1813 | 1748 | ||
| 1814 | mlog_entry_void(); | ||
| 1815 | |||
| 1816 | mlog(0, "inode %llu drop open lock\n", | 1749 | mlog(0, "inode %llu drop open lock\n", |
| 1817 | (unsigned long long)OCFS2_I(inode)->ip_blkno); | 1750 | (unsigned long long)OCFS2_I(inode)->ip_blkno); |
| 1818 | 1751 | ||
| @@ -1827,7 +1760,7 @@ void ocfs2_open_unlock(struct inode *inode) | |||
| 1827 | DLM_LOCK_EX); | 1760 | DLM_LOCK_EX); |
| 1828 | 1761 | ||
| 1829 | out: | 1762 | out: |
| 1830 | mlog_exit_void(); | 1763 | return; |
| 1831 | } | 1764 | } |
| 1832 | 1765 | ||
| 1833 | static int ocfs2_flock_handle_signal(struct ocfs2_lock_res *lockres, | 1766 | static int ocfs2_flock_handle_signal(struct ocfs2_lock_res *lockres, |
| @@ -2043,8 +1976,6 @@ static void ocfs2_downconvert_on_unlock(struct ocfs2_super *osb, | |||
| 2043 | { | 1976 | { |
| 2044 | int kick = 0; | 1977 | int kick = 0; |
| 2045 | 1978 | ||
| 2046 | mlog_entry_void(); | ||
| 2047 | |||
| 2048 | /* If we know that another node is waiting on our lock, kick | 1979 | /* If we know that another node is waiting on our lock, kick |
| 2049 | * the downconvert thread * pre-emptively when we reach a release | 1980 | * the downconvert thread * pre-emptively when we reach a release |
| 2050 | * condition. */ | 1981 | * condition. */ |
| @@ -2065,8 +1996,6 @@ static void ocfs2_downconvert_on_unlock(struct ocfs2_super *osb, | |||
| 2065 | 1996 | ||
| 2066 | if (kick) | 1997 | if (kick) |
| 2067 | ocfs2_wake_downconvert_thread(osb); | 1998 | ocfs2_wake_downconvert_thread(osb); |
| 2068 | |||
| 2069 | mlog_exit_void(); | ||
| 2070 | } | 1999 | } |
| 2071 | 2000 | ||
| 2072 | #define OCFS2_SEC_BITS 34 | 2001 | #define OCFS2_SEC_BITS 34 |
| @@ -2095,8 +2024,6 @@ static void __ocfs2_stuff_meta_lvb(struct inode *inode) | |||
| 2095 | struct ocfs2_lock_res *lockres = &oi->ip_inode_lockres; | 2024 | struct ocfs2_lock_res *lockres = &oi->ip_inode_lockres; |
| 2096 | struct ocfs2_meta_lvb *lvb; | 2025 | struct ocfs2_meta_lvb *lvb; |
| 2097 | 2026 | ||
| 2098 | mlog_entry_void(); | ||
| 2099 | |||
| 2100 | lvb = ocfs2_dlm_lvb(&lockres->l_lksb); | 2027 | lvb = ocfs2_dlm_lvb(&lockres->l_lksb); |
| 2101 | 2028 | ||
| 2102 | /* | 2029 | /* |
| @@ -2128,8 +2055,6 @@ static void __ocfs2_stuff_meta_lvb(struct inode *inode) | |||
| 2128 | 2055 | ||
| 2129 | out: | 2056 | out: |
| 2130 | mlog_meta_lvb(0, lockres); | 2057 | mlog_meta_lvb(0, lockres); |
| 2131 | |||
| 2132 | mlog_exit_void(); | ||
| 2133 | } | 2058 | } |
| 2134 | 2059 | ||
| 2135 | static void ocfs2_unpack_timespec(struct timespec *spec, | 2060 | static void ocfs2_unpack_timespec(struct timespec *spec, |
| @@ -2145,8 +2070,6 @@ static void ocfs2_refresh_inode_from_lvb(struct inode *inode) | |||
| 2145 | struct ocfs2_lock_res *lockres = &oi->ip_inode_lockres; | 2070 | struct ocfs2_lock_res *lockres = &oi->ip_inode_lockres; |
| 2146 | struct ocfs2_meta_lvb *lvb; | 2071 | struct ocfs2_meta_lvb *lvb; |
| 2147 | 2072 | ||
| 2148 | mlog_entry_void(); | ||
| 2149 | |||
| 2150 | mlog_meta_lvb(0, lockres); | 2073 | mlog_meta_lvb(0, lockres); |
| 2151 | 2074 | ||
| 2152 | lvb = ocfs2_dlm_lvb(&lockres->l_lksb); | 2075 | lvb = ocfs2_dlm_lvb(&lockres->l_lksb); |
| @@ -2177,8 +2100,6 @@ static void ocfs2_refresh_inode_from_lvb(struct inode *inode) | |||
| 2177 | ocfs2_unpack_timespec(&inode->i_ctime, | 2100 | ocfs2_unpack_timespec(&inode->i_ctime, |
| 2178 | be64_to_cpu(lvb->lvb_ictime_packed)); | 2101 | be64_to_cpu(lvb->lvb_ictime_packed)); |
| 2179 | spin_unlock(&oi->ip_lock); | 2102 | spin_unlock(&oi->ip_lock); |
| 2180 | |||
| 2181 | mlog_exit_void(); | ||
| 2182 | } | 2103 | } |
| 2183 | 2104 | ||
| 2184 | static inline int ocfs2_meta_lvb_is_trustable(struct inode *inode, | 2105 | static inline int ocfs2_meta_lvb_is_trustable(struct inode *inode, |
| @@ -2205,8 +2126,6 @@ static int ocfs2_should_refresh_lock_res(struct ocfs2_lock_res *lockres) | |||
| 2205 | unsigned long flags; | 2126 | unsigned long flags; |
| 2206 | int status = 0; | 2127 | int status = 0; |
| 2207 | 2128 | ||
| 2208 | mlog_entry_void(); | ||
| 2209 | |||
| 2210 | refresh_check: | 2129 | refresh_check: |
| 2211 | spin_lock_irqsave(&lockres->l_lock, flags); | 2130 | spin_lock_irqsave(&lockres->l_lock, flags); |
| 2212 | if (!(lockres->l_flags & OCFS2_LOCK_NEEDS_REFRESH)) { | 2131 | if (!(lockres->l_flags & OCFS2_LOCK_NEEDS_REFRESH)) { |
| @@ -2227,7 +2146,7 @@ refresh_check: | |||
| 2227 | 2146 | ||
| 2228 | status = 1; | 2147 | status = 1; |
| 2229 | bail: | 2148 | bail: |
| 2230 | mlog_exit(status); | 2149 | mlog(0, "status %d\n", status); |
| 2231 | return status; | 2150 | return status; |
| 2232 | } | 2151 | } |
| 2233 | 2152 | ||
| @@ -2237,7 +2156,6 @@ static inline void ocfs2_complete_lock_res_refresh(struct ocfs2_lock_res *lockre | |||
| 2237 | int status) | 2156 | int status) |
| 2238 | { | 2157 | { |
| 2239 | unsigned long flags; | 2158 | unsigned long flags; |
| 2240 | mlog_entry_void(); | ||
| 2241 | 2159 | ||
| 2242 | spin_lock_irqsave(&lockres->l_lock, flags); | 2160 | spin_lock_irqsave(&lockres->l_lock, flags); |
| 2243 | lockres_clear_flags(lockres, OCFS2_LOCK_REFRESHING); | 2161 | lockres_clear_flags(lockres, OCFS2_LOCK_REFRESHING); |
| @@ -2246,8 +2164,6 @@ static inline void ocfs2_complete_lock_res_refresh(struct ocfs2_lock_res *lockre | |||
| 2246 | spin_unlock_irqrestore(&lockres->l_lock, flags); | 2164 | spin_unlock_irqrestore(&lockres->l_lock, flags); |
| 2247 | 2165 | ||
| 2248 | wake_up(&lockres->l_event); | 2166 | wake_up(&lockres->l_event); |
| 2249 | |||
| 2250 | mlog_exit_void(); | ||
| 2251 | } | 2167 | } |
| 2252 | 2168 | ||
| 2253 | /* may or may not return a bh if it went to disk. */ | 2169 | /* may or may not return a bh if it went to disk. */ |
| @@ -2260,8 +2176,6 @@ static int ocfs2_inode_lock_update(struct inode *inode, | |||
| 2260 | struct ocfs2_dinode *fe; | 2176 | struct ocfs2_dinode *fe; |
| 2261 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 2177 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
| 2262 | 2178 | ||
| 2263 | mlog_entry_void(); | ||
| 2264 | |||
| 2265 | if (ocfs2_mount_local(osb)) | 2179 | if (ocfs2_mount_local(osb)) |
| 2266 | goto bail; | 2180 | goto bail; |
| 2267 | 2181 | ||
| @@ -2330,7 +2244,6 @@ static int ocfs2_inode_lock_update(struct inode *inode, | |||
| 2330 | bail_refresh: | 2244 | bail_refresh: |
| 2331 | ocfs2_complete_lock_res_refresh(lockres, status); | 2245 | ocfs2_complete_lock_res_refresh(lockres, status); |
| 2332 | bail: | 2246 | bail: |
| 2333 | mlog_exit(status); | ||
| 2334 | return status; | 2247 | return status; |
| 2335 | } | 2248 | } |
| 2336 | 2249 | ||
| @@ -2374,8 +2287,6 @@ int ocfs2_inode_lock_full_nested(struct inode *inode, | |||
| 2374 | 2287 | ||
| 2375 | BUG_ON(!inode); | 2288 | BUG_ON(!inode); |
| 2376 | 2289 | ||
| 2377 | mlog_entry_void(); | ||
| 2378 | |||
| 2379 | mlog(0, "inode %llu, take %s META lock\n", | 2290 | mlog(0, "inode %llu, take %s META lock\n", |
| 2380 | (unsigned long long)OCFS2_I(inode)->ip_blkno, | 2291 | (unsigned long long)OCFS2_I(inode)->ip_blkno, |
| 2381 | ex ? "EXMODE" : "PRMODE"); | 2292 | ex ? "EXMODE" : "PRMODE"); |
| @@ -2467,7 +2378,6 @@ bail: | |||
| 2467 | if (local_bh) | 2378 | if (local_bh) |
| 2468 | brelse(local_bh); | 2379 | brelse(local_bh); |
| 2469 | 2380 | ||
| 2470 | mlog_exit(status); | ||
| 2471 | return status; | 2381 | return status; |
| 2472 | } | 2382 | } |
| 2473 | 2383 | ||
| @@ -2517,7 +2427,6 @@ int ocfs2_inode_lock_atime(struct inode *inode, | |||
| 2517 | { | 2427 | { |
| 2518 | int ret; | 2428 | int ret; |
| 2519 | 2429 | ||
| 2520 | mlog_entry_void(); | ||
| 2521 | ret = ocfs2_inode_lock(inode, NULL, 0); | 2430 | ret = ocfs2_inode_lock(inode, NULL, 0); |
| 2522 | if (ret < 0) { | 2431 | if (ret < 0) { |
| 2523 | mlog_errno(ret); | 2432 | mlog_errno(ret); |
| @@ -2545,7 +2454,6 @@ int ocfs2_inode_lock_atime(struct inode *inode, | |||
| 2545 | } else | 2454 | } else |
| 2546 | *level = 0; | 2455 | *level = 0; |
| 2547 | 2456 | ||
| 2548 | mlog_exit(ret); | ||
| 2549 | return ret; | 2457 | return ret; |
| 2550 | } | 2458 | } |
| 2551 | 2459 | ||
| @@ -2556,8 +2464,6 @@ void ocfs2_inode_unlock(struct inode *inode, | |||
| 2556 | struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_inode_lockres; | 2464 | struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_inode_lockres; |
| 2557 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 2465 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
| 2558 | 2466 | ||
| 2559 | mlog_entry_void(); | ||
| 2560 | |||
| 2561 | mlog(0, "inode %llu drop %s META lock\n", | 2467 | mlog(0, "inode %llu drop %s META lock\n", |
| 2562 | (unsigned long long)OCFS2_I(inode)->ip_blkno, | 2468 | (unsigned long long)OCFS2_I(inode)->ip_blkno, |
| 2563 | ex ? "EXMODE" : "PRMODE"); | 2469 | ex ? "EXMODE" : "PRMODE"); |
| @@ -2565,8 +2471,6 @@ void ocfs2_inode_unlock(struct inode *inode, | |||
| 2565 | if (!ocfs2_is_hard_readonly(OCFS2_SB(inode->i_sb)) && | 2471 | if (!ocfs2_is_hard_readonly(OCFS2_SB(inode->i_sb)) && |
| 2566 | !ocfs2_mount_local(osb)) | 2472 | !ocfs2_mount_local(osb)) |
| 2567 | ocfs2_cluster_unlock(OCFS2_SB(inode->i_sb), lockres, level); | 2473 | ocfs2_cluster_unlock(OCFS2_SB(inode->i_sb), lockres, level); |
| 2568 | |||
| 2569 | mlog_exit_void(); | ||
| 2570 | } | 2474 | } |
| 2571 | 2475 | ||
| 2572 | int ocfs2_orphan_scan_lock(struct ocfs2_super *osb, u32 *seqno) | 2476 | int ocfs2_orphan_scan_lock(struct ocfs2_super *osb, u32 *seqno) |
| @@ -2617,8 +2521,6 @@ int ocfs2_super_lock(struct ocfs2_super *osb, | |||
| 2617 | int level = ex ? DLM_LOCK_EX : DLM_LOCK_PR; | 2521 | int level = ex ? DLM_LOCK_EX : DLM_LOCK_PR; |
| 2618 | struct ocfs2_lock_res *lockres = &osb->osb_super_lockres; | 2522 | struct ocfs2_lock_res *lockres = &osb->osb_super_lockres; |
| 2619 | 2523 | ||
| 2620 | mlog_entry_void(); | ||
| 2621 | |||
| 2622 | if (ocfs2_is_hard_readonly(osb)) | 2524 | if (ocfs2_is_hard_readonly(osb)) |
| 2623 | return -EROFS; | 2525 | return -EROFS; |
| 2624 | 2526 | ||
| @@ -2650,7 +2552,6 @@ int ocfs2_super_lock(struct ocfs2_super *osb, | |||
| 2650 | ocfs2_track_lock_refresh(lockres); | 2552 | ocfs2_track_lock_refresh(lockres); |
| 2651 | } | 2553 | } |
| 2652 | bail: | 2554 | bail: |
| 2653 | mlog_exit(status); | ||
| 2654 | return status; | 2555 | return status; |
| 2655 | } | 2556 | } |
| 2656 | 2557 | ||
| @@ -2869,8 +2770,15 @@ static void *ocfs2_dlm_seq_next(struct seq_file *m, void *v, loff_t *pos) | |||
| 2869 | return iter; | 2770 | return iter; |
| 2870 | } | 2771 | } |
| 2871 | 2772 | ||
| 2872 | /* So that debugfs.ocfs2 can determine which format is being used */ | 2773 | /* |
| 2873 | #define OCFS2_DLM_DEBUG_STR_VERSION 2 | 2774 | * Version is used by debugfs.ocfs2 to determine the format being used |
| 2775 | * | ||
| 2776 | * New in version 2 | ||
| 2777 | * - Lock stats printed | ||
| 2778 | * New in version 3 | ||
| 2779 | * - Max time in lock stats is in usecs (instead of nsecs) | ||
| 2780 | */ | ||
| 2781 | #define OCFS2_DLM_DEBUG_STR_VERSION 3 | ||
| 2874 | static int ocfs2_dlm_seq_show(struct seq_file *m, void *v) | 2782 | static int ocfs2_dlm_seq_show(struct seq_file *m, void *v) |
| 2875 | { | 2783 | { |
| 2876 | int i; | 2784 | int i; |
| @@ -2912,18 +2820,18 @@ static int ocfs2_dlm_seq_show(struct seq_file *m, void *v) | |||
| 2912 | seq_printf(m, "0x%x\t", lvb[i]); | 2820 | seq_printf(m, "0x%x\t", lvb[i]); |
| 2913 | 2821 | ||
| 2914 | #ifdef CONFIG_OCFS2_FS_STATS | 2822 | #ifdef CONFIG_OCFS2_FS_STATS |
| 2915 | # define lock_num_prmode(_l) (_l)->l_lock_num_prmode | 2823 | # define lock_num_prmode(_l) ((_l)->l_lock_prmode.ls_gets) |
| 2916 | # define lock_num_exmode(_l) (_l)->l_lock_num_exmode | 2824 | # define lock_num_exmode(_l) ((_l)->l_lock_exmode.ls_gets) |
| 2917 | # define lock_num_prmode_failed(_l) (_l)->l_lock_num_prmode_failed | 2825 | # define lock_num_prmode_failed(_l) ((_l)->l_lock_prmode.ls_fail) |
| 2918 | # define lock_num_exmode_failed(_l) (_l)->l_lock_num_exmode_failed | 2826 | # define lock_num_exmode_failed(_l) ((_l)->l_lock_exmode.ls_fail) |
| 2919 | # define lock_total_prmode(_l) (_l)->l_lock_total_prmode | 2827 | # define lock_total_prmode(_l) ((_l)->l_lock_prmode.ls_total) |
| 2920 | # define lock_total_exmode(_l) (_l)->l_lock_total_exmode | 2828 | # define lock_total_exmode(_l) ((_l)->l_lock_exmode.ls_total) |
| 2921 | # define lock_max_prmode(_l) (_l)->l_lock_max_prmode | 2829 | # define lock_max_prmode(_l) ((_l)->l_lock_prmode.ls_max) |
| 2922 | # define lock_max_exmode(_l) (_l)->l_lock_max_exmode | 2830 | # define lock_max_exmode(_l) ((_l)->l_lock_exmode.ls_max) |
| 2923 | # define lock_refresh(_l) (_l)->l_lock_refresh | 2831 | # define lock_refresh(_l) ((_l)->l_lock_refresh) |
| 2924 | #else | 2832 | #else |
| 2925 | # define lock_num_prmode(_l) (0ULL) | 2833 | # define lock_num_prmode(_l) (0) |
| 2926 | # define lock_num_exmode(_l) (0ULL) | 2834 | # define lock_num_exmode(_l) (0) |
| 2927 | # define lock_num_prmode_failed(_l) (0) | 2835 | # define lock_num_prmode_failed(_l) (0) |
| 2928 | # define lock_num_exmode_failed(_l) (0) | 2836 | # define lock_num_exmode_failed(_l) (0) |
| 2929 | # define lock_total_prmode(_l) (0ULL) | 2837 | # define lock_total_prmode(_l) (0ULL) |
| @@ -2933,8 +2841,8 @@ static int ocfs2_dlm_seq_show(struct seq_file *m, void *v) | |||
| 2933 | # define lock_refresh(_l) (0) | 2841 | # define lock_refresh(_l) (0) |
| 2934 | #endif | 2842 | #endif |
| 2935 | /* The following seq_print was added in version 2 of this output */ | 2843 | /* The following seq_print was added in version 2 of this output */ |
| 2936 | seq_printf(m, "%llu\t" | 2844 | seq_printf(m, "%u\t" |
| 2937 | "%llu\t" | 2845 | "%u\t" |
| 2938 | "%u\t" | 2846 | "%u\t" |
| 2939 | "%u\t" | 2847 | "%u\t" |
| 2940 | "%llu\t" | 2848 | "%llu\t" |
| @@ -3054,8 +2962,6 @@ int ocfs2_dlm_init(struct ocfs2_super *osb) | |||
| 3054 | int status = 0; | 2962 | int status = 0; |
| 3055 | struct ocfs2_cluster_connection *conn = NULL; | 2963 | struct ocfs2_cluster_connection *conn = NULL; |
| 3056 | 2964 | ||
| 3057 | mlog_entry_void(); | ||
| 3058 | |||
| 3059 | if (ocfs2_mount_local(osb)) { | 2965 | if (ocfs2_mount_local(osb)) { |
| 3060 | osb->node_num = 0; | 2966 | osb->node_num = 0; |
| 3061 | goto local; | 2967 | goto local; |
| @@ -3112,15 +3018,12 @@ bail: | |||
| 3112 | kthread_stop(osb->dc_task); | 3018 | kthread_stop(osb->dc_task); |
| 3113 | } | 3019 | } |
| 3114 | 3020 | ||
| 3115 | mlog_exit(status); | ||
| 3116 | return status; | 3021 | return status; |
| 3117 | } | 3022 | } |
| 3118 | 3023 | ||
| 3119 | void ocfs2_dlm_shutdown(struct ocfs2_super *osb, | 3024 | void ocfs2_dlm_shutdown(struct ocfs2_super *osb, |
| 3120 | int hangup_pending) | 3025 | int hangup_pending) |
| 3121 | { | 3026 | { |
| 3122 | mlog_entry_void(); | ||
| 3123 | |||
| 3124 | ocfs2_drop_osb_locks(osb); | 3027 | ocfs2_drop_osb_locks(osb); |
| 3125 | 3028 | ||
| 3126 | /* | 3029 | /* |
| @@ -3143,8 +3046,6 @@ void ocfs2_dlm_shutdown(struct ocfs2_super *osb, | |||
| 3143 | osb->cconn = NULL; | 3046 | osb->cconn = NULL; |
| 3144 | 3047 | ||
| 3145 | ocfs2_dlm_shutdown_debug(osb); | 3048 | ocfs2_dlm_shutdown_debug(osb); |
| 3146 | |||
| 3147 | mlog_exit_void(); | ||
| 3148 | } | 3049 | } |
| 3149 | 3050 | ||
| 3150 | static int ocfs2_drop_lock(struct ocfs2_super *osb, | 3051 | static int ocfs2_drop_lock(struct ocfs2_super *osb, |
| @@ -3226,7 +3127,6 @@ static int ocfs2_drop_lock(struct ocfs2_super *osb, | |||
| 3226 | 3127 | ||
| 3227 | ocfs2_wait_on_busy_lock(lockres); | 3128 | ocfs2_wait_on_busy_lock(lockres); |
| 3228 | out: | 3129 | out: |
| 3229 | mlog_exit(0); | ||
| 3230 | return 0; | 3130 | return 0; |
| 3231 | } | 3131 | } |
| 3232 | 3132 | ||
| @@ -3284,8 +3184,6 @@ int ocfs2_drop_inode_locks(struct inode *inode) | |||
| 3284 | { | 3184 | { |
| 3285 | int status, err; | 3185 | int status, err; |
| 3286 | 3186 | ||
| 3287 | mlog_entry_void(); | ||
| 3288 | |||
| 3289 | /* No need to call ocfs2_mark_lockres_freeing here - | 3187 | /* No need to call ocfs2_mark_lockres_freeing here - |
| 3290 | * ocfs2_clear_inode has done it for us. */ | 3188 | * ocfs2_clear_inode has done it for us. */ |
| 3291 | 3189 | ||
| @@ -3310,7 +3208,6 @@ int ocfs2_drop_inode_locks(struct inode *inode) | |||
| 3310 | if (err < 0 && !status) | 3208 | if (err < 0 && !status) |
| 3311 | status = err; | 3209 | status = err; |
| 3312 | 3210 | ||
| 3313 | mlog_exit(status); | ||
| 3314 | return status; | 3211 | return status; |
| 3315 | } | 3212 | } |
| 3316 | 3213 | ||
| @@ -3352,8 +3249,6 @@ static int ocfs2_downconvert_lock(struct ocfs2_super *osb, | |||
| 3352 | int ret; | 3249 | int ret; |
| 3353 | u32 dlm_flags = DLM_LKF_CONVERT; | 3250 | u32 dlm_flags = DLM_LKF_CONVERT; |
| 3354 | 3251 | ||
| 3355 | mlog_entry_void(); | ||
| 3356 | |||
| 3357 | mlog(ML_BASTS, "lockres %s, level %d => %d\n", lockres->l_name, | 3252 | mlog(ML_BASTS, "lockres %s, level %d => %d\n", lockres->l_name, |
| 3358 | lockres->l_level, new_level); | 3253 | lockres->l_level, new_level); |
| 3359 | 3254 | ||
| @@ -3375,7 +3270,6 @@ static int ocfs2_downconvert_lock(struct ocfs2_super *osb, | |||
| 3375 | 3270 | ||
| 3376 | ret = 0; | 3271 | ret = 0; |
| 3377 | bail: | 3272 | bail: |
| 3378 | mlog_exit(ret); | ||
| 3379 | return ret; | 3273 | return ret; |
| 3380 | } | 3274 | } |
| 3381 | 3275 | ||
| @@ -3385,8 +3279,6 @@ static int ocfs2_prepare_cancel_convert(struct ocfs2_super *osb, | |||
| 3385 | { | 3279 | { |
| 3386 | assert_spin_locked(&lockres->l_lock); | 3280 | assert_spin_locked(&lockres->l_lock); |
| 3387 | 3281 | ||
| 3388 | mlog_entry_void(); | ||
| 3389 | |||
| 3390 | if (lockres->l_unlock_action == OCFS2_UNLOCK_CANCEL_CONVERT) { | 3282 | if (lockres->l_unlock_action == OCFS2_UNLOCK_CANCEL_CONVERT) { |
| 3391 | /* If we're already trying to cancel a lock conversion | 3283 | /* If we're already trying to cancel a lock conversion |
| 3392 | * then just drop the spinlock and allow the caller to | 3284 | * then just drop the spinlock and allow the caller to |
| @@ -3416,8 +3308,6 @@ static int ocfs2_cancel_convert(struct ocfs2_super *osb, | |||
| 3416 | { | 3308 | { |
| 3417 | int ret; | 3309 | int ret; |
| 3418 | 3310 | ||
| 3419 | mlog_entry_void(); | ||
| 3420 | |||
| 3421 | ret = ocfs2_dlm_unlock(osb->cconn, &lockres->l_lksb, | 3311 | ret = ocfs2_dlm_unlock(osb->cconn, &lockres->l_lksb, |
| 3422 | DLM_LKF_CANCEL); | 3312 | DLM_LKF_CANCEL); |
| 3423 | if (ret) { | 3313 | if (ret) { |
| @@ -3427,7 +3317,6 @@ static int ocfs2_cancel_convert(struct ocfs2_super *osb, | |||
| 3427 | 3317 | ||
| 3428 | mlog(ML_BASTS, "lockres %s\n", lockres->l_name); | 3318 | mlog(ML_BASTS, "lockres %s\n", lockres->l_name); |
| 3429 | 3319 | ||
| 3430 | mlog_exit(ret); | ||
| 3431 | return ret; | 3320 | return ret; |
| 3432 | } | 3321 | } |
| 3433 | 3322 | ||
| @@ -3443,8 +3332,6 @@ static int ocfs2_unblock_lock(struct ocfs2_super *osb, | |||
| 3443 | int set_lvb = 0; | 3332 | int set_lvb = 0; |
| 3444 | unsigned int gen; | 3333 | unsigned int gen; |
| 3445 | 3334 | ||
| 3446 | mlog_entry_void(); | ||
| 3447 | |||
| 3448 | spin_lock_irqsave(&lockres->l_lock, flags); | 3335 | spin_lock_irqsave(&lockres->l_lock, flags); |
| 3449 | 3336 | ||
| 3450 | recheck: | 3337 | recheck: |
| @@ -3619,14 +3506,14 @@ downconvert: | |||
| 3619 | gen); | 3506 | gen); |
| 3620 | 3507 | ||
| 3621 | leave: | 3508 | leave: |
| 3622 | mlog_exit(ret); | 3509 | if (ret) |
| 3510 | mlog_errno(ret); | ||
| 3623 | return ret; | 3511 | return ret; |
| 3624 | 3512 | ||
| 3625 | leave_requeue: | 3513 | leave_requeue: |
| 3626 | spin_unlock_irqrestore(&lockres->l_lock, flags); | 3514 | spin_unlock_irqrestore(&lockres->l_lock, flags); |
| 3627 | ctl->requeue = 1; | 3515 | ctl->requeue = 1; |
| 3628 | 3516 | ||
| 3629 | mlog_exit(0); | ||
| 3630 | return 0; | 3517 | return 0; |
| 3631 | } | 3518 | } |
| 3632 | 3519 | ||
| @@ -3859,8 +3746,6 @@ static void ocfs2_set_qinfo_lvb(struct ocfs2_lock_res *lockres) | |||
| 3859 | struct mem_dqinfo *info = sb_dqinfo(oinfo->dqi_gi.dqi_sb, | 3746 | struct mem_dqinfo *info = sb_dqinfo(oinfo->dqi_gi.dqi_sb, |
| 3860 | oinfo->dqi_gi.dqi_type); | 3747 | oinfo->dqi_gi.dqi_type); |
| 3861 | 3748 | ||
| 3862 | mlog_entry_void(); | ||
| 3863 | |||
| 3864 | lvb = ocfs2_dlm_lvb(&lockres->l_lksb); | 3749 | lvb = ocfs2_dlm_lvb(&lockres->l_lksb); |
| 3865 | lvb->lvb_version = OCFS2_QINFO_LVB_VERSION; | 3750 | lvb->lvb_version = OCFS2_QINFO_LVB_VERSION; |
| 3866 | lvb->lvb_bgrace = cpu_to_be32(info->dqi_bgrace); | 3751 | lvb->lvb_bgrace = cpu_to_be32(info->dqi_bgrace); |
| @@ -3869,8 +3754,6 @@ static void ocfs2_set_qinfo_lvb(struct ocfs2_lock_res *lockres) | |||
| 3869 | lvb->lvb_blocks = cpu_to_be32(oinfo->dqi_gi.dqi_blocks); | 3754 | lvb->lvb_blocks = cpu_to_be32(oinfo->dqi_gi.dqi_blocks); |
| 3870 | lvb->lvb_free_blk = cpu_to_be32(oinfo->dqi_gi.dqi_free_blk); | 3755 | lvb->lvb_free_blk = cpu_to_be32(oinfo->dqi_gi.dqi_free_blk); |
| 3871 | lvb->lvb_free_entry = cpu_to_be32(oinfo->dqi_gi.dqi_free_entry); | 3756 | lvb->lvb_free_entry = cpu_to_be32(oinfo->dqi_gi.dqi_free_entry); |
| 3872 | |||
| 3873 | mlog_exit_void(); | ||
| 3874 | } | 3757 | } |
| 3875 | 3758 | ||
| 3876 | void ocfs2_qinfo_unlock(struct ocfs2_mem_dqinfo *oinfo, int ex) | 3759 | void ocfs2_qinfo_unlock(struct ocfs2_mem_dqinfo *oinfo, int ex) |
| @@ -3879,10 +3762,8 @@ void ocfs2_qinfo_unlock(struct ocfs2_mem_dqinfo *oinfo, int ex) | |||
| 3879 | struct ocfs2_super *osb = OCFS2_SB(oinfo->dqi_gi.dqi_sb); | 3762 | struct ocfs2_super *osb = OCFS2_SB(oinfo->dqi_gi.dqi_sb); |
| 3880 | int level = ex ? DLM_LOCK_EX : DLM_LOCK_PR; | 3763 | int level = ex ? DLM_LOCK_EX : DLM_LOCK_PR; |
| 3881 | 3764 | ||
| 3882 | mlog_entry_void(); | ||
| 3883 | if (!ocfs2_is_hard_readonly(osb) && !ocfs2_mount_local(osb)) | 3765 | if (!ocfs2_is_hard_readonly(osb) && !ocfs2_mount_local(osb)) |
| 3884 | ocfs2_cluster_unlock(osb, lockres, level); | 3766 | ocfs2_cluster_unlock(osb, lockres, level); |
| 3885 | mlog_exit_void(); | ||
| 3886 | } | 3767 | } |
| 3887 | 3768 | ||
| 3888 | static int ocfs2_refresh_qinfo(struct ocfs2_mem_dqinfo *oinfo) | 3769 | static int ocfs2_refresh_qinfo(struct ocfs2_mem_dqinfo *oinfo) |
| @@ -3937,8 +3818,6 @@ int ocfs2_qinfo_lock(struct ocfs2_mem_dqinfo *oinfo, int ex) | |||
| 3937 | int level = ex ? DLM_LOCK_EX : DLM_LOCK_PR; | 3818 | int level = ex ? DLM_LOCK_EX : DLM_LOCK_PR; |
| 3938 | int status = 0; | 3819 | int status = 0; |
| 3939 | 3820 | ||
| 3940 | mlog_entry_void(); | ||
| 3941 | |||
| 3942 | /* On RO devices, locking really isn't needed... */ | 3821 | /* On RO devices, locking really isn't needed... */ |
| 3943 | if (ocfs2_is_hard_readonly(osb)) { | 3822 | if (ocfs2_is_hard_readonly(osb)) { |
| 3944 | if (ex) | 3823 | if (ex) |
| @@ -3961,7 +3840,6 @@ int ocfs2_qinfo_lock(struct ocfs2_mem_dqinfo *oinfo, int ex) | |||
| 3961 | ocfs2_qinfo_unlock(oinfo, ex); | 3840 | ocfs2_qinfo_unlock(oinfo, ex); |
| 3962 | ocfs2_complete_lock_res_refresh(lockres, status); | 3841 | ocfs2_complete_lock_res_refresh(lockres, status); |
| 3963 | bail: | 3842 | bail: |
| 3964 | mlog_exit(status); | ||
| 3965 | return status; | 3843 | return status; |
| 3966 | } | 3844 | } |
| 3967 | 3845 | ||
| @@ -4007,8 +3885,6 @@ static void ocfs2_process_blocked_lock(struct ocfs2_super *osb, | |||
| 4007 | * considered valid until we remove the OCFS2_LOCK_QUEUED | 3885 | * considered valid until we remove the OCFS2_LOCK_QUEUED |
| 4008 | * flag. */ | 3886 | * flag. */ |
| 4009 | 3887 | ||
| 4010 | mlog_entry_void(); | ||
| 4011 | |||
| 4012 | BUG_ON(!lockres); | 3888 | BUG_ON(!lockres); |
| 4013 | BUG_ON(!lockres->l_ops); | 3889 | BUG_ON(!lockres->l_ops); |
| 4014 | 3890 | ||
| @@ -4042,15 +3918,11 @@ unqueue: | |||
| 4042 | if (ctl.unblock_action != UNBLOCK_CONTINUE | 3918 | if (ctl.unblock_action != UNBLOCK_CONTINUE |
| 4043 | && lockres->l_ops->post_unlock) | 3919 | && lockres->l_ops->post_unlock) |
| 4044 | lockres->l_ops->post_unlock(osb, lockres); | 3920 | lockres->l_ops->post_unlock(osb, lockres); |
| 4045 | |||
| 4046 | mlog_exit_void(); | ||
| 4047 | } | 3921 | } |
| 4048 | 3922 | ||
| 4049 | static void ocfs2_schedule_blocked_lock(struct ocfs2_super *osb, | 3923 | static void ocfs2_schedule_blocked_lock(struct ocfs2_super *osb, |
| 4050 | struct ocfs2_lock_res *lockres) | 3924 | struct ocfs2_lock_res *lockres) |
| 4051 | { | 3925 | { |
| 4052 | mlog_entry_void(); | ||
| 4053 | |||
| 4054 | assert_spin_locked(&lockres->l_lock); | 3926 | assert_spin_locked(&lockres->l_lock); |
| 4055 | 3927 | ||
| 4056 | if (lockres->l_flags & OCFS2_LOCK_FREEING) { | 3928 | if (lockres->l_flags & OCFS2_LOCK_FREEING) { |
| @@ -4071,8 +3943,6 @@ static void ocfs2_schedule_blocked_lock(struct ocfs2_super *osb, | |||
| 4071 | osb->blocked_lock_count++; | 3943 | osb->blocked_lock_count++; |
| 4072 | } | 3944 | } |
| 4073 | spin_unlock(&osb->dc_task_lock); | 3945 | spin_unlock(&osb->dc_task_lock); |
| 4074 | |||
| 4075 | mlog_exit_void(); | ||
| 4076 | } | 3946 | } |
| 4077 | 3947 | ||
| 4078 | static void ocfs2_downconvert_thread_do_work(struct ocfs2_super *osb) | 3948 | static void ocfs2_downconvert_thread_do_work(struct ocfs2_super *osb) |
| @@ -4080,8 +3950,6 @@ static void ocfs2_downconvert_thread_do_work(struct ocfs2_super *osb) | |||
| 4080 | unsigned long processed; | 3950 | unsigned long processed; |
| 4081 | struct ocfs2_lock_res *lockres; | 3951 | struct ocfs2_lock_res *lockres; |
| 4082 | 3952 | ||
| 4083 | mlog_entry_void(); | ||
| 4084 | |||
| 4085 | spin_lock(&osb->dc_task_lock); | 3953 | spin_lock(&osb->dc_task_lock); |
| 4086 | /* grab this early so we know to try again if a state change and | 3954 | /* grab this early so we know to try again if a state change and |
| 4087 | * wake happens part-way through our work */ | 3955 | * wake happens part-way through our work */ |
| @@ -4105,8 +3973,6 @@ static void ocfs2_downconvert_thread_do_work(struct ocfs2_super *osb) | |||
| 4105 | spin_lock(&osb->dc_task_lock); | 3973 | spin_lock(&osb->dc_task_lock); |
| 4106 | } | 3974 | } |
| 4107 | spin_unlock(&osb->dc_task_lock); | 3975 | spin_unlock(&osb->dc_task_lock); |
| 4108 | |||
| 4109 | mlog_exit_void(); | ||
| 4110 | } | 3976 | } |
| 4111 | 3977 | ||
| 4112 | static int ocfs2_downconvert_thread_lists_empty(struct ocfs2_super *osb) | 3978 | static int ocfs2_downconvert_thread_lists_empty(struct ocfs2_super *osb) |
diff --git a/fs/ocfs2/export.c b/fs/ocfs2/export.c index 254652a9b54..745db42528d 100644 --- a/fs/ocfs2/export.c +++ b/fs/ocfs2/export.c | |||
| @@ -26,7 +26,6 @@ | |||
| 26 | #include <linux/fs.h> | 26 | #include <linux/fs.h> |
| 27 | #include <linux/types.h> | 27 | #include <linux/types.h> |
| 28 | 28 | ||
| 29 | #define MLOG_MASK_PREFIX ML_EXPORT | ||
| 30 | #include <cluster/masklog.h> | 29 | #include <cluster/masklog.h> |
| 31 | 30 | ||
| 32 | #include "ocfs2.h" | 31 | #include "ocfs2.h" |
| @@ -40,6 +39,7 @@ | |||
| 40 | 39 | ||
| 41 | #include "buffer_head_io.h" | 40 | #include "buffer_head_io.h" |
| 42 | #include "suballoc.h" | 41 | #include "suballoc.h" |
| 42 | #include "ocfs2_trace.h" | ||
| 43 | 43 | ||
| 44 | struct ocfs2_inode_handle | 44 | struct ocfs2_inode_handle |
| 45 | { | 45 | { |
| @@ -56,10 +56,9 @@ static struct dentry *ocfs2_get_dentry(struct super_block *sb, | |||
| 56 | int status, set; | 56 | int status, set; |
| 57 | struct dentry *result; | 57 | struct dentry *result; |
| 58 | 58 | ||
| 59 | mlog_entry("(0x%p, 0x%p)\n", sb, handle); | 59 | trace_ocfs2_get_dentry_begin(sb, handle, (unsigned long long)blkno); |
| 60 | 60 | ||
| 61 | if (blkno == 0) { | 61 | if (blkno == 0) { |
| 62 | mlog(0, "nfs wants inode with blkno: 0\n"); | ||
| 63 | result = ERR_PTR(-ESTALE); | 62 | result = ERR_PTR(-ESTALE); |
| 64 | goto bail; | 63 | goto bail; |
| 65 | } | 64 | } |
| @@ -83,6 +82,7 @@ static struct dentry *ocfs2_get_dentry(struct super_block *sb, | |||
| 83 | } | 82 | } |
| 84 | 83 | ||
| 85 | status = ocfs2_test_inode_bit(osb, blkno, &set); | 84 | status = ocfs2_test_inode_bit(osb, blkno, &set); |
| 85 | trace_ocfs2_get_dentry_test_bit(status, set); | ||
| 86 | if (status < 0) { | 86 | if (status < 0) { |
| 87 | if (status == -EINVAL) { | 87 | if (status == -EINVAL) { |
| 88 | /* | 88 | /* |
| @@ -90,18 +90,14 @@ static struct dentry *ocfs2_get_dentry(struct super_block *sb, | |||
| 90 | * as an inode, we return -ESTALE to be | 90 | * as an inode, we return -ESTALE to be |
| 91 | * nice | 91 | * nice |
| 92 | */ | 92 | */ |
| 93 | mlog(0, "test inode bit failed %d\n", status); | ||
| 94 | status = -ESTALE; | 93 | status = -ESTALE; |
| 95 | } else { | 94 | } else |
| 96 | mlog(ML_ERROR, "test inode bit failed %d\n", status); | 95 | mlog(ML_ERROR, "test inode bit failed %d\n", status); |
| 97 | } | ||
| 98 | goto unlock_nfs_sync; | 96 | goto unlock_nfs_sync; |
| 99 | } | 97 | } |
| 100 | 98 | ||
| 101 | /* If the inode allocator bit is clear, this inode must be stale */ | 99 | /* If the inode allocator bit is clear, this inode must be stale */ |
| 102 | if (!set) { | 100 | if (!set) { |
| 103 | mlog(0, "inode %llu suballoc bit is clear\n", | ||
| 104 | (unsigned long long)blkno); | ||
| 105 | status = -ESTALE; | 101 | status = -ESTALE; |
| 106 | goto unlock_nfs_sync; | 102 | goto unlock_nfs_sync; |
| 107 | } | 103 | } |
| @@ -114,8 +110,8 @@ unlock_nfs_sync: | |||
| 114 | check_err: | 110 | check_err: |
| 115 | if (status < 0) { | 111 | if (status < 0) { |
| 116 | if (status == -ESTALE) { | 112 | if (status == -ESTALE) { |
| 117 | mlog(0, "stale inode ino: %llu generation: %u\n", | 113 | trace_ocfs2_get_dentry_stale((unsigned long long)blkno, |
| 118 | (unsigned long long)blkno, handle->ih_generation); | 114 | handle->ih_generation); |
| 119 | } | 115 | } |
| 120 | result = ERR_PTR(status); | 116 | result = ERR_PTR(status); |
| 121 | goto bail; | 117 | goto bail; |
| @@ -130,8 +126,9 @@ check_err: | |||
| 130 | check_gen: | 126 | check_gen: |
| 131 | if (handle->ih_generation != inode->i_generation) { | 127 | if (handle->ih_generation != inode->i_generation) { |
| 132 | iput(inode); | 128 | iput(inode); |
| 133 | mlog(0, "stale inode ino: %llu generation: %u\n", | 129 | trace_ocfs2_get_dentry_generation((unsigned long long)blkno, |
| 134 | (unsigned long long)blkno, handle->ih_generation); | 130 | handle->ih_generation, |
| 131 | inode->i_generation); | ||
| 135 | result = ERR_PTR(-ESTALE); | 132 | result = ERR_PTR(-ESTALE); |
| 136 | goto bail; | 133 | goto bail; |
| 137 | } | 134 | } |
| @@ -141,7 +138,7 @@ check_gen: | |||
| 141 | mlog_errno(PTR_ERR(result)); | 138 | mlog_errno(PTR_ERR(result)); |
| 142 | 139 | ||
| 143 | bail: | 140 | bail: |
| 144 | mlog_exit_ptr(result); | 141 | trace_ocfs2_get_dentry_end(result); |
| 145 | return result; | 142 | return result; |
| 146 | } | 143 | } |
| 147 | 144 | ||
| @@ -152,11 +149,8 @@ static struct dentry *ocfs2_get_parent(struct dentry *child) | |||
| 152 | struct dentry *parent; | 149 | struct dentry *parent; |
| 153 | struct inode *dir = child->d_inode; | 150 | struct inode *dir = child->d_inode; |
| 154 | 151 | ||
| 155 | mlog_entry("(0x%p, '%.*s')\n", child, | 152 | trace_ocfs2_get_parent(child, child->d_name.len, child->d_name.name, |
| 156 | child->d_name.len, child->d_name.name); | 153 | (unsigned long long)OCFS2_I(dir)->ip_blkno); |
| 157 | |||
| 158 | mlog(0, "find parent of directory %llu\n", | ||
| 159 | (unsigned long long)OCFS2_I(dir)->ip_blkno); | ||
| 160 | 154 | ||
| 161 | status = ocfs2_inode_lock(dir, NULL, 0); | 155 | status = ocfs2_inode_lock(dir, NULL, 0); |
| 162 | if (status < 0) { | 156 | if (status < 0) { |
| @@ -178,7 +172,7 @@ bail_unlock: | |||
| 178 | ocfs2_inode_unlock(dir, 0); | 172 | ocfs2_inode_unlock(dir, 0); |
| 179 | 173 | ||
| 180 | bail: | 174 | bail: |
| 181 | mlog_exit_ptr(parent); | 175 | trace_ocfs2_get_parent_end(parent); |
| 182 | 176 | ||
| 183 | return parent; | 177 | return parent; |
| 184 | } | 178 | } |
| @@ -193,9 +187,9 @@ static int ocfs2_encode_fh(struct dentry *dentry, u32 *fh_in, int *max_len, | |||
| 193 | u32 generation; | 187 | u32 generation; |
| 194 | __le32 *fh = (__force __le32 *) fh_in; | 188 | __le32 *fh = (__force __le32 *) fh_in; |
| 195 | 189 | ||
| 196 | mlog_entry("(0x%p, '%.*s', 0x%p, %d, %d)\n", dentry, | 190 | trace_ocfs2_encode_fh_begin(dentry, dentry->d_name.len, |
| 197 | dentry->d_name.len, dentry->d_name.name, | 191 | dentry->d_name.name, |
| 198 | fh, len, connectable); | 192 | fh, len, connectable); |
| 199 | 193 | ||
| 200 | if (connectable && (len < 6)) { | 194 | if (connectable && (len < 6)) { |
| 201 | *max_len = 6; | 195 | *max_len = 6; |
| @@ -210,8 +204,7 @@ static int ocfs2_encode_fh(struct dentry *dentry, u32 *fh_in, int *max_len, | |||
| 210 | blkno = OCFS2_I(inode)->ip_blkno; | 204 | blkno = OCFS2_I(inode)->ip_blkno; |
| 211 | generation = inode->i_generation; | 205 | generation = inode->i_generation; |
| 212 | 206 | ||
| 213 | mlog(0, "Encoding fh: blkno: %llu, generation: %u\n", | 207 | trace_ocfs2_encode_fh_self((unsigned long long)blkno, generation); |
| 214 | (unsigned long long)blkno, generation); | ||
| 215 | 208 | ||
| 216 | len = 3; | 209 | len = 3; |
| 217 | fh[0] = cpu_to_le32((u32)(blkno >> 32)); | 210 | fh[0] = cpu_to_le32((u32)(blkno >> 32)); |
| @@ -236,14 +229,14 @@ static int ocfs2_encode_fh(struct dentry *dentry, u32 *fh_in, int *max_len, | |||
| 236 | len = 6; | 229 | len = 6; |
| 237 | type = 2; | 230 | type = 2; |
| 238 | 231 | ||
| 239 | mlog(0, "Encoding parent: blkno: %llu, generation: %u\n", | 232 | trace_ocfs2_encode_fh_parent((unsigned long long)blkno, |
| 240 | (unsigned long long)blkno, generation); | 233 | generation); |
| 241 | } | 234 | } |
| 242 | 235 | ||
| 243 | *max_len = len; | 236 | *max_len = len; |
| 244 | 237 | ||
| 245 | bail: | 238 | bail: |
| 246 | mlog_exit(type); | 239 | trace_ocfs2_encode_fh_type(type); |
| 247 | return type; | 240 | return type; |
| 248 | } | 241 | } |
| 249 | 242 | ||
diff --git a/fs/ocfs2/extent_map.c b/fs/ocfs2/extent_map.c index 09e3fdfa6d3..23457b491e8 100644 --- a/fs/ocfs2/extent_map.c +++ b/fs/ocfs2/extent_map.c | |||
| @@ -28,7 +28,6 @@ | |||
| 28 | #include <linux/types.h> | 28 | #include <linux/types.h> |
| 29 | #include <linux/fiemap.h> | 29 | #include <linux/fiemap.h> |
| 30 | 30 | ||
| 31 | #define MLOG_MASK_PREFIX ML_EXTENT_MAP | ||
| 32 | #include <cluster/masklog.h> | 31 | #include <cluster/masklog.h> |
| 33 | 32 | ||
| 34 | #include "ocfs2.h" | 33 | #include "ocfs2.h" |
| @@ -39,6 +38,7 @@ | |||
| 39 | #include "inode.h" | 38 | #include "inode.h" |
| 40 | #include "super.h" | 39 | #include "super.h" |
| 41 | #include "symlink.h" | 40 | #include "symlink.h" |
| 41 | #include "ocfs2_trace.h" | ||
| 42 | 42 | ||
| 43 | #include "buffer_head_io.h" | 43 | #include "buffer_head_io.h" |
| 44 | 44 | ||
| @@ -841,10 +841,9 @@ int ocfs2_read_virt_blocks(struct inode *inode, u64 v_block, int nr, | |||
| 841 | u64 p_block, p_count; | 841 | u64 p_block, p_count; |
| 842 | int i, count, done = 0; | 842 | int i, count, done = 0; |
| 843 | 843 | ||
| 844 | mlog_entry("(inode = %p, v_block = %llu, nr = %d, bhs = %p, " | 844 | trace_ocfs2_read_virt_blocks( |
| 845 | "flags = %x, validate = %p)\n", | 845 | inode, (unsigned long long)v_block, nr, bhs, flags, |
| 846 | inode, (unsigned long long)v_block, nr, bhs, flags, | 846 | validate); |
| 847 | validate); | ||
| 848 | 847 | ||
| 849 | if (((v_block + nr - 1) << inode->i_sb->s_blocksize_bits) >= | 848 | if (((v_block + nr - 1) << inode->i_sb->s_blocksize_bits) >= |
| 850 | i_size_read(inode)) { | 849 | i_size_read(inode)) { |
| @@ -897,7 +896,6 @@ int ocfs2_read_virt_blocks(struct inode *inode, u64 v_block, int nr, | |||
| 897 | } | 896 | } |
| 898 | 897 | ||
| 899 | out: | 898 | out: |
| 900 | mlog_exit(rc); | ||
| 901 | return rc; | 899 | return rc; |
| 902 | } | 900 | } |
| 903 | 901 | ||
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index a6651956482..41565ae5285 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c | |||
| @@ -38,7 +38,6 @@ | |||
| 38 | #include <linux/quotaops.h> | 38 | #include <linux/quotaops.h> |
| 39 | #include <linux/blkdev.h> | 39 | #include <linux/blkdev.h> |
| 40 | 40 | ||
| 41 | #define MLOG_MASK_PREFIX ML_INODE | ||
| 42 | #include <cluster/masklog.h> | 41 | #include <cluster/masklog.h> |
| 43 | 42 | ||
| 44 | #include "ocfs2.h" | 43 | #include "ocfs2.h" |
| @@ -61,6 +60,7 @@ | |||
| 61 | #include "acl.h" | 60 | #include "acl.h" |
| 62 | #include "quota.h" | 61 | #include "quota.h" |
| 63 | #include "refcounttree.h" | 62 | #include "refcounttree.h" |
| 63 | #include "ocfs2_trace.h" | ||
| 64 | 64 | ||
| 65 | #include "buffer_head_io.h" | 65 | #include "buffer_head_io.h" |
| 66 | 66 | ||
| @@ -99,8 +99,10 @@ static int ocfs2_file_open(struct inode *inode, struct file *file) | |||
| 99 | int mode = file->f_flags; | 99 | int mode = file->f_flags; |
| 100 | struct ocfs2_inode_info *oi = OCFS2_I(inode); | 100 | struct ocfs2_inode_info *oi = OCFS2_I(inode); |
| 101 | 101 | ||
| 102 | mlog_entry("(0x%p, 0x%p, '%.*s')\n", inode, file, | 102 | trace_ocfs2_file_open(inode, file, file->f_path.dentry, |
| 103 | file->f_path.dentry->d_name.len, file->f_path.dentry->d_name.name); | 103 | (unsigned long long)OCFS2_I(inode)->ip_blkno, |
| 104 | file->f_path.dentry->d_name.len, | ||
| 105 | file->f_path.dentry->d_name.name, mode); | ||
| 104 | 106 | ||
| 105 | if (file->f_mode & FMODE_WRITE) | 107 | if (file->f_mode & FMODE_WRITE) |
| 106 | dquot_initialize(inode); | 108 | dquot_initialize(inode); |
| @@ -135,7 +137,6 @@ static int ocfs2_file_open(struct inode *inode, struct file *file) | |||
| 135 | } | 137 | } |
| 136 | 138 | ||
| 137 | leave: | 139 | leave: |
| 138 | mlog_exit(status); | ||
| 139 | return status; | 140 | return status; |
| 140 | } | 141 | } |
| 141 | 142 | ||
| @@ -143,19 +144,19 @@ static int ocfs2_file_release(struct inode *inode, struct file *file) | |||
| 143 | { | 144 | { |
| 144 | struct ocfs2_inode_info *oi = OCFS2_I(inode); | 145 | struct ocfs2_inode_info *oi = OCFS2_I(inode); |
| 145 | 146 | ||
| 146 | mlog_entry("(0x%p, 0x%p, '%.*s')\n", inode, file, | ||
| 147 | file->f_path.dentry->d_name.len, | ||
| 148 | file->f_path.dentry->d_name.name); | ||
| 149 | |||
| 150 | spin_lock(&oi->ip_lock); | 147 | spin_lock(&oi->ip_lock); |
| 151 | if (!--oi->ip_open_count) | 148 | if (!--oi->ip_open_count) |
| 152 | oi->ip_flags &= ~OCFS2_INODE_OPEN_DIRECT; | 149 | oi->ip_flags &= ~OCFS2_INODE_OPEN_DIRECT; |
| 150 | |||
| 151 | trace_ocfs2_file_release(inode, file, file->f_path.dentry, | ||
| 152 | oi->ip_blkno, | ||
| 153 | file->f_path.dentry->d_name.len, | ||
| 154 | file->f_path.dentry->d_name.name, | ||
| 155 | oi->ip_open_count); | ||
| 153 | spin_unlock(&oi->ip_lock); | 156 | spin_unlock(&oi->ip_lock); |
| 154 | 157 | ||
| 155 | ocfs2_free_file_private(inode, file); | 158 | ocfs2_free_file_private(inode, file); |
| 156 | 159 | ||
| 157 | mlog_exit(0); | ||
| 158 | |||
| 159 | return 0; | 160 | return 0; |
| 160 | } | 161 | } |
| 161 | 162 | ||
| @@ -177,9 +178,11 @@ static int ocfs2_sync_file(struct file *file, int datasync) | |||
| 177 | struct inode *inode = file->f_mapping->host; | 178 | struct inode *inode = file->f_mapping->host; |
| 178 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 179 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
| 179 | 180 | ||
| 180 | mlog_entry("(0x%p, %d, 0x%p, '%.*s')\n", file, datasync, | 181 | trace_ocfs2_sync_file(inode, file, file->f_path.dentry, |
| 181 | file->f_path.dentry, file->f_path.dentry->d_name.len, | 182 | OCFS2_I(inode)->ip_blkno, |
| 182 | file->f_path.dentry->d_name.name); | 183 | file->f_path.dentry->d_name.len, |
| 184 | file->f_path.dentry->d_name.name, | ||
| 185 | (unsigned long long)datasync); | ||
| 183 | 186 | ||
| 184 | if (datasync && !(inode->i_state & I_DIRTY_DATASYNC)) { | 187 | if (datasync && !(inode->i_state & I_DIRTY_DATASYNC)) { |
| 185 | /* | 188 | /* |
| @@ -195,7 +198,8 @@ static int ocfs2_sync_file(struct file *file, int datasync) | |||
| 195 | err = jbd2_journal_force_commit(journal); | 198 | err = jbd2_journal_force_commit(journal); |
| 196 | 199 | ||
| 197 | bail: | 200 | bail: |
| 198 | mlog_exit(err); | 201 | if (err) |
| 202 | mlog_errno(err); | ||
| 199 | 203 | ||
| 200 | return (err < 0) ? -EIO : 0; | 204 | return (err < 0) ? -EIO : 0; |
| 201 | } | 205 | } |
| @@ -251,8 +255,6 @@ int ocfs2_update_inode_atime(struct inode *inode, | |||
| 251 | handle_t *handle; | 255 | handle_t *handle; |
| 252 | struct ocfs2_dinode *di = (struct ocfs2_dinode *) bh->b_data; | 256 | struct ocfs2_dinode *di = (struct ocfs2_dinode *) bh->b_data; |
| 253 | 257 | ||
| 254 | mlog_entry_void(); | ||
| 255 | |||
| 256 | handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS); | 258 | handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS); |
| 257 | if (IS_ERR(handle)) { | 259 | if (IS_ERR(handle)) { |
| 258 | ret = PTR_ERR(handle); | 260 | ret = PTR_ERR(handle); |
| @@ -280,7 +282,6 @@ int ocfs2_update_inode_atime(struct inode *inode, | |||
| 280 | out_commit: | 282 | out_commit: |
| 281 | ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle); | 283 | ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle); |
| 282 | out: | 284 | out: |
| 283 | mlog_exit(ret); | ||
| 284 | return ret; | 285 | return ret; |
| 285 | } | 286 | } |
| 286 | 287 | ||
| @@ -291,7 +292,6 @@ static int ocfs2_set_inode_size(handle_t *handle, | |||
| 291 | { | 292 | { |
| 292 | int status; | 293 | int status; |
| 293 | 294 | ||
| 294 | mlog_entry_void(); | ||
| 295 | i_size_write(inode, new_i_size); | 295 | i_size_write(inode, new_i_size); |
| 296 | inode->i_blocks = ocfs2_inode_sector_count(inode); | 296 | inode->i_blocks = ocfs2_inode_sector_count(inode); |
| 297 | inode->i_ctime = inode->i_mtime = CURRENT_TIME; | 297 | inode->i_ctime = inode->i_mtime = CURRENT_TIME; |
| @@ -303,7 +303,6 @@ static int ocfs2_set_inode_size(handle_t *handle, | |||
| 303 | } | 303 | } |
| 304 | 304 | ||
| 305 | bail: | 305 | bail: |
| 306 | mlog_exit(status); | ||
| 307 | return status; | 306 | return status; |
| 308 | } | 307 | } |
| 309 | 308 | ||
| @@ -375,8 +374,6 @@ static int ocfs2_orphan_for_truncate(struct ocfs2_super *osb, | |||
| 375 | struct ocfs2_dinode *di; | 374 | struct ocfs2_dinode *di; |
| 376 | u64 cluster_bytes; | 375 | u64 cluster_bytes; |
| 377 | 376 | ||
| 378 | mlog_entry_void(); | ||
| 379 | |||
| 380 | /* | 377 | /* |
| 381 | * We need to CoW the cluster contains the offset if it is reflinked | 378 | * We need to CoW the cluster contains the offset if it is reflinked |
| 382 | * since we will call ocfs2_zero_range_for_truncate later which will | 379 | * since we will call ocfs2_zero_range_for_truncate later which will |
| @@ -429,8 +426,6 @@ static int ocfs2_orphan_for_truncate(struct ocfs2_super *osb, | |||
| 429 | out_commit: | 426 | out_commit: |
| 430 | ocfs2_commit_trans(osb, handle); | 427 | ocfs2_commit_trans(osb, handle); |
| 431 | out: | 428 | out: |
| 432 | |||
| 433 | mlog_exit(status); | ||
| 434 | return status; | 429 | return status; |
| 435 | } | 430 | } |
| 436 | 431 | ||
| @@ -442,14 +437,14 @@ static int ocfs2_truncate_file(struct inode *inode, | |||
| 442 | struct ocfs2_dinode *fe = NULL; | 437 | struct ocfs2_dinode *fe = NULL; |
| 443 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 438 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
| 444 | 439 | ||
| 445 | mlog_entry("(inode = %llu, new_i_size = %llu\n", | ||
| 446 | (unsigned long long)OCFS2_I(inode)->ip_blkno, | ||
| 447 | (unsigned long long)new_i_size); | ||
| 448 | |||
| 449 | /* We trust di_bh because it comes from ocfs2_inode_lock(), which | 440 | /* We trust di_bh because it comes from ocfs2_inode_lock(), which |
| 450 | * already validated it */ | 441 | * already validated it */ |
| 451 | fe = (struct ocfs2_dinode *) di_bh->b_data; | 442 | fe = (struct ocfs2_dinode *) di_bh->b_data; |
| 452 | 443 | ||
| 444 | trace_ocfs2_truncate_file((unsigned long long)OCFS2_I(inode)->ip_blkno, | ||
| 445 | (unsigned long long)le64_to_cpu(fe->i_size), | ||
| 446 | (unsigned long long)new_i_size); | ||
| 447 | |||
| 453 | mlog_bug_on_msg(le64_to_cpu(fe->i_size) != i_size_read(inode), | 448 | mlog_bug_on_msg(le64_to_cpu(fe->i_size) != i_size_read(inode), |
| 454 | "Inode %llu, inode i_size = %lld != di " | 449 | "Inode %llu, inode i_size = %lld != di " |
| 455 | "i_size = %llu, i_flags = 0x%x\n", | 450 | "i_size = %llu, i_flags = 0x%x\n", |
| @@ -459,19 +454,14 @@ static int ocfs2_truncate_file(struct inode *inode, | |||
| 459 | le32_to_cpu(fe->i_flags)); | 454 | le32_to_cpu(fe->i_flags)); |
| 460 | 455 | ||
| 461 | if (new_i_size > le64_to_cpu(fe->i_size)) { | 456 | if (new_i_size > le64_to_cpu(fe->i_size)) { |
| 462 | mlog(0, "asked to truncate file with size (%llu) to size (%llu)!\n", | 457 | trace_ocfs2_truncate_file_error( |
| 463 | (unsigned long long)le64_to_cpu(fe->i_size), | 458 | (unsigned long long)le64_to_cpu(fe->i_size), |
| 464 | (unsigned long long)new_i_size); | 459 | (unsigned long long)new_i_size); |
| 465 | status = -EINVAL; | 460 | status = -EINVAL; |
| 466 | mlog_errno(status); | 461 | mlog_errno(status); |
| 467 | goto bail; | 462 | goto bail; |
| 468 | } | 463 | } |
| 469 | 464 | ||
| 470 | mlog(0, "inode %llu, i_size = %llu, new_i_size = %llu\n", | ||
| 471 | (unsigned long long)le64_to_cpu(fe->i_blkno), | ||
| 472 | (unsigned long long)le64_to_cpu(fe->i_size), | ||
| 473 | (unsigned long long)new_i_size); | ||
| 474 | |||
| 475 | /* lets handle the simple truncate cases before doing any more | 465 | /* lets handle the simple truncate cases before doing any more |
| 476 | * cluster locking. */ | 466 | * cluster locking. */ |
| 477 | if (new_i_size == le64_to_cpu(fe->i_size)) | 467 | if (new_i_size == le64_to_cpu(fe->i_size)) |
| @@ -525,7 +515,6 @@ bail: | |||
| 525 | if (!status && OCFS2_I(inode)->ip_clusters == 0) | 515 | if (!status && OCFS2_I(inode)->ip_clusters == 0) |
| 526 | status = ocfs2_try_remove_refcount_tree(inode, di_bh); | 516 | status = ocfs2_try_remove_refcount_tree(inode, di_bh); |
| 527 | 517 | ||
| 528 | mlog_exit(status); | ||
| 529 | return status; | 518 | return status; |
| 530 | } | 519 | } |
| 531 | 520 | ||
| @@ -578,8 +567,6 @@ static int __ocfs2_extend_allocation(struct inode *inode, u32 logical_start, | |||
| 578 | struct ocfs2_extent_tree et; | 567 | struct ocfs2_extent_tree et; |
| 579 | int did_quota = 0; | 568 | int did_quota = 0; |
| 580 | 569 | ||
| 581 | mlog_entry("(clusters_to_add = %u)\n", clusters_to_add); | ||
| 582 | |||
| 583 | /* | 570 | /* |
| 584 | * This function only exists for file systems which don't | 571 | * This function only exists for file systems which don't |
| 585 | * support holes. | 572 | * support holes. |
| @@ -596,11 +583,6 @@ static int __ocfs2_extend_allocation(struct inode *inode, u32 logical_start, | |||
| 596 | restart_all: | 583 | restart_all: |
| 597 | BUG_ON(le32_to_cpu(fe->i_clusters) != OCFS2_I(inode)->ip_clusters); | 584 | BUG_ON(le32_to_cpu(fe->i_clusters) != OCFS2_I(inode)->ip_clusters); |
| 598 | 585 | ||
| 599 | mlog(0, "extend inode %llu, i_size = %lld, di->i_clusters = %u, " | ||
| 600 | "clusters_to_add = %u\n", | ||
| 601 | (unsigned long long)OCFS2_I(inode)->ip_blkno, | ||
| 602 | (long long)i_size_read(inode), le32_to_cpu(fe->i_clusters), | ||
| 603 | clusters_to_add); | ||
| 604 | ocfs2_init_dinode_extent_tree(&et, INODE_CACHE(inode), bh); | 586 | ocfs2_init_dinode_extent_tree(&et, INODE_CACHE(inode), bh); |
| 605 | status = ocfs2_lock_allocators(inode, &et, clusters_to_add, 0, | 587 | status = ocfs2_lock_allocators(inode, &et, clusters_to_add, 0, |
| 606 | &data_ac, &meta_ac); | 588 | &data_ac, &meta_ac); |
| @@ -620,6 +602,12 @@ restart_all: | |||
| 620 | } | 602 | } |
| 621 | 603 | ||
| 622 | restarted_transaction: | 604 | restarted_transaction: |
| 605 | trace_ocfs2_extend_allocation( | ||
| 606 | (unsigned long long)OCFS2_I(inode)->ip_blkno, | ||
| 607 | (unsigned long long)i_size_read(inode), | ||
| 608 | le32_to_cpu(fe->i_clusters), clusters_to_add, | ||
| 609 | why, restart_func); | ||
| 610 | |||
| 623 | status = dquot_alloc_space_nodirty(inode, | 611 | status = dquot_alloc_space_nodirty(inode, |
| 624 | ocfs2_clusters_to_bytes(osb->sb, clusters_to_add)); | 612 | ocfs2_clusters_to_bytes(osb->sb, clusters_to_add)); |
| 625 | if (status) | 613 | if (status) |
| @@ -666,13 +654,11 @@ restarted_transaction: | |||
| 666 | 654 | ||
| 667 | if (why != RESTART_NONE && clusters_to_add) { | 655 | if (why != RESTART_NONE && clusters_to_add) { |
| 668 | if (why == RESTART_META) { | 656 | if (why == RESTART_META) { |
| 669 | mlog(0, "restarting function.\n"); | ||
| 670 | restart_func = 1; | 657 | restart_func = 1; |
| 671 | status = 0; | 658 | status = 0; |
| 672 | } else { | 659 | } else { |
| 673 | BUG_ON(why != RESTART_TRANS); | 660 | BUG_ON(why != RESTART_TRANS); |
| 674 | 661 | ||
| 675 | mlog(0, "restarting transaction.\n"); | ||
| 676 | /* TODO: This can be more intelligent. */ | 662 | /* TODO: This can be more intelligent. */ |
| 677 | credits = ocfs2_calc_extend_credits(osb->sb, | 663 | credits = ocfs2_calc_extend_credits(osb->sb, |
| 678 | &fe->id2.i_list, | 664 | &fe->id2.i_list, |
| @@ -689,11 +675,11 @@ restarted_transaction: | |||
| 689 | } | 675 | } |
| 690 | } | 676 | } |
| 691 | 677 | ||
| 692 | mlog(0, "fe: i_clusters = %u, i_size=%llu\n", | 678 | trace_ocfs2_extend_allocation_end(OCFS2_I(inode)->ip_blkno, |
| 693 | le32_to_cpu(fe->i_clusters), | 679 | le32_to_cpu(fe->i_clusters), |
| 694 | (unsigned long long)le64_to_cpu(fe->i_size)); | 680 | (unsigned long long)le64_to_cpu(fe->i_size), |
| 695 | mlog(0, "inode: ip_clusters=%u, i_size=%lld\n", | 681 | OCFS2_I(inode)->ip_clusters, |
| 696 | OCFS2_I(inode)->ip_clusters, (long long)i_size_read(inode)); | 682 | (unsigned long long)i_size_read(inode)); |
| 697 | 683 | ||
| 698 | leave: | 684 | leave: |
| 699 | if (status < 0 && did_quota) | 685 | if (status < 0 && did_quota) |
| @@ -718,7 +704,6 @@ leave: | |||
| 718 | brelse(bh); | 704 | brelse(bh); |
| 719 | bh = NULL; | 705 | bh = NULL; |
| 720 | 706 | ||
| 721 | mlog_exit(status); | ||
| 722 | return status; | 707 | return status; |
| 723 | } | 708 | } |
| 724 | 709 | ||
| @@ -785,10 +770,11 @@ static int ocfs2_write_zero_page(struct inode *inode, u64 abs_from, | |||
| 785 | if (!zero_to) | 770 | if (!zero_to) |
| 786 | zero_to = PAGE_CACHE_SIZE; | 771 | zero_to = PAGE_CACHE_SIZE; |
| 787 | 772 | ||
| 788 | mlog(0, | 773 | trace_ocfs2_write_zero_page( |
| 789 | "abs_from = %llu, abs_to = %llu, index = %lu, zero_from = %u, zero_to = %u\n", | 774 | (unsigned long long)OCFS2_I(inode)->ip_blkno, |
| 790 | (unsigned long long)abs_from, (unsigned long long)abs_to, | 775 | (unsigned long long)abs_from, |
| 791 | index, zero_from, zero_to); | 776 | (unsigned long long)abs_to, |
| 777 | index, zero_from, zero_to); | ||
| 792 | 778 | ||
| 793 | /* We know that zero_from is block aligned */ | 779 | /* We know that zero_from is block aligned */ |
| 794 | for (block_start = zero_from; block_start < zero_to; | 780 | for (block_start = zero_from; block_start < zero_to; |
| @@ -928,9 +914,10 @@ static int ocfs2_zero_extend_range(struct inode *inode, u64 range_start, | |||
| 928 | u64 next_pos; | 914 | u64 next_pos; |
| 929 | u64 zero_pos = range_start; | 915 | u64 zero_pos = range_start; |
| 930 | 916 | ||
| 931 | mlog(0, "range_start = %llu, range_end = %llu\n", | 917 | trace_ocfs2_zero_extend_range( |
| 932 | (unsigned long long)range_start, | 918 | (unsigned long long)OCFS2_I(inode)->ip_blkno, |
| 933 | (unsigned long long)range_end); | 919 | (unsigned long long)range_start, |
| 920 | (unsigned long long)range_end); | ||
| 934 | BUG_ON(range_start >= range_end); | 921 | BUG_ON(range_start >= range_end); |
| 935 | 922 | ||
| 936 | while (zero_pos < range_end) { | 923 | while (zero_pos < range_end) { |
| @@ -962,9 +949,9 @@ int ocfs2_zero_extend(struct inode *inode, struct buffer_head *di_bh, | |||
| 962 | struct super_block *sb = inode->i_sb; | 949 | struct super_block *sb = inode->i_sb; |
| 963 | 950 | ||
| 964 | zero_start = ocfs2_align_bytes_to_blocks(sb, i_size_read(inode)); | 951 | zero_start = ocfs2_align_bytes_to_blocks(sb, i_size_read(inode)); |
| 965 | mlog(0, "zero_start %llu for i_size %llu\n", | 952 | trace_ocfs2_zero_extend((unsigned long long)OCFS2_I(inode)->ip_blkno, |
| 966 | (unsigned long long)zero_start, | 953 | (unsigned long long)zero_start, |
| 967 | (unsigned long long)i_size_read(inode)); | 954 | (unsigned long long)i_size_read(inode)); |
| 968 | while (zero_start < zero_to_size) { | 955 | while (zero_start < zero_to_size) { |
| 969 | ret = ocfs2_zero_extend_get_range(inode, di_bh, zero_start, | 956 | ret = ocfs2_zero_extend_get_range(inode, di_bh, zero_start, |
| 970 | zero_to_size, | 957 | zero_to_size, |
| @@ -1113,30 +1100,20 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr) | |||
| 1113 | struct dquot *transfer_to[MAXQUOTAS] = { }; | 1100 | struct dquot *transfer_to[MAXQUOTAS] = { }; |
| 1114 | int qtype; | 1101 | int qtype; |
| 1115 | 1102 | ||
| 1116 | mlog_entry("(0x%p, '%.*s')\n", dentry, | 1103 | trace_ocfs2_setattr(inode, dentry, |
| 1117 | dentry->d_name.len, dentry->d_name.name); | 1104 | (unsigned long long)OCFS2_I(inode)->ip_blkno, |
| 1105 | dentry->d_name.len, dentry->d_name.name, | ||
| 1106 | attr->ia_valid, attr->ia_mode, | ||
| 1107 | attr->ia_uid, attr->ia_gid); | ||
| 1118 | 1108 | ||
| 1119 | /* ensuring we don't even attempt to truncate a symlink */ | 1109 | /* ensuring we don't even attempt to truncate a symlink */ |
| 1120 | if (S_ISLNK(inode->i_mode)) | 1110 | if (S_ISLNK(inode->i_mode)) |
| 1121 | attr->ia_valid &= ~ATTR_SIZE; | 1111 | attr->ia_valid &= ~ATTR_SIZE; |
| 1122 | 1112 | ||
| 1123 | if (attr->ia_valid & ATTR_MODE) | ||
| 1124 | mlog(0, "mode change: %d\n", attr->ia_mode); | ||
| 1125 | if (attr->ia_valid & ATTR_UID) | ||
| 1126 | mlog(0, "uid change: %d\n", attr->ia_uid); | ||
| 1127 | if (attr->ia_valid & ATTR_GID) | ||
| 1128 | mlog(0, "gid change: %d\n", attr->ia_gid); | ||
| 1129 | if (attr->ia_valid & ATTR_SIZE) | ||
| 1130 | mlog(0, "size change...\n"); | ||
| 1131 | if (attr->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME)) | ||
| 1132 | mlog(0, "time change...\n"); | ||
| 1133 | |||
| 1134 | #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \ | 1113 | #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \ |
| 1135 | | ATTR_GID | ATTR_UID | ATTR_MODE) | 1114 | | ATTR_GID | ATTR_UID | ATTR_MODE) |
| 1136 | if (!(attr->ia_valid & OCFS2_VALID_ATTRS)) { | 1115 | if (!(attr->ia_valid & OCFS2_VALID_ATTRS)) |
| 1137 | mlog(0, "can't handle attrs: 0x%x\n", attr->ia_valid); | ||
| 1138 | return 0; | 1116 | return 0; |
| 1139 | } | ||
| 1140 | 1117 | ||
| 1141 | status = inode_change_ok(inode, attr); | 1118 | status = inode_change_ok(inode, attr); |
| 1142 | if (status) | 1119 | if (status) |
| @@ -1274,7 +1251,6 @@ bail: | |||
| 1274 | mlog_errno(status); | 1251 | mlog_errno(status); |
| 1275 | } | 1252 | } |
| 1276 | 1253 | ||
| 1277 | mlog_exit(status); | ||
| 1278 | return status; | 1254 | return status; |
| 1279 | } | 1255 | } |
| 1280 | 1256 | ||
| @@ -1287,8 +1263,6 @@ int ocfs2_getattr(struct vfsmount *mnt, | |||
| 1287 | struct ocfs2_super *osb = sb->s_fs_info; | 1263 | struct ocfs2_super *osb = sb->s_fs_info; |
| 1288 | int err; | 1264 | int err; |
| 1289 | 1265 | ||
| 1290 | mlog_entry_void(); | ||
| 1291 | |||
| 1292 | err = ocfs2_inode_revalidate(dentry); | 1266 | err = ocfs2_inode_revalidate(dentry); |
| 1293 | if (err) { | 1267 | if (err) { |
| 1294 | if (err != -ENOENT) | 1268 | if (err != -ENOENT) |
| @@ -1302,8 +1276,6 @@ int ocfs2_getattr(struct vfsmount *mnt, | |||
| 1302 | stat->blksize = osb->s_clustersize; | 1276 | stat->blksize = osb->s_clustersize; |
| 1303 | 1277 | ||
| 1304 | bail: | 1278 | bail: |
| 1305 | mlog_exit(err); | ||
| 1306 | |||
| 1307 | return err; | 1279 | return err; |
| 1308 | } | 1280 | } |
| 1309 | 1281 | ||
| @@ -1314,8 +1286,6 @@ int ocfs2_permission(struct inode *inode, int mask, unsigned int flags) | |||
| 1314 | if (flags & IPERM_FLAG_RCU) | 1286 | if (flags & IPERM_FLAG_RCU) |
| 1315 | return -ECHILD; | 1287 | return -ECHILD; |
| 1316 | 1288 | ||
| 1317 | mlog_entry_void(); | ||
| 1318 | |||
| 1319 | ret = ocfs2_inode_lock(inode, NULL, 0); | 1289 | ret = ocfs2_inode_lock(inode, NULL, 0); |
| 1320 | if (ret) { | 1290 | if (ret) { |
| 1321 | if (ret != -ENOENT) | 1291 | if (ret != -ENOENT) |
| @@ -1327,7 +1297,6 @@ int ocfs2_permission(struct inode *inode, int mask, unsigned int flags) | |||
| 1327 | 1297 | ||
| 1328 | ocfs2_inode_unlock(inode, 0); | 1298 | ocfs2_inode_unlock(inode, 0); |
| 1329 | out: | 1299 | out: |
| 1330 | mlog_exit(ret); | ||
| 1331 | return ret; | 1300 | return ret; |
| 1332 | } | 1301 | } |
| 1333 | 1302 | ||
| @@ -1339,8 +1308,9 @@ static int __ocfs2_write_remove_suid(struct inode *inode, | |||
| 1339 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 1308 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
| 1340 | struct ocfs2_dinode *di; | 1309 | struct ocfs2_dinode *di; |
| 1341 | 1310 | ||
| 1342 | mlog_entry("(Inode %llu, mode 0%o)\n", | 1311 | trace_ocfs2_write_remove_suid( |
| 1343 | (unsigned long long)OCFS2_I(inode)->ip_blkno, inode->i_mode); | 1312 | (unsigned long long)OCFS2_I(inode)->ip_blkno, |
| 1313 | inode->i_mode); | ||
| 1344 | 1314 | ||
| 1345 | handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS); | 1315 | handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS); |
| 1346 | if (IS_ERR(handle)) { | 1316 | if (IS_ERR(handle)) { |
| @@ -1368,7 +1338,6 @@ static int __ocfs2_write_remove_suid(struct inode *inode, | |||
| 1368 | out_trans: | 1338 | out_trans: |
| 1369 | ocfs2_commit_trans(osb, handle); | 1339 | ocfs2_commit_trans(osb, handle); |
| 1370 | out: | 1340 | out: |
| 1371 | mlog_exit(ret); | ||
| 1372 | return ret; | 1341 | return ret; |
| 1373 | } | 1342 | } |
| 1374 | 1343 | ||
| @@ -1547,8 +1516,9 @@ static int ocfs2_zero_partial_clusters(struct inode *inode, | |||
| 1547 | * partial clusters here. There's no need to worry about | 1516 | * partial clusters here. There's no need to worry about |
| 1548 | * physical allocation - the zeroing code knows to skip holes. | 1517 | * physical allocation - the zeroing code knows to skip holes. |
| 1549 | */ | 1518 | */ |
| 1550 | mlog(0, "byte start: %llu, end: %llu\n", | 1519 | trace_ocfs2_zero_partial_clusters( |
| 1551 | (unsigned long long)start, (unsigned long long)end); | 1520 | (unsigned long long)OCFS2_I(inode)->ip_blkno, |
| 1521 | (unsigned long long)start, (unsigned long long)end); | ||
| 1552 | 1522 | ||
| 1553 | /* | 1523 | /* |
| 1554 | * If both edges are on a cluster boundary then there's no | 1524 | * If both edges are on a cluster boundary then there's no |
| @@ -1572,8 +1542,8 @@ static int ocfs2_zero_partial_clusters(struct inode *inode, | |||
| 1572 | if (tmpend > end) | 1542 | if (tmpend > end) |
| 1573 | tmpend = end; | 1543 | tmpend = end; |
| 1574 | 1544 | ||
| 1575 | mlog(0, "1st range: start: %llu, tmpend: %llu\n", | 1545 | trace_ocfs2_zero_partial_clusters_range1((unsigned long long)start, |
| 1576 | (unsigned long long)start, (unsigned long long)tmpend); | 1546 | (unsigned long long)tmpend); |
| 1577 | 1547 | ||
| 1578 | ret = ocfs2_zero_range_for_truncate(inode, handle, start, tmpend); | 1548 | ret = ocfs2_zero_range_for_truncate(inode, handle, start, tmpend); |
| 1579 | if (ret) | 1549 | if (ret) |
| @@ -1587,8 +1557,8 @@ static int ocfs2_zero_partial_clusters(struct inode *inode, | |||
| 1587 | */ | 1557 | */ |
| 1588 | start = end & ~(osb->s_clustersize - 1); | 1558 | start = end & ~(osb->s_clustersize - 1); |
| 1589 | 1559 | ||
| 1590 | mlog(0, "2nd range: start: %llu, end: %llu\n", | 1560 | trace_ocfs2_zero_partial_clusters_range2( |
| 1591 | (unsigned long long)start, (unsigned long long)end); | 1561 | (unsigned long long)start, (unsigned long long)end); |
| 1592 | 1562 | ||
| 1593 | ret = ocfs2_zero_range_for_truncate(inode, handle, start, end); | 1563 | ret = ocfs2_zero_range_for_truncate(inode, handle, start, end); |
| 1594 | if (ret) | 1564 | if (ret) |
| @@ -1688,6 +1658,11 @@ static int ocfs2_remove_inode_range(struct inode *inode, | |||
| 1688 | ocfs2_init_dinode_extent_tree(&et, INODE_CACHE(inode), di_bh); | 1658 | ocfs2_init_dinode_extent_tree(&et, INODE_CACHE(inode), di_bh); |
| 1689 | ocfs2_init_dealloc_ctxt(&dealloc); | 1659 | ocfs2_init_dealloc_ctxt(&dealloc); |
| 1690 | 1660 | ||
| 1661 | trace_ocfs2_remove_inode_range( | ||
| 1662 | (unsigned long long)OCFS2_I(inode)->ip_blkno, | ||
| 1663 | (unsigned long long)byte_start, | ||
| 1664 | (unsigned long long)byte_len); | ||
| 1665 | |||
| 1691 | if (byte_len == 0) | 1666 | if (byte_len == 0) |
| 1692 | return 0; | 1667 | return 0; |
| 1693 | 1668 | ||
| @@ -1734,11 +1709,6 @@ static int ocfs2_remove_inode_range(struct inode *inode, | |||
| 1734 | trunc_end = (byte_start + byte_len) >> osb->s_clustersize_bits; | 1709 | trunc_end = (byte_start + byte_len) >> osb->s_clustersize_bits; |
| 1735 | cluster_in_el = trunc_end; | 1710 | cluster_in_el = trunc_end; |
| 1736 | 1711 | ||
| 1737 | mlog(0, "Inode: %llu, start: %llu, len: %llu, cstart: %u, cend: %u\n", | ||
| 1738 | (unsigned long long)OCFS2_I(inode)->ip_blkno, | ||
| 1739 | (unsigned long long)byte_start, | ||
| 1740 | (unsigned long long)byte_len, trunc_start, trunc_end); | ||
| 1741 | |||
| 1742 | ret = ocfs2_zero_partial_clusters(inode, byte_start, byte_len); | 1712 | ret = ocfs2_zero_partial_clusters(inode, byte_start, byte_len); |
| 1743 | if (ret) { | 1713 | if (ret) { |
| 1744 | mlog_errno(ret); | 1714 | mlog_errno(ret); |
| @@ -2093,7 +2063,7 @@ static int ocfs2_prepare_inode_for_write(struct file *file, | |||
| 2093 | int ret = 0, meta_level = 0; | 2063 | int ret = 0, meta_level = 0; |
| 2094 | struct dentry *dentry = file->f_path.dentry; | 2064 | struct dentry *dentry = file->f_path.dentry; |
| 2095 | struct inode *inode = dentry->d_inode; | 2065 | struct inode *inode = dentry->d_inode; |
| 2096 | loff_t saved_pos, end; | 2066 | loff_t saved_pos = 0, end; |
| 2097 | 2067 | ||
| 2098 | /* | 2068 | /* |
| 2099 | * We start with a read level meta lock and only jump to an ex | 2069 | * We start with a read level meta lock and only jump to an ex |
| @@ -2132,12 +2102,10 @@ static int ocfs2_prepare_inode_for_write(struct file *file, | |||
| 2132 | 2102 | ||
| 2133 | /* work on a copy of ppos until we're sure that we won't have | 2103 | /* work on a copy of ppos until we're sure that we won't have |
| 2134 | * to recalculate it due to relocking. */ | 2104 | * to recalculate it due to relocking. */ |
| 2135 | if (appending) { | 2105 | if (appending) |
| 2136 | saved_pos = i_size_read(inode); | 2106 | saved_pos = i_size_read(inode); |
| 2137 | mlog(0, "O_APPEND: inode->i_size=%llu\n", saved_pos); | 2107 | else |
| 2138 | } else { | ||
| 2139 | saved_pos = *ppos; | 2108 | saved_pos = *ppos; |
| 2140 | } | ||
| 2141 | 2109 | ||
| 2142 | end = saved_pos + count; | 2110 | end = saved_pos + count; |
| 2143 | 2111 | ||
| @@ -2208,6 +2176,10 @@ static int ocfs2_prepare_inode_for_write(struct file *file, | |||
| 2208 | *ppos = saved_pos; | 2176 | *ppos = saved_pos; |
| 2209 | 2177 | ||
| 2210 | out_unlock: | 2178 | out_unlock: |
| 2179 | trace_ocfs2_prepare_inode_for_write(OCFS2_I(inode)->ip_blkno, | ||
| 2180 | saved_pos, appending, count, | ||
| 2181 | direct_io, has_refcount); | ||
| 2182 | |||
| 2211 | if (meta_level >= 0) | 2183 | if (meta_level >= 0) |
| 2212 | ocfs2_inode_unlock(inode, meta_level); | 2184 | ocfs2_inode_unlock(inode, meta_level); |
| 2213 | 2185 | ||
| @@ -2233,10 +2205,11 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb, | |||
| 2233 | int full_coherency = !(osb->s_mount_opt & | 2205 | int full_coherency = !(osb->s_mount_opt & |
| 2234 | OCFS2_MOUNT_COHERENCY_BUFFERED); | 2206 | OCFS2_MOUNT_COHERENCY_BUFFERED); |
| 2235 | 2207 | ||
| 2236 | mlog_entry("(0x%p, %u, '%.*s')\n", file, | 2208 | trace_ocfs2_file_aio_write(inode, file, file->f_path.dentry, |
| 2237 | (unsigned int)nr_segs, | 2209 | (unsigned long long)OCFS2_I(inode)->ip_blkno, |
| 2238 | file->f_path.dentry->d_name.len, | 2210 | file->f_path.dentry->d_name.len, |
| 2239 | file->f_path.dentry->d_name.name); | 2211 | file->f_path.dentry->d_name.name, |
| 2212 | (unsigned int)nr_segs); | ||
| 2240 | 2213 | ||
| 2241 | if (iocb->ki_left == 0) | 2214 | if (iocb->ki_left == 0) |
| 2242 | return 0; | 2215 | return 0; |
| @@ -2402,7 +2375,6 @@ out_sems: | |||
| 2402 | 2375 | ||
| 2403 | if (written) | 2376 | if (written) |
| 2404 | ret = written; | 2377 | ret = written; |
| 2405 | mlog_exit(ret); | ||
| 2406 | return ret; | 2378 | return ret; |
| 2407 | } | 2379 | } |
| 2408 | 2380 | ||
| @@ -2438,10 +2410,11 @@ static ssize_t ocfs2_file_splice_write(struct pipe_inode_info *pipe, | |||
| 2438 | .u.file = out, | 2410 | .u.file = out, |
| 2439 | }; | 2411 | }; |
| 2440 | 2412 | ||
| 2441 | mlog_entry("(0x%p, 0x%p, %u, '%.*s')\n", out, pipe, | 2413 | |
| 2442 | (unsigned int)len, | 2414 | trace_ocfs2_file_splice_write(inode, out, out->f_path.dentry, |
| 2443 | out->f_path.dentry->d_name.len, | 2415 | (unsigned long long)OCFS2_I(inode)->ip_blkno, |
| 2444 | out->f_path.dentry->d_name.name); | 2416 | out->f_path.dentry->d_name.len, |
| 2417 | out->f_path.dentry->d_name.name, len); | ||
| 2445 | 2418 | ||
| 2446 | if (pipe->inode) | 2419 | if (pipe->inode) |
| 2447 | mutex_lock_nested(&pipe->inode->i_mutex, I_MUTEX_PARENT); | 2420 | mutex_lock_nested(&pipe->inode->i_mutex, I_MUTEX_PARENT); |
| @@ -2485,7 +2458,6 @@ static ssize_t ocfs2_file_splice_write(struct pipe_inode_info *pipe, | |||
| 2485 | balance_dirty_pages_ratelimited_nr(mapping, nr_pages); | 2458 | balance_dirty_pages_ratelimited_nr(mapping, nr_pages); |
| 2486 | } | 2459 | } |
| 2487 | 2460 | ||
| 2488 | mlog_exit(ret); | ||
| 2489 | return ret; | 2461 | return ret; |
| 2490 | } | 2462 | } |
| 2491 | 2463 | ||
| @@ -2498,10 +2470,10 @@ static ssize_t ocfs2_file_splice_read(struct file *in, | |||
| 2498 | int ret = 0, lock_level = 0; | 2470 | int ret = 0, lock_level = 0; |
| 2499 | struct inode *inode = in->f_path.dentry->d_inode; | 2471 | struct inode *inode = in->f_path.dentry->d_inode; |
| 2500 | 2472 | ||
| 2501 | mlog_entry("(0x%p, 0x%p, %u, '%.*s')\n", in, pipe, | 2473 | trace_ocfs2_file_splice_read(inode, in, in->f_path.dentry, |
| 2502 | (unsigned int)len, | 2474 | (unsigned long long)OCFS2_I(inode)->ip_blkno, |
| 2503 | in->f_path.dentry->d_name.len, | 2475 | in->f_path.dentry->d_name.len, |
| 2504 | in->f_path.dentry->d_name.name); | 2476 | in->f_path.dentry->d_name.name, len); |
| 2505 | 2477 | ||
| 2506 | /* | 2478 | /* |
| 2507 | * See the comment in ocfs2_file_aio_read() | 2479 | * See the comment in ocfs2_file_aio_read() |
| @@ -2516,7 +2488,6 @@ static ssize_t ocfs2_file_splice_read(struct file *in, | |||
| 2516 | ret = generic_file_splice_read(in, ppos, pipe, len, flags); | 2488 | ret = generic_file_splice_read(in, ppos, pipe, len, flags); |
| 2517 | 2489 | ||
| 2518 | bail: | 2490 | bail: |
| 2519 | mlog_exit(ret); | ||
| 2520 | return ret; | 2491 | return ret; |
| 2521 | } | 2492 | } |
| 2522 | 2493 | ||
| @@ -2529,10 +2500,11 @@ static ssize_t ocfs2_file_aio_read(struct kiocb *iocb, | |||
| 2529 | struct file *filp = iocb->ki_filp; | 2500 | struct file *filp = iocb->ki_filp; |
| 2530 | struct inode *inode = filp->f_path.dentry->d_inode; | 2501 | struct inode *inode = filp->f_path.dentry->d_inode; |
| 2531 | 2502 | ||
| 2532 | mlog_entry("(0x%p, %u, '%.*s')\n", filp, | 2503 | trace_ocfs2_file_aio_read(inode, filp, filp->f_path.dentry, |
| 2533 | (unsigned int)nr_segs, | 2504 | (unsigned long long)OCFS2_I(inode)->ip_blkno, |
| 2534 | filp->f_path.dentry->d_name.len, | 2505 | filp->f_path.dentry->d_name.len, |
| 2535 | filp->f_path.dentry->d_name.name); | 2506 | filp->f_path.dentry->d_name.name, nr_segs); |
| 2507 | |||
| 2536 | 2508 | ||
| 2537 | if (!inode) { | 2509 | if (!inode) { |
| 2538 | ret = -EINVAL; | 2510 | ret = -EINVAL; |
| @@ -2578,8 +2550,7 @@ static ssize_t ocfs2_file_aio_read(struct kiocb *iocb, | |||
| 2578 | ocfs2_inode_unlock(inode, lock_level); | 2550 | ocfs2_inode_unlock(inode, lock_level); |
| 2579 | 2551 | ||
| 2580 | ret = generic_file_aio_read(iocb, iov, nr_segs, iocb->ki_pos); | 2552 | ret = generic_file_aio_read(iocb, iov, nr_segs, iocb->ki_pos); |
| 2581 | if (ret == -EINVAL) | 2553 | trace_generic_file_aio_read_ret(ret); |
| 2582 | mlog(0, "generic_file_aio_read returned -EINVAL\n"); | ||
| 2583 | 2554 | ||
| 2584 | /* buffered aio wouldn't have proper lock coverage today */ | 2555 | /* buffered aio wouldn't have proper lock coverage today */ |
| 2585 | BUG_ON(ret == -EIOCBQUEUED && !(filp->f_flags & O_DIRECT)); | 2556 | BUG_ON(ret == -EIOCBQUEUED && !(filp->f_flags & O_DIRECT)); |
| @@ -2597,7 +2568,6 @@ bail: | |||
| 2597 | } | 2568 | } |
| 2598 | if (rw_level != -1) | 2569 | if (rw_level != -1) |
| 2599 | ocfs2_rw_unlock(inode, rw_level); | 2570 | ocfs2_rw_unlock(inode, rw_level); |
| 2600 | mlog_exit(ret); | ||
| 2601 | 2571 | ||
| 2602 | return ret; | 2572 | return ret; |
| 2603 | } | 2573 | } |
diff --git a/fs/ocfs2/heartbeat.c b/fs/ocfs2/heartbeat.c index 1aa863dd901..d8208b20dc5 100644 --- a/fs/ocfs2/heartbeat.c +++ b/fs/ocfs2/heartbeat.c | |||
| @@ -28,7 +28,6 @@ | |||
| 28 | #include <linux/types.h> | 28 | #include <linux/types.h> |
| 29 | #include <linux/highmem.h> | 29 | #include <linux/highmem.h> |
| 30 | 30 | ||
| 31 | #define MLOG_MASK_PREFIX ML_SUPER | ||
| 32 | #include <cluster/masklog.h> | 31 | #include <cluster/masklog.h> |
| 33 | 32 | ||
| 34 | #include "ocfs2.h" | 33 | #include "ocfs2.h" |
| @@ -37,6 +36,7 @@ | |||
| 37 | #include "heartbeat.h" | 36 | #include "heartbeat.h" |
| 38 | #include "inode.h" | 37 | #include "inode.h" |
| 39 | #include "journal.h" | 38 | #include "journal.h" |
| 39 | #include "ocfs2_trace.h" | ||
| 40 | 40 | ||
| 41 | #include "buffer_head_io.h" | 41 | #include "buffer_head_io.h" |
| 42 | 42 | ||
| @@ -66,7 +66,7 @@ void ocfs2_do_node_down(int node_num, void *data) | |||
| 66 | 66 | ||
| 67 | BUG_ON(osb->node_num == node_num); | 67 | BUG_ON(osb->node_num == node_num); |
| 68 | 68 | ||
| 69 | mlog(0, "ocfs2: node down event for %d\n", node_num); | 69 | trace_ocfs2_do_node_down(node_num); |
| 70 | 70 | ||
| 71 | if (!osb->cconn) { | 71 | if (!osb->cconn) { |
| 72 | /* | 72 | /* |
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c index 4068c6c4c6f..177d3a6c2a5 100644 --- a/fs/ocfs2/inode.c +++ b/fs/ocfs2/inode.c | |||
| @@ -31,7 +31,6 @@ | |||
| 31 | 31 | ||
| 32 | #include <asm/byteorder.h> | 32 | #include <asm/byteorder.h> |
| 33 | 33 | ||
| 34 | #define MLOG_MASK_PREFIX ML_INODE | ||
| 35 | #include <cluster/masklog.h> | 34 | #include <cluster/masklog.h> |
| 36 | 35 | ||
| 37 | #include "ocfs2.h" | 36 | #include "ocfs2.h" |
| @@ -53,6 +52,7 @@ | |||
| 53 | #include "uptodate.h" | 52 | #include "uptodate.h" |
| 54 | #include "xattr.h" | 53 | #include "xattr.h" |
| 55 | #include "refcounttree.h" | 54 | #include "refcounttree.h" |
| 55 | #include "ocfs2_trace.h" | ||
| 56 | 56 | ||
| 57 | #include "buffer_head_io.h" | 57 | #include "buffer_head_io.h" |
| 58 | 58 | ||
| @@ -131,7 +131,8 @@ struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno, unsigned flags, | |||
| 131 | struct super_block *sb = osb->sb; | 131 | struct super_block *sb = osb->sb; |
| 132 | struct ocfs2_find_inode_args args; | 132 | struct ocfs2_find_inode_args args; |
| 133 | 133 | ||
| 134 | mlog_entry("(blkno = %llu)\n", (unsigned long long)blkno); | 134 | trace_ocfs2_iget_begin((unsigned long long)blkno, flags, |
| 135 | sysfile_type); | ||
| 135 | 136 | ||
| 136 | /* Ok. By now we've either got the offsets passed to us by the | 137 | /* Ok. By now we've either got the offsets passed to us by the |
| 137 | * caller, or we just pulled them off the bh. Lets do some | 138 | * caller, or we just pulled them off the bh. Lets do some |
| @@ -152,16 +153,16 @@ struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno, unsigned flags, | |||
| 152 | /* inode was *not* in the inode cache. 2.6.x requires | 153 | /* inode was *not* in the inode cache. 2.6.x requires |
| 153 | * us to do our own read_inode call and unlock it | 154 | * us to do our own read_inode call and unlock it |
| 154 | * afterwards. */ | 155 | * afterwards. */ |
| 155 | if (inode && inode->i_state & I_NEW) { | ||
| 156 | mlog(0, "Inode was not in inode cache, reading it.\n"); | ||
| 157 | ocfs2_read_locked_inode(inode, &args); | ||
| 158 | unlock_new_inode(inode); | ||
| 159 | } | ||
| 160 | if (inode == NULL) { | 156 | if (inode == NULL) { |
| 161 | inode = ERR_PTR(-ENOMEM); | 157 | inode = ERR_PTR(-ENOMEM); |
| 162 | mlog_errno(PTR_ERR(inode)); | 158 | mlog_errno(PTR_ERR(inode)); |
| 163 | goto bail; | 159 | goto bail; |
| 164 | } | 160 | } |
| 161 | trace_ocfs2_iget5_locked(inode->i_state); | ||
| 162 | if (inode->i_state & I_NEW) { | ||
| 163 | ocfs2_read_locked_inode(inode, &args); | ||
| 164 | unlock_new_inode(inode); | ||
| 165 | } | ||
| 165 | if (is_bad_inode(inode)) { | 166 | if (is_bad_inode(inode)) { |
| 166 | iput(inode); | 167 | iput(inode); |
| 167 | inode = ERR_PTR(-ESTALE); | 168 | inode = ERR_PTR(-ESTALE); |
| @@ -170,9 +171,8 @@ struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno, unsigned flags, | |||
| 170 | 171 | ||
| 171 | bail: | 172 | bail: |
| 172 | if (!IS_ERR(inode)) { | 173 | if (!IS_ERR(inode)) { |
| 173 | mlog(0, "returning inode with number %llu\n", | 174 | trace_ocfs2_iget_end(inode, |
| 174 | (unsigned long long)OCFS2_I(inode)->ip_blkno); | 175 | (unsigned long long)OCFS2_I(inode)->ip_blkno); |
| 175 | mlog_exit_ptr(inode); | ||
| 176 | } | 176 | } |
| 177 | 177 | ||
| 178 | return inode; | 178 | return inode; |
| @@ -192,18 +192,17 @@ static int ocfs2_find_actor(struct inode *inode, void *opaque) | |||
| 192 | struct ocfs2_inode_info *oi = OCFS2_I(inode); | 192 | struct ocfs2_inode_info *oi = OCFS2_I(inode); |
| 193 | int ret = 0; | 193 | int ret = 0; |
| 194 | 194 | ||
| 195 | mlog_entry("(0x%p, %lu, 0x%p)\n", inode, inode->i_ino, opaque); | ||
| 196 | |||
| 197 | args = opaque; | 195 | args = opaque; |
| 198 | 196 | ||
| 199 | mlog_bug_on_msg(!inode, "No inode in find actor!\n"); | 197 | mlog_bug_on_msg(!inode, "No inode in find actor!\n"); |
| 200 | 198 | ||
| 199 | trace_ocfs2_find_actor(inode, inode->i_ino, opaque, args->fi_blkno); | ||
| 200 | |||
| 201 | if (oi->ip_blkno != args->fi_blkno) | 201 | if (oi->ip_blkno != args->fi_blkno) |
| 202 | goto bail; | 202 | goto bail; |
| 203 | 203 | ||
| 204 | ret = 1; | 204 | ret = 1; |
| 205 | bail: | 205 | bail: |
| 206 | mlog_exit(ret); | ||
| 207 | return ret; | 206 | return ret; |
| 208 | } | 207 | } |
| 209 | 208 | ||
| @@ -218,8 +217,6 @@ static int ocfs2_init_locked_inode(struct inode *inode, void *opaque) | |||
| 218 | static struct lock_class_key ocfs2_quota_ip_alloc_sem_key, | 217 | static struct lock_class_key ocfs2_quota_ip_alloc_sem_key, |
| 219 | ocfs2_file_ip_alloc_sem_key; | 218 | ocfs2_file_ip_alloc_sem_key; |
| 220 | 219 | ||
| 221 | mlog_entry("inode = %p, opaque = %p\n", inode, opaque); | ||
| 222 | |||
| 223 | inode->i_ino = args->fi_ino; | 220 | inode->i_ino = args->fi_ino; |
| 224 | OCFS2_I(inode)->ip_blkno = args->fi_blkno; | 221 | OCFS2_I(inode)->ip_blkno = args->fi_blkno; |
| 225 | if (args->fi_sysfile_type != 0) | 222 | if (args->fi_sysfile_type != 0) |
| @@ -235,7 +232,6 @@ static int ocfs2_init_locked_inode(struct inode *inode, void *opaque) | |||
| 235 | lockdep_set_class(&OCFS2_I(inode)->ip_alloc_sem, | 232 | lockdep_set_class(&OCFS2_I(inode)->ip_alloc_sem, |
| 236 | &ocfs2_file_ip_alloc_sem_key); | 233 | &ocfs2_file_ip_alloc_sem_key); |
| 237 | 234 | ||
| 238 | mlog_exit(0); | ||
| 239 | return 0; | 235 | return 0; |
| 240 | } | 236 | } |
| 241 | 237 | ||
| @@ -246,9 +242,6 @@ void ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe, | |||
| 246 | struct ocfs2_super *osb; | 242 | struct ocfs2_super *osb; |
| 247 | int use_plocks = 1; | 243 | int use_plocks = 1; |
| 248 | 244 | ||
| 249 | mlog_entry("(0x%p, size:%llu)\n", inode, | ||
| 250 | (unsigned long long)le64_to_cpu(fe->i_size)); | ||
| 251 | |||
| 252 | sb = inode->i_sb; | 245 | sb = inode->i_sb; |
| 253 | osb = OCFS2_SB(sb); | 246 | osb = OCFS2_SB(sb); |
| 254 | 247 | ||
| @@ -300,20 +293,20 @@ void ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe, | |||
| 300 | 293 | ||
| 301 | inode->i_nlink = ocfs2_read_links_count(fe); | 294 | inode->i_nlink = ocfs2_read_links_count(fe); |
| 302 | 295 | ||
| 296 | trace_ocfs2_populate_inode(OCFS2_I(inode)->ip_blkno, | ||
| 297 | le32_to_cpu(fe->i_flags)); | ||
| 303 | if (fe->i_flags & cpu_to_le32(OCFS2_SYSTEM_FL)) { | 298 | if (fe->i_flags & cpu_to_le32(OCFS2_SYSTEM_FL)) { |
| 304 | OCFS2_I(inode)->ip_flags |= OCFS2_INODE_SYSTEM_FILE; | 299 | OCFS2_I(inode)->ip_flags |= OCFS2_INODE_SYSTEM_FILE; |
| 305 | inode->i_flags |= S_NOQUOTA; | 300 | inode->i_flags |= S_NOQUOTA; |
| 306 | } | 301 | } |
| 307 | 302 | ||
| 308 | if (fe->i_flags & cpu_to_le32(OCFS2_LOCAL_ALLOC_FL)) { | 303 | if (fe->i_flags & cpu_to_le32(OCFS2_LOCAL_ALLOC_FL)) { |
| 309 | OCFS2_I(inode)->ip_flags |= OCFS2_INODE_BITMAP; | 304 | OCFS2_I(inode)->ip_flags |= OCFS2_INODE_BITMAP; |
| 310 | mlog(0, "local alloc inode: i_ino=%lu\n", inode->i_ino); | ||
| 311 | } else if (fe->i_flags & cpu_to_le32(OCFS2_BITMAP_FL)) { | 305 | } else if (fe->i_flags & cpu_to_le32(OCFS2_BITMAP_FL)) { |
| 312 | OCFS2_I(inode)->ip_flags |= OCFS2_INODE_BITMAP; | 306 | OCFS2_I(inode)->ip_flags |= OCFS2_INODE_BITMAP; |
| 313 | } else if (fe->i_flags & cpu_to_le32(OCFS2_QUOTA_FL)) { | 307 | } else if (fe->i_flags & cpu_to_le32(OCFS2_QUOTA_FL)) { |
| 314 | inode->i_flags |= S_NOQUOTA; | 308 | inode->i_flags |= S_NOQUOTA; |
| 315 | } else if (fe->i_flags & cpu_to_le32(OCFS2_SUPER_BLOCK_FL)) { | 309 | } else if (fe->i_flags & cpu_to_le32(OCFS2_SUPER_BLOCK_FL)) { |
| 316 | mlog(0, "superblock inode: i_ino=%lu\n", inode->i_ino); | ||
| 317 | /* we can't actually hit this as read_inode can't | 310 | /* we can't actually hit this as read_inode can't |
| 318 | * handle superblocks today ;-) */ | 311 | * handle superblocks today ;-) */ |
| 319 | BUG(); | 312 | BUG(); |
| @@ -381,7 +374,6 @@ void ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe, | |||
| 381 | if (S_ISDIR(inode->i_mode)) | 374 | if (S_ISDIR(inode->i_mode)) |
| 382 | ocfs2_resv_set_type(&OCFS2_I(inode)->ip_la_data_resv, | 375 | ocfs2_resv_set_type(&OCFS2_I(inode)->ip_la_data_resv, |
| 383 | OCFS2_RESV_FLAG_DIR); | 376 | OCFS2_RESV_FLAG_DIR); |
| 384 | mlog_exit_void(); | ||
| 385 | } | 377 | } |
| 386 | 378 | ||
| 387 | static int ocfs2_read_locked_inode(struct inode *inode, | 379 | static int ocfs2_read_locked_inode(struct inode *inode, |
| @@ -394,8 +386,6 @@ static int ocfs2_read_locked_inode(struct inode *inode, | |||
| 394 | int status, can_lock; | 386 | int status, can_lock; |
| 395 | u32 generation = 0; | 387 | u32 generation = 0; |
| 396 | 388 | ||
| 397 | mlog_entry("(0x%p, 0x%p)\n", inode, args); | ||
| 398 | |||
| 399 | status = -EINVAL; | 389 | status = -EINVAL; |
| 400 | if (inode == NULL || inode->i_sb == NULL) { | 390 | if (inode == NULL || inode->i_sb == NULL) { |
| 401 | mlog(ML_ERROR, "bad inode\n"); | 391 | mlog(ML_ERROR, "bad inode\n"); |
| @@ -443,6 +433,9 @@ static int ocfs2_read_locked_inode(struct inode *inode, | |||
| 443 | && !(args->fi_flags & OCFS2_FI_FLAG_ORPHAN_RECOVERY) | 433 | && !(args->fi_flags & OCFS2_FI_FLAG_ORPHAN_RECOVERY) |
| 444 | && !ocfs2_mount_local(osb); | 434 | && !ocfs2_mount_local(osb); |
| 445 | 435 | ||
| 436 | trace_ocfs2_read_locked_inode( | ||
| 437 | (unsigned long long)OCFS2_I(inode)->ip_blkno, can_lock); | ||
| 438 | |||
| 446 | /* | 439 | /* |
| 447 | * To maintain backwards compatibility with older versions of | 440 | * To maintain backwards compatibility with older versions of |
| 448 | * ocfs2-tools, we still store the generation value for system | 441 | * ocfs2-tools, we still store the generation value for system |
| @@ -534,7 +527,6 @@ bail: | |||
| 534 | if (args && bh) | 527 | if (args && bh) |
| 535 | brelse(bh); | 528 | brelse(bh); |
| 536 | 529 | ||
| 537 | mlog_exit(status); | ||
| 538 | return status; | 530 | return status; |
| 539 | } | 531 | } |
| 540 | 532 | ||
| @@ -551,8 +543,6 @@ static int ocfs2_truncate_for_delete(struct ocfs2_super *osb, | |||
| 551 | struct ocfs2_dinode *fe; | 543 | struct ocfs2_dinode *fe; |
| 552 | handle_t *handle = NULL; | 544 | handle_t *handle = NULL; |
| 553 | 545 | ||
| 554 | mlog_entry_void(); | ||
| 555 | |||
| 556 | fe = (struct ocfs2_dinode *) fe_bh->b_data; | 546 | fe = (struct ocfs2_dinode *) fe_bh->b_data; |
| 557 | 547 | ||
| 558 | /* | 548 | /* |
| @@ -600,7 +590,6 @@ static int ocfs2_truncate_for_delete(struct ocfs2_super *osb, | |||
| 600 | out: | 590 | out: |
| 601 | if (handle) | 591 | if (handle) |
| 602 | ocfs2_commit_trans(osb, handle); | 592 | ocfs2_commit_trans(osb, handle); |
| 603 | mlog_exit(status); | ||
| 604 | return status; | 593 | return status; |
| 605 | } | 594 | } |
| 606 | 595 | ||
| @@ -696,8 +685,6 @@ static int ocfs2_check_orphan_recovery_state(struct ocfs2_super *osb, | |||
| 696 | 685 | ||
| 697 | spin_lock(&osb->osb_lock); | 686 | spin_lock(&osb->osb_lock); |
| 698 | if (ocfs2_node_map_test_bit(osb, &osb->osb_recovering_orphan_dirs, slot)) { | 687 | if (ocfs2_node_map_test_bit(osb, &osb->osb_recovering_orphan_dirs, slot)) { |
| 699 | mlog(0, "Recovery is happening on orphan dir %d, will skip " | ||
| 700 | "this inode\n", slot); | ||
| 701 | ret = -EDEADLK; | 688 | ret = -EDEADLK; |
| 702 | goto out; | 689 | goto out; |
| 703 | } | 690 | } |
| @@ -706,6 +693,7 @@ static int ocfs2_check_orphan_recovery_state(struct ocfs2_super *osb, | |||
| 706 | osb->osb_orphan_wipes[slot]++; | 693 | osb->osb_orphan_wipes[slot]++; |
| 707 | out: | 694 | out: |
| 708 | spin_unlock(&osb->osb_lock); | 695 | spin_unlock(&osb->osb_lock); |
| 696 | trace_ocfs2_check_orphan_recovery_state(slot, ret); | ||
| 709 | return ret; | 697 | return ret; |
| 710 | } | 698 | } |
| 711 | 699 | ||
| @@ -816,6 +804,10 @@ static int ocfs2_inode_is_valid_to_delete(struct inode *inode) | |||
| 816 | struct ocfs2_inode_info *oi = OCFS2_I(inode); | 804 | struct ocfs2_inode_info *oi = OCFS2_I(inode); |
| 817 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 805 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
| 818 | 806 | ||
| 807 | trace_ocfs2_inode_is_valid_to_delete(current, osb->dc_task, | ||
| 808 | (unsigned long long)oi->ip_blkno, | ||
| 809 | oi->ip_flags); | ||
| 810 | |||
| 819 | /* We shouldn't be getting here for the root directory | 811 | /* We shouldn't be getting here for the root directory |
| 820 | * inode.. */ | 812 | * inode.. */ |
| 821 | if (inode == osb->root_inode) { | 813 | if (inode == osb->root_inode) { |
| @@ -828,11 +820,8 @@ static int ocfs2_inode_is_valid_to_delete(struct inode *inode) | |||
| 828 | * have to skip deleting this guy. That's OK though because | 820 | * have to skip deleting this guy. That's OK though because |
| 829 | * the node who's doing the actual deleting should handle it | 821 | * the node who's doing the actual deleting should handle it |
| 830 | * anyway. */ | 822 | * anyway. */ |
| 831 | if (current == osb->dc_task) { | 823 | if (current == osb->dc_task) |
| 832 | mlog(0, "Skipping delete of %lu because we're currently " | ||
| 833 | "in downconvert\n", inode->i_ino); | ||
| 834 | goto bail; | 824 | goto bail; |
| 835 | } | ||
| 836 | 825 | ||
| 837 | spin_lock(&oi->ip_lock); | 826 | spin_lock(&oi->ip_lock); |
| 838 | /* OCFS2 *never* deletes system files. This should technically | 827 | /* OCFS2 *never* deletes system files. This should technically |
| @@ -847,11 +836,8 @@ static int ocfs2_inode_is_valid_to_delete(struct inode *inode) | |||
| 847 | /* If we have allowd wipe of this inode for another node, it | 836 | /* If we have allowd wipe of this inode for another node, it |
| 848 | * will be marked here so we can safely skip it. Recovery will | 837 | * will be marked here so we can safely skip it. Recovery will |
| 849 | * cleanup any inodes we might inadvertantly skip here. */ | 838 | * cleanup any inodes we might inadvertantly skip here. */ |
| 850 | if (oi->ip_flags & OCFS2_INODE_SKIP_DELETE) { | 839 | if (oi->ip_flags & OCFS2_INODE_SKIP_DELETE) |
| 851 | mlog(0, "Skipping delete of %lu because another node " | ||
| 852 | "has done this for us.\n", inode->i_ino); | ||
| 853 | goto bail_unlock; | 840 | goto bail_unlock; |
| 854 | } | ||
| 855 | 841 | ||
| 856 | ret = 1; | 842 | ret = 1; |
| 857 | bail_unlock: | 843 | bail_unlock: |
| @@ -868,28 +854,27 @@ static int ocfs2_query_inode_wipe(struct inode *inode, | |||
| 868 | struct buffer_head *di_bh, | 854 | struct buffer_head *di_bh, |
| 869 | int *wipe) | 855 | int *wipe) |
| 870 | { | 856 | { |
| 871 | int status = 0; | 857 | int status = 0, reason = 0; |
| 872 | struct ocfs2_inode_info *oi = OCFS2_I(inode); | 858 | struct ocfs2_inode_info *oi = OCFS2_I(inode); |
| 873 | struct ocfs2_dinode *di; | 859 | struct ocfs2_dinode *di; |
| 874 | 860 | ||
| 875 | *wipe = 0; | 861 | *wipe = 0; |
| 876 | 862 | ||
| 863 | trace_ocfs2_query_inode_wipe_begin((unsigned long long)oi->ip_blkno, | ||
| 864 | inode->i_nlink); | ||
| 865 | |||
| 877 | /* While we were waiting for the cluster lock in | 866 | /* While we were waiting for the cluster lock in |
| 878 | * ocfs2_delete_inode, another node might have asked to delete | 867 | * ocfs2_delete_inode, another node might have asked to delete |
| 879 | * the inode. Recheck our flags to catch this. */ | 868 | * the inode. Recheck our flags to catch this. */ |
| 880 | if (!ocfs2_inode_is_valid_to_delete(inode)) { | 869 | if (!ocfs2_inode_is_valid_to_delete(inode)) { |
| 881 | mlog(0, "Skipping delete of %llu because flags changed\n", | 870 | reason = 1; |
| 882 | (unsigned long long)oi->ip_blkno); | ||
| 883 | goto bail; | 871 | goto bail; |
| 884 | } | 872 | } |
| 885 | 873 | ||
| 886 | /* Now that we have an up to date inode, we can double check | 874 | /* Now that we have an up to date inode, we can double check |
| 887 | * the link count. */ | 875 | * the link count. */ |
| 888 | if (inode->i_nlink) { | 876 | if (inode->i_nlink) |
| 889 | mlog(0, "Skipping delete of %llu because nlink = %u\n", | ||
| 890 | (unsigned long long)oi->ip_blkno, inode->i_nlink); | ||
| 891 | goto bail; | 877 | goto bail; |
| 892 | } | ||
| 893 | 878 | ||
| 894 | /* Do some basic inode verification... */ | 879 | /* Do some basic inode verification... */ |
| 895 | di = (struct ocfs2_dinode *) di_bh->b_data; | 880 | di = (struct ocfs2_dinode *) di_bh->b_data; |
| @@ -904,9 +889,7 @@ static int ocfs2_query_inode_wipe(struct inode *inode, | |||
| 904 | * ORPHANED_FL not. | 889 | * ORPHANED_FL not. |
| 905 | */ | 890 | */ |
| 906 | if (di->i_dyn_features & cpu_to_le16(OCFS2_HAS_REFCOUNT_FL)) { | 891 | if (di->i_dyn_features & cpu_to_le16(OCFS2_HAS_REFCOUNT_FL)) { |
| 907 | mlog(0, "Reflinked inode %llu is no longer orphaned. " | 892 | reason = 2; |
| 908 | "it shouldn't be deleted\n", | ||
| 909 | (unsigned long long)oi->ip_blkno); | ||
| 910 | goto bail; | 893 | goto bail; |
| 911 | } | 894 | } |
| 912 | 895 | ||
| @@ -943,8 +926,7 @@ static int ocfs2_query_inode_wipe(struct inode *inode, | |||
| 943 | status = ocfs2_try_open_lock(inode, 1); | 926 | status = ocfs2_try_open_lock(inode, 1); |
| 944 | if (status == -EAGAIN) { | 927 | if (status == -EAGAIN) { |
| 945 | status = 0; | 928 | status = 0; |
| 946 | mlog(0, "Skipping delete of %llu because it is in use on " | 929 | reason = 3; |
| 947 | "other nodes\n", (unsigned long long)oi->ip_blkno); | ||
| 948 | goto bail; | 930 | goto bail; |
| 949 | } | 931 | } |
| 950 | if (status < 0) { | 932 | if (status < 0) { |
| @@ -953,11 +935,10 @@ static int ocfs2_query_inode_wipe(struct inode *inode, | |||
| 953 | } | 935 | } |
| 954 | 936 | ||
| 955 | *wipe = 1; | 937 | *wipe = 1; |
| 956 | mlog(0, "Inode %llu is ok to wipe from orphan dir %u\n", | 938 | trace_ocfs2_query_inode_wipe_succ(le16_to_cpu(di->i_orphaned_slot)); |
| 957 | (unsigned long long)oi->ip_blkno, | ||
| 958 | le16_to_cpu(di->i_orphaned_slot)); | ||
| 959 | 939 | ||
| 960 | bail: | 940 | bail: |
| 941 | trace_ocfs2_query_inode_wipe_end(status, reason); | ||
| 961 | return status; | 942 | return status; |
| 962 | } | 943 | } |
| 963 | 944 | ||
| @@ -967,8 +948,8 @@ bail: | |||
| 967 | static void ocfs2_cleanup_delete_inode(struct inode *inode, | 948 | static void ocfs2_cleanup_delete_inode(struct inode *inode, |
| 968 | int sync_data) | 949 | int sync_data) |
| 969 | { | 950 | { |
| 970 | mlog(0, "Cleanup inode %llu, sync = %d\n", | 951 | trace_ocfs2_cleanup_delete_inode( |
| 971 | (unsigned long long)OCFS2_I(inode)->ip_blkno, sync_data); | 952 | (unsigned long long)OCFS2_I(inode)->ip_blkno, sync_data); |
| 972 | if (sync_data) | 953 | if (sync_data) |
| 973 | write_inode_now(inode, 1); | 954 | write_inode_now(inode, 1); |
| 974 | truncate_inode_pages(&inode->i_data, 0); | 955 | truncate_inode_pages(&inode->i_data, 0); |
| @@ -980,15 +961,15 @@ static void ocfs2_delete_inode(struct inode *inode) | |||
| 980 | sigset_t oldset; | 961 | sigset_t oldset; |
| 981 | struct buffer_head *di_bh = NULL; | 962 | struct buffer_head *di_bh = NULL; |
| 982 | 963 | ||
| 983 | mlog_entry("(inode->i_ino = %lu)\n", inode->i_ino); | 964 | trace_ocfs2_delete_inode(inode->i_ino, |
| 965 | (unsigned long long)OCFS2_I(inode)->ip_blkno, | ||
| 966 | is_bad_inode(inode)); | ||
| 984 | 967 | ||
| 985 | /* When we fail in read_inode() we mark inode as bad. The second test | 968 | /* When we fail in read_inode() we mark inode as bad. The second test |
| 986 | * catches the case when inode allocation fails before allocating | 969 | * catches the case when inode allocation fails before allocating |
| 987 | * a block for inode. */ | 970 | * a block for inode. */ |
| 988 | if (is_bad_inode(inode) || !OCFS2_I(inode)->ip_blkno) { | 971 | if (is_bad_inode(inode) || !OCFS2_I(inode)->ip_blkno) |
| 989 | mlog(0, "Skipping delete of bad inode\n"); | ||
| 990 | goto bail; | 972 | goto bail; |
| 991 | } | ||
| 992 | 973 | ||
| 993 | dquot_initialize(inode); | 974 | dquot_initialize(inode); |
| 994 | 975 | ||
| @@ -1080,7 +1061,7 @@ bail_unlock_nfs_sync: | |||
| 1080 | bail_unblock: | 1061 | bail_unblock: |
| 1081 | ocfs2_unblock_signals(&oldset); | 1062 | ocfs2_unblock_signals(&oldset); |
| 1082 | bail: | 1063 | bail: |
| 1083 | mlog_exit_void(); | 1064 | return; |
| 1084 | } | 1065 | } |
| 1085 | 1066 | ||
| 1086 | static void ocfs2_clear_inode(struct inode *inode) | 1067 | static void ocfs2_clear_inode(struct inode *inode) |
| @@ -1088,11 +1069,9 @@ static void ocfs2_clear_inode(struct inode *inode) | |||
| 1088 | int status; | 1069 | int status; |
| 1089 | struct ocfs2_inode_info *oi = OCFS2_I(inode); | 1070 | struct ocfs2_inode_info *oi = OCFS2_I(inode); |
| 1090 | 1071 | ||
| 1091 | mlog_entry_void(); | ||
| 1092 | |||
| 1093 | end_writeback(inode); | 1072 | end_writeback(inode); |
| 1094 | mlog(0, "Clearing inode: %llu, nlink = %u\n", | 1073 | trace_ocfs2_clear_inode((unsigned long long)oi->ip_blkno, |
| 1095 | (unsigned long long)OCFS2_I(inode)->ip_blkno, inode->i_nlink); | 1074 | inode->i_nlink); |
| 1096 | 1075 | ||
| 1097 | mlog_bug_on_msg(OCFS2_SB(inode->i_sb) == NULL, | 1076 | mlog_bug_on_msg(OCFS2_SB(inode->i_sb) == NULL, |
| 1098 | "Inode=%lu\n", inode->i_ino); | 1077 | "Inode=%lu\n", inode->i_ino); |
| @@ -1181,8 +1160,6 @@ static void ocfs2_clear_inode(struct inode *inode) | |||
| 1181 | */ | 1160 | */ |
| 1182 | jbd2_journal_release_jbd_inode(OCFS2_SB(inode->i_sb)->journal->j_journal, | 1161 | jbd2_journal_release_jbd_inode(OCFS2_SB(inode->i_sb)->journal->j_journal, |
| 1183 | &oi->ip_jinode); | 1162 | &oi->ip_jinode); |
| 1184 | |||
| 1185 | mlog_exit_void(); | ||
| 1186 | } | 1163 | } |
| 1187 | 1164 | ||
| 1188 | void ocfs2_evict_inode(struct inode *inode) | 1165 | void ocfs2_evict_inode(struct inode *inode) |
| @@ -1204,17 +1181,14 @@ int ocfs2_drop_inode(struct inode *inode) | |||
| 1204 | struct ocfs2_inode_info *oi = OCFS2_I(inode); | 1181 | struct ocfs2_inode_info *oi = OCFS2_I(inode); |
| 1205 | int res; | 1182 | int res; |
| 1206 | 1183 | ||
| 1207 | mlog_entry_void(); | 1184 | trace_ocfs2_drop_inode((unsigned long long)oi->ip_blkno, |
| 1208 | 1185 | inode->i_nlink, oi->ip_flags); | |
| 1209 | mlog(0, "Drop inode %llu, nlink = %u, ip_flags = 0x%x\n", | ||
| 1210 | (unsigned long long)oi->ip_blkno, inode->i_nlink, oi->ip_flags); | ||
| 1211 | 1186 | ||
| 1212 | if (oi->ip_flags & OCFS2_INODE_MAYBE_ORPHANED) | 1187 | if (oi->ip_flags & OCFS2_INODE_MAYBE_ORPHANED) |
| 1213 | res = 1; | 1188 | res = 1; |
| 1214 | else | 1189 | else |
| 1215 | res = generic_drop_inode(inode); | 1190 | res = generic_drop_inode(inode); |
| 1216 | 1191 | ||
| 1217 | mlog_exit_void(); | ||
| 1218 | return res; | 1192 | return res; |
| 1219 | } | 1193 | } |
| 1220 | 1194 | ||
| @@ -1226,11 +1200,11 @@ int ocfs2_inode_revalidate(struct dentry *dentry) | |||
| 1226 | struct inode *inode = dentry->d_inode; | 1200 | struct inode *inode = dentry->d_inode; |
| 1227 | int status = 0; | 1201 | int status = 0; |
| 1228 | 1202 | ||
| 1229 | mlog_entry("(inode = 0x%p, ino = %llu)\n", inode, | 1203 | trace_ocfs2_inode_revalidate(inode, |
| 1230 | inode ? (unsigned long long)OCFS2_I(inode)->ip_blkno : 0ULL); | 1204 | inode ? (unsigned long long)OCFS2_I(inode)->ip_blkno : 0ULL, |
| 1205 | inode ? (unsigned long long)OCFS2_I(inode)->ip_flags : 0); | ||
| 1231 | 1206 | ||
| 1232 | if (!inode) { | 1207 | if (!inode) { |
| 1233 | mlog(0, "eep, no inode!\n"); | ||
| 1234 | status = -ENOENT; | 1208 | status = -ENOENT; |
| 1235 | goto bail; | 1209 | goto bail; |
| 1236 | } | 1210 | } |
| @@ -1238,7 +1212,6 @@ int ocfs2_inode_revalidate(struct dentry *dentry) | |||
| 1238 | spin_lock(&OCFS2_I(inode)->ip_lock); | 1212 | spin_lock(&OCFS2_I(inode)->ip_lock); |
| 1239 | if (OCFS2_I(inode)->ip_flags & OCFS2_INODE_DELETED) { | 1213 | if (OCFS2_I(inode)->ip_flags & OCFS2_INODE_DELETED) { |
| 1240 | spin_unlock(&OCFS2_I(inode)->ip_lock); | 1214 | spin_unlock(&OCFS2_I(inode)->ip_lock); |
| 1241 | mlog(0, "inode deleted!\n"); | ||
| 1242 | status = -ENOENT; | 1215 | status = -ENOENT; |
| 1243 | goto bail; | 1216 | goto bail; |
| 1244 | } | 1217 | } |
| @@ -1254,8 +1227,6 @@ int ocfs2_inode_revalidate(struct dentry *dentry) | |||
| 1254 | } | 1227 | } |
| 1255 | ocfs2_inode_unlock(inode, 0); | 1228 | ocfs2_inode_unlock(inode, 0); |
| 1256 | bail: | 1229 | bail: |
| 1257 | mlog_exit(status); | ||
| 1258 | |||
| 1259 | return status; | 1230 | return status; |
| 1260 | } | 1231 | } |
| 1261 | 1232 | ||
| @@ -1271,8 +1242,7 @@ int ocfs2_mark_inode_dirty(handle_t *handle, | |||
| 1271 | int status; | 1242 | int status; |
| 1272 | struct ocfs2_dinode *fe = (struct ocfs2_dinode *) bh->b_data; | 1243 | struct ocfs2_dinode *fe = (struct ocfs2_dinode *) bh->b_data; |
| 1273 | 1244 | ||
| 1274 | mlog_entry("(inode %llu)\n", | 1245 | trace_ocfs2_mark_inode_dirty((unsigned long long)OCFS2_I(inode)->ip_blkno); |
| 1275 | (unsigned long long)OCFS2_I(inode)->ip_blkno); | ||
| 1276 | 1246 | ||
| 1277 | status = ocfs2_journal_access_di(handle, INODE_CACHE(inode), bh, | 1247 | status = ocfs2_journal_access_di(handle, INODE_CACHE(inode), bh, |
| 1278 | OCFS2_JOURNAL_ACCESS_WRITE); | 1248 | OCFS2_JOURNAL_ACCESS_WRITE); |
| @@ -1302,7 +1272,6 @@ int ocfs2_mark_inode_dirty(handle_t *handle, | |||
| 1302 | 1272 | ||
| 1303 | ocfs2_journal_dirty(handle, bh); | 1273 | ocfs2_journal_dirty(handle, bh); |
| 1304 | leave: | 1274 | leave: |
| 1305 | mlog_exit(status); | ||
| 1306 | return status; | 1275 | return status; |
| 1307 | } | 1276 | } |
| 1308 | 1277 | ||
| @@ -1345,8 +1314,7 @@ int ocfs2_validate_inode_block(struct super_block *sb, | |||
| 1345 | int rc; | 1314 | int rc; |
| 1346 | struct ocfs2_dinode *di = (struct ocfs2_dinode *)bh->b_data; | 1315 | struct ocfs2_dinode *di = (struct ocfs2_dinode *)bh->b_data; |
| 1347 | 1316 | ||
| 1348 | mlog(0, "Validating dinode %llu\n", | 1317 | trace_ocfs2_validate_inode_block((unsigned long long)bh->b_blocknr); |
| 1349 | (unsigned long long)bh->b_blocknr); | ||
| 1350 | 1318 | ||
| 1351 | BUG_ON(!buffer_uptodate(bh)); | 1319 | BUG_ON(!buffer_uptodate(bh)); |
| 1352 | 1320 | ||
diff --git a/fs/ocfs2/ioctl.c b/fs/ocfs2/ioctl.c index 09de77ce002..8f13c5989ea 100644 --- a/fs/ocfs2/ioctl.c +++ b/fs/ocfs2/ioctl.c | |||
| @@ -9,7 +9,6 @@ | |||
| 9 | #include <linux/mount.h> | 9 | #include <linux/mount.h> |
| 10 | #include <linux/compat.h> | 10 | #include <linux/compat.h> |
| 11 | 11 | ||
| 12 | #define MLOG_MASK_PREFIX ML_INODE | ||
| 13 | #include <cluster/masklog.h> | 12 | #include <cluster/masklog.h> |
| 14 | 13 | ||
| 15 | #include "ocfs2.h" | 14 | #include "ocfs2.h" |
| @@ -46,6 +45,22 @@ static inline void __o2info_set_request_error(struct ocfs2_info_request *kreq, | |||
| 46 | #define o2info_set_request_error(a, b) \ | 45 | #define o2info_set_request_error(a, b) \ |
| 47 | __o2info_set_request_error((struct ocfs2_info_request *)&(a), b) | 46 | __o2info_set_request_error((struct ocfs2_info_request *)&(a), b) |
| 48 | 47 | ||
| 48 | static inline void __o2info_set_request_filled(struct ocfs2_info_request *req) | ||
| 49 | { | ||
| 50 | req->ir_flags |= OCFS2_INFO_FL_FILLED; | ||
| 51 | } | ||
| 52 | |||
| 53 | #define o2info_set_request_filled(a) \ | ||
| 54 | __o2info_set_request_filled((struct ocfs2_info_request *)&(a)) | ||
| 55 | |||
| 56 | static inline void __o2info_clear_request_filled(struct ocfs2_info_request *req) | ||
| 57 | { | ||
| 58 | req->ir_flags &= ~OCFS2_INFO_FL_FILLED; | ||
| 59 | } | ||
| 60 | |||
| 61 | #define o2info_clear_request_filled(a) \ | ||
| 62 | __o2info_clear_request_filled((struct ocfs2_info_request *)&(a)) | ||
| 63 | |||
| 49 | static int ocfs2_get_inode_attr(struct inode *inode, unsigned *flags) | 64 | static int ocfs2_get_inode_attr(struct inode *inode, unsigned *flags) |
| 50 | { | 65 | { |
| 51 | int status; | 66 | int status; |
| @@ -59,7 +74,6 @@ static int ocfs2_get_inode_attr(struct inode *inode, unsigned *flags) | |||
| 59 | *flags = OCFS2_I(inode)->ip_attr; | 74 | *flags = OCFS2_I(inode)->ip_attr; |
| 60 | ocfs2_inode_unlock(inode, 0); | 75 | ocfs2_inode_unlock(inode, 0); |
| 61 | 76 | ||
| 62 | mlog_exit(status); | ||
| 63 | return status; | 77 | return status; |
| 64 | } | 78 | } |
| 65 | 79 | ||
| @@ -125,7 +139,6 @@ bail: | |||
| 125 | 139 | ||
| 126 | brelse(bh); | 140 | brelse(bh); |
| 127 | 141 | ||
| 128 | mlog_exit(status); | ||
| 129 | return status; | 142 | return status; |
| 130 | } | 143 | } |
| 131 | 144 | ||
| @@ -139,7 +152,8 @@ int ocfs2_info_handle_blocksize(struct inode *inode, | |||
| 139 | goto bail; | 152 | goto bail; |
| 140 | 153 | ||
| 141 | oib.ib_blocksize = inode->i_sb->s_blocksize; | 154 | oib.ib_blocksize = inode->i_sb->s_blocksize; |
| 142 | oib.ib_req.ir_flags |= OCFS2_INFO_FL_FILLED; | 155 | |
| 156 | o2info_set_request_filled(oib); | ||
| 143 | 157 | ||
| 144 | if (o2info_to_user(oib, req)) | 158 | if (o2info_to_user(oib, req)) |
| 145 | goto bail; | 159 | goto bail; |
| @@ -163,7 +177,8 @@ int ocfs2_info_handle_clustersize(struct inode *inode, | |||
| 163 | goto bail; | 177 | goto bail; |
| 164 | 178 | ||
| 165 | oic.ic_clustersize = osb->s_clustersize; | 179 | oic.ic_clustersize = osb->s_clustersize; |
| 166 | oic.ic_req.ir_flags |= OCFS2_INFO_FL_FILLED; | 180 | |
| 181 | o2info_set_request_filled(oic); | ||
| 167 | 182 | ||
| 168 | if (o2info_to_user(oic, req)) | 183 | if (o2info_to_user(oic, req)) |
| 169 | goto bail; | 184 | goto bail; |
| @@ -187,7 +202,8 @@ int ocfs2_info_handle_maxslots(struct inode *inode, | |||
| 187 | goto bail; | 202 | goto bail; |
| 188 | 203 | ||
| 189 | oim.im_max_slots = osb->max_slots; | 204 | oim.im_max_slots = osb->max_slots; |
| 190 | oim.im_req.ir_flags |= OCFS2_INFO_FL_FILLED; | 205 | |
| 206 | o2info_set_request_filled(oim); | ||
| 191 | 207 | ||
| 192 | if (o2info_to_user(oim, req)) | 208 | if (o2info_to_user(oim, req)) |
| 193 | goto bail; | 209 | goto bail; |
| @@ -211,7 +227,8 @@ int ocfs2_info_handle_label(struct inode *inode, | |||
| 211 | goto bail; | 227 | goto bail; |
| 212 | 228 | ||
| 213 | memcpy(oil.il_label, osb->vol_label, OCFS2_MAX_VOL_LABEL_LEN); | 229 | memcpy(oil.il_label, osb->vol_label, OCFS2_MAX_VOL_LABEL_LEN); |
| 214 | oil.il_req.ir_flags |= OCFS2_INFO_FL_FILLED; | 230 | |
| 231 | o2info_set_request_filled(oil); | ||
| 215 | 232 | ||
| 216 | if (o2info_to_user(oil, req)) | 233 | if (o2info_to_user(oil, req)) |
| 217 | goto bail; | 234 | goto bail; |
| @@ -235,7 +252,8 @@ int ocfs2_info_handle_uuid(struct inode *inode, | |||
| 235 | goto bail; | 252 | goto bail; |
| 236 | 253 | ||
| 237 | memcpy(oiu.iu_uuid_str, osb->uuid_str, OCFS2_TEXT_UUID_LEN + 1); | 254 | memcpy(oiu.iu_uuid_str, osb->uuid_str, OCFS2_TEXT_UUID_LEN + 1); |
| 238 | oiu.iu_req.ir_flags |= OCFS2_INFO_FL_FILLED; | 255 | |
| 256 | o2info_set_request_filled(oiu); | ||
| 239 | 257 | ||
| 240 | if (o2info_to_user(oiu, req)) | 258 | if (o2info_to_user(oiu, req)) |
| 241 | goto bail; | 259 | goto bail; |
| @@ -261,7 +279,8 @@ int ocfs2_info_handle_fs_features(struct inode *inode, | |||
| 261 | oif.if_compat_features = osb->s_feature_compat; | 279 | oif.if_compat_features = osb->s_feature_compat; |
| 262 | oif.if_incompat_features = osb->s_feature_incompat; | 280 | oif.if_incompat_features = osb->s_feature_incompat; |
| 263 | oif.if_ro_compat_features = osb->s_feature_ro_compat; | 281 | oif.if_ro_compat_features = osb->s_feature_ro_compat; |
| 264 | oif.if_req.ir_flags |= OCFS2_INFO_FL_FILLED; | 282 | |
| 283 | o2info_set_request_filled(oif); | ||
| 265 | 284 | ||
| 266 | if (o2info_to_user(oif, req)) | 285 | if (o2info_to_user(oif, req)) |
| 267 | goto bail; | 286 | goto bail; |
| @@ -286,7 +305,7 @@ int ocfs2_info_handle_journal_size(struct inode *inode, | |||
| 286 | 305 | ||
| 287 | oij.ij_journal_size = osb->journal->j_inode->i_size; | 306 | oij.ij_journal_size = osb->journal->j_inode->i_size; |
| 288 | 307 | ||
| 289 | oij.ij_req.ir_flags |= OCFS2_INFO_FL_FILLED; | 308 | o2info_set_request_filled(oij); |
| 290 | 309 | ||
| 291 | if (o2info_to_user(oij, req)) | 310 | if (o2info_to_user(oij, req)) |
| 292 | goto bail; | 311 | goto bail; |
| @@ -308,7 +327,7 @@ int ocfs2_info_handle_unknown(struct inode *inode, | |||
| 308 | if (o2info_from_user(oir, req)) | 327 | if (o2info_from_user(oir, req)) |
| 309 | goto bail; | 328 | goto bail; |
| 310 | 329 | ||
| 311 | oir.ir_flags &= ~OCFS2_INFO_FL_FILLED; | 330 | o2info_clear_request_filled(oir); |
| 312 | 331 | ||
| 313 | if (o2info_to_user(oir, req)) | 332 | if (o2info_to_user(oir, req)) |
| 314 | goto bail; | 333 | goto bail; |
diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c index faa2303dbf0..dcc2d932715 100644 --- a/fs/ocfs2/journal.c +++ b/fs/ocfs2/journal.c | |||
| @@ -31,7 +31,6 @@ | |||
| 31 | #include <linux/time.h> | 31 | #include <linux/time.h> |
| 32 | #include <linux/random.h> | 32 | #include <linux/random.h> |
| 33 | 33 | ||
| 34 | #define MLOG_MASK_PREFIX ML_JOURNAL | ||
| 35 | #include <cluster/masklog.h> | 34 | #include <cluster/masklog.h> |
| 36 | 35 | ||
| 37 | #include "ocfs2.h" | 36 | #include "ocfs2.h" |
| @@ -52,6 +51,7 @@ | |||
| 52 | #include "quota.h" | 51 | #include "quota.h" |
| 53 | 52 | ||
| 54 | #include "buffer_head_io.h" | 53 | #include "buffer_head_io.h" |
| 54 | #include "ocfs2_trace.h" | ||
| 55 | 55 | ||
| 56 | DEFINE_SPINLOCK(trans_inc_lock); | 56 | DEFINE_SPINLOCK(trans_inc_lock); |
| 57 | 57 | ||
| @@ -303,16 +303,15 @@ static int ocfs2_commit_cache(struct ocfs2_super *osb) | |||
| 303 | unsigned int flushed; | 303 | unsigned int flushed; |
| 304 | struct ocfs2_journal *journal = NULL; | 304 | struct ocfs2_journal *journal = NULL; |
| 305 | 305 | ||
| 306 | mlog_entry_void(); | ||
| 307 | |||
| 308 | journal = osb->journal; | 306 | journal = osb->journal; |
| 309 | 307 | ||
| 310 | /* Flush all pending commits and checkpoint the journal. */ | 308 | /* Flush all pending commits and checkpoint the journal. */ |
| 311 | down_write(&journal->j_trans_barrier); | 309 | down_write(&journal->j_trans_barrier); |
| 312 | 310 | ||
| 313 | if (atomic_read(&journal->j_num_trans) == 0) { | 311 | flushed = atomic_read(&journal->j_num_trans); |
| 312 | trace_ocfs2_commit_cache_begin(flushed); | ||
| 313 | if (flushed == 0) { | ||
| 314 | up_write(&journal->j_trans_barrier); | 314 | up_write(&journal->j_trans_barrier); |
| 315 | mlog(0, "No transactions for me to flush!\n"); | ||
| 316 | goto finally; | 315 | goto finally; |
| 317 | } | 316 | } |
| 318 | 317 | ||
| @@ -331,13 +330,11 @@ static int ocfs2_commit_cache(struct ocfs2_super *osb) | |||
| 331 | atomic_set(&journal->j_num_trans, 0); | 330 | atomic_set(&journal->j_num_trans, 0); |
| 332 | up_write(&journal->j_trans_barrier); | 331 | up_write(&journal->j_trans_barrier); |
| 333 | 332 | ||
| 334 | mlog(0, "commit_thread: flushed transaction %lu (%u handles)\n", | 333 | trace_ocfs2_commit_cache_end(journal->j_trans_id, flushed); |
| 335 | journal->j_trans_id, flushed); | ||
| 336 | 334 | ||
| 337 | ocfs2_wake_downconvert_thread(osb); | 335 | ocfs2_wake_downconvert_thread(osb); |
| 338 | wake_up(&journal->j_checkpointed); | 336 | wake_up(&journal->j_checkpointed); |
| 339 | finally: | 337 | finally: |
| 340 | mlog_exit(status); | ||
| 341 | return status; | 338 | return status; |
| 342 | } | 339 | } |
| 343 | 340 | ||
| @@ -425,9 +422,8 @@ int ocfs2_extend_trans(handle_t *handle, int nblocks) | |||
| 425 | return 0; | 422 | return 0; |
| 426 | 423 | ||
| 427 | old_nblocks = handle->h_buffer_credits; | 424 | old_nblocks = handle->h_buffer_credits; |
| 428 | mlog_entry_void(); | ||
| 429 | 425 | ||
| 430 | mlog(0, "Trying to extend transaction by %d blocks\n", nblocks); | 426 | trace_ocfs2_extend_trans(old_nblocks, nblocks); |
| 431 | 427 | ||
| 432 | #ifdef CONFIG_OCFS2_DEBUG_FS | 428 | #ifdef CONFIG_OCFS2_DEBUG_FS |
| 433 | status = 1; | 429 | status = 1; |
| @@ -440,9 +436,7 @@ int ocfs2_extend_trans(handle_t *handle, int nblocks) | |||
| 440 | #endif | 436 | #endif |
| 441 | 437 | ||
| 442 | if (status > 0) { | 438 | if (status > 0) { |
| 443 | mlog(0, | 439 | trace_ocfs2_extend_trans_restart(old_nblocks + nblocks); |
| 444 | "jbd2_journal_extend failed, trying " | ||
| 445 | "jbd2_journal_restart\n"); | ||
| 446 | status = jbd2_journal_restart(handle, | 440 | status = jbd2_journal_restart(handle, |
| 447 | old_nblocks + nblocks); | 441 | old_nblocks + nblocks); |
| 448 | if (status < 0) { | 442 | if (status < 0) { |
| @@ -453,8 +447,6 @@ int ocfs2_extend_trans(handle_t *handle, int nblocks) | |||
| 453 | 447 | ||
| 454 | status = 0; | 448 | status = 0; |
| 455 | bail: | 449 | bail: |
| 456 | |||
| 457 | mlog_exit(status); | ||
| 458 | return status; | 450 | return status; |
| 459 | } | 451 | } |
| 460 | 452 | ||
| @@ -622,12 +614,9 @@ static int __ocfs2_journal_access(handle_t *handle, | |||
| 622 | BUG_ON(!handle); | 614 | BUG_ON(!handle); |
| 623 | BUG_ON(!bh); | 615 | BUG_ON(!bh); |
| 624 | 616 | ||
| 625 | mlog_entry("bh->b_blocknr=%llu, type=%d (\"%s\"), bh->b_size = %zu\n", | 617 | trace_ocfs2_journal_access( |
| 626 | (unsigned long long)bh->b_blocknr, type, | 618 | (unsigned long long)ocfs2_metadata_cache_owner(ci), |
| 627 | (type == OCFS2_JOURNAL_ACCESS_CREATE) ? | 619 | (unsigned long long)bh->b_blocknr, type, bh->b_size); |
| 628 | "OCFS2_JOURNAL_ACCESS_CREATE" : | ||
| 629 | "OCFS2_JOURNAL_ACCESS_WRITE", | ||
| 630 | bh->b_size); | ||
| 631 | 620 | ||
| 632 | /* we can safely remove this assertion after testing. */ | 621 | /* we can safely remove this assertion after testing. */ |
| 633 | if (!buffer_uptodate(bh)) { | 622 | if (!buffer_uptodate(bh)) { |
| @@ -668,7 +657,6 @@ static int __ocfs2_journal_access(handle_t *handle, | |||
| 668 | mlog(ML_ERROR, "Error %d getting %d access to buffer!\n", | 657 | mlog(ML_ERROR, "Error %d getting %d access to buffer!\n", |
| 669 | status, type); | 658 | status, type); |
| 670 | 659 | ||
| 671 | mlog_exit(status); | ||
| 672 | return status; | 660 | return status; |
| 673 | } | 661 | } |
| 674 | 662 | ||
| @@ -737,13 +725,10 @@ void ocfs2_journal_dirty(handle_t *handle, struct buffer_head *bh) | |||
| 737 | { | 725 | { |
| 738 | int status; | 726 | int status; |
| 739 | 727 | ||
| 740 | mlog_entry("(bh->b_blocknr=%llu)\n", | 728 | trace_ocfs2_journal_dirty((unsigned long long)bh->b_blocknr); |
| 741 | (unsigned long long)bh->b_blocknr); | ||
| 742 | 729 | ||
| 743 | status = jbd2_journal_dirty_metadata(handle, bh); | 730 | status = jbd2_journal_dirty_metadata(handle, bh); |
| 744 | BUG_ON(status); | 731 | BUG_ON(status); |
| 745 | |||
| 746 | mlog_exit_void(); | ||
| 747 | } | 732 | } |
| 748 | 733 | ||
| 749 | #define OCFS2_DEFAULT_COMMIT_INTERVAL (HZ * JBD2_DEFAULT_MAX_COMMIT_AGE) | 734 | #define OCFS2_DEFAULT_COMMIT_INTERVAL (HZ * JBD2_DEFAULT_MAX_COMMIT_AGE) |
| @@ -775,8 +760,6 @@ int ocfs2_journal_init(struct ocfs2_journal *journal, int *dirty) | |||
| 775 | struct ocfs2_super *osb; | 760 | struct ocfs2_super *osb; |
| 776 | int inode_lock = 0; | 761 | int inode_lock = 0; |
| 777 | 762 | ||
| 778 | mlog_entry_void(); | ||
| 779 | |||
| 780 | BUG_ON(!journal); | 763 | BUG_ON(!journal); |
| 781 | 764 | ||
| 782 | osb = journal->j_osb; | 765 | osb = journal->j_osb; |
| @@ -820,10 +803,9 @@ int ocfs2_journal_init(struct ocfs2_journal *journal, int *dirty) | |||
| 820 | goto done; | 803 | goto done; |
| 821 | } | 804 | } |
| 822 | 805 | ||
| 823 | mlog(0, "inode->i_size = %lld\n", inode->i_size); | 806 | trace_ocfs2_journal_init(inode->i_size, |
| 824 | mlog(0, "inode->i_blocks = %llu\n", | 807 | (unsigned long long)inode->i_blocks, |
| 825 | (unsigned long long)inode->i_blocks); | 808 | OCFS2_I(inode)->ip_clusters); |
| 826 | mlog(0, "inode->ip_clusters = %u\n", OCFS2_I(inode)->ip_clusters); | ||
| 827 | 809 | ||
| 828 | /* call the kernels journal init function now */ | 810 | /* call the kernels journal init function now */ |
| 829 | j_journal = jbd2_journal_init_inode(inode); | 811 | j_journal = jbd2_journal_init_inode(inode); |
| @@ -833,8 +815,7 @@ int ocfs2_journal_init(struct ocfs2_journal *journal, int *dirty) | |||
| 833 | goto done; | 815 | goto done; |
| 834 | } | 816 | } |
| 835 | 817 | ||
| 836 | mlog(0, "Returned from jbd2_journal_init_inode\n"); | 818 | trace_ocfs2_journal_init_maxlen(j_journal->j_maxlen); |
| 837 | mlog(0, "j_journal->j_maxlen = %u\n", j_journal->j_maxlen); | ||
| 838 | 819 | ||
| 839 | *dirty = (le32_to_cpu(di->id1.journal1.ij_flags) & | 820 | *dirty = (le32_to_cpu(di->id1.journal1.ij_flags) & |
| 840 | OCFS2_JOURNAL_DIRTY_FL); | 821 | OCFS2_JOURNAL_DIRTY_FL); |
| @@ -859,7 +840,6 @@ done: | |||
| 859 | } | 840 | } |
| 860 | } | 841 | } |
| 861 | 842 | ||
| 862 | mlog_exit(status); | ||
| 863 | return status; | 843 | return status; |
| 864 | } | 844 | } |
| 865 | 845 | ||
| @@ -882,8 +862,6 @@ static int ocfs2_journal_toggle_dirty(struct ocfs2_super *osb, | |||
| 882 | struct buffer_head *bh = journal->j_bh; | 862 | struct buffer_head *bh = journal->j_bh; |
| 883 | struct ocfs2_dinode *fe; | 863 | struct ocfs2_dinode *fe; |
| 884 | 864 | ||
| 885 | mlog_entry_void(); | ||
| 886 | |||
| 887 | fe = (struct ocfs2_dinode *)bh->b_data; | 865 | fe = (struct ocfs2_dinode *)bh->b_data; |
| 888 | 866 | ||
| 889 | /* The journal bh on the osb always comes from ocfs2_journal_init() | 867 | /* The journal bh on the osb always comes from ocfs2_journal_init() |
| @@ -906,7 +884,6 @@ static int ocfs2_journal_toggle_dirty(struct ocfs2_super *osb, | |||
| 906 | if (status < 0) | 884 | if (status < 0) |
| 907 | mlog_errno(status); | 885 | mlog_errno(status); |
| 908 | 886 | ||
| 909 | mlog_exit(status); | ||
| 910 | return status; | 887 | return status; |
| 911 | } | 888 | } |
| 912 | 889 | ||
| @@ -921,8 +898,6 @@ void ocfs2_journal_shutdown(struct ocfs2_super *osb) | |||
| 921 | struct inode *inode = NULL; | 898 | struct inode *inode = NULL; |
| 922 | int num_running_trans = 0; | 899 | int num_running_trans = 0; |
| 923 | 900 | ||
| 924 | mlog_entry_void(); | ||
| 925 | |||
| 926 | BUG_ON(!osb); | 901 | BUG_ON(!osb); |
| 927 | 902 | ||
| 928 | journal = osb->journal; | 903 | journal = osb->journal; |
| @@ -939,10 +914,7 @@ void ocfs2_journal_shutdown(struct ocfs2_super *osb) | |||
| 939 | BUG(); | 914 | BUG(); |
| 940 | 915 | ||
| 941 | num_running_trans = atomic_read(&(osb->journal->j_num_trans)); | 916 | num_running_trans = atomic_read(&(osb->journal->j_num_trans)); |
| 942 | if (num_running_trans > 0) | 917 | trace_ocfs2_journal_shutdown(num_running_trans); |
| 943 | mlog(0, "Shutting down journal: must wait on %d " | ||
| 944 | "running transactions!\n", | ||
| 945 | num_running_trans); | ||
| 946 | 918 | ||
| 947 | /* Do a commit_cache here. It will flush our journal, *and* | 919 | /* Do a commit_cache here. It will flush our journal, *and* |
| 948 | * release any locks that are still held. | 920 | * release any locks that are still held. |
| @@ -955,7 +927,7 @@ void ocfs2_journal_shutdown(struct ocfs2_super *osb) | |||
| 955 | * completely destroy the journal. */ | 927 | * completely destroy the journal. */ |
| 956 | if (osb->commit_task) { | 928 | if (osb->commit_task) { |
| 957 | /* Wait for the commit thread */ | 929 | /* Wait for the commit thread */ |
| 958 | mlog(0, "Waiting for ocfs2commit to exit....\n"); | 930 | trace_ocfs2_journal_shutdown_wait(osb->commit_task); |
| 959 | kthread_stop(osb->commit_task); | 931 | kthread_stop(osb->commit_task); |
| 960 | osb->commit_task = NULL; | 932 | osb->commit_task = NULL; |
| 961 | } | 933 | } |
| @@ -998,7 +970,6 @@ void ocfs2_journal_shutdown(struct ocfs2_super *osb) | |||
| 998 | done: | 970 | done: |
| 999 | if (inode) | 971 | if (inode) |
| 1000 | iput(inode); | 972 | iput(inode); |
| 1001 | mlog_exit_void(); | ||
| 1002 | } | 973 | } |
| 1003 | 974 | ||
| 1004 | static void ocfs2_clear_journal_error(struct super_block *sb, | 975 | static void ocfs2_clear_journal_error(struct super_block *sb, |
| @@ -1024,8 +995,6 @@ int ocfs2_journal_load(struct ocfs2_journal *journal, int local, int replayed) | |||
| 1024 | int status = 0; | 995 | int status = 0; |
| 1025 | struct ocfs2_super *osb; | 996 | struct ocfs2_super *osb; |
| 1026 | 997 | ||
| 1027 | mlog_entry_void(); | ||
| 1028 | |||
| 1029 | BUG_ON(!journal); | 998 | BUG_ON(!journal); |
| 1030 | 999 | ||
| 1031 | osb = journal->j_osb; | 1000 | osb = journal->j_osb; |
| @@ -1059,7 +1028,6 @@ int ocfs2_journal_load(struct ocfs2_journal *journal, int local, int replayed) | |||
| 1059 | osb->commit_task = NULL; | 1028 | osb->commit_task = NULL; |
| 1060 | 1029 | ||
| 1061 | done: | 1030 | done: |
| 1062 | mlog_exit(status); | ||
| 1063 | return status; | 1031 | return status; |
| 1064 | } | 1032 | } |
| 1065 | 1033 | ||
| @@ -1070,8 +1038,6 @@ int ocfs2_journal_wipe(struct ocfs2_journal *journal, int full) | |||
| 1070 | { | 1038 | { |
| 1071 | int status; | 1039 | int status; |
| 1072 | 1040 | ||
| 1073 | mlog_entry_void(); | ||
| 1074 | |||
| 1075 | BUG_ON(!journal); | 1041 | BUG_ON(!journal); |
| 1076 | 1042 | ||
| 1077 | status = jbd2_journal_wipe(journal->j_journal, full); | 1043 | status = jbd2_journal_wipe(journal->j_journal, full); |
| @@ -1085,7 +1051,6 @@ int ocfs2_journal_wipe(struct ocfs2_journal *journal, int full) | |||
| 1085 | mlog_errno(status); | 1051 | mlog_errno(status); |
| 1086 | 1052 | ||
| 1087 | bail: | 1053 | bail: |
| 1088 | mlog_exit(status); | ||
| 1089 | return status; | 1054 | return status; |
| 1090 | } | 1055 | } |
| 1091 | 1056 | ||
| @@ -1124,8 +1089,6 @@ static int ocfs2_force_read_journal(struct inode *inode) | |||
| 1124 | #define CONCURRENT_JOURNAL_FILL 32ULL | 1089 | #define CONCURRENT_JOURNAL_FILL 32ULL |
| 1125 | struct buffer_head *bhs[CONCURRENT_JOURNAL_FILL]; | 1090 | struct buffer_head *bhs[CONCURRENT_JOURNAL_FILL]; |
| 1126 | 1091 | ||
| 1127 | mlog_entry_void(); | ||
| 1128 | |||
| 1129 | memset(bhs, 0, sizeof(struct buffer_head *) * CONCURRENT_JOURNAL_FILL); | 1092 | memset(bhs, 0, sizeof(struct buffer_head *) * CONCURRENT_JOURNAL_FILL); |
| 1130 | 1093 | ||
| 1131 | num_blocks = ocfs2_blocks_for_bytes(inode->i_sb, inode->i_size); | 1094 | num_blocks = ocfs2_blocks_for_bytes(inode->i_sb, inode->i_size); |
| @@ -1161,7 +1124,6 @@ static int ocfs2_force_read_journal(struct inode *inode) | |||
| 1161 | bail: | 1124 | bail: |
| 1162 | for(i = 0; i < CONCURRENT_JOURNAL_FILL; i++) | 1125 | for(i = 0; i < CONCURRENT_JOURNAL_FILL; i++) |
| 1163 | brelse(bhs[i]); | 1126 | brelse(bhs[i]); |
| 1164 | mlog_exit(status); | ||
| 1165 | return status; | 1127 | return status; |
| 1166 | } | 1128 | } |
| 1167 | 1129 | ||
| @@ -1185,7 +1147,7 @@ struct ocfs2_la_recovery_item { | |||
| 1185 | */ | 1147 | */ |
| 1186 | void ocfs2_complete_recovery(struct work_struct *work) | 1148 | void ocfs2_complete_recovery(struct work_struct *work) |
| 1187 | { | 1149 | { |
| 1188 | int ret; | 1150 | int ret = 0; |
| 1189 | struct ocfs2_journal *journal = | 1151 | struct ocfs2_journal *journal = |
| 1190 | container_of(work, struct ocfs2_journal, j_recovery_work); | 1152 | container_of(work, struct ocfs2_journal, j_recovery_work); |
| 1191 | struct ocfs2_super *osb = journal->j_osb; | 1153 | struct ocfs2_super *osb = journal->j_osb; |
| @@ -1194,9 +1156,8 @@ void ocfs2_complete_recovery(struct work_struct *work) | |||
| 1194 | struct ocfs2_quota_recovery *qrec; | 1156 | struct ocfs2_quota_recovery *qrec; |
| 1195 | LIST_HEAD(tmp_la_list); | 1157 | LIST_HEAD(tmp_la_list); |
| 1196 | 1158 | ||
| 1197 | mlog_entry_void(); | 1159 | trace_ocfs2_complete_recovery( |
| 1198 | 1160 | (unsigned long long)OCFS2_I(journal->j_inode)->ip_blkno); | |
| 1199 | mlog(0, "completing recovery from keventd\n"); | ||
| 1200 | 1161 | ||
| 1201 | spin_lock(&journal->j_lock); | 1162 | spin_lock(&journal->j_lock); |
| 1202 | list_splice_init(&journal->j_la_cleanups, &tmp_la_list); | 1163 | list_splice_init(&journal->j_la_cleanups, &tmp_la_list); |
| @@ -1205,15 +1166,18 @@ void ocfs2_complete_recovery(struct work_struct *work) | |||
| 1205 | list_for_each_entry_safe(item, n, &tmp_la_list, lri_list) { | 1166 | list_for_each_entry_safe(item, n, &tmp_la_list, lri_list) { |
| 1206 | list_del_init(&item->lri_list); | 1167 | list_del_init(&item->lri_list); |
| 1207 | 1168 | ||
| 1208 | mlog(0, "Complete recovery for slot %d\n", item->lri_slot); | ||
| 1209 | |||
| 1210 | ocfs2_wait_on_quotas(osb); | 1169 | ocfs2_wait_on_quotas(osb); |
| 1211 | 1170 | ||
| 1212 | la_dinode = item->lri_la_dinode; | 1171 | la_dinode = item->lri_la_dinode; |
| 1213 | if (la_dinode) { | 1172 | tl_dinode = item->lri_tl_dinode; |
| 1214 | mlog(0, "Clean up local alloc %llu\n", | 1173 | qrec = item->lri_qrec; |
| 1215 | (unsigned long long)le64_to_cpu(la_dinode->i_blkno)); | 1174 | |
| 1175 | trace_ocfs2_complete_recovery_slot(item->lri_slot, | ||
| 1176 | la_dinode ? le64_to_cpu(la_dinode->i_blkno) : 0, | ||
| 1177 | tl_dinode ? le64_to_cpu(tl_dinode->i_blkno) : 0, | ||
| 1178 | qrec); | ||
| 1216 | 1179 | ||
| 1180 | if (la_dinode) { | ||
| 1217 | ret = ocfs2_complete_local_alloc_recovery(osb, | 1181 | ret = ocfs2_complete_local_alloc_recovery(osb, |
| 1218 | la_dinode); | 1182 | la_dinode); |
| 1219 | if (ret < 0) | 1183 | if (ret < 0) |
| @@ -1222,11 +1186,7 @@ void ocfs2_complete_recovery(struct work_struct *work) | |||
| 1222 | kfree(la_dinode); | 1186 | kfree(la_dinode); |
| 1223 | } | 1187 | } |
| 1224 | 1188 | ||
| 1225 | tl_dinode = item->lri_tl_dinode; | ||
| 1226 | if (tl_dinode) { | 1189 | if (tl_dinode) { |
| 1227 | mlog(0, "Clean up truncate log %llu\n", | ||
| 1228 | (unsigned long long)le64_to_cpu(tl_dinode->i_blkno)); | ||
| 1229 | |||
| 1230 | ret = ocfs2_complete_truncate_log_recovery(osb, | 1190 | ret = ocfs2_complete_truncate_log_recovery(osb, |
| 1231 | tl_dinode); | 1191 | tl_dinode); |
| 1232 | if (ret < 0) | 1192 | if (ret < 0) |
| @@ -1239,9 +1199,7 @@ void ocfs2_complete_recovery(struct work_struct *work) | |||
| 1239 | if (ret < 0) | 1199 | if (ret < 0) |
| 1240 | mlog_errno(ret); | 1200 | mlog_errno(ret); |
| 1241 | 1201 | ||
| 1242 | qrec = item->lri_qrec; | ||
| 1243 | if (qrec) { | 1202 | if (qrec) { |
| 1244 | mlog(0, "Recovering quota files"); | ||
| 1245 | ret = ocfs2_finish_quota_recovery(osb, qrec, | 1203 | ret = ocfs2_finish_quota_recovery(osb, qrec, |
| 1246 | item->lri_slot); | 1204 | item->lri_slot); |
| 1247 | if (ret < 0) | 1205 | if (ret < 0) |
| @@ -1252,8 +1210,7 @@ void ocfs2_complete_recovery(struct work_struct *work) | |||
| 1252 | kfree(item); | 1210 | kfree(item); |
| 1253 | } | 1211 | } |
| 1254 | 1212 | ||
| 1255 | mlog(0, "Recovery completion\n"); | 1213 | trace_ocfs2_complete_recovery_end(ret); |
| 1256 | mlog_exit_void(); | ||
| 1257 | } | 1214 | } |
| 1258 | 1215 | ||
| 1259 | /* NOTE: This function always eats your references to la_dinode and | 1216 | /* NOTE: This function always eats your references to la_dinode and |
| @@ -1339,8 +1296,6 @@ static int __ocfs2_recovery_thread(void *arg) | |||
| 1339 | int rm_quota_used = 0, i; | 1296 | int rm_quota_used = 0, i; |
| 1340 | struct ocfs2_quota_recovery *qrec; | 1297 | struct ocfs2_quota_recovery *qrec; |
| 1341 | 1298 | ||
| 1342 | mlog_entry_void(); | ||
| 1343 | |||
| 1344 | status = ocfs2_wait_on_mount(osb); | 1299 | status = ocfs2_wait_on_mount(osb); |
| 1345 | if (status < 0) { | 1300 | if (status < 0) { |
| 1346 | goto bail; | 1301 | goto bail; |
| @@ -1372,15 +1327,12 @@ restart: | |||
| 1372 | * clear it until ocfs2_recover_node() has succeeded. */ | 1327 | * clear it until ocfs2_recover_node() has succeeded. */ |
| 1373 | node_num = rm->rm_entries[0]; | 1328 | node_num = rm->rm_entries[0]; |
| 1374 | spin_unlock(&osb->osb_lock); | 1329 | spin_unlock(&osb->osb_lock); |
| 1375 | mlog(0, "checking node %d\n", node_num); | ||
| 1376 | slot_num = ocfs2_node_num_to_slot(osb, node_num); | 1330 | slot_num = ocfs2_node_num_to_slot(osb, node_num); |
| 1331 | trace_ocfs2_recovery_thread_node(node_num, slot_num); | ||
| 1377 | if (slot_num == -ENOENT) { | 1332 | if (slot_num == -ENOENT) { |
| 1378 | status = 0; | 1333 | status = 0; |
| 1379 | mlog(0, "no slot for this node, so no recovery" | ||
| 1380 | "required.\n"); | ||
| 1381 | goto skip_recovery; | 1334 | goto skip_recovery; |
| 1382 | } | 1335 | } |
| 1383 | mlog(0, "node %d was using slot %d\n", node_num, slot_num); | ||
| 1384 | 1336 | ||
| 1385 | /* It is a bit subtle with quota recovery. We cannot do it | 1337 | /* It is a bit subtle with quota recovery. We cannot do it |
| 1386 | * immediately because we have to obtain cluster locks from | 1338 | * immediately because we have to obtain cluster locks from |
| @@ -1407,7 +1359,7 @@ skip_recovery: | |||
| 1407 | spin_lock(&osb->osb_lock); | 1359 | spin_lock(&osb->osb_lock); |
| 1408 | } | 1360 | } |
| 1409 | spin_unlock(&osb->osb_lock); | 1361 | spin_unlock(&osb->osb_lock); |
| 1410 | mlog(0, "All nodes recovered\n"); | 1362 | trace_ocfs2_recovery_thread_end(status); |
| 1411 | 1363 | ||
| 1412 | /* Refresh all journal recovery generations from disk */ | 1364 | /* Refresh all journal recovery generations from disk */ |
| 1413 | status = ocfs2_check_journals_nolocks(osb); | 1365 | status = ocfs2_check_journals_nolocks(osb); |
| @@ -1451,7 +1403,6 @@ bail: | |||
| 1451 | if (rm_quota) | 1403 | if (rm_quota) |
| 1452 | kfree(rm_quota); | 1404 | kfree(rm_quota); |
| 1453 | 1405 | ||
| 1454 | mlog_exit(status); | ||
| 1455 | /* no one is callint kthread_stop() for us so the kthread() api | 1406 | /* no one is callint kthread_stop() for us so the kthread() api |
| 1456 | * requires that we call do_exit(). And it isn't exported, but | 1407 | * requires that we call do_exit(). And it isn't exported, but |
| 1457 | * complete_and_exit() seems to be a minimal wrapper around it. */ | 1408 | * complete_and_exit() seems to be a minimal wrapper around it. */ |
| @@ -1461,19 +1412,15 @@ bail: | |||
| 1461 | 1412 | ||
| 1462 | void ocfs2_recovery_thread(struct ocfs2_super *osb, int node_num) | 1413 | void ocfs2_recovery_thread(struct ocfs2_super *osb, int node_num) |
| 1463 | { | 1414 | { |
| 1464 | mlog_entry("(node_num=%d, osb->node_num = %d)\n", | ||
| 1465 | node_num, osb->node_num); | ||
| 1466 | |||
| 1467 | mutex_lock(&osb->recovery_lock); | 1415 | mutex_lock(&osb->recovery_lock); |
| 1468 | if (osb->disable_recovery) | ||
| 1469 | goto out; | ||
| 1470 | 1416 | ||
| 1471 | /* People waiting on recovery will wait on | 1417 | trace_ocfs2_recovery_thread(node_num, osb->node_num, |
| 1472 | * the recovery map to empty. */ | 1418 | osb->disable_recovery, osb->recovery_thread_task, |
| 1473 | if (ocfs2_recovery_map_set(osb, node_num)) | 1419 | osb->disable_recovery ? |
| 1474 | mlog(0, "node %d already in recovery map.\n", node_num); | 1420 | -1 : ocfs2_recovery_map_set(osb, node_num)); |
| 1475 | 1421 | ||
| 1476 | mlog(0, "starting recovery thread...\n"); | 1422 | if (osb->disable_recovery) |
| 1423 | goto out; | ||
| 1477 | 1424 | ||
| 1478 | if (osb->recovery_thread_task) | 1425 | if (osb->recovery_thread_task) |
| 1479 | goto out; | 1426 | goto out; |
| @@ -1488,8 +1435,6 @@ void ocfs2_recovery_thread(struct ocfs2_super *osb, int node_num) | |||
| 1488 | out: | 1435 | out: |
| 1489 | mutex_unlock(&osb->recovery_lock); | 1436 | mutex_unlock(&osb->recovery_lock); |
| 1490 | wake_up(&osb->recovery_event); | 1437 | wake_up(&osb->recovery_event); |
| 1491 | |||
| 1492 | mlog_exit_void(); | ||
| 1493 | } | 1438 | } |
| 1494 | 1439 | ||
| 1495 | static int ocfs2_read_journal_inode(struct ocfs2_super *osb, | 1440 | static int ocfs2_read_journal_inode(struct ocfs2_super *osb, |
| @@ -1563,7 +1508,7 @@ static int ocfs2_replay_journal(struct ocfs2_super *osb, | |||
| 1563 | * If not, it needs recovery. | 1508 | * If not, it needs recovery. |
| 1564 | */ | 1509 | */ |
| 1565 | if (osb->slot_recovery_generations[slot_num] != slot_reco_gen) { | 1510 | if (osb->slot_recovery_generations[slot_num] != slot_reco_gen) { |
| 1566 | mlog(0, "Slot %u already recovered (old/new=%u/%u)\n", slot_num, | 1511 | trace_ocfs2_replay_journal_recovered(slot_num, |
| 1567 | osb->slot_recovery_generations[slot_num], slot_reco_gen); | 1512 | osb->slot_recovery_generations[slot_num], slot_reco_gen); |
| 1568 | osb->slot_recovery_generations[slot_num] = slot_reco_gen; | 1513 | osb->slot_recovery_generations[slot_num] = slot_reco_gen; |
| 1569 | status = -EBUSY; | 1514 | status = -EBUSY; |
| @@ -1574,7 +1519,7 @@ static int ocfs2_replay_journal(struct ocfs2_super *osb, | |||
| 1574 | 1519 | ||
| 1575 | status = ocfs2_inode_lock_full(inode, &bh, 1, OCFS2_META_LOCK_RECOVERY); | 1520 | status = ocfs2_inode_lock_full(inode, &bh, 1, OCFS2_META_LOCK_RECOVERY); |
| 1576 | if (status < 0) { | 1521 | if (status < 0) { |
| 1577 | mlog(0, "status returned from ocfs2_inode_lock=%d\n", status); | 1522 | trace_ocfs2_replay_journal_lock_err(status); |
| 1578 | if (status != -ERESTARTSYS) | 1523 | if (status != -ERESTARTSYS) |
| 1579 | mlog(ML_ERROR, "Could not lock journal!\n"); | 1524 | mlog(ML_ERROR, "Could not lock journal!\n"); |
| 1580 | goto done; | 1525 | goto done; |
| @@ -1587,7 +1532,7 @@ static int ocfs2_replay_journal(struct ocfs2_super *osb, | |||
| 1587 | slot_reco_gen = ocfs2_get_recovery_generation(fe); | 1532 | slot_reco_gen = ocfs2_get_recovery_generation(fe); |
| 1588 | 1533 | ||
| 1589 | if (!(flags & OCFS2_JOURNAL_DIRTY_FL)) { | 1534 | if (!(flags & OCFS2_JOURNAL_DIRTY_FL)) { |
| 1590 | mlog(0, "No recovery required for node %d\n", node_num); | 1535 | trace_ocfs2_replay_journal_skip(node_num); |
| 1591 | /* Refresh recovery generation for the slot */ | 1536 | /* Refresh recovery generation for the slot */ |
| 1592 | osb->slot_recovery_generations[slot_num] = slot_reco_gen; | 1537 | osb->slot_recovery_generations[slot_num] = slot_reco_gen; |
| 1593 | goto done; | 1538 | goto done; |
| @@ -1608,7 +1553,6 @@ static int ocfs2_replay_journal(struct ocfs2_super *osb, | |||
| 1608 | goto done; | 1553 | goto done; |
| 1609 | } | 1554 | } |
| 1610 | 1555 | ||
| 1611 | mlog(0, "calling journal_init_inode\n"); | ||
| 1612 | journal = jbd2_journal_init_inode(inode); | 1556 | journal = jbd2_journal_init_inode(inode); |
| 1613 | if (journal == NULL) { | 1557 | if (journal == NULL) { |
| 1614 | mlog(ML_ERROR, "Linux journal layer error\n"); | 1558 | mlog(ML_ERROR, "Linux journal layer error\n"); |
| @@ -1628,7 +1572,6 @@ static int ocfs2_replay_journal(struct ocfs2_super *osb, | |||
| 1628 | ocfs2_clear_journal_error(osb->sb, journal, slot_num); | 1572 | ocfs2_clear_journal_error(osb->sb, journal, slot_num); |
| 1629 | 1573 | ||
| 1630 | /* wipe the journal */ | 1574 | /* wipe the journal */ |
| 1631 | mlog(0, "flushing the journal.\n"); | ||
| 1632 | jbd2_journal_lock_updates(journal); | 1575 | jbd2_journal_lock_updates(journal); |
| 1633 | status = jbd2_journal_flush(journal); | 1576 | status = jbd2_journal_flush(journal); |
| 1634 | jbd2_journal_unlock_updates(journal); | 1577 | jbd2_journal_unlock_updates(journal); |
| @@ -1665,7 +1608,6 @@ done: | |||
| 1665 | 1608 | ||
| 1666 | brelse(bh); | 1609 | brelse(bh); |
| 1667 | 1610 | ||
| 1668 | mlog_exit(status); | ||
| 1669 | return status; | 1611 | return status; |
| 1670 | } | 1612 | } |
| 1671 | 1613 | ||
| @@ -1688,8 +1630,7 @@ static int ocfs2_recover_node(struct ocfs2_super *osb, | |||
| 1688 | struct ocfs2_dinode *la_copy = NULL; | 1630 | struct ocfs2_dinode *la_copy = NULL; |
| 1689 | struct ocfs2_dinode *tl_copy = NULL; | 1631 | struct ocfs2_dinode *tl_copy = NULL; |
| 1690 | 1632 | ||
| 1691 | mlog_entry("(node_num=%d, slot_num=%d, osb->node_num = %d)\n", | 1633 | trace_ocfs2_recover_node(node_num, slot_num, osb->node_num); |
| 1692 | node_num, slot_num, osb->node_num); | ||
| 1693 | 1634 | ||
| 1694 | /* Should not ever be called to recover ourselves -- in that | 1635 | /* Should not ever be called to recover ourselves -- in that |
| 1695 | * case we should've called ocfs2_journal_load instead. */ | 1636 | * case we should've called ocfs2_journal_load instead. */ |
| @@ -1698,9 +1639,7 @@ static int ocfs2_recover_node(struct ocfs2_super *osb, | |||
| 1698 | status = ocfs2_replay_journal(osb, node_num, slot_num); | 1639 | status = ocfs2_replay_journal(osb, node_num, slot_num); |
| 1699 | if (status < 0) { | 1640 | if (status < 0) { |
| 1700 | if (status == -EBUSY) { | 1641 | if (status == -EBUSY) { |
| 1701 | mlog(0, "Skipping recovery for slot %u (node %u) " | 1642 | trace_ocfs2_recover_node_skip(slot_num, node_num); |
| 1702 | "as another node has recovered it\n", slot_num, | ||
| 1703 | node_num); | ||
| 1704 | status = 0; | 1643 | status = 0; |
| 1705 | goto done; | 1644 | goto done; |
| 1706 | } | 1645 | } |
| @@ -1735,7 +1674,6 @@ static int ocfs2_recover_node(struct ocfs2_super *osb, | |||
| 1735 | status = 0; | 1674 | status = 0; |
| 1736 | done: | 1675 | done: |
| 1737 | 1676 | ||
| 1738 | mlog_exit(status); | ||
| 1739 | return status; | 1677 | return status; |
| 1740 | } | 1678 | } |
| 1741 | 1679 | ||
| @@ -1808,8 +1746,8 @@ int ocfs2_mark_dead_nodes(struct ocfs2_super *osb) | |||
| 1808 | spin_lock(&osb->osb_lock); | 1746 | spin_lock(&osb->osb_lock); |
| 1809 | osb->slot_recovery_generations[i] = gen; | 1747 | osb->slot_recovery_generations[i] = gen; |
| 1810 | 1748 | ||
| 1811 | mlog(0, "Slot %u recovery generation is %u\n", i, | 1749 | trace_ocfs2_mark_dead_nodes(i, |
| 1812 | osb->slot_recovery_generations[i]); | 1750 | osb->slot_recovery_generations[i]); |
| 1813 | 1751 | ||
| 1814 | if (i == osb->slot_num) { | 1752 | if (i == osb->slot_num) { |
| 1815 | spin_unlock(&osb->osb_lock); | 1753 | spin_unlock(&osb->osb_lock); |
| @@ -1845,7 +1783,6 @@ int ocfs2_mark_dead_nodes(struct ocfs2_super *osb) | |||
| 1845 | 1783 | ||
| 1846 | status = 0; | 1784 | status = 0; |
| 1847 | bail: | 1785 | bail: |
| 1848 | mlog_exit(status); | ||
| 1849 | return status; | 1786 | return status; |
| 1850 | } | 1787 | } |
| 1851 | 1788 | ||
| @@ -1884,11 +1821,12 @@ void ocfs2_queue_orphan_scan(struct ocfs2_super *osb) | |||
| 1884 | 1821 | ||
| 1885 | os = &osb->osb_orphan_scan; | 1822 | os = &osb->osb_orphan_scan; |
| 1886 | 1823 | ||
| 1887 | mlog(0, "Begin orphan scan\n"); | ||
| 1888 | |||
| 1889 | if (atomic_read(&os->os_state) == ORPHAN_SCAN_INACTIVE) | 1824 | if (atomic_read(&os->os_state) == ORPHAN_SCAN_INACTIVE) |
| 1890 | goto out; | 1825 | goto out; |
| 1891 | 1826 | ||
| 1827 | trace_ocfs2_queue_orphan_scan_begin(os->os_count, os->os_seqno, | ||
| 1828 | atomic_read(&os->os_state)); | ||
| 1829 | |||
| 1892 | status = ocfs2_orphan_scan_lock(osb, &seqno); | 1830 | status = ocfs2_orphan_scan_lock(osb, &seqno); |
| 1893 | if (status < 0) { | 1831 | if (status < 0) { |
| 1894 | if (status != -EAGAIN) | 1832 | if (status != -EAGAIN) |
| @@ -1918,7 +1856,8 @@ void ocfs2_queue_orphan_scan(struct ocfs2_super *osb) | |||
| 1918 | unlock: | 1856 | unlock: |
| 1919 | ocfs2_orphan_scan_unlock(osb, seqno); | 1857 | ocfs2_orphan_scan_unlock(osb, seqno); |
| 1920 | out: | 1858 | out: |
| 1921 | mlog(0, "Orphan scan completed\n"); | 1859 | trace_ocfs2_queue_orphan_scan_end(os->os_count, os->os_seqno, |
| 1860 | atomic_read(&os->os_state)); | ||
| 1922 | return; | 1861 | return; |
| 1923 | } | 1862 | } |
| 1924 | 1863 | ||
| @@ -2002,8 +1941,7 @@ static int ocfs2_orphan_filldir(void *priv, const char *name, int name_len, | |||
| 2002 | if (IS_ERR(iter)) | 1941 | if (IS_ERR(iter)) |
| 2003 | return 0; | 1942 | return 0; |
| 2004 | 1943 | ||
| 2005 | mlog(0, "queue orphan %llu\n", | 1944 | trace_ocfs2_orphan_filldir((unsigned long long)OCFS2_I(iter)->ip_blkno); |
| 2006 | (unsigned long long)OCFS2_I(iter)->ip_blkno); | ||
| 2007 | /* No locking is required for the next_orphan queue as there | 1945 | /* No locking is required for the next_orphan queue as there |
| 2008 | * is only ever a single process doing orphan recovery. */ | 1946 | * is only ever a single process doing orphan recovery. */ |
| 2009 | OCFS2_I(iter)->ip_next_orphan = p->head; | 1947 | OCFS2_I(iter)->ip_next_orphan = p->head; |
| @@ -2119,7 +2057,7 @@ static int ocfs2_recover_orphans(struct ocfs2_super *osb, | |||
| 2119 | struct inode *iter; | 2057 | struct inode *iter; |
| 2120 | struct ocfs2_inode_info *oi; | 2058 | struct ocfs2_inode_info *oi; |
| 2121 | 2059 | ||
| 2122 | mlog(0, "Recover inodes from orphan dir in slot %d\n", slot); | 2060 | trace_ocfs2_recover_orphans(slot); |
| 2123 | 2061 | ||
| 2124 | ocfs2_mark_recovering_orphan_dir(osb, slot); | 2062 | ocfs2_mark_recovering_orphan_dir(osb, slot); |
| 2125 | ret = ocfs2_queue_orphans(osb, slot, &inode); | 2063 | ret = ocfs2_queue_orphans(osb, slot, &inode); |
| @@ -2132,7 +2070,8 @@ static int ocfs2_recover_orphans(struct ocfs2_super *osb, | |||
| 2132 | 2070 | ||
| 2133 | while (inode) { | 2071 | while (inode) { |
| 2134 | oi = OCFS2_I(inode); | 2072 | oi = OCFS2_I(inode); |
| 2135 | mlog(0, "iput orphan %llu\n", (unsigned long long)oi->ip_blkno); | 2073 | trace_ocfs2_recover_orphans_iput( |
| 2074 | (unsigned long long)oi->ip_blkno); | ||
| 2136 | 2075 | ||
| 2137 | iter = oi->ip_next_orphan; | 2076 | iter = oi->ip_next_orphan; |
| 2138 | 2077 | ||
| @@ -2170,6 +2109,7 @@ static int __ocfs2_wait_on_mount(struct ocfs2_super *osb, int quota) | |||
| 2170 | * MOUNTED flag, but this is set right before | 2109 | * MOUNTED flag, but this is set right before |
| 2171 | * dismount_volume() so we can trust it. */ | 2110 | * dismount_volume() so we can trust it. */ |
| 2172 | if (atomic_read(&osb->vol_state) == VOLUME_DISABLED) { | 2111 | if (atomic_read(&osb->vol_state) == VOLUME_DISABLED) { |
| 2112 | trace_ocfs2_wait_on_mount(VOLUME_DISABLED); | ||
| 2173 | mlog(0, "mount error, exiting!\n"); | 2113 | mlog(0, "mount error, exiting!\n"); |
| 2174 | return -EBUSY; | 2114 | return -EBUSY; |
| 2175 | } | 2115 | } |
diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c index ec6adbf8f55..210c3523754 100644 --- a/fs/ocfs2/localalloc.c +++ b/fs/ocfs2/localalloc.c | |||
| @@ -29,7 +29,6 @@ | |||
| 29 | #include <linux/highmem.h> | 29 | #include <linux/highmem.h> |
| 30 | #include <linux/bitops.h> | 30 | #include <linux/bitops.h> |
| 31 | 31 | ||
| 32 | #define MLOG_MASK_PREFIX ML_DISK_ALLOC | ||
| 33 | #include <cluster/masklog.h> | 32 | #include <cluster/masklog.h> |
| 34 | 33 | ||
| 35 | #include "ocfs2.h" | 34 | #include "ocfs2.h" |
| @@ -43,6 +42,7 @@ | |||
| 43 | #include "suballoc.h" | 42 | #include "suballoc.h" |
| 44 | #include "super.h" | 43 | #include "super.h" |
| 45 | #include "sysfile.h" | 44 | #include "sysfile.h" |
| 45 | #include "ocfs2_trace.h" | ||
| 46 | 46 | ||
| 47 | #include "buffer_head_io.h" | 47 | #include "buffer_head_io.h" |
| 48 | 48 | ||
| @@ -201,8 +201,7 @@ void ocfs2_la_set_sizes(struct ocfs2_super *osb, int requested_mb) | |||
| 201 | la_max_mb = ocfs2_clusters_to_megabytes(sb, | 201 | la_max_mb = ocfs2_clusters_to_megabytes(sb, |
| 202 | ocfs2_local_alloc_size(sb) * 8); | 202 | ocfs2_local_alloc_size(sb) * 8); |
| 203 | 203 | ||
| 204 | mlog(0, "requested: %dM, max: %uM, default: %uM\n", | 204 | trace_ocfs2_la_set_sizes(requested_mb, la_max_mb, la_default_mb); |
| 205 | requested_mb, la_max_mb, la_default_mb); | ||
| 206 | 205 | ||
| 207 | if (requested_mb == -1) { | 206 | if (requested_mb == -1) { |
| 208 | /* No user request - use defaults */ | 207 | /* No user request - use defaults */ |
| @@ -276,8 +275,8 @@ int ocfs2_alloc_should_use_local(struct ocfs2_super *osb, u64 bits) | |||
| 276 | 275 | ||
| 277 | ret = 1; | 276 | ret = 1; |
| 278 | bail: | 277 | bail: |
| 279 | mlog(0, "state=%d, bits=%llu, la_bits=%d, ret=%d\n", | 278 | trace_ocfs2_alloc_should_use_local( |
| 280 | osb->local_alloc_state, (unsigned long long)bits, la_bits, ret); | 279 | (unsigned long long)bits, osb->local_alloc_state, la_bits, ret); |
| 281 | spin_unlock(&osb->osb_lock); | 280 | spin_unlock(&osb->osb_lock); |
| 282 | return ret; | 281 | return ret; |
| 283 | } | 282 | } |
| @@ -291,8 +290,6 @@ int ocfs2_load_local_alloc(struct ocfs2_super *osb) | |||
| 291 | struct inode *inode = NULL; | 290 | struct inode *inode = NULL; |
| 292 | struct ocfs2_local_alloc *la; | 291 | struct ocfs2_local_alloc *la; |
| 293 | 292 | ||
| 294 | mlog_entry_void(); | ||
| 295 | |||
| 296 | if (osb->local_alloc_bits == 0) | 293 | if (osb->local_alloc_bits == 0) |
| 297 | goto bail; | 294 | goto bail; |
| 298 | 295 | ||
| @@ -364,9 +361,10 @@ bail: | |||
| 364 | if (inode) | 361 | if (inode) |
| 365 | iput(inode); | 362 | iput(inode); |
| 366 | 363 | ||
| 367 | mlog(0, "Local alloc window bits = %d\n", osb->local_alloc_bits); | 364 | trace_ocfs2_load_local_alloc(osb->local_alloc_bits); |
| 368 | 365 | ||
| 369 | mlog_exit(status); | 366 | if (status) |
| 367 | mlog_errno(status); | ||
| 370 | return status; | 368 | return status; |
| 371 | } | 369 | } |
| 372 | 370 | ||
| @@ -388,8 +386,6 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb) | |||
| 388 | struct ocfs2_dinode *alloc_copy = NULL; | 386 | struct ocfs2_dinode *alloc_copy = NULL; |
| 389 | struct ocfs2_dinode *alloc = NULL; | 387 | struct ocfs2_dinode *alloc = NULL; |
| 390 | 388 | ||
| 391 | mlog_entry_void(); | ||
| 392 | |||
| 393 | cancel_delayed_work(&osb->la_enable_wq); | 389 | cancel_delayed_work(&osb->la_enable_wq); |
| 394 | flush_workqueue(ocfs2_wq); | 390 | flush_workqueue(ocfs2_wq); |
| 395 | 391 | ||
| @@ -482,8 +478,6 @@ out: | |||
| 482 | 478 | ||
| 483 | if (alloc_copy) | 479 | if (alloc_copy) |
| 484 | kfree(alloc_copy); | 480 | kfree(alloc_copy); |
| 485 | |||
| 486 | mlog_exit_void(); | ||
| 487 | } | 481 | } |
| 488 | 482 | ||
| 489 | /* | 483 | /* |
| @@ -502,7 +496,7 @@ int ocfs2_begin_local_alloc_recovery(struct ocfs2_super *osb, | |||
| 502 | struct inode *inode = NULL; | 496 | struct inode *inode = NULL; |
| 503 | struct ocfs2_dinode *alloc; | 497 | struct ocfs2_dinode *alloc; |
| 504 | 498 | ||
| 505 | mlog_entry("(slot_num = %d)\n", slot_num); | 499 | trace_ocfs2_begin_local_alloc_recovery(slot_num); |
| 506 | 500 | ||
| 507 | *alloc_copy = NULL; | 501 | *alloc_copy = NULL; |
| 508 | 502 | ||
| @@ -552,7 +546,8 @@ bail: | |||
| 552 | iput(inode); | 546 | iput(inode); |
| 553 | } | 547 | } |
| 554 | 548 | ||
| 555 | mlog_exit(status); | 549 | if (status) |
| 550 | mlog_errno(status); | ||
| 556 | return status; | 551 | return status; |
| 557 | } | 552 | } |
| 558 | 553 | ||
| @@ -570,8 +565,6 @@ int ocfs2_complete_local_alloc_recovery(struct ocfs2_super *osb, | |||
| 570 | struct buffer_head *main_bm_bh = NULL; | 565 | struct buffer_head *main_bm_bh = NULL; |
| 571 | struct inode *main_bm_inode; | 566 | struct inode *main_bm_inode; |
| 572 | 567 | ||
| 573 | mlog_entry_void(); | ||
| 574 | |||
| 575 | main_bm_inode = ocfs2_get_system_file_inode(osb, | 568 | main_bm_inode = ocfs2_get_system_file_inode(osb, |
| 576 | GLOBAL_BITMAP_SYSTEM_INODE, | 569 | GLOBAL_BITMAP_SYSTEM_INODE, |
| 577 | OCFS2_INVALID_SLOT); | 570 | OCFS2_INVALID_SLOT); |
| @@ -620,7 +613,8 @@ out_mutex: | |||
| 620 | out: | 613 | out: |
| 621 | if (!status) | 614 | if (!status) |
| 622 | ocfs2_init_steal_slots(osb); | 615 | ocfs2_init_steal_slots(osb); |
| 623 | mlog_exit(status); | 616 | if (status) |
| 617 | mlog_errno(status); | ||
| 624 | return status; | 618 | return status; |
| 625 | } | 619 | } |
| 626 | 620 | ||
| @@ -640,8 +634,6 @@ int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb, | |||
| 640 | struct inode *local_alloc_inode; | 634 | struct inode *local_alloc_inode; |
| 641 | unsigned int free_bits; | 635 | unsigned int free_bits; |
| 642 | 636 | ||
| 643 | mlog_entry_void(); | ||
| 644 | |||
| 645 | BUG_ON(!ac); | 637 | BUG_ON(!ac); |
| 646 | 638 | ||
| 647 | local_alloc_inode = | 639 | local_alloc_inode = |
| @@ -712,10 +704,6 @@ int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb, | |||
| 712 | goto bail; | 704 | goto bail; |
| 713 | } | 705 | } |
| 714 | 706 | ||
| 715 | if (ac->ac_max_block) | ||
| 716 | mlog(0, "Calling in_range for max block %llu\n", | ||
| 717 | (unsigned long long)ac->ac_max_block); | ||
| 718 | |||
| 719 | ac->ac_inode = local_alloc_inode; | 707 | ac->ac_inode = local_alloc_inode; |
| 720 | /* We should never use localalloc from another slot */ | 708 | /* We should never use localalloc from another slot */ |
| 721 | ac->ac_alloc_slot = osb->slot_num; | 709 | ac->ac_alloc_slot = osb->slot_num; |
| @@ -729,10 +717,12 @@ bail: | |||
| 729 | iput(local_alloc_inode); | 717 | iput(local_alloc_inode); |
| 730 | } | 718 | } |
| 731 | 719 | ||
| 732 | mlog(0, "bits=%d, slot=%d, ret=%d\n", bits_wanted, osb->slot_num, | 720 | trace_ocfs2_reserve_local_alloc_bits( |
| 733 | status); | 721 | (unsigned long long)ac->ac_max_block, |
| 722 | bits_wanted, osb->slot_num, status); | ||
| 734 | 723 | ||
| 735 | mlog_exit(status); | 724 | if (status) |
| 725 | mlog_errno(status); | ||
| 736 | return status; | 726 | return status; |
| 737 | } | 727 | } |
| 738 | 728 | ||
| @@ -749,7 +739,6 @@ int ocfs2_claim_local_alloc_bits(struct ocfs2_super *osb, | |||
| 749 | struct ocfs2_dinode *alloc; | 739 | struct ocfs2_dinode *alloc; |
| 750 | struct ocfs2_local_alloc *la; | 740 | struct ocfs2_local_alloc *la; |
| 751 | 741 | ||
| 752 | mlog_entry_void(); | ||
| 753 | BUG_ON(ac->ac_which != OCFS2_AC_USE_LOCAL); | 742 | BUG_ON(ac->ac_which != OCFS2_AC_USE_LOCAL); |
| 754 | 743 | ||
| 755 | local_alloc_inode = ac->ac_inode; | 744 | local_alloc_inode = ac->ac_inode; |
| @@ -788,7 +777,8 @@ int ocfs2_claim_local_alloc_bits(struct ocfs2_super *osb, | |||
| 788 | ocfs2_journal_dirty(handle, osb->local_alloc_bh); | 777 | ocfs2_journal_dirty(handle, osb->local_alloc_bh); |
| 789 | 778 | ||
| 790 | bail: | 779 | bail: |
| 791 | mlog_exit(status); | 780 | if (status) |
| 781 | mlog_errno(status); | ||
| 792 | return status; | 782 | return status; |
| 793 | } | 783 | } |
| 794 | 784 | ||
| @@ -799,13 +789,11 @@ static u32 ocfs2_local_alloc_count_bits(struct ocfs2_dinode *alloc) | |||
| 799 | u32 count = 0; | 789 | u32 count = 0; |
| 800 | struct ocfs2_local_alloc *la = OCFS2_LOCAL_ALLOC(alloc); | 790 | struct ocfs2_local_alloc *la = OCFS2_LOCAL_ALLOC(alloc); |
| 801 | 791 | ||
| 802 | mlog_entry_void(); | ||
| 803 | |||
| 804 | buffer = la->la_bitmap; | 792 | buffer = la->la_bitmap; |
| 805 | for (i = 0; i < le16_to_cpu(la->la_size); i++) | 793 | for (i = 0; i < le16_to_cpu(la->la_size); i++) |
| 806 | count += hweight8(buffer[i]); | 794 | count += hweight8(buffer[i]); |
| 807 | 795 | ||
| 808 | mlog_exit(count); | 796 | trace_ocfs2_local_alloc_count_bits(count); |
| 809 | return count; | 797 | return count; |
| 810 | } | 798 | } |
| 811 | 799 | ||
| @@ -820,10 +808,7 @@ static int ocfs2_local_alloc_find_clear_bits(struct ocfs2_super *osb, | |||
| 820 | void *bitmap = NULL; | 808 | void *bitmap = NULL; |
| 821 | struct ocfs2_reservation_map *resmap = &osb->osb_la_resmap; | 809 | struct ocfs2_reservation_map *resmap = &osb->osb_la_resmap; |
| 822 | 810 | ||
| 823 | mlog_entry("(numbits wanted = %u)\n", *numbits); | ||
| 824 | |||
| 825 | if (!alloc->id1.bitmap1.i_total) { | 811 | if (!alloc->id1.bitmap1.i_total) { |
| 826 | mlog(0, "No bits in my window!\n"); | ||
| 827 | bitoff = -1; | 812 | bitoff = -1; |
| 828 | goto bail; | 813 | goto bail; |
| 829 | } | 814 | } |
| @@ -883,8 +868,7 @@ static int ocfs2_local_alloc_find_clear_bits(struct ocfs2_super *osb, | |||
| 883 | } | 868 | } |
| 884 | } | 869 | } |
| 885 | 870 | ||
| 886 | mlog(0, "Exiting loop, bitoff = %d, numfound = %d\n", bitoff, | 871 | trace_ocfs2_local_alloc_find_clear_bits_search_bitmap(bitoff, numfound); |
| 887 | numfound); | ||
| 888 | 872 | ||
| 889 | if (numfound == *numbits) | 873 | if (numfound == *numbits) |
| 890 | bitoff = startoff - numfound; | 874 | bitoff = startoff - numfound; |
| @@ -895,7 +879,10 @@ bail: | |||
| 895 | if (local_resv) | 879 | if (local_resv) |
| 896 | ocfs2_resv_discard(resmap, resv); | 880 | ocfs2_resv_discard(resmap, resv); |
| 897 | 881 | ||
| 898 | mlog_exit(bitoff); | 882 | trace_ocfs2_local_alloc_find_clear_bits(*numbits, |
| 883 | le32_to_cpu(alloc->id1.bitmap1.i_total), | ||
| 884 | bitoff, numfound); | ||
| 885 | |||
| 899 | return bitoff; | 886 | return bitoff; |
| 900 | } | 887 | } |
| 901 | 888 | ||
| @@ -903,15 +890,12 @@ static void ocfs2_clear_local_alloc(struct ocfs2_dinode *alloc) | |||
| 903 | { | 890 | { |
| 904 | struct ocfs2_local_alloc *la = OCFS2_LOCAL_ALLOC(alloc); | 891 | struct ocfs2_local_alloc *la = OCFS2_LOCAL_ALLOC(alloc); |
| 905 | int i; | 892 | int i; |
| 906 | mlog_entry_void(); | ||
| 907 | 893 | ||
| 908 | alloc->id1.bitmap1.i_total = 0; | 894 | alloc->id1.bitmap1.i_total = 0; |
| 909 | alloc->id1.bitmap1.i_used = 0; | 895 | alloc->id1.bitmap1.i_used = 0; |
| 910 | la->la_bm_off = 0; | 896 | la->la_bm_off = 0; |
| 911 | for(i = 0; i < le16_to_cpu(la->la_size); i++) | 897 | for(i = 0; i < le16_to_cpu(la->la_size); i++) |
| 912 | la->la_bitmap[i] = 0; | 898 | la->la_bitmap[i] = 0; |
| 913 | |||
| 914 | mlog_exit_void(); | ||
| 915 | } | 899 | } |
| 916 | 900 | ||
| 917 | #if 0 | 901 | #if 0 |
| @@ -952,18 +936,16 @@ static int ocfs2_sync_local_to_main(struct ocfs2_super *osb, | |||
| 952 | void *bitmap; | 936 | void *bitmap; |
| 953 | struct ocfs2_local_alloc *la = OCFS2_LOCAL_ALLOC(alloc); | 937 | struct ocfs2_local_alloc *la = OCFS2_LOCAL_ALLOC(alloc); |
| 954 | 938 | ||
| 955 | mlog_entry("total = %u, used = %u\n", | 939 | trace_ocfs2_sync_local_to_main( |
| 956 | le32_to_cpu(alloc->id1.bitmap1.i_total), | 940 | le32_to_cpu(alloc->id1.bitmap1.i_total), |
| 957 | le32_to_cpu(alloc->id1.bitmap1.i_used)); | 941 | le32_to_cpu(alloc->id1.bitmap1.i_used)); |
| 958 | 942 | ||
| 959 | if (!alloc->id1.bitmap1.i_total) { | 943 | if (!alloc->id1.bitmap1.i_total) { |
| 960 | mlog(0, "nothing to sync!\n"); | ||
| 961 | goto bail; | 944 | goto bail; |
| 962 | } | 945 | } |
| 963 | 946 | ||
| 964 | if (le32_to_cpu(alloc->id1.bitmap1.i_used) == | 947 | if (le32_to_cpu(alloc->id1.bitmap1.i_used) == |
| 965 | le32_to_cpu(alloc->id1.bitmap1.i_total)) { | 948 | le32_to_cpu(alloc->id1.bitmap1.i_total)) { |
| 966 | mlog(0, "all bits were taken!\n"); | ||
| 967 | goto bail; | 949 | goto bail; |
| 968 | } | 950 | } |
| 969 | 951 | ||
| @@ -985,8 +967,7 @@ static int ocfs2_sync_local_to_main(struct ocfs2_super *osb, | |||
| 985 | ocfs2_clusters_to_blocks(osb->sb, | 967 | ocfs2_clusters_to_blocks(osb->sb, |
| 986 | start - count); | 968 | start - count); |
| 987 | 969 | ||
| 988 | mlog(0, "freeing %u bits starting at local alloc bit " | 970 | trace_ocfs2_sync_local_to_main_free( |
| 989 | "%u (la_start_blk = %llu, blkno = %llu)\n", | ||
| 990 | count, start - count, | 971 | count, start - count, |
| 991 | (unsigned long long)la_start_blk, | 972 | (unsigned long long)la_start_blk, |
| 992 | (unsigned long long)blkno); | 973 | (unsigned long long)blkno); |
| @@ -1007,7 +988,8 @@ static int ocfs2_sync_local_to_main(struct ocfs2_super *osb, | |||
| 1007 | } | 988 | } |
| 1008 | 989 | ||
| 1009 | bail: | 990 | bail: |
| 1010 | mlog_exit(status); | 991 | if (status) |
| 992 | mlog_errno(status); | ||
| 1011 | return status; | 993 | return status; |
| 1012 | } | 994 | } |
| 1013 | 995 | ||
| @@ -1132,7 +1114,8 @@ bail: | |||
| 1132 | *ac = NULL; | 1114 | *ac = NULL; |
| 1133 | } | 1115 | } |
| 1134 | 1116 | ||
| 1135 | mlog_exit(status); | 1117 | if (status) |
| 1118 | mlog_errno(status); | ||
| 1136 | return status; | 1119 | return status; |
| 1137 | } | 1120 | } |
| 1138 | 1121 | ||
| @@ -1148,17 +1131,12 @@ static int ocfs2_local_alloc_new_window(struct ocfs2_super *osb, | |||
| 1148 | struct ocfs2_dinode *alloc = NULL; | 1131 | struct ocfs2_dinode *alloc = NULL; |
| 1149 | struct ocfs2_local_alloc *la; | 1132 | struct ocfs2_local_alloc *la; |
| 1150 | 1133 | ||
| 1151 | mlog_entry_void(); | ||
| 1152 | |||
| 1153 | alloc = (struct ocfs2_dinode *) osb->local_alloc_bh->b_data; | 1134 | alloc = (struct ocfs2_dinode *) osb->local_alloc_bh->b_data; |
| 1154 | la = OCFS2_LOCAL_ALLOC(alloc); | 1135 | la = OCFS2_LOCAL_ALLOC(alloc); |
| 1155 | 1136 | ||
| 1156 | if (alloc->id1.bitmap1.i_total) | 1137 | trace_ocfs2_local_alloc_new_window( |
| 1157 | mlog(0, "asking me to alloc a new window over a non-empty " | 1138 | le32_to_cpu(alloc->id1.bitmap1.i_total), |
| 1158 | "one\n"); | 1139 | osb->local_alloc_bits); |
| 1159 | |||
| 1160 | mlog(0, "Allocating %u clusters for a new window.\n", | ||
| 1161 | osb->local_alloc_bits); | ||
| 1162 | 1140 | ||
| 1163 | /* Instruct the allocation code to try the most recently used | 1141 | /* Instruct the allocation code to try the most recently used |
| 1164 | * cluster group. We'll re-record the group used this pass | 1142 | * cluster group. We'll re-record the group used this pass |
| @@ -1220,13 +1198,13 @@ retry_enospc: | |||
| 1220 | ocfs2_resmap_restart(&osb->osb_la_resmap, cluster_count, | 1198 | ocfs2_resmap_restart(&osb->osb_la_resmap, cluster_count, |
| 1221 | OCFS2_LOCAL_ALLOC(alloc)->la_bitmap); | 1199 | OCFS2_LOCAL_ALLOC(alloc)->la_bitmap); |
| 1222 | 1200 | ||
| 1223 | mlog(0, "New window allocated:\n"); | 1201 | trace_ocfs2_local_alloc_new_window_result( |
| 1224 | mlog(0, "window la_bm_off = %u\n", | 1202 | OCFS2_LOCAL_ALLOC(alloc)->la_bm_off, |
| 1225 | OCFS2_LOCAL_ALLOC(alloc)->la_bm_off); | 1203 | le32_to_cpu(alloc->id1.bitmap1.i_total)); |
| 1226 | mlog(0, "window bits = %u\n", le32_to_cpu(alloc->id1.bitmap1.i_total)); | ||
| 1227 | 1204 | ||
| 1228 | bail: | 1205 | bail: |
| 1229 | mlog_exit(status); | 1206 | if (status) |
| 1207 | mlog_errno(status); | ||
| 1230 | return status; | 1208 | return status; |
| 1231 | } | 1209 | } |
| 1232 | 1210 | ||
| @@ -1243,8 +1221,6 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb, | |||
| 1243 | struct ocfs2_dinode *alloc_copy = NULL; | 1221 | struct ocfs2_dinode *alloc_copy = NULL; |
| 1244 | struct ocfs2_alloc_context *ac = NULL; | 1222 | struct ocfs2_alloc_context *ac = NULL; |
| 1245 | 1223 | ||
| 1246 | mlog_entry_void(); | ||
| 1247 | |||
| 1248 | ocfs2_recalc_la_window(osb, OCFS2_LA_EVENT_SLIDE); | 1224 | ocfs2_recalc_la_window(osb, OCFS2_LA_EVENT_SLIDE); |
| 1249 | 1225 | ||
| 1250 | /* This will lock the main bitmap for us. */ | 1226 | /* This will lock the main bitmap for us. */ |
| @@ -1324,7 +1300,8 @@ bail: | |||
| 1324 | if (ac) | 1300 | if (ac) |
| 1325 | ocfs2_free_alloc_context(ac); | 1301 | ocfs2_free_alloc_context(ac); |
| 1326 | 1302 | ||
| 1327 | mlog_exit(status); | 1303 | if (status) |
| 1304 | mlog_errno(status); | ||
| 1328 | return status; | 1305 | return status; |
| 1329 | } | 1306 | } |
| 1330 | 1307 | ||
diff --git a/fs/ocfs2/locks.c b/fs/ocfs2/locks.c index b5cb3ede940..e57c804069e 100644 --- a/fs/ocfs2/locks.c +++ b/fs/ocfs2/locks.c | |||
| @@ -26,7 +26,6 @@ | |||
| 26 | #include <linux/fs.h> | 26 | #include <linux/fs.h> |
| 27 | #include <linux/fcntl.h> | 27 | #include <linux/fcntl.h> |
| 28 | 28 | ||
| 29 | #define MLOG_MASK_PREFIX ML_INODE | ||
| 30 | #include <cluster/masklog.h> | 29 | #include <cluster/masklog.h> |
| 31 | 30 | ||
| 32 | #include "ocfs2.h" | 31 | #include "ocfs2.h" |
diff --git a/fs/ocfs2/mmap.c b/fs/ocfs2/mmap.c index 7e32db9c2c9..3e9393ca39e 100644 --- a/fs/ocfs2/mmap.c +++ b/fs/ocfs2/mmap.c | |||
| @@ -31,7 +31,6 @@ | |||
| 31 | #include <linux/signal.h> | 31 | #include <linux/signal.h> |
| 32 | #include <linux/rbtree.h> | 32 | #include <linux/rbtree.h> |
| 33 | 33 | ||
| 34 | #define MLOG_MASK_PREFIX ML_FILE_IO | ||
| 35 | #include <cluster/masklog.h> | 34 | #include <cluster/masklog.h> |
| 36 | 35 | ||
| 37 | #include "ocfs2.h" | 36 | #include "ocfs2.h" |
| @@ -42,6 +41,7 @@ | |||
| 42 | #include "inode.h" | 41 | #include "inode.h" |
| 43 | #include "mmap.h" | 42 | #include "mmap.h" |
| 44 | #include "super.h" | 43 | #include "super.h" |
| 44 | #include "ocfs2_trace.h" | ||
| 45 | 45 | ||
| 46 | 46 | ||
| 47 | static int ocfs2_fault(struct vm_area_struct *area, struct vm_fault *vmf) | 47 | static int ocfs2_fault(struct vm_area_struct *area, struct vm_fault *vmf) |
| @@ -49,13 +49,12 @@ static int ocfs2_fault(struct vm_area_struct *area, struct vm_fault *vmf) | |||
| 49 | sigset_t oldset; | 49 | sigset_t oldset; |
| 50 | int ret; | 50 | int ret; |
| 51 | 51 | ||
| 52 | mlog_entry("(area=%p, page offset=%lu)\n", area, vmf->pgoff); | ||
| 53 | |||
| 54 | ocfs2_block_signals(&oldset); | 52 | ocfs2_block_signals(&oldset); |
| 55 | ret = filemap_fault(area, vmf); | 53 | ret = filemap_fault(area, vmf); |
| 56 | ocfs2_unblock_signals(&oldset); | 54 | ocfs2_unblock_signals(&oldset); |
| 57 | 55 | ||
| 58 | mlog_exit_ptr(vmf->page); | 56 | trace_ocfs2_fault(OCFS2_I(area->vm_file->f_mapping->host)->ip_blkno, |
| 57 | area, vmf->page, vmf->pgoff); | ||
| 59 | return ret; | 58 | return ret; |
| 60 | } | 59 | } |
| 61 | 60 | ||
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c index d6c25d76b53..28f2cc1080d 100644 --- a/fs/ocfs2/namei.c +++ b/fs/ocfs2/namei.c | |||
| @@ -42,7 +42,6 @@ | |||
| 42 | #include <linux/highmem.h> | 42 | #include <linux/highmem.h> |
| 43 | #include <linux/quotaops.h> | 43 | #include <linux/quotaops.h> |
| 44 | 44 | ||
| 45 | #define MLOG_MASK_PREFIX ML_NAMEI | ||
| 46 | #include <cluster/masklog.h> | 45 | #include <cluster/masklog.h> |
| 47 | 46 | ||
| 48 | #include "ocfs2.h" | 47 | #include "ocfs2.h" |
| @@ -63,6 +62,7 @@ | |||
| 63 | #include "uptodate.h" | 62 | #include "uptodate.h" |
| 64 | #include "xattr.h" | 63 | #include "xattr.h" |
| 65 | #include "acl.h" | 64 | #include "acl.h" |
| 65 | #include "ocfs2_trace.h" | ||
| 66 | 66 | ||
| 67 | #include "buffer_head_io.h" | 67 | #include "buffer_head_io.h" |
| 68 | 68 | ||
| @@ -106,17 +106,15 @@ static struct dentry *ocfs2_lookup(struct inode *dir, struct dentry *dentry, | |||
| 106 | struct dentry *ret; | 106 | struct dentry *ret; |
| 107 | struct ocfs2_inode_info *oi; | 107 | struct ocfs2_inode_info *oi; |
| 108 | 108 | ||
| 109 | mlog_entry("(0x%p, 0x%p, '%.*s')\n", dir, dentry, | 109 | trace_ocfs2_lookup(dir, dentry, dentry->d_name.len, |
| 110 | dentry->d_name.len, dentry->d_name.name); | 110 | dentry->d_name.name, |
| 111 | (unsigned long long)OCFS2_I(dir)->ip_blkno, 0); | ||
| 111 | 112 | ||
| 112 | if (dentry->d_name.len > OCFS2_MAX_FILENAME_LEN) { | 113 | if (dentry->d_name.len > OCFS2_MAX_FILENAME_LEN) { |
| 113 | ret = ERR_PTR(-ENAMETOOLONG); | 114 | ret = ERR_PTR(-ENAMETOOLONG); |
| 114 | goto bail; | 115 | goto bail; |
| 115 | } | 116 | } |
| 116 | 117 | ||
| 117 | mlog(0, "find name %.*s in directory %llu\n", dentry->d_name.len, | ||
| 118 | dentry->d_name.name, (unsigned long long)OCFS2_I(dir)->ip_blkno); | ||
| 119 | |||
| 120 | status = ocfs2_inode_lock_nested(dir, NULL, 0, OI_LS_PARENT); | 118 | status = ocfs2_inode_lock_nested(dir, NULL, 0, OI_LS_PARENT); |
| 121 | if (status < 0) { | 119 | if (status < 0) { |
| 122 | if (status != -ENOENT) | 120 | if (status != -ENOENT) |
| @@ -182,7 +180,7 @@ bail_unlock: | |||
| 182 | 180 | ||
| 183 | bail: | 181 | bail: |
| 184 | 182 | ||
| 185 | mlog_exit_ptr(ret); | 183 | trace_ocfs2_lookup_ret(ret); |
| 186 | 184 | ||
| 187 | return ret; | 185 | return ret; |
| 188 | } | 186 | } |
| @@ -235,9 +233,9 @@ static int ocfs2_mknod(struct inode *dir, | |||
| 235 | sigset_t oldset; | 233 | sigset_t oldset; |
| 236 | int did_block_signals = 0; | 234 | int did_block_signals = 0; |
| 237 | 235 | ||
| 238 | mlog_entry("(0x%p, 0x%p, %d, %lu, '%.*s')\n", dir, dentry, mode, | 236 | trace_ocfs2_mknod(dir, dentry, dentry->d_name.len, dentry->d_name.name, |
| 239 | (unsigned long)dev, dentry->d_name.len, | 237 | (unsigned long long)OCFS2_I(dir)->ip_blkno, |
| 240 | dentry->d_name.name); | 238 | (unsigned long)dev, mode); |
| 241 | 239 | ||
| 242 | dquot_initialize(dir); | 240 | dquot_initialize(dir); |
| 243 | 241 | ||
| @@ -354,10 +352,6 @@ static int ocfs2_mknod(struct inode *dir, | |||
| 354 | goto leave; | 352 | goto leave; |
| 355 | did_quota_inode = 1; | 353 | did_quota_inode = 1; |
| 356 | 354 | ||
| 357 | mlog_entry("(0x%p, 0x%p, %d, %lu, '%.*s')\n", dir, dentry, | ||
| 358 | inode->i_mode, (unsigned long)dev, dentry->d_name.len, | ||
| 359 | dentry->d_name.name); | ||
| 360 | |||
| 361 | /* do the real work now. */ | 355 | /* do the real work now. */ |
| 362 | status = ocfs2_mknod_locked(osb, dir, inode, dev, | 356 | status = ocfs2_mknod_locked(osb, dir, inode, dev, |
| 363 | &new_fe_bh, parent_fe_bh, handle, | 357 | &new_fe_bh, parent_fe_bh, handle, |
| @@ -436,9 +430,6 @@ leave: | |||
| 436 | if (did_block_signals) | 430 | if (did_block_signals) |
| 437 | ocfs2_unblock_signals(&oldset); | 431 | ocfs2_unblock_signals(&oldset); |
| 438 | 432 | ||
| 439 | if (status == -ENOSPC) | ||
| 440 | mlog(0, "Disk is full\n"); | ||
| 441 | |||
| 442 | brelse(new_fe_bh); | 433 | brelse(new_fe_bh); |
| 443 | brelse(parent_fe_bh); | 434 | brelse(parent_fe_bh); |
| 444 | kfree(si.name); | 435 | kfree(si.name); |
| @@ -466,7 +457,8 @@ leave: | |||
| 466 | iput(inode); | 457 | iput(inode); |
| 467 | } | 458 | } |
| 468 | 459 | ||
| 469 | mlog_exit(status); | 460 | if (status) |
| 461 | mlog_errno(status); | ||
| 470 | 462 | ||
| 471 | return status; | 463 | return status; |
| 472 | } | 464 | } |
| @@ -577,7 +569,8 @@ leave: | |||
| 577 | } | 569 | } |
| 578 | } | 570 | } |
| 579 | 571 | ||
| 580 | mlog_exit(status); | 572 | if (status) |
| 573 | mlog_errno(status); | ||
| 581 | return status; | 574 | return status; |
| 582 | } | 575 | } |
| 583 | 576 | ||
| @@ -615,10 +608,11 @@ static int ocfs2_mkdir(struct inode *dir, | |||
| 615 | { | 608 | { |
| 616 | int ret; | 609 | int ret; |
| 617 | 610 | ||
| 618 | mlog_entry("(0x%p, 0x%p, %d, '%.*s')\n", dir, dentry, mode, | 611 | trace_ocfs2_mkdir(dir, dentry, dentry->d_name.len, dentry->d_name.name, |
| 619 | dentry->d_name.len, dentry->d_name.name); | 612 | OCFS2_I(dir)->ip_blkno, mode); |
| 620 | ret = ocfs2_mknod(dir, dentry, mode | S_IFDIR, 0); | 613 | ret = ocfs2_mknod(dir, dentry, mode | S_IFDIR, 0); |
| 621 | mlog_exit(ret); | 614 | if (ret) |
| 615 | mlog_errno(ret); | ||
| 622 | 616 | ||
| 623 | return ret; | 617 | return ret; |
| 624 | } | 618 | } |
| @@ -630,10 +624,11 @@ static int ocfs2_create(struct inode *dir, | |||
| 630 | { | 624 | { |
| 631 | int ret; | 625 | int ret; |
| 632 | 626 | ||
| 633 | mlog_entry("(0x%p, 0x%p, %d, '%.*s')\n", dir, dentry, mode, | 627 | trace_ocfs2_create(dir, dentry, dentry->d_name.len, dentry->d_name.name, |
| 634 | dentry->d_name.len, dentry->d_name.name); | 628 | (unsigned long long)OCFS2_I(dir)->ip_blkno, mode); |
| 635 | ret = ocfs2_mknod(dir, dentry, mode | S_IFREG, 0); | 629 | ret = ocfs2_mknod(dir, dentry, mode | S_IFREG, 0); |
| 636 | mlog_exit(ret); | 630 | if (ret) |
| 631 | mlog_errno(ret); | ||
| 637 | 632 | ||
| 638 | return ret; | 633 | return ret; |
| 639 | } | 634 | } |
| @@ -652,9 +647,9 @@ static int ocfs2_link(struct dentry *old_dentry, | |||
| 652 | struct ocfs2_dir_lookup_result lookup = { NULL, }; | 647 | struct ocfs2_dir_lookup_result lookup = { NULL, }; |
| 653 | sigset_t oldset; | 648 | sigset_t oldset; |
| 654 | 649 | ||
| 655 | mlog_entry("(inode=%lu, old='%.*s' new='%.*s')\n", inode->i_ino, | 650 | trace_ocfs2_link((unsigned long long)OCFS2_I(inode)->ip_blkno, |
| 656 | old_dentry->d_name.len, old_dentry->d_name.name, | 651 | old_dentry->d_name.len, old_dentry->d_name.name, |
| 657 | dentry->d_name.len, dentry->d_name.name); | 652 | dentry->d_name.len, dentry->d_name.name); |
| 658 | 653 | ||
| 659 | if (S_ISDIR(inode->i_mode)) | 654 | if (S_ISDIR(inode->i_mode)) |
| 660 | return -EPERM; | 655 | return -EPERM; |
| @@ -757,7 +752,8 @@ out: | |||
| 757 | 752 | ||
| 758 | ocfs2_free_dir_lookup_result(&lookup); | 753 | ocfs2_free_dir_lookup_result(&lookup); |
| 759 | 754 | ||
| 760 | mlog_exit(err); | 755 | if (err) |
| 756 | mlog_errno(err); | ||
| 761 | 757 | ||
| 762 | return err; | 758 | return err; |
| 763 | } | 759 | } |
| @@ -809,19 +805,17 @@ static int ocfs2_unlink(struct inode *dir, | |||
| 809 | struct ocfs2_dir_lookup_result lookup = { NULL, }; | 805 | struct ocfs2_dir_lookup_result lookup = { NULL, }; |
| 810 | struct ocfs2_dir_lookup_result orphan_insert = { NULL, }; | 806 | struct ocfs2_dir_lookup_result orphan_insert = { NULL, }; |
| 811 | 807 | ||
| 812 | mlog_entry("(0x%p, 0x%p, '%.*s')\n", dir, dentry, | 808 | trace_ocfs2_unlink(dir, dentry, dentry->d_name.len, |
| 813 | dentry->d_name.len, dentry->d_name.name); | 809 | dentry->d_name.name, |
| 810 | (unsigned long long)OCFS2_I(dir)->ip_blkno, | ||
| 811 | (unsigned long long)OCFS2_I(inode)->ip_blkno); | ||
| 814 | 812 | ||
| 815 | dquot_initialize(dir); | 813 | dquot_initialize(dir); |
| 816 | 814 | ||
| 817 | BUG_ON(dentry->d_parent->d_inode != dir); | 815 | BUG_ON(dentry->d_parent->d_inode != dir); |
| 818 | 816 | ||
| 819 | mlog(0, "ino = %llu\n", (unsigned long long)OCFS2_I(inode)->ip_blkno); | 817 | if (inode == osb->root_inode) |
| 820 | |||
| 821 | if (inode == osb->root_inode) { | ||
| 822 | mlog(0, "Cannot delete the root directory\n"); | ||
| 823 | return -EPERM; | 818 | return -EPERM; |
| 824 | } | ||
| 825 | 819 | ||
| 826 | status = ocfs2_inode_lock_nested(dir, &parent_node_bh, 1, | 820 | status = ocfs2_inode_lock_nested(dir, &parent_node_bh, 1, |
| 827 | OI_LS_PARENT); | 821 | OI_LS_PARENT); |
| @@ -843,9 +837,10 @@ static int ocfs2_unlink(struct inode *dir, | |||
| 843 | if (OCFS2_I(inode)->ip_blkno != blkno) { | 837 | if (OCFS2_I(inode)->ip_blkno != blkno) { |
| 844 | status = -ENOENT; | 838 | status = -ENOENT; |
| 845 | 839 | ||
| 846 | mlog(0, "ip_blkno %llu != dirent blkno %llu ip_flags = %x\n", | 840 | trace_ocfs2_unlink_noent( |
| 847 | (unsigned long long)OCFS2_I(inode)->ip_blkno, | 841 | (unsigned long long)OCFS2_I(inode)->ip_blkno, |
| 848 | (unsigned long long)blkno, OCFS2_I(inode)->ip_flags); | 842 | (unsigned long long)blkno, |
| 843 | OCFS2_I(inode)->ip_flags); | ||
| 849 | goto leave; | 844 | goto leave; |
| 850 | } | 845 | } |
| 851 | 846 | ||
| @@ -954,7 +949,8 @@ leave: | |||
| 954 | ocfs2_free_dir_lookup_result(&orphan_insert); | 949 | ocfs2_free_dir_lookup_result(&orphan_insert); |
| 955 | ocfs2_free_dir_lookup_result(&lookup); | 950 | ocfs2_free_dir_lookup_result(&lookup); |
| 956 | 951 | ||
| 957 | mlog_exit(status); | 952 | if (status) |
| 953 | mlog_errno(status); | ||
| 958 | 954 | ||
| 959 | return status; | 955 | return status; |
| 960 | } | 956 | } |
| @@ -975,9 +971,8 @@ static int ocfs2_double_lock(struct ocfs2_super *osb, | |||
| 975 | struct buffer_head **tmpbh; | 971 | struct buffer_head **tmpbh; |
| 976 | struct inode *tmpinode; | 972 | struct inode *tmpinode; |
| 977 | 973 | ||
| 978 | mlog_entry("(inode1 = %llu, inode2 = %llu)\n", | 974 | trace_ocfs2_double_lock((unsigned long long)oi1->ip_blkno, |
| 979 | (unsigned long long)oi1->ip_blkno, | 975 | (unsigned long long)oi2->ip_blkno); |
| 980 | (unsigned long long)oi2->ip_blkno); | ||
| 981 | 976 | ||
| 982 | if (*bh1) | 977 | if (*bh1) |
| 983 | *bh1 = NULL; | 978 | *bh1 = NULL; |
| @@ -988,7 +983,6 @@ static int ocfs2_double_lock(struct ocfs2_super *osb, | |||
| 988 | if (oi1->ip_blkno != oi2->ip_blkno) { | 983 | if (oi1->ip_blkno != oi2->ip_blkno) { |
| 989 | if (oi1->ip_blkno < oi2->ip_blkno) { | 984 | if (oi1->ip_blkno < oi2->ip_blkno) { |
| 990 | /* switch id1 and id2 around */ | 985 | /* switch id1 and id2 around */ |
| 991 | mlog(0, "switching them around...\n"); | ||
| 992 | tmpbh = bh2; | 986 | tmpbh = bh2; |
| 993 | bh2 = bh1; | 987 | bh2 = bh1; |
| 994 | bh1 = tmpbh; | 988 | bh1 = tmpbh; |
| @@ -1024,8 +1018,13 @@ static int ocfs2_double_lock(struct ocfs2_super *osb, | |||
| 1024 | mlog_errno(status); | 1018 | mlog_errno(status); |
| 1025 | } | 1019 | } |
| 1026 | 1020 | ||
| 1021 | trace_ocfs2_double_lock_end( | ||
| 1022 | (unsigned long long)OCFS2_I(inode1)->ip_blkno, | ||
| 1023 | (unsigned long long)OCFS2_I(inode2)->ip_blkno); | ||
| 1024 | |||
| 1027 | bail: | 1025 | bail: |
| 1028 | mlog_exit(status); | 1026 | if (status) |
| 1027 | mlog_errno(status); | ||
| 1029 | return status; | 1028 | return status; |
| 1030 | } | 1029 | } |
| 1031 | 1030 | ||
| @@ -1067,10 +1066,9 @@ static int ocfs2_rename(struct inode *old_dir, | |||
| 1067 | /* At some point it might be nice to break this function up a | 1066 | /* At some point it might be nice to break this function up a |
| 1068 | * bit. */ | 1067 | * bit. */ |
| 1069 | 1068 | ||
| 1070 | mlog_entry("(0x%p, 0x%p, 0x%p, 0x%p, from='%.*s' to='%.*s')\n", | 1069 | trace_ocfs2_rename(old_dir, old_dentry, new_dir, new_dentry, |
| 1071 | old_dir, old_dentry, new_dir, new_dentry, | 1070 | old_dentry->d_name.len, old_dentry->d_name.name, |
| 1072 | old_dentry->d_name.len, old_dentry->d_name.name, | 1071 | new_dentry->d_name.len, new_dentry->d_name.name); |
| 1073 | new_dentry->d_name.len, new_dentry->d_name.name); | ||
| 1074 | 1072 | ||
| 1075 | dquot_initialize(old_dir); | 1073 | dquot_initialize(old_dir); |
| 1076 | dquot_initialize(new_dir); | 1074 | dquot_initialize(new_dir); |
| @@ -1227,16 +1225,15 @@ static int ocfs2_rename(struct inode *old_dir, | |||
| 1227 | if (!new_inode) { | 1225 | if (!new_inode) { |
| 1228 | status = -EACCES; | 1226 | status = -EACCES; |
| 1229 | 1227 | ||
| 1230 | mlog(0, "We found an inode for name %.*s but VFS " | 1228 | trace_ocfs2_rename_target_exists(new_dentry->d_name.len, |
| 1231 | "didn't give us one.\n", new_dentry->d_name.len, | 1229 | new_dentry->d_name.name); |
| 1232 | new_dentry->d_name.name); | ||
| 1233 | goto bail; | 1230 | goto bail; |
| 1234 | } | 1231 | } |
| 1235 | 1232 | ||
| 1236 | if (OCFS2_I(new_inode)->ip_blkno != newfe_blkno) { | 1233 | if (OCFS2_I(new_inode)->ip_blkno != newfe_blkno) { |
| 1237 | status = -EACCES; | 1234 | status = -EACCES; |
| 1238 | 1235 | ||
| 1239 | mlog(0, "Inode %llu and dir %llu disagree. flags = %x\n", | 1236 | trace_ocfs2_rename_disagree( |
| 1240 | (unsigned long long)OCFS2_I(new_inode)->ip_blkno, | 1237 | (unsigned long long)OCFS2_I(new_inode)->ip_blkno, |
| 1241 | (unsigned long long)newfe_blkno, | 1238 | (unsigned long long)newfe_blkno, |
| 1242 | OCFS2_I(new_inode)->ip_flags); | 1239 | OCFS2_I(new_inode)->ip_flags); |
| @@ -1259,8 +1256,7 @@ static int ocfs2_rename(struct inode *old_dir, | |||
| 1259 | 1256 | ||
| 1260 | newfe = (struct ocfs2_dinode *) newfe_bh->b_data; | 1257 | newfe = (struct ocfs2_dinode *) newfe_bh->b_data; |
| 1261 | 1258 | ||
| 1262 | mlog(0, "aha rename over existing... new_blkno=%llu " | 1259 | trace_ocfs2_rename_over_existing( |
| 1263 | "newfebh=%p bhblocknr=%llu\n", | ||
| 1264 | (unsigned long long)newfe_blkno, newfe_bh, newfe_bh ? | 1260 | (unsigned long long)newfe_blkno, newfe_bh, newfe_bh ? |
| 1265 | (unsigned long long)newfe_bh->b_blocknr : 0ULL); | 1261 | (unsigned long long)newfe_bh->b_blocknr : 0ULL); |
| 1266 | 1262 | ||
| @@ -1476,7 +1472,8 @@ bail: | |||
| 1476 | brelse(old_dir_bh); | 1472 | brelse(old_dir_bh); |
| 1477 | brelse(new_dir_bh); | 1473 | brelse(new_dir_bh); |
| 1478 | 1474 | ||
| 1479 | mlog_exit(status); | 1475 | if (status) |
| 1476 | mlog_errno(status); | ||
| 1480 | 1477 | ||
| 1481 | return status; | 1478 | return status; |
| 1482 | } | 1479 | } |
| @@ -1501,9 +1498,8 @@ static int ocfs2_create_symlink_data(struct ocfs2_super *osb, | |||
| 1501 | * write i_size + 1 bytes. */ | 1498 | * write i_size + 1 bytes. */ |
| 1502 | blocks = (bytes_left + sb->s_blocksize - 1) >> sb->s_blocksize_bits; | 1499 | blocks = (bytes_left + sb->s_blocksize - 1) >> sb->s_blocksize_bits; |
| 1503 | 1500 | ||
| 1504 | mlog_entry("i_blocks = %llu, i_size = %llu, blocks = %d\n", | 1501 | trace_ocfs2_create_symlink_data((unsigned long long)inode->i_blocks, |
| 1505 | (unsigned long long)inode->i_blocks, | 1502 | i_size_read(inode), blocks); |
| 1506 | i_size_read(inode), blocks); | ||
| 1507 | 1503 | ||
| 1508 | /* Sanity check -- make sure we're going to fit. */ | 1504 | /* Sanity check -- make sure we're going to fit. */ |
| 1509 | if (bytes_left > | 1505 | if (bytes_left > |
| @@ -1579,7 +1575,8 @@ bail: | |||
| 1579 | kfree(bhs); | 1575 | kfree(bhs); |
| 1580 | } | 1576 | } |
| 1581 | 1577 | ||
| 1582 | mlog_exit(status); | 1578 | if (status) |
| 1579 | mlog_errno(status); | ||
| 1583 | return status; | 1580 | return status; |
| 1584 | } | 1581 | } |
| 1585 | 1582 | ||
| @@ -1610,8 +1607,8 @@ static int ocfs2_symlink(struct inode *dir, | |||
| 1610 | sigset_t oldset; | 1607 | sigset_t oldset; |
| 1611 | int did_block_signals = 0; | 1608 | int did_block_signals = 0; |
| 1612 | 1609 | ||
| 1613 | mlog_entry("(0x%p, 0x%p, symname='%s' actual='%.*s')\n", dir, | 1610 | trace_ocfs2_symlink_begin(dir, dentry, symname, |
| 1614 | dentry, symname, dentry->d_name.len, dentry->d_name.name); | 1611 | dentry->d_name.len, dentry->d_name.name); |
| 1615 | 1612 | ||
| 1616 | dquot_initialize(dir); | 1613 | dquot_initialize(dir); |
| 1617 | 1614 | ||
| @@ -1713,9 +1710,10 @@ static int ocfs2_symlink(struct inode *dir, | |||
| 1713 | goto bail; | 1710 | goto bail; |
| 1714 | did_quota_inode = 1; | 1711 | did_quota_inode = 1; |
| 1715 | 1712 | ||
| 1716 | mlog_entry("(0x%p, 0x%p, %d, '%.*s')\n", dir, dentry, | 1713 | trace_ocfs2_symlink_create(dir, dentry, dentry->d_name.len, |
| 1717 | inode->i_mode, dentry->d_name.len, | 1714 | dentry->d_name.name, |
| 1718 | dentry->d_name.name); | 1715 | (unsigned long long)OCFS2_I(dir)->ip_blkno, |
| 1716 | inode->i_mode); | ||
| 1719 | 1717 | ||
| 1720 | status = ocfs2_mknod_locked(osb, dir, inode, | 1718 | status = ocfs2_mknod_locked(osb, dir, inode, |
| 1721 | 0, &new_fe_bh, parent_fe_bh, handle, | 1719 | 0, &new_fe_bh, parent_fe_bh, handle, |
| @@ -1835,7 +1833,8 @@ bail: | |||
| 1835 | iput(inode); | 1833 | iput(inode); |
| 1836 | } | 1834 | } |
| 1837 | 1835 | ||
| 1838 | mlog_exit(status); | 1836 | if (status) |
| 1837 | mlog_errno(status); | ||
| 1839 | 1838 | ||
| 1840 | return status; | 1839 | return status; |
| 1841 | } | 1840 | } |
| @@ -1844,8 +1843,6 @@ static int ocfs2_blkno_stringify(u64 blkno, char *name) | |||
| 1844 | { | 1843 | { |
| 1845 | int status, namelen; | 1844 | int status, namelen; |
| 1846 | 1845 | ||
| 1847 | mlog_entry_void(); | ||
| 1848 | |||
| 1849 | namelen = snprintf(name, OCFS2_ORPHAN_NAMELEN + 1, "%016llx", | 1846 | namelen = snprintf(name, OCFS2_ORPHAN_NAMELEN + 1, "%016llx", |
| 1850 | (long long)blkno); | 1847 | (long long)blkno); |
| 1851 | if (namelen <= 0) { | 1848 | if (namelen <= 0) { |
| @@ -1862,12 +1859,12 @@ static int ocfs2_blkno_stringify(u64 blkno, char *name) | |||
| 1862 | goto bail; | 1859 | goto bail; |
| 1863 | } | 1860 | } |
| 1864 | 1861 | ||
| 1865 | mlog(0, "built filename '%s' for orphan dir (len=%d)\n", name, | 1862 | trace_ocfs2_blkno_stringify(blkno, name, namelen); |
| 1866 | namelen); | ||
| 1867 | 1863 | ||
| 1868 | status = 0; | 1864 | status = 0; |
| 1869 | bail: | 1865 | bail: |
| 1870 | mlog_exit(status); | 1866 | if (status < 0) |
| 1867 | mlog_errno(status); | ||
| 1871 | return status; | 1868 | return status; |
| 1872 | } | 1869 | } |
| 1873 | 1870 | ||
| @@ -1980,7 +1977,8 @@ out: | |||
| 1980 | iput(orphan_dir_inode); | 1977 | iput(orphan_dir_inode); |
| 1981 | } | 1978 | } |
| 1982 | 1979 | ||
| 1983 | mlog_exit(ret); | 1980 | if (ret) |
| 1981 | mlog_errno(ret); | ||
| 1984 | return ret; | 1982 | return ret; |
| 1985 | } | 1983 | } |
| 1986 | 1984 | ||
| @@ -1997,7 +1995,8 @@ static int ocfs2_orphan_add(struct ocfs2_super *osb, | |||
| 1997 | struct ocfs2_dinode *orphan_fe; | 1995 | struct ocfs2_dinode *orphan_fe; |
| 1998 | struct ocfs2_dinode *fe = (struct ocfs2_dinode *) fe_bh->b_data; | 1996 | struct ocfs2_dinode *fe = (struct ocfs2_dinode *) fe_bh->b_data; |
| 1999 | 1997 | ||
| 2000 | mlog_entry("(inode->i_ino = %lu)\n", inode->i_ino); | 1998 | trace_ocfs2_orphan_add_begin( |
| 1999 | (unsigned long long)OCFS2_I(inode)->ip_blkno); | ||
| 2001 | 2000 | ||
| 2002 | status = ocfs2_read_inode_block(orphan_dir_inode, &orphan_dir_bh); | 2001 | status = ocfs2_read_inode_block(orphan_dir_inode, &orphan_dir_bh); |
| 2003 | if (status < 0) { | 2002 | if (status < 0) { |
| @@ -2056,13 +2055,14 @@ static int ocfs2_orphan_add(struct ocfs2_super *osb, | |||
| 2056 | 2055 | ||
| 2057 | ocfs2_journal_dirty(handle, fe_bh); | 2056 | ocfs2_journal_dirty(handle, fe_bh); |
| 2058 | 2057 | ||
| 2059 | mlog(0, "Inode %llu orphaned in slot %d\n", | 2058 | trace_ocfs2_orphan_add_end((unsigned long long)OCFS2_I(inode)->ip_blkno, |
| 2060 | (unsigned long long)OCFS2_I(inode)->ip_blkno, osb->slot_num); | 2059 | osb->slot_num); |
| 2061 | 2060 | ||
| 2062 | leave: | 2061 | leave: |
| 2063 | brelse(orphan_dir_bh); | 2062 | brelse(orphan_dir_bh); |
| 2064 | 2063 | ||
| 2065 | mlog_exit(status); | 2064 | if (status) |
| 2065 | mlog_errno(status); | ||
| 2066 | return status; | 2066 | return status; |
| 2067 | } | 2067 | } |
| 2068 | 2068 | ||
| @@ -2078,17 +2078,15 @@ int ocfs2_orphan_del(struct ocfs2_super *osb, | |||
| 2078 | int status = 0; | 2078 | int status = 0; |
| 2079 | struct ocfs2_dir_lookup_result lookup = { NULL, }; | 2079 | struct ocfs2_dir_lookup_result lookup = { NULL, }; |
| 2080 | 2080 | ||
| 2081 | mlog_entry_void(); | ||
| 2082 | |||
| 2083 | status = ocfs2_blkno_stringify(OCFS2_I(inode)->ip_blkno, name); | 2081 | status = ocfs2_blkno_stringify(OCFS2_I(inode)->ip_blkno, name); |
| 2084 | if (status < 0) { | 2082 | if (status < 0) { |
| 2085 | mlog_errno(status); | 2083 | mlog_errno(status); |
| 2086 | goto leave; | 2084 | goto leave; |
| 2087 | } | 2085 | } |
| 2088 | 2086 | ||
| 2089 | mlog(0, "removing '%s' from orphan dir %llu (namelen=%d)\n", | 2087 | trace_ocfs2_orphan_del( |
| 2090 | name, (unsigned long long)OCFS2_I(orphan_dir_inode)->ip_blkno, | 2088 | (unsigned long long)OCFS2_I(orphan_dir_inode)->ip_blkno, |
| 2091 | OCFS2_ORPHAN_NAMELEN); | 2089 | name, OCFS2_ORPHAN_NAMELEN); |
| 2092 | 2090 | ||
| 2093 | /* find it's spot in the orphan directory */ | 2091 | /* find it's spot in the orphan directory */ |
| 2094 | status = ocfs2_find_entry(name, OCFS2_ORPHAN_NAMELEN, orphan_dir_inode, | 2092 | status = ocfs2_find_entry(name, OCFS2_ORPHAN_NAMELEN, orphan_dir_inode, |
| @@ -2124,7 +2122,8 @@ int ocfs2_orphan_del(struct ocfs2_super *osb, | |||
| 2124 | leave: | 2122 | leave: |
| 2125 | ocfs2_free_dir_lookup_result(&lookup); | 2123 | ocfs2_free_dir_lookup_result(&lookup); |
| 2126 | 2124 | ||
| 2127 | mlog_exit(status); | 2125 | if (status) |
| 2126 | mlog_errno(status); | ||
| 2128 | return status; | 2127 | return status; |
| 2129 | } | 2128 | } |
| 2130 | 2129 | ||
| @@ -2321,9 +2320,6 @@ leave: | |||
| 2321 | iput(orphan_dir); | 2320 | iput(orphan_dir); |
| 2322 | } | 2321 | } |
| 2323 | 2322 | ||
| 2324 | if (status == -ENOSPC) | ||
| 2325 | mlog(0, "Disk is full\n"); | ||
| 2326 | |||
| 2327 | if ((status < 0) && inode) { | 2323 | if ((status < 0) && inode) { |
| 2328 | clear_nlink(inode); | 2324 | clear_nlink(inode); |
| 2329 | iput(inode); | 2325 | iput(inode); |
| @@ -2358,8 +2354,10 @@ int ocfs2_mv_orphaned_inode_to_new(struct inode *dir, | |||
| 2358 | struct buffer_head *di_bh = NULL; | 2354 | struct buffer_head *di_bh = NULL; |
| 2359 | struct ocfs2_dir_lookup_result lookup = { NULL, }; | 2355 | struct ocfs2_dir_lookup_result lookup = { NULL, }; |
| 2360 | 2356 | ||
| 2361 | mlog_entry("(0x%p, 0x%p, %.*s')\n", dir, dentry, | 2357 | trace_ocfs2_mv_orphaned_inode_to_new(dir, dentry, |
| 2362 | dentry->d_name.len, dentry->d_name.name); | 2358 | dentry->d_name.len, dentry->d_name.name, |
| 2359 | (unsigned long long)OCFS2_I(dir)->ip_blkno, | ||
| 2360 | (unsigned long long)OCFS2_I(inode)->ip_blkno); | ||
| 2363 | 2361 | ||
| 2364 | status = ocfs2_inode_lock(dir, &parent_di_bh, 1); | 2362 | status = ocfs2_inode_lock(dir, &parent_di_bh, 1); |
| 2365 | if (status < 0) { | 2363 | if (status < 0) { |
| @@ -2476,7 +2474,8 @@ leave: | |||
| 2476 | 2474 | ||
| 2477 | ocfs2_free_dir_lookup_result(&lookup); | 2475 | ocfs2_free_dir_lookup_result(&lookup); |
| 2478 | 2476 | ||
| 2479 | mlog_exit(status); | 2477 | if (status) |
| 2478 | mlog_errno(status); | ||
| 2480 | 2479 | ||
| 2481 | return status; | 2480 | return status; |
| 2482 | } | 2481 | } |
diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h index 1a97ba1ec3f..409285854f6 100644 --- a/fs/ocfs2/ocfs2.h +++ b/fs/ocfs2/ocfs2.h | |||
| @@ -147,6 +147,17 @@ struct ocfs2_lock_res_ops; | |||
| 147 | 147 | ||
| 148 | typedef void (*ocfs2_lock_callback)(int status, unsigned long data); | 148 | typedef void (*ocfs2_lock_callback)(int status, unsigned long data); |
| 149 | 149 | ||
| 150 | #ifdef CONFIG_OCFS2_FS_STATS | ||
| 151 | struct ocfs2_lock_stats { | ||
| 152 | u64 ls_total; /* Total wait in NSEC */ | ||
| 153 | u32 ls_gets; /* Num acquires */ | ||
| 154 | u32 ls_fail; /* Num failed acquires */ | ||
| 155 | |||
| 156 | /* Storing max wait in usecs saves 24 bytes per inode */ | ||
| 157 | u32 ls_max; /* Max wait in USEC */ | ||
| 158 | }; | ||
| 159 | #endif | ||
| 160 | |||
| 150 | struct ocfs2_lock_res { | 161 | struct ocfs2_lock_res { |
| 151 | void *l_priv; | 162 | void *l_priv; |
| 152 | struct ocfs2_lock_res_ops *l_ops; | 163 | struct ocfs2_lock_res_ops *l_ops; |
| @@ -182,15 +193,9 @@ struct ocfs2_lock_res { | |||
| 182 | struct list_head l_debug_list; | 193 | struct list_head l_debug_list; |
| 183 | 194 | ||
| 184 | #ifdef CONFIG_OCFS2_FS_STATS | 195 | #ifdef CONFIG_OCFS2_FS_STATS |
| 185 | unsigned long long l_lock_num_prmode; /* PR acquires */ | 196 | struct ocfs2_lock_stats l_lock_prmode; /* PR mode stats */ |
| 186 | unsigned long long l_lock_num_exmode; /* EX acquires */ | 197 | u32 l_lock_refresh; /* Disk refreshes */ |
| 187 | unsigned int l_lock_num_prmode_failed; /* Failed PR gets */ | 198 | struct ocfs2_lock_stats l_lock_exmode; /* EX mode stats */ |
| 188 | unsigned int l_lock_num_exmode_failed; /* Failed EX gets */ | ||
| 189 | unsigned long long l_lock_total_prmode; /* Tot wait for PR */ | ||
| 190 | unsigned long long l_lock_total_exmode; /* Tot wait for EX */ | ||
| 191 | unsigned int l_lock_max_prmode; /* Max wait for PR */ | ||
| 192 | unsigned int l_lock_max_exmode; /* Max wait for EX */ | ||
| 193 | unsigned int l_lock_refresh; /* Disk refreshes */ | ||
| 194 | #endif | 199 | #endif |
| 195 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | 200 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
| 196 | struct lockdep_map l_lockdep_map; | 201 | struct lockdep_map l_lockdep_map; |
diff --git a/fs/ocfs2/ocfs2_trace.h b/fs/ocfs2/ocfs2_trace.h new file mode 100644 index 00000000000..a1dae5bb54a --- /dev/null +++ b/fs/ocfs2/ocfs2_trace.h | |||
| @@ -0,0 +1,2739 @@ | |||
| 1 | #undef TRACE_SYSTEM | ||
| 2 | #define TRACE_SYSTEM ocfs2 | ||
| 3 | |||
| 4 | #if !defined(_TRACE_OCFS2_H) || defined(TRACE_HEADER_MULTI_READ) | ||
| 5 | #define _TRACE_OCFS2_H | ||
| 6 | |||
| 7 | #include <linux/tracepoint.h> | ||
| 8 | |||
| 9 | DECLARE_EVENT_CLASS(ocfs2__int, | ||
| 10 | TP_PROTO(int num), | ||
| 11 | TP_ARGS(num), | ||
| 12 | TP_STRUCT__entry( | ||
| 13 | __field(int, num) | ||
| 14 | ), | ||
| 15 | TP_fast_assign( | ||
| 16 | __entry->num = num; | ||
| 17 | ), | ||
| 18 | TP_printk("%d", __entry->num) | ||
| 19 | ); | ||
| 20 | |||
| 21 | #define DEFINE_OCFS2_INT_EVENT(name) \ | ||
| 22 | DEFINE_EVENT(ocfs2__int, name, \ | ||
| 23 | TP_PROTO(int num), \ | ||
| 24 | TP_ARGS(num)) | ||
| 25 | |||
| 26 | DECLARE_EVENT_CLASS(ocfs2__uint, | ||
| 27 | TP_PROTO(unsigned int num), | ||
| 28 | TP_ARGS(num), | ||
| 29 | TP_STRUCT__entry( | ||
| 30 | __field( unsigned int, num ) | ||
| 31 | ), | ||
| 32 | TP_fast_assign( | ||
| 33 | __entry->num = num; | ||
| 34 | ), | ||
| 35 | TP_printk("%u", __entry->num) | ||
| 36 | ); | ||
| 37 | |||
| 38 | #define DEFINE_OCFS2_UINT_EVENT(name) \ | ||
| 39 | DEFINE_EVENT(ocfs2__uint, name, \ | ||
| 40 | TP_PROTO(unsigned int num), \ | ||
| 41 | TP_ARGS(num)) | ||
| 42 | |||
| 43 | DECLARE_EVENT_CLASS(ocfs2__ull, | ||
| 44 | TP_PROTO(unsigned long long blkno), | ||
| 45 | TP_ARGS(blkno), | ||
| 46 | TP_STRUCT__entry( | ||
| 47 | __field(unsigned long long, blkno) | ||
| 48 | ), | ||
| 49 | TP_fast_assign( | ||
| 50 | __entry->blkno = blkno; | ||
| 51 | ), | ||
| 52 | TP_printk("%llu", __entry->blkno) | ||
| 53 | ); | ||
| 54 | |||
| 55 | #define DEFINE_OCFS2_ULL_EVENT(name) \ | ||
| 56 | DEFINE_EVENT(ocfs2__ull, name, \ | ||
| 57 | TP_PROTO(unsigned long long num), \ | ||
| 58 | TP_ARGS(num)) | ||
| 59 | |||
| 60 | DECLARE_EVENT_CLASS(ocfs2__pointer, | ||
| 61 | TP_PROTO(void *pointer), | ||
| 62 | TP_ARGS(pointer), | ||
| 63 | TP_STRUCT__entry( | ||
| 64 | __field(void *, pointer) | ||
| 65 | ), | ||
| 66 | TP_fast_assign( | ||
| 67 | __entry->pointer = pointer; | ||
| 68 | ), | ||
| 69 | TP_printk("%p", __entry->pointer) | ||
| 70 | ); | ||
| 71 | |||
| 72 | #define DEFINE_OCFS2_POINTER_EVENT(name) \ | ||
| 73 | DEFINE_EVENT(ocfs2__pointer, name, \ | ||
| 74 | TP_PROTO(void *pointer), \ | ||
| 75 | TP_ARGS(pointer)) | ||
| 76 | |||
| 77 | DECLARE_EVENT_CLASS(ocfs2__string, | ||
| 78 | TP_PROTO(const char *name), | ||
| 79 | TP_ARGS(name), | ||
| 80 | TP_STRUCT__entry( | ||
| 81 | __string(name,name) | ||
| 82 | ), | ||
| 83 | TP_fast_assign( | ||
| 84 | __assign_str(name, name); | ||
| 85 | ), | ||
| 86 | TP_printk("%s", __get_str(name)) | ||
| 87 | ); | ||
| 88 | |||
| 89 | #define DEFINE_OCFS2_STRING_EVENT(name) \ | ||
| 90 | DEFINE_EVENT(ocfs2__string, name, \ | ||
| 91 | TP_PROTO(const char *name), \ | ||
| 92 | TP_ARGS(name)) | ||
| 93 | |||
| 94 | DECLARE_EVENT_CLASS(ocfs2__int_int, | ||
| 95 | TP_PROTO(int value1, int value2), | ||
| 96 | TP_ARGS(value1, value2), | ||
| 97 | TP_STRUCT__entry( | ||
| 98 | __field(int, value1) | ||
| 99 | __field(int, value2) | ||
| 100 | ), | ||
| 101 | TP_fast_assign( | ||
| 102 | __entry->value1 = value1; | ||
| 103 | __entry->value2 = value2; | ||
| 104 | ), | ||
| 105 | TP_printk("%d %d", __entry->value1, __entry->value2) | ||
| 106 | ); | ||
| 107 | |||
| 108 | #define DEFINE_OCFS2_INT_INT_EVENT(name) \ | ||
| 109 | DEFINE_EVENT(ocfs2__int_int, name, \ | ||
| 110 | TP_PROTO(int val1, int val2), \ | ||
| 111 | TP_ARGS(val1, val2)) | ||
| 112 | |||
| 113 | DECLARE_EVENT_CLASS(ocfs2__uint_int, | ||
| 114 | TP_PROTO(unsigned int value1, int value2), | ||
| 115 | TP_ARGS(value1, value2), | ||
| 116 | TP_STRUCT__entry( | ||
| 117 | __field(unsigned int, value1) | ||
| 118 | __field(int, value2) | ||
| 119 | ), | ||
| 120 | TP_fast_assign( | ||
| 121 | __entry->value1 = value1; | ||
| 122 | __entry->value2 = value2; | ||
| 123 | ), | ||
| 124 | TP_printk("%u %d", __entry->value1, __entry->value2) | ||
| 125 | ); | ||
| 126 | |||
| 127 | #define DEFINE_OCFS2_UINT_INT_EVENT(name) \ | ||
| 128 | DEFINE_EVENT(ocfs2__uint_int, name, \ | ||
| 129 | TP_PROTO(unsigned int val1, int val2), \ | ||
| 130 | TP_ARGS(val1, val2)) | ||
| 131 | |||
| 132 | DECLARE_EVENT_CLASS(ocfs2__uint_uint, | ||
| 133 | TP_PROTO(unsigned int value1, unsigned int value2), | ||
| 134 | TP_ARGS(value1, value2), | ||
| 135 | TP_STRUCT__entry( | ||
| 136 | __field(unsigned int, value1) | ||
| 137 | __field(unsigned int, value2) | ||
| 138 | ), | ||
| 139 | TP_fast_assign( | ||
| 140 | __entry->value1 = value1; | ||
| 141 | __entry->value2 = value2; | ||
| 142 | ), | ||
| 143 | TP_printk("%u %u", __entry->value1, __entry->value2) | ||
| 144 | ); | ||
| 145 | |||
| 146 | #define DEFINE_OCFS2_UINT_UINT_EVENT(name) \ | ||
| 147 | DEFINE_EVENT(ocfs2__uint_uint, name, \ | ||
| 148 | TP_PROTO(unsigned int val1, unsigned int val2), \ | ||
| 149 | TP_ARGS(val1, val2)) | ||
| 150 | |||
| 151 | DECLARE_EVENT_CLASS(ocfs2__ull_uint, | ||
| 152 | TP_PROTO(unsigned long long value1, unsigned int value2), | ||
| 153 | TP_ARGS(value1, value2), | ||
| 154 | TP_STRUCT__entry( | ||
| 155 | __field(unsigned long long, value1) | ||
| 156 | __field(unsigned int, value2) | ||
| 157 | ), | ||
| 158 | TP_fast_assign( | ||
| 159 | __entry->value1 = value1; | ||
| 160 | __entry->value2 = value2; | ||
| 161 | ), | ||
| 162 | TP_printk("%llu %u", __entry->value1, __entry->value2) | ||
| 163 | ); | ||
| 164 | |||
| 165 | #define DEFINE_OCFS2_ULL_UINT_EVENT(name) \ | ||
| 166 | DEFINE_EVENT(ocfs2__ull_uint, name, \ | ||
| 167 | TP_PROTO(unsigned long long val1, unsigned int val2), \ | ||
| 168 | TP_ARGS(val1, val2)) | ||
| 169 | |||
| 170 | DECLARE_EVENT_CLASS(ocfs2__ull_int, | ||
| 171 | TP_PROTO(unsigned long long value1, int value2), | ||
| 172 | TP_ARGS(value1, value2), | ||
| 173 | TP_STRUCT__entry( | ||
| 174 | __field(unsigned long long, value1) | ||
| 175 | __field(int, value2) | ||
| 176 | ), | ||
| 177 | TP_fast_assign( | ||
| 178 | __entry->value1 = value1; | ||
| 179 | __entry->value2 = value2; | ||
| 180 | ), | ||
| 181 | TP_printk("%llu %d", __entry->value1, __entry->value2) | ||
| 182 | ); | ||
| 183 | |||
| 184 | #define DEFINE_OCFS2_ULL_INT_EVENT(name) \ | ||
| 185 | DEFINE_EVENT(ocfs2__ull_int, name, \ | ||
| 186 | TP_PROTO(unsigned long long val1, int val2), \ | ||
| 187 | TP_ARGS(val1, val2)) | ||
| 188 | |||
| 189 | DECLARE_EVENT_CLASS(ocfs2__ull_ull, | ||
| 190 | TP_PROTO(unsigned long long value1, unsigned long long value2), | ||
| 191 | TP_ARGS(value1, value2), | ||
| 192 | TP_STRUCT__entry( | ||
| 193 | __field(unsigned long long, value1) | ||
| 194 | __field(unsigned long long, value2) | ||
| 195 | ), | ||
| 196 | TP_fast_assign( | ||
| 197 | __entry->value1 = value1; | ||
| 198 | __entry->value2 = value2; | ||
| 199 | ), | ||
| 200 | TP_printk("%llu %llu", __entry->value1, __entry->value2) | ||
| 201 | ); | ||
| 202 | |||
| 203 | #define DEFINE_OCFS2_ULL_ULL_EVENT(name) \ | ||
| 204 | DEFINE_EVENT(ocfs2__ull_ull, name, \ | ||
| 205 | TP_PROTO(unsigned long long val1, unsigned long long val2), \ | ||
| 206 | TP_ARGS(val1, val2)) | ||
| 207 | |||
| 208 | DECLARE_EVENT_CLASS(ocfs2__ull_ull_uint, | ||
| 209 | TP_PROTO(unsigned long long value1, | ||
| 210 | unsigned long long value2, unsigned int value3), | ||
| 211 | TP_ARGS(value1, value2, value3), | ||
| 212 | TP_STRUCT__entry( | ||
| 213 | __field(unsigned long long, value1) | ||
| 214 | __field(unsigned long long, value2) | ||
| 215 | __field(unsigned int, value3) | ||
| 216 | ), | ||
| 217 | TP_fast_assign( | ||
| 218 | __entry->value1 = value1; | ||
| 219 | __entry->value2 = value2; | ||
| 220 | __entry->value3 = value3; | ||
| 221 | ), | ||
| 222 | TP_printk("%llu %llu %u", | ||
| 223 | __entry->value1, __entry->value2, __entry->value3) | ||
| 224 | ); | ||
| 225 | |||
| 226 | #define DEFINE_OCFS2_ULL_ULL_UINT_EVENT(name) \ | ||
| 227 | DEFINE_EVENT(ocfs2__ull_ull_uint, name, \ | ||
| 228 | TP_PROTO(unsigned long long val1, \ | ||
| 229 | unsigned long long val2, unsigned int val3), \ | ||
| 230 | TP_ARGS(val1, val2, val3)) | ||
| 231 | |||
| 232 | DECLARE_EVENT_CLASS(ocfs2__ull_uint_uint, | ||
| 233 | TP_PROTO(unsigned long long value1, | ||
| 234 | unsigned int value2, unsigned int value3), | ||
| 235 | TP_ARGS(value1, value2, value3), | ||
| 236 | TP_STRUCT__entry( | ||
| 237 | __field(unsigned long long, value1) | ||
| 238 | __field(unsigned int, value2) | ||
| 239 | __field(unsigned int, value3) | ||
| 240 | ), | ||
| 241 | TP_fast_assign( | ||
| 242 | __entry->value1 = value1; | ||
| 243 | __entry->value2 = value2; | ||
| 244 | __entry->value3 = value3; | ||
| 245 | ), | ||
| 246 | TP_printk("%llu %u %u", __entry->value1, | ||
| 247 | __entry->value2, __entry->value3) | ||
| 248 | ); | ||
| 249 | |||
| 250 | #define DEFINE_OCFS2_ULL_UINT_UINT_EVENT(name) \ | ||
| 251 | DEFINE_EVENT(ocfs2__ull_uint_uint, name, \ | ||
| 252 | TP_PROTO(unsigned long long val1, \ | ||
| 253 | unsigned int val2, unsigned int val3), \ | ||
| 254 | TP_ARGS(val1, val2, val3)) | ||
| 255 | |||
| 256 | DECLARE_EVENT_CLASS(ocfs2__uint_uint_uint, | ||
| 257 | TP_PROTO(unsigned int value1, unsigned int value2, | ||
| 258 | unsigned int value3), | ||
| 259 | TP_ARGS(value1, value2, value3), | ||
| 260 | TP_STRUCT__entry( | ||
| 261 | __field( unsigned int, value1 ) | ||
| 262 | __field( unsigned int, value2 ) | ||
| 263 | __field( unsigned int, value3 ) | ||
| 264 | ), | ||
| 265 | TP_fast_assign( | ||
| 266 | __entry->value1 = value1; | ||
| 267 | __entry->value2 = value2; | ||
| 268 | __entry->value3 = value3; | ||
| 269 | ), | ||
| 270 | TP_printk("%u %u %u", __entry->value1, __entry->value2, __entry->value3) | ||
| 271 | ); | ||
| 272 | |||
| 273 | #define DEFINE_OCFS2_UINT_UINT_UINT_EVENT(name) \ | ||
| 274 | DEFINE_EVENT(ocfs2__uint_uint_uint, name, \ | ||
| 275 | TP_PROTO(unsigned int value1, unsigned int value2, \ | ||
| 276 | unsigned int value3), \ | ||
| 277 | TP_ARGS(value1, value2, value3)) | ||
| 278 | |||
| 279 | DECLARE_EVENT_CLASS(ocfs2__ull_ull_ull, | ||
| 280 | TP_PROTO(unsigned long long value1, | ||
| 281 | unsigned long long value2, unsigned long long value3), | ||
| 282 | TP_ARGS(value1, value2, value3), | ||
| 283 | TP_STRUCT__entry( | ||
| 284 | __field(unsigned long long, value1) | ||
| 285 | __field(unsigned long long, value2) | ||
| 286 | __field(unsigned long long, value3) | ||
| 287 | ), | ||
| 288 | TP_fast_assign( | ||
| 289 | __entry->value1 = value1; | ||
| 290 | __entry->value2 = value2; | ||
| 291 | __entry->value3 = value3; | ||
| 292 | ), | ||
| 293 | TP_printk("%llu %llu %llu", | ||
| 294 | __entry->value1, __entry->value2, __entry->value3) | ||
| 295 | ); | ||
| 296 | |||
| 297 | #define DEFINE_OCFS2_ULL_ULL_ULL_EVENT(name) \ | ||
| 298 | DEFINE_EVENT(ocfs2__ull_ull_ull, name, \ | ||
| 299 | TP_PROTO(unsigned long long value1, unsigned long long value2, \ | ||
| 300 | unsigned long long value3), \ | ||
| 301 | TP_ARGS(value1, value2, value3)) | ||
| 302 | |||
| 303 | DECLARE_EVENT_CLASS(ocfs2__ull_int_int_int, | ||
| 304 | TP_PROTO(unsigned long long ull, int value1, int value2, int value3), | ||
| 305 | TP_ARGS(ull, value1, value2, value3), | ||
| 306 | TP_STRUCT__entry( | ||
| 307 | __field( unsigned long long, ull ) | ||
| 308 | __field( int, value1 ) | ||
| 309 | __field( int, value2 ) | ||
| 310 | __field( int, value3 ) | ||
| 311 | ), | ||
| 312 | TP_fast_assign( | ||
| 313 | __entry->ull = ull; | ||
| 314 | __entry->value1 = value1; | ||
| 315 | __entry->value2 = value2; | ||
| 316 | __entry->value3 = value3; | ||
| 317 | ), | ||
| 318 | TP_printk("%llu %d %d %d", | ||
| 319 | __entry->ull, __entry->value1, | ||
| 320 | __entry->value2, __entry->value3) | ||
| 321 | ); | ||
| 322 | |||
| 323 | #define DEFINE_OCFS2_ULL_INT_INT_INT_EVENT(name) \ | ||
| 324 | DEFINE_EVENT(ocfs2__ull_int_int_int, name, \ | ||
| 325 | TP_PROTO(unsigned long long ull, int value1, \ | ||
| 326 | int value2, int value3), \ | ||
| 327 | TP_ARGS(ull, value1, value2, value3)) | ||
| 328 | |||
| 329 | DECLARE_EVENT_CLASS(ocfs2__ull_uint_uint_uint, | ||
| 330 | TP_PROTO(unsigned long long ull, unsigned int value1, | ||
| 331 | unsigned int value2, unsigned int value3), | ||
| 332 | TP_ARGS(ull, value1, value2, value3), | ||
| 333 | TP_STRUCT__entry( | ||
| 334 | __field(unsigned long long, ull) | ||
| 335 | __field(unsigned int, value1) | ||
| 336 | __field(unsigned int, value2) | ||
| 337 | __field(unsigned int, value3) | ||
| 338 | ), | ||
| 339 | TP_fast_assign( | ||
| 340 | __entry->ull = ull; | ||
| 341 | __entry->value1 = value1; | ||
| 342 | __entry->value2 = value2; | ||
| 343 | __entry->value3 = value3; | ||
| 344 | ), | ||
| 345 | TP_printk("%llu %u %u %u", | ||
| 346 | __entry->ull, __entry->value1, | ||
| 347 | __entry->value2, __entry->value3) | ||
| 348 | ); | ||
| 349 | |||
| 350 | #define DEFINE_OCFS2_ULL_UINT_UINT_UINT_EVENT(name) \ | ||
| 351 | DEFINE_EVENT(ocfs2__ull_uint_uint_uint, name, \ | ||
| 352 | TP_PROTO(unsigned long long ull, unsigned int value1, \ | ||
| 353 | unsigned int value2, unsigned int value3), \ | ||
| 354 | TP_ARGS(ull, value1, value2, value3)) | ||
| 355 | |||
| 356 | DECLARE_EVENT_CLASS(ocfs2__ull_ull_uint_uint, | ||
| 357 | TP_PROTO(unsigned long long value1, unsigned long long value2, | ||
| 358 | unsigned int value3, unsigned int value4), | ||
| 359 | TP_ARGS(value1, value2, value3, value4), | ||
| 360 | TP_STRUCT__entry( | ||
| 361 | __field(unsigned long long, value1) | ||
| 362 | __field(unsigned long long, value2) | ||
| 363 | __field(unsigned int, value3) | ||
| 364 | __field(unsigned int, value4) | ||
| 365 | ), | ||
| 366 | TP_fast_assign( | ||
| 367 | __entry->value1 = value1; | ||
| 368 | __entry->value2 = value2; | ||
| 369 | __entry->value3 = value3; | ||
| 370 | __entry->value4 = value4; | ||
| 371 | ), | ||
| 372 | TP_printk("%llu %llu %u %u", | ||
| 373 | __entry->value1, __entry->value2, | ||
| 374 | __entry->value3, __entry->value4) | ||
| 375 | ); | ||
| 376 | |||
| 377 | #define DEFINE_OCFS2_ULL_ULL_UINT_UINT_EVENT(name) \ | ||
| 378 | DEFINE_EVENT(ocfs2__ull_ull_uint_uint, name, \ | ||
| 379 | TP_PROTO(unsigned long long ull, unsigned long long ull1, \ | ||
| 380 | unsigned int value2, unsigned int value3), \ | ||
| 381 | TP_ARGS(ull, ull1, value2, value3)) | ||
| 382 | |||
| 383 | /* Trace events for fs/ocfs2/alloc.c. */ | ||
| 384 | DECLARE_EVENT_CLASS(ocfs2__btree_ops, | ||
| 385 | TP_PROTO(unsigned long long owner,\ | ||
| 386 | unsigned int value1, unsigned int value2), | ||
| 387 | TP_ARGS(owner, value1, value2), | ||
| 388 | TP_STRUCT__entry( | ||
| 389 | __field(unsigned long long, owner) | ||
| 390 | __field(unsigned int, value1) | ||
| 391 | __field(unsigned int, value2) | ||
| 392 | ), | ||
| 393 | TP_fast_assign( | ||
| 394 | __entry->owner = owner; | ||
| 395 | __entry->value1 = value1; | ||
| 396 | __entry->value2 = value2; | ||
| 397 | ), | ||
| 398 | TP_printk("%llu %u %u", | ||
| 399 | __entry->owner, __entry->value1, __entry->value2) | ||
| 400 | ); | ||
| 401 | |||
| 402 | #define DEFINE_OCFS2_BTREE_EVENT(name) \ | ||
| 403 | DEFINE_EVENT(ocfs2__btree_ops, name, \ | ||
| 404 | TP_PROTO(unsigned long long owner, \ | ||
| 405 | unsigned int value1, unsigned int value2), \ | ||
| 406 | TP_ARGS(owner, value1, value2)) | ||
| 407 | |||
| 408 | DEFINE_OCFS2_BTREE_EVENT(ocfs2_adjust_rightmost_branch); | ||
| 409 | |||
| 410 | DEFINE_OCFS2_BTREE_EVENT(ocfs2_rotate_tree_right); | ||
| 411 | |||
| 412 | DEFINE_OCFS2_BTREE_EVENT(ocfs2_append_rec_to_path); | ||
| 413 | |||
| 414 | DEFINE_OCFS2_BTREE_EVENT(ocfs2_insert_extent_start); | ||
| 415 | |||
| 416 | DEFINE_OCFS2_BTREE_EVENT(ocfs2_add_clusters_in_btree); | ||
| 417 | |||
| 418 | DEFINE_OCFS2_INT_EVENT(ocfs2_num_free_extents); | ||
| 419 | |||
| 420 | DEFINE_OCFS2_INT_EVENT(ocfs2_complete_edge_insert); | ||
| 421 | |||
| 422 | TRACE_EVENT(ocfs2_grow_tree, | ||
| 423 | TP_PROTO(unsigned long long owner, int depth), | ||
| 424 | TP_ARGS(owner, depth), | ||
| 425 | TP_STRUCT__entry( | ||
| 426 | __field(unsigned long long, owner) | ||
| 427 | __field(int, depth) | ||
| 428 | ), | ||
| 429 | TP_fast_assign( | ||
| 430 | __entry->owner = owner; | ||
| 431 | __entry->depth = depth; | ||
| 432 | ), | ||
| 433 | TP_printk("%llu %d", __entry->owner, __entry->depth) | ||
| 434 | ); | ||
| 435 | |||
| 436 | TRACE_EVENT(ocfs2_rotate_subtree, | ||
| 437 | TP_PROTO(int subtree_root, unsigned long long blkno, | ||
| 438 | int depth), | ||
| 439 | TP_ARGS(subtree_root, blkno, depth), | ||
| 440 | TP_STRUCT__entry( | ||
| 441 | __field(int, subtree_root) | ||
| 442 | __field(unsigned long long, blkno) | ||
| 443 | __field(int, depth) | ||
| 444 | ), | ||
| 445 | TP_fast_assign( | ||
| 446 | __entry->subtree_root = subtree_root; | ||
| 447 | __entry->blkno = blkno; | ||
| 448 | __entry->depth = depth; | ||
| 449 | ), | ||
| 450 | TP_printk("%d %llu %d", __entry->subtree_root, | ||
| 451 | __entry->blkno, __entry->depth) | ||
| 452 | ); | ||
| 453 | |||
| 454 | TRACE_EVENT(ocfs2_insert_extent, | ||
| 455 | TP_PROTO(unsigned int ins_appending, unsigned int ins_contig, | ||
| 456 | int ins_contig_index, int free_records, int ins_tree_depth), | ||
| 457 | TP_ARGS(ins_appending, ins_contig, ins_contig_index, free_records, | ||
| 458 | ins_tree_depth), | ||
| 459 | TP_STRUCT__entry( | ||
| 460 | __field(unsigned int, ins_appending) | ||
| 461 | __field(unsigned int, ins_contig) | ||
| 462 | __field(int, ins_contig_index) | ||
| 463 | __field(int, free_records) | ||
| 464 | __field(int, ins_tree_depth) | ||
| 465 | ), | ||
| 466 | TP_fast_assign( | ||
| 467 | __entry->ins_appending = ins_appending; | ||
| 468 | __entry->ins_contig = ins_contig; | ||
| 469 | __entry->ins_contig_index = ins_contig_index; | ||
| 470 | __entry->free_records = free_records; | ||
| 471 | __entry->ins_tree_depth = ins_tree_depth; | ||
| 472 | ), | ||
| 473 | TP_printk("%u %u %d %d %d", | ||
| 474 | __entry->ins_appending, __entry->ins_contig, | ||
| 475 | __entry->ins_contig_index, __entry->free_records, | ||
| 476 | __entry->ins_tree_depth) | ||
| 477 | ); | ||
| 478 | |||
| 479 | TRACE_EVENT(ocfs2_split_extent, | ||
| 480 | TP_PROTO(int split_index, unsigned int c_contig_type, | ||
| 481 | unsigned int c_has_empty_extent, | ||
| 482 | unsigned int c_split_covers_rec), | ||
| 483 | TP_ARGS(split_index, c_contig_type, | ||
| 484 | c_has_empty_extent, c_split_covers_rec), | ||
| 485 | TP_STRUCT__entry( | ||
| 486 | __field(int, split_index) | ||
| 487 | __field(unsigned int, c_contig_type) | ||
| 488 | __field(unsigned int, c_has_empty_extent) | ||
| 489 | __field(unsigned int, c_split_covers_rec) | ||
| 490 | ), | ||
| 491 | TP_fast_assign( | ||
| 492 | __entry->split_index = split_index; | ||
| 493 | __entry->c_contig_type = c_contig_type; | ||
| 494 | __entry->c_has_empty_extent = c_has_empty_extent; | ||
| 495 | __entry->c_split_covers_rec = c_split_covers_rec; | ||
| 496 | ), | ||
| 497 | TP_printk("%d %u %u %u", __entry->split_index, __entry->c_contig_type, | ||
| 498 | __entry->c_has_empty_extent, __entry->c_split_covers_rec) | ||
| 499 | ); | ||
| 500 | |||
| 501 | TRACE_EVENT(ocfs2_remove_extent, | ||
| 502 | TP_PROTO(unsigned long long owner, unsigned int cpos, | ||
| 503 | unsigned int len, int index, | ||
| 504 | unsigned int e_cpos, unsigned int clusters), | ||
| 505 | TP_ARGS(owner, cpos, len, index, e_cpos, clusters), | ||
| 506 | TP_STRUCT__entry( | ||
| 507 | __field(unsigned long long, owner) | ||
| 508 | __field(unsigned int, cpos) | ||
| 509 | __field(unsigned int, len) | ||
| 510 | __field(int, index) | ||
| 511 | __field(unsigned int, e_cpos) | ||
| 512 | __field(unsigned int, clusters) | ||
| 513 | ), | ||
| 514 | TP_fast_assign( | ||
| 515 | __entry->owner = owner; | ||
| 516 | __entry->cpos = cpos; | ||
| 517 | __entry->len = len; | ||
| 518 | __entry->index = index; | ||
| 519 | __entry->e_cpos = e_cpos; | ||
| 520 | __entry->clusters = clusters; | ||
| 521 | ), | ||
| 522 | TP_printk("%llu %u %u %d %u %u", | ||
| 523 | __entry->owner, __entry->cpos, __entry->len, __entry->index, | ||
| 524 | __entry->e_cpos, __entry->clusters) | ||
| 525 | ); | ||
| 526 | |||
| 527 | TRACE_EVENT(ocfs2_commit_truncate, | ||
| 528 | TP_PROTO(unsigned long long ino, unsigned int new_cpos, | ||
| 529 | unsigned int clusters, unsigned int depth), | ||
| 530 | TP_ARGS(ino, new_cpos, clusters, depth), | ||
| 531 | TP_STRUCT__entry( | ||
| 532 | __field(unsigned long long, ino) | ||
| 533 | __field(unsigned int, new_cpos) | ||
| 534 | __field(unsigned int, clusters) | ||
| 535 | __field(unsigned int, depth) | ||
| 536 | ), | ||
| 537 | TP_fast_assign( | ||
| 538 | __entry->ino = ino; | ||
| 539 | __entry->new_cpos = new_cpos; | ||
| 540 | __entry->clusters = clusters; | ||
| 541 | __entry->depth = depth; | ||
| 542 | ), | ||
| 543 | TP_printk("%llu %u %u %u", | ||
| 544 | __entry->ino, __entry->new_cpos, | ||
| 545 | __entry->clusters, __entry->depth) | ||
| 546 | ); | ||
| 547 | |||
| 548 | TRACE_EVENT(ocfs2_validate_extent_block, | ||
| 549 | TP_PROTO(unsigned long long blkno), | ||
| 550 | TP_ARGS(blkno), | ||
| 551 | TP_STRUCT__entry( | ||
| 552 | __field(unsigned long long, blkno) | ||
| 553 | ), | ||
| 554 | TP_fast_assign( | ||
| 555 | __entry->blkno = blkno; | ||
| 556 | ), | ||
| 557 | TP_printk("%llu ", __entry->blkno) | ||
| 558 | ); | ||
| 559 | |||
| 560 | TRACE_EVENT(ocfs2_rotate_leaf, | ||
| 561 | TP_PROTO(unsigned int insert_cpos, int insert_index, | ||
| 562 | int has_empty, int next_free, | ||
| 563 | unsigned int l_count), | ||
| 564 | TP_ARGS(insert_cpos, insert_index, has_empty, | ||
| 565 | next_free, l_count), | ||
| 566 | TP_STRUCT__entry( | ||
| 567 | __field(unsigned int, insert_cpos) | ||
| 568 | __field(int, insert_index) | ||
| 569 | __field(int, has_empty) | ||
| 570 | __field(int, next_free) | ||
| 571 | __field(unsigned int, l_count) | ||
| 572 | ), | ||
| 573 | TP_fast_assign( | ||
| 574 | __entry->insert_cpos = insert_cpos; | ||
| 575 | __entry->insert_index = insert_index; | ||
| 576 | __entry->has_empty = has_empty; | ||
| 577 | __entry->next_free = next_free; | ||
| 578 | __entry->l_count = l_count; | ||
| 579 | ), | ||
| 580 | TP_printk("%u %d %d %d %u", __entry->insert_cpos, | ||
| 581 | __entry->insert_index, __entry->has_empty, | ||
| 582 | __entry->next_free, __entry->l_count) | ||
| 583 | ); | ||
| 584 | |||
| 585 | TRACE_EVENT(ocfs2_add_clusters_in_btree_ret, | ||
| 586 | TP_PROTO(int status, int reason, int err), | ||
| 587 | TP_ARGS(status, reason, err), | ||
| 588 | TP_STRUCT__entry( | ||
| 589 | __field(int, status) | ||
| 590 | __field(int, reason) | ||
| 591 | __field(int, err) | ||
| 592 | ), | ||
| 593 | TP_fast_assign( | ||
| 594 | __entry->status = status; | ||
| 595 | __entry->reason = reason; | ||
| 596 | __entry->err = err; | ||
| 597 | ), | ||
| 598 | TP_printk("%d %d %d", __entry->status, | ||
| 599 | __entry->reason, __entry->err) | ||
| 600 | ); | ||
| 601 | |||
| 602 | TRACE_EVENT(ocfs2_mark_extent_written, | ||
| 603 | TP_PROTO(unsigned long long owner, unsigned int cpos, | ||
| 604 | unsigned int len, unsigned int phys), | ||
| 605 | TP_ARGS(owner, cpos, len, phys), | ||
| 606 | TP_STRUCT__entry( | ||
| 607 | __field(unsigned long long, owner) | ||
| 608 | __field(unsigned int, cpos) | ||
| 609 | __field(unsigned int, len) | ||
| 610 | __field(unsigned int, phys) | ||
| 611 | ), | ||
| 612 | TP_fast_assign( | ||
| 613 | __entry->owner = owner; | ||
| 614 | __entry->cpos = cpos; | ||
| 615 | __entry->len = len; | ||
| 616 | __entry->phys = phys; | ||
| 617 | ), | ||
| 618 | TP_printk("%llu %u %u %u", | ||
| 619 | __entry->owner, __entry->cpos, | ||
| 620 | __entry->len, __entry->phys) | ||
| 621 | ); | ||
| 622 | |||
| 623 | DECLARE_EVENT_CLASS(ocfs2__truncate_log_ops, | ||
| 624 | TP_PROTO(unsigned long long blkno, int index, | ||
| 625 | unsigned int start, unsigned int num), | ||
| 626 | TP_ARGS(blkno, index, start, num), | ||
| 627 | TP_STRUCT__entry( | ||
| 628 | __field(unsigned long long, blkno) | ||
| 629 | __field(int, index) | ||
| 630 | __field(unsigned int, start) | ||
| 631 | __field(unsigned int, num) | ||
| 632 | ), | ||
| 633 | TP_fast_assign( | ||
| 634 | __entry->blkno = blkno; | ||
| 635 | __entry->index = index; | ||
| 636 | __entry->start = start; | ||
| 637 | __entry->num = num; | ||
| 638 | ), | ||
| 639 | TP_printk("%llu %d %u %u", | ||
| 640 | __entry->blkno, __entry->index, | ||
| 641 | __entry->start, __entry->num) | ||
| 642 | ); | ||
| 643 | |||
| 644 | #define DEFINE_OCFS2_TRUNCATE_LOG_OPS_EVENT(name) \ | ||
| 645 | DEFINE_EVENT(ocfs2__truncate_log_ops, name, \ | ||
| 646 | TP_PROTO(unsigned long long blkno, int index, \ | ||
| 647 | unsigned int start, unsigned int num), \ | ||
| 648 | TP_ARGS(blkno, index, start, num)) | ||
| 649 | |||
| 650 | DEFINE_OCFS2_TRUNCATE_LOG_OPS_EVENT(ocfs2_truncate_log_append); | ||
| 651 | |||
| 652 | DEFINE_OCFS2_TRUNCATE_LOG_OPS_EVENT(ocfs2_replay_truncate_records); | ||
| 653 | |||
| 654 | DEFINE_OCFS2_ULL_UINT_EVENT(ocfs2_flush_truncate_log); | ||
| 655 | |||
| 656 | DEFINE_OCFS2_INT_EVENT(ocfs2_begin_truncate_log_recovery); | ||
| 657 | |||
| 658 | DEFINE_OCFS2_INT_EVENT(ocfs2_truncate_log_recovery_num); | ||
| 659 | |||
| 660 | DEFINE_OCFS2_ULL_UINT_EVENT(ocfs2_complete_truncate_log_recovery); | ||
| 661 | |||
| 662 | DEFINE_OCFS2_ULL_UINT_EVENT(ocfs2_free_cached_blocks); | ||
| 663 | |||
| 664 | DEFINE_OCFS2_ULL_UINT_EVENT(ocfs2_cache_cluster_dealloc); | ||
| 665 | |||
| 666 | DEFINE_OCFS2_INT_INT_EVENT(ocfs2_run_deallocs); | ||
| 667 | |||
| 668 | TRACE_EVENT(ocfs2_cache_block_dealloc, | ||
| 669 | TP_PROTO(int type, int slot, unsigned long long suballoc, | ||
| 670 | unsigned long long blkno, unsigned int bit), | ||
| 671 | TP_ARGS(type, slot, suballoc, blkno, bit), | ||
| 672 | TP_STRUCT__entry( | ||
| 673 | __field(int, type) | ||
| 674 | __field(int, slot) | ||
| 675 | __field(unsigned long long, suballoc) | ||
| 676 | __field(unsigned long long, blkno) | ||
| 677 | __field(unsigned int, bit) | ||
| 678 | ), | ||
| 679 | TP_fast_assign( | ||
| 680 | __entry->type = type; | ||
| 681 | __entry->slot = slot; | ||
| 682 | __entry->suballoc = suballoc; | ||
| 683 | __entry->blkno = blkno; | ||
| 684 | __entry->bit = bit; | ||
| 685 | ), | ||
| 686 | TP_printk("%d %d %llu %llu %u", | ||
| 687 | __entry->type, __entry->slot, __entry->suballoc, | ||
| 688 | __entry->blkno, __entry->bit) | ||
| 689 | ); | ||
| 690 | |||
| 691 | /* End of trace events for fs/ocfs2/alloc.c. */ | ||
| 692 | |||
| 693 | /* Trace events for fs/ocfs2/localalloc.c. */ | ||
| 694 | |||
| 695 | DEFINE_OCFS2_UINT_UINT_UINT_EVENT(ocfs2_la_set_sizes); | ||
| 696 | |||
| 697 | DEFINE_OCFS2_ULL_INT_INT_INT_EVENT(ocfs2_alloc_should_use_local); | ||
| 698 | |||
| 699 | DEFINE_OCFS2_INT_EVENT(ocfs2_load_local_alloc); | ||
| 700 | |||
| 701 | DEFINE_OCFS2_INT_EVENT(ocfs2_begin_local_alloc_recovery); | ||
| 702 | |||
| 703 | DEFINE_OCFS2_ULL_INT_INT_INT_EVENT(ocfs2_reserve_local_alloc_bits); | ||
| 704 | |||
| 705 | DEFINE_OCFS2_UINT_EVENT(ocfs2_local_alloc_count_bits); | ||
| 706 | |||
| 707 | DEFINE_OCFS2_INT_INT_EVENT(ocfs2_local_alloc_find_clear_bits_search_bitmap); | ||
| 708 | |||
| 709 | DEFINE_OCFS2_ULL_INT_INT_INT_EVENT(ocfs2_local_alloc_find_clear_bits); | ||
| 710 | |||
| 711 | DEFINE_OCFS2_INT_INT_EVENT(ocfs2_sync_local_to_main); | ||
| 712 | |||
| 713 | TRACE_EVENT(ocfs2_sync_local_to_main_free, | ||
| 714 | TP_PROTO(int count, int bit, unsigned long long start_blk, | ||
| 715 | unsigned long long blkno), | ||
| 716 | TP_ARGS(count, bit, start_blk, blkno), | ||
| 717 | TP_STRUCT__entry( | ||
| 718 | __field(int, count) | ||
| 719 | __field(int, bit) | ||
| 720 | __field(unsigned long long, start_blk) | ||
| 721 | __field(unsigned long long, blkno) | ||
| 722 | ), | ||
| 723 | TP_fast_assign( | ||
| 724 | __entry->count = count; | ||
| 725 | __entry->bit = bit; | ||
| 726 | __entry->start_blk = start_blk; | ||
| 727 | __entry->blkno = blkno; | ||
| 728 | ), | ||
| 729 | TP_printk("%d %d %llu %llu", | ||
| 730 | __entry->count, __entry->bit, __entry->start_blk, | ||
| 731 | __entry->blkno) | ||
| 732 | ); | ||
| 733 | |||
| 734 | DEFINE_OCFS2_INT_INT_EVENT(ocfs2_local_alloc_new_window); | ||
| 735 | |||
| 736 | DEFINE_OCFS2_ULL_UINT_EVENT(ocfs2_local_alloc_new_window_result); | ||
| 737 | |||
| 738 | /* End of trace events for fs/ocfs2/localalloc.c. */ | ||
| 739 | |||
| 740 | /* Trace events for fs/ocfs2/resize.c. */ | ||
| 741 | |||
| 742 | DEFINE_OCFS2_UINT_UINT_EVENT(ocfs2_update_last_group_and_inode); | ||
| 743 | |||
| 744 | DEFINE_OCFS2_ULL_UINT_EVENT(ocfs2_group_extend); | ||
| 745 | |||
| 746 | DEFINE_OCFS2_ULL_UINT_UINT_UINT_EVENT(ocfs2_group_add); | ||
| 747 | |||
| 748 | /* End of trace events for fs/ocfs2/resize.c. */ | ||
| 749 | |||
| 750 | /* Trace events for fs/ocfs2/suballoc.c. */ | ||
| 751 | |||
| 752 | DEFINE_OCFS2_ULL_EVENT(ocfs2_validate_group_descriptor); | ||
| 753 | |||
| 754 | DEFINE_OCFS2_ULL_UINT_EVENT(ocfs2_block_group_alloc_contig); | ||
| 755 | |||
| 756 | DEFINE_OCFS2_ULL_UINT_EVENT(ocfs2_block_group_alloc_discontig); | ||
| 757 | |||
| 758 | DEFINE_OCFS2_ULL_EVENT(ocfs2_block_group_alloc); | ||
| 759 | |||
| 760 | DEFINE_OCFS2_UINT_UINT_EVENT(ocfs2_reserve_suballoc_bits_nospc); | ||
| 761 | |||
| 762 | DEFINE_OCFS2_UINT_UINT_UINT_EVENT(ocfs2_reserve_suballoc_bits_no_new_group); | ||
| 763 | |||
| 764 | DEFINE_OCFS2_ULL_EVENT(ocfs2_reserve_new_inode_new_group); | ||
| 765 | |||
| 766 | DEFINE_OCFS2_UINT_UINT_EVENT(ocfs2_block_group_set_bits); | ||
| 767 | |||
| 768 | TRACE_EVENT(ocfs2_relink_block_group, | ||
| 769 | TP_PROTO(unsigned long long i_blkno, unsigned int chain, | ||
| 770 | unsigned long long bg_blkno, | ||
| 771 | unsigned long long prev_blkno), | ||
| 772 | TP_ARGS(i_blkno, chain, bg_blkno, prev_blkno), | ||
| 773 | TP_STRUCT__entry( | ||
| 774 | __field(unsigned long long, i_blkno) | ||
| 775 | __field(unsigned int, chain) | ||
| 776 | __field(unsigned long long, bg_blkno) | ||
| 777 | __field(unsigned long long, prev_blkno) | ||
| 778 | ), | ||
| 779 | TP_fast_assign( | ||
| 780 | __entry->i_blkno = i_blkno; | ||
| 781 | __entry->chain = chain; | ||
| 782 | __entry->bg_blkno = bg_blkno; | ||
| 783 | __entry->prev_blkno = prev_blkno; | ||
| 784 | ), | ||
| 785 | TP_printk("%llu %u %llu %llu", | ||
| 786 | __entry->i_blkno, __entry->chain, __entry->bg_blkno, | ||
| 787 | __entry->prev_blkno) | ||
| 788 | ); | ||
| 789 | |||
| 790 | DEFINE_OCFS2_ULL_UINT_UINT_UINT_EVENT(ocfs2_cluster_group_search_wrong_max_bits); | ||
| 791 | |||
| 792 | DEFINE_OCFS2_ULL_ULL_EVENT(ocfs2_cluster_group_search_max_block); | ||
| 793 | |||
| 794 | DEFINE_OCFS2_ULL_ULL_EVENT(ocfs2_block_group_search_max_block); | ||
| 795 | |||
| 796 | DEFINE_OCFS2_ULL_UINT_UINT_EVENT(ocfs2_search_chain_begin); | ||
| 797 | |||
| 798 | DEFINE_OCFS2_ULL_UINT_EVENT(ocfs2_search_chain_succ); | ||
| 799 | |||
| 800 | DEFINE_OCFS2_ULL_UINT_EVENT(ocfs2_search_chain_end); | ||
| 801 | |||
| 802 | DEFINE_OCFS2_UINT_EVENT(ocfs2_claim_suballoc_bits); | ||
| 803 | |||
| 804 | DEFINE_OCFS2_ULL_UINT_EVENT(ocfs2_claim_new_inode_at_loc); | ||
| 805 | |||
| 806 | DEFINE_OCFS2_UINT_UINT_EVENT(ocfs2_block_group_clear_bits); | ||
| 807 | |||
| 808 | TRACE_EVENT(ocfs2_free_suballoc_bits, | ||
| 809 | TP_PROTO(unsigned long long inode, unsigned long long group, | ||
| 810 | unsigned int start_bit, unsigned int count), | ||
| 811 | TP_ARGS(inode, group, start_bit, count), | ||
| 812 | TP_STRUCT__entry( | ||
| 813 | __field(unsigned long long, inode) | ||
| 814 | __field(unsigned long long, group) | ||
| 815 | __field(unsigned int, start_bit) | ||
| 816 | __field(unsigned int, count) | ||
| 817 | ), | ||
| 818 | TP_fast_assign( | ||
| 819 | __entry->inode = inode; | ||
| 820 | __entry->group = group; | ||
| 821 | __entry->start_bit = start_bit; | ||
| 822 | __entry->count = count; | ||
| 823 | ), | ||
| 824 | TP_printk("%llu %llu %u %u", __entry->inode, __entry->group, | ||
| 825 | __entry->start_bit, __entry->count) | ||
| 826 | ); | ||
| 827 | |||
| 828 | TRACE_EVENT(ocfs2_free_clusters, | ||
| 829 | TP_PROTO(unsigned long long bg_blkno, unsigned long long start_blk, | ||
| 830 | unsigned int start_bit, unsigned int count), | ||
| 831 | TP_ARGS(bg_blkno, start_blk, start_bit, count), | ||
| 832 | TP_STRUCT__entry( | ||
| 833 | __field(unsigned long long, bg_blkno) | ||
| 834 | __field(unsigned long long, start_blk) | ||
| 835 | __field(unsigned int, start_bit) | ||
| 836 | __field(unsigned int, count) | ||
| 837 | ), | ||
| 838 | TP_fast_assign( | ||
| 839 | __entry->bg_blkno = bg_blkno; | ||
| 840 | __entry->start_blk = start_blk; | ||
| 841 | __entry->start_bit = start_bit; | ||
| 842 | __entry->count = count; | ||
| 843 | ), | ||
| 844 | TP_printk("%llu %llu %u %u", __entry->bg_blkno, __entry->start_blk, | ||
| 845 | __entry->start_bit, __entry->count) | ||
| 846 | ); | ||
| 847 | |||
| 848 | DEFINE_OCFS2_ULL_EVENT(ocfs2_get_suballoc_slot_bit); | ||
| 849 | |||
| 850 | DEFINE_OCFS2_ULL_UINT_EVENT(ocfs2_test_suballoc_bit); | ||
| 851 | |||
| 852 | DEFINE_OCFS2_ULL_EVENT(ocfs2_test_inode_bit); | ||
| 853 | |||
| 854 | /* End of trace events for fs/ocfs2/suballoc.c. */ | ||
| 855 | |||
| 856 | /* Trace events for fs/ocfs2/refcounttree.c. */ | ||
| 857 | |||
| 858 | DEFINE_OCFS2_ULL_EVENT(ocfs2_validate_refcount_block); | ||
| 859 | |||
| 860 | DEFINE_OCFS2_ULL_EVENT(ocfs2_purge_refcount_trees); | ||
| 861 | |||
| 862 | DEFINE_OCFS2_ULL_EVENT(ocfs2_create_refcount_tree); | ||
| 863 | |||
| 864 | DEFINE_OCFS2_ULL_EVENT(ocfs2_create_refcount_tree_blkno); | ||
| 865 | |||
| 866 | DEFINE_OCFS2_ULL_INT_INT_INT_EVENT(ocfs2_change_refcount_rec); | ||
| 867 | |||
| 868 | DEFINE_OCFS2_ULL_UINT_EVENT(ocfs2_expand_inline_ref_root); | ||
| 869 | |||
| 870 | DEFINE_OCFS2_ULL_UINT_UINT_EVENT(ocfs2_divide_leaf_refcount_block); | ||
| 871 | |||
| 872 | DEFINE_OCFS2_ULL_UINT_EVENT(ocfs2_new_leaf_refcount_block); | ||
| 873 | |||
| 874 | DECLARE_EVENT_CLASS(ocfs2__refcount_tree_ops, | ||
| 875 | TP_PROTO(unsigned long long blkno, int index, | ||
| 876 | unsigned long long cpos, | ||
| 877 | unsigned int clusters, unsigned int refcount), | ||
| 878 | TP_ARGS(blkno, index, cpos, clusters, refcount), | ||
| 879 | TP_STRUCT__entry( | ||
| 880 | __field(unsigned long long, blkno) | ||
| 881 | __field(int, index) | ||
| 882 | __field(unsigned long long, cpos) | ||
| 883 | __field(unsigned int, clusters) | ||
| 884 | __field(unsigned int, refcount) | ||
| 885 | ), | ||
| 886 | TP_fast_assign( | ||
| 887 | __entry->blkno = blkno; | ||
| 888 | __entry->index = index; | ||
| 889 | __entry->cpos = cpos; | ||
| 890 | __entry->clusters = clusters; | ||
| 891 | __entry->refcount = refcount; | ||
| 892 | ), | ||
| 893 | TP_printk("%llu %d %llu %u %u", __entry->blkno, __entry->index, | ||
| 894 | __entry->cpos, __entry->clusters, __entry->refcount) | ||
| 895 | ); | ||
| 896 | |||
| 897 | #define DEFINE_OCFS2_REFCOUNT_TREE_OPS_EVENT(name) \ | ||
| 898 | DEFINE_EVENT(ocfs2__refcount_tree_ops, name, \ | ||
| 899 | TP_PROTO(unsigned long long blkno, int index, \ | ||
| 900 | unsigned long long cpos, \ | ||
| 901 | unsigned int count, unsigned int refcount), \ | ||
| 902 | TP_ARGS(blkno, index, cpos, count, refcount)) | ||
| 903 | |||
| 904 | DEFINE_OCFS2_REFCOUNT_TREE_OPS_EVENT(ocfs2_insert_refcount_rec); | ||
| 905 | |||
| 906 | TRACE_EVENT(ocfs2_split_refcount_rec, | ||
| 907 | TP_PROTO(unsigned long long cpos, | ||
| 908 | unsigned int clusters, unsigned int refcount, | ||
| 909 | unsigned long long split_cpos, | ||
| 910 | unsigned int split_clusters, unsigned int split_refcount), | ||
| 911 | TP_ARGS(cpos, clusters, refcount, | ||
| 912 | split_cpos, split_clusters, split_refcount), | ||
| 913 | TP_STRUCT__entry( | ||
| 914 | __field(unsigned long long, cpos) | ||
| 915 | __field(unsigned int, clusters) | ||
| 916 | __field(unsigned int, refcount) | ||
| 917 | __field(unsigned long long, split_cpos) | ||
| 918 | __field(unsigned int, split_clusters) | ||
| 919 | __field(unsigned int, split_refcount) | ||
| 920 | ), | ||
| 921 | TP_fast_assign( | ||
| 922 | __entry->cpos = cpos; | ||
| 923 | __entry->clusters = clusters; | ||
| 924 | __entry->refcount = refcount; | ||
| 925 | __entry->split_cpos = split_cpos; | ||
| 926 | __entry->split_clusters = split_clusters; | ||
| 927 | __entry->split_refcount = split_refcount; | ||
| 928 | ), | ||
| 929 | TP_printk("%llu %u %u %llu %u %u", | ||
| 930 | __entry->cpos, __entry->clusters, __entry->refcount, | ||
| 931 | __entry->split_cpos, __entry->split_clusters, | ||
| 932 | __entry->split_refcount) | ||
| 933 | ); | ||
| 934 | |||
| 935 | DEFINE_OCFS2_REFCOUNT_TREE_OPS_EVENT(ocfs2_split_refcount_rec_insert); | ||
| 936 | |||
| 937 | DEFINE_OCFS2_ULL_ULL_UINT_EVENT(ocfs2_increase_refcount_begin); | ||
| 938 | |||
| 939 | DEFINE_OCFS2_ULL_UINT_UINT_EVENT(ocfs2_increase_refcount_change); | ||
| 940 | |||
| 941 | DEFINE_OCFS2_ULL_UINT_EVENT(ocfs2_increase_refcount_insert); | ||
| 942 | |||
| 943 | DEFINE_OCFS2_ULL_UINT_UINT_EVENT(ocfs2_increase_refcount_split); | ||
| 944 | |||
| 945 | DEFINE_OCFS2_ULL_ULL_UINT_EVENT(ocfs2_remove_refcount_extent); | ||
| 946 | |||
| 947 | DEFINE_OCFS2_ULL_EVENT(ocfs2_restore_refcount_block); | ||
| 948 | |||
| 949 | DEFINE_OCFS2_ULL_ULL_UINT_EVENT(ocfs2_decrease_refcount_rec); | ||
| 950 | |||
| 951 | TRACE_EVENT(ocfs2_decrease_refcount, | ||
| 952 | TP_PROTO(unsigned long long owner, | ||
| 953 | unsigned long long cpos, | ||
| 954 | unsigned int len, int delete), | ||
| 955 | TP_ARGS(owner, cpos, len, delete), | ||
| 956 | TP_STRUCT__entry( | ||
| 957 | __field(unsigned long long, owner) | ||
| 958 | __field(unsigned long long, cpos) | ||
| 959 | __field(unsigned int, len) | ||
| 960 | __field(int, delete) | ||
| 961 | ), | ||
| 962 | TP_fast_assign( | ||
| 963 | __entry->owner = owner; | ||
| 964 | __entry->cpos = cpos; | ||
| 965 | __entry->len = len; | ||
| 966 | __entry->delete = delete; | ||
| 967 | ), | ||
| 968 | TP_printk("%llu %llu %u %d", | ||
| 969 | __entry->owner, __entry->cpos, __entry->len, __entry->delete) | ||
| 970 | ); | ||
| 971 | |||
| 972 | DEFINE_OCFS2_ULL_UINT_UINT_UINT_EVENT(ocfs2_mark_extent_refcounted); | ||
| 973 | |||
| 974 | DEFINE_OCFS2_ULL_UINT_UINT_UINT_EVENT(ocfs2_calc_refcount_meta_credits); | ||
| 975 | |||
| 976 | TRACE_EVENT(ocfs2_calc_refcount_meta_credits_iterate, | ||
| 977 | TP_PROTO(int recs_add, unsigned long long cpos, | ||
| 978 | unsigned int clusters, unsigned long long r_cpos, | ||
| 979 | unsigned int r_clusters, unsigned int refcount, int index), | ||
| 980 | TP_ARGS(recs_add, cpos, clusters, r_cpos, r_clusters, refcount, index), | ||
| 981 | TP_STRUCT__entry( | ||
| 982 | __field(int, recs_add) | ||
| 983 | __field(unsigned long long, cpos) | ||
| 984 | __field(unsigned int, clusters) | ||
| 985 | __field(unsigned long long, r_cpos) | ||
| 986 | __field(unsigned int, r_clusters) | ||
| 987 | __field(unsigned int, refcount) | ||
| 988 | __field(int, index) | ||
| 989 | ), | ||
| 990 | TP_fast_assign( | ||
| 991 | __entry->recs_add = recs_add; | ||
| 992 | __entry->cpos = cpos; | ||
| 993 | __entry->clusters = clusters; | ||
| 994 | __entry->r_cpos = r_cpos; | ||
| 995 | __entry->r_clusters = r_clusters; | ||
| 996 | __entry->refcount = refcount; | ||
| 997 | __entry->index = index; | ||
| 998 | ), | ||
| 999 | TP_printk("%d %llu %u %llu %u %u %d", | ||
| 1000 | __entry->recs_add, __entry->cpos, __entry->clusters, | ||
| 1001 | __entry->r_cpos, __entry->r_clusters, | ||
| 1002 | __entry->refcount, __entry->index) | ||
| 1003 | ); | ||
| 1004 | |||
| 1005 | DEFINE_OCFS2_INT_INT_EVENT(ocfs2_add_refcount_flag); | ||
| 1006 | |||
| 1007 | DEFINE_OCFS2_INT_INT_EVENT(ocfs2_prepare_refcount_change_for_del); | ||
| 1008 | |||
| 1009 | DEFINE_OCFS2_INT_INT_EVENT(ocfs2_lock_refcount_allocators); | ||
| 1010 | |||
| 1011 | DEFINE_OCFS2_ULL_UINT_UINT_UINT_EVENT(ocfs2_duplicate_clusters_by_page); | ||
| 1012 | |||
| 1013 | DEFINE_OCFS2_ULL_UINT_UINT_UINT_EVENT(ocfs2_duplicate_clusters_by_jbd); | ||
| 1014 | |||
| 1015 | TRACE_EVENT(ocfs2_clear_ext_refcount, | ||
| 1016 | TP_PROTO(unsigned long long ino, unsigned int cpos, | ||
| 1017 | unsigned int len, unsigned int p_cluster, | ||
| 1018 | unsigned int ext_flags), | ||
| 1019 | TP_ARGS(ino, cpos, len, p_cluster, ext_flags), | ||
| 1020 | TP_STRUCT__entry( | ||
| 1021 | __field(unsigned long long, ino) | ||
| 1022 | __field(unsigned int, cpos) | ||
| 1023 | __field(unsigned int, len) | ||
| 1024 | __field(unsigned int, p_cluster) | ||
| 1025 | __field(unsigned int, ext_flags) | ||
| 1026 | ), | ||
| 1027 | TP_fast_assign( | ||
| 1028 | __entry->ino = ino; | ||
| 1029 | __entry->cpos = cpos; | ||
| 1030 | __entry->len = len; | ||
| 1031 | __entry->p_cluster = p_cluster; | ||
| 1032 | __entry->ext_flags = ext_flags; | ||
| 1033 | ), | ||
| 1034 | TP_printk("%llu %u %u %u %u", | ||
| 1035 | __entry->ino, __entry->cpos, __entry->len, | ||
| 1036 | __entry->p_cluster, __entry->ext_flags) | ||
| 1037 | ); | ||
| 1038 | |||
| 1039 | TRACE_EVENT(ocfs2_replace_clusters, | ||
| 1040 | TP_PROTO(unsigned long long ino, unsigned int cpos, | ||
| 1041 | unsigned int old, unsigned int new, unsigned int len, | ||
| 1042 | unsigned int ext_flags), | ||
| 1043 | TP_ARGS(ino, cpos, old, new, len, ext_flags), | ||
| 1044 | TP_STRUCT__entry( | ||
| 1045 | __field(unsigned long long, ino) | ||
| 1046 | __field(unsigned int, cpos) | ||
| 1047 | __field(unsigned int, old) | ||
| 1048 | __field(unsigned int, new) | ||
| 1049 | __field(unsigned int, len) | ||
| 1050 | __field(unsigned int, ext_flags) | ||
| 1051 | ), | ||
| 1052 | TP_fast_assign( | ||
| 1053 | __entry->ino = ino; | ||
| 1054 | __entry->cpos = cpos; | ||
| 1055 | __entry->old = old; | ||
| 1056 | __entry->new = new; | ||
| 1057 | __entry->len = len; | ||
| 1058 | __entry->ext_flags = ext_flags; | ||
| 1059 | ), | ||
| 1060 | TP_printk("%llu %u %u %u %u %u", | ||
| 1061 | __entry->ino, __entry->cpos, __entry->old, __entry->new, | ||
| 1062 | __entry->len, __entry->ext_flags) | ||
| 1063 | ); | ||
| 1064 | |||
| 1065 | DEFINE_OCFS2_ULL_UINT_UINT_UINT_EVENT(ocfs2_make_clusters_writable); | ||
| 1066 | |||
| 1067 | TRACE_EVENT(ocfs2_refcount_cow_hunk, | ||
| 1068 | TP_PROTO(unsigned long long ino, unsigned int cpos, | ||
| 1069 | unsigned int write_len, unsigned int max_cpos, | ||
| 1070 | unsigned int cow_start, unsigned int cow_len), | ||
| 1071 | TP_ARGS(ino, cpos, write_len, max_cpos, cow_start, cow_len), | ||
| 1072 | TP_STRUCT__entry( | ||
| 1073 | __field(unsigned long long, ino) | ||
| 1074 | __field(unsigned int, cpos) | ||
| 1075 | __field(unsigned int, write_len) | ||
| 1076 | __field(unsigned int, max_cpos) | ||
| 1077 | __field(unsigned int, cow_start) | ||
| 1078 | __field(unsigned int, cow_len) | ||
| 1079 | ), | ||
| 1080 | TP_fast_assign( | ||
| 1081 | __entry->ino = ino; | ||
| 1082 | __entry->cpos = cpos; | ||
| 1083 | __entry->write_len = write_len; | ||
| 1084 | __entry->max_cpos = max_cpos; | ||
| 1085 | __entry->cow_start = cow_start; | ||
| 1086 | __entry->cow_len = cow_len; | ||
| 1087 | ), | ||
| 1088 | TP_printk("%llu %u %u %u %u %u", | ||
| 1089 | __entry->ino, __entry->cpos, __entry->write_len, | ||
| 1090 | __entry->max_cpos, __entry->cow_start, __entry->cow_len) | ||
| 1091 | ); | ||
| 1092 | |||
| 1093 | /* End of trace events for fs/ocfs2/refcounttree.c. */ | ||
| 1094 | |||
| 1095 | /* Trace events for fs/ocfs2/aops.c. */ | ||
| 1096 | |||
| 1097 | DECLARE_EVENT_CLASS(ocfs2__get_block, | ||
| 1098 | TP_PROTO(unsigned long long ino, unsigned long long iblock, | ||
| 1099 | void *bh_result, int create), | ||
| 1100 | TP_ARGS(ino, iblock, bh_result, create), | ||
| 1101 | TP_STRUCT__entry( | ||
| 1102 | __field(unsigned long long, ino) | ||
| 1103 | __field(unsigned long long, iblock) | ||
| 1104 | __field(void *, bh_result) | ||
| 1105 | __field(int, create) | ||
| 1106 | ), | ||
| 1107 | TP_fast_assign( | ||
| 1108 | __entry->ino = ino; | ||
| 1109 | __entry->iblock = iblock; | ||
| 1110 | __entry->bh_result = bh_result; | ||
| 1111 | __entry->create = create; | ||
| 1112 | ), | ||
| 1113 | TP_printk("%llu %llu %p %d", | ||
| 1114 | __entry->ino, __entry->iblock, | ||
| 1115 | __entry->bh_result, __entry->create) | ||
| 1116 | ); | ||
| 1117 | |||
| 1118 | #define DEFINE_OCFS2_GET_BLOCK_EVENT(name) \ | ||
| 1119 | DEFINE_EVENT(ocfs2__get_block, name, \ | ||
| 1120 | TP_PROTO(unsigned long long ino, unsigned long long iblock, \ | ||
| 1121 | void *bh_result, int create), \ | ||
| 1122 | TP_ARGS(ino, iblock, bh_result, create)) | ||
| 1123 | |||
| 1124 | DEFINE_OCFS2_GET_BLOCK_EVENT(ocfs2_symlink_get_block); | ||
| 1125 | |||
| 1126 | DEFINE_OCFS2_GET_BLOCK_EVENT(ocfs2_get_block); | ||
| 1127 | |||
| 1128 | DEFINE_OCFS2_ULL_ULL_EVENT(ocfs2_get_block_end); | ||
| 1129 | |||
| 1130 | DEFINE_OCFS2_ULL_ULL_EVENT(ocfs2_readpage); | ||
| 1131 | |||
| 1132 | DEFINE_OCFS2_ULL_ULL_EVENT(ocfs2_writepage); | ||
| 1133 | |||
| 1134 | DEFINE_OCFS2_ULL_ULL_EVENT(ocfs2_bmap); | ||
| 1135 | |||
| 1136 | TRACE_EVENT(ocfs2_try_to_write_inline_data, | ||
| 1137 | TP_PROTO(unsigned long long ino, unsigned int len, | ||
| 1138 | unsigned long long pos, unsigned int flags), | ||
| 1139 | TP_ARGS(ino, len, pos, flags), | ||
| 1140 | TP_STRUCT__entry( | ||
| 1141 | __field(unsigned long long, ino) | ||
| 1142 | __field(unsigned int, len) | ||
| 1143 | __field(unsigned long long, pos) | ||
| 1144 | __field(unsigned int, flags) | ||
| 1145 | ), | ||
| 1146 | TP_fast_assign( | ||
| 1147 | __entry->ino = ino; | ||
| 1148 | __entry->len = len; | ||
| 1149 | __entry->pos = pos; | ||
| 1150 | __entry->flags = flags; | ||
| 1151 | ), | ||
| 1152 | TP_printk("%llu %u %llu 0x%x", | ||
| 1153 | __entry->ino, __entry->len, __entry->pos, __entry->flags) | ||
| 1154 | ); | ||
| 1155 | |||
| 1156 | TRACE_EVENT(ocfs2_write_begin_nolock, | ||
| 1157 | TP_PROTO(unsigned long long ino, | ||
| 1158 | long long i_size, unsigned int i_clusters, | ||
| 1159 | unsigned long long pos, unsigned int len, | ||
| 1160 | unsigned int flags, void *page, | ||
| 1161 | unsigned int clusters, unsigned int extents_to_split), | ||
| 1162 | TP_ARGS(ino, i_size, i_clusters, pos, len, flags, | ||
| 1163 | page, clusters, extents_to_split), | ||
| 1164 | TP_STRUCT__entry( | ||
| 1165 | __field(unsigned long long, ino) | ||
| 1166 | __field(long long, i_size) | ||
| 1167 | __field(unsigned int, i_clusters) | ||
| 1168 | __field(unsigned long long, pos) | ||
| 1169 | __field(unsigned int, len) | ||
| 1170 | __field(unsigned int, flags) | ||
| 1171 | __field(void *, page) | ||
| 1172 | __field(unsigned int, clusters) | ||
| 1173 | __field(unsigned int, extents_to_split) | ||
| 1174 | ), | ||
| 1175 | TP_fast_assign( | ||
| 1176 | __entry->ino = ino; | ||
| 1177 | __entry->i_size = i_size; | ||
| 1178 | __entry->i_clusters = i_clusters; | ||
| 1179 | __entry->pos = pos; | ||
| 1180 | __entry->len = len; | ||
| 1181 | __entry->flags = flags; | ||
| 1182 | __entry->page = page; | ||
| 1183 | __entry->clusters = clusters; | ||
| 1184 | __entry->extents_to_split = extents_to_split; | ||
| 1185 | ), | ||
| 1186 | TP_printk("%llu %lld %u %llu %u %u %p %u %u", | ||
| 1187 | __entry->ino, __entry->i_size, __entry->i_clusters, | ||
| 1188 | __entry->pos, __entry->len, | ||
| 1189 | __entry->flags, __entry->page, __entry->clusters, | ||
| 1190 | __entry->extents_to_split) | ||
| 1191 | ); | ||
| 1192 | |||
| 1193 | TRACE_EVENT(ocfs2_write_end_inline, | ||
| 1194 | TP_PROTO(unsigned long long ino, | ||
| 1195 | unsigned long long pos, unsigned int copied, | ||
| 1196 | unsigned int id_count, unsigned int features), | ||
| 1197 | TP_ARGS(ino, pos, copied, id_count, features), | ||
| 1198 | TP_STRUCT__entry( | ||
| 1199 | __field(unsigned long long, ino) | ||
| 1200 | __field(unsigned long long, pos) | ||
| 1201 | __field(unsigned int, copied) | ||
| 1202 | __field(unsigned int, id_count) | ||
| 1203 | __field(unsigned int, features) | ||
| 1204 | ), | ||
| 1205 | TP_fast_assign( | ||
| 1206 | __entry->ino = ino; | ||
| 1207 | __entry->pos = pos; | ||
| 1208 | __entry->copied = copied; | ||
| 1209 | __entry->id_count = id_count; | ||
| 1210 | __entry->features = features; | ||
| 1211 | ), | ||
| 1212 | TP_printk("%llu %llu %u %u %u", | ||
| 1213 | __entry->ino, __entry->pos, __entry->copied, | ||
| 1214 | __entry->id_count, __entry->features) | ||
| 1215 | ); | ||
| 1216 | |||
| 1217 | /* End of trace events for fs/ocfs2/aops.c. */ | ||
| 1218 | |||
| 1219 | /* Trace events for fs/ocfs2/mmap.c. */ | ||
| 1220 | |||
| 1221 | TRACE_EVENT(ocfs2_fault, | ||
| 1222 | TP_PROTO(unsigned long long ino, | ||
| 1223 | void *area, void *page, unsigned long pgoff), | ||
| 1224 | TP_ARGS(ino, area, page, pgoff), | ||
| 1225 | TP_STRUCT__entry( | ||
| 1226 | __field(unsigned long long, ino) | ||
| 1227 | __field(void *, area) | ||
| 1228 | __field(void *, page) | ||
| 1229 | __field(unsigned long, pgoff) | ||
| 1230 | ), | ||
| 1231 | TP_fast_assign( | ||
| 1232 | __entry->ino = ino; | ||
| 1233 | __entry->area = area; | ||
| 1234 | __entry->page = page; | ||
| 1235 | __entry->pgoff = pgoff; | ||
| 1236 | ), | ||
| 1237 | TP_printk("%llu %p %p %lu", | ||
| 1238 | __entry->ino, __entry->area, __entry->page, __entry->pgoff) | ||
| 1239 | ); | ||
| 1240 | |||
| 1241 | /* End of trace events for fs/ocfs2/mmap.c. */ | ||
| 1242 | |||
| 1243 | /* Trace events for fs/ocfs2/file.c. */ | ||
| 1244 | |||
| 1245 | DECLARE_EVENT_CLASS(ocfs2__file_ops, | ||
| 1246 | TP_PROTO(void *inode, void *file, void *dentry, | ||
| 1247 | unsigned long long ino, | ||
| 1248 | unsigned int d_len, const unsigned char *d_name, | ||
| 1249 | unsigned long long para), | ||
| 1250 | TP_ARGS(inode, file, dentry, ino, d_len, d_name, para), | ||
| 1251 | TP_STRUCT__entry( | ||
| 1252 | __field(void *, inode) | ||
| 1253 | __field(void *, file) | ||
| 1254 | __field(void *, dentry) | ||
| 1255 | __field(unsigned long long, ino) | ||
| 1256 | __field(unsigned int, d_len) | ||
| 1257 | __string(d_name, d_name) | ||
| 1258 | __field(unsigned long long, para) | ||
| 1259 | ), | ||
| 1260 | TP_fast_assign( | ||
| 1261 | __entry->inode = inode; | ||
| 1262 | __entry->file = file; | ||
| 1263 | __entry->dentry = dentry; | ||
| 1264 | __entry->ino = ino; | ||
| 1265 | __entry->d_len = d_len; | ||
| 1266 | __assign_str(d_name, d_name); | ||
| 1267 | __entry->para = para; | ||
| 1268 | ), | ||
| 1269 | TP_printk("%p %p %p %llu %llu %.*s", __entry->inode, __entry->file, | ||
| 1270 | __entry->dentry, __entry->ino, __entry->para, | ||
| 1271 | __entry->d_len, __get_str(d_name)) | ||
| 1272 | ); | ||
| 1273 | |||
| 1274 | #define DEFINE_OCFS2_FILE_OPS(name) \ | ||
| 1275 | DEFINE_EVENT(ocfs2__file_ops, name, \ | ||
| 1276 | TP_PROTO(void *inode, void *file, void *dentry, \ | ||
| 1277 | unsigned long long ino, \ | ||
| 1278 | unsigned int d_len, const unsigned char *d_name, \ | ||
| 1279 | unsigned long long mode), \ | ||
| 1280 | TP_ARGS(inode, file, dentry, ino, d_len, d_name, mode)) | ||
| 1281 | |||
| 1282 | DEFINE_OCFS2_FILE_OPS(ocfs2_file_open); | ||
| 1283 | |||
| 1284 | DEFINE_OCFS2_FILE_OPS(ocfs2_file_release); | ||
| 1285 | |||
| 1286 | DEFINE_OCFS2_FILE_OPS(ocfs2_sync_file); | ||
| 1287 | |||
| 1288 | DEFINE_OCFS2_FILE_OPS(ocfs2_file_aio_write); | ||
| 1289 | |||
| 1290 | DEFINE_OCFS2_FILE_OPS(ocfs2_file_splice_write); | ||
| 1291 | |||
| 1292 | DEFINE_OCFS2_FILE_OPS(ocfs2_file_splice_read); | ||
| 1293 | |||
| 1294 | DEFINE_OCFS2_FILE_OPS(ocfs2_file_aio_read); | ||
| 1295 | |||
| 1296 | DEFINE_OCFS2_ULL_ULL_ULL_EVENT(ocfs2_truncate_file); | ||
| 1297 | |||
| 1298 | DEFINE_OCFS2_ULL_ULL_EVENT(ocfs2_truncate_file_error); | ||
| 1299 | |||
| 1300 | TRACE_EVENT(ocfs2_extend_allocation, | ||
| 1301 | TP_PROTO(unsigned long long ip_blkno, unsigned long long size, | ||
| 1302 | unsigned int clusters, unsigned int clusters_to_add, | ||
| 1303 | int why, int restart_func), | ||
| 1304 | TP_ARGS(ip_blkno, size, clusters, clusters_to_add, why, restart_func), | ||
| 1305 | TP_STRUCT__entry( | ||
| 1306 | __field(unsigned long long, ip_blkno) | ||
| 1307 | __field(unsigned long long, size) | ||
| 1308 | __field(unsigned int, clusters) | ||
| 1309 | __field(unsigned int, clusters_to_add) | ||
| 1310 | __field(int, why) | ||
| 1311 | __field(int, restart_func) | ||
| 1312 | ), | ||
| 1313 | TP_fast_assign( | ||
| 1314 | __entry->ip_blkno = ip_blkno; | ||
| 1315 | __entry->size = size; | ||
| 1316 | __entry->clusters = clusters; | ||
| 1317 | __entry->clusters_to_add = clusters_to_add; | ||
| 1318 | __entry->why = why; | ||
| 1319 | __entry->restart_func = restart_func; | ||
| 1320 | ), | ||
| 1321 | TP_printk("%llu %llu %u %u %d %d", | ||
| 1322 | __entry->ip_blkno, __entry->size, __entry->clusters, | ||
| 1323 | __entry->clusters_to_add, __entry->why, __entry->restart_func) | ||
| 1324 | ); | ||
| 1325 | |||
| 1326 | TRACE_EVENT(ocfs2_extend_allocation_end, | ||
| 1327 | TP_PROTO(unsigned long long ino, | ||
| 1328 | unsigned int di_clusters, unsigned long long di_size, | ||
| 1329 | unsigned int ip_clusters, unsigned long long i_size), | ||
| 1330 | TP_ARGS(ino, di_clusters, di_size, ip_clusters, i_size), | ||
| 1331 | TP_STRUCT__entry( | ||
| 1332 | __field(unsigned long long, ino) | ||
| 1333 | __field(unsigned int, di_clusters) | ||
| 1334 | __field(unsigned long long, di_size) | ||
| 1335 | __field(unsigned int, ip_clusters) | ||
| 1336 | __field(unsigned long long, i_size) | ||
| 1337 | ), | ||
| 1338 | TP_fast_assign( | ||
| 1339 | __entry->ino = ino; | ||
| 1340 | __entry->di_clusters = di_clusters; | ||
| 1341 | __entry->di_size = di_size; | ||
| 1342 | __entry->ip_clusters = ip_clusters; | ||
| 1343 | __entry->i_size = i_size; | ||
| 1344 | ), | ||
| 1345 | TP_printk("%llu %u %llu %u %llu", __entry->ino, __entry->di_clusters, | ||
| 1346 | __entry->di_size, __entry->ip_clusters, __entry->i_size) | ||
| 1347 | ); | ||
| 1348 | |||
| 1349 | TRACE_EVENT(ocfs2_write_zero_page, | ||
| 1350 | TP_PROTO(unsigned long long ino, | ||
| 1351 | unsigned long long abs_from, unsigned long long abs_to, | ||
| 1352 | unsigned long index, unsigned int zero_from, | ||
| 1353 | unsigned int zero_to), | ||
| 1354 | TP_ARGS(ino, abs_from, abs_to, index, zero_from, zero_to), | ||
| 1355 | TP_STRUCT__entry( | ||
| 1356 | __field(unsigned long long, ino) | ||
| 1357 | __field(unsigned long long, abs_from) | ||
| 1358 | __field(unsigned long long, abs_to) | ||
| 1359 | __field(unsigned long, index) | ||
| 1360 | __field(unsigned int, zero_from) | ||
| 1361 | __field(unsigned int, zero_to) | ||
| 1362 | ), | ||
| 1363 | TP_fast_assign( | ||
| 1364 | __entry->ino = ino; | ||
| 1365 | __entry->abs_from = abs_from; | ||
| 1366 | __entry->abs_to = abs_to; | ||
| 1367 | __entry->index = index; | ||
| 1368 | __entry->zero_from = zero_from; | ||
| 1369 | __entry->zero_to = zero_to; | ||
| 1370 | ), | ||
| 1371 | TP_printk("%llu %llu %llu %lu %u %u", __entry->ino, | ||
| 1372 | __entry->abs_from, __entry->abs_to, | ||
| 1373 | __entry->index, __entry->zero_from, __entry->zero_to) | ||
| 1374 | ); | ||
| 1375 | |||
| 1376 | DEFINE_OCFS2_ULL_ULL_ULL_EVENT(ocfs2_zero_extend_range); | ||
| 1377 | |||
| 1378 | DEFINE_OCFS2_ULL_ULL_ULL_EVENT(ocfs2_zero_extend); | ||
| 1379 | |||
| 1380 | TRACE_EVENT(ocfs2_setattr, | ||
| 1381 | TP_PROTO(void *inode, void *dentry, | ||
| 1382 | unsigned long long ino, | ||
| 1383 | unsigned int d_len, const unsigned char *d_name, | ||
| 1384 | unsigned int ia_valid, unsigned int ia_mode, | ||
| 1385 | unsigned int ia_uid, unsigned int ia_gid), | ||
| 1386 | TP_ARGS(inode, dentry, ino, d_len, d_name, | ||
| 1387 | ia_valid, ia_mode, ia_uid, ia_gid), | ||
| 1388 | TP_STRUCT__entry( | ||
| 1389 | __field(void *, inode) | ||
| 1390 | __field(void *, dentry) | ||
| 1391 | __field(unsigned long long, ino) | ||
| 1392 | __field(unsigned int, d_len) | ||
| 1393 | __string(d_name, d_name) | ||
| 1394 | __field(unsigned int, ia_valid) | ||
| 1395 | __field(unsigned int, ia_mode) | ||
| 1396 | __field(unsigned int, ia_uid) | ||
| 1397 | __field(unsigned int, ia_gid) | ||
| 1398 | ), | ||
| 1399 | TP_fast_assign( | ||
| 1400 | __entry->inode = inode; | ||
| 1401 | __entry->dentry = dentry; | ||
| 1402 | __entry->ino = ino; | ||
| 1403 | __entry->d_len = d_len; | ||
| 1404 | __assign_str(d_name, d_name); | ||
| 1405 | __entry->ia_valid = ia_valid; | ||
| 1406 | __entry->ia_mode = ia_mode; | ||
| 1407 | __entry->ia_uid = ia_uid; | ||
| 1408 | __entry->ia_gid = ia_gid; | ||
| 1409 | ), | ||
| 1410 | TP_printk("%p %p %llu %.*s %u %u %u %u", __entry->inode, | ||
| 1411 | __entry->dentry, __entry->ino, __entry->d_len, | ||
| 1412 | __get_str(d_name), __entry->ia_valid, __entry->ia_mode, | ||
| 1413 | __entry->ia_uid, __entry->ia_gid) | ||
| 1414 | ); | ||
| 1415 | |||
| 1416 | DEFINE_OCFS2_ULL_UINT_EVENT(ocfs2_write_remove_suid); | ||
| 1417 | |||
| 1418 | DEFINE_OCFS2_ULL_ULL_ULL_EVENT(ocfs2_zero_partial_clusters); | ||
| 1419 | |||
| 1420 | DEFINE_OCFS2_ULL_ULL_EVENT(ocfs2_zero_partial_clusters_range1); | ||
| 1421 | |||
| 1422 | DEFINE_OCFS2_ULL_ULL_EVENT(ocfs2_zero_partial_clusters_range2); | ||
| 1423 | |||
| 1424 | DEFINE_OCFS2_ULL_ULL_ULL_EVENT(ocfs2_remove_inode_range); | ||
| 1425 | |||
| 1426 | TRACE_EVENT(ocfs2_prepare_inode_for_write, | ||
| 1427 | TP_PROTO(unsigned long long ino, unsigned long long saved_pos, | ||
| 1428 | int appending, unsigned long count, | ||
| 1429 | int *direct_io, int *has_refcount), | ||
| 1430 | TP_ARGS(ino, saved_pos, appending, count, direct_io, has_refcount), | ||
| 1431 | TP_STRUCT__entry( | ||
| 1432 | __field(unsigned long long, ino) | ||
| 1433 | __field(unsigned long long, saved_pos) | ||
| 1434 | __field(int, appending) | ||
| 1435 | __field(unsigned long, count) | ||
| 1436 | __field(int, direct_io) | ||
| 1437 | __field(int, has_refcount) | ||
| 1438 | ), | ||
| 1439 | TP_fast_assign( | ||
| 1440 | __entry->ino = ino; | ||
| 1441 | __entry->saved_pos = saved_pos; | ||
| 1442 | __entry->appending = appending; | ||
| 1443 | __entry->count = count; | ||
| 1444 | __entry->direct_io = direct_io ? *direct_io : -1; | ||
| 1445 | __entry->has_refcount = has_refcount ? *has_refcount : -1; | ||
| 1446 | ), | ||
| 1447 | TP_printk("%llu %llu %d %lu %d %d", __entry->ino, | ||
| 1448 | __entry->saved_pos, __entry->appending, __entry->count, | ||
| 1449 | __entry->direct_io, __entry->has_refcount) | ||
| 1450 | ); | ||
| 1451 | |||
| 1452 | DEFINE_OCFS2_INT_EVENT(generic_file_aio_read_ret); | ||
| 1453 | |||
| 1454 | /* End of trace events for fs/ocfs2/file.c. */ | ||
| 1455 | |||
| 1456 | /* Trace events for fs/ocfs2/inode.c. */ | ||
| 1457 | |||
| 1458 | TRACE_EVENT(ocfs2_iget_begin, | ||
| 1459 | TP_PROTO(unsigned long long ino, unsigned int flags, int sysfile_type), | ||
| 1460 | TP_ARGS(ino, flags, sysfile_type), | ||
| 1461 | TP_STRUCT__entry( | ||
| 1462 | __field(unsigned long long, ino) | ||
| 1463 | __field(unsigned int, flags) | ||
| 1464 | __field(int, sysfile_type) | ||
| 1465 | ), | ||
| 1466 | TP_fast_assign( | ||
| 1467 | __entry->ino = ino; | ||
| 1468 | __entry->flags = flags; | ||
| 1469 | __entry->sysfile_type = sysfile_type; | ||
| 1470 | ), | ||
| 1471 | TP_printk("%llu %u %d", __entry->ino, | ||
| 1472 | __entry->flags, __entry->sysfile_type) | ||
| 1473 | ); | ||
| 1474 | |||
| 1475 | DEFINE_OCFS2_ULL_EVENT(ocfs2_iget5_locked); | ||
| 1476 | |||
| 1477 | TRACE_EVENT(ocfs2_iget_end, | ||
| 1478 | TP_PROTO(void *inode, unsigned long long ino), | ||
| 1479 | TP_ARGS(inode, ino), | ||
| 1480 | TP_STRUCT__entry( | ||
| 1481 | __field(void *, inode) | ||
| 1482 | __field(unsigned long long, ino) | ||
| 1483 | ), | ||
| 1484 | TP_fast_assign( | ||
| 1485 | __entry->inode = inode; | ||
| 1486 | __entry->ino = ino; | ||
| 1487 | ), | ||
| 1488 | TP_printk("%p %llu", __entry->inode, __entry->ino) | ||
| 1489 | ); | ||
| 1490 | |||
| 1491 | TRACE_EVENT(ocfs2_find_actor, | ||
| 1492 | TP_PROTO(void *inode, unsigned long long ino, | ||
| 1493 | void *args, unsigned long long fi_blkno), | ||
| 1494 | TP_ARGS(inode, ino, args, fi_blkno), | ||
| 1495 | TP_STRUCT__entry( | ||
| 1496 | __field(void *, inode) | ||
| 1497 | __field(unsigned long long, ino) | ||
| 1498 | __field(void *, args) | ||
| 1499 | __field(unsigned long long, fi_blkno) | ||
| 1500 | ), | ||
| 1501 | TP_fast_assign( | ||
| 1502 | __entry->inode = inode; | ||
| 1503 | __entry->ino = ino; | ||
| 1504 | __entry->args = args; | ||
| 1505 | __entry->fi_blkno = fi_blkno; | ||
| 1506 | ), | ||
| 1507 | TP_printk("%p %llu %p %llu", __entry->inode, __entry->ino, | ||
| 1508 | __entry->args, __entry->fi_blkno) | ||
| 1509 | ); | ||
| 1510 | |||
| 1511 | DEFINE_OCFS2_ULL_UINT_EVENT(ocfs2_populate_inode); | ||
| 1512 | |||
| 1513 | DEFINE_OCFS2_ULL_INT_EVENT(ocfs2_read_locked_inode); | ||
| 1514 | |||
| 1515 | DEFINE_OCFS2_INT_INT_EVENT(ocfs2_check_orphan_recovery_state); | ||
| 1516 | |||
| 1517 | DEFINE_OCFS2_ULL_EVENT(ocfs2_validate_inode_block); | ||
| 1518 | |||
| 1519 | TRACE_EVENT(ocfs2_inode_is_valid_to_delete, | ||
| 1520 | TP_PROTO(void *task, void *dc_task, unsigned long long ino, | ||
| 1521 | unsigned int flags), | ||
| 1522 | TP_ARGS(task, dc_task, ino, flags), | ||
| 1523 | TP_STRUCT__entry( | ||
| 1524 | __field(void *, task) | ||
| 1525 | __field(void *, dc_task) | ||
| 1526 | __field(unsigned long long, ino) | ||
| 1527 | __field(unsigned int, flags) | ||
| 1528 | ), | ||
| 1529 | TP_fast_assign( | ||
| 1530 | __entry->task = task; | ||
| 1531 | __entry->dc_task = dc_task; | ||
| 1532 | __entry->ino = ino; | ||
| 1533 | __entry->flags = flags; | ||
| 1534 | ), | ||
| 1535 | TP_printk("%p %p %llu %u", __entry->task, __entry->dc_task, | ||
| 1536 | __entry->ino, __entry->flags) | ||
| 1537 | ); | ||
| 1538 | |||
| 1539 | DEFINE_OCFS2_ULL_UINT_EVENT(ocfs2_query_inode_wipe_begin); | ||
| 1540 | |||
| 1541 | DEFINE_OCFS2_UINT_EVENT(ocfs2_query_inode_wipe_succ); | ||
| 1542 | |||
| 1543 | DEFINE_OCFS2_INT_INT_EVENT(ocfs2_query_inode_wipe_end); | ||
| 1544 | |||
| 1545 | DEFINE_OCFS2_ULL_INT_EVENT(ocfs2_cleanup_delete_inode); | ||
| 1546 | |||
| 1547 | DEFINE_OCFS2_ULL_ULL_UINT_EVENT(ocfs2_delete_inode); | ||
| 1548 | |||
| 1549 | DEFINE_OCFS2_ULL_UINT_EVENT(ocfs2_clear_inode); | ||
| 1550 | |||
| 1551 | DEFINE_OCFS2_ULL_UINT_UINT_EVENT(ocfs2_drop_inode); | ||
| 1552 | |||
| 1553 | TRACE_EVENT(ocfs2_inode_revalidate, | ||
| 1554 | TP_PROTO(void *inode, unsigned long long ino, | ||
| 1555 | unsigned int flags), | ||
| 1556 | TP_ARGS(inode, ino, flags), | ||
| 1557 | TP_STRUCT__entry( | ||
| 1558 | __field(void *, inode) | ||
| 1559 | __field(unsigned long long, ino) | ||
| 1560 | __field(unsigned int, flags) | ||
| 1561 | ), | ||
| 1562 | TP_fast_assign( | ||
| 1563 | __entry->inode = inode; | ||
| 1564 | __entry->ino = ino; | ||
| 1565 | __entry->flags = flags; | ||
| 1566 | ), | ||
| 1567 | TP_printk("%p %llu %u", __entry->inode, __entry->ino, __entry->flags) | ||
| 1568 | ); | ||
| 1569 | |||
| 1570 | DEFINE_OCFS2_ULL_EVENT(ocfs2_mark_inode_dirty); | ||
| 1571 | |||
| 1572 | /* End of trace events for fs/ocfs2/inode.c. */ | ||
| 1573 | |||
| 1574 | /* Trace events for fs/ocfs2/extent_map.c. */ | ||
| 1575 | |||
| 1576 | TRACE_EVENT(ocfs2_read_virt_blocks, | ||
| 1577 | TP_PROTO(void *inode, unsigned long long vblock, int nr, | ||
| 1578 | void *bhs, unsigned int flags, void *validate), | ||
| 1579 | TP_ARGS(inode, vblock, nr, bhs, flags, validate), | ||
| 1580 | TP_STRUCT__entry( | ||
| 1581 | __field(void *, inode) | ||
| 1582 | __field(unsigned long long, vblock) | ||
| 1583 | __field(int, nr) | ||
| 1584 | __field(void *, bhs) | ||
| 1585 | __field(unsigned int, flags) | ||
| 1586 | __field(void *, validate) | ||
| 1587 | ), | ||
| 1588 | TP_fast_assign( | ||
| 1589 | __entry->inode = inode; | ||
| 1590 | __entry->vblock = vblock; | ||
| 1591 | __entry->nr = nr; | ||
| 1592 | __entry->bhs = bhs; | ||
| 1593 | __entry->flags = flags; | ||
| 1594 | __entry->validate = validate; | ||
| 1595 | ), | ||
| 1596 | TP_printk("%p %llu %d %p %x %p", __entry->inode, __entry->vblock, | ||
| 1597 | __entry->nr, __entry->bhs, __entry->flags, __entry->validate) | ||
| 1598 | ); | ||
| 1599 | |||
| 1600 | /* End of trace events for fs/ocfs2/extent_map.c. */ | ||
| 1601 | |||
| 1602 | /* Trace events for fs/ocfs2/slot_map.c. */ | ||
| 1603 | |||
| 1604 | DEFINE_OCFS2_UINT_EVENT(ocfs2_refresh_slot_info); | ||
| 1605 | |||
| 1606 | DEFINE_OCFS2_ULL_UINT_EVENT(ocfs2_map_slot_buffers); | ||
| 1607 | |||
| 1608 | DEFINE_OCFS2_ULL_UINT_EVENT(ocfs2_map_slot_buffers_block); | ||
| 1609 | |||
| 1610 | DEFINE_OCFS2_INT_EVENT(ocfs2_find_slot); | ||
| 1611 | |||
| 1612 | /* End of trace events for fs/ocfs2/slot_map.c. */ | ||
| 1613 | |||
| 1614 | /* Trace events for fs/ocfs2/heartbeat.c. */ | ||
| 1615 | |||
| 1616 | DEFINE_OCFS2_INT_EVENT(ocfs2_do_node_down); | ||
| 1617 | |||
| 1618 | /* End of trace events for fs/ocfs2/heartbeat.c. */ | ||
| 1619 | |||
| 1620 | /* Trace events for fs/ocfs2/super.c. */ | ||
| 1621 | |||
| 1622 | TRACE_EVENT(ocfs2_remount, | ||
| 1623 | TP_PROTO(unsigned long s_flags, unsigned long osb_flags, int flags), | ||
| 1624 | TP_ARGS(s_flags, osb_flags, flags), | ||
| 1625 | TP_STRUCT__entry( | ||
| 1626 | __field(unsigned long, s_flags) | ||
| 1627 | __field(unsigned long, osb_flags) | ||
| 1628 | __field(int, flags) | ||
| 1629 | ), | ||
| 1630 | TP_fast_assign( | ||
| 1631 | __entry->s_flags = s_flags; | ||
| 1632 | __entry->osb_flags = osb_flags; | ||
| 1633 | __entry->flags = flags; | ||
| 1634 | ), | ||
| 1635 | TP_printk("%lu %lu %d", __entry->s_flags, | ||
| 1636 | __entry->osb_flags, __entry->flags) | ||
| 1637 | ); | ||
| 1638 | |||
| 1639 | TRACE_EVENT(ocfs2_fill_super, | ||
| 1640 | TP_PROTO(void *sb, void *data, int silent), | ||
| 1641 | TP_ARGS(sb, data, silent), | ||
| 1642 | TP_STRUCT__entry( | ||
| 1643 | __field(void *, sb) | ||
| 1644 | __field(void *, data) | ||
| 1645 | __field(int, silent) | ||
| 1646 | ), | ||
| 1647 | TP_fast_assign( | ||
| 1648 | __entry->sb = sb; | ||
| 1649 | __entry->data = data; | ||
| 1650 | __entry->silent = silent; | ||
| 1651 | ), | ||
| 1652 | TP_printk("%p %p %d", __entry->sb, | ||
| 1653 | __entry->data, __entry->silent) | ||
| 1654 | ); | ||
| 1655 | |||
| 1656 | TRACE_EVENT(ocfs2_parse_options, | ||
| 1657 | TP_PROTO(int is_remount, char *options), | ||
| 1658 | TP_ARGS(is_remount, options), | ||
| 1659 | TP_STRUCT__entry( | ||
| 1660 | __field(int, is_remount) | ||
| 1661 | __string(options, options) | ||
| 1662 | ), | ||
| 1663 | TP_fast_assign( | ||
| 1664 | __entry->is_remount = is_remount; | ||
| 1665 | __assign_str(options, options); | ||
| 1666 | ), | ||
| 1667 | TP_printk("%d %s", __entry->is_remount, __get_str(options)) | ||
| 1668 | ); | ||
| 1669 | |||
| 1670 | DEFINE_OCFS2_POINTER_EVENT(ocfs2_put_super); | ||
| 1671 | |||
| 1672 | TRACE_EVENT(ocfs2_statfs, | ||
| 1673 | TP_PROTO(void *sb, void *buf), | ||
| 1674 | TP_ARGS(sb, buf), | ||
| 1675 | TP_STRUCT__entry( | ||
| 1676 | __field(void *, sb) | ||
| 1677 | __field(void *, buf) | ||
| 1678 | ), | ||
| 1679 | TP_fast_assign( | ||
| 1680 | __entry->sb = sb; | ||
| 1681 | __entry->buf = buf; | ||
| 1682 | ), | ||
| 1683 | TP_printk("%p %p", __entry->sb, __entry->buf) | ||
| 1684 | ); | ||
| 1685 | |||
| 1686 | DEFINE_OCFS2_POINTER_EVENT(ocfs2_dismount_volume); | ||
| 1687 | |||
| 1688 | TRACE_EVENT(ocfs2_initialize_super, | ||
| 1689 | TP_PROTO(char *label, char *uuid_str, unsigned long long root_dir, | ||
| 1690 | unsigned long long system_dir, int cluster_bits), | ||
| 1691 | TP_ARGS(label, uuid_str, root_dir, system_dir, cluster_bits), | ||
| 1692 | TP_STRUCT__entry( | ||
| 1693 | __string(label, label) | ||
| 1694 | __string(uuid_str, uuid_str) | ||
| 1695 | __field(unsigned long long, root_dir) | ||
| 1696 | __field(unsigned long long, system_dir) | ||
| 1697 | __field(int, cluster_bits) | ||
| 1698 | ), | ||
| 1699 | TP_fast_assign( | ||
| 1700 | __assign_str(label, label); | ||
| 1701 | __assign_str(uuid_str, uuid_str); | ||
| 1702 | __entry->root_dir = root_dir; | ||
| 1703 | __entry->system_dir = system_dir; | ||
| 1704 | __entry->cluster_bits = cluster_bits; | ||
| 1705 | ), | ||
| 1706 | TP_printk("%s %s %llu %llu %d", __get_str(label), __get_str(uuid_str), | ||
| 1707 | __entry->root_dir, __entry->system_dir, __entry->cluster_bits) | ||
| 1708 | ); | ||
| 1709 | |||
| 1710 | /* End of trace events for fs/ocfs2/super.c. */ | ||
| 1711 | |||
| 1712 | /* Trace events for fs/ocfs2/xattr.c. */ | ||
| 1713 | |||
| 1714 | DEFINE_OCFS2_ULL_EVENT(ocfs2_validate_xattr_block); | ||
| 1715 | |||
| 1716 | DEFINE_OCFS2_UINT_EVENT(ocfs2_xattr_extend_allocation); | ||
| 1717 | |||
| 1718 | TRACE_EVENT(ocfs2_init_xattr_set_ctxt, | ||
| 1719 | TP_PROTO(const char *name, int meta, int clusters, int credits), | ||
| 1720 | TP_ARGS(name, meta, clusters, credits), | ||
| 1721 | TP_STRUCT__entry( | ||
| 1722 | __string(name, name) | ||
| 1723 | __field(int, meta) | ||
| 1724 | __field(int, clusters) | ||
| 1725 | __field(int, credits) | ||
| 1726 | ), | ||
| 1727 | TP_fast_assign( | ||
| 1728 | __assign_str(name, name); | ||
| 1729 | __entry->meta = meta; | ||
| 1730 | __entry->clusters = clusters; | ||
| 1731 | __entry->credits = credits; | ||
| 1732 | ), | ||
| 1733 | TP_printk("%s %d %d %d", __get_str(name), __entry->meta, | ||
| 1734 | __entry->clusters, __entry->credits) | ||
| 1735 | ); | ||
| 1736 | |||
| 1737 | DECLARE_EVENT_CLASS(ocfs2__xattr_find, | ||
| 1738 | TP_PROTO(unsigned long long ino, const char *name, int name_index, | ||
| 1739 | unsigned int hash, unsigned long long location, | ||
| 1740 | int xe_index), | ||
| 1741 | TP_ARGS(ino, name, name_index, hash, location, xe_index), | ||
| 1742 | TP_STRUCT__entry( | ||
| 1743 | __field(unsigned long long, ino) | ||
| 1744 | __string(name, name) | ||
| 1745 | __field(int, name_index) | ||
| 1746 | __field(unsigned int, hash) | ||
| 1747 | __field(unsigned long long, location) | ||
| 1748 | __field(int, xe_index) | ||
| 1749 | ), | ||
| 1750 | TP_fast_assign( | ||
| 1751 | __entry->ino = ino; | ||
| 1752 | __assign_str(name, name); | ||
| 1753 | __entry->name_index = name_index; | ||
| 1754 | __entry->hash = hash; | ||
| 1755 | __entry->location = location; | ||
| 1756 | __entry->xe_index = xe_index; | ||
| 1757 | ), | ||
| 1758 | TP_printk("%llu %s %d %u %llu %d", __entry->ino, __get_str(name), | ||
| 1759 | __entry->name_index, __entry->hash, __entry->location, | ||
| 1760 | __entry->xe_index) | ||
| 1761 | ); | ||
| 1762 | |||
| 1763 | #define DEFINE_OCFS2_XATTR_FIND_EVENT(name) \ | ||
| 1764 | DEFINE_EVENT(ocfs2__xattr_find, name, \ | ||
| 1765 | TP_PROTO(unsigned long long ino, const char *name, int name_index, \ | ||
| 1766 | unsigned int hash, unsigned long long bucket, \ | ||
| 1767 | int xe_index), \ | ||
| 1768 | TP_ARGS(ino, name, name_index, hash, bucket, xe_index)) | ||
| 1769 | |||
| 1770 | DEFINE_OCFS2_XATTR_FIND_EVENT(ocfs2_xattr_bucket_find); | ||
| 1771 | |||
| 1772 | DEFINE_OCFS2_XATTR_FIND_EVENT(ocfs2_xattr_index_block_find); | ||
| 1773 | |||
| 1774 | DEFINE_OCFS2_XATTR_FIND_EVENT(ocfs2_xattr_index_block_find_rec); | ||
| 1775 | |||
| 1776 | DEFINE_OCFS2_ULL_ULL_UINT_EVENT(ocfs2_iterate_xattr_buckets); | ||
| 1777 | |||
| 1778 | DEFINE_OCFS2_ULL_UINT_EVENT(ocfs2_iterate_xattr_bucket); | ||
| 1779 | |||
| 1780 | DEFINE_OCFS2_ULL_ULL_EVENT(ocfs2_cp_xattr_block_to_bucket_begin); | ||
| 1781 | |||
| 1782 | DEFINE_OCFS2_UINT_UINT_UINT_EVENT(ocfs2_cp_xattr_block_to_bucket_end); | ||
| 1783 | |||
| 1784 | DEFINE_OCFS2_ULL_EVENT(ocfs2_xattr_create_index_block_begin); | ||
| 1785 | |||
| 1786 | DEFINE_OCFS2_ULL_EVENT(ocfs2_xattr_create_index_block); | ||
| 1787 | |||
| 1788 | DEFINE_OCFS2_ULL_UINT_UINT_UINT_EVENT(ocfs2_defrag_xattr_bucket); | ||
| 1789 | |||
| 1790 | DEFINE_OCFS2_ULL_ULL_EVENT(ocfs2_mv_xattr_bucket_cross_cluster); | ||
| 1791 | |||
| 1792 | DEFINE_OCFS2_ULL_ULL_EVENT(ocfs2_divide_xattr_bucket_begin); | ||
| 1793 | |||
| 1794 | DEFINE_OCFS2_UINT_UINT_UINT_EVENT(ocfs2_divide_xattr_bucket_move); | ||
| 1795 | |||
| 1796 | DEFINE_OCFS2_ULL_ULL_UINT_EVENT(ocfs2_cp_xattr_bucket); | ||
| 1797 | |||
| 1798 | DEFINE_OCFS2_ULL_ULL_EVENT(ocfs2_mv_xattr_buckets); | ||
| 1799 | |||
| 1800 | DEFINE_OCFS2_ULL_ULL_UINT_EVENT(ocfs2_adjust_xattr_cross_cluster); | ||
| 1801 | |||
| 1802 | DEFINE_OCFS2_ULL_ULL_UINT_UINT_EVENT(ocfs2_add_new_xattr_cluster_begin); | ||
| 1803 | |||
| 1804 | DEFINE_OCFS2_ULL_UINT_EVENT(ocfs2_add_new_xattr_cluster); | ||
| 1805 | |||
| 1806 | DEFINE_OCFS2_ULL_UINT_UINT_EVENT(ocfs2_add_new_xattr_cluster_insert); | ||
| 1807 | |||
| 1808 | DEFINE_OCFS2_ULL_ULL_UINT_UINT_EVENT(ocfs2_extend_xattr_bucket); | ||
| 1809 | |||
| 1810 | DEFINE_OCFS2_ULL_EVENT(ocfs2_add_new_xattr_bucket); | ||
| 1811 | |||
| 1812 | DEFINE_OCFS2_ULL_UINT_UINT_EVENT(ocfs2_xattr_bucket_value_truncate); | ||
| 1813 | |||
| 1814 | DEFINE_OCFS2_ULL_ULL_UINT_UINT_EVENT(ocfs2_rm_xattr_cluster); | ||
| 1815 | |||
| 1816 | DEFINE_OCFS2_ULL_UINT_EVENT(ocfs2_reflink_xattr_header); | ||
| 1817 | |||
| 1818 | DEFINE_OCFS2_ULL_INT_EVENT(ocfs2_create_empty_xattr_block); | ||
| 1819 | |||
| 1820 | DEFINE_OCFS2_STRING_EVENT(ocfs2_xattr_set_entry_bucket); | ||
| 1821 | |||
| 1822 | DEFINE_OCFS2_STRING_EVENT(ocfs2_xattr_set_entry_index_block); | ||
| 1823 | |||
| 1824 | DEFINE_OCFS2_ULL_UINT_EVENT(ocfs2_xattr_bucket_value_refcount); | ||
| 1825 | |||
| 1826 | DEFINE_OCFS2_ULL_UINT_UINT_EVENT(ocfs2_reflink_xattr_buckets); | ||
| 1827 | |||
| 1828 | DEFINE_OCFS2_ULL_UINT_EVENT(ocfs2_reflink_xattr_rec); | ||
| 1829 | |||
| 1830 | /* End of trace events for fs/ocfs2/xattr.c. */ | ||
| 1831 | |||
| 1832 | /* Trace events for fs/ocfs2/reservations.c. */ | ||
| 1833 | |||
| 1834 | DEFINE_OCFS2_UINT_UINT_EVENT(ocfs2_resv_insert); | ||
| 1835 | |||
| 1836 | DEFINE_OCFS2_ULL_UINT_UINT_UINT_EVENT(ocfs2_resmap_find_free_bits_begin); | ||
| 1837 | |||
| 1838 | DEFINE_OCFS2_UINT_UINT_EVENT(ocfs2_resmap_find_free_bits_end); | ||
| 1839 | |||
| 1840 | TRACE_EVENT(ocfs2_resv_find_window_begin, | ||
| 1841 | TP_PROTO(unsigned int r_start, unsigned int r_end, unsigned int goal, | ||
| 1842 | unsigned int wanted, int empty_root), | ||
| 1843 | TP_ARGS(r_start, r_end, goal, wanted, empty_root), | ||
| 1844 | TP_STRUCT__entry( | ||
| 1845 | __field(unsigned int, r_start) | ||
| 1846 | __field(unsigned int, r_end) | ||
| 1847 | __field(unsigned int, goal) | ||
| 1848 | __field(unsigned int, wanted) | ||
| 1849 | __field(int, empty_root) | ||
| 1850 | ), | ||
| 1851 | TP_fast_assign( | ||
| 1852 | __entry->r_start = r_start; | ||
| 1853 | __entry->r_end = r_end; | ||
| 1854 | __entry->goal = goal; | ||
| 1855 | __entry->wanted = wanted; | ||
| 1856 | __entry->empty_root = empty_root; | ||
| 1857 | ), | ||
| 1858 | TP_printk("%u %u %u %u %d", __entry->r_start, __entry->r_end, | ||
| 1859 | __entry->goal, __entry->wanted, __entry->empty_root) | ||
| 1860 | ); | ||
| 1861 | |||
| 1862 | DEFINE_OCFS2_UINT_UINT_EVENT(ocfs2_resv_find_window_prev); | ||
| 1863 | |||
| 1864 | DEFINE_OCFS2_INT_INT_EVENT(ocfs2_resv_find_window_next); | ||
| 1865 | |||
| 1866 | DEFINE_OCFS2_UINT_UINT_UINT_EVENT(ocfs2_cannibalize_resv_begin); | ||
| 1867 | |||
| 1868 | TRACE_EVENT(ocfs2_cannibalize_resv_end, | ||
| 1869 | TP_PROTO(unsigned int start, unsigned int end, unsigned int len, | ||
| 1870 | unsigned int last_start, unsigned int last_len), | ||
| 1871 | TP_ARGS(start, end, len, last_start, last_len), | ||
| 1872 | TP_STRUCT__entry( | ||
| 1873 | __field(unsigned int, start) | ||
| 1874 | __field(unsigned int, end) | ||
| 1875 | __field(unsigned int, len) | ||
| 1876 | __field(unsigned int, last_start) | ||
| 1877 | __field(unsigned int, last_len) | ||
| 1878 | ), | ||
| 1879 | TP_fast_assign( | ||
| 1880 | __entry->start = start; | ||
| 1881 | __entry->end = end; | ||
| 1882 | __entry->len = len; | ||
| 1883 | __entry->last_start = last_start; | ||
| 1884 | __entry->last_len = last_len; | ||
| 1885 | ), | ||
| 1886 | TP_printk("%u %u %u %u %u", __entry->start, __entry->end, | ||
| 1887 | __entry->len, __entry->last_start, __entry->last_len) | ||
| 1888 | ); | ||
| 1889 | |||
| 1890 | DEFINE_OCFS2_UINT_UINT_EVENT(ocfs2_resmap_resv_bits); | ||
| 1891 | |||
| 1892 | TRACE_EVENT(ocfs2_resmap_claimed_bits_begin, | ||
| 1893 | TP_PROTO(unsigned int cstart, unsigned int cend, unsigned int clen, | ||
| 1894 | unsigned int r_start, unsigned int r_end, unsigned int r_len, | ||
| 1895 | unsigned int last_start, unsigned int last_len), | ||
| 1896 | TP_ARGS(cstart, cend, clen, r_start, r_end, | ||
| 1897 | r_len, last_start, last_len), | ||
| 1898 | TP_STRUCT__entry( | ||
| 1899 | __field(unsigned int, cstart) | ||
| 1900 | __field(unsigned int, cend) | ||
| 1901 | __field(unsigned int, clen) | ||
| 1902 | __field(unsigned int, r_start) | ||
| 1903 | __field(unsigned int, r_end) | ||
| 1904 | __field(unsigned int, r_len) | ||
| 1905 | __field(unsigned int, last_start) | ||
| 1906 | __field(unsigned int, last_len) | ||
| 1907 | ), | ||
| 1908 | TP_fast_assign( | ||
| 1909 | __entry->cstart = cstart; | ||
| 1910 | __entry->cend = cend; | ||
| 1911 | __entry->clen = clen; | ||
| 1912 | __entry->r_start = r_start; | ||
| 1913 | __entry->r_end = r_end; | ||
| 1914 | __entry->r_len = r_len; | ||
| 1915 | __entry->last_start = last_start; | ||
| 1916 | __entry->last_len = last_len; | ||
| 1917 | ), | ||
| 1918 | TP_printk("%u %u %u %u %u %u %u %u", | ||
| 1919 | __entry->cstart, __entry->cend, __entry->clen, | ||
| 1920 | __entry->r_start, __entry->r_end, __entry->r_len, | ||
| 1921 | __entry->last_start, __entry->last_len) | ||
| 1922 | ); | ||
| 1923 | |||
| 1924 | TRACE_EVENT(ocfs2_resmap_claimed_bits_end, | ||
| 1925 | TP_PROTO(unsigned int start, unsigned int end, unsigned int len, | ||
| 1926 | unsigned int last_start, unsigned int last_len), | ||
| 1927 | TP_ARGS(start, end, len, last_start, last_len), | ||
| 1928 | TP_STRUCT__entry( | ||
| 1929 | __field(unsigned int, start) | ||
| 1930 | __field(unsigned int, end) | ||
| 1931 | __field(unsigned int, len) | ||
| 1932 | __field(unsigned int, last_start) | ||
| 1933 | __field(unsigned int, last_len) | ||
| 1934 | ), | ||
| 1935 | TP_fast_assign( | ||
| 1936 | __entry->start = start; | ||
| 1937 | __entry->end = end; | ||
| 1938 | __entry->len = len; | ||
| 1939 | __entry->last_start = last_start; | ||
| 1940 | __entry->last_len = last_len; | ||
| 1941 | ), | ||
| 1942 | TP_printk("%u %u %u %u %u", __entry->start, __entry->end, | ||
| 1943 | __entry->len, __entry->last_start, __entry->last_len) | ||
| 1944 | ); | ||
| 1945 | |||
| 1946 | /* End of trace events for fs/ocfs2/reservations.c. */ | ||
| 1947 | |||
| 1948 | /* Trace events for fs/ocfs2/quota_local.c. */ | ||
| 1949 | |||
| 1950 | DEFINE_OCFS2_ULL_UINT_EVENT(ocfs2_recover_local_quota_file); | ||
| 1951 | |||
| 1952 | DEFINE_OCFS2_INT_EVENT(ocfs2_finish_quota_recovery); | ||
| 1953 | |||
| 1954 | DEFINE_OCFS2_ULL_ULL_UINT_EVENT(olq_set_dquot); | ||
| 1955 | |||
| 1956 | /* End of trace events for fs/ocfs2/quota_local.c. */ | ||
| 1957 | |||
| 1958 | /* Trace events for fs/ocfs2/quota_global.c. */ | ||
| 1959 | |||
| 1960 | DEFINE_OCFS2_ULL_EVENT(ocfs2_validate_quota_block); | ||
| 1961 | |||
| 1962 | TRACE_EVENT(ocfs2_sync_dquot, | ||
| 1963 | TP_PROTO(unsigned int dq_id, long long dqb_curspace, | ||
| 1964 | long long spacechange, long long curinodes, | ||
| 1965 | long long inodechange), | ||
| 1966 | TP_ARGS(dq_id, dqb_curspace, spacechange, curinodes, inodechange), | ||
| 1967 | TP_STRUCT__entry( | ||
| 1968 | __field(unsigned int, dq_id) | ||
| 1969 | __field(long long, dqb_curspace) | ||
| 1970 | __field(long long, spacechange) | ||
| 1971 | __field(long long, curinodes) | ||
| 1972 | __field(long long, inodechange) | ||
| 1973 | ), | ||
| 1974 | TP_fast_assign( | ||
| 1975 | __entry->dq_id = dq_id; | ||
| 1976 | __entry->dqb_curspace = dqb_curspace; | ||
| 1977 | __entry->spacechange = spacechange; | ||
| 1978 | __entry->curinodes = curinodes; | ||
| 1979 | __entry->inodechange = inodechange; | ||
| 1980 | ), | ||
| 1981 | TP_printk("%u %lld %lld %lld %lld", __entry->dq_id, | ||
| 1982 | __entry->dqb_curspace, __entry->spacechange, | ||
| 1983 | __entry->curinodes, __entry->inodechange) | ||
| 1984 | ); | ||
| 1985 | |||
| 1986 | TRACE_EVENT(ocfs2_sync_dquot_helper, | ||
| 1987 | TP_PROTO(unsigned int dq_id, unsigned int dq_type, unsigned long type, | ||
| 1988 | const char *s_id), | ||
| 1989 | TP_ARGS(dq_id, dq_type, type, s_id), | ||
| 1990 | |||
| 1991 | TP_STRUCT__entry( | ||
| 1992 | __field(unsigned int, dq_id) | ||
| 1993 | __field(unsigned int, dq_type) | ||
| 1994 | __field(unsigned long, type) | ||
| 1995 | __string(s_id, s_id) | ||
| 1996 | ), | ||
| 1997 | TP_fast_assign( | ||
| 1998 | __entry->dq_id = dq_id; | ||
| 1999 | __entry->dq_type = dq_type; | ||
| 2000 | __entry->type = type; | ||
| 2001 | __assign_str(s_id, s_id); | ||
| 2002 | ), | ||
| 2003 | TP_printk("%u %u %lu %s", __entry->dq_id, __entry->dq_type, | ||
| 2004 | __entry->type, __get_str(s_id)) | ||
| 2005 | ); | ||
| 2006 | |||
| 2007 | DEFINE_OCFS2_UINT_INT_EVENT(ocfs2_write_dquot); | ||
| 2008 | |||
| 2009 | DEFINE_OCFS2_UINT_INT_EVENT(ocfs2_release_dquot); | ||
| 2010 | |||
| 2011 | DEFINE_OCFS2_UINT_INT_EVENT(ocfs2_acquire_dquot); | ||
| 2012 | |||
| 2013 | DEFINE_OCFS2_UINT_INT_EVENT(ocfs2_mark_dquot_dirty); | ||
| 2014 | |||
| 2015 | /* End of trace events for fs/ocfs2/quota_global.c. */ | ||
| 2016 | |||
| 2017 | /* Trace events for fs/ocfs2/dir.c. */ | ||
| 2018 | DEFINE_OCFS2_INT_EVENT(ocfs2_search_dirblock); | ||
| 2019 | |||
| 2020 | DEFINE_OCFS2_ULL_EVENT(ocfs2_validate_dir_block); | ||
| 2021 | |||
| 2022 | DEFINE_OCFS2_POINTER_EVENT(ocfs2_find_entry_el); | ||
| 2023 | |||
| 2024 | TRACE_EVENT(ocfs2_dx_dir_search, | ||
| 2025 | TP_PROTO(unsigned long long ino, int namelen, const char *name, | ||
| 2026 | unsigned int major_hash, unsigned int minor_hash, | ||
| 2027 | unsigned long long blkno), | ||
| 2028 | TP_ARGS(ino, namelen, name, major_hash, minor_hash, blkno), | ||
| 2029 | TP_STRUCT__entry( | ||
| 2030 | __field(unsigned long long, ino) | ||
| 2031 | __field(int, namelen) | ||
| 2032 | __string(name, name) | ||
| 2033 | __field(unsigned int, major_hash) | ||
| 2034 | __field(unsigned int,minor_hash) | ||
| 2035 | __field(unsigned long long, blkno) | ||
| 2036 | ), | ||
| 2037 | TP_fast_assign( | ||
| 2038 | __entry->ino = ino; | ||
| 2039 | __entry->namelen = namelen; | ||
| 2040 | __assign_str(name, name); | ||
| 2041 | __entry->major_hash = major_hash; | ||
| 2042 | __entry->minor_hash = minor_hash; | ||
| 2043 | __entry->blkno = blkno; | ||
| 2044 | ), | ||
| 2045 | TP_printk("%llu %.*s %u %u %llu", __entry->ino, | ||
| 2046 | __entry->namelen, __get_str(name), | ||
| 2047 | __entry->major_hash, __entry->minor_hash, __entry->blkno) | ||
| 2048 | ); | ||
| 2049 | |||
| 2050 | DEFINE_OCFS2_UINT_UINT_EVENT(ocfs2_dx_dir_search_leaf_info); | ||
| 2051 | |||
| 2052 | DEFINE_OCFS2_ULL_INT_EVENT(ocfs2_delete_entry_dx); | ||
| 2053 | |||
| 2054 | DEFINE_OCFS2_ULL_EVENT(ocfs2_readdir); | ||
| 2055 | |||
| 2056 | TRACE_EVENT(ocfs2_find_files_on_disk, | ||
| 2057 | TP_PROTO(int namelen, const char *name, void *blkno, | ||
| 2058 | unsigned long long dir), | ||
| 2059 | TP_ARGS(namelen, name, blkno, dir), | ||
| 2060 | TP_STRUCT__entry( | ||
| 2061 | __field(int, namelen) | ||
| 2062 | __string(name, name) | ||
| 2063 | __field(void *, blkno) | ||
| 2064 | __field(unsigned long long, dir) | ||
| 2065 | ), | ||
| 2066 | TP_fast_assign( | ||
| 2067 | __entry->namelen = namelen; | ||
| 2068 | __assign_str(name, name); | ||
| 2069 | __entry->blkno = blkno; | ||
| 2070 | __entry->dir = dir; | ||
| 2071 | ), | ||
| 2072 | TP_printk("%.*s %p %llu", __entry->namelen, __get_str(name), | ||
| 2073 | __entry->blkno, __entry->dir) | ||
| 2074 | ); | ||
| 2075 | |||
| 2076 | TRACE_EVENT(ocfs2_check_dir_for_entry, | ||
| 2077 | TP_PROTO(unsigned long long dir, int namelen, const char *name), | ||
| 2078 | TP_ARGS(dir, namelen, name), | ||
| 2079 | TP_STRUCT__entry( | ||
| 2080 | __field(unsigned long long, dir) | ||
| 2081 | __field(int, namelen) | ||
| 2082 | __string(name, name) | ||
| 2083 | ), | ||
| 2084 | TP_fast_assign( | ||
| 2085 | __entry->dir = dir; | ||
| 2086 | __entry->namelen = namelen; | ||
| 2087 | __assign_str(name, name); | ||
| 2088 | ), | ||
| 2089 | TP_printk("%llu %.*s", __entry->dir, | ||
| 2090 | __entry->namelen, __get_str(name)) | ||
| 2091 | ); | ||
| 2092 | |||
| 2093 | DEFINE_OCFS2_ULL_ULL_EVENT(ocfs2_dx_dir_attach_index); | ||
| 2094 | |||
| 2095 | DEFINE_OCFS2_ULL_ULL_UINT_EVENT(ocfs2_dx_dir_format_cluster); | ||
| 2096 | |||
| 2097 | TRACE_EVENT(ocfs2_dx_dir_index_root_block, | ||
| 2098 | TP_PROTO(unsigned long long dir, | ||
| 2099 | unsigned int major_hash, unsigned int minor_hash, | ||
| 2100 | int namelen, const char *name, unsigned int num_used), | ||
| 2101 | TP_ARGS(dir, major_hash, minor_hash, namelen, name, num_used), | ||
| 2102 | TP_STRUCT__entry( | ||
| 2103 | __field(unsigned long long, dir) | ||
| 2104 | __field(unsigned int, major_hash) | ||
| 2105 | __field(unsigned int, minor_hash) | ||
| 2106 | __field(int, namelen) | ||
| 2107 | __string(name, name) | ||
| 2108 | __field(unsigned int, num_used) | ||
| 2109 | ), | ||
| 2110 | TP_fast_assign( | ||
| 2111 | __entry->dir = dir; | ||
| 2112 | __entry->major_hash = major_hash; | ||
| 2113 | __entry->minor_hash = minor_hash; | ||
| 2114 | __entry->namelen = namelen; | ||
| 2115 | __assign_str(name, name); | ||
| 2116 | __entry->num_used = num_used; | ||
| 2117 | ), | ||
| 2118 | TP_printk("%llu %x %x %.*s %u", __entry->dir, | ||
| 2119 | __entry->major_hash, __entry->minor_hash, | ||
| 2120 | __entry->namelen, __get_str(name), __entry->num_used) | ||
| 2121 | ); | ||
| 2122 | |||
| 2123 | DEFINE_OCFS2_ULL_ULL_EVENT(ocfs2_extend_dir); | ||
| 2124 | |||
| 2125 | DEFINE_OCFS2_ULL_ULL_UINT_EVENT(ocfs2_dx_dir_rebalance); | ||
| 2126 | |||
| 2127 | DEFINE_OCFS2_UINT_UINT_UINT_EVENT(ocfs2_dx_dir_rebalance_split); | ||
| 2128 | |||
| 2129 | DEFINE_OCFS2_ULL_INT_EVENT(ocfs2_prepare_dir_for_insert); | ||
| 2130 | |||
| 2131 | /* End of trace events for fs/ocfs2/dir.c. */ | ||
| 2132 | |||
| 2133 | /* Trace events for fs/ocfs2/namei.c. */ | ||
| 2134 | |||
| 2135 | DECLARE_EVENT_CLASS(ocfs2__dentry_ops, | ||
| 2136 | TP_PROTO(void *dir, void *dentry, int name_len, const char *name, | ||
| 2137 | unsigned long long dir_blkno, unsigned long long extra), | ||
| 2138 | TP_ARGS(dir, dentry, name_len, name, dir_blkno, extra), | ||
| 2139 | TP_STRUCT__entry( | ||
| 2140 | __field(void *, dir) | ||
| 2141 | __field(void *, dentry) | ||
| 2142 | __field(int, name_len) | ||
| 2143 | __string(name, name) | ||
| 2144 | __field(unsigned long long, dir_blkno) | ||
| 2145 | __field(unsigned long long, extra) | ||
| 2146 | ), | ||
| 2147 | TP_fast_assign( | ||
| 2148 | __entry->dir = dir; | ||
| 2149 | __entry->dentry = dentry; | ||
| 2150 | __entry->name_len = name_len; | ||
| 2151 | __assign_str(name, name); | ||
| 2152 | __entry->dir_blkno = dir_blkno; | ||
| 2153 | __entry->extra = extra; | ||
| 2154 | ), | ||
| 2155 | TP_printk("%p %p %.*s %llu %llu", __entry->dir, __entry->dentry, | ||
| 2156 | __entry->name_len, __get_str(name), | ||
| 2157 | __entry->dir_blkno, __entry->extra) | ||
| 2158 | ); | ||
| 2159 | |||
| 2160 | #define DEFINE_OCFS2_DENTRY_OPS(name) \ | ||
| 2161 | DEFINE_EVENT(ocfs2__dentry_ops, name, \ | ||
| 2162 | TP_PROTO(void *dir, void *dentry, int name_len, const char *name, \ | ||
| 2163 | unsigned long long dir_blkno, unsigned long long extra), \ | ||
| 2164 | TP_ARGS(dir, dentry, name_len, name, dir_blkno, extra)) | ||
| 2165 | |||
| 2166 | DEFINE_OCFS2_DENTRY_OPS(ocfs2_lookup); | ||
| 2167 | |||
| 2168 | DEFINE_OCFS2_DENTRY_OPS(ocfs2_mkdir); | ||
| 2169 | |||
| 2170 | DEFINE_OCFS2_DENTRY_OPS(ocfs2_create); | ||
| 2171 | |||
| 2172 | DEFINE_OCFS2_DENTRY_OPS(ocfs2_unlink); | ||
| 2173 | |||
| 2174 | DEFINE_OCFS2_DENTRY_OPS(ocfs2_symlink_create); | ||
| 2175 | |||
| 2176 | DEFINE_OCFS2_DENTRY_OPS(ocfs2_mv_orphaned_inode_to_new); | ||
| 2177 | |||
| 2178 | DEFINE_OCFS2_POINTER_EVENT(ocfs2_lookup_ret); | ||
| 2179 | |||
| 2180 | TRACE_EVENT(ocfs2_mknod, | ||
| 2181 | TP_PROTO(void *dir, void *dentry, int name_len, const char *name, | ||
| 2182 | unsigned long long dir_blkno, unsigned long dev, int mode), | ||
| 2183 | TP_ARGS(dir, dentry, name_len, name, dir_blkno, dev, mode), | ||
| 2184 | TP_STRUCT__entry( | ||
| 2185 | __field(void *, dir) | ||
| 2186 | __field(void *, dentry) | ||
| 2187 | __field(int, name_len) | ||
| 2188 | __string(name, name) | ||
| 2189 | __field(unsigned long long, dir_blkno) | ||
| 2190 | __field(unsigned long, dev) | ||
| 2191 | __field(int, mode) | ||
| 2192 | ), | ||
| 2193 | TP_fast_assign( | ||
| 2194 | __entry->dir = dir; | ||
| 2195 | __entry->dentry = dentry; | ||
| 2196 | __entry->name_len = name_len; | ||
| 2197 | __assign_str(name, name); | ||
| 2198 | __entry->dir_blkno = dir_blkno; | ||
| 2199 | __entry->dev = dev; | ||
| 2200 | __entry->mode = mode; | ||
| 2201 | ), | ||
| 2202 | TP_printk("%p %p %.*s %llu %lu %d", __entry->dir, __entry->dentry, | ||
| 2203 | __entry->name_len, __get_str(name), | ||
| 2204 | __entry->dir_blkno, __entry->dev, __entry->mode) | ||
| 2205 | ); | ||
| 2206 | |||
| 2207 | TRACE_EVENT(ocfs2_link, | ||
| 2208 | TP_PROTO(unsigned long long ino, int old_len, const char *old_name, | ||
| 2209 | int name_len, const char *name), | ||
| 2210 | TP_ARGS(ino, old_len, old_name, name_len, name), | ||
| 2211 | TP_STRUCT__entry( | ||
| 2212 | __field(unsigned long long, ino) | ||
| 2213 | __field(int, old_len) | ||
| 2214 | __string(old_name, old_name) | ||
| 2215 | __field(int, name_len) | ||
| 2216 | __string(name, name) | ||
| 2217 | ), | ||
| 2218 | TP_fast_assign( | ||
| 2219 | __entry->ino = ino; | ||
| 2220 | __entry->old_len = old_len; | ||
| 2221 | __assign_str(old_name, old_name); | ||
| 2222 | __entry->name_len = name_len; | ||
| 2223 | __assign_str(name, name); | ||
| 2224 | ), | ||
| 2225 | TP_printk("%llu %.*s %.*s", __entry->ino, | ||
| 2226 | __entry->old_len, __get_str(old_name), | ||
| 2227 | __entry->name_len, __get_str(name)) | ||
| 2228 | ); | ||
| 2229 | |||
| 2230 | DEFINE_OCFS2_ULL_ULL_UINT_EVENT(ocfs2_unlink_noent); | ||
| 2231 | |||
| 2232 | DEFINE_OCFS2_ULL_ULL_EVENT(ocfs2_double_lock); | ||
| 2233 | |||
| 2234 | DEFINE_OCFS2_ULL_ULL_EVENT(ocfs2_double_lock_end); | ||
| 2235 | |||
| 2236 | TRACE_EVENT(ocfs2_rename, | ||
| 2237 | TP_PROTO(void *old_dir, void *old_dentry, | ||
| 2238 | void *new_dir, void *new_dentry, | ||
| 2239 | int old_len, const char *old_name, | ||
| 2240 | int new_len, const char *new_name), | ||
| 2241 | TP_ARGS(old_dir, old_dentry, new_dir, new_dentry, | ||
| 2242 | old_len, old_name, new_len, new_name), | ||
| 2243 | TP_STRUCT__entry( | ||
| 2244 | __field(void *, old_dir) | ||
| 2245 | __field(void *, old_dentry) | ||
| 2246 | __field(void *, new_dir) | ||
| 2247 | __field(void *, new_dentry) | ||
| 2248 | __field(int, old_len) | ||
| 2249 | __string(old_name, old_name) | ||
| 2250 | __field(int, new_len) | ||
| 2251 | __string(new_name, new_name) | ||
| 2252 | ), | ||
| 2253 | TP_fast_assign( | ||
| 2254 | __entry->old_dir = old_dir; | ||
| 2255 | __entry->old_dentry = old_dentry; | ||
| 2256 | __entry->new_dir = new_dir; | ||
| 2257 | __entry->new_dentry = new_dentry; | ||
| 2258 | __entry->old_len = old_len; | ||
| 2259 | __assign_str(old_name, old_name); | ||
| 2260 | __entry->new_len = new_len; | ||
| 2261 | __assign_str(new_name, new_name); | ||
| 2262 | ), | ||
| 2263 | TP_printk("%p %p %p %p %.*s %.*s", | ||
| 2264 | __entry->old_dir, __entry->old_dentry, | ||
| 2265 | __entry->new_dir, __entry->new_dentry, | ||
| 2266 | __entry->old_len, __get_str(old_name), | ||
| 2267 | __entry->new_len, __get_str(new_name)) | ||
| 2268 | ); | ||
| 2269 | |||
| 2270 | TRACE_EVENT(ocfs2_rename_target_exists, | ||
| 2271 | TP_PROTO(int new_len, const char *new_name), | ||
| 2272 | TP_ARGS(new_len, new_name), | ||
| 2273 | TP_STRUCT__entry( | ||
| 2274 | __field(int, new_len) | ||
| 2275 | __string(new_name, new_name) | ||
| 2276 | ), | ||
| 2277 | TP_fast_assign( | ||
| 2278 | __entry->new_len = new_len; | ||
| 2279 | __assign_str(new_name, new_name); | ||
| 2280 | ), | ||
| 2281 | TP_printk("%.*s", __entry->new_len, __get_str(new_name)) | ||
| 2282 | ); | ||
| 2283 | |||
| 2284 | DEFINE_OCFS2_ULL_ULL_UINT_EVENT(ocfs2_rename_disagree); | ||
| 2285 | |||
| 2286 | TRACE_EVENT(ocfs2_rename_over_existing, | ||
| 2287 | TP_PROTO(unsigned long long new_blkno, void *new_bh, | ||
| 2288 | unsigned long long newdi_blkno), | ||
| 2289 | TP_ARGS(new_blkno, new_bh, newdi_blkno), | ||
| 2290 | TP_STRUCT__entry( | ||
| 2291 | __field(unsigned long long, new_blkno) | ||
| 2292 | __field(void *, new_bh) | ||
| 2293 | __field(unsigned long long, newdi_blkno) | ||
| 2294 | ), | ||
| 2295 | TP_fast_assign( | ||
| 2296 | __entry->new_blkno = new_blkno; | ||
| 2297 | __entry->new_bh = new_bh; | ||
| 2298 | __entry->newdi_blkno = newdi_blkno; | ||
| 2299 | ), | ||
| 2300 | TP_printk("%llu %p %llu", __entry->new_blkno, __entry->new_bh, | ||
| 2301 | __entry->newdi_blkno) | ||
| 2302 | ); | ||
| 2303 | |||
| 2304 | DEFINE_OCFS2_ULL_ULL_UINT_EVENT(ocfs2_create_symlink_data); | ||
| 2305 | |||
| 2306 | TRACE_EVENT(ocfs2_symlink_begin, | ||
| 2307 | TP_PROTO(void *dir, void *dentry, const char *symname, | ||
| 2308 | int len, const char *name), | ||
| 2309 | TP_ARGS(dir, dentry, symname, len, name), | ||
| 2310 | TP_STRUCT__entry( | ||
| 2311 | __field(void *, dir) | ||
| 2312 | __field(void *, dentry) | ||
| 2313 | __field(const char *, symname) | ||
| 2314 | __field(int, len) | ||
| 2315 | __string(name, name) | ||
| 2316 | ), | ||
| 2317 | TP_fast_assign( | ||
| 2318 | __entry->dir = dir; | ||
| 2319 | __entry->dentry = dentry; | ||
| 2320 | __entry->symname = symname; | ||
| 2321 | __entry->len = len; | ||
| 2322 | __assign_str(name, name); | ||
| 2323 | ), | ||
| 2324 | TP_printk("%p %p %s %.*s", __entry->dir, __entry->dentry, | ||
| 2325 | __entry->symname, __entry->len, __get_str(name)) | ||
| 2326 | ); | ||
| 2327 | |||
| 2328 | TRACE_EVENT(ocfs2_blkno_stringify, | ||
| 2329 | TP_PROTO(unsigned long long blkno, const char *name, int namelen), | ||
| 2330 | TP_ARGS(blkno, name, namelen), | ||
| 2331 | TP_STRUCT__entry( | ||
| 2332 | __field(unsigned long long, blkno) | ||
| 2333 | __string(name, name) | ||
| 2334 | __field(int, namelen) | ||
| 2335 | ), | ||
| 2336 | TP_fast_assign( | ||
| 2337 | __entry->blkno = blkno; | ||
| 2338 | __assign_str(name, name); | ||
| 2339 | __entry->namelen = namelen; | ||
| 2340 | ), | ||
| 2341 | TP_printk("%llu %s %d", __entry->blkno, __get_str(name), | ||
| 2342 | __entry->namelen) | ||
| 2343 | ); | ||
| 2344 | |||
| 2345 | DEFINE_OCFS2_ULL_EVENT(ocfs2_orphan_add_begin); | ||
| 2346 | |||
| 2347 | DEFINE_OCFS2_ULL_UINT_EVENT(ocfs2_orphan_add_end); | ||
| 2348 | |||
| 2349 | TRACE_EVENT(ocfs2_orphan_del, | ||
| 2350 | TP_PROTO(unsigned long long dir, const char *name, int namelen), | ||
| 2351 | TP_ARGS(dir, name, namelen), | ||
| 2352 | TP_STRUCT__entry( | ||
| 2353 | __field(unsigned long long, dir) | ||
| 2354 | __string(name, name) | ||
| 2355 | __field(int, namelen) | ||
| 2356 | ), | ||
| 2357 | TP_fast_assign( | ||
| 2358 | __entry->dir = dir; | ||
| 2359 | __assign_str(name, name); | ||
| 2360 | __entry->namelen = namelen; | ||
| 2361 | ), | ||
| 2362 | TP_printk("%llu %s %d", __entry->dir, __get_str(name), | ||
| 2363 | __entry->namelen) | ||
| 2364 | ); | ||
| 2365 | |||
| 2366 | /* End of trace events for fs/ocfs2/namei.c. */ | ||
| 2367 | |||
| 2368 | /* Trace events for fs/ocfs2/dcache.c. */ | ||
| 2369 | |||
| 2370 | TRACE_EVENT(ocfs2_dentry_revalidate, | ||
| 2371 | TP_PROTO(void *dentry, int len, const char *name), | ||
| 2372 | TP_ARGS(dentry, len, name), | ||
| 2373 | TP_STRUCT__entry( | ||
| 2374 | __field(void *, dentry) | ||
| 2375 | __field(int, len) | ||
| 2376 | __string(name, name) | ||
| 2377 | ), | ||
| 2378 | TP_fast_assign( | ||
| 2379 | __entry->dentry = dentry; | ||
| 2380 | __entry->len = len; | ||
| 2381 | __assign_str(name, name); | ||
| 2382 | ), | ||
| 2383 | TP_printk("%p %.*s", __entry->dentry, __entry->len, __get_str(name)) | ||
| 2384 | ); | ||
| 2385 | |||
| 2386 | TRACE_EVENT(ocfs2_dentry_revalidate_negative, | ||
| 2387 | TP_PROTO(int len, const char *name, unsigned long pgen, | ||
| 2388 | unsigned long gen), | ||
| 2389 | TP_ARGS(len, name, pgen, gen), | ||
| 2390 | TP_STRUCT__entry( | ||
| 2391 | __field(int, len) | ||
| 2392 | __string(name, name) | ||
| 2393 | __field(unsigned long, pgen) | ||
| 2394 | __field(unsigned long, gen) | ||
| 2395 | ), | ||
| 2396 | TP_fast_assign( | ||
| 2397 | __entry->len = len; | ||
| 2398 | __assign_str(name, name); | ||
| 2399 | __entry->pgen = pgen; | ||
| 2400 | __entry->gen = gen; | ||
| 2401 | ), | ||
| 2402 | TP_printk("%.*s %lu %lu", __entry->len, __get_str(name), | ||
| 2403 | __entry->pgen, __entry->gen) | ||
| 2404 | ); | ||
| 2405 | |||
| 2406 | DEFINE_OCFS2_ULL_EVENT(ocfs2_dentry_revalidate_delete); | ||
| 2407 | |||
| 2408 | DEFINE_OCFS2_ULL_INT_EVENT(ocfs2_dentry_revalidate_orphaned); | ||
| 2409 | |||
| 2410 | DEFINE_OCFS2_ULL_EVENT(ocfs2_dentry_revalidate_nofsdata); | ||
| 2411 | |||
| 2412 | DEFINE_OCFS2_INT_EVENT(ocfs2_dentry_revalidate_ret); | ||
| 2413 | |||
| 2414 | TRACE_EVENT(ocfs2_find_local_alias, | ||
| 2415 | TP_PROTO(int len, const char *name), | ||
| 2416 | TP_ARGS(len, name), | ||
| 2417 | TP_STRUCT__entry( | ||
| 2418 | __field(int, len) | ||
| 2419 | __string(name, name) | ||
| 2420 | ), | ||
| 2421 | TP_fast_assign( | ||
| 2422 | __entry->len = len; | ||
| 2423 | __assign_str(name, name); | ||
| 2424 | ), | ||
| 2425 | TP_printk("%.*s", __entry->len, __get_str(name)) | ||
| 2426 | ); | ||
| 2427 | |||
| 2428 | TRACE_EVENT(ocfs2_dentry_attach_lock, | ||
| 2429 | TP_PROTO(int len, const char *name, | ||
| 2430 | unsigned long long parent, void *fsdata), | ||
| 2431 | TP_ARGS(len, name, parent, fsdata), | ||
| 2432 | TP_STRUCT__entry( | ||
| 2433 | __field(int, len) | ||
| 2434 | __string(name, name) | ||
| 2435 | __field(unsigned long long, parent) | ||
| 2436 | __field(void *, fsdata) | ||
| 2437 | ), | ||
| 2438 | TP_fast_assign( | ||
| 2439 | __entry->len = len; | ||
| 2440 | __assign_str(name, name); | ||
| 2441 | __entry->parent = parent; | ||
| 2442 | __entry->fsdata = fsdata; | ||
| 2443 | ), | ||
| 2444 | TP_printk("%.*s %llu %p", __entry->len, __get_str(name), | ||
| 2445 | __entry->parent, __entry->fsdata) | ||
| 2446 | ); | ||
| 2447 | |||
| 2448 | TRACE_EVENT(ocfs2_dentry_attach_lock_found, | ||
| 2449 | TP_PROTO(const char *name, unsigned long long parent, | ||
| 2450 | unsigned long long ino), | ||
| 2451 | TP_ARGS(name, parent, ino), | ||
| 2452 | TP_STRUCT__entry( | ||
| 2453 | __string(name, name) | ||
| 2454 | __field(unsigned long long, parent) | ||
| 2455 | __field(unsigned long long, ino) | ||
| 2456 | ), | ||
| 2457 | TP_fast_assign( | ||
| 2458 | __assign_str(name, name); | ||
| 2459 | __entry->parent = parent; | ||
| 2460 | __entry->ino = ino; | ||
| 2461 | ), | ||
| 2462 | TP_printk("%s %llu %llu", __get_str(name), __entry->parent, __entry->ino) | ||
| 2463 | ); | ||
| 2464 | /* End of trace events for fs/ocfs2/dcache.c. */ | ||
| 2465 | |||
| 2466 | /* Trace events for fs/ocfs2/export.c. */ | ||
| 2467 | |||
| 2468 | TRACE_EVENT(ocfs2_get_dentry_begin, | ||
| 2469 | TP_PROTO(void *sb, void *handle, unsigned long long blkno), | ||
| 2470 | TP_ARGS(sb, handle, blkno), | ||
| 2471 | TP_STRUCT__entry( | ||
| 2472 | __field(void *, sb) | ||
| 2473 | __field(void *, handle) | ||
| 2474 | __field(unsigned long long, blkno) | ||
| 2475 | ), | ||
| 2476 | TP_fast_assign( | ||
| 2477 | __entry->sb = sb; | ||
| 2478 | __entry->handle = handle; | ||
| 2479 | __entry->blkno = blkno; | ||
| 2480 | ), | ||
| 2481 | TP_printk("%p %p %llu", __entry->sb, __entry->handle, __entry->blkno) | ||
| 2482 | ); | ||
| 2483 | |||
| 2484 | DEFINE_OCFS2_INT_INT_EVENT(ocfs2_get_dentry_test_bit); | ||
| 2485 | |||
| 2486 | DEFINE_OCFS2_ULL_UINT_EVENT(ocfs2_get_dentry_stale); | ||
| 2487 | |||
| 2488 | DEFINE_OCFS2_ULL_UINT_UINT_EVENT(ocfs2_get_dentry_generation); | ||
| 2489 | |||
| 2490 | DEFINE_OCFS2_POINTER_EVENT(ocfs2_get_dentry_end); | ||
| 2491 | |||
| 2492 | TRACE_EVENT(ocfs2_get_parent, | ||
| 2493 | TP_PROTO(void *child, int len, const char *name, | ||
| 2494 | unsigned long long ino), | ||
| 2495 | TP_ARGS(child, len, name, ino), | ||
| 2496 | TP_STRUCT__entry( | ||
| 2497 | __field(void *, child) | ||
| 2498 | __field(int, len) | ||
| 2499 | __string(name, name) | ||
| 2500 | __field(unsigned long long, ino) | ||
| 2501 | ), | ||
| 2502 | TP_fast_assign( | ||
| 2503 | __entry->child = child; | ||
| 2504 | __entry->len = len; | ||
| 2505 | __assign_str(name, name); | ||
| 2506 | __entry->ino = ino; | ||
| 2507 | ), | ||
| 2508 | TP_printk("%p %.*s %llu", __entry->child, __entry->len, | ||
| 2509 | __get_str(name), __entry->ino) | ||
| 2510 | ); | ||
| 2511 | |||
| 2512 | DEFINE_OCFS2_POINTER_EVENT(ocfs2_get_parent_end); | ||
| 2513 | |||
| 2514 | TRACE_EVENT(ocfs2_encode_fh_begin, | ||
| 2515 | TP_PROTO(void *dentry, int name_len, const char *name, | ||
| 2516 | void *fh, int len, int connectable), | ||
| 2517 | TP_ARGS(dentry, name_len, name, fh, len, connectable), | ||
| 2518 | TP_STRUCT__entry( | ||
| 2519 | __field(void *, dentry) | ||
| 2520 | __field(int, name_len) | ||
| 2521 | __string(name, name) | ||
| 2522 | __field(void *, fh) | ||
| 2523 | __field(int, len) | ||
| 2524 | __field(int, connectable) | ||
| 2525 | ), | ||
| 2526 | TP_fast_assign( | ||
| 2527 | __entry->dentry = dentry; | ||
| 2528 | __entry->name_len = name_len; | ||
| 2529 | __assign_str(name, name); | ||
| 2530 | __entry->fh = fh; | ||
| 2531 | __entry->len = len; | ||
| 2532 | __entry->connectable = connectable; | ||
| 2533 | ), | ||
| 2534 | TP_printk("%p %.*s %p %d %d", __entry->dentry, __entry->name_len, | ||
| 2535 | __get_str(name), __entry->fh, __entry->len, | ||
| 2536 | __entry->connectable) | ||
| 2537 | ); | ||
| 2538 | |||
| 2539 | DEFINE_OCFS2_ULL_UINT_EVENT(ocfs2_encode_fh_self); | ||
| 2540 | |||
| 2541 | DEFINE_OCFS2_ULL_UINT_EVENT(ocfs2_encode_fh_parent); | ||
| 2542 | |||
| 2543 | DEFINE_OCFS2_INT_EVENT(ocfs2_encode_fh_type); | ||
| 2544 | |||
| 2545 | /* End of trace events for fs/ocfs2/export.c. */ | ||
| 2546 | |||
| 2547 | /* Trace events for fs/ocfs2/journal.c. */ | ||
| 2548 | |||
| 2549 | DEFINE_OCFS2_UINT_EVENT(ocfs2_commit_cache_begin); | ||
| 2550 | |||
| 2551 | DEFINE_OCFS2_ULL_UINT_EVENT(ocfs2_commit_cache_end); | ||
| 2552 | |||
| 2553 | DEFINE_OCFS2_INT_INT_EVENT(ocfs2_extend_trans); | ||
| 2554 | |||
| 2555 | DEFINE_OCFS2_INT_EVENT(ocfs2_extend_trans_restart); | ||
| 2556 | |||
| 2557 | DEFINE_OCFS2_ULL_ULL_UINT_UINT_EVENT(ocfs2_journal_access); | ||
| 2558 | |||
| 2559 | DEFINE_OCFS2_ULL_EVENT(ocfs2_journal_dirty); | ||
| 2560 | |||
| 2561 | DEFINE_OCFS2_ULL_ULL_UINT_EVENT(ocfs2_journal_init); | ||
| 2562 | |||
| 2563 | DEFINE_OCFS2_UINT_EVENT(ocfs2_journal_init_maxlen); | ||
| 2564 | |||
| 2565 | DEFINE_OCFS2_INT_EVENT(ocfs2_journal_shutdown); | ||
| 2566 | |||
| 2567 | DEFINE_OCFS2_POINTER_EVENT(ocfs2_journal_shutdown_wait); | ||
| 2568 | |||
| 2569 | DEFINE_OCFS2_ULL_EVENT(ocfs2_complete_recovery); | ||
| 2570 | |||
| 2571 | DEFINE_OCFS2_INT_EVENT(ocfs2_complete_recovery_end); | ||
| 2572 | |||
| 2573 | TRACE_EVENT(ocfs2_complete_recovery_slot, | ||
| 2574 | TP_PROTO(int slot, unsigned long long la_ino, | ||
| 2575 | unsigned long long tl_ino, void *qrec), | ||
| 2576 | TP_ARGS(slot, la_ino, tl_ino, qrec), | ||
| 2577 | TP_STRUCT__entry( | ||
| 2578 | __field(int, slot) | ||
| 2579 | __field(unsigned long long, la_ino) | ||
| 2580 | __field(unsigned long long, tl_ino) | ||
| 2581 | __field(void *, qrec) | ||
| 2582 | ), | ||
| 2583 | TP_fast_assign( | ||
| 2584 | __entry->slot = slot; | ||
| 2585 | __entry->la_ino = la_ino; | ||
| 2586 | __entry->tl_ino = tl_ino; | ||
| 2587 | __entry->qrec = qrec; | ||
| 2588 | ), | ||
| 2589 | TP_printk("%d %llu %llu %p", __entry->slot, __entry->la_ino, | ||
| 2590 | __entry->tl_ino, __entry->qrec) | ||
| 2591 | ); | ||
| 2592 | |||
| 2593 | DEFINE_OCFS2_INT_INT_EVENT(ocfs2_recovery_thread_node); | ||
| 2594 | |||
| 2595 | DEFINE_OCFS2_INT_EVENT(ocfs2_recovery_thread_end); | ||
| 2596 | |||
| 2597 | TRACE_EVENT(ocfs2_recovery_thread, | ||
| 2598 | TP_PROTO(int node_num, int osb_node_num, int disable, | ||
| 2599 | void *recovery_thread, int map_set), | ||
| 2600 | TP_ARGS(node_num, osb_node_num, disable, recovery_thread, map_set), | ||
| 2601 | TP_STRUCT__entry( | ||
| 2602 | __field(int, node_num) | ||
| 2603 | __field(int, osb_node_num) | ||
| 2604 | __field(int,disable) | ||
| 2605 | __field(void *, recovery_thread) | ||
| 2606 | __field(int,map_set) | ||
| 2607 | ), | ||
| 2608 | TP_fast_assign( | ||
| 2609 | __entry->node_num = node_num; | ||
| 2610 | __entry->osb_node_num = osb_node_num; | ||
| 2611 | __entry->disable = disable; | ||
| 2612 | __entry->recovery_thread = recovery_thread; | ||
| 2613 | __entry->map_set = map_set; | ||
| 2614 | ), | ||
| 2615 | TP_printk("%d %d %d %p %d", __entry->node_num, | ||
| 2616 | __entry->osb_node_num, __entry->disable, | ||
| 2617 | __entry->recovery_thread, __entry->map_set) | ||
| 2618 | ); | ||
| 2619 | |||
| 2620 | DEFINE_OCFS2_UINT_UINT_UINT_EVENT(ocfs2_replay_journal_recovered); | ||
| 2621 | |||
| 2622 | DEFINE_OCFS2_INT_EVENT(ocfs2_replay_journal_lock_err); | ||
| 2623 | |||
| 2624 | DEFINE_OCFS2_INT_EVENT(ocfs2_replay_journal_skip); | ||
| 2625 | |||
| 2626 | DEFINE_OCFS2_UINT_UINT_UINT_EVENT(ocfs2_recover_node); | ||
| 2627 | |||
| 2628 | DEFINE_OCFS2_UINT_UINT_EVENT(ocfs2_recover_node_skip); | ||
| 2629 | |||
| 2630 | DEFINE_OCFS2_UINT_UINT_EVENT(ocfs2_mark_dead_nodes); | ||
| 2631 | |||
| 2632 | DEFINE_OCFS2_UINT_UINT_UINT_EVENT(ocfs2_queue_orphan_scan_begin); | ||
| 2633 | |||
| 2634 | DEFINE_OCFS2_UINT_UINT_UINT_EVENT(ocfs2_queue_orphan_scan_end); | ||
| 2635 | |||
| 2636 | DEFINE_OCFS2_ULL_EVENT(ocfs2_orphan_filldir); | ||
| 2637 | |||
| 2638 | DEFINE_OCFS2_INT_EVENT(ocfs2_recover_orphans); | ||
| 2639 | |||
| 2640 | DEFINE_OCFS2_ULL_EVENT(ocfs2_recover_orphans_iput); | ||
| 2641 | |||
| 2642 | DEFINE_OCFS2_INT_EVENT(ocfs2_wait_on_mount); | ||
| 2643 | |||
| 2644 | /* End of trace events for fs/ocfs2/journal.c. */ | ||
| 2645 | |||
| 2646 | /* Trace events for fs/ocfs2/buffer_head_io.c. */ | ||
| 2647 | |||
| 2648 | DEFINE_OCFS2_ULL_UINT_EVENT(ocfs2_read_blocks_sync); | ||
| 2649 | |||
| 2650 | DEFINE_OCFS2_ULL_EVENT(ocfs2_read_blocks_sync_jbd); | ||
| 2651 | |||
| 2652 | DEFINE_OCFS2_ULL_ULL_EVENT(ocfs2_read_blocks_from_disk); | ||
| 2653 | |||
| 2654 | DEFINE_OCFS2_ULL_INT_INT_INT_EVENT(ocfs2_read_blocks_bh); | ||
| 2655 | |||
| 2656 | DEFINE_OCFS2_ULL_INT_INT_INT_EVENT(ocfs2_read_blocks_end); | ||
| 2657 | |||
| 2658 | TRACE_EVENT(ocfs2_write_block, | ||
| 2659 | TP_PROTO(unsigned long long block, void *ci), | ||
| 2660 | TP_ARGS(block, ci), | ||
| 2661 | TP_STRUCT__entry( | ||
| 2662 | __field(unsigned long long, block) | ||
| 2663 | __field(void *, ci) | ||
| 2664 | ), | ||
| 2665 | TP_fast_assign( | ||
| 2666 | __entry->block = block; | ||
| 2667 | __entry->ci = ci; | ||
| 2668 | ), | ||
| 2669 | TP_printk("%llu %p", __entry->block, __entry->ci) | ||
| 2670 | ); | ||
| 2671 | |||
| 2672 | TRACE_EVENT(ocfs2_read_blocks_begin, | ||
| 2673 | TP_PROTO(void *ci, unsigned long long block, | ||
| 2674 | unsigned int nr, int flags), | ||
| 2675 | TP_ARGS(ci, block, nr, flags), | ||
| 2676 | TP_STRUCT__entry( | ||
| 2677 | __field(void *, ci) | ||
| 2678 | __field(unsigned long long, block) | ||
| 2679 | __field(unsigned int, nr) | ||
| 2680 | __field(int, flags) | ||
| 2681 | ), | ||
| 2682 | TP_fast_assign( | ||
| 2683 | __entry->ci = ci; | ||
| 2684 | __entry->block = block; | ||
| 2685 | __entry->nr = nr; | ||
| 2686 | __entry->flags = flags; | ||
| 2687 | ), | ||
| 2688 | TP_printk("%p %llu %u %d", __entry->ci, __entry->block, | ||
| 2689 | __entry->nr, __entry->flags) | ||
| 2690 | ); | ||
| 2691 | |||
| 2692 | /* End of trace events for fs/ocfs2/buffer_head_io.c. */ | ||
| 2693 | |||
| 2694 | /* Trace events for fs/ocfs2/uptodate.c. */ | ||
| 2695 | |||
| 2696 | DEFINE_OCFS2_ULL_EVENT(ocfs2_purge_copied_metadata_tree); | ||
| 2697 | |||
| 2698 | DEFINE_OCFS2_ULL_UINT_UINT_EVENT(ocfs2_metadata_cache_purge); | ||
| 2699 | |||
| 2700 | DEFINE_OCFS2_ULL_ULL_UINT_EVENT(ocfs2_buffer_cached_begin); | ||
| 2701 | |||
| 2702 | TRACE_EVENT(ocfs2_buffer_cached_end, | ||
| 2703 | TP_PROTO(int index, void *item), | ||
| 2704 | TP_ARGS(index, item), | ||
| 2705 | TP_STRUCT__entry( | ||
| 2706 | __field(int, index) | ||
| 2707 | __field(void *, item) | ||
| 2708 | ), | ||
| 2709 | TP_fast_assign( | ||
| 2710 | __entry->index = index; | ||
| 2711 | __entry->item = item; | ||
| 2712 | ), | ||
| 2713 | TP_printk("%d %p", __entry->index, __entry->item) | ||
| 2714 | ); | ||
| 2715 | |||
| 2716 | DEFINE_OCFS2_ULL_ULL_UINT_EVENT(ocfs2_append_cache_array); | ||
| 2717 | |||
| 2718 | DEFINE_OCFS2_ULL_ULL_UINT_EVENT(ocfs2_insert_cache_tree); | ||
| 2719 | |||
| 2720 | DEFINE_OCFS2_ULL_UINT_UINT_EVENT(ocfs2_expand_cache); | ||
| 2721 | |||
| 2722 | DEFINE_OCFS2_ULL_UINT_UINT_EVENT(ocfs2_set_buffer_uptodate); | ||
| 2723 | |||
| 2724 | DEFINE_OCFS2_ULL_ULL_EVENT(ocfs2_set_buffer_uptodate_begin); | ||
| 2725 | |||
| 2726 | DEFINE_OCFS2_ULL_UINT_UINT_EVENT(ocfs2_remove_metadata_array); | ||
| 2727 | |||
| 2728 | DEFINE_OCFS2_ULL_ULL_EVENT(ocfs2_remove_metadata_tree); | ||
| 2729 | |||
| 2730 | DEFINE_OCFS2_ULL_ULL_UINT_UINT_EVENT(ocfs2_remove_block_from_cache); | ||
| 2731 | |||
| 2732 | /* End of trace events for fs/ocfs2/uptodate.c. */ | ||
| 2733 | #endif /* _TRACE_OCFS2_H */ | ||
| 2734 | |||
| 2735 | /* This part must be outside protection */ | ||
| 2736 | #undef TRACE_INCLUDE_PATH | ||
| 2737 | #define TRACE_INCLUDE_PATH . | ||
| 2738 | #define TRACE_INCLUDE_FILE ocfs2_trace | ||
| 2739 | #include <trace/define_trace.h> | ||
diff --git a/fs/ocfs2/quota_global.c b/fs/ocfs2/quota_global.c index a73f6416648..279aef68025 100644 --- a/fs/ocfs2/quota_global.c +++ b/fs/ocfs2/quota_global.c | |||
| @@ -11,7 +11,6 @@ | |||
| 11 | #include <linux/writeback.h> | 11 | #include <linux/writeback.h> |
| 12 | #include <linux/workqueue.h> | 12 | #include <linux/workqueue.h> |
| 13 | 13 | ||
| 14 | #define MLOG_MASK_PREFIX ML_QUOTA | ||
| 15 | #include <cluster/masklog.h> | 14 | #include <cluster/masklog.h> |
| 16 | 15 | ||
| 17 | #include "ocfs2_fs.h" | 16 | #include "ocfs2_fs.h" |
| @@ -27,6 +26,7 @@ | |||
| 27 | #include "super.h" | 26 | #include "super.h" |
| 28 | #include "buffer_head_io.h" | 27 | #include "buffer_head_io.h" |
| 29 | #include "quota.h" | 28 | #include "quota.h" |
| 29 | #include "ocfs2_trace.h" | ||
| 30 | 30 | ||
| 31 | /* | 31 | /* |
| 32 | * Locking of quotas with OCFS2 is rather complex. Here are rules that | 32 | * Locking of quotas with OCFS2 is rather complex. Here are rules that |
| @@ -130,8 +130,7 @@ int ocfs2_validate_quota_block(struct super_block *sb, struct buffer_head *bh) | |||
| 130 | struct ocfs2_disk_dqtrailer *dqt = | 130 | struct ocfs2_disk_dqtrailer *dqt = |
| 131 | ocfs2_block_dqtrailer(sb->s_blocksize, bh->b_data); | 131 | ocfs2_block_dqtrailer(sb->s_blocksize, bh->b_data); |
| 132 | 132 | ||
| 133 | mlog(0, "Validating quota block %llu\n", | 133 | trace_ocfs2_validate_quota_block((unsigned long long)bh->b_blocknr); |
| 134 | (unsigned long long)bh->b_blocknr); | ||
| 135 | 134 | ||
| 136 | BUG_ON(!buffer_uptodate(bh)); | 135 | BUG_ON(!buffer_uptodate(bh)); |
| 137 | 136 | ||
| @@ -341,8 +340,6 @@ int ocfs2_global_read_info(struct super_block *sb, int type) | |||
| 341 | u64 pcount; | 340 | u64 pcount; |
| 342 | int status; | 341 | int status; |
| 343 | 342 | ||
| 344 | mlog_entry_void(); | ||
| 345 | |||
| 346 | /* Read global header */ | 343 | /* Read global header */ |
| 347 | gqinode = ocfs2_get_system_file_inode(OCFS2_SB(sb), ino[type], | 344 | gqinode = ocfs2_get_system_file_inode(OCFS2_SB(sb), ino[type], |
| 348 | OCFS2_INVALID_SLOT); | 345 | OCFS2_INVALID_SLOT); |
| @@ -402,7 +399,8 @@ int ocfs2_global_read_info(struct super_block *sb, int type) | |||
| 402 | msecs_to_jiffies(oinfo->dqi_syncms)); | 399 | msecs_to_jiffies(oinfo->dqi_syncms)); |
| 403 | 400 | ||
| 404 | out_err: | 401 | out_err: |
| 405 | mlog_exit(status); | 402 | if (status) |
| 403 | mlog_errno(status); | ||
| 406 | return status; | 404 | return status; |
| 407 | out_unlock: | 405 | out_unlock: |
| 408 | ocfs2_unlock_global_qf(oinfo, 0); | 406 | ocfs2_unlock_global_qf(oinfo, 0); |
| @@ -508,9 +506,10 @@ int __ocfs2_sync_dquot(struct dquot *dquot, int freeing) | |||
| 508 | olditime = dquot->dq_dqb.dqb_itime; | 506 | olditime = dquot->dq_dqb.dqb_itime; |
| 509 | oldbtime = dquot->dq_dqb.dqb_btime; | 507 | oldbtime = dquot->dq_dqb.dqb_btime; |
| 510 | ocfs2_global_disk2memdqb(dquot, &dqblk); | 508 | ocfs2_global_disk2memdqb(dquot, &dqblk); |
| 511 | mlog(0, "Syncing global dquot %u space %lld+%lld, inodes %lld+%lld\n", | 509 | trace_ocfs2_sync_dquot(dquot->dq_id, dquot->dq_dqb.dqb_curspace, |
| 512 | dquot->dq_id, dquot->dq_dqb.dqb_curspace, (long long)spacechange, | 510 | (long long)spacechange, |
| 513 | dquot->dq_dqb.dqb_curinodes, (long long)inodechange); | 511 | dquot->dq_dqb.dqb_curinodes, |
| 512 | (long long)inodechange); | ||
| 514 | if (!test_bit(DQ_LASTSET_B + QIF_SPACE_B, &dquot->dq_flags)) | 513 | if (!test_bit(DQ_LASTSET_B + QIF_SPACE_B, &dquot->dq_flags)) |
| 515 | dquot->dq_dqb.dqb_curspace += spacechange; | 514 | dquot->dq_dqb.dqb_curspace += spacechange; |
| 516 | if (!test_bit(DQ_LASTSET_B + QIF_INODES_B, &dquot->dq_flags)) | 515 | if (!test_bit(DQ_LASTSET_B + QIF_INODES_B, &dquot->dq_flags)) |
| @@ -594,8 +593,8 @@ static int ocfs2_sync_dquot_helper(struct dquot *dquot, unsigned long type) | |||
| 594 | struct ocfs2_super *osb = OCFS2_SB(sb); | 593 | struct ocfs2_super *osb = OCFS2_SB(sb); |
| 595 | int status = 0; | 594 | int status = 0; |
| 596 | 595 | ||
| 597 | mlog_entry("id=%u qtype=%u type=%lu device=%s\n", dquot->dq_id, | 596 | trace_ocfs2_sync_dquot_helper(dquot->dq_id, dquot->dq_type, |
| 598 | dquot->dq_type, type, sb->s_id); | 597 | type, sb->s_id); |
| 599 | if (type != dquot->dq_type) | 598 | if (type != dquot->dq_type) |
| 600 | goto out; | 599 | goto out; |
| 601 | status = ocfs2_lock_global_qf(oinfo, 1); | 600 | status = ocfs2_lock_global_qf(oinfo, 1); |
| @@ -621,7 +620,6 @@ static int ocfs2_sync_dquot_helper(struct dquot *dquot, unsigned long type) | |||
| 621 | out_ilock: | 620 | out_ilock: |
| 622 | ocfs2_unlock_global_qf(oinfo, 1); | 621 | ocfs2_unlock_global_qf(oinfo, 1); |
| 623 | out: | 622 | out: |
| 624 | mlog_exit(status); | ||
| 625 | return status; | 623 | return status; |
| 626 | } | 624 | } |
| 627 | 625 | ||
| @@ -647,7 +645,7 @@ static int ocfs2_write_dquot(struct dquot *dquot) | |||
| 647 | struct ocfs2_super *osb = OCFS2_SB(dquot->dq_sb); | 645 | struct ocfs2_super *osb = OCFS2_SB(dquot->dq_sb); |
| 648 | int status = 0; | 646 | int status = 0; |
| 649 | 647 | ||
| 650 | mlog_entry("id=%u, type=%d", dquot->dq_id, dquot->dq_type); | 648 | trace_ocfs2_write_dquot(dquot->dq_id, dquot->dq_type); |
| 651 | 649 | ||
| 652 | handle = ocfs2_start_trans(osb, OCFS2_QWRITE_CREDITS); | 650 | handle = ocfs2_start_trans(osb, OCFS2_QWRITE_CREDITS); |
| 653 | if (IS_ERR(handle)) { | 651 | if (IS_ERR(handle)) { |
| @@ -660,7 +658,6 @@ static int ocfs2_write_dquot(struct dquot *dquot) | |||
| 660 | mutex_unlock(&sb_dqopt(dquot->dq_sb)->dqio_mutex); | 658 | mutex_unlock(&sb_dqopt(dquot->dq_sb)->dqio_mutex); |
| 661 | ocfs2_commit_trans(osb, handle); | 659 | ocfs2_commit_trans(osb, handle); |
| 662 | out: | 660 | out: |
| 663 | mlog_exit(status); | ||
| 664 | return status; | 661 | return status; |
| 665 | } | 662 | } |
| 666 | 663 | ||
| @@ -686,7 +683,7 @@ static int ocfs2_release_dquot(struct dquot *dquot) | |||
| 686 | struct ocfs2_super *osb = OCFS2_SB(dquot->dq_sb); | 683 | struct ocfs2_super *osb = OCFS2_SB(dquot->dq_sb); |
| 687 | int status = 0; | 684 | int status = 0; |
| 688 | 685 | ||
| 689 | mlog_entry("id=%u, type=%d", dquot->dq_id, dquot->dq_type); | 686 | trace_ocfs2_release_dquot(dquot->dq_id, dquot->dq_type); |
| 690 | 687 | ||
| 691 | mutex_lock(&dquot->dq_lock); | 688 | mutex_lock(&dquot->dq_lock); |
| 692 | /* Check whether we are not racing with some other dqget() */ | 689 | /* Check whether we are not racing with some other dqget() */ |
| @@ -722,7 +719,8 @@ out_ilock: | |||
| 722 | ocfs2_unlock_global_qf(oinfo, 1); | 719 | ocfs2_unlock_global_qf(oinfo, 1); |
| 723 | out: | 720 | out: |
| 724 | mutex_unlock(&dquot->dq_lock); | 721 | mutex_unlock(&dquot->dq_lock); |
| 725 | mlog_exit(status); | 722 | if (status) |
| 723 | mlog_errno(status); | ||
| 726 | return status; | 724 | return status; |
| 727 | } | 725 | } |
| 728 | 726 | ||
| @@ -743,7 +741,7 @@ static int ocfs2_acquire_dquot(struct dquot *dquot) | |||
| 743 | int need_alloc = ocfs2_global_qinit_alloc(sb, type); | 741 | int need_alloc = ocfs2_global_qinit_alloc(sb, type); |
| 744 | handle_t *handle; | 742 | handle_t *handle; |
| 745 | 743 | ||
| 746 | mlog_entry("id=%u, type=%d", dquot->dq_id, type); | 744 | trace_ocfs2_acquire_dquot(dquot->dq_id, type); |
| 747 | mutex_lock(&dquot->dq_lock); | 745 | mutex_lock(&dquot->dq_lock); |
| 748 | /* | 746 | /* |
| 749 | * We need an exclusive lock, because we're going to update use count | 747 | * We need an exclusive lock, because we're going to update use count |
| @@ -809,7 +807,8 @@ out_dq: | |||
| 809 | set_bit(DQ_ACTIVE_B, &dquot->dq_flags); | 807 | set_bit(DQ_ACTIVE_B, &dquot->dq_flags); |
| 810 | out: | 808 | out: |
| 811 | mutex_unlock(&dquot->dq_lock); | 809 | mutex_unlock(&dquot->dq_lock); |
| 812 | mlog_exit(status); | 810 | if (status) |
| 811 | mlog_errno(status); | ||
| 813 | return status; | 812 | return status; |
| 814 | } | 813 | } |
| 815 | 814 | ||
| @@ -829,7 +828,7 @@ static int ocfs2_mark_dquot_dirty(struct dquot *dquot) | |||
| 829 | handle_t *handle; | 828 | handle_t *handle; |
| 830 | struct ocfs2_super *osb = OCFS2_SB(sb); | 829 | struct ocfs2_super *osb = OCFS2_SB(sb); |
| 831 | 830 | ||
| 832 | mlog_entry("id=%u, type=%d", dquot->dq_id, type); | 831 | trace_ocfs2_mark_dquot_dirty(dquot->dq_id, type); |
| 833 | 832 | ||
| 834 | /* In case user set some limits, sync dquot immediately to global | 833 | /* In case user set some limits, sync dquot immediately to global |
| 835 | * quota file so that information propagates quicker */ | 834 | * quota file so that information propagates quicker */ |
| @@ -866,7 +865,8 @@ out_dlock: | |||
| 866 | out_ilock: | 865 | out_ilock: |
| 867 | ocfs2_unlock_global_qf(oinfo, 1); | 866 | ocfs2_unlock_global_qf(oinfo, 1); |
| 868 | out: | 867 | out: |
| 869 | mlog_exit(status); | 868 | if (status) |
| 869 | mlog_errno(status); | ||
| 870 | return status; | 870 | return status; |
| 871 | } | 871 | } |
| 872 | 872 | ||
| @@ -877,8 +877,6 @@ static int ocfs2_write_info(struct super_block *sb, int type) | |||
| 877 | int status = 0; | 877 | int status = 0; |
| 878 | struct ocfs2_mem_dqinfo *oinfo = sb_dqinfo(sb, type)->dqi_priv; | 878 | struct ocfs2_mem_dqinfo *oinfo = sb_dqinfo(sb, type)->dqi_priv; |
| 879 | 879 | ||
| 880 | mlog_entry_void(); | ||
| 881 | |||
| 882 | status = ocfs2_lock_global_qf(oinfo, 1); | 880 | status = ocfs2_lock_global_qf(oinfo, 1); |
| 883 | if (status < 0) | 881 | if (status < 0) |
| 884 | goto out; | 882 | goto out; |
| @@ -893,7 +891,8 @@ static int ocfs2_write_info(struct super_block *sb, int type) | |||
| 893 | out_ilock: | 891 | out_ilock: |
| 894 | ocfs2_unlock_global_qf(oinfo, 1); | 892 | ocfs2_unlock_global_qf(oinfo, 1); |
| 895 | out: | 893 | out: |
| 896 | mlog_exit(status); | 894 | if (status) |
| 895 | mlog_errno(status); | ||
| 897 | return status; | 896 | return status; |
| 898 | } | 897 | } |
| 899 | 898 | ||
diff --git a/fs/ocfs2/quota_local.c b/fs/ocfs2/quota_local.c index dc78764ccc4..dc8007fc924 100644 --- a/fs/ocfs2/quota_local.c +++ b/fs/ocfs2/quota_local.c | |||
| @@ -8,7 +8,6 @@ | |||
| 8 | #include <linux/quotaops.h> | 8 | #include <linux/quotaops.h> |
| 9 | #include <linux/module.h> | 9 | #include <linux/module.h> |
| 10 | 10 | ||
| 11 | #define MLOG_MASK_PREFIX ML_QUOTA | ||
| 12 | #include <cluster/masklog.h> | 11 | #include <cluster/masklog.h> |
| 13 | 12 | ||
| 14 | #include "ocfs2_fs.h" | 13 | #include "ocfs2_fs.h" |
| @@ -23,6 +22,7 @@ | |||
| 23 | #include "quota.h" | 22 | #include "quota.h" |
| 24 | #include "uptodate.h" | 23 | #include "uptodate.h" |
| 25 | #include "super.h" | 24 | #include "super.h" |
| 25 | #include "ocfs2_trace.h" | ||
| 26 | 26 | ||
| 27 | /* Number of local quota structures per block */ | 27 | /* Number of local quota structures per block */ |
| 28 | static inline unsigned int ol_quota_entries_per_block(struct super_block *sb) | 28 | static inline unsigned int ol_quota_entries_per_block(struct super_block *sb) |
| @@ -475,7 +475,7 @@ static int ocfs2_recover_local_quota_file(struct inode *lqinode, | |||
| 475 | struct ocfs2_recovery_chunk *rchunk, *next; | 475 | struct ocfs2_recovery_chunk *rchunk, *next; |
| 476 | qsize_t spacechange, inodechange; | 476 | qsize_t spacechange, inodechange; |
| 477 | 477 | ||
| 478 | mlog_entry("ino=%lu type=%u", (unsigned long)lqinode->i_ino, type); | 478 | trace_ocfs2_recover_local_quota_file((unsigned long)lqinode->i_ino, type); |
| 479 | 479 | ||
| 480 | list_for_each_entry_safe(rchunk, next, &(rec->r_list[type]), rc_list) { | 480 | list_for_each_entry_safe(rchunk, next, &(rec->r_list[type]), rc_list) { |
| 481 | chunk = rchunk->rc_chunk; | 481 | chunk = rchunk->rc_chunk; |
| @@ -575,7 +575,8 @@ out_put_bh: | |||
| 575 | } | 575 | } |
| 576 | if (status < 0) | 576 | if (status < 0) |
| 577 | free_recovery_list(&(rec->r_list[type])); | 577 | free_recovery_list(&(rec->r_list[type])); |
| 578 | mlog_exit(status); | 578 | if (status) |
| 579 | mlog_errno(status); | ||
| 579 | return status; | 580 | return status; |
| 580 | } | 581 | } |
| 581 | 582 | ||
| @@ -600,7 +601,7 @@ int ocfs2_finish_quota_recovery(struct ocfs2_super *osb, | |||
| 600 | for (type = 0; type < MAXQUOTAS; type++) { | 601 | for (type = 0; type < MAXQUOTAS; type++) { |
| 601 | if (list_empty(&(rec->r_list[type]))) | 602 | if (list_empty(&(rec->r_list[type]))) |
| 602 | continue; | 603 | continue; |
| 603 | mlog(0, "Recovering quota in slot %d\n", slot_num); | 604 | trace_ocfs2_finish_quota_recovery(slot_num); |
| 604 | lqinode = ocfs2_get_system_file_inode(osb, ino[type], slot_num); | 605 | lqinode = ocfs2_get_system_file_inode(osb, ino[type], slot_num); |
| 605 | if (!lqinode) { | 606 | if (!lqinode) { |
| 606 | status = -ENOENT; | 607 | status = -ENOENT; |
| @@ -882,9 +883,10 @@ static void olq_set_dquot(struct buffer_head *bh, void *private) | |||
| 882 | dqblk->dqb_inodemod = cpu_to_le64(od->dq_dquot.dq_dqb.dqb_curinodes - | 883 | dqblk->dqb_inodemod = cpu_to_le64(od->dq_dquot.dq_dqb.dqb_curinodes - |
| 883 | od->dq_originodes); | 884 | od->dq_originodes); |
| 884 | spin_unlock(&dq_data_lock); | 885 | spin_unlock(&dq_data_lock); |
| 885 | mlog(0, "Writing local dquot %u space %lld inodes %lld\n", | 886 | trace_olq_set_dquot( |
| 886 | od->dq_dquot.dq_id, (long long)le64_to_cpu(dqblk->dqb_spacemod), | 887 | (unsigned long long)le64_to_cpu(dqblk->dqb_spacemod), |
| 887 | (long long)le64_to_cpu(dqblk->dqb_inodemod)); | 888 | (unsigned long long)le64_to_cpu(dqblk->dqb_inodemod), |
| 889 | od->dq_dquot.dq_id); | ||
| 888 | } | 890 | } |
| 889 | 891 | ||
| 890 | /* Write dquot to local quota file */ | 892 | /* Write dquot to local quota file */ |
diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c index c384d634872..5d32749c896 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c | |||
| @@ -16,7 +16,6 @@ | |||
| 16 | */ | 16 | */ |
| 17 | 17 | ||
| 18 | #include <linux/sort.h> | 18 | #include <linux/sort.h> |
| 19 | #define MLOG_MASK_PREFIX ML_REFCOUNT | ||
| 20 | #include <cluster/masklog.h> | 19 | #include <cluster/masklog.h> |
| 21 | #include "ocfs2.h" | 20 | #include "ocfs2.h" |
| 22 | #include "inode.h" | 21 | #include "inode.h" |
| @@ -34,6 +33,7 @@ | |||
| 34 | #include "aops.h" | 33 | #include "aops.h" |
| 35 | #include "xattr.h" | 34 | #include "xattr.h" |
| 36 | #include "namei.h" | 35 | #include "namei.h" |
| 36 | #include "ocfs2_trace.h" | ||
| 37 | 37 | ||
| 38 | #include <linux/bio.h> | 38 | #include <linux/bio.h> |
| 39 | #include <linux/blkdev.h> | 39 | #include <linux/blkdev.h> |
| @@ -84,8 +84,7 @@ static int ocfs2_validate_refcount_block(struct super_block *sb, | |||
| 84 | struct ocfs2_refcount_block *rb = | 84 | struct ocfs2_refcount_block *rb = |
| 85 | (struct ocfs2_refcount_block *)bh->b_data; | 85 | (struct ocfs2_refcount_block *)bh->b_data; |
| 86 | 86 | ||
| 87 | mlog(0, "Validating refcount block %llu\n", | 87 | trace_ocfs2_validate_refcount_block((unsigned long long)bh->b_blocknr); |
| 88 | (unsigned long long)bh->b_blocknr); | ||
| 89 | 88 | ||
| 90 | BUG_ON(!buffer_uptodate(bh)); | 89 | BUG_ON(!buffer_uptodate(bh)); |
| 91 | 90 | ||
| @@ -545,8 +544,8 @@ void ocfs2_purge_refcount_trees(struct ocfs2_super *osb) | |||
| 545 | while ((node = rb_last(root)) != NULL) { | 544 | while ((node = rb_last(root)) != NULL) { |
| 546 | tree = rb_entry(node, struct ocfs2_refcount_tree, rf_node); | 545 | tree = rb_entry(node, struct ocfs2_refcount_tree, rf_node); |
| 547 | 546 | ||
| 548 | mlog(0, "Purge tree %llu\n", | 547 | trace_ocfs2_purge_refcount_trees( |
| 549 | (unsigned long long) tree->rf_blkno); | 548 | (unsigned long long) tree->rf_blkno); |
| 550 | 549 | ||
| 551 | rb_erase(&tree->rf_node, root); | 550 | rb_erase(&tree->rf_node, root); |
| 552 | ocfs2_free_refcount_tree(tree); | 551 | ocfs2_free_refcount_tree(tree); |
| @@ -575,7 +574,8 @@ static int ocfs2_create_refcount_tree(struct inode *inode, | |||
| 575 | 574 | ||
| 576 | BUG_ON(oi->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL); | 575 | BUG_ON(oi->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL); |
| 577 | 576 | ||
| 578 | mlog(0, "create tree for inode %lu\n", inode->i_ino); | 577 | trace_ocfs2_create_refcount_tree( |
| 578 | (unsigned long long)OCFS2_I(inode)->ip_blkno); | ||
| 579 | 579 | ||
| 580 | ret = ocfs2_reserve_new_metadata_blocks(osb, 1, &meta_ac); | 580 | ret = ocfs2_reserve_new_metadata_blocks(osb, 1, &meta_ac); |
| 581 | if (ret) { | 581 | if (ret) { |
| @@ -646,8 +646,7 @@ static int ocfs2_create_refcount_tree(struct inode *inode, | |||
| 646 | di->i_refcount_loc = cpu_to_le64(first_blkno); | 646 | di->i_refcount_loc = cpu_to_le64(first_blkno); |
| 647 | spin_unlock(&oi->ip_lock); | 647 | spin_unlock(&oi->ip_lock); |
| 648 | 648 | ||
| 649 | mlog(0, "created tree for inode %lu, refblock %llu\n", | 649 | trace_ocfs2_create_refcount_tree_blkno((unsigned long long)first_blkno); |
| 650 | inode->i_ino, (unsigned long long)first_blkno); | ||
| 651 | 650 | ||
| 652 | ocfs2_journal_dirty(handle, di_bh); | 651 | ocfs2_journal_dirty(handle, di_bh); |
| 653 | 652 | ||
| @@ -1256,8 +1255,9 @@ static int ocfs2_change_refcount_rec(handle_t *handle, | |||
| 1256 | goto out; | 1255 | goto out; |
| 1257 | } | 1256 | } |
| 1258 | 1257 | ||
| 1259 | mlog(0, "change index %d, old count %u, change %d\n", index, | 1258 | trace_ocfs2_change_refcount_rec( |
| 1260 | le32_to_cpu(rec->r_refcount), change); | 1259 | (unsigned long long)ocfs2_metadata_cache_owner(ci), |
| 1260 | index, le32_to_cpu(rec->r_refcount), change); | ||
| 1261 | le32_add_cpu(&rec->r_refcount, change); | 1261 | le32_add_cpu(&rec->r_refcount, change); |
| 1262 | 1262 | ||
| 1263 | if (!rec->r_refcount) { | 1263 | if (!rec->r_refcount) { |
| @@ -1353,8 +1353,8 @@ static int ocfs2_expand_inline_ref_root(handle_t *handle, | |||
| 1353 | 1353 | ||
| 1354 | ocfs2_journal_dirty(handle, ref_root_bh); | 1354 | ocfs2_journal_dirty(handle, ref_root_bh); |
| 1355 | 1355 | ||
| 1356 | mlog(0, "new leaf block %llu, used %u\n", (unsigned long long)blkno, | 1356 | trace_ocfs2_expand_inline_ref_root((unsigned long long)blkno, |
| 1357 | le16_to_cpu(new_rb->rf_records.rl_used)); | 1357 | le16_to_cpu(new_rb->rf_records.rl_used)); |
| 1358 | 1358 | ||
| 1359 | *ref_leaf_bh = new_bh; | 1359 | *ref_leaf_bh = new_bh; |
| 1360 | new_bh = NULL; | 1360 | new_bh = NULL; |
| @@ -1466,9 +1466,9 @@ static int ocfs2_divide_leaf_refcount_block(struct buffer_head *ref_leaf_bh, | |||
| 1466 | (struct ocfs2_refcount_block *)new_bh->b_data; | 1466 | (struct ocfs2_refcount_block *)new_bh->b_data; |
| 1467 | struct ocfs2_refcount_list *new_rl = &new_rb->rf_records; | 1467 | struct ocfs2_refcount_list *new_rl = &new_rb->rf_records; |
| 1468 | 1468 | ||
| 1469 | mlog(0, "split old leaf refcount block %llu, count = %u, used = %u\n", | 1469 | trace_ocfs2_divide_leaf_refcount_block( |
| 1470 | (unsigned long long)ref_leaf_bh->b_blocknr, | 1470 | (unsigned long long)ref_leaf_bh->b_blocknr, |
| 1471 | le32_to_cpu(rl->rl_count), le32_to_cpu(rl->rl_used)); | 1471 | le32_to_cpu(rl->rl_count), le32_to_cpu(rl->rl_used)); |
| 1472 | 1472 | ||
| 1473 | /* | 1473 | /* |
| 1474 | * XXX: Improvement later. | 1474 | * XXX: Improvement later. |
| @@ -1601,8 +1601,8 @@ static int ocfs2_new_leaf_refcount_block(handle_t *handle, | |||
| 1601 | 1601 | ||
| 1602 | ocfs2_init_refcount_extent_tree(&ref_et, ci, ref_root_bh); | 1602 | ocfs2_init_refcount_extent_tree(&ref_et, ci, ref_root_bh); |
| 1603 | 1603 | ||
| 1604 | mlog(0, "insert new leaf block %llu at %u\n", | 1604 | trace_ocfs2_new_leaf_refcount_block( |
| 1605 | (unsigned long long)new_bh->b_blocknr, new_cpos); | 1605 | (unsigned long long)new_bh->b_blocknr, new_cpos); |
| 1606 | 1606 | ||
| 1607 | /* Insert the new leaf block with the specific offset cpos. */ | 1607 | /* Insert the new leaf block with the specific offset cpos. */ |
| 1608 | ret = ocfs2_insert_extent(handle, &ref_et, new_cpos, new_bh->b_blocknr, | 1608 | ret = ocfs2_insert_extent(handle, &ref_et, new_cpos, new_bh->b_blocknr, |
| @@ -1794,11 +1794,10 @@ static int ocfs2_insert_refcount_rec(handle_t *handle, | |||
| 1794 | (le16_to_cpu(rf_list->rl_used) - index) * | 1794 | (le16_to_cpu(rf_list->rl_used) - index) * |
| 1795 | sizeof(struct ocfs2_refcount_rec)); | 1795 | sizeof(struct ocfs2_refcount_rec)); |
| 1796 | 1796 | ||
| 1797 | mlog(0, "insert refcount record start %llu, len %u, count %u " | 1797 | trace_ocfs2_insert_refcount_rec( |
| 1798 | "to leaf block %llu at index %d\n", | 1798 | (unsigned long long)ref_leaf_bh->b_blocknr, index, |
| 1799 | (unsigned long long)le64_to_cpu(rec->r_cpos), | 1799 | (unsigned long long)le64_to_cpu(rec->r_cpos), |
| 1800 | le32_to_cpu(rec->r_clusters), le32_to_cpu(rec->r_refcount), | 1800 | le32_to_cpu(rec->r_clusters), le32_to_cpu(rec->r_refcount)); |
| 1801 | (unsigned long long)ref_leaf_bh->b_blocknr, index); | ||
| 1802 | 1801 | ||
| 1803 | rf_list->rl_recs[index] = *rec; | 1802 | rf_list->rl_recs[index] = *rec; |
| 1804 | 1803 | ||
| @@ -1850,10 +1849,12 @@ static int ocfs2_split_refcount_rec(handle_t *handle, | |||
| 1850 | 1849 | ||
| 1851 | BUG_ON(le32_to_cpu(rb->rf_flags) & OCFS2_REFCOUNT_TREE_FL); | 1850 | BUG_ON(le32_to_cpu(rb->rf_flags) & OCFS2_REFCOUNT_TREE_FL); |
| 1852 | 1851 | ||
| 1853 | mlog(0, "original r_pos %llu, cluster %u, split %llu, cluster %u\n", | 1852 | trace_ocfs2_split_refcount_rec(le64_to_cpu(orig_rec->r_cpos), |
| 1854 | le64_to_cpu(orig_rec->r_cpos), le32_to_cpu(orig_rec->r_clusters), | 1853 | le32_to_cpu(orig_rec->r_clusters), |
| 1855 | le64_to_cpu(split_rec->r_cpos), | 1854 | le32_to_cpu(orig_rec->r_refcount), |
| 1856 | le32_to_cpu(split_rec->r_clusters)); | 1855 | le64_to_cpu(split_rec->r_cpos), |
| 1856 | le32_to_cpu(split_rec->r_clusters), | ||
| 1857 | le32_to_cpu(split_rec->r_refcount)); | ||
| 1857 | 1858 | ||
| 1858 | /* | 1859 | /* |
| 1859 | * If we just need to split the header or tail clusters, | 1860 | * If we just need to split the header or tail clusters, |
| @@ -1967,12 +1968,11 @@ static int ocfs2_split_refcount_rec(handle_t *handle, | |||
| 1967 | 1968 | ||
| 1968 | if (split_rec->r_refcount) { | 1969 | if (split_rec->r_refcount) { |
| 1969 | rf_list->rl_recs[index] = *split_rec; | 1970 | rf_list->rl_recs[index] = *split_rec; |
| 1970 | mlog(0, "insert refcount record start %llu, len %u, count %u " | 1971 | trace_ocfs2_split_refcount_rec_insert( |
| 1971 | "to leaf block %llu at index %d\n", | 1972 | (unsigned long long)ref_leaf_bh->b_blocknr, index, |
| 1972 | (unsigned long long)le64_to_cpu(split_rec->r_cpos), | 1973 | (unsigned long long)le64_to_cpu(split_rec->r_cpos), |
| 1973 | le32_to_cpu(split_rec->r_clusters), | 1974 | le32_to_cpu(split_rec->r_clusters), |
| 1974 | le32_to_cpu(split_rec->r_refcount), | 1975 | le32_to_cpu(split_rec->r_refcount)); |
| 1975 | (unsigned long long)ref_leaf_bh->b_blocknr, index); | ||
| 1976 | 1976 | ||
| 1977 | if (merge) | 1977 | if (merge) |
| 1978 | ocfs2_refcount_rec_merge(rb, index); | 1978 | ocfs2_refcount_rec_merge(rb, index); |
| @@ -1997,7 +1997,7 @@ static int __ocfs2_increase_refcount(handle_t *handle, | |||
| 1997 | struct ocfs2_refcount_rec rec; | 1997 | struct ocfs2_refcount_rec rec; |
| 1998 | unsigned int set_len = 0; | 1998 | unsigned int set_len = 0; |
| 1999 | 1999 | ||
| 2000 | mlog(0, "Tree owner %llu, add refcount start %llu, len %u\n", | 2000 | trace_ocfs2_increase_refcount_begin( |
| 2001 | (unsigned long long)ocfs2_metadata_cache_owner(ci), | 2001 | (unsigned long long)ocfs2_metadata_cache_owner(ci), |
| 2002 | (unsigned long long)cpos, len); | 2002 | (unsigned long long)cpos, len); |
| 2003 | 2003 | ||
| @@ -2024,9 +2024,9 @@ static int __ocfs2_increase_refcount(handle_t *handle, | |||
| 2024 | */ | 2024 | */ |
| 2025 | if (rec.r_refcount && le64_to_cpu(rec.r_cpos) == cpos && | 2025 | if (rec.r_refcount && le64_to_cpu(rec.r_cpos) == cpos && |
| 2026 | set_len <= len) { | 2026 | set_len <= len) { |
| 2027 | mlog(0, "increase refcount rec, start %llu, len %u, " | 2027 | trace_ocfs2_increase_refcount_change( |
| 2028 | "count %u\n", (unsigned long long)cpos, set_len, | 2028 | (unsigned long long)cpos, set_len, |
| 2029 | le32_to_cpu(rec.r_refcount)); | 2029 | le32_to_cpu(rec.r_refcount)); |
| 2030 | ret = ocfs2_change_refcount_rec(handle, ci, | 2030 | ret = ocfs2_change_refcount_rec(handle, ci, |
| 2031 | ref_leaf_bh, index, | 2031 | ref_leaf_bh, index, |
| 2032 | merge, 1); | 2032 | merge, 1); |
| @@ -2037,7 +2037,7 @@ static int __ocfs2_increase_refcount(handle_t *handle, | |||
| 2037 | } else if (!rec.r_refcount) { | 2037 | } else if (!rec.r_refcount) { |
| 2038 | rec.r_refcount = cpu_to_le32(1); | 2038 | rec.r_refcount = cpu_to_le32(1); |
| 2039 | 2039 | ||
| 2040 | mlog(0, "insert refcount rec, start %llu, len %u\n", | 2040 | trace_ocfs2_increase_refcount_insert( |
| 2041 | (unsigned long long)le64_to_cpu(rec.r_cpos), | 2041 | (unsigned long long)le64_to_cpu(rec.r_cpos), |
| 2042 | set_len); | 2042 | set_len); |
| 2043 | ret = ocfs2_insert_refcount_rec(handle, ci, ref_root_bh, | 2043 | ret = ocfs2_insert_refcount_rec(handle, ci, ref_root_bh, |
| @@ -2055,8 +2055,7 @@ static int __ocfs2_increase_refcount(handle_t *handle, | |||
| 2055 | rec.r_clusters = cpu_to_le32(set_len); | 2055 | rec.r_clusters = cpu_to_le32(set_len); |
| 2056 | le32_add_cpu(&rec.r_refcount, 1); | 2056 | le32_add_cpu(&rec.r_refcount, 1); |
| 2057 | 2057 | ||
| 2058 | mlog(0, "split refcount rec, start %llu, " | 2058 | trace_ocfs2_increase_refcount_split( |
| 2059 | "len %u, count %u\n", | ||
| 2060 | (unsigned long long)le64_to_cpu(rec.r_cpos), | 2059 | (unsigned long long)le64_to_cpu(rec.r_cpos), |
| 2061 | set_len, le32_to_cpu(rec.r_refcount)); | 2060 | set_len, le32_to_cpu(rec.r_refcount)); |
| 2062 | ret = ocfs2_split_refcount_rec(handle, ci, | 2061 | ret = ocfs2_split_refcount_rec(handle, ci, |
| @@ -2095,6 +2094,11 @@ static int ocfs2_remove_refcount_extent(handle_t *handle, | |||
| 2095 | 2094 | ||
| 2096 | BUG_ON(rb->rf_records.rl_used); | 2095 | BUG_ON(rb->rf_records.rl_used); |
| 2097 | 2096 | ||
| 2097 | trace_ocfs2_remove_refcount_extent( | ||
| 2098 | (unsigned long long)ocfs2_metadata_cache_owner(ci), | ||
| 2099 | (unsigned long long)ref_leaf_bh->b_blocknr, | ||
| 2100 | le32_to_cpu(rb->rf_cpos)); | ||
| 2101 | |||
| 2098 | ocfs2_init_refcount_extent_tree(&et, ci, ref_root_bh); | 2102 | ocfs2_init_refcount_extent_tree(&et, ci, ref_root_bh); |
| 2099 | ret = ocfs2_remove_extent(handle, &et, le32_to_cpu(rb->rf_cpos), | 2103 | ret = ocfs2_remove_extent(handle, &et, le32_to_cpu(rb->rf_cpos), |
| 2100 | 1, meta_ac, dealloc); | 2104 | 1, meta_ac, dealloc); |
| @@ -2137,7 +2141,7 @@ static int ocfs2_remove_refcount_extent(handle_t *handle, | |||
| 2137 | if (!rb->rf_list.l_next_free_rec) { | 2141 | if (!rb->rf_list.l_next_free_rec) { |
| 2138 | BUG_ON(rb->rf_clusters); | 2142 | BUG_ON(rb->rf_clusters); |
| 2139 | 2143 | ||
| 2140 | mlog(0, "reset refcount tree root %llu to be a record block.\n", | 2144 | trace_ocfs2_restore_refcount_block( |
| 2141 | (unsigned long long)ref_root_bh->b_blocknr); | 2145 | (unsigned long long)ref_root_bh->b_blocknr); |
| 2142 | 2146 | ||
| 2143 | rb->rf_flags = 0; | 2147 | rb->rf_flags = 0; |
| @@ -2184,6 +2188,10 @@ static int ocfs2_decrease_refcount_rec(handle_t *handle, | |||
| 2184 | BUG_ON(cpos + len > | 2188 | BUG_ON(cpos + len > |
| 2185 | le64_to_cpu(rec->r_cpos) + le32_to_cpu(rec->r_clusters)); | 2189 | le64_to_cpu(rec->r_cpos) + le32_to_cpu(rec->r_clusters)); |
| 2186 | 2190 | ||
| 2191 | trace_ocfs2_decrease_refcount_rec( | ||
| 2192 | (unsigned long long)ocfs2_metadata_cache_owner(ci), | ||
| 2193 | (unsigned long long)cpos, len); | ||
| 2194 | |||
| 2187 | if (cpos == le64_to_cpu(rec->r_cpos) && | 2195 | if (cpos == le64_to_cpu(rec->r_cpos) && |
| 2188 | len == le32_to_cpu(rec->r_clusters)) | 2196 | len == le32_to_cpu(rec->r_clusters)) |
| 2189 | ret = ocfs2_change_refcount_rec(handle, ci, | 2197 | ret = ocfs2_change_refcount_rec(handle, ci, |
| @@ -2195,12 +2203,6 @@ static int ocfs2_decrease_refcount_rec(handle_t *handle, | |||
| 2195 | 2203 | ||
| 2196 | le32_add_cpu(&split.r_refcount, -1); | 2204 | le32_add_cpu(&split.r_refcount, -1); |
| 2197 | 2205 | ||
| 2198 | mlog(0, "split refcount rec, start %llu, " | ||
| 2199 | "len %u, count %u, original start %llu, len %u\n", | ||
| 2200 | (unsigned long long)le64_to_cpu(split.r_cpos), | ||
| 2201 | len, le32_to_cpu(split.r_refcount), | ||
| 2202 | (unsigned long long)le64_to_cpu(rec->r_cpos), | ||
| 2203 | le32_to_cpu(rec->r_clusters)); | ||
| 2204 | ret = ocfs2_split_refcount_rec(handle, ci, | 2206 | ret = ocfs2_split_refcount_rec(handle, ci, |
| 2205 | ref_root_bh, ref_leaf_bh, | 2207 | ref_root_bh, ref_leaf_bh, |
| 2206 | &split, index, 1, | 2208 | &split, index, 1, |
| @@ -2239,10 +2241,9 @@ static int __ocfs2_decrease_refcount(handle_t *handle, | |||
| 2239 | struct super_block *sb = ocfs2_metadata_cache_get_super(ci); | 2241 | struct super_block *sb = ocfs2_metadata_cache_get_super(ci); |
| 2240 | struct buffer_head *ref_leaf_bh = NULL; | 2242 | struct buffer_head *ref_leaf_bh = NULL; |
| 2241 | 2243 | ||
| 2242 | mlog(0, "Tree owner %llu, decrease refcount start %llu, " | 2244 | trace_ocfs2_decrease_refcount( |
| 2243 | "len %u, delete %u\n", | 2245 | (unsigned long long)ocfs2_metadata_cache_owner(ci), |
| 2244 | (unsigned long long)ocfs2_metadata_cache_owner(ci), | 2246 | (unsigned long long)cpos, len, delete); |
| 2245 | (unsigned long long)cpos, len, delete); | ||
| 2246 | 2247 | ||
| 2247 | while (len) { | 2248 | while (len) { |
| 2248 | ret = ocfs2_get_refcount_rec(ci, ref_root_bh, | 2249 | ret = ocfs2_get_refcount_rec(ci, ref_root_bh, |
| @@ -2352,8 +2353,8 @@ static int ocfs2_mark_extent_refcounted(struct inode *inode, | |||
| 2352 | { | 2353 | { |
| 2353 | int ret; | 2354 | int ret; |
| 2354 | 2355 | ||
| 2355 | mlog(0, "Inode %lu refcount tree cpos %u, len %u, phys cluster %u\n", | 2356 | trace_ocfs2_mark_extent_refcounted(OCFS2_I(inode)->ip_blkno, |
| 2356 | inode->i_ino, cpos, len, phys); | 2357 | cpos, len, phys); |
| 2357 | 2358 | ||
| 2358 | if (!ocfs2_refcount_tree(OCFS2_SB(inode->i_sb))) { | 2359 | if (!ocfs2_refcount_tree(OCFS2_SB(inode->i_sb))) { |
| 2359 | ocfs2_error(inode->i_sb, "Inode %lu want to use refcount " | 2360 | ocfs2_error(inode->i_sb, "Inode %lu want to use refcount " |
| @@ -2392,8 +2393,6 @@ static int ocfs2_calc_refcount_meta_credits(struct super_block *sb, | |||
| 2392 | struct buffer_head *ref_leaf_bh = NULL, *prev_bh = NULL; | 2393 | struct buffer_head *ref_leaf_bh = NULL, *prev_bh = NULL; |
| 2393 | u32 len; | 2394 | u32 len; |
| 2394 | 2395 | ||
| 2395 | mlog(0, "start_cpos %llu, clusters %u\n", | ||
| 2396 | (unsigned long long)start_cpos, clusters); | ||
| 2397 | while (clusters) { | 2396 | while (clusters) { |
| 2398 | ret = ocfs2_get_refcount_rec(ci, ref_root_bh, | 2397 | ret = ocfs2_get_refcount_rec(ci, ref_root_bh, |
| 2399 | cpos, clusters, &rec, | 2398 | cpos, clusters, &rec, |
| @@ -2427,12 +2426,11 @@ static int ocfs2_calc_refcount_meta_credits(struct super_block *sb, | |||
| 2427 | 2426 | ||
| 2428 | rb = (struct ocfs2_refcount_block *)ref_leaf_bh->b_data; | 2427 | rb = (struct ocfs2_refcount_block *)ref_leaf_bh->b_data; |
| 2429 | 2428 | ||
| 2430 | mlog(0, "recs_add %d,cpos %llu, clusters %u, rec->r_cpos %llu," | 2429 | trace_ocfs2_calc_refcount_meta_credits_iterate( |
| 2431 | "rec->r_clusters %u, rec->r_refcount %u, index %d\n", | 2430 | recs_add, (unsigned long long)cpos, clusters, |
| 2432 | recs_add, (unsigned long long)cpos, clusters, | 2431 | (unsigned long long)le64_to_cpu(rec.r_cpos), |
| 2433 | (unsigned long long)le64_to_cpu(rec.r_cpos), | 2432 | le32_to_cpu(rec.r_clusters), |
| 2434 | le32_to_cpu(rec.r_clusters), | 2433 | le32_to_cpu(rec.r_refcount), index); |
| 2435 | le32_to_cpu(rec.r_refcount), index); | ||
| 2436 | 2434 | ||
| 2437 | len = min((u64)cpos + clusters, le64_to_cpu(rec.r_cpos) + | 2435 | len = min((u64)cpos + clusters, le64_to_cpu(rec.r_cpos) + |
| 2438 | le32_to_cpu(rec.r_clusters)) - cpos; | 2436 | le32_to_cpu(rec.r_clusters)) - cpos; |
| @@ -2488,7 +2486,6 @@ static int ocfs2_calc_refcount_meta_credits(struct super_block *sb, | |||
| 2488 | if (!ref_blocks) | 2486 | if (!ref_blocks) |
| 2489 | goto out; | 2487 | goto out; |
| 2490 | 2488 | ||
| 2491 | mlog(0, "we need ref_blocks %d\n", ref_blocks); | ||
| 2492 | *meta_add += ref_blocks; | 2489 | *meta_add += ref_blocks; |
| 2493 | *credits += ref_blocks; | 2490 | *credits += ref_blocks; |
| 2494 | 2491 | ||
| @@ -2514,6 +2511,10 @@ static int ocfs2_calc_refcount_meta_credits(struct super_block *sb, | |||
| 2514 | } | 2511 | } |
| 2515 | 2512 | ||
| 2516 | out: | 2513 | out: |
| 2514 | |||
| 2515 | trace_ocfs2_calc_refcount_meta_credits( | ||
| 2516 | (unsigned long long)start_cpos, clusters, | ||
| 2517 | *meta_add, *credits); | ||
| 2517 | brelse(ref_leaf_bh); | 2518 | brelse(ref_leaf_bh); |
| 2518 | brelse(prev_bh); | 2519 | brelse(prev_bh); |
| 2519 | return ret; | 2520 | return ret; |
| @@ -2578,8 +2579,7 @@ int ocfs2_prepare_refcount_change_for_del(struct inode *inode, | |||
| 2578 | goto out; | 2579 | goto out; |
| 2579 | } | 2580 | } |
| 2580 | 2581 | ||
| 2581 | mlog(0, "reserve new metadata %d blocks, credits = %d\n", | 2582 | trace_ocfs2_prepare_refcount_change_for_del(*ref_blocks, *credits); |
| 2582 | *ref_blocks, *credits); | ||
| 2583 | 2583 | ||
| 2584 | out: | 2584 | out: |
| 2585 | brelse(ref_root_bh); | 2585 | brelse(ref_root_bh); |
| @@ -2886,8 +2886,7 @@ static int ocfs2_lock_refcount_allocators(struct super_block *sb, | |||
| 2886 | goto out; | 2886 | goto out; |
| 2887 | } | 2887 | } |
| 2888 | 2888 | ||
| 2889 | mlog(0, "reserve new metadata %d, clusters %u, credits = %d\n", | 2889 | trace_ocfs2_lock_refcount_allocators(meta_add, *credits); |
| 2890 | meta_add, num_clusters, *credits); | ||
| 2891 | ret = ocfs2_reserve_new_metadata_blocks(OCFS2_SB(sb), meta_add, | 2890 | ret = ocfs2_reserve_new_metadata_blocks(OCFS2_SB(sb), meta_add, |
| 2892 | meta_ac); | 2891 | meta_ac); |
| 2893 | if (ret) { | 2892 | if (ret) { |
| @@ -2937,8 +2936,8 @@ static int ocfs2_duplicate_clusters_by_page(handle_t *handle, | |||
| 2937 | loff_t offset, end, map_end; | 2936 | loff_t offset, end, map_end; |
| 2938 | struct address_space *mapping = context->inode->i_mapping; | 2937 | struct address_space *mapping = context->inode->i_mapping; |
| 2939 | 2938 | ||
| 2940 | mlog(0, "old_cluster %u, new %u, len %u at offset %u\n", old_cluster, | 2939 | trace_ocfs2_duplicate_clusters_by_page(cpos, old_cluster, |
| 2941 | new_cluster, new_len, cpos); | 2940 | new_cluster, new_len); |
| 2942 | 2941 | ||
| 2943 | readahead_pages = | 2942 | readahead_pages = |
| 2944 | (ocfs2_cow_contig_clusters(sb) << | 2943 | (ocfs2_cow_contig_clusters(sb) << |
| @@ -3031,8 +3030,8 @@ static int ocfs2_duplicate_clusters_by_jbd(handle_t *handle, | |||
| 3031 | struct buffer_head *old_bh = NULL; | 3030 | struct buffer_head *old_bh = NULL; |
| 3032 | struct buffer_head *new_bh = NULL; | 3031 | struct buffer_head *new_bh = NULL; |
| 3033 | 3032 | ||
| 3034 | mlog(0, "old_cluster %u, new %u, len %u\n", old_cluster, | 3033 | trace_ocfs2_duplicate_clusters_by_page(cpos, old_cluster, |
| 3035 | new_cluster, new_len); | 3034 | new_cluster, new_len); |
| 3036 | 3035 | ||
| 3037 | for (i = 0; i < blocks; i++, old_block++, new_block++) { | 3036 | for (i = 0; i < blocks; i++, old_block++, new_block++) { |
| 3038 | new_bh = sb_getblk(osb->sb, new_block); | 3037 | new_bh = sb_getblk(osb->sb, new_block); |
| @@ -3085,8 +3084,8 @@ static int ocfs2_clear_ext_refcount(handle_t *handle, | |||
| 3085 | struct super_block *sb = ocfs2_metadata_cache_get_super(et->et_ci); | 3084 | struct super_block *sb = ocfs2_metadata_cache_get_super(et->et_ci); |
| 3086 | u64 ino = ocfs2_metadata_cache_owner(et->et_ci); | 3085 | u64 ino = ocfs2_metadata_cache_owner(et->et_ci); |
| 3087 | 3086 | ||
| 3088 | mlog(0, "inode %llu cpos %u, len %u, p_cluster %u, ext_flags %u\n", | 3087 | trace_ocfs2_clear_ext_refcount((unsigned long long)ino, |
| 3089 | (unsigned long long)ino, cpos, len, p_cluster, ext_flags); | 3088 | cpos, len, p_cluster, ext_flags); |
| 3090 | 3089 | ||
| 3091 | memset(&replace_rec, 0, sizeof(replace_rec)); | 3090 | memset(&replace_rec, 0, sizeof(replace_rec)); |
| 3092 | replace_rec.e_cpos = cpu_to_le32(cpos); | 3091 | replace_rec.e_cpos = cpu_to_le32(cpos); |
| @@ -3141,8 +3140,8 @@ static int ocfs2_replace_clusters(handle_t *handle, | |||
| 3141 | struct ocfs2_caching_info *ci = context->data_et.et_ci; | 3140 | struct ocfs2_caching_info *ci = context->data_et.et_ci; |
| 3142 | u64 ino = ocfs2_metadata_cache_owner(ci); | 3141 | u64 ino = ocfs2_metadata_cache_owner(ci); |
| 3143 | 3142 | ||
| 3144 | mlog(0, "inode %llu, cpos %u, old %u, new %u, len %u, ext_flags %u\n", | 3143 | trace_ocfs2_replace_clusters((unsigned long long)ino, |
| 3145 | (unsigned long long)ino, cpos, old, new, len, ext_flags); | 3144 | cpos, old, new, len, ext_flags); |
| 3146 | 3145 | ||
| 3147 | /*If the old clusters is unwritten, no need to duplicate. */ | 3146 | /*If the old clusters is unwritten, no need to duplicate. */ |
| 3148 | if (!(ext_flags & OCFS2_EXT_UNWRITTEN)) { | 3147 | if (!(ext_flags & OCFS2_EXT_UNWRITTEN)) { |
| @@ -3236,8 +3235,8 @@ static int ocfs2_make_clusters_writable(struct super_block *sb, | |||
| 3236 | struct ocfs2_caching_info *ref_ci = &context->ref_tree->rf_ci; | 3235 | struct ocfs2_caching_info *ref_ci = &context->ref_tree->rf_ci; |
| 3237 | struct ocfs2_refcount_rec rec; | 3236 | struct ocfs2_refcount_rec rec; |
| 3238 | 3237 | ||
| 3239 | mlog(0, "cpos %u, p_cluster %u, num_clusters %u, e_flags %u\n", | 3238 | trace_ocfs2_make_clusters_writable(cpos, p_cluster, |
| 3240 | cpos, p_cluster, num_clusters, e_flags); | 3239 | num_clusters, e_flags); |
| 3241 | 3240 | ||
| 3242 | ret = ocfs2_lock_refcount_allocators(sb, p_cluster, num_clusters, | 3241 | ret = ocfs2_lock_refcount_allocators(sb, p_cluster, num_clusters, |
| 3243 | &context->data_et, | 3242 | &context->data_et, |
| @@ -3475,9 +3474,9 @@ static int ocfs2_refcount_cow_hunk(struct inode *inode, | |||
| 3475 | goto out; | 3474 | goto out; |
| 3476 | } | 3475 | } |
| 3477 | 3476 | ||
| 3478 | mlog(0, "CoW inode %lu, cpos %u, write_len %u, cow_start %u, " | 3477 | trace_ocfs2_refcount_cow_hunk(OCFS2_I(inode)->ip_blkno, |
| 3479 | "cow_len %u\n", inode->i_ino, | 3478 | cpos, write_len, max_cpos, |
| 3480 | cpos, write_len, cow_start, cow_len); | 3479 | cow_start, cow_len); |
| 3481 | 3480 | ||
| 3482 | BUG_ON(cow_len == 0); | 3481 | BUG_ON(cow_len == 0); |
| 3483 | 3482 | ||
| @@ -3756,8 +3755,7 @@ int ocfs2_add_refcount_flag(struct inode *inode, | |||
| 3756 | goto out; | 3755 | goto out; |
| 3757 | } | 3756 | } |
| 3758 | 3757 | ||
| 3759 | mlog(0, "reserve new metadata %d, credits = %d\n", | 3758 | trace_ocfs2_add_refcount_flag(ref_blocks, credits); |
| 3760 | ref_blocks, credits); | ||
| 3761 | 3759 | ||
| 3762 | if (ref_blocks) { | 3760 | if (ref_blocks) { |
| 3763 | ret = ocfs2_reserve_new_metadata_blocks(OCFS2_SB(inode->i_sb), | 3761 | ret = ocfs2_reserve_new_metadata_blocks(OCFS2_SB(inode->i_sb), |
diff --git a/fs/ocfs2/reservations.c b/fs/ocfs2/reservations.c index 3e78db361bc..41ffd36c689 100644 --- a/fs/ocfs2/reservations.c +++ b/fs/ocfs2/reservations.c | |||
| @@ -30,10 +30,10 @@ | |||
| 30 | #include <linux/bitops.h> | 30 | #include <linux/bitops.h> |
| 31 | #include <linux/list.h> | 31 | #include <linux/list.h> |
| 32 | 32 | ||
| 33 | #define MLOG_MASK_PREFIX ML_RESERVATIONS | ||
| 34 | #include <cluster/masklog.h> | 33 | #include <cluster/masklog.h> |
| 35 | 34 | ||
| 36 | #include "ocfs2.h" | 35 | #include "ocfs2.h" |
| 36 | #include "ocfs2_trace.h" | ||
| 37 | 37 | ||
| 38 | #ifdef CONFIG_OCFS2_DEBUG_FS | 38 | #ifdef CONFIG_OCFS2_DEBUG_FS |
| 39 | #define OCFS2_CHECK_RESERVATIONS | 39 | #define OCFS2_CHECK_RESERVATIONS |
| @@ -321,8 +321,7 @@ static void ocfs2_resv_insert(struct ocfs2_reservation_map *resmap, | |||
| 321 | 321 | ||
| 322 | assert_spin_locked(&resv_lock); | 322 | assert_spin_locked(&resv_lock); |
| 323 | 323 | ||
| 324 | mlog(0, "Insert reservation start: %u len: %u\n", new->r_start, | 324 | trace_ocfs2_resv_insert(new->r_start, new->r_len); |
| 325 | new->r_len); | ||
| 326 | 325 | ||
| 327 | while (*p) { | 326 | while (*p) { |
| 328 | parent = *p; | 327 | parent = *p; |
| @@ -423,8 +422,8 @@ static int ocfs2_resmap_find_free_bits(struct ocfs2_reservation_map *resmap, | |||
| 423 | unsigned int best_start, best_len = 0; | 422 | unsigned int best_start, best_len = 0; |
| 424 | int offset, start, found; | 423 | int offset, start, found; |
| 425 | 424 | ||
| 426 | mlog(0, "Find %u bits within range (%u, len %u) resmap len: %u\n", | 425 | trace_ocfs2_resmap_find_free_bits_begin(search_start, search_len, |
| 427 | wanted, search_start, search_len, resmap->m_bitmap_len); | 426 | wanted, resmap->m_bitmap_len); |
| 428 | 427 | ||
| 429 | found = best_start = best_len = 0; | 428 | found = best_start = best_len = 0; |
| 430 | 429 | ||
| @@ -463,7 +462,7 @@ static int ocfs2_resmap_find_free_bits(struct ocfs2_reservation_map *resmap, | |||
| 463 | *rlen = best_len; | 462 | *rlen = best_len; |
| 464 | *rstart = best_start; | 463 | *rstart = best_start; |
| 465 | 464 | ||
| 466 | mlog(0, "Found start: %u len: %u\n", best_start, best_len); | 465 | trace_ocfs2_resmap_find_free_bits_end(best_start, best_len); |
| 467 | 466 | ||
| 468 | return *rlen; | 467 | return *rlen; |
| 469 | } | 468 | } |
| @@ -487,9 +486,8 @@ static void __ocfs2_resv_find_window(struct ocfs2_reservation_map *resmap, | |||
| 487 | * - our window should be last in all reservations | 486 | * - our window should be last in all reservations |
| 488 | * - need to make sure we don't go past end of bitmap | 487 | * - need to make sure we don't go past end of bitmap |
| 489 | */ | 488 | */ |
| 490 | 489 | trace_ocfs2_resv_find_window_begin(resv->r_start, ocfs2_resv_end(resv), | |
| 491 | mlog(0, "resv start: %u resv end: %u goal: %u wanted: %u\n", | 490 | goal, wanted, RB_EMPTY_ROOT(root)); |
| 492 | resv->r_start, ocfs2_resv_end(resv), goal, wanted); | ||
| 493 | 491 | ||
| 494 | assert_spin_locked(&resv_lock); | 492 | assert_spin_locked(&resv_lock); |
| 495 | 493 | ||
| @@ -498,9 +496,6 @@ static void __ocfs2_resv_find_window(struct ocfs2_reservation_map *resmap, | |||
| 498 | * Easiest case - empty tree. We can just take | 496 | * Easiest case - empty tree. We can just take |
| 499 | * whatever window of free bits we want. | 497 | * whatever window of free bits we want. |
| 500 | */ | 498 | */ |
| 501 | |||
| 502 | mlog(0, "Empty root\n"); | ||
| 503 | |||
| 504 | clen = ocfs2_resmap_find_free_bits(resmap, wanted, goal, | 499 | clen = ocfs2_resmap_find_free_bits(resmap, wanted, goal, |
| 505 | resmap->m_bitmap_len - goal, | 500 | resmap->m_bitmap_len - goal, |
| 506 | &cstart, &clen); | 501 | &cstart, &clen); |
| @@ -524,8 +519,6 @@ static void __ocfs2_resv_find_window(struct ocfs2_reservation_map *resmap, | |||
| 524 | prev_resv = ocfs2_find_resv_lhs(resmap, goal); | 519 | prev_resv = ocfs2_find_resv_lhs(resmap, goal); |
| 525 | 520 | ||
| 526 | if (prev_resv == NULL) { | 521 | if (prev_resv == NULL) { |
| 527 | mlog(0, "Goal on LHS of leftmost window\n"); | ||
| 528 | |||
| 529 | /* | 522 | /* |
| 530 | * A NULL here means that the search code couldn't | 523 | * A NULL here means that the search code couldn't |
| 531 | * find a window that starts before goal. | 524 | * find a window that starts before goal. |
| @@ -570,13 +563,15 @@ static void __ocfs2_resv_find_window(struct ocfs2_reservation_map *resmap, | |||
| 570 | next_resv = NULL; | 563 | next_resv = NULL; |
| 571 | } | 564 | } |
| 572 | 565 | ||
| 566 | trace_ocfs2_resv_find_window_prev(prev_resv->r_start, | ||
| 567 | ocfs2_resv_end(prev_resv)); | ||
| 568 | |||
| 573 | prev = &prev_resv->r_node; | 569 | prev = &prev_resv->r_node; |
| 574 | 570 | ||
| 575 | /* Now we do a linear search for a window, starting at 'prev_rsv' */ | 571 | /* Now we do a linear search for a window, starting at 'prev_rsv' */ |
| 576 | while (1) { | 572 | while (1) { |
| 577 | next = rb_next(prev); | 573 | next = rb_next(prev); |
| 578 | if (next) { | 574 | if (next) { |
| 579 | mlog(0, "One more resv found in linear search\n"); | ||
| 580 | next_resv = rb_entry(next, | 575 | next_resv = rb_entry(next, |
| 581 | struct ocfs2_alloc_reservation, | 576 | struct ocfs2_alloc_reservation, |
| 582 | r_node); | 577 | r_node); |
| @@ -585,7 +580,6 @@ static void __ocfs2_resv_find_window(struct ocfs2_reservation_map *resmap, | |||
| 585 | gap_end = next_resv->r_start - 1; | 580 | gap_end = next_resv->r_start - 1; |
| 586 | gap_len = gap_end - gap_start + 1; | 581 | gap_len = gap_end - gap_start + 1; |
| 587 | } else { | 582 | } else { |
| 588 | mlog(0, "No next node\n"); | ||
| 589 | /* | 583 | /* |
| 590 | * We're at the rightmost edge of the | 584 | * We're at the rightmost edge of the |
| 591 | * tree. See if a reservation between this | 585 | * tree. See if a reservation between this |
| @@ -596,6 +590,8 @@ static void __ocfs2_resv_find_window(struct ocfs2_reservation_map *resmap, | |||
| 596 | gap_end = resmap->m_bitmap_len - 1; | 590 | gap_end = resmap->m_bitmap_len - 1; |
| 597 | } | 591 | } |
| 598 | 592 | ||
| 593 | trace_ocfs2_resv_find_window_next(next ? next_resv->r_start: -1, | ||
| 594 | next ? ocfs2_resv_end(next_resv) : -1); | ||
| 599 | /* | 595 | /* |
| 600 | * No need to check this gap if we have already found | 596 | * No need to check this gap if we have already found |
| 601 | * a larger region of free bits. | 597 | * a larger region of free bits. |
| @@ -654,8 +650,9 @@ static void ocfs2_cannibalize_resv(struct ocfs2_reservation_map *resmap, | |||
| 654 | lru_resv = list_first_entry(&resmap->m_lru, | 650 | lru_resv = list_first_entry(&resmap->m_lru, |
| 655 | struct ocfs2_alloc_reservation, r_lru); | 651 | struct ocfs2_alloc_reservation, r_lru); |
| 656 | 652 | ||
| 657 | mlog(0, "lru resv: start: %u len: %u end: %u\n", lru_resv->r_start, | 653 | trace_ocfs2_cannibalize_resv_begin(lru_resv->r_start, |
| 658 | lru_resv->r_len, ocfs2_resv_end(lru_resv)); | 654 | lru_resv->r_len, |
| 655 | ocfs2_resv_end(lru_resv)); | ||
| 659 | 656 | ||
| 660 | /* | 657 | /* |
| 661 | * Cannibalize (some or all) of the target reservation and | 658 | * Cannibalize (some or all) of the target reservation and |
| @@ -684,10 +681,9 @@ static void ocfs2_cannibalize_resv(struct ocfs2_reservation_map *resmap, | |||
| 684 | resv->r_len = shrink; | 681 | resv->r_len = shrink; |
| 685 | } | 682 | } |
| 686 | 683 | ||
| 687 | mlog(0, "Reservation now looks like: r_start: %u r_end: %u " | 684 | trace_ocfs2_cannibalize_resv_end(resv->r_start, ocfs2_resv_end(resv), |
| 688 | "r_len: %u r_last_start: %u r_last_len: %u\n", | 685 | resv->r_len, resv->r_last_start, |
| 689 | resv->r_start, ocfs2_resv_end(resv), resv->r_len, | 686 | resv->r_last_len); |
| 690 | resv->r_last_start, resv->r_last_len); | ||
| 691 | 687 | ||
| 692 | ocfs2_resv_insert(resmap, resv); | 688 | ocfs2_resv_insert(resmap, resv); |
| 693 | } | 689 | } |
| @@ -748,7 +744,6 @@ int ocfs2_resmap_resv_bits(struct ocfs2_reservation_map *resmap, | |||
| 748 | if ((resv->r_flags & OCFS2_RESV_FLAG_TMP) || wanted < *clen) | 744 | if ((resv->r_flags & OCFS2_RESV_FLAG_TMP) || wanted < *clen) |
| 749 | wanted = *clen; | 745 | wanted = *clen; |
| 750 | 746 | ||
| 751 | mlog(0, "empty reservation, find new window\n"); | ||
| 752 | /* | 747 | /* |
| 753 | * Try to get a window here. If it works, we must fall | 748 | * Try to get a window here. If it works, we must fall |
| 754 | * through and test the bitmap . This avoids some | 749 | * through and test the bitmap . This avoids some |
| @@ -757,6 +752,7 @@ int ocfs2_resmap_resv_bits(struct ocfs2_reservation_map *resmap, | |||
| 757 | * that inode. | 752 | * that inode. |
| 758 | */ | 753 | */ |
| 759 | ocfs2_resv_find_window(resmap, resv, wanted); | 754 | ocfs2_resv_find_window(resmap, resv, wanted); |
| 755 | trace_ocfs2_resmap_resv_bits(resv->r_start, resv->r_len); | ||
| 760 | } | 756 | } |
| 761 | 757 | ||
| 762 | BUG_ON(ocfs2_resv_empty(resv)); | 758 | BUG_ON(ocfs2_resv_empty(resv)); |
| @@ -813,10 +809,10 @@ void ocfs2_resmap_claimed_bits(struct ocfs2_reservation_map *resmap, | |||
| 813 | 809 | ||
| 814 | spin_lock(&resv_lock); | 810 | spin_lock(&resv_lock); |
| 815 | 811 | ||
| 816 | mlog(0, "claim bits: cstart: %u cend: %u clen: %u r_start: %u " | 812 | trace_ocfs2_resmap_claimed_bits_begin(cstart, cend, clen, resv->r_start, |
| 817 | "r_end: %u r_len: %u, r_last_start: %u r_last_len: %u\n", | 813 | ocfs2_resv_end(resv), resv->r_len, |
| 818 | cstart, cend, clen, resv->r_start, ocfs2_resv_end(resv), | 814 | resv->r_last_start, |
| 819 | resv->r_len, resv->r_last_start, resv->r_last_len); | 815 | resv->r_last_len); |
| 820 | 816 | ||
| 821 | BUG_ON(cstart < resv->r_start); | 817 | BUG_ON(cstart < resv->r_start); |
| 822 | BUG_ON(cstart > ocfs2_resv_end(resv)); | 818 | BUG_ON(cstart > ocfs2_resv_end(resv)); |
| @@ -833,10 +829,9 @@ void ocfs2_resmap_claimed_bits(struct ocfs2_reservation_map *resmap, | |||
| 833 | if (!ocfs2_resv_empty(resv)) | 829 | if (!ocfs2_resv_empty(resv)) |
| 834 | ocfs2_resv_mark_lru(resmap, resv); | 830 | ocfs2_resv_mark_lru(resmap, resv); |
| 835 | 831 | ||
| 836 | mlog(0, "Reservation now looks like: r_start: %u r_end: %u " | 832 | trace_ocfs2_resmap_claimed_bits_end(resv->r_start, ocfs2_resv_end(resv), |
| 837 | "r_len: %u r_last_start: %u r_last_len: %u\n", | 833 | resv->r_len, resv->r_last_start, |
| 838 | resv->r_start, ocfs2_resv_end(resv), resv->r_len, | 834 | resv->r_last_len); |
| 839 | resv->r_last_start, resv->r_last_len); | ||
| 840 | 835 | ||
| 841 | ocfs2_check_resmap(resmap); | 836 | ocfs2_check_resmap(resmap); |
| 842 | 837 | ||
diff --git a/fs/ocfs2/resize.c b/fs/ocfs2/resize.c index dacd553d861..ec55add7604 100644 --- a/fs/ocfs2/resize.c +++ b/fs/ocfs2/resize.c | |||
| @@ -27,7 +27,6 @@ | |||
| 27 | #include <linux/fs.h> | 27 | #include <linux/fs.h> |
| 28 | #include <linux/types.h> | 28 | #include <linux/types.h> |
| 29 | 29 | ||
| 30 | #define MLOG_MASK_PREFIX ML_DISK_ALLOC | ||
| 31 | #include <cluster/masklog.h> | 30 | #include <cluster/masklog.h> |
| 32 | 31 | ||
| 33 | #include "ocfs2.h" | 32 | #include "ocfs2.h" |
| @@ -39,6 +38,7 @@ | |||
| 39 | #include "super.h" | 38 | #include "super.h" |
| 40 | #include "sysfile.h" | 39 | #include "sysfile.h" |
| 41 | #include "uptodate.h" | 40 | #include "uptodate.h" |
| 41 | #include "ocfs2_trace.h" | ||
| 42 | 42 | ||
| 43 | #include "buffer_head_io.h" | 43 | #include "buffer_head_io.h" |
| 44 | #include "suballoc.h" | 44 | #include "suballoc.h" |
| @@ -82,7 +82,6 @@ static u16 ocfs2_calc_new_backup_super(struct inode *inode, | |||
| 82 | backups++; | 82 | backups++; |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | mlog_exit_void(); | ||
| 86 | return backups; | 85 | return backups; |
| 87 | } | 86 | } |
| 88 | 87 | ||
| @@ -103,8 +102,8 @@ static int ocfs2_update_last_group_and_inode(handle_t *handle, | |||
| 103 | u16 cl_bpc = le16_to_cpu(cl->cl_bpc); | 102 | u16 cl_bpc = le16_to_cpu(cl->cl_bpc); |
| 104 | u16 cl_cpg = le16_to_cpu(cl->cl_cpg); | 103 | u16 cl_cpg = le16_to_cpu(cl->cl_cpg); |
| 105 | 104 | ||
| 106 | mlog_entry("(new_clusters=%d, first_new_cluster = %u)\n", | 105 | trace_ocfs2_update_last_group_and_inode(new_clusters, |
| 107 | new_clusters, first_new_cluster); | 106 | first_new_cluster); |
| 108 | 107 | ||
| 109 | ret = ocfs2_journal_access_gd(handle, INODE_CACHE(bm_inode), | 108 | ret = ocfs2_journal_access_gd(handle, INODE_CACHE(bm_inode), |
| 110 | group_bh, OCFS2_JOURNAL_ACCESS_WRITE); | 109 | group_bh, OCFS2_JOURNAL_ACCESS_WRITE); |
| @@ -176,7 +175,8 @@ out_rollback: | |||
| 176 | le16_add_cpu(&group->bg_free_bits_count, -1 * num_bits); | 175 | le16_add_cpu(&group->bg_free_bits_count, -1 * num_bits); |
| 177 | } | 176 | } |
| 178 | out: | 177 | out: |
| 179 | mlog_exit(ret); | 178 | if (ret) |
| 179 | mlog_errno(ret); | ||
| 180 | return ret; | 180 | return ret; |
| 181 | } | 181 | } |
| 182 | 182 | ||
| @@ -281,8 +281,6 @@ int ocfs2_group_extend(struct inode * inode, int new_clusters) | |||
| 281 | u32 first_new_cluster; | 281 | u32 first_new_cluster; |
| 282 | u64 lgd_blkno; | 282 | u64 lgd_blkno; |
| 283 | 283 | ||
| 284 | mlog_entry_void(); | ||
| 285 | |||
| 286 | if (ocfs2_is_hard_readonly(osb) || ocfs2_is_soft_readonly(osb)) | 284 | if (ocfs2_is_hard_readonly(osb) || ocfs2_is_soft_readonly(osb)) |
| 287 | return -EROFS; | 285 | return -EROFS; |
| 288 | 286 | ||
| @@ -342,7 +340,8 @@ int ocfs2_group_extend(struct inode * inode, int new_clusters) | |||
| 342 | goto out_unlock; | 340 | goto out_unlock; |
| 343 | } | 341 | } |
| 344 | 342 | ||
| 345 | mlog(0, "extend the last group at %llu, new clusters = %d\n", | 343 | |
| 344 | trace_ocfs2_group_extend( | ||
| 346 | (unsigned long long)le64_to_cpu(group->bg_blkno), new_clusters); | 345 | (unsigned long long)le64_to_cpu(group->bg_blkno), new_clusters); |
| 347 | 346 | ||
| 348 | handle = ocfs2_start_trans(osb, OCFS2_GROUP_EXTEND_CREDITS); | 347 | handle = ocfs2_start_trans(osb, OCFS2_GROUP_EXTEND_CREDITS); |
| @@ -377,7 +376,6 @@ out_mutex: | |||
| 377 | iput(main_bm_inode); | 376 | iput(main_bm_inode); |
| 378 | 377 | ||
| 379 | out: | 378 | out: |
| 380 | mlog_exit_void(); | ||
| 381 | return ret; | 379 | return ret; |
| 382 | } | 380 | } |
| 383 | 381 | ||
| @@ -472,8 +470,6 @@ int ocfs2_group_add(struct inode *inode, struct ocfs2_new_group_input *input) | |||
| 472 | struct ocfs2_chain_rec *cr; | 470 | struct ocfs2_chain_rec *cr; |
| 473 | u16 cl_bpc; | 471 | u16 cl_bpc; |
| 474 | 472 | ||
| 475 | mlog_entry_void(); | ||
| 476 | |||
| 477 | if (ocfs2_is_hard_readonly(osb) || ocfs2_is_soft_readonly(osb)) | 473 | if (ocfs2_is_hard_readonly(osb) || ocfs2_is_soft_readonly(osb)) |
| 478 | return -EROFS; | 474 | return -EROFS; |
| 479 | 475 | ||
| @@ -520,8 +516,8 @@ int ocfs2_group_add(struct inode *inode, struct ocfs2_new_group_input *input) | |||
| 520 | goto out_unlock; | 516 | goto out_unlock; |
| 521 | } | 517 | } |
| 522 | 518 | ||
| 523 | mlog(0, "Add a new group %llu in chain = %u, length = %u\n", | 519 | trace_ocfs2_group_add((unsigned long long)input->group, |
| 524 | (unsigned long long)input->group, input->chain, input->clusters); | 520 | input->chain, input->clusters, input->frees); |
| 525 | 521 | ||
| 526 | handle = ocfs2_start_trans(osb, OCFS2_GROUP_ADD_CREDITS); | 522 | handle = ocfs2_start_trans(osb, OCFS2_GROUP_ADD_CREDITS); |
| 527 | if (IS_ERR(handle)) { | 523 | if (IS_ERR(handle)) { |
| @@ -589,6 +585,5 @@ out_mutex: | |||
| 589 | iput(main_bm_inode); | 585 | iput(main_bm_inode); |
| 590 | 586 | ||
| 591 | out: | 587 | out: |
| 592 | mlog_exit_void(); | ||
| 593 | return ret; | 588 | return ret; |
| 594 | } | 589 | } |
diff --git a/fs/ocfs2/slot_map.c b/fs/ocfs2/slot_map.c index ab4e0172cc1..26fc0014d50 100644 --- a/fs/ocfs2/slot_map.c +++ b/fs/ocfs2/slot_map.c | |||
| @@ -27,7 +27,6 @@ | |||
| 27 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
| 28 | #include <linux/highmem.h> | 28 | #include <linux/highmem.h> |
| 29 | 29 | ||
| 30 | #define MLOG_MASK_PREFIX ML_SUPER | ||
| 31 | #include <cluster/masklog.h> | 30 | #include <cluster/masklog.h> |
| 32 | 31 | ||
| 33 | #include "ocfs2.h" | 32 | #include "ocfs2.h" |
| @@ -39,6 +38,7 @@ | |||
| 39 | #include "slot_map.h" | 38 | #include "slot_map.h" |
| 40 | #include "super.h" | 39 | #include "super.h" |
| 41 | #include "sysfile.h" | 40 | #include "sysfile.h" |
| 41 | #include "ocfs2_trace.h" | ||
| 42 | 42 | ||
| 43 | #include "buffer_head_io.h" | 43 | #include "buffer_head_io.h" |
| 44 | 44 | ||
| @@ -142,8 +142,7 @@ int ocfs2_refresh_slot_info(struct ocfs2_super *osb) | |||
| 142 | BUG_ON(si->si_blocks == 0); | 142 | BUG_ON(si->si_blocks == 0); |
| 143 | BUG_ON(si->si_bh == NULL); | 143 | BUG_ON(si->si_bh == NULL); |
| 144 | 144 | ||
| 145 | mlog(0, "Refreshing slot map, reading %u block(s)\n", | 145 | trace_ocfs2_refresh_slot_info(si->si_blocks); |
| 146 | si->si_blocks); | ||
| 147 | 146 | ||
| 148 | /* | 147 | /* |
| 149 | * We pass -1 as blocknr because we expect all of si->si_bh to | 148 | * We pass -1 as blocknr because we expect all of si->si_bh to |
| @@ -381,8 +380,7 @@ static int ocfs2_map_slot_buffers(struct ocfs2_super *osb, | |||
| 381 | /* The size checks above should ensure this */ | 380 | /* The size checks above should ensure this */ |
| 382 | BUG_ON((osb->max_slots / si->si_slots_per_block) > blocks); | 381 | BUG_ON((osb->max_slots / si->si_slots_per_block) > blocks); |
| 383 | 382 | ||
| 384 | mlog(0, "Slot map needs %u buffers for %llu bytes\n", | 383 | trace_ocfs2_map_slot_buffers(bytes, si->si_blocks); |
| 385 | si->si_blocks, bytes); | ||
| 386 | 384 | ||
| 387 | si->si_bh = kzalloc(sizeof(struct buffer_head *) * si->si_blocks, | 385 | si->si_bh = kzalloc(sizeof(struct buffer_head *) * si->si_blocks, |
| 388 | GFP_KERNEL); | 386 | GFP_KERNEL); |
| @@ -400,8 +398,7 @@ static int ocfs2_map_slot_buffers(struct ocfs2_super *osb, | |||
| 400 | goto bail; | 398 | goto bail; |
| 401 | } | 399 | } |
| 402 | 400 | ||
| 403 | mlog(0, "Reading slot map block %u at %llu\n", i, | 401 | trace_ocfs2_map_slot_buffers_block((unsigned long long)blkno, i); |
| 404 | (unsigned long long)blkno); | ||
| 405 | 402 | ||
| 406 | bh = NULL; /* Acquire a fresh bh */ | 403 | bh = NULL; /* Acquire a fresh bh */ |
| 407 | status = ocfs2_read_blocks(INODE_CACHE(si->si_inode), blkno, | 404 | status = ocfs2_read_blocks(INODE_CACHE(si->si_inode), blkno, |
| @@ -475,8 +472,6 @@ int ocfs2_find_slot(struct ocfs2_super *osb) | |||
| 475 | int slot; | 472 | int slot; |
| 476 | struct ocfs2_slot_info *si; | 473 | struct ocfs2_slot_info *si; |
| 477 | 474 | ||
| 478 | mlog_entry_void(); | ||
| 479 | |||
| 480 | si = osb->slot_info; | 475 | si = osb->slot_info; |
| 481 | 476 | ||
| 482 | spin_lock(&osb->osb_lock); | 477 | spin_lock(&osb->osb_lock); |
| @@ -505,14 +500,13 @@ int ocfs2_find_slot(struct ocfs2_super *osb) | |||
| 505 | osb->slot_num = slot; | 500 | osb->slot_num = slot; |
| 506 | spin_unlock(&osb->osb_lock); | 501 | spin_unlock(&osb->osb_lock); |
| 507 | 502 | ||
| 508 | mlog(0, "taking node slot %d\n", osb->slot_num); | 503 | trace_ocfs2_find_slot(osb->slot_num); |
| 509 | 504 | ||
| 510 | status = ocfs2_update_disk_slot(osb, si, osb->slot_num); | 505 | status = ocfs2_update_disk_slot(osb, si, osb->slot_num); |
| 511 | if (status < 0) | 506 | if (status < 0) |
| 512 | mlog_errno(status); | 507 | mlog_errno(status); |
| 513 | 508 | ||
| 514 | bail: | 509 | bail: |
| 515 | mlog_exit(status); | ||
| 516 | return status; | 510 | return status; |
| 517 | } | 511 | } |
| 518 | 512 | ||
diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c index 71998d4d61d..ab6e2061074 100644 --- a/fs/ocfs2/suballoc.c +++ b/fs/ocfs2/suballoc.c | |||
| @@ -29,7 +29,6 @@ | |||
| 29 | #include <linux/slab.h> | 29 | #include <linux/slab.h> |
| 30 | #include <linux/highmem.h> | 30 | #include <linux/highmem.h> |
| 31 | 31 | ||
| 32 | #define MLOG_MASK_PREFIX ML_DISK_ALLOC | ||
| 33 | #include <cluster/masklog.h> | 32 | #include <cluster/masklog.h> |
| 34 | 33 | ||
| 35 | #include "ocfs2.h" | 34 | #include "ocfs2.h" |
| @@ -44,6 +43,7 @@ | |||
| 44 | #include "super.h" | 43 | #include "super.h" |
| 45 | #include "sysfile.h" | 44 | #include "sysfile.h" |
| 46 | #include "uptodate.h" | 45 | #include "uptodate.h" |
| 46 | #include "ocfs2_trace.h" | ||
| 47 | 47 | ||
| 48 | #include "buffer_head_io.h" | 48 | #include "buffer_head_io.h" |
| 49 | 49 | ||
| @@ -308,8 +308,8 @@ static int ocfs2_validate_group_descriptor(struct super_block *sb, | |||
| 308 | int rc; | 308 | int rc; |
| 309 | struct ocfs2_group_desc *gd = (struct ocfs2_group_desc *)bh->b_data; | 309 | struct ocfs2_group_desc *gd = (struct ocfs2_group_desc *)bh->b_data; |
| 310 | 310 | ||
| 311 | mlog(0, "Validating group descriptor %llu\n", | 311 | trace_ocfs2_validate_group_descriptor( |
| 312 | (unsigned long long)bh->b_blocknr); | 312 | (unsigned long long)bh->b_blocknr); |
| 313 | 313 | ||
| 314 | BUG_ON(!buffer_uptodate(bh)); | 314 | BUG_ON(!buffer_uptodate(bh)); |
| 315 | 315 | ||
| @@ -389,8 +389,6 @@ static int ocfs2_block_group_fill(handle_t *handle, | |||
| 389 | struct ocfs2_group_desc *bg = (struct ocfs2_group_desc *) bg_bh->b_data; | 389 | struct ocfs2_group_desc *bg = (struct ocfs2_group_desc *) bg_bh->b_data; |
| 390 | struct super_block * sb = alloc_inode->i_sb; | 390 | struct super_block * sb = alloc_inode->i_sb; |
| 391 | 391 | ||
| 392 | mlog_entry_void(); | ||
| 393 | |||
| 394 | if (((unsigned long long) bg_bh->b_blocknr) != group_blkno) { | 392 | if (((unsigned long long) bg_bh->b_blocknr) != group_blkno) { |
| 395 | ocfs2_error(alloc_inode->i_sb, "group block (%llu) != " | 393 | ocfs2_error(alloc_inode->i_sb, "group block (%llu) != " |
| 396 | "b_blocknr (%llu)", | 394 | "b_blocknr (%llu)", |
| @@ -436,7 +434,8 @@ static int ocfs2_block_group_fill(handle_t *handle, | |||
| 436 | * allocation time. */ | 434 | * allocation time. */ |
| 437 | 435 | ||
| 438 | bail: | 436 | bail: |
| 439 | mlog_exit(status); | 437 | if (status) |
| 438 | mlog_errno(status); | ||
| 440 | return status; | 439 | return status; |
| 441 | } | 440 | } |
| 442 | 441 | ||
| @@ -477,8 +476,8 @@ ocfs2_block_group_alloc_contig(struct ocfs2_super *osb, handle_t *handle, | |||
| 477 | 476 | ||
| 478 | /* setup the group */ | 477 | /* setup the group */ |
| 479 | bg_blkno = ocfs2_clusters_to_blocks(osb->sb, bit_off); | 478 | bg_blkno = ocfs2_clusters_to_blocks(osb->sb, bit_off); |
| 480 | mlog(0, "new descriptor, record %u, at block %llu\n", | 479 | trace_ocfs2_block_group_alloc_contig( |
| 481 | alloc_rec, (unsigned long long)bg_blkno); | 480 | (unsigned long long)bg_blkno, alloc_rec); |
| 482 | 481 | ||
| 483 | bg_bh = sb_getblk(osb->sb, bg_blkno); | 482 | bg_bh = sb_getblk(osb->sb, bg_blkno); |
| 484 | if (!bg_bh) { | 483 | if (!bg_bh) { |
| @@ -657,8 +656,8 @@ ocfs2_block_group_alloc_discontig(handle_t *handle, | |||
| 657 | 656 | ||
| 658 | /* setup the group */ | 657 | /* setup the group */ |
| 659 | bg_blkno = ocfs2_clusters_to_blocks(osb->sb, bit_off); | 658 | bg_blkno = ocfs2_clusters_to_blocks(osb->sb, bit_off); |
| 660 | mlog(0, "new descriptor, record %u, at block %llu\n", | 659 | trace_ocfs2_block_group_alloc_discontig( |
| 661 | alloc_rec, (unsigned long long)bg_blkno); | 660 | (unsigned long long)bg_blkno, alloc_rec); |
| 662 | 661 | ||
| 663 | bg_bh = sb_getblk(osb->sb, bg_blkno); | 662 | bg_bh = sb_getblk(osb->sb, bg_blkno); |
| 664 | if (!bg_bh) { | 663 | if (!bg_bh) { |
| @@ -707,8 +706,6 @@ static int ocfs2_block_group_alloc(struct ocfs2_super *osb, | |||
| 707 | 706 | ||
| 708 | BUG_ON(ocfs2_is_cluster_bitmap(alloc_inode)); | 707 | BUG_ON(ocfs2_is_cluster_bitmap(alloc_inode)); |
| 709 | 708 | ||
| 710 | mlog_entry_void(); | ||
| 711 | |||
| 712 | cl = &fe->id2.i_chain; | 709 | cl = &fe->id2.i_chain; |
| 713 | status = ocfs2_reserve_clusters_with_limit(osb, | 710 | status = ocfs2_reserve_clusters_with_limit(osb, |
| 714 | le16_to_cpu(cl->cl_cpg), | 711 | le16_to_cpu(cl->cl_cpg), |
| @@ -730,8 +727,8 @@ static int ocfs2_block_group_alloc(struct ocfs2_super *osb, | |||
| 730 | } | 727 | } |
| 731 | 728 | ||
| 732 | if (last_alloc_group && *last_alloc_group != 0) { | 729 | if (last_alloc_group && *last_alloc_group != 0) { |
| 733 | mlog(0, "use old allocation group %llu for block group alloc\n", | 730 | trace_ocfs2_block_group_alloc( |
| 734 | (unsigned long long)*last_alloc_group); | 731 | (unsigned long long)*last_alloc_group); |
| 735 | ac->ac_last_group = *last_alloc_group; | 732 | ac->ac_last_group = *last_alloc_group; |
| 736 | } | 733 | } |
| 737 | 734 | ||
| @@ -796,7 +793,8 @@ bail: | |||
| 796 | 793 | ||
| 797 | brelse(bg_bh); | 794 | brelse(bg_bh); |
| 798 | 795 | ||
| 799 | mlog_exit(status); | 796 | if (status) |
| 797 | mlog_errno(status); | ||
| 800 | return status; | 798 | return status; |
| 801 | } | 799 | } |
| 802 | 800 | ||
| @@ -814,8 +812,6 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb, | |||
| 814 | struct ocfs2_dinode *fe; | 812 | struct ocfs2_dinode *fe; |
| 815 | u32 free_bits; | 813 | u32 free_bits; |
| 816 | 814 | ||
| 817 | mlog_entry_void(); | ||
| 818 | |||
| 819 | alloc_inode = ocfs2_get_system_file_inode(osb, type, slot); | 815 | alloc_inode = ocfs2_get_system_file_inode(osb, type, slot); |
| 820 | if (!alloc_inode) { | 816 | if (!alloc_inode) { |
| 821 | mlog_errno(-EINVAL); | 817 | mlog_errno(-EINVAL); |
| @@ -855,16 +851,15 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb, | |||
| 855 | if (bits_wanted > free_bits) { | 851 | if (bits_wanted > free_bits) { |
| 856 | /* cluster bitmap never grows */ | 852 | /* cluster bitmap never grows */ |
| 857 | if (ocfs2_is_cluster_bitmap(alloc_inode)) { | 853 | if (ocfs2_is_cluster_bitmap(alloc_inode)) { |
| 858 | mlog(0, "Disk Full: wanted=%u, free_bits=%u\n", | 854 | trace_ocfs2_reserve_suballoc_bits_nospc(bits_wanted, |
| 859 | bits_wanted, free_bits); | 855 | free_bits); |
| 860 | status = -ENOSPC; | 856 | status = -ENOSPC; |
| 861 | goto bail; | 857 | goto bail; |
| 862 | } | 858 | } |
| 863 | 859 | ||
| 864 | if (!(flags & ALLOC_NEW_GROUP)) { | 860 | if (!(flags & ALLOC_NEW_GROUP)) { |
| 865 | mlog(0, "Alloc File %u Full: wanted=%u, free_bits=%u, " | 861 | trace_ocfs2_reserve_suballoc_bits_no_new_group( |
| 866 | "and we don't alloc a new group for it.\n", | 862 | slot, bits_wanted, free_bits); |
| 867 | slot, bits_wanted, free_bits); | ||
| 868 | status = -ENOSPC; | 863 | status = -ENOSPC; |
| 869 | goto bail; | 864 | goto bail; |
| 870 | } | 865 | } |
| @@ -890,7 +885,8 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb, | |||
| 890 | bail: | 885 | bail: |
| 891 | brelse(bh); | 886 | brelse(bh); |
| 892 | 887 | ||
| 893 | mlog_exit(status); | 888 | if (status) |
| 889 | mlog_errno(status); | ||
| 894 | return status; | 890 | return status; |
| 895 | } | 891 | } |
| 896 | 892 | ||
| @@ -1052,7 +1048,8 @@ bail: | |||
| 1052 | *ac = NULL; | 1048 | *ac = NULL; |
| 1053 | } | 1049 | } |
| 1054 | 1050 | ||
| 1055 | mlog_exit(status); | 1051 | if (status) |
| 1052 | mlog_errno(status); | ||
| 1056 | return status; | 1053 | return status; |
| 1057 | } | 1054 | } |
| 1058 | 1055 | ||
| @@ -1119,8 +1116,8 @@ int ocfs2_reserve_new_inode(struct ocfs2_super *osb, | |||
| 1119 | spin_lock(&osb->osb_lock); | 1116 | spin_lock(&osb->osb_lock); |
| 1120 | osb->osb_inode_alloc_group = alloc_group; | 1117 | osb->osb_inode_alloc_group = alloc_group; |
| 1121 | spin_unlock(&osb->osb_lock); | 1118 | spin_unlock(&osb->osb_lock); |
| 1122 | mlog(0, "after reservation, new allocation group is " | 1119 | trace_ocfs2_reserve_new_inode_new_group( |
| 1123 | "%llu\n", (unsigned long long)alloc_group); | 1120 | (unsigned long long)alloc_group); |
| 1124 | 1121 | ||
| 1125 | /* | 1122 | /* |
| 1126 | * Some inodes must be freed by us, so try to allocate | 1123 | * Some inodes must be freed by us, so try to allocate |
| @@ -1152,7 +1149,8 @@ bail: | |||
| 1152 | *ac = NULL; | 1149 | *ac = NULL; |
| 1153 | } | 1150 | } |
| 1154 | 1151 | ||
| 1155 | mlog_exit(status); | 1152 | if (status) |
| 1153 | mlog_errno(status); | ||
| 1156 | return status; | 1154 | return status; |
| 1157 | } | 1155 | } |
| 1158 | 1156 | ||
| @@ -1189,8 +1187,6 @@ static int ocfs2_reserve_clusters_with_limit(struct ocfs2_super *osb, | |||
| 1189 | { | 1187 | { |
| 1190 | int status; | 1188 | int status; |
| 1191 | 1189 | ||
| 1192 | mlog_entry_void(); | ||
| 1193 | |||
| 1194 | *ac = kzalloc(sizeof(struct ocfs2_alloc_context), GFP_KERNEL); | 1190 | *ac = kzalloc(sizeof(struct ocfs2_alloc_context), GFP_KERNEL); |
| 1195 | if (!(*ac)) { | 1191 | if (!(*ac)) { |
| 1196 | status = -ENOMEM; | 1192 | status = -ENOMEM; |
| @@ -1229,7 +1225,8 @@ bail: | |||
| 1229 | *ac = NULL; | 1225 | *ac = NULL; |
| 1230 | } | 1226 | } |
| 1231 | 1227 | ||
| 1232 | mlog_exit(status); | 1228 | if (status) |
| 1229 | mlog_errno(status); | ||
| 1233 | return status; | 1230 | return status; |
| 1234 | } | 1231 | } |
| 1235 | 1232 | ||
| @@ -1357,15 +1354,12 @@ static inline int ocfs2_block_group_set_bits(handle_t *handle, | |||
| 1357 | void *bitmap = bg->bg_bitmap; | 1354 | void *bitmap = bg->bg_bitmap; |
| 1358 | int journal_type = OCFS2_JOURNAL_ACCESS_WRITE; | 1355 | int journal_type = OCFS2_JOURNAL_ACCESS_WRITE; |
| 1359 | 1356 | ||
| 1360 | mlog_entry_void(); | ||
| 1361 | |||
| 1362 | /* All callers get the descriptor via | 1357 | /* All callers get the descriptor via |
| 1363 | * ocfs2_read_group_descriptor(). Any corruption is a code bug. */ | 1358 | * ocfs2_read_group_descriptor(). Any corruption is a code bug. */ |
| 1364 | BUG_ON(!OCFS2_IS_VALID_GROUP_DESC(bg)); | 1359 | BUG_ON(!OCFS2_IS_VALID_GROUP_DESC(bg)); |
| 1365 | BUG_ON(le16_to_cpu(bg->bg_free_bits_count) < num_bits); | 1360 | BUG_ON(le16_to_cpu(bg->bg_free_bits_count) < num_bits); |
| 1366 | 1361 | ||
| 1367 | mlog(0, "block_group_set_bits: off = %u, num = %u\n", bit_off, | 1362 | trace_ocfs2_block_group_set_bits(bit_off, num_bits); |
| 1368 | num_bits); | ||
| 1369 | 1363 | ||
| 1370 | if (ocfs2_is_cluster_bitmap(alloc_inode)) | 1364 | if (ocfs2_is_cluster_bitmap(alloc_inode)) |
| 1371 | journal_type = OCFS2_JOURNAL_ACCESS_UNDO; | 1365 | journal_type = OCFS2_JOURNAL_ACCESS_UNDO; |
| @@ -1394,7 +1388,8 @@ static inline int ocfs2_block_group_set_bits(handle_t *handle, | |||
| 1394 | ocfs2_journal_dirty(handle, group_bh); | 1388 | ocfs2_journal_dirty(handle, group_bh); |
| 1395 | 1389 | ||
| 1396 | bail: | 1390 | bail: |
| 1397 | mlog_exit(status); | 1391 | if (status) |
| 1392 | mlog_errno(status); | ||
| 1398 | return status; | 1393 | return status; |
| 1399 | } | 1394 | } |
| 1400 | 1395 | ||
| @@ -1437,10 +1432,10 @@ static int ocfs2_relink_block_group(handle_t *handle, | |||
| 1437 | BUG_ON(!OCFS2_IS_VALID_GROUP_DESC(bg)); | 1432 | BUG_ON(!OCFS2_IS_VALID_GROUP_DESC(bg)); |
| 1438 | BUG_ON(!OCFS2_IS_VALID_GROUP_DESC(prev_bg)); | 1433 | BUG_ON(!OCFS2_IS_VALID_GROUP_DESC(prev_bg)); |
| 1439 | 1434 | ||
| 1440 | mlog(0, "Suballoc %llu, chain %u, move group %llu to top, prev = %llu\n", | 1435 | trace_ocfs2_relink_block_group( |
| 1441 | (unsigned long long)le64_to_cpu(fe->i_blkno), chain, | 1436 | (unsigned long long)le64_to_cpu(fe->i_blkno), chain, |
| 1442 | (unsigned long long)le64_to_cpu(bg->bg_blkno), | 1437 | (unsigned long long)le64_to_cpu(bg->bg_blkno), |
| 1443 | (unsigned long long)le64_to_cpu(prev_bg->bg_blkno)); | 1438 | (unsigned long long)le64_to_cpu(prev_bg->bg_blkno)); |
| 1444 | 1439 | ||
| 1445 | fe_ptr = le64_to_cpu(fe->id2.i_chain.cl_recs[chain].c_blkno); | 1440 | fe_ptr = le64_to_cpu(fe->id2.i_chain.cl_recs[chain].c_blkno); |
| 1446 | bg_ptr = le64_to_cpu(bg->bg_next_group); | 1441 | bg_ptr = le64_to_cpu(bg->bg_next_group); |
| @@ -1484,7 +1479,8 @@ out_rollback: | |||
| 1484 | prev_bg->bg_next_group = cpu_to_le64(prev_bg_ptr); | 1479 | prev_bg->bg_next_group = cpu_to_le64(prev_bg_ptr); |
| 1485 | } | 1480 | } |
| 1486 | 1481 | ||
| 1487 | mlog_exit(status); | 1482 | if (status) |
| 1483 | mlog_errno(status); | ||
| 1488 | return status; | 1484 | return status; |
| 1489 | } | 1485 | } |
| 1490 | 1486 | ||
| @@ -1525,10 +1521,10 @@ static int ocfs2_cluster_group_search(struct inode *inode, | |||
| 1525 | if ((gd_cluster_off + max_bits) > | 1521 | if ((gd_cluster_off + max_bits) > |
| 1526 | OCFS2_I(inode)->ip_clusters) { | 1522 | OCFS2_I(inode)->ip_clusters) { |
| 1527 | max_bits = OCFS2_I(inode)->ip_clusters - gd_cluster_off; | 1523 | max_bits = OCFS2_I(inode)->ip_clusters - gd_cluster_off; |
| 1528 | mlog(0, "Desc %llu, bg_bits %u, clusters %u, use %u\n", | 1524 | trace_ocfs2_cluster_group_search_wrong_max_bits( |
| 1529 | (unsigned long long)le64_to_cpu(gd->bg_blkno), | 1525 | (unsigned long long)le64_to_cpu(gd->bg_blkno), |
| 1530 | le16_to_cpu(gd->bg_bits), | 1526 | le16_to_cpu(gd->bg_bits), |
| 1531 | OCFS2_I(inode)->ip_clusters, max_bits); | 1527 | OCFS2_I(inode)->ip_clusters, max_bits); |
| 1532 | } | 1528 | } |
| 1533 | 1529 | ||
| 1534 | ret = ocfs2_block_group_find_clear_bits(OCFS2_SB(inode->i_sb), | 1530 | ret = ocfs2_block_group_find_clear_bits(OCFS2_SB(inode->i_sb), |
| @@ -1542,9 +1538,9 @@ static int ocfs2_cluster_group_search(struct inode *inode, | |||
| 1542 | gd_cluster_off + | 1538 | gd_cluster_off + |
| 1543 | res->sr_bit_offset + | 1539 | res->sr_bit_offset + |
| 1544 | res->sr_bits); | 1540 | res->sr_bits); |
| 1545 | mlog(0, "Checking %llu against %llu\n", | 1541 | trace_ocfs2_cluster_group_search_max_block( |
| 1546 | (unsigned long long)blkoff, | 1542 | (unsigned long long)blkoff, |
| 1547 | (unsigned long long)max_block); | 1543 | (unsigned long long)max_block); |
| 1548 | if (blkoff > max_block) | 1544 | if (blkoff > max_block) |
| 1549 | return -ENOSPC; | 1545 | return -ENOSPC; |
| 1550 | } | 1546 | } |
| @@ -1588,9 +1584,9 @@ static int ocfs2_block_group_search(struct inode *inode, | |||
| 1588 | if (!ret && max_block) { | 1584 | if (!ret && max_block) { |
| 1589 | blkoff = le64_to_cpu(bg->bg_blkno) + | 1585 | blkoff = le64_to_cpu(bg->bg_blkno) + |
| 1590 | res->sr_bit_offset + res->sr_bits; | 1586 | res->sr_bit_offset + res->sr_bits; |
| 1591 | mlog(0, "Checking %llu against %llu\n", | 1587 | trace_ocfs2_block_group_search_max_block( |
| 1592 | (unsigned long long)blkoff, | 1588 | (unsigned long long)blkoff, |
| 1593 | (unsigned long long)max_block); | 1589 | (unsigned long long)max_block); |
| 1594 | if (blkoff > max_block) | 1590 | if (blkoff > max_block) |
| 1595 | ret = -ENOSPC; | 1591 | ret = -ENOSPC; |
| 1596 | } | 1592 | } |
| @@ -1756,9 +1752,9 @@ static int ocfs2_search_chain(struct ocfs2_alloc_context *ac, | |||
| 1756 | struct ocfs2_group_desc *bg; | 1752 | struct ocfs2_group_desc *bg; |
| 1757 | 1753 | ||
| 1758 | chain = ac->ac_chain; | 1754 | chain = ac->ac_chain; |
| 1759 | mlog(0, "trying to alloc %u bits from chain %u, inode %llu\n", | 1755 | trace_ocfs2_search_chain_begin( |
| 1760 | bits_wanted, chain, | 1756 | (unsigned long long)OCFS2_I(alloc_inode)->ip_blkno, |
| 1761 | (unsigned long long)OCFS2_I(alloc_inode)->ip_blkno); | 1757 | bits_wanted, chain); |
| 1762 | 1758 | ||
| 1763 | status = ocfs2_read_group_descriptor(alloc_inode, fe, | 1759 | status = ocfs2_read_group_descriptor(alloc_inode, fe, |
| 1764 | le64_to_cpu(cl->cl_recs[chain].c_blkno), | 1760 | le64_to_cpu(cl->cl_recs[chain].c_blkno), |
| @@ -1799,8 +1795,8 @@ static int ocfs2_search_chain(struct ocfs2_alloc_context *ac, | |||
| 1799 | goto bail; | 1795 | goto bail; |
| 1800 | } | 1796 | } |
| 1801 | 1797 | ||
| 1802 | mlog(0, "alloc succeeds: we give %u bits from block group %llu\n", | 1798 | trace_ocfs2_search_chain_succ( |
| 1803 | res->sr_bits, (unsigned long long)le64_to_cpu(bg->bg_blkno)); | 1799 | (unsigned long long)le64_to_cpu(bg->bg_blkno), res->sr_bits); |
| 1804 | 1800 | ||
| 1805 | res->sr_bg_blkno = le64_to_cpu(bg->bg_blkno); | 1801 | res->sr_bg_blkno = le64_to_cpu(bg->bg_blkno); |
| 1806 | 1802 | ||
| @@ -1861,8 +1857,9 @@ static int ocfs2_search_chain(struct ocfs2_alloc_context *ac, | |||
| 1861 | goto bail; | 1857 | goto bail; |
| 1862 | } | 1858 | } |
| 1863 | 1859 | ||
| 1864 | mlog(0, "Allocated %u bits from suballocator %llu\n", res->sr_bits, | 1860 | trace_ocfs2_search_chain_end( |
| 1865 | (unsigned long long)le64_to_cpu(fe->i_blkno)); | 1861 | (unsigned long long)le64_to_cpu(fe->i_blkno), |
| 1862 | res->sr_bits); | ||
| 1866 | 1863 | ||
| 1867 | out_loc_only: | 1864 | out_loc_only: |
| 1868 | *bits_left = le16_to_cpu(bg->bg_free_bits_count); | 1865 | *bits_left = le16_to_cpu(bg->bg_free_bits_count); |
| @@ -1870,7 +1867,8 @@ bail: | |||
| 1870 | brelse(group_bh); | 1867 | brelse(group_bh); |
| 1871 | brelse(prev_group_bh); | 1868 | brelse(prev_group_bh); |
| 1872 | 1869 | ||
| 1873 | mlog_exit(status); | 1870 | if (status) |
| 1871 | mlog_errno(status); | ||
| 1874 | return status; | 1872 | return status; |
| 1875 | } | 1873 | } |
| 1876 | 1874 | ||
| @@ -1888,8 +1886,6 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_alloc_context *ac, | |||
| 1888 | struct ocfs2_chain_list *cl; | 1886 | struct ocfs2_chain_list *cl; |
| 1889 | struct ocfs2_dinode *fe; | 1887 | struct ocfs2_dinode *fe; |
| 1890 | 1888 | ||
| 1891 | mlog_entry_void(); | ||
| 1892 | |||
| 1893 | BUG_ON(ac->ac_bits_given >= ac->ac_bits_wanted); | 1889 | BUG_ON(ac->ac_bits_given >= ac->ac_bits_wanted); |
| 1894 | BUG_ON(bits_wanted > (ac->ac_bits_wanted - ac->ac_bits_given)); | 1890 | BUG_ON(bits_wanted > (ac->ac_bits_wanted - ac->ac_bits_given)); |
| 1895 | BUG_ON(!ac->ac_bh); | 1891 | BUG_ON(!ac->ac_bh); |
| @@ -1945,8 +1941,7 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_alloc_context *ac, | |||
| 1945 | goto bail; | 1941 | goto bail; |
| 1946 | } | 1942 | } |
| 1947 | 1943 | ||
| 1948 | mlog(0, "Search of victim chain %u came up with nothing, " | 1944 | trace_ocfs2_claim_suballoc_bits(victim); |
| 1949 | "trying all chains now.\n", victim); | ||
| 1950 | 1945 | ||
| 1951 | /* If we didn't pick a good victim, then just default to | 1946 | /* If we didn't pick a good victim, then just default to |
| 1952 | * searching each chain in order. Don't allow chain relinking | 1947 | * searching each chain in order. Don't allow chain relinking |
| @@ -1984,7 +1979,8 @@ set_hint: | |||
| 1984 | } | 1979 | } |
| 1985 | 1980 | ||
| 1986 | bail: | 1981 | bail: |
| 1987 | mlog_exit(status); | 1982 | if (status) |
| 1983 | mlog_errno(status); | ||
| 1988 | return status; | 1984 | return status; |
| 1989 | } | 1985 | } |
| 1990 | 1986 | ||
| @@ -2021,7 +2017,8 @@ int ocfs2_claim_metadata(handle_t *handle, | |||
| 2021 | *num_bits = res.sr_bits; | 2017 | *num_bits = res.sr_bits; |
| 2022 | status = 0; | 2018 | status = 0; |
| 2023 | bail: | 2019 | bail: |
| 2024 | mlog_exit(status); | 2020 | if (status) |
| 2021 | mlog_errno(status); | ||
| 2025 | return status; | 2022 | return status; |
| 2026 | } | 2023 | } |
| 2027 | 2024 | ||
| @@ -2172,8 +2169,8 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle, | |||
| 2172 | goto out; | 2169 | goto out; |
| 2173 | } | 2170 | } |
| 2174 | 2171 | ||
| 2175 | mlog(0, "Allocated %u bits from suballocator %llu\n", res->sr_bits, | 2172 | trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno, |
| 2176 | (unsigned long long)di_blkno); | 2173 | res->sr_bits); |
| 2177 | 2174 | ||
| 2178 | atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs); | 2175 | atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs); |
| 2179 | 2176 | ||
| @@ -2201,8 +2198,6 @@ int ocfs2_claim_new_inode(handle_t *handle, | |||
| 2201 | int status; | 2198 | int status; |
| 2202 | struct ocfs2_suballoc_result res; | 2199 | struct ocfs2_suballoc_result res; |
| 2203 | 2200 | ||
| 2204 | mlog_entry_void(); | ||
| 2205 | |||
| 2206 | BUG_ON(!ac); | 2201 | BUG_ON(!ac); |
| 2207 | BUG_ON(ac->ac_bits_given != 0); | 2202 | BUG_ON(ac->ac_bits_given != 0); |
| 2208 | BUG_ON(ac->ac_bits_wanted != 1); | 2203 | BUG_ON(ac->ac_bits_wanted != 1); |
| @@ -2230,7 +2225,8 @@ int ocfs2_claim_new_inode(handle_t *handle, | |||
| 2230 | ocfs2_save_inode_ac_group(dir, ac); | 2225 | ocfs2_save_inode_ac_group(dir, ac); |
| 2231 | status = 0; | 2226 | status = 0; |
| 2232 | bail: | 2227 | bail: |
| 2233 | mlog_exit(status); | 2228 | if (status) |
| 2229 | mlog_errno(status); | ||
| 2234 | return status; | 2230 | return status; |
| 2235 | } | 2231 | } |
| 2236 | 2232 | ||
| @@ -2307,8 +2303,6 @@ int __ocfs2_claim_clusters(handle_t *handle, | |||
| 2307 | struct ocfs2_suballoc_result res = { .sr_blkno = 0, }; | 2303 | struct ocfs2_suballoc_result res = { .sr_blkno = 0, }; |
| 2308 | struct ocfs2_super *osb = OCFS2_SB(ac->ac_inode->i_sb); | 2304 | struct ocfs2_super *osb = OCFS2_SB(ac->ac_inode->i_sb); |
| 2309 | 2305 | ||
| 2310 | mlog_entry_void(); | ||
| 2311 | |||
| 2312 | BUG_ON(ac->ac_bits_given >= ac->ac_bits_wanted); | 2306 | BUG_ON(ac->ac_bits_given >= ac->ac_bits_wanted); |
| 2313 | 2307 | ||
| 2314 | BUG_ON(ac->ac_which != OCFS2_AC_USE_LOCAL | 2308 | BUG_ON(ac->ac_which != OCFS2_AC_USE_LOCAL |
| @@ -2363,7 +2357,8 @@ int __ocfs2_claim_clusters(handle_t *handle, | |||
| 2363 | ac->ac_bits_given += *num_clusters; | 2357 | ac->ac_bits_given += *num_clusters; |
| 2364 | 2358 | ||
| 2365 | bail: | 2359 | bail: |
| 2366 | mlog_exit(status); | 2360 | if (status) |
| 2361 | mlog_errno(status); | ||
| 2367 | return status; | 2362 | return status; |
| 2368 | } | 2363 | } |
| 2369 | 2364 | ||
| @@ -2392,13 +2387,11 @@ static int ocfs2_block_group_clear_bits(handle_t *handle, | |||
| 2392 | unsigned int tmp; | 2387 | unsigned int tmp; |
| 2393 | struct ocfs2_group_desc *undo_bg = NULL; | 2388 | struct ocfs2_group_desc *undo_bg = NULL; |
| 2394 | 2389 | ||
| 2395 | mlog_entry_void(); | ||
| 2396 | |||
| 2397 | /* The caller got this descriptor from | 2390 | /* The caller got this descriptor from |
| 2398 | * ocfs2_read_group_descriptor(). Any corruption is a code bug. */ | 2391 | * ocfs2_read_group_descriptor(). Any corruption is a code bug. */ |
| 2399 | BUG_ON(!OCFS2_IS_VALID_GROUP_DESC(bg)); | 2392 | BUG_ON(!OCFS2_IS_VALID_GROUP_DESC(bg)); |
| 2400 | 2393 | ||
| 2401 | mlog(0, "off = %u, num = %u\n", bit_off, num_bits); | 2394 | trace_ocfs2_block_group_clear_bits(bit_off, num_bits); |
| 2402 | 2395 | ||
| 2403 | BUG_ON(undo_fn && !ocfs2_is_cluster_bitmap(alloc_inode)); | 2396 | BUG_ON(undo_fn && !ocfs2_is_cluster_bitmap(alloc_inode)); |
| 2404 | status = ocfs2_journal_access_gd(handle, INODE_CACHE(alloc_inode), | 2397 | status = ocfs2_journal_access_gd(handle, INODE_CACHE(alloc_inode), |
| @@ -2463,8 +2456,6 @@ static int _ocfs2_free_suballoc_bits(handle_t *handle, | |||
| 2463 | struct buffer_head *group_bh = NULL; | 2456 | struct buffer_head *group_bh = NULL; |
| 2464 | struct ocfs2_group_desc *group; | 2457 | struct ocfs2_group_desc *group; |
| 2465 | 2458 | ||
| 2466 | mlog_entry_void(); | ||
| 2467 | |||
| 2468 | /* The alloc_bh comes from ocfs2_free_dinode() or | 2459 | /* The alloc_bh comes from ocfs2_free_dinode() or |
| 2469 | * ocfs2_free_clusters(). The callers have all locked the | 2460 | * ocfs2_free_clusters(). The callers have all locked the |
| 2470 | * allocator and gotten alloc_bh from the lock call. This | 2461 | * allocator and gotten alloc_bh from the lock call. This |
| @@ -2473,9 +2464,10 @@ static int _ocfs2_free_suballoc_bits(handle_t *handle, | |||
| 2473 | BUG_ON(!OCFS2_IS_VALID_DINODE(fe)); | 2464 | BUG_ON(!OCFS2_IS_VALID_DINODE(fe)); |
| 2474 | BUG_ON((count + start_bit) > ocfs2_bits_per_group(cl)); | 2465 | BUG_ON((count + start_bit) > ocfs2_bits_per_group(cl)); |
| 2475 | 2466 | ||
| 2476 | mlog(0, "%llu: freeing %u bits from group %llu, starting at %u\n", | 2467 | trace_ocfs2_free_suballoc_bits( |
| 2477 | (unsigned long long)OCFS2_I(alloc_inode)->ip_blkno, count, | 2468 | (unsigned long long)OCFS2_I(alloc_inode)->ip_blkno, |
| 2478 | (unsigned long long)bg_blkno, start_bit); | 2469 | (unsigned long long)bg_blkno, |
| 2470 | start_bit, count); | ||
| 2479 | 2471 | ||
| 2480 | status = ocfs2_read_group_descriptor(alloc_inode, fe, bg_blkno, | 2472 | status = ocfs2_read_group_descriptor(alloc_inode, fe, bg_blkno, |
| 2481 | &group_bh); | 2473 | &group_bh); |
| @@ -2511,7 +2503,8 @@ static int _ocfs2_free_suballoc_bits(handle_t *handle, | |||
| 2511 | bail: | 2503 | bail: |
| 2512 | brelse(group_bh); | 2504 | brelse(group_bh); |
| 2513 | 2505 | ||
| 2514 | mlog_exit(status); | 2506 | if (status) |
| 2507 | mlog_errno(status); | ||
| 2515 | return status; | 2508 | return status; |
| 2516 | } | 2509 | } |
| 2517 | 2510 | ||
| @@ -2556,11 +2549,8 @@ static int _ocfs2_free_clusters(handle_t *handle, | |||
| 2556 | 2549 | ||
| 2557 | /* You can't ever have a contiguous set of clusters | 2550 | /* You can't ever have a contiguous set of clusters |
| 2558 | * bigger than a block group bitmap so we never have to worry | 2551 | * bigger than a block group bitmap so we never have to worry |
| 2559 | * about looping on them. */ | 2552 | * about looping on them. |
| 2560 | 2553 | * This is expensive. We can safely remove once this stuff has | |
| 2561 | mlog_entry_void(); | ||
| 2562 | |||
| 2563 | /* This is expensive. We can safely remove once this stuff has | ||
| 2564 | * gotten tested really well. */ | 2554 | * gotten tested really well. */ |
| 2565 | BUG_ON(start_blk != ocfs2_clusters_to_blocks(bitmap_inode->i_sb, ocfs2_blocks_to_clusters(bitmap_inode->i_sb, start_blk))); | 2555 | BUG_ON(start_blk != ocfs2_clusters_to_blocks(bitmap_inode->i_sb, ocfs2_blocks_to_clusters(bitmap_inode->i_sb, start_blk))); |
| 2566 | 2556 | ||
| @@ -2569,10 +2559,9 @@ static int _ocfs2_free_clusters(handle_t *handle, | |||
| 2569 | ocfs2_block_to_cluster_group(bitmap_inode, start_blk, &bg_blkno, | 2559 | ocfs2_block_to_cluster_group(bitmap_inode, start_blk, &bg_blkno, |
| 2570 | &bg_start_bit); | 2560 | &bg_start_bit); |
| 2571 | 2561 | ||
| 2572 | mlog(0, "want to free %u clusters starting at block %llu\n", | 2562 | trace_ocfs2_free_clusters((unsigned long long)bg_blkno, |
| 2573 | num_clusters, (unsigned long long)start_blk); | 2563 | (unsigned long long)start_blk, |
| 2574 | mlog(0, "bg_blkno = %llu, bg_start_bit = %u\n", | 2564 | bg_start_bit, num_clusters); |
| 2575 | (unsigned long long)bg_blkno, bg_start_bit); | ||
| 2576 | 2565 | ||
| 2577 | status = _ocfs2_free_suballoc_bits(handle, bitmap_inode, bitmap_bh, | 2566 | status = _ocfs2_free_suballoc_bits(handle, bitmap_inode, bitmap_bh, |
| 2578 | bg_start_bit, bg_blkno, | 2567 | bg_start_bit, bg_blkno, |
| @@ -2586,7 +2575,8 @@ static int _ocfs2_free_clusters(handle_t *handle, | |||
| 2586 | num_clusters); | 2575 | num_clusters); |
| 2587 | 2576 | ||
| 2588 | out: | 2577 | out: |
| 2589 | mlog_exit(status); | 2578 | if (status) |
| 2579 | mlog_errno(status); | ||
| 2590 | return status; | 2580 | return status; |
| 2591 | } | 2581 | } |
| 2592 | 2582 | ||
| @@ -2756,7 +2746,7 @@ static int ocfs2_get_suballoc_slot_bit(struct ocfs2_super *osb, u64 blkno, | |||
| 2756 | struct buffer_head *inode_bh = NULL; | 2746 | struct buffer_head *inode_bh = NULL; |
| 2757 | struct ocfs2_dinode *inode_fe; | 2747 | struct ocfs2_dinode *inode_fe; |
| 2758 | 2748 | ||
| 2759 | mlog_entry("blkno: %llu\n", (unsigned long long)blkno); | 2749 | trace_ocfs2_get_suballoc_slot_bit((unsigned long long)blkno); |
| 2760 | 2750 | ||
| 2761 | /* dirty read disk */ | 2751 | /* dirty read disk */ |
| 2762 | status = ocfs2_read_blocks_sync(osb, blkno, 1, &inode_bh); | 2752 | status = ocfs2_read_blocks_sync(osb, blkno, 1, &inode_bh); |
| @@ -2793,7 +2783,8 @@ static int ocfs2_get_suballoc_slot_bit(struct ocfs2_super *osb, u64 blkno, | |||
| 2793 | bail: | 2783 | bail: |
| 2794 | brelse(inode_bh); | 2784 | brelse(inode_bh); |
| 2795 | 2785 | ||
| 2796 | mlog_exit(status); | 2786 | if (status) |
| 2787 | mlog_errno(status); | ||
| 2797 | return status; | 2788 | return status; |
| 2798 | } | 2789 | } |
| 2799 | 2790 | ||
| @@ -2816,8 +2807,8 @@ static int ocfs2_test_suballoc_bit(struct ocfs2_super *osb, | |||
| 2816 | u64 bg_blkno; | 2807 | u64 bg_blkno; |
| 2817 | int status; | 2808 | int status; |
| 2818 | 2809 | ||
| 2819 | mlog_entry("blkno: %llu bit: %u\n", (unsigned long long)blkno, | 2810 | trace_ocfs2_test_suballoc_bit((unsigned long long)blkno, |
| 2820 | (unsigned int)bit); | 2811 | (unsigned int)bit); |
| 2821 | 2812 | ||
| 2822 | alloc_di = (struct ocfs2_dinode *)alloc_bh->b_data; | 2813 | alloc_di = (struct ocfs2_dinode *)alloc_bh->b_data; |
| 2823 | if ((bit + 1) > ocfs2_bits_per_group(&alloc_di->id2.i_chain)) { | 2814 | if ((bit + 1) > ocfs2_bits_per_group(&alloc_di->id2.i_chain)) { |
| @@ -2844,7 +2835,8 @@ static int ocfs2_test_suballoc_bit(struct ocfs2_super *osb, | |||
| 2844 | bail: | 2835 | bail: |
| 2845 | brelse(group_bh); | 2836 | brelse(group_bh); |
| 2846 | 2837 | ||
| 2847 | mlog_exit(status); | 2838 | if (status) |
| 2839 | mlog_errno(status); | ||
| 2848 | return status; | 2840 | return status; |
| 2849 | } | 2841 | } |
| 2850 | 2842 | ||
| @@ -2869,7 +2861,7 @@ int ocfs2_test_inode_bit(struct ocfs2_super *osb, u64 blkno, int *res) | |||
| 2869 | struct inode *inode_alloc_inode; | 2861 | struct inode *inode_alloc_inode; |
| 2870 | struct buffer_head *alloc_bh = NULL; | 2862 | struct buffer_head *alloc_bh = NULL; |
| 2871 | 2863 | ||
| 2872 | mlog_entry("blkno: %llu", (unsigned long long)blkno); | 2864 | trace_ocfs2_test_inode_bit((unsigned long long)blkno); |
| 2873 | 2865 | ||
| 2874 | status = ocfs2_get_suballoc_slot_bit(osb, blkno, &suballoc_slot, | 2866 | status = ocfs2_get_suballoc_slot_bit(osb, blkno, &suballoc_slot, |
| 2875 | &group_blkno, &suballoc_bit); | 2867 | &group_blkno, &suballoc_bit); |
| @@ -2910,6 +2902,7 @@ int ocfs2_test_inode_bit(struct ocfs2_super *osb, u64 blkno, int *res) | |||
| 2910 | iput(inode_alloc_inode); | 2902 | iput(inode_alloc_inode); |
| 2911 | brelse(alloc_bh); | 2903 | brelse(alloc_bh); |
| 2912 | bail: | 2904 | bail: |
| 2913 | mlog_exit(status); | 2905 | if (status) |
| 2906 | mlog_errno(status); | ||
| 2914 | return status; | 2907 | return status; |
| 2915 | } | 2908 | } |
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c index 236ed1bdca2..69fa11b35aa 100644 --- a/fs/ocfs2/super.c +++ b/fs/ocfs2/super.c | |||
| @@ -42,7 +42,9 @@ | |||
| 42 | #include <linux/seq_file.h> | 42 | #include <linux/seq_file.h> |
| 43 | #include <linux/quotaops.h> | 43 | #include <linux/quotaops.h> |
| 44 | 44 | ||
| 45 | #define MLOG_MASK_PREFIX ML_SUPER | 45 | #define CREATE_TRACE_POINTS |
| 46 | #include "ocfs2_trace.h" | ||
| 47 | |||
| 46 | #include <cluster/masklog.h> | 48 | #include <cluster/masklog.h> |
| 47 | 49 | ||
| 48 | #include "ocfs2.h" | 50 | #include "ocfs2.h" |
| @@ -441,8 +443,6 @@ static int ocfs2_init_global_system_inodes(struct ocfs2_super *osb) | |||
| 441 | int status = 0; | 443 | int status = 0; |
| 442 | int i; | 444 | int i; |
| 443 | 445 | ||
| 444 | mlog_entry_void(); | ||
| 445 | |||
| 446 | new = ocfs2_iget(osb, osb->root_blkno, OCFS2_FI_FLAG_SYSFILE, 0); | 446 | new = ocfs2_iget(osb, osb->root_blkno, OCFS2_FI_FLAG_SYSFILE, 0); |
| 447 | if (IS_ERR(new)) { | 447 | if (IS_ERR(new)) { |
| 448 | status = PTR_ERR(new); | 448 | status = PTR_ERR(new); |
| @@ -478,7 +478,8 @@ static int ocfs2_init_global_system_inodes(struct ocfs2_super *osb) | |||
| 478 | } | 478 | } |
| 479 | 479 | ||
| 480 | bail: | 480 | bail: |
| 481 | mlog_exit(status); | 481 | if (status) |
| 482 | mlog_errno(status); | ||
| 482 | return status; | 483 | return status; |
| 483 | } | 484 | } |
| 484 | 485 | ||
| @@ -488,8 +489,6 @@ static int ocfs2_init_local_system_inodes(struct ocfs2_super *osb) | |||
| 488 | int status = 0; | 489 | int status = 0; |
| 489 | int i; | 490 | int i; |
| 490 | 491 | ||
| 491 | mlog_entry_void(); | ||
| 492 | |||
| 493 | for (i = OCFS2_LAST_GLOBAL_SYSTEM_INODE + 1; | 492 | for (i = OCFS2_LAST_GLOBAL_SYSTEM_INODE + 1; |
| 494 | i < NUM_SYSTEM_INODES; | 493 | i < NUM_SYSTEM_INODES; |
| 495 | i++) { | 494 | i++) { |
| @@ -508,7 +507,8 @@ static int ocfs2_init_local_system_inodes(struct ocfs2_super *osb) | |||
| 508 | } | 507 | } |
| 509 | 508 | ||
| 510 | bail: | 509 | bail: |
| 511 | mlog_exit(status); | 510 | if (status) |
| 511 | mlog_errno(status); | ||
| 512 | return status; | 512 | return status; |
| 513 | } | 513 | } |
| 514 | 514 | ||
| @@ -517,8 +517,6 @@ static void ocfs2_release_system_inodes(struct ocfs2_super *osb) | |||
| 517 | int i; | 517 | int i; |
| 518 | struct inode *inode; | 518 | struct inode *inode; |
| 519 | 519 | ||
| 520 | mlog_entry_void(); | ||
| 521 | |||
| 522 | for (i = 0; i < NUM_GLOBAL_SYSTEM_INODES; i++) { | 520 | for (i = 0; i < NUM_GLOBAL_SYSTEM_INODES; i++) { |
| 523 | inode = osb->global_system_inodes[i]; | 521 | inode = osb->global_system_inodes[i]; |
| 524 | if (inode) { | 522 | if (inode) { |
| @@ -540,7 +538,7 @@ static void ocfs2_release_system_inodes(struct ocfs2_super *osb) | |||
| 540 | } | 538 | } |
| 541 | 539 | ||
| 542 | if (!osb->local_system_inodes) | 540 | if (!osb->local_system_inodes) |
| 543 | goto out; | 541 | return; |
| 544 | 542 | ||
| 545 | for (i = 0; i < NUM_LOCAL_SYSTEM_INODES * osb->max_slots; i++) { | 543 | for (i = 0; i < NUM_LOCAL_SYSTEM_INODES * osb->max_slots; i++) { |
| 546 | if (osb->local_system_inodes[i]) { | 544 | if (osb->local_system_inodes[i]) { |
| @@ -551,9 +549,6 @@ static void ocfs2_release_system_inodes(struct ocfs2_super *osb) | |||
| 551 | 549 | ||
| 552 | kfree(osb->local_system_inodes); | 550 | kfree(osb->local_system_inodes); |
| 553 | osb->local_system_inodes = NULL; | 551 | osb->local_system_inodes = NULL; |
| 554 | |||
| 555 | out: | ||
| 556 | mlog_exit(0); | ||
| 557 | } | 552 | } |
| 558 | 553 | ||
| 559 | /* We're allocating fs objects, use GFP_NOFS */ | 554 | /* We're allocating fs objects, use GFP_NOFS */ |
| @@ -684,12 +679,9 @@ static int ocfs2_remount(struct super_block *sb, int *flags, char *data) | |||
| 684 | } | 679 | } |
| 685 | 680 | ||
| 686 | if (*flags & MS_RDONLY) { | 681 | if (*flags & MS_RDONLY) { |
| 687 | mlog(0, "Going to ro mode.\n"); | ||
| 688 | sb->s_flags |= MS_RDONLY; | 682 | sb->s_flags |= MS_RDONLY; |
| 689 | osb->osb_flags |= OCFS2_OSB_SOFT_RO; | 683 | osb->osb_flags |= OCFS2_OSB_SOFT_RO; |
| 690 | } else { | 684 | } else { |
| 691 | mlog(0, "Making ro filesystem writeable.\n"); | ||
| 692 | |||
| 693 | if (osb->osb_flags & OCFS2_OSB_ERROR_FS) { | 685 | if (osb->osb_flags & OCFS2_OSB_ERROR_FS) { |
| 694 | mlog(ML_ERROR, "Cannot remount RDWR " | 686 | mlog(ML_ERROR, "Cannot remount RDWR " |
| 695 | "filesystem due to previous errors.\n"); | 687 | "filesystem due to previous errors.\n"); |
| @@ -707,6 +699,7 @@ static int ocfs2_remount(struct super_block *sb, int *flags, char *data) | |||
| 707 | sb->s_flags &= ~MS_RDONLY; | 699 | sb->s_flags &= ~MS_RDONLY; |
| 708 | osb->osb_flags &= ~OCFS2_OSB_SOFT_RO; | 700 | osb->osb_flags &= ~OCFS2_OSB_SOFT_RO; |
| 709 | } | 701 | } |
| 702 | trace_ocfs2_remount(sb->s_flags, osb->osb_flags, *flags); | ||
| 710 | unlock_osb: | 703 | unlock_osb: |
| 711 | spin_unlock(&osb->osb_lock); | 704 | spin_unlock(&osb->osb_lock); |
| 712 | /* Enable quota accounting after remounting RW */ | 705 | /* Enable quota accounting after remounting RW */ |
| @@ -1032,7 +1025,7 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) | |||
| 1032 | char nodestr[8]; | 1025 | char nodestr[8]; |
| 1033 | struct ocfs2_blockcheck_stats stats; | 1026 | struct ocfs2_blockcheck_stats stats; |
| 1034 | 1027 | ||
| 1035 | mlog_entry("%p, %p, %i", sb, data, silent); | 1028 | trace_ocfs2_fill_super(sb, data, silent); |
| 1036 | 1029 | ||
| 1037 | if (!ocfs2_parse_options(sb, data, &parsed_options, 0)) { | 1030 | if (!ocfs2_parse_options(sb, data, &parsed_options, 0)) { |
| 1038 | status = -EINVAL; | 1031 | status = -EINVAL; |
| @@ -1208,7 +1201,6 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) | |||
| 1208 | mlog_errno(status); | 1201 | mlog_errno(status); |
| 1209 | atomic_set(&osb->vol_state, VOLUME_DISABLED); | 1202 | atomic_set(&osb->vol_state, VOLUME_DISABLED); |
| 1210 | wake_up(&osb->osb_mount_event); | 1203 | wake_up(&osb->osb_mount_event); |
| 1211 | mlog_exit(status); | ||
| 1212 | return status; | 1204 | return status; |
| 1213 | } | 1205 | } |
| 1214 | } | 1206 | } |
| @@ -1222,7 +1214,6 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) | |||
| 1222 | /* Start this when the mount is almost sure of being successful */ | 1214 | /* Start this when the mount is almost sure of being successful */ |
| 1223 | ocfs2_orphan_scan_start(osb); | 1215 | ocfs2_orphan_scan_start(osb); |
| 1224 | 1216 | ||
| 1225 | mlog_exit(status); | ||
| 1226 | return status; | 1217 | return status; |
| 1227 | 1218 | ||
| 1228 | read_super_error: | 1219 | read_super_error: |
| @@ -1237,7 +1228,8 @@ read_super_error: | |||
| 1237 | ocfs2_dismount_volume(sb, 1); | 1228 | ocfs2_dismount_volume(sb, 1); |
| 1238 | } | 1229 | } |
| 1239 | 1230 | ||
| 1240 | mlog_exit(status); | 1231 | if (status) |
| 1232 | mlog_errno(status); | ||
| 1241 | return status; | 1233 | return status; |
| 1242 | } | 1234 | } |
| 1243 | 1235 | ||
| @@ -1320,8 +1312,7 @@ static int ocfs2_parse_options(struct super_block *sb, | |||
| 1320 | char *p; | 1312 | char *p; |
| 1321 | u32 tmp; | 1313 | u32 tmp; |
| 1322 | 1314 | ||
| 1323 | mlog_entry("remount: %d, options: \"%s\"\n", is_remount, | 1315 | trace_ocfs2_parse_options(is_remount, options ? options : "(none)"); |
| 1324 | options ? options : "(none)"); | ||
| 1325 | 1316 | ||
| 1326 | mopt->commit_interval = 0; | 1317 | mopt->commit_interval = 0; |
| 1327 | mopt->mount_opt = OCFS2_MOUNT_NOINTR; | 1318 | mopt->mount_opt = OCFS2_MOUNT_NOINTR; |
| @@ -1538,7 +1529,6 @@ static int ocfs2_parse_options(struct super_block *sb, | |||
| 1538 | status = 1; | 1529 | status = 1; |
| 1539 | 1530 | ||
| 1540 | bail: | 1531 | bail: |
| 1541 | mlog_exit(status); | ||
| 1542 | return status; | 1532 | return status; |
| 1543 | } | 1533 | } |
| 1544 | 1534 | ||
| @@ -1629,8 +1619,6 @@ static int __init ocfs2_init(void) | |||
| 1629 | { | 1619 | { |
| 1630 | int status; | 1620 | int status; |
| 1631 | 1621 | ||
| 1632 | mlog_entry_void(); | ||
| 1633 | |||
| 1634 | ocfs2_print_version(); | 1622 | ocfs2_print_version(); |
| 1635 | 1623 | ||
| 1636 | status = init_ocfs2_uptodate_cache(); | 1624 | status = init_ocfs2_uptodate_cache(); |
| @@ -1664,10 +1652,9 @@ leave: | |||
| 1664 | if (status < 0) { | 1652 | if (status < 0) { |
| 1665 | ocfs2_free_mem_caches(); | 1653 | ocfs2_free_mem_caches(); |
| 1666 | exit_ocfs2_uptodate_cache(); | 1654 | exit_ocfs2_uptodate_cache(); |
| 1655 | mlog_errno(status); | ||
| 1667 | } | 1656 | } |
| 1668 | 1657 | ||
| 1669 | mlog_exit(status); | ||
| 1670 | |||
| 1671 | if (status >= 0) { | 1658 | if (status >= 0) { |
| 1672 | return register_filesystem(&ocfs2_fs_type); | 1659 | return register_filesystem(&ocfs2_fs_type); |
| 1673 | } else | 1660 | } else |
| @@ -1676,8 +1663,6 @@ leave: | |||
| 1676 | 1663 | ||
| 1677 | static void __exit ocfs2_exit(void) | 1664 | static void __exit ocfs2_exit(void) |
| 1678 | { | 1665 | { |
| 1679 | mlog_entry_void(); | ||
| 1680 | |||
| 1681 | if (ocfs2_wq) { | 1666 | if (ocfs2_wq) { |
| 1682 | flush_workqueue(ocfs2_wq); | 1667 | flush_workqueue(ocfs2_wq); |
| 1683 | destroy_workqueue(ocfs2_wq); | 1668 | destroy_workqueue(ocfs2_wq); |
| @@ -1692,18 +1677,14 @@ static void __exit ocfs2_exit(void) | |||
| 1692 | unregister_filesystem(&ocfs2_fs_type); | 1677 | unregister_filesystem(&ocfs2_fs_type); |
| 1693 | 1678 | ||
| 1694 | exit_ocfs2_uptodate_cache(); | 1679 | exit_ocfs2_uptodate_cache(); |
| 1695 | |||
| 1696 | mlog_exit_void(); | ||
| 1697 | } | 1680 | } |
| 1698 | 1681 | ||
| 1699 | static void ocfs2_put_super(struct super_block *sb) | 1682 | static void ocfs2_put_super(struct super_block *sb) |
| 1700 | { | 1683 | { |
| 1701 | mlog_entry("(0x%p)\n", sb); | 1684 | trace_ocfs2_put_super(sb); |
| 1702 | 1685 | ||
| 1703 | ocfs2_sync_blockdev(sb); | 1686 | ocfs2_sync_blockdev(sb); |
| 1704 | ocfs2_dismount_volume(sb, 0); | 1687 | ocfs2_dismount_volume(sb, 0); |
| 1705 | |||
| 1706 | mlog_exit_void(); | ||
| 1707 | } | 1688 | } |
| 1708 | 1689 | ||
| 1709 | static int ocfs2_statfs(struct dentry *dentry, struct kstatfs *buf) | 1690 | static int ocfs2_statfs(struct dentry *dentry, struct kstatfs *buf) |
| @@ -1715,7 +1696,7 @@ static int ocfs2_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
| 1715 | struct buffer_head *bh = NULL; | 1696 | struct buffer_head *bh = NULL; |
| 1716 | struct inode *inode = NULL; | 1697 | struct inode *inode = NULL; |
| 1717 | 1698 | ||
| 1718 | mlog_entry("(%p, %p)\n", dentry->d_sb, buf); | 1699 | trace_ocfs2_statfs(dentry->d_sb, buf); |
| 1719 | 1700 | ||
| 1720 | osb = OCFS2_SB(dentry->d_sb); | 1701 | osb = OCFS2_SB(dentry->d_sb); |
| 1721 | 1702 | ||
| @@ -1762,7 +1743,8 @@ bail: | |||
| 1762 | if (inode) | 1743 | if (inode) |
| 1763 | iput(inode); | 1744 | iput(inode); |
| 1764 | 1745 | ||
| 1765 | mlog_exit(status); | 1746 | if (status) |
| 1747 | mlog_errno(status); | ||
| 1766 | 1748 | ||
| 1767 | return status; | 1749 | return status; |
| 1768 | } | 1750 | } |
| @@ -1882,8 +1864,6 @@ static int ocfs2_mount_volume(struct super_block *sb) | |||
| 1882 | int unlock_super = 0; | 1864 | int unlock_super = 0; |
| 1883 | struct ocfs2_super *osb = OCFS2_SB(sb); | 1865 | struct ocfs2_super *osb = OCFS2_SB(sb); |
| 1884 | 1866 | ||
| 1885 | mlog_entry_void(); | ||
| 1886 | |||
| 1887 | if (ocfs2_is_hard_readonly(osb)) | 1867 | if (ocfs2_is_hard_readonly(osb)) |
| 1888 | goto leave; | 1868 | goto leave; |
| 1889 | 1869 | ||
| @@ -1928,7 +1908,6 @@ leave: | |||
| 1928 | if (unlock_super) | 1908 | if (unlock_super) |
| 1929 | ocfs2_super_unlock(osb, 1); | 1909 | ocfs2_super_unlock(osb, 1); |
| 1930 | 1910 | ||
| 1931 | mlog_exit(status); | ||
| 1932 | return status; | 1911 | return status; |
| 1933 | } | 1912 | } |
| 1934 | 1913 | ||
| @@ -1938,7 +1917,7 @@ static void ocfs2_dismount_volume(struct super_block *sb, int mnt_err) | |||
| 1938 | struct ocfs2_super *osb = NULL; | 1917 | struct ocfs2_super *osb = NULL; |
| 1939 | char nodestr[8]; | 1918 | char nodestr[8]; |
| 1940 | 1919 | ||
| 1941 | mlog_entry("(0x%p)\n", sb); | 1920 | trace_ocfs2_dismount_volume(sb); |
| 1942 | 1921 | ||
| 1943 | BUG_ON(!sb); | 1922 | BUG_ON(!sb); |
| 1944 | osb = OCFS2_SB(sb); | 1923 | osb = OCFS2_SB(sb); |
| @@ -2090,8 +2069,6 @@ static int ocfs2_initialize_super(struct super_block *sb, | |||
| 2090 | struct ocfs2_super *osb; | 2069 | struct ocfs2_super *osb; |
| 2091 | u64 total_blocks; | 2070 | u64 total_blocks; |
| 2092 | 2071 | ||
| 2093 | mlog_entry_void(); | ||
| 2094 | |||
| 2095 | osb = kzalloc(sizeof(struct ocfs2_super), GFP_KERNEL); | 2072 | osb = kzalloc(sizeof(struct ocfs2_super), GFP_KERNEL); |
| 2096 | if (!osb) { | 2073 | if (!osb) { |
| 2097 | status = -ENOMEM; | 2074 | status = -ENOMEM; |
| @@ -2155,7 +2132,6 @@ static int ocfs2_initialize_super(struct super_block *sb, | |||
| 2155 | status = -EINVAL; | 2132 | status = -EINVAL; |
| 2156 | goto bail; | 2133 | goto bail; |
| 2157 | } | 2134 | } |
| 2158 | mlog(0, "max_slots for this device: %u\n", osb->max_slots); | ||
| 2159 | 2135 | ||
| 2160 | ocfs2_orphan_scan_init(osb); | 2136 | ocfs2_orphan_scan_init(osb); |
| 2161 | 2137 | ||
| @@ -2294,7 +2270,6 @@ static int ocfs2_initialize_super(struct super_block *sb, | |||
| 2294 | osb->s_clustersize_bits = | 2270 | osb->s_clustersize_bits = |
| 2295 | le32_to_cpu(di->id2.i_super.s_clustersize_bits); | 2271 | le32_to_cpu(di->id2.i_super.s_clustersize_bits); |
| 2296 | osb->s_clustersize = 1 << osb->s_clustersize_bits; | 2272 | osb->s_clustersize = 1 << osb->s_clustersize_bits; |
| 2297 | mlog(0, "clusterbits=%d\n", osb->s_clustersize_bits); | ||
| 2298 | 2273 | ||
| 2299 | if (osb->s_clustersize < OCFS2_MIN_CLUSTERSIZE || | 2274 | if (osb->s_clustersize < OCFS2_MIN_CLUSTERSIZE || |
| 2300 | osb->s_clustersize > OCFS2_MAX_CLUSTERSIZE) { | 2275 | osb->s_clustersize > OCFS2_MAX_CLUSTERSIZE) { |
| @@ -2333,11 +2308,10 @@ static int ocfs2_initialize_super(struct super_block *sb, | |||
| 2333 | le64_to_cpu(di->id2.i_super.s_first_cluster_group); | 2308 | le64_to_cpu(di->id2.i_super.s_first_cluster_group); |
| 2334 | osb->fs_generation = le32_to_cpu(di->i_fs_generation); | 2309 | osb->fs_generation = le32_to_cpu(di->i_fs_generation); |
| 2335 | osb->uuid_hash = le32_to_cpu(di->id2.i_super.s_uuid_hash); | 2310 | osb->uuid_hash = le32_to_cpu(di->id2.i_super.s_uuid_hash); |
| 2336 | mlog(0, "vol_label: %s\n", osb->vol_label); | 2311 | trace_ocfs2_initialize_super(osb->vol_label, osb->uuid_str, |
| 2337 | mlog(0, "uuid: %s\n", osb->uuid_str); | 2312 | (unsigned long long)osb->root_blkno, |
| 2338 | mlog(0, "root_blkno=%llu, system_dir_blkno=%llu\n", | 2313 | (unsigned long long)osb->system_dir_blkno, |
| 2339 | (unsigned long long)osb->root_blkno, | 2314 | osb->s_clustersize_bits); |
| 2340 | (unsigned long long)osb->system_dir_blkno); | ||
| 2341 | 2315 | ||
| 2342 | osb->osb_dlm_debug = ocfs2_new_dlm_debug(); | 2316 | osb->osb_dlm_debug = ocfs2_new_dlm_debug(); |
| 2343 | if (!osb->osb_dlm_debug) { | 2317 | if (!osb->osb_dlm_debug) { |
| @@ -2380,7 +2354,6 @@ static int ocfs2_initialize_super(struct super_block *sb, | |||
| 2380 | } | 2354 | } |
| 2381 | 2355 | ||
| 2382 | bail: | 2356 | bail: |
| 2383 | mlog_exit(status); | ||
| 2384 | return status; | 2357 | return status; |
| 2385 | } | 2358 | } |
| 2386 | 2359 | ||
| @@ -2396,8 +2369,6 @@ static int ocfs2_verify_volume(struct ocfs2_dinode *di, | |||
| 2396 | { | 2369 | { |
| 2397 | int status = -EAGAIN; | 2370 | int status = -EAGAIN; |
| 2398 | 2371 | ||
| 2399 | mlog_entry_void(); | ||
| 2400 | |||
| 2401 | if (memcmp(di->i_signature, OCFS2_SUPER_BLOCK_SIGNATURE, | 2372 | if (memcmp(di->i_signature, OCFS2_SUPER_BLOCK_SIGNATURE, |
| 2402 | strlen(OCFS2_SUPER_BLOCK_SIGNATURE)) == 0) { | 2373 | strlen(OCFS2_SUPER_BLOCK_SIGNATURE)) == 0) { |
| 2403 | /* We have to do a raw check of the feature here */ | 2374 | /* We have to do a raw check of the feature here */ |
| @@ -2452,7 +2423,8 @@ static int ocfs2_verify_volume(struct ocfs2_dinode *di, | |||
| 2452 | } | 2423 | } |
| 2453 | 2424 | ||
| 2454 | out: | 2425 | out: |
| 2455 | mlog_exit(status); | 2426 | if (status && status != -EAGAIN) |
| 2427 | mlog_errno(status); | ||
| 2456 | return status; | 2428 | return status; |
| 2457 | } | 2429 | } |
| 2458 | 2430 | ||
| @@ -2465,8 +2437,6 @@ static int ocfs2_check_volume(struct ocfs2_super *osb) | |||
| 2465 | * recover | 2437 | * recover |
| 2466 | * ourselves. */ | 2438 | * ourselves. */ |
| 2467 | 2439 | ||
| 2468 | mlog_entry_void(); | ||
| 2469 | |||
| 2470 | /* Init our journal object. */ | 2440 | /* Init our journal object. */ |
| 2471 | status = ocfs2_journal_init(osb->journal, &dirty); | 2441 | status = ocfs2_journal_init(osb->journal, &dirty); |
| 2472 | if (status < 0) { | 2442 | if (status < 0) { |
| @@ -2516,8 +2486,6 @@ static int ocfs2_check_volume(struct ocfs2_super *osb) | |||
| 2516 | * ourselves as mounted. */ | 2486 | * ourselves as mounted. */ |
| 2517 | } | 2487 | } |
| 2518 | 2488 | ||
| 2519 | mlog(0, "Journal loaded.\n"); | ||
| 2520 | |||
| 2521 | status = ocfs2_load_local_alloc(osb); | 2489 | status = ocfs2_load_local_alloc(osb); |
| 2522 | if (status < 0) { | 2490 | if (status < 0) { |
| 2523 | mlog_errno(status); | 2491 | mlog_errno(status); |
| @@ -2549,7 +2517,8 @@ finally: | |||
| 2549 | if (local_alloc) | 2517 | if (local_alloc) |
| 2550 | kfree(local_alloc); | 2518 | kfree(local_alloc); |
| 2551 | 2519 | ||
| 2552 | mlog_exit(status); | 2520 | if (status) |
| 2521 | mlog_errno(status); | ||
| 2553 | return status; | 2522 | return status; |
| 2554 | } | 2523 | } |
| 2555 | 2524 | ||
| @@ -2561,8 +2530,6 @@ finally: | |||
| 2561 | */ | 2530 | */ |
| 2562 | static void ocfs2_delete_osb(struct ocfs2_super *osb) | 2531 | static void ocfs2_delete_osb(struct ocfs2_super *osb) |
| 2563 | { | 2532 | { |
| 2564 | mlog_entry_void(); | ||
| 2565 | |||
| 2566 | /* This function assumes that the caller has the main osb resource */ | 2533 | /* This function assumes that the caller has the main osb resource */ |
| 2567 | 2534 | ||
| 2568 | ocfs2_free_slot_info(osb); | 2535 | ocfs2_free_slot_info(osb); |
| @@ -2580,8 +2547,6 @@ static void ocfs2_delete_osb(struct ocfs2_super *osb) | |||
| 2580 | kfree(osb->uuid_str); | 2547 | kfree(osb->uuid_str); |
| 2581 | ocfs2_put_dlm_debug(osb->osb_dlm_debug); | 2548 | ocfs2_put_dlm_debug(osb->osb_dlm_debug); |
| 2582 | memset(osb, 0, sizeof(struct ocfs2_super)); | 2549 | memset(osb, 0, sizeof(struct ocfs2_super)); |
| 2583 | |||
| 2584 | mlog_exit_void(); | ||
| 2585 | } | 2550 | } |
| 2586 | 2551 | ||
| 2587 | /* Put OCFS2 into a readonly state, or (if the user specifies it), | 2552 | /* Put OCFS2 into a readonly state, or (if the user specifies it), |
diff --git a/fs/ocfs2/symlink.c b/fs/ocfs2/symlink.c index 9975457c981..5d22872e2bb 100644 --- a/fs/ocfs2/symlink.c +++ b/fs/ocfs2/symlink.c | |||
| @@ -40,7 +40,6 @@ | |||
| 40 | #include <linux/pagemap.h> | 40 | #include <linux/pagemap.h> |
| 41 | #include <linux/namei.h> | 41 | #include <linux/namei.h> |
| 42 | 42 | ||
| 43 | #define MLOG_MASK_PREFIX ML_NAMEI | ||
| 44 | #include <cluster/masklog.h> | 43 | #include <cluster/masklog.h> |
| 45 | 44 | ||
| 46 | #include "ocfs2.h" | 45 | #include "ocfs2.h" |
| @@ -62,8 +61,6 @@ static char *ocfs2_fast_symlink_getlink(struct inode *inode, | |||
| 62 | char *link = NULL; | 61 | char *link = NULL; |
| 63 | struct ocfs2_dinode *fe; | 62 | struct ocfs2_dinode *fe; |
| 64 | 63 | ||
| 65 | mlog_entry_void(); | ||
| 66 | |||
| 67 | status = ocfs2_read_inode_block(inode, bh); | 64 | status = ocfs2_read_inode_block(inode, bh); |
| 68 | if (status < 0) { | 65 | if (status < 0) { |
| 69 | mlog_errno(status); | 66 | mlog_errno(status); |
| @@ -74,7 +71,6 @@ static char *ocfs2_fast_symlink_getlink(struct inode *inode, | |||
| 74 | fe = (struct ocfs2_dinode *) (*bh)->b_data; | 71 | fe = (struct ocfs2_dinode *) (*bh)->b_data; |
| 75 | link = (char *) fe->id2.i_symlink; | 72 | link = (char *) fe->id2.i_symlink; |
| 76 | bail: | 73 | bail: |
| 77 | mlog_exit(status); | ||
| 78 | 74 | ||
| 79 | return link; | 75 | return link; |
| 80 | } | 76 | } |
| @@ -88,8 +84,6 @@ static int ocfs2_readlink(struct dentry *dentry, | |||
| 88 | struct buffer_head *bh = NULL; | 84 | struct buffer_head *bh = NULL; |
| 89 | struct inode *inode = dentry->d_inode; | 85 | struct inode *inode = dentry->d_inode; |
| 90 | 86 | ||
| 91 | mlog_entry_void(); | ||
| 92 | |||
| 93 | link = ocfs2_fast_symlink_getlink(inode, &bh); | 87 | link = ocfs2_fast_symlink_getlink(inode, &bh); |
| 94 | if (IS_ERR(link)) { | 88 | if (IS_ERR(link)) { |
| 95 | ret = PTR_ERR(link); | 89 | ret = PTR_ERR(link); |
| @@ -104,7 +98,8 @@ static int ocfs2_readlink(struct dentry *dentry, | |||
| 104 | 98 | ||
| 105 | brelse(bh); | 99 | brelse(bh); |
| 106 | out: | 100 | out: |
| 107 | mlog_exit(ret); | 101 | if (ret < 0) |
| 102 | mlog_errno(ret); | ||
| 108 | return ret; | 103 | return ret; |
| 109 | } | 104 | } |
| 110 | 105 | ||
| @@ -117,8 +112,6 @@ static void *ocfs2_fast_follow_link(struct dentry *dentry, | |||
| 117 | struct inode *inode = dentry->d_inode; | 112 | struct inode *inode = dentry->d_inode; |
| 118 | struct buffer_head *bh = NULL; | 113 | struct buffer_head *bh = NULL; |
| 119 | 114 | ||
| 120 | mlog_entry_void(); | ||
| 121 | |||
| 122 | BUG_ON(!ocfs2_inode_is_fast_symlink(inode)); | 115 | BUG_ON(!ocfs2_inode_is_fast_symlink(inode)); |
| 123 | target = ocfs2_fast_symlink_getlink(inode, &bh); | 116 | target = ocfs2_fast_symlink_getlink(inode, &bh); |
| 124 | if (IS_ERR(target)) { | 117 | if (IS_ERR(target)) { |
| @@ -142,7 +135,8 @@ bail: | |||
| 142 | nd_set_link(nd, status ? ERR_PTR(status) : link); | 135 | nd_set_link(nd, status ? ERR_PTR(status) : link); |
| 143 | brelse(bh); | 136 | brelse(bh); |
| 144 | 137 | ||
| 145 | mlog_exit(status); | 138 | if (status) |
| 139 | mlog_errno(status); | ||
| 146 | return NULL; | 140 | return NULL; |
| 147 | } | 141 | } |
| 148 | 142 | ||
diff --git a/fs/ocfs2/sysfile.c b/fs/ocfs2/sysfile.c index 902efb23b6a..3d635f4bbb2 100644 --- a/fs/ocfs2/sysfile.c +++ b/fs/ocfs2/sysfile.c | |||
| @@ -27,7 +27,6 @@ | |||
| 27 | #include <linux/types.h> | 27 | #include <linux/types.h> |
| 28 | #include <linux/highmem.h> | 28 | #include <linux/highmem.h> |
| 29 | 29 | ||
| 30 | #define MLOG_MASK_PREFIX ML_INODE | ||
| 31 | #include <cluster/masklog.h> | 30 | #include <cluster/masklog.h> |
| 32 | 31 | ||
| 33 | #include "ocfs2.h" | 32 | #include "ocfs2.h" |
diff --git a/fs/ocfs2/uptodate.c b/fs/ocfs2/uptodate.c index a0a120e82b9..52eaf33d346 100644 --- a/fs/ocfs2/uptodate.c +++ b/fs/ocfs2/uptodate.c | |||
| @@ -54,14 +54,13 @@ | |||
| 54 | #include <linux/buffer_head.h> | 54 | #include <linux/buffer_head.h> |
| 55 | #include <linux/rbtree.h> | 55 | #include <linux/rbtree.h> |
| 56 | 56 | ||
| 57 | #define MLOG_MASK_PREFIX ML_UPTODATE | ||
| 58 | |||
| 59 | #include <cluster/masklog.h> | 57 | #include <cluster/masklog.h> |
| 60 | 58 | ||
| 61 | #include "ocfs2.h" | 59 | #include "ocfs2.h" |
| 62 | 60 | ||
| 63 | #include "inode.h" | 61 | #include "inode.h" |
| 64 | #include "uptodate.h" | 62 | #include "uptodate.h" |
| 63 | #include "ocfs2_trace.h" | ||
| 65 | 64 | ||
| 66 | struct ocfs2_meta_cache_item { | 65 | struct ocfs2_meta_cache_item { |
| 67 | struct rb_node c_node; | 66 | struct rb_node c_node; |
| @@ -152,8 +151,8 @@ static unsigned int ocfs2_purge_copied_metadata_tree(struct rb_root *root) | |||
| 152 | while ((node = rb_last(root)) != NULL) { | 151 | while ((node = rb_last(root)) != NULL) { |
| 153 | item = rb_entry(node, struct ocfs2_meta_cache_item, c_node); | 152 | item = rb_entry(node, struct ocfs2_meta_cache_item, c_node); |
| 154 | 153 | ||
| 155 | mlog(0, "Purge item %llu\n", | 154 | trace_ocfs2_purge_copied_metadata_tree( |
| 156 | (unsigned long long) item->c_block); | 155 | (unsigned long long) item->c_block); |
| 157 | 156 | ||
| 158 | rb_erase(&item->c_node, root); | 157 | rb_erase(&item->c_node, root); |
| 159 | kmem_cache_free(ocfs2_uptodate_cachep, item); | 158 | kmem_cache_free(ocfs2_uptodate_cachep, item); |
| @@ -180,9 +179,9 @@ void ocfs2_metadata_cache_purge(struct ocfs2_caching_info *ci) | |||
| 180 | tree = !(ci->ci_flags & OCFS2_CACHE_FL_INLINE); | 179 | tree = !(ci->ci_flags & OCFS2_CACHE_FL_INLINE); |
| 181 | to_purge = ci->ci_num_cached; | 180 | to_purge = ci->ci_num_cached; |
| 182 | 181 | ||
| 183 | mlog(0, "Purge %u %s items from Owner %llu\n", to_purge, | 182 | trace_ocfs2_metadata_cache_purge( |
| 184 | tree ? "array" : "tree", | 183 | (unsigned long long)ocfs2_metadata_cache_owner(ci), |
| 185 | (unsigned long long)ocfs2_metadata_cache_owner(ci)); | 184 | to_purge, tree); |
| 186 | 185 | ||
| 187 | /* If we're a tree, save off the root so that we can safely | 186 | /* If we're a tree, save off the root so that we can safely |
| 188 | * initialize the cache. We do the work to free tree members | 187 | * initialize the cache. We do the work to free tree members |
| @@ -249,10 +248,10 @@ static int ocfs2_buffer_cached(struct ocfs2_caching_info *ci, | |||
| 249 | 248 | ||
| 250 | ocfs2_metadata_cache_lock(ci); | 249 | ocfs2_metadata_cache_lock(ci); |
| 251 | 250 | ||
| 252 | mlog(0, "Owner %llu, query block %llu (inline = %u)\n", | 251 | trace_ocfs2_buffer_cached_begin( |
| 253 | (unsigned long long)ocfs2_metadata_cache_owner(ci), | 252 | (unsigned long long)ocfs2_metadata_cache_owner(ci), |
| 254 | (unsigned long long) bh->b_blocknr, | 253 | (unsigned long long) bh->b_blocknr, |
| 255 | !!(ci->ci_flags & OCFS2_CACHE_FL_INLINE)); | 254 | !!(ci->ci_flags & OCFS2_CACHE_FL_INLINE)); |
| 256 | 255 | ||
| 257 | if (ci->ci_flags & OCFS2_CACHE_FL_INLINE) | 256 | if (ci->ci_flags & OCFS2_CACHE_FL_INLINE) |
| 258 | index = ocfs2_search_cache_array(ci, bh->b_blocknr); | 257 | index = ocfs2_search_cache_array(ci, bh->b_blocknr); |
| @@ -261,7 +260,7 @@ static int ocfs2_buffer_cached(struct ocfs2_caching_info *ci, | |||
| 261 | 260 | ||
| 262 | ocfs2_metadata_cache_unlock(ci); | 261 | ocfs2_metadata_cache_unlock(ci); |
| 263 | 262 | ||
| 264 | mlog(0, "index = %d, item = %p\n", index, item); | 263 | trace_ocfs2_buffer_cached_end(index, item); |
| 265 | 264 | ||
| 266 | return (index != -1) || (item != NULL); | 265 | return (index != -1) || (item != NULL); |
| 267 | } | 266 | } |
| @@ -306,8 +305,9 @@ static void ocfs2_append_cache_array(struct ocfs2_caching_info *ci, | |||
| 306 | { | 305 | { |
| 307 | BUG_ON(ci->ci_num_cached >= OCFS2_CACHE_INFO_MAX_ARRAY); | 306 | BUG_ON(ci->ci_num_cached >= OCFS2_CACHE_INFO_MAX_ARRAY); |
| 308 | 307 | ||
| 309 | mlog(0, "block %llu takes position %u\n", (unsigned long long) block, | 308 | trace_ocfs2_append_cache_array( |
| 310 | ci->ci_num_cached); | 309 | (unsigned long long)ocfs2_metadata_cache_owner(ci), |
| 310 | (unsigned long long)block, ci->ci_num_cached); | ||
| 311 | 311 | ||
| 312 | ci->ci_cache.ci_array[ci->ci_num_cached] = block; | 312 | ci->ci_cache.ci_array[ci->ci_num_cached] = block; |
| 313 | ci->ci_num_cached++; | 313 | ci->ci_num_cached++; |
| @@ -324,8 +324,9 @@ static void __ocfs2_insert_cache_tree(struct ocfs2_caching_info *ci, | |||
| 324 | struct rb_node **p = &ci->ci_cache.ci_tree.rb_node; | 324 | struct rb_node **p = &ci->ci_cache.ci_tree.rb_node; |
| 325 | struct ocfs2_meta_cache_item *tmp; | 325 | struct ocfs2_meta_cache_item *tmp; |
| 326 | 326 | ||
| 327 | mlog(0, "Insert block %llu num = %u\n", (unsigned long long) block, | 327 | trace_ocfs2_insert_cache_tree( |
| 328 | ci->ci_num_cached); | 328 | (unsigned long long)ocfs2_metadata_cache_owner(ci), |
| 329 | (unsigned long long)block, ci->ci_num_cached); | ||
| 329 | 330 | ||
| 330 | while(*p) { | 331 | while(*p) { |
| 331 | parent = *p; | 332 | parent = *p; |
| @@ -389,9 +390,9 @@ static void ocfs2_expand_cache(struct ocfs2_caching_info *ci, | |||
| 389 | tree[i] = NULL; | 390 | tree[i] = NULL; |
| 390 | } | 391 | } |
| 391 | 392 | ||
| 392 | mlog(0, "Expanded %llu to a tree cache: flags 0x%x, num = %u\n", | 393 | trace_ocfs2_expand_cache( |
| 393 | (unsigned long long)ocfs2_metadata_cache_owner(ci), | 394 | (unsigned long long)ocfs2_metadata_cache_owner(ci), |
| 394 | ci->ci_flags, ci->ci_num_cached); | 395 | ci->ci_flags, ci->ci_num_cached); |
| 395 | } | 396 | } |
| 396 | 397 | ||
| 397 | /* Slow path function - memory allocation is necessary. See the | 398 | /* Slow path function - memory allocation is necessary. See the |
| @@ -405,9 +406,9 @@ static void __ocfs2_set_buffer_uptodate(struct ocfs2_caching_info *ci, | |||
| 405 | struct ocfs2_meta_cache_item *tree[OCFS2_CACHE_INFO_MAX_ARRAY] = | 406 | struct ocfs2_meta_cache_item *tree[OCFS2_CACHE_INFO_MAX_ARRAY] = |
| 406 | { NULL, }; | 407 | { NULL, }; |
| 407 | 408 | ||
| 408 | mlog(0, "Owner %llu, block %llu, expand = %d\n", | 409 | trace_ocfs2_set_buffer_uptodate( |
| 409 | (unsigned long long)ocfs2_metadata_cache_owner(ci), | 410 | (unsigned long long)ocfs2_metadata_cache_owner(ci), |
| 410 | (unsigned long long)block, expand_tree); | 411 | (unsigned long long)block, expand_tree); |
| 411 | 412 | ||
| 412 | new = kmem_cache_alloc(ocfs2_uptodate_cachep, GFP_NOFS); | 413 | new = kmem_cache_alloc(ocfs2_uptodate_cachep, GFP_NOFS); |
| 413 | if (!new) { | 414 | if (!new) { |
| @@ -433,7 +434,6 @@ static void __ocfs2_set_buffer_uptodate(struct ocfs2_caching_info *ci, | |||
| 433 | 434 | ||
| 434 | ocfs2_metadata_cache_lock(ci); | 435 | ocfs2_metadata_cache_lock(ci); |
| 435 | if (ocfs2_insert_can_use_array(ci)) { | 436 | if (ocfs2_insert_can_use_array(ci)) { |
| 436 | mlog(0, "Someone cleared the tree underneath us\n"); | ||
| 437 | /* Ok, items were removed from the cache in between | 437 | /* Ok, items were removed from the cache in between |
| 438 | * locks. Detect this and revert back to the fast path */ | 438 | * locks. Detect this and revert back to the fast path */ |
| 439 | ocfs2_append_cache_array(ci, block); | 439 | ocfs2_append_cache_array(ci, block); |
| @@ -490,9 +490,9 @@ void ocfs2_set_buffer_uptodate(struct ocfs2_caching_info *ci, | |||
| 490 | if (ocfs2_buffer_cached(ci, bh)) | 490 | if (ocfs2_buffer_cached(ci, bh)) |
| 491 | return; | 491 | return; |
| 492 | 492 | ||
| 493 | mlog(0, "Owner %llu, inserting block %llu\n", | 493 | trace_ocfs2_set_buffer_uptodate_begin( |
| 494 | (unsigned long long)ocfs2_metadata_cache_owner(ci), | 494 | (unsigned long long)ocfs2_metadata_cache_owner(ci), |
| 495 | (unsigned long long)bh->b_blocknr); | 495 | (unsigned long long)bh->b_blocknr); |
| 496 | 496 | ||
| 497 | /* No need to recheck under spinlock - insertion is guarded by | 497 | /* No need to recheck under spinlock - insertion is guarded by |
| 498 | * co_io_lock() */ | 498 | * co_io_lock() */ |
| @@ -542,8 +542,9 @@ static void ocfs2_remove_metadata_array(struct ocfs2_caching_info *ci, | |||
| 542 | BUG_ON(index >= ci->ci_num_cached); | 542 | BUG_ON(index >= ci->ci_num_cached); |
| 543 | BUG_ON(!ci->ci_num_cached); | 543 | BUG_ON(!ci->ci_num_cached); |
| 544 | 544 | ||
| 545 | mlog(0, "remove index %d (num_cached = %u\n", index, | 545 | trace_ocfs2_remove_metadata_array( |
| 546 | ci->ci_num_cached); | 546 | (unsigned long long)ocfs2_metadata_cache_owner(ci), |
| 547 | index, ci->ci_num_cached); | ||
| 547 | 548 | ||
| 548 | ci->ci_num_cached--; | 549 | ci->ci_num_cached--; |
| 549 | 550 | ||
| @@ -559,8 +560,9 @@ static void ocfs2_remove_metadata_array(struct ocfs2_caching_info *ci, | |||
| 559 | static void ocfs2_remove_metadata_tree(struct ocfs2_caching_info *ci, | 560 | static void ocfs2_remove_metadata_tree(struct ocfs2_caching_info *ci, |
| 560 | struct ocfs2_meta_cache_item *item) | 561 | struct ocfs2_meta_cache_item *item) |
| 561 | { | 562 | { |
| 562 | mlog(0, "remove block %llu from tree\n", | 563 | trace_ocfs2_remove_metadata_tree( |
| 563 | (unsigned long long) item->c_block); | 564 | (unsigned long long)ocfs2_metadata_cache_owner(ci), |
| 565 | (unsigned long long)item->c_block); | ||
| 564 | 566 | ||
| 565 | rb_erase(&item->c_node, &ci->ci_cache.ci_tree); | 567 | rb_erase(&item->c_node, &ci->ci_cache.ci_tree); |
| 566 | ci->ci_num_cached--; | 568 | ci->ci_num_cached--; |
| @@ -573,10 +575,10 @@ static void ocfs2_remove_block_from_cache(struct ocfs2_caching_info *ci, | |||
| 573 | struct ocfs2_meta_cache_item *item = NULL; | 575 | struct ocfs2_meta_cache_item *item = NULL; |
| 574 | 576 | ||
| 575 | ocfs2_metadata_cache_lock(ci); | 577 | ocfs2_metadata_cache_lock(ci); |
| 576 | mlog(0, "Owner %llu, remove %llu, items = %u, array = %u\n", | 578 | trace_ocfs2_remove_block_from_cache( |
| 577 | (unsigned long long)ocfs2_metadata_cache_owner(ci), | 579 | (unsigned long long)ocfs2_metadata_cache_owner(ci), |
| 578 | (unsigned long long) block, ci->ci_num_cached, | 580 | (unsigned long long) block, ci->ci_num_cached, |
| 579 | ci->ci_flags & OCFS2_CACHE_FL_INLINE); | 581 | ci->ci_flags); |
| 580 | 582 | ||
| 581 | if (ci->ci_flags & OCFS2_CACHE_FL_INLINE) { | 583 | if (ci->ci_flags & OCFS2_CACHE_FL_INLINE) { |
| 582 | index = ocfs2_search_cache_array(ci, block); | 584 | index = ocfs2_search_cache_array(ci, block); |
| @@ -626,9 +628,6 @@ int __init init_ocfs2_uptodate_cache(void) | |||
| 626 | if (!ocfs2_uptodate_cachep) | 628 | if (!ocfs2_uptodate_cachep) |
| 627 | return -ENOMEM; | 629 | return -ENOMEM; |
| 628 | 630 | ||
| 629 | mlog(0, "%u inlined cache items per inode.\n", | ||
| 630 | OCFS2_CACHE_INFO_MAX_ARRAY); | ||
| 631 | |||
| 632 | return 0; | 631 | return 0; |
| 633 | } | 632 | } |
| 634 | 633 | ||
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c index 6bb602486c6..57a215dc2d9 100644 --- a/fs/ocfs2/xattr.c +++ b/fs/ocfs2/xattr.c | |||
| @@ -37,7 +37,6 @@ | |||
| 37 | #include <linux/string.h> | 37 | #include <linux/string.h> |
| 38 | #include <linux/security.h> | 38 | #include <linux/security.h> |
| 39 | 39 | ||
| 40 | #define MLOG_MASK_PREFIX ML_XATTR | ||
| 41 | #include <cluster/masklog.h> | 40 | #include <cluster/masklog.h> |
| 42 | 41 | ||
| 43 | #include "ocfs2.h" | 42 | #include "ocfs2.h" |
| @@ -57,6 +56,7 @@ | |||
| 57 | #include "xattr.h" | 56 | #include "xattr.h" |
| 58 | #include "refcounttree.h" | 57 | #include "refcounttree.h" |
| 59 | #include "acl.h" | 58 | #include "acl.h" |
| 59 | #include "ocfs2_trace.h" | ||
| 60 | 60 | ||
| 61 | struct ocfs2_xattr_def_value_root { | 61 | struct ocfs2_xattr_def_value_root { |
| 62 | struct ocfs2_xattr_value_root xv; | 62 | struct ocfs2_xattr_value_root xv; |
| @@ -474,8 +474,7 @@ static int ocfs2_validate_xattr_block(struct super_block *sb, | |||
| 474 | struct ocfs2_xattr_block *xb = | 474 | struct ocfs2_xattr_block *xb = |
| 475 | (struct ocfs2_xattr_block *)bh->b_data; | 475 | (struct ocfs2_xattr_block *)bh->b_data; |
| 476 | 476 | ||
| 477 | mlog(0, "Validating xattr block %llu\n", | 477 | trace_ocfs2_validate_xattr_block((unsigned long long)bh->b_blocknr); |
| 478 | (unsigned long long)bh->b_blocknr); | ||
| 479 | 478 | ||
| 480 | BUG_ON(!buffer_uptodate(bh)); | 479 | BUG_ON(!buffer_uptodate(bh)); |
| 481 | 480 | ||
| @@ -715,11 +714,11 @@ static int ocfs2_xattr_extend_allocation(struct inode *inode, | |||
| 715 | u32 prev_clusters, logical_start = le32_to_cpu(vb->vb_xv->xr_clusters); | 714 | u32 prev_clusters, logical_start = le32_to_cpu(vb->vb_xv->xr_clusters); |
| 716 | struct ocfs2_extent_tree et; | 715 | struct ocfs2_extent_tree et; |
| 717 | 716 | ||
| 718 | mlog(0, "(clusters_to_add for xattr= %u)\n", clusters_to_add); | ||
| 719 | |||
| 720 | ocfs2_init_xattr_value_extent_tree(&et, INODE_CACHE(inode), vb); | 717 | ocfs2_init_xattr_value_extent_tree(&et, INODE_CACHE(inode), vb); |
| 721 | 718 | ||
| 722 | while (clusters_to_add) { | 719 | while (clusters_to_add) { |
| 720 | trace_ocfs2_xattr_extend_allocation(clusters_to_add); | ||
| 721 | |||
| 723 | status = vb->vb_access(handle, INODE_CACHE(inode), vb->vb_bh, | 722 | status = vb->vb_access(handle, INODE_CACHE(inode), vb->vb_bh, |
| 724 | OCFS2_JOURNAL_ACCESS_WRITE); | 723 | OCFS2_JOURNAL_ACCESS_WRITE); |
| 725 | if (status < 0) { | 724 | if (status < 0) { |
| @@ -754,8 +753,6 @@ static int ocfs2_xattr_extend_allocation(struct inode *inode, | |||
| 754 | */ | 753 | */ |
| 755 | BUG_ON(why == RESTART_META); | 754 | BUG_ON(why == RESTART_META); |
| 756 | 755 | ||
| 757 | mlog(0, "restarting xattr value extension for %u" | ||
| 758 | " clusters,.\n", clusters_to_add); | ||
| 759 | credits = ocfs2_calc_extend_credits(inode->i_sb, | 756 | credits = ocfs2_calc_extend_credits(inode->i_sb, |
| 760 | &vb->vb_xv->xr_list, | 757 | &vb->vb_xv->xr_list, |
| 761 | clusters_to_add); | 758 | clusters_to_add); |
| @@ -3246,8 +3243,8 @@ static int ocfs2_init_xattr_set_ctxt(struct inode *inode, | |||
| 3246 | } | 3243 | } |
| 3247 | 3244 | ||
| 3248 | meta_add += extra_meta; | 3245 | meta_add += extra_meta; |
| 3249 | mlog(0, "Set xattr %s, reserve meta blocks = %d, clusters = %d, " | 3246 | trace_ocfs2_init_xattr_set_ctxt(xi->xi_name, meta_add, |
| 3250 | "credits = %d\n", xi->xi_name, meta_add, clusters_add, *credits); | 3247 | clusters_add, *credits); |
| 3251 | 3248 | ||
| 3252 | if (meta_add) { | 3249 | if (meta_add) { |
| 3253 | ret = ocfs2_reserve_new_metadata_blocks(osb, meta_add, | 3250 | ret = ocfs2_reserve_new_metadata_blocks(osb, meta_add, |
| @@ -3887,8 +3884,10 @@ static int ocfs2_xattr_bucket_find(struct inode *inode, | |||
| 3887 | 3884 | ||
| 3888 | if (found) { | 3885 | if (found) { |
| 3889 | xs->here = &xs->header->xh_entries[index]; | 3886 | xs->here = &xs->header->xh_entries[index]; |
| 3890 | mlog(0, "find xattr %s in bucket %llu, entry = %u\n", name, | 3887 | trace_ocfs2_xattr_bucket_find(OCFS2_I(inode)->ip_blkno, |
| 3891 | (unsigned long long)bucket_blkno(xs->bucket), index); | 3888 | name, name_index, name_hash, |
| 3889 | (unsigned long long)bucket_blkno(xs->bucket), | ||
| 3890 | index); | ||
| 3892 | } else | 3891 | } else |
| 3893 | ret = -ENODATA; | 3892 | ret = -ENODATA; |
| 3894 | 3893 | ||
| @@ -3915,8 +3914,10 @@ static int ocfs2_xattr_index_block_find(struct inode *inode, | |||
| 3915 | if (le16_to_cpu(el->l_next_free_rec) == 0) | 3914 | if (le16_to_cpu(el->l_next_free_rec) == 0) |
| 3916 | return -ENODATA; | 3915 | return -ENODATA; |
| 3917 | 3916 | ||
| 3918 | mlog(0, "find xattr %s, hash = %u, index = %d in xattr tree\n", | 3917 | trace_ocfs2_xattr_index_block_find(OCFS2_I(inode)->ip_blkno, |
| 3919 | name, name_hash, name_index); | 3918 | name, name_index, name_hash, |
| 3919 | (unsigned long long)root_bh->b_blocknr, | ||
| 3920 | -1); | ||
| 3920 | 3921 | ||
| 3921 | ret = ocfs2_xattr_get_rec(inode, name_hash, &p_blkno, &first_hash, | 3922 | ret = ocfs2_xattr_get_rec(inode, name_hash, &p_blkno, &first_hash, |
| 3922 | &num_clusters, el); | 3923 | &num_clusters, el); |
| @@ -3927,9 +3928,10 @@ static int ocfs2_xattr_index_block_find(struct inode *inode, | |||
| 3927 | 3928 | ||
| 3928 | BUG_ON(p_blkno == 0 || num_clusters == 0 || first_hash > name_hash); | 3929 | BUG_ON(p_blkno == 0 || num_clusters == 0 || first_hash > name_hash); |
| 3929 | 3930 | ||
| 3930 | mlog(0, "find xattr extent rec %u clusters from %llu, the first hash " | 3931 | trace_ocfs2_xattr_index_block_find_rec(OCFS2_I(inode)->ip_blkno, |
| 3931 | "in the rec is %u\n", num_clusters, (unsigned long long)p_blkno, | 3932 | name, name_index, first_hash, |
| 3932 | first_hash); | 3933 | (unsigned long long)p_blkno, |
| 3934 | num_clusters); | ||
| 3933 | 3935 | ||
| 3934 | ret = ocfs2_xattr_bucket_find(inode, name_index, name, name_hash, | 3936 | ret = ocfs2_xattr_bucket_find(inode, name_index, name, name_hash, |
| 3935 | p_blkno, first_hash, num_clusters, xs); | 3937 | p_blkno, first_hash, num_clusters, xs); |
| @@ -3955,8 +3957,9 @@ static int ocfs2_iterate_xattr_buckets(struct inode *inode, | |||
| 3955 | return -ENOMEM; | 3957 | return -ENOMEM; |
| 3956 | } | 3958 | } |
| 3957 | 3959 | ||
| 3958 | mlog(0, "iterating xattr buckets in %u clusters starting from %llu\n", | 3960 | trace_ocfs2_iterate_xattr_buckets( |
| 3959 | clusters, (unsigned long long)blkno); | 3961 | (unsigned long long)OCFS2_I(inode)->ip_blkno, |
| 3962 | (unsigned long long)blkno, clusters); | ||
| 3960 | 3963 | ||
| 3961 | for (i = 0; i < num_buckets; i++, blkno += bucket->bu_blocks) { | 3964 | for (i = 0; i < num_buckets; i++, blkno += bucket->bu_blocks) { |
| 3962 | ret = ocfs2_read_xattr_bucket(bucket, blkno); | 3965 | ret = ocfs2_read_xattr_bucket(bucket, blkno); |
| @@ -3972,8 +3975,7 @@ static int ocfs2_iterate_xattr_buckets(struct inode *inode, | |||
| 3972 | if (i == 0) | 3975 | if (i == 0) |
| 3973 | num_buckets = le16_to_cpu(bucket_xh(bucket)->xh_num_buckets); | 3976 | num_buckets = le16_to_cpu(bucket_xh(bucket)->xh_num_buckets); |
| 3974 | 3977 | ||
| 3975 | mlog(0, "iterating xattr bucket %llu, first hash %u\n", | 3978 | trace_ocfs2_iterate_xattr_bucket((unsigned long long)blkno, |
| 3976 | (unsigned long long)blkno, | ||
| 3977 | le32_to_cpu(bucket_xh(bucket)->xh_entries[0].xe_name_hash)); | 3979 | le32_to_cpu(bucket_xh(bucket)->xh_entries[0].xe_name_hash)); |
| 3978 | if (func) { | 3980 | if (func) { |
| 3979 | ret = func(inode, bucket, para); | 3981 | ret = func(inode, bucket, para); |
| @@ -4173,9 +4175,9 @@ static void ocfs2_cp_xattr_block_to_bucket(struct inode *inode, | |||
| 4173 | char *src = xb_bh->b_data; | 4175 | char *src = xb_bh->b_data; |
| 4174 | char *target = bucket_block(bucket, blks - 1); | 4176 | char *target = bucket_block(bucket, blks - 1); |
| 4175 | 4177 | ||
| 4176 | mlog(0, "cp xattr from block %llu to bucket %llu\n", | 4178 | trace_ocfs2_cp_xattr_block_to_bucket_begin( |
| 4177 | (unsigned long long)xb_bh->b_blocknr, | 4179 | (unsigned long long)xb_bh->b_blocknr, |
| 4178 | (unsigned long long)bucket_blkno(bucket)); | 4180 | (unsigned long long)bucket_blkno(bucket)); |
| 4179 | 4181 | ||
| 4180 | for (i = 0; i < blks; i++) | 4182 | for (i = 0; i < blks; i++) |
| 4181 | memset(bucket_block(bucket, i), 0, blocksize); | 4183 | memset(bucket_block(bucket, i), 0, blocksize); |
| @@ -4211,8 +4213,7 @@ static void ocfs2_cp_xattr_block_to_bucket(struct inode *inode, | |||
| 4211 | for (i = 0; i < count; i++) | 4213 | for (i = 0; i < count; i++) |
| 4212 | le16_add_cpu(&xh->xh_entries[i].xe_name_offset, off_change); | 4214 | le16_add_cpu(&xh->xh_entries[i].xe_name_offset, off_change); |
| 4213 | 4215 | ||
| 4214 | mlog(0, "copy entry: start = %u, size = %u, offset_change = %u\n", | 4216 | trace_ocfs2_cp_xattr_block_to_bucket_end(offset, size, off_change); |
| 4215 | offset, size, off_change); | ||
| 4216 | 4217 | ||
| 4217 | sort(target + offset, count, sizeof(struct ocfs2_xattr_entry), | 4218 | sort(target + offset, count, sizeof(struct ocfs2_xattr_entry), |
| 4218 | cmp_xe, swap_xe); | 4219 | cmp_xe, swap_xe); |
| @@ -4261,8 +4262,8 @@ static int ocfs2_xattr_create_index_block(struct inode *inode, | |||
| 4261 | struct ocfs2_xattr_tree_root *xr; | 4262 | struct ocfs2_xattr_tree_root *xr; |
| 4262 | u16 xb_flags = le16_to_cpu(xb->xb_flags); | 4263 | u16 xb_flags = le16_to_cpu(xb->xb_flags); |
| 4263 | 4264 | ||
| 4264 | mlog(0, "create xattr index block for %llu\n", | 4265 | trace_ocfs2_xattr_create_index_block_begin( |
| 4265 | (unsigned long long)xb_bh->b_blocknr); | 4266 | (unsigned long long)xb_bh->b_blocknr); |
| 4266 | 4267 | ||
| 4267 | BUG_ON(xb_flags & OCFS2_XATTR_INDEXED); | 4268 | BUG_ON(xb_flags & OCFS2_XATTR_INDEXED); |
| 4268 | BUG_ON(!xs->bucket); | 4269 | BUG_ON(!xs->bucket); |
| @@ -4295,8 +4296,7 @@ static int ocfs2_xattr_create_index_block(struct inode *inode, | |||
| 4295 | */ | 4296 | */ |
| 4296 | blkno = ocfs2_clusters_to_blocks(inode->i_sb, bit_off); | 4297 | blkno = ocfs2_clusters_to_blocks(inode->i_sb, bit_off); |
| 4297 | 4298 | ||
| 4298 | mlog(0, "allocate 1 cluster from %llu to xattr block\n", | 4299 | trace_ocfs2_xattr_create_index_block((unsigned long long)blkno); |
| 4299 | (unsigned long long)blkno); | ||
| 4300 | 4300 | ||
| 4301 | ret = ocfs2_init_xattr_bucket(xs->bucket, blkno); | 4301 | ret = ocfs2_init_xattr_bucket(xs->bucket, blkno); |
| 4302 | if (ret) { | 4302 | if (ret) { |
| @@ -4400,8 +4400,7 @@ static int ocfs2_defrag_xattr_bucket(struct inode *inode, | |||
| 4400 | entries = (char *)xh->xh_entries; | 4400 | entries = (char *)xh->xh_entries; |
| 4401 | xh_free_start = le16_to_cpu(xh->xh_free_start); | 4401 | xh_free_start = le16_to_cpu(xh->xh_free_start); |
| 4402 | 4402 | ||
| 4403 | mlog(0, "adjust xattr bucket in %llu, count = %u, " | 4403 | trace_ocfs2_defrag_xattr_bucket( |
| 4404 | "xh_free_start = %u, xh_name_value_len = %u.\n", | ||
| 4405 | (unsigned long long)blkno, le16_to_cpu(xh->xh_count), | 4404 | (unsigned long long)blkno, le16_to_cpu(xh->xh_count), |
| 4406 | xh_free_start, le16_to_cpu(xh->xh_name_value_len)); | 4405 | xh_free_start, le16_to_cpu(xh->xh_name_value_len)); |
| 4407 | 4406 | ||
| @@ -4503,8 +4502,9 @@ static int ocfs2_mv_xattr_bucket_cross_cluster(struct inode *inode, | |||
| 4503 | BUG_ON(le16_to_cpu(bucket_xh(first)->xh_num_buckets) < num_buckets); | 4502 | BUG_ON(le16_to_cpu(bucket_xh(first)->xh_num_buckets) < num_buckets); |
| 4504 | BUG_ON(OCFS2_XATTR_BUCKET_SIZE == OCFS2_SB(sb)->s_clustersize); | 4503 | BUG_ON(OCFS2_XATTR_BUCKET_SIZE == OCFS2_SB(sb)->s_clustersize); |
| 4505 | 4504 | ||
| 4506 | mlog(0, "move half of xattrs in cluster %llu to %llu\n", | 4505 | trace_ocfs2_mv_xattr_bucket_cross_cluster( |
| 4507 | (unsigned long long)last_cluster_blkno, (unsigned long long)new_blkno); | 4506 | (unsigned long long)last_cluster_blkno, |
| 4507 | (unsigned long long)new_blkno); | ||
| 4508 | 4508 | ||
| 4509 | ret = ocfs2_mv_xattr_buckets(inode, handle, bucket_blkno(first), | 4509 | ret = ocfs2_mv_xattr_buckets(inode, handle, bucket_blkno(first), |
| 4510 | last_cluster_blkno, new_blkno, | 4510 | last_cluster_blkno, new_blkno, |
| @@ -4614,8 +4614,8 @@ static int ocfs2_divide_xattr_bucket(struct inode *inode, | |||
| 4614 | struct ocfs2_xattr_entry *xe; | 4614 | struct ocfs2_xattr_entry *xe; |
| 4615 | int blocksize = inode->i_sb->s_blocksize; | 4615 | int blocksize = inode->i_sb->s_blocksize; |
| 4616 | 4616 | ||
| 4617 | mlog(0, "move some of xattrs from bucket %llu to %llu\n", | 4617 | trace_ocfs2_divide_xattr_bucket_begin((unsigned long long)blk, |
| 4618 | (unsigned long long)blk, (unsigned long long)new_blk); | 4618 | (unsigned long long)new_blk); |
| 4619 | 4619 | ||
| 4620 | s_bucket = ocfs2_xattr_bucket_new(inode); | 4620 | s_bucket = ocfs2_xattr_bucket_new(inode); |
| 4621 | t_bucket = ocfs2_xattr_bucket_new(inode); | 4621 | t_bucket = ocfs2_xattr_bucket_new(inode); |
| @@ -4714,9 +4714,9 @@ static int ocfs2_divide_xattr_bucket(struct inode *inode, | |||
| 4714 | */ | 4714 | */ |
| 4715 | xe = &xh->xh_entries[start]; | 4715 | xe = &xh->xh_entries[start]; |
| 4716 | len = sizeof(struct ocfs2_xattr_entry) * (count - start); | 4716 | len = sizeof(struct ocfs2_xattr_entry) * (count - start); |
| 4717 | mlog(0, "mv xattr entry len %d from %d to %d\n", len, | 4717 | trace_ocfs2_divide_xattr_bucket_move(len, |
| 4718 | (int)((char *)xe - (char *)xh), | 4718 | (int)((char *)xe - (char *)xh), |
| 4719 | (int)((char *)xh->xh_entries - (char *)xh)); | 4719 | (int)((char *)xh->xh_entries - (char *)xh)); |
| 4720 | memmove((char *)xh->xh_entries, (char *)xe, len); | 4720 | memmove((char *)xh->xh_entries, (char *)xe, len); |
| 4721 | xe = &xh->xh_entries[count - start]; | 4721 | xe = &xh->xh_entries[count - start]; |
| 4722 | len = sizeof(struct ocfs2_xattr_entry) * start; | 4722 | len = sizeof(struct ocfs2_xattr_entry) * start; |
| @@ -4788,9 +4788,9 @@ static int ocfs2_cp_xattr_bucket(struct inode *inode, | |||
| 4788 | 4788 | ||
| 4789 | BUG_ON(s_blkno == t_blkno); | 4789 | BUG_ON(s_blkno == t_blkno); |
| 4790 | 4790 | ||
| 4791 | mlog(0, "cp bucket %llu to %llu, target is %d\n", | 4791 | trace_ocfs2_cp_xattr_bucket((unsigned long long)s_blkno, |
| 4792 | (unsigned long long)s_blkno, (unsigned long long)t_blkno, | 4792 | (unsigned long long)t_blkno, |
| 4793 | t_is_new); | 4793 | t_is_new); |
| 4794 | 4794 | ||
| 4795 | s_bucket = ocfs2_xattr_bucket_new(inode); | 4795 | s_bucket = ocfs2_xattr_bucket_new(inode); |
| 4796 | t_bucket = ocfs2_xattr_bucket_new(inode); | 4796 | t_bucket = ocfs2_xattr_bucket_new(inode); |
| @@ -4862,8 +4862,8 @@ static int ocfs2_mv_xattr_buckets(struct inode *inode, handle_t *handle, | |||
| 4862 | int num_buckets = ocfs2_xattr_buckets_per_cluster(osb); | 4862 | int num_buckets = ocfs2_xattr_buckets_per_cluster(osb); |
| 4863 | struct ocfs2_xattr_bucket *old_first, *new_first; | 4863 | struct ocfs2_xattr_bucket *old_first, *new_first; |
| 4864 | 4864 | ||
| 4865 | mlog(0, "mv xattrs from cluster %llu to %llu\n", | 4865 | trace_ocfs2_mv_xattr_buckets((unsigned long long)last_blk, |
| 4866 | (unsigned long long)last_blk, (unsigned long long)to_blk); | 4866 | (unsigned long long)to_blk); |
| 4867 | 4867 | ||
| 4868 | BUG_ON(start_bucket >= num_buckets); | 4868 | BUG_ON(start_bucket >= num_buckets); |
| 4869 | if (start_bucket) { | 4869 | if (start_bucket) { |
| @@ -5013,9 +5013,9 @@ static int ocfs2_adjust_xattr_cross_cluster(struct inode *inode, | |||
| 5013 | { | 5013 | { |
| 5014 | int ret; | 5014 | int ret; |
| 5015 | 5015 | ||
| 5016 | mlog(0, "adjust xattrs from cluster %llu len %u to %llu\n", | 5016 | trace_ocfs2_adjust_xattr_cross_cluster( |
| 5017 | (unsigned long long)bucket_blkno(first), prev_clusters, | 5017 | (unsigned long long)bucket_blkno(first), |
| 5018 | (unsigned long long)new_blk); | 5018 | (unsigned long long)new_blk, prev_clusters); |
| 5019 | 5019 | ||
| 5020 | if (ocfs2_xattr_buckets_per_cluster(OCFS2_SB(inode->i_sb)) > 1) { | 5020 | if (ocfs2_xattr_buckets_per_cluster(OCFS2_SB(inode->i_sb)) > 1) { |
| 5021 | ret = ocfs2_mv_xattr_bucket_cross_cluster(inode, | 5021 | ret = ocfs2_mv_xattr_bucket_cross_cluster(inode, |
| @@ -5088,10 +5088,10 @@ static int ocfs2_add_new_xattr_cluster(struct inode *inode, | |||
| 5088 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 5088 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
| 5089 | struct ocfs2_extent_tree et; | 5089 | struct ocfs2_extent_tree et; |
| 5090 | 5090 | ||
| 5091 | mlog(0, "Add new xattr cluster for %llu, previous xattr hash = %u, " | 5091 | trace_ocfs2_add_new_xattr_cluster_begin( |
| 5092 | "previous xattr blkno = %llu\n", | 5092 | (unsigned long long)OCFS2_I(inode)->ip_blkno, |
| 5093 | (unsigned long long)OCFS2_I(inode)->ip_blkno, | 5093 | (unsigned long long)bucket_blkno(first), |
| 5094 | prev_cpos, (unsigned long long)bucket_blkno(first)); | 5094 | prev_cpos, prev_clusters); |
| 5095 | 5095 | ||
| 5096 | ocfs2_init_xattr_tree_extent_tree(&et, INODE_CACHE(inode), root_bh); | 5096 | ocfs2_init_xattr_tree_extent_tree(&et, INODE_CACHE(inode), root_bh); |
| 5097 | 5097 | ||
| @@ -5113,8 +5113,7 @@ static int ocfs2_add_new_xattr_cluster(struct inode *inode, | |||
| 5113 | BUG_ON(num_bits > clusters_to_add); | 5113 | BUG_ON(num_bits > clusters_to_add); |
| 5114 | 5114 | ||
| 5115 | block = ocfs2_clusters_to_blocks(osb->sb, bit_off); | 5115 | block = ocfs2_clusters_to_blocks(osb->sb, bit_off); |
| 5116 | mlog(0, "Allocating %u clusters at block %u for xattr in inode %llu\n", | 5116 | trace_ocfs2_add_new_xattr_cluster((unsigned long long)block, num_bits); |
| 5117 | num_bits, bit_off, (unsigned long long)OCFS2_I(inode)->ip_blkno); | ||
| 5118 | 5117 | ||
| 5119 | if (bucket_blkno(first) + (prev_clusters * bpc) == block && | 5118 | if (bucket_blkno(first) + (prev_clusters * bpc) == block && |
| 5120 | (prev_clusters + num_bits) << osb->s_clustersize_bits <= | 5119 | (prev_clusters + num_bits) << osb->s_clustersize_bits <= |
| @@ -5130,8 +5129,6 @@ static int ocfs2_add_new_xattr_cluster(struct inode *inode, | |||
| 5130 | */ | 5129 | */ |
| 5131 | v_start = prev_cpos + prev_clusters; | 5130 | v_start = prev_cpos + prev_clusters; |
| 5132 | *num_clusters = prev_clusters + num_bits; | 5131 | *num_clusters = prev_clusters + num_bits; |
| 5133 | mlog(0, "Add contiguous %u clusters to previous extent rec.\n", | ||
| 5134 | num_bits); | ||
| 5135 | } else { | 5132 | } else { |
| 5136 | ret = ocfs2_adjust_xattr_cross_cluster(inode, | 5133 | ret = ocfs2_adjust_xattr_cross_cluster(inode, |
| 5137 | handle, | 5134 | handle, |
| @@ -5147,8 +5144,8 @@ static int ocfs2_add_new_xattr_cluster(struct inode *inode, | |||
| 5147 | } | 5144 | } |
| 5148 | } | 5145 | } |
| 5149 | 5146 | ||
| 5150 | mlog(0, "Insert %u clusters at block %llu for xattr at %u\n", | 5147 | trace_ocfs2_add_new_xattr_cluster_insert((unsigned long long)block, |
| 5151 | num_bits, (unsigned long long)block, v_start); | 5148 | v_start, num_bits); |
| 5152 | ret = ocfs2_insert_extent(handle, &et, v_start, block, | 5149 | ret = ocfs2_insert_extent(handle, &et, v_start, block, |
| 5153 | num_bits, 0, ctxt->meta_ac); | 5150 | num_bits, 0, ctxt->meta_ac); |
| 5154 | if (ret < 0) { | 5151 | if (ret < 0) { |
| @@ -5183,9 +5180,9 @@ static int ocfs2_extend_xattr_bucket(struct inode *inode, | |||
| 5183 | u64 end_blk; | 5180 | u64 end_blk; |
| 5184 | u16 new_bucket = le16_to_cpu(bucket_xh(first)->xh_num_buckets); | 5181 | u16 new_bucket = le16_to_cpu(bucket_xh(first)->xh_num_buckets); |
| 5185 | 5182 | ||
| 5186 | mlog(0, "extend xattr bucket in %llu, xattr extend rec starting " | 5183 | trace_ocfs2_extend_xattr_bucket((unsigned long long)target_blk, |
| 5187 | "from %llu, len = %u\n", (unsigned long long)target_blk, | 5184 | (unsigned long long)bucket_blkno(first), |
| 5188 | (unsigned long long)bucket_blkno(first), num_clusters); | 5185 | num_clusters, new_bucket); |
| 5189 | 5186 | ||
| 5190 | /* The extent must have room for an additional bucket */ | 5187 | /* The extent must have room for an additional bucket */ |
| 5191 | BUG_ON(new_bucket >= | 5188 | BUG_ON(new_bucket >= |
| @@ -5265,8 +5262,8 @@ static int ocfs2_add_new_xattr_bucket(struct inode *inode, | |||
| 5265 | /* The bucket at the front of the extent */ | 5262 | /* The bucket at the front of the extent */ |
| 5266 | struct ocfs2_xattr_bucket *first; | 5263 | struct ocfs2_xattr_bucket *first; |
| 5267 | 5264 | ||
| 5268 | mlog(0, "Add new xattr bucket starting from %llu\n", | 5265 | trace_ocfs2_add_new_xattr_bucket( |
| 5269 | (unsigned long long)bucket_blkno(target)); | 5266 | (unsigned long long)bucket_blkno(target)); |
| 5270 | 5267 | ||
| 5271 | /* The first bucket of the original extent */ | 5268 | /* The first bucket of the original extent */ |
| 5272 | first = ocfs2_xattr_bucket_new(inode); | 5269 | first = ocfs2_xattr_bucket_new(inode); |
| @@ -5382,8 +5379,8 @@ static int ocfs2_xattr_bucket_value_truncate(struct inode *inode, | |||
| 5382 | * modified something. We have to assume they did, and dirty | 5379 | * modified something. We have to assume they did, and dirty |
| 5383 | * the whole bucket. This leaves us in a consistent state. | 5380 | * the whole bucket. This leaves us in a consistent state. |
| 5384 | */ | 5381 | */ |
| 5385 | mlog(0, "truncate %u in xattr bucket %llu to %d bytes.\n", | 5382 | trace_ocfs2_xattr_bucket_value_truncate( |
| 5386 | xe_off, (unsigned long long)bucket_blkno(bucket), len); | 5383 | (unsigned long long)bucket_blkno(bucket), xe_off, len); |
| 5387 | ret = ocfs2_xattr_value_truncate(inode, &vb, len, ctxt); | 5384 | ret = ocfs2_xattr_value_truncate(inode, &vb, len, ctxt); |
| 5388 | if (ret) { | 5385 | if (ret) { |
| 5389 | mlog_errno(ret); | 5386 | mlog_errno(ret); |
| @@ -5433,8 +5430,9 @@ static int ocfs2_rm_xattr_cluster(struct inode *inode, | |||
| 5433 | 5430 | ||
| 5434 | ocfs2_init_dealloc_ctxt(&dealloc); | 5431 | ocfs2_init_dealloc_ctxt(&dealloc); |
| 5435 | 5432 | ||
| 5436 | mlog(0, "rm xattr extent rec at %u len = %u, start from %llu\n", | 5433 | trace_ocfs2_rm_xattr_cluster( |
| 5437 | cpos, len, (unsigned long long)blkno); | 5434 | (unsigned long long)OCFS2_I(inode)->ip_blkno, |
| 5435 | (unsigned long long)blkno, cpos, len); | ||
| 5438 | 5436 | ||
| 5439 | ocfs2_remove_xattr_clusters_from_cache(INODE_CACHE(inode), blkno, | 5437 | ocfs2_remove_xattr_clusters_from_cache(INODE_CACHE(inode), blkno, |
| 5440 | len); | 5438 | len); |
| @@ -5538,7 +5536,7 @@ static int ocfs2_xattr_set_entry_bucket(struct inode *inode, | |||
| 5538 | int ret; | 5536 | int ret; |
| 5539 | struct ocfs2_xa_loc loc; | 5537 | struct ocfs2_xa_loc loc; |
| 5540 | 5538 | ||
| 5541 | mlog_entry("Set xattr %s in xattr bucket\n", xi->xi_name); | 5539 | trace_ocfs2_xattr_set_entry_bucket(xi->xi_name); |
| 5542 | 5540 | ||
| 5543 | ocfs2_init_xattr_bucket_xa_loc(&loc, xs->bucket, | 5541 | ocfs2_init_xattr_bucket_xa_loc(&loc, xs->bucket, |
| 5544 | xs->not_found ? NULL : xs->here); | 5542 | xs->not_found ? NULL : xs->here); |
| @@ -5570,7 +5568,6 @@ static int ocfs2_xattr_set_entry_bucket(struct inode *inode, | |||
| 5570 | 5568 | ||
| 5571 | 5569 | ||
| 5572 | out: | 5570 | out: |
| 5573 | mlog_exit(ret); | ||
| 5574 | return ret; | 5571 | return ret; |
| 5575 | } | 5572 | } |
| 5576 | 5573 | ||
| @@ -5581,7 +5578,7 @@ static int ocfs2_xattr_set_entry_index_block(struct inode *inode, | |||
| 5581 | { | 5578 | { |
| 5582 | int ret; | 5579 | int ret; |
| 5583 | 5580 | ||
| 5584 | mlog_entry("Set xattr %s in xattr index block\n", xi->xi_name); | 5581 | trace_ocfs2_xattr_set_entry_index_block(xi->xi_name); |
| 5585 | 5582 | ||
| 5586 | ret = ocfs2_xattr_set_entry_bucket(inode, xi, xs, ctxt); | 5583 | ret = ocfs2_xattr_set_entry_bucket(inode, xi, xs, ctxt); |
| 5587 | if (!ret) | 5584 | if (!ret) |
| @@ -5637,7 +5634,6 @@ static int ocfs2_xattr_set_entry_index_block(struct inode *inode, | |||
| 5637 | mlog_errno(ret); | 5634 | mlog_errno(ret); |
| 5638 | 5635 | ||
| 5639 | out: | 5636 | out: |
| 5640 | mlog_exit(ret); | ||
| 5641 | return ret; | 5637 | return ret; |
| 5642 | } | 5638 | } |
| 5643 | 5639 | ||
| @@ -6041,9 +6037,9 @@ static int ocfs2_xattr_bucket_value_refcount(struct inode *inode, | |||
| 6041 | if (ocfs2_meta_ecc(OCFS2_SB(inode->i_sb))) | 6037 | if (ocfs2_meta_ecc(OCFS2_SB(inode->i_sb))) |
| 6042 | p = &refcount; | 6038 | p = &refcount; |
| 6043 | 6039 | ||
| 6044 | mlog(0, "refcount bucket %llu, count = %u\n", | 6040 | trace_ocfs2_xattr_bucket_value_refcount( |
| 6045 | (unsigned long long)bucket_blkno(bucket), | 6041 | (unsigned long long)bucket_blkno(bucket), |
| 6046 | le16_to_cpu(xh->xh_count)); | 6042 | le16_to_cpu(xh->xh_count)); |
| 6047 | for (i = 0; i < le16_to_cpu(xh->xh_count); i++) { | 6043 | for (i = 0; i < le16_to_cpu(xh->xh_count); i++) { |
| 6048 | xe = &xh->xh_entries[i]; | 6044 | xe = &xh->xh_entries[i]; |
| 6049 | 6045 | ||
| @@ -6339,8 +6335,8 @@ static int ocfs2_reflink_xattr_header(handle_t *handle, | |||
| 6339 | u32 clusters, cpos, p_cluster, num_clusters; | 6335 | u32 clusters, cpos, p_cluster, num_clusters; |
| 6340 | unsigned int ext_flags = 0; | 6336 | unsigned int ext_flags = 0; |
| 6341 | 6337 | ||
| 6342 | mlog(0, "reflink xattr in container %llu, count = %u\n", | 6338 | trace_ocfs2_reflink_xattr_header((unsigned long long)old_bh->b_blocknr, |
| 6343 | (unsigned long long)old_bh->b_blocknr, le16_to_cpu(xh->xh_count)); | 6339 | le16_to_cpu(xh->xh_count)); |
| 6344 | 6340 | ||
| 6345 | last = &new_xh->xh_entries[le16_to_cpu(new_xh->xh_count)]; | 6341 | last = &new_xh->xh_entries[le16_to_cpu(new_xh->xh_count)]; |
| 6346 | for (i = 0, j = 0; i < le16_to_cpu(xh->xh_count); i++, j++) { | 6342 | for (i = 0, j = 0; i < le16_to_cpu(xh->xh_count); i++, j++) { |
| @@ -6540,8 +6536,8 @@ static int ocfs2_create_empty_xattr_block(struct inode *inode, | |||
| 6540 | goto out; | 6536 | goto out; |
| 6541 | } | 6537 | } |
| 6542 | 6538 | ||
| 6543 | mlog(0, "create new xattr block for inode %llu, index = %d\n", | 6539 | trace_ocfs2_create_empty_xattr_block( |
| 6544 | (unsigned long long)fe_bh->b_blocknr, indexed); | 6540 | (unsigned long long)fe_bh->b_blocknr, indexed); |
| 6545 | ret = ocfs2_create_xattr_block(inode, fe_bh, &ctxt, indexed, | 6541 | ret = ocfs2_create_xattr_block(inode, fe_bh, &ctxt, indexed, |
| 6546 | ret_bh); | 6542 | ret_bh); |
| 6547 | if (ret) | 6543 | if (ret) |
| @@ -6952,8 +6948,8 @@ static int ocfs2_reflink_xattr_buckets(handle_t *handle, | |||
| 6952 | if (ret) | 6948 | if (ret) |
| 6953 | mlog_errno(ret); | 6949 | mlog_errno(ret); |
| 6954 | 6950 | ||
| 6955 | mlog(0, "insert new xattr extent rec start %llu len %u to %u\n", | 6951 | trace_ocfs2_reflink_xattr_buckets((unsigned long long)new_blkno, |
| 6956 | (unsigned long long)new_blkno, num_clusters, reflink_cpos); | 6952 | num_clusters, reflink_cpos); |
| 6957 | 6953 | ||
| 6958 | len -= num_clusters; | 6954 | len -= num_clusters; |
| 6959 | blkno += ocfs2_clusters_to_blocks(inode->i_sb, num_clusters); | 6955 | blkno += ocfs2_clusters_to_blocks(inode->i_sb, num_clusters); |
| @@ -6982,8 +6978,7 @@ static int ocfs2_reflink_xattr_rec(struct inode *inode, | |||
| 6982 | struct ocfs2_alloc_context *data_ac = NULL; | 6978 | struct ocfs2_alloc_context *data_ac = NULL; |
| 6983 | struct ocfs2_extent_tree et; | 6979 | struct ocfs2_extent_tree et; |
| 6984 | 6980 | ||
| 6985 | mlog(0, "reflink xattr buckets %llu len %u\n", | 6981 | trace_ocfs2_reflink_xattr_rec((unsigned long long)blkno, len); |
| 6986 | (unsigned long long)blkno, len); | ||
| 6987 | 6982 | ||
| 6988 | ocfs2_init_xattr_tree_extent_tree(&et, | 6983 | ocfs2_init_xattr_tree_extent_tree(&et, |
| 6989 | INODE_CACHE(args->reflink->new_inode), | 6984 | INODE_CACHE(args->reflink->new_inode), |
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 7c708a418ac..2e7addfd980 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c | |||
| @@ -182,7 +182,8 @@ static void m_stop(struct seq_file *m, void *v) | |||
| 182 | struct proc_maps_private *priv = m->private; | 182 | struct proc_maps_private *priv = m->private; |
| 183 | struct vm_area_struct *vma = v; | 183 | struct vm_area_struct *vma = v; |
| 184 | 184 | ||
| 185 | vma_stop(priv, vma); | 185 | if (!IS_ERR(vma)) |
| 186 | vma_stop(priv, vma); | ||
| 186 | if (priv->task) | 187 | if (priv->task) |
| 187 | put_task_struct(priv->task); | 188 | put_task_struct(priv->task); |
| 188 | } | 189 | } |
diff --git a/include/linux/bch.h b/include/linux/bch.h new file mode 100644 index 00000000000..295b4ef153b --- /dev/null +++ b/include/linux/bch.h | |||
| @@ -0,0 +1,79 @@ | |||
| 1 | /* | ||
| 2 | * Generic binary BCH encoding/decoding library | ||
| 3 | * | ||
| 4 | * This program is free software; you can redistribute it and/or modify it | ||
| 5 | * under the terms of the GNU General Public License version 2 as published by | ||
| 6 | * the Free Software Foundation. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
| 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| 11 | * more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License along with | ||
| 14 | * this program; if not, write to the Free Software Foundation, Inc., 51 | ||
| 15 | * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| 16 | * | ||
| 17 | * Copyright © 2011 Parrot S.A. | ||
| 18 | * | ||
| 19 | * Author: Ivan Djelic <ivan.djelic@parrot.com> | ||
| 20 | * | ||
| 21 | * Description: | ||
| 22 | * | ||
| 23 | * This library provides runtime configurable encoding/decoding of binary | ||
| 24 | * Bose-Chaudhuri-Hocquenghem (BCH) codes. | ||
| 25 | */ | ||
| 26 | #ifndef _BCH_H | ||
| 27 | #define _BCH_H | ||
| 28 | |||
| 29 | #include <linux/types.h> | ||
| 30 | |||
| 31 | /** | ||
| 32 | * struct bch_control - BCH control structure | ||
| 33 | * @m: Galois field order | ||
| 34 | * @n: maximum codeword size in bits (= 2^m-1) | ||
| 35 | * @t: error correction capability in bits | ||
| 36 | * @ecc_bits: ecc exact size in bits, i.e. generator polynomial degree (<=m*t) | ||
| 37 | * @ecc_bytes: ecc max size (m*t bits) in bytes | ||
| 38 | * @a_pow_tab: Galois field GF(2^m) exponentiation lookup table | ||
| 39 | * @a_log_tab: Galois field GF(2^m) log lookup table | ||
| 40 | * @mod8_tab: remainder generator polynomial lookup tables | ||
| 41 | * @ecc_buf: ecc parity words buffer | ||
| 42 | * @ecc_buf2: ecc parity words buffer | ||
| 43 | * @xi_tab: GF(2^m) base for solving degree 2 polynomial roots | ||
| 44 | * @syn: syndrome buffer | ||
| 45 | * @cache: log-based polynomial representation buffer | ||
| 46 | * @elp: error locator polynomial | ||
| 47 | * @poly_2t: temporary polynomials of degree 2t | ||
| 48 | */ | ||
| 49 | struct bch_control { | ||
| 50 | unsigned int m; | ||
| 51 | unsigned int n; | ||
| 52 | unsigned int t; | ||
| 53 | unsigned int ecc_bits; | ||
| 54 | unsigned int ecc_bytes; | ||
| 55 | /* private: */ | ||
| 56 | uint16_t *a_pow_tab; | ||
| 57 | uint16_t *a_log_tab; | ||
| 58 | uint32_t *mod8_tab; | ||
| 59 | uint32_t *ecc_buf; | ||
| 60 | uint32_t *ecc_buf2; | ||
| 61 | unsigned int *xi_tab; | ||
| 62 | unsigned int *syn; | ||
| 63 | int *cache; | ||
| 64 | struct gf_poly *elp; | ||
| 65 | struct gf_poly *poly_2t[4]; | ||
| 66 | }; | ||
| 67 | |||
| 68 | struct bch_control *init_bch(int m, int t, unsigned int prim_poly); | ||
| 69 | |||
| 70 | void free_bch(struct bch_control *bch); | ||
| 71 | |||
| 72 | void encode_bch(struct bch_control *bch, const uint8_t *data, | ||
| 73 | unsigned int len, uint8_t *ecc); | ||
| 74 | |||
| 75 | int decode_bch(struct bch_control *bch, const uint8_t *data, unsigned int len, | ||
| 76 | const uint8_t *recv_ecc, const uint8_t *calc_ecc, | ||
| 77 | const unsigned int *syn, unsigned int *errloc); | ||
| 78 | |||
| 79 | #endif /* _BCH_H */ | ||
diff --git a/include/linux/drbd.h b/include/linux/drbd.h index ef44c7a0638..d18d673ebc7 100644 --- a/include/linux/drbd.h +++ b/include/linux/drbd.h | |||
| @@ -53,10 +53,10 @@ | |||
| 53 | 53 | ||
| 54 | 54 | ||
| 55 | extern const char *drbd_buildtag(void); | 55 | extern const char *drbd_buildtag(void); |
| 56 | #define REL_VERSION "8.3.9" | 56 | #define REL_VERSION "8.3.10" |
| 57 | #define API_VERSION 88 | 57 | #define API_VERSION 88 |
| 58 | #define PRO_VERSION_MIN 86 | 58 | #define PRO_VERSION_MIN 86 |
| 59 | #define PRO_VERSION_MAX 95 | 59 | #define PRO_VERSION_MAX 96 |
| 60 | 60 | ||
| 61 | 61 | ||
| 62 | enum drbd_io_error_p { | 62 | enum drbd_io_error_p { |
| @@ -96,8 +96,14 @@ enum drbd_on_no_data { | |||
| 96 | OND_SUSPEND_IO | 96 | OND_SUSPEND_IO |
| 97 | }; | 97 | }; |
| 98 | 98 | ||
| 99 | enum drbd_on_congestion { | ||
| 100 | OC_BLOCK, | ||
| 101 | OC_PULL_AHEAD, | ||
| 102 | OC_DISCONNECT, | ||
| 103 | }; | ||
| 104 | |||
| 99 | /* KEEP the order, do not delete or insert. Only append. */ | 105 | /* KEEP the order, do not delete or insert. Only append. */ |
| 100 | enum drbd_ret_codes { | 106 | enum drbd_ret_code { |
| 101 | ERR_CODE_BASE = 100, | 107 | ERR_CODE_BASE = 100, |
| 102 | NO_ERROR = 101, | 108 | NO_ERROR = 101, |
| 103 | ERR_LOCAL_ADDR = 102, | 109 | ERR_LOCAL_ADDR = 102, |
| @@ -146,6 +152,9 @@ enum drbd_ret_codes { | |||
| 146 | ERR_PERM = 152, | 152 | ERR_PERM = 152, |
| 147 | ERR_NEED_APV_93 = 153, | 153 | ERR_NEED_APV_93 = 153, |
| 148 | ERR_STONITH_AND_PROT_A = 154, | 154 | ERR_STONITH_AND_PROT_A = 154, |
| 155 | ERR_CONG_NOT_PROTO_A = 155, | ||
| 156 | ERR_PIC_AFTER_DEP = 156, | ||
| 157 | ERR_PIC_PEER_DEP = 157, | ||
| 149 | 158 | ||
| 150 | /* insert new ones above this line */ | 159 | /* insert new ones above this line */ |
| 151 | AFTER_LAST_ERR_CODE | 160 | AFTER_LAST_ERR_CODE |
| @@ -199,6 +208,10 @@ enum drbd_conns { | |||
| 199 | C_VERIFY_T, | 208 | C_VERIFY_T, |
| 200 | C_PAUSED_SYNC_S, | 209 | C_PAUSED_SYNC_S, |
| 201 | C_PAUSED_SYNC_T, | 210 | C_PAUSED_SYNC_T, |
| 211 | |||
| 212 | C_AHEAD, | ||
| 213 | C_BEHIND, | ||
| 214 | |||
| 202 | C_MASK = 31 | 215 | C_MASK = 31 |
| 203 | }; | 216 | }; |
| 204 | 217 | ||
| @@ -259,7 +272,7 @@ union drbd_state { | |||
| 259 | unsigned int i; | 272 | unsigned int i; |
| 260 | }; | 273 | }; |
| 261 | 274 | ||
| 262 | enum drbd_state_ret_codes { | 275 | enum drbd_state_rv { |
| 263 | SS_CW_NO_NEED = 4, | 276 | SS_CW_NO_NEED = 4, |
| 264 | SS_CW_SUCCESS = 3, | 277 | SS_CW_SUCCESS = 3, |
| 265 | SS_NOTHING_TO_DO = 2, | 278 | SS_NOTHING_TO_DO = 2, |
| @@ -290,7 +303,7 @@ enum drbd_state_ret_codes { | |||
| 290 | extern const char *drbd_conn_str(enum drbd_conns); | 303 | extern const char *drbd_conn_str(enum drbd_conns); |
| 291 | extern const char *drbd_role_str(enum drbd_role); | 304 | extern const char *drbd_role_str(enum drbd_role); |
| 292 | extern const char *drbd_disk_str(enum drbd_disk_state); | 305 | extern const char *drbd_disk_str(enum drbd_disk_state); |
| 293 | extern const char *drbd_set_st_err_str(enum drbd_state_ret_codes); | 306 | extern const char *drbd_set_st_err_str(enum drbd_state_rv); |
| 294 | 307 | ||
| 295 | #define SHARED_SECRET_MAX 64 | 308 | #define SHARED_SECRET_MAX 64 |
| 296 | 309 | ||
diff --git a/include/linux/drbd_limits.h b/include/linux/drbd_limits.h index 4ac33f34b77..bb264a5732d 100644 --- a/include/linux/drbd_limits.h +++ b/include/linux/drbd_limits.h | |||
| @@ -16,7 +16,8 @@ | |||
| 16 | #define DEBUG_RANGE_CHECK 0 | 16 | #define DEBUG_RANGE_CHECK 0 |
| 17 | 17 | ||
| 18 | #define DRBD_MINOR_COUNT_MIN 1 | 18 | #define DRBD_MINOR_COUNT_MIN 1 |
| 19 | #define DRBD_MINOR_COUNT_MAX 255 | 19 | #define DRBD_MINOR_COUNT_MAX 256 |
| 20 | #define DRBD_MINOR_COUNT_DEF 32 | ||
| 20 | 21 | ||
| 21 | #define DRBD_DIALOG_REFRESH_MIN 0 | 22 | #define DRBD_DIALOG_REFRESH_MIN 0 |
| 22 | #define DRBD_DIALOG_REFRESH_MAX 600 | 23 | #define DRBD_DIALOG_REFRESH_MAX 600 |
| @@ -129,6 +130,7 @@ | |||
| 129 | #define DRBD_AFTER_SB_2P_DEF ASB_DISCONNECT | 130 | #define DRBD_AFTER_SB_2P_DEF ASB_DISCONNECT |
| 130 | #define DRBD_RR_CONFLICT_DEF ASB_DISCONNECT | 131 | #define DRBD_RR_CONFLICT_DEF ASB_DISCONNECT |
| 131 | #define DRBD_ON_NO_DATA_DEF OND_IO_ERROR | 132 | #define DRBD_ON_NO_DATA_DEF OND_IO_ERROR |
| 133 | #define DRBD_ON_CONGESTION_DEF OC_BLOCK | ||
| 132 | 134 | ||
| 133 | #define DRBD_MAX_BIO_BVECS_MIN 0 | 135 | #define DRBD_MAX_BIO_BVECS_MIN 0 |
| 134 | #define DRBD_MAX_BIO_BVECS_MAX 128 | 136 | #define DRBD_MAX_BIO_BVECS_MAX 128 |
| @@ -154,5 +156,13 @@ | |||
| 154 | #define DRBD_C_MIN_RATE_MAX (4 << 20) | 156 | #define DRBD_C_MIN_RATE_MAX (4 << 20) |
| 155 | #define DRBD_C_MIN_RATE_DEF 4096 | 157 | #define DRBD_C_MIN_RATE_DEF 4096 |
| 156 | 158 | ||
| 159 | #define DRBD_CONG_FILL_MIN 0 | ||
| 160 | #define DRBD_CONG_FILL_MAX (10<<21) /* 10GByte in sectors */ | ||
| 161 | #define DRBD_CONG_FILL_DEF 0 | ||
| 162 | |||
| 163 | #define DRBD_CONG_EXTENTS_MIN DRBD_AL_EXTENTS_MIN | ||
| 164 | #define DRBD_CONG_EXTENTS_MAX DRBD_AL_EXTENTS_MAX | ||
| 165 | #define DRBD_CONG_EXTENTS_DEF DRBD_AL_EXTENTS_DEF | ||
| 166 | |||
| 157 | #undef RANGE | 167 | #undef RANGE |
| 158 | #endif | 168 | #endif |
diff --git a/include/linux/drbd_nl.h b/include/linux/drbd_nl.h index ade91107c9a..ab6159e4fcf 100644 --- a/include/linux/drbd_nl.h +++ b/include/linux/drbd_nl.h | |||
| @@ -56,6 +56,9 @@ NL_PACKET(net_conf, 5, | |||
| 56 | NL_INTEGER( 39, T_MAY_IGNORE, rr_conflict) | 56 | NL_INTEGER( 39, T_MAY_IGNORE, rr_conflict) |
| 57 | NL_INTEGER( 40, T_MAY_IGNORE, ping_timeo) | 57 | NL_INTEGER( 40, T_MAY_IGNORE, ping_timeo) |
| 58 | NL_INTEGER( 67, T_MAY_IGNORE, rcvbuf_size) | 58 | NL_INTEGER( 67, T_MAY_IGNORE, rcvbuf_size) |
| 59 | NL_INTEGER( 81, T_MAY_IGNORE, on_congestion) | ||
| 60 | NL_INTEGER( 82, T_MAY_IGNORE, cong_fill) | ||
| 61 | NL_INTEGER( 83, T_MAY_IGNORE, cong_extents) | ||
| 59 | /* 59 addr_family was available in GIT, never released */ | 62 | /* 59 addr_family was available in GIT, never released */ |
| 60 | NL_BIT( 60, T_MANDATORY, mind_af) | 63 | NL_BIT( 60, T_MANDATORY, mind_af) |
| 61 | NL_BIT( 27, T_MAY_IGNORE, want_lose) | 64 | NL_BIT( 27, T_MAY_IGNORE, want_lose) |
| @@ -66,7 +69,9 @@ NL_PACKET(net_conf, 5, | |||
| 66 | NL_BIT( 70, T_MANDATORY, dry_run) | 69 | NL_BIT( 70, T_MANDATORY, dry_run) |
| 67 | ) | 70 | ) |
| 68 | 71 | ||
| 69 | NL_PACKET(disconnect, 6, ) | 72 | NL_PACKET(disconnect, 6, |
| 73 | NL_BIT( 84, T_MAY_IGNORE, force) | ||
| 74 | ) | ||
| 70 | 75 | ||
| 71 | NL_PACKET(resize, 7, | 76 | NL_PACKET(resize, 7, |
| 72 | NL_INT64( 29, T_MAY_IGNORE, resize_size) | 77 | NL_INT64( 29, T_MAY_IGNORE, resize_size) |
| @@ -143,9 +148,13 @@ NL_PACKET(new_c_uuid, 26, | |||
| 143 | NL_BIT( 63, T_MANDATORY, clear_bm) | 148 | NL_BIT( 63, T_MANDATORY, clear_bm) |
| 144 | ) | 149 | ) |
| 145 | 150 | ||
| 151 | #ifdef NL_RESPONSE | ||
| 152 | NL_RESPONSE(return_code_only, 27) | ||
| 153 | #endif | ||
| 154 | |||
| 146 | #undef NL_PACKET | 155 | #undef NL_PACKET |
| 147 | #undef NL_INTEGER | 156 | #undef NL_INTEGER |
| 148 | #undef NL_INT64 | 157 | #undef NL_INT64 |
| 149 | #undef NL_BIT | 158 | #undef NL_BIT |
| 150 | #undef NL_STRING | 159 | #undef NL_STRING |
| 151 | 160 | #undef NL_RESPONSE | |
diff --git a/include/linux/drbd_tag_magic.h b/include/linux/drbd_tag_magic.h index fcdff8410e9..f14a165e82d 100644 --- a/include/linux/drbd_tag_magic.h +++ b/include/linux/drbd_tag_magic.h | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | /* declare packet_type enums */ | 7 | /* declare packet_type enums */ |
| 8 | enum packet_types { | 8 | enum packet_types { |
| 9 | #define NL_PACKET(name, number, fields) P_ ## name = number, | 9 | #define NL_PACKET(name, number, fields) P_ ## name = number, |
| 10 | #define NL_RESPONSE(name, number) P_ ## name = number, | ||
| 10 | #define NL_INTEGER(pn, pr, member) | 11 | #define NL_INTEGER(pn, pr, member) |
| 11 | #define NL_INT64(pn, pr, member) | 12 | #define NL_INT64(pn, pr, member) |
| 12 | #define NL_BIT(pn, pr, member) | 13 | #define NL_BIT(pn, pr, member) |
diff --git a/include/linux/mfd/ab8500.h b/include/linux/mfd/ab8500.h index 56f8dea7215..6e4f77ef4d2 100644 --- a/include/linux/mfd/ab8500.h +++ b/include/linux/mfd/ab8500.h | |||
| @@ -139,17 +139,23 @@ struct ab8500 { | |||
| 139 | u8 oldmask[AB8500_NUM_IRQ_REGS]; | 139 | u8 oldmask[AB8500_NUM_IRQ_REGS]; |
| 140 | }; | 140 | }; |
| 141 | 141 | ||
| 142 | struct regulator_reg_init; | ||
| 142 | struct regulator_init_data; | 143 | struct regulator_init_data; |
| 143 | 144 | ||
| 144 | /** | 145 | /** |
| 145 | * struct ab8500_platform_data - AB8500 platform data | 146 | * struct ab8500_platform_data - AB8500 platform data |
| 146 | * @irq_base: start of AB8500 IRQs, AB8500_NR_IRQS will be used | 147 | * @irq_base: start of AB8500 IRQs, AB8500_NR_IRQS will be used |
| 147 | * @init: board-specific initialization after detection of ab8500 | 148 | * @init: board-specific initialization after detection of ab8500 |
| 149 | * @num_regulator_reg_init: number of regulator init registers | ||
| 150 | * @regulator_reg_init: regulator init registers | ||
| 151 | * @num_regulator: number of regulators | ||
| 148 | * @regulator: machine-specific constraints for regulators | 152 | * @regulator: machine-specific constraints for regulators |
| 149 | */ | 153 | */ |
| 150 | struct ab8500_platform_data { | 154 | struct ab8500_platform_data { |
| 151 | int irq_base; | 155 | int irq_base; |
| 152 | void (*init) (struct ab8500 *); | 156 | void (*init) (struct ab8500 *); |
| 157 | int num_regulator_reg_init; | ||
| 158 | struct ab8500_regulator_reg_init *regulator_reg_init; | ||
| 153 | int num_regulator; | 159 | int num_regulator; |
| 154 | struct regulator_init_data *regulator; | 160 | struct regulator_init_data *regulator; |
| 155 | }; | 161 | }; |
diff --git a/include/linux/mfd/core.h b/include/linux/mfd/core.h index 1408bf8eed5..ad1b19aa650 100644 --- a/include/linux/mfd/core.h +++ b/include/linux/mfd/core.h | |||
| @@ -63,6 +63,24 @@ extern int mfd_cell_enable(struct platform_device *pdev); | |||
| 63 | extern int mfd_cell_disable(struct platform_device *pdev); | 63 | extern int mfd_cell_disable(struct platform_device *pdev); |
| 64 | 64 | ||
| 65 | /* | 65 | /* |
| 66 | * "Clone" multiple platform devices for a single cell. This is to be used | ||
| 67 | * for devices that have multiple users of a cell. For example, if an mfd | ||
| 68 | * driver wants the cell "foo" to be used by a GPIO driver, an MTD driver, | ||
| 69 | * and a platform driver, the following bit of code would be use after first | ||
| 70 | * calling mfd_add_devices(): | ||
| 71 | * | ||
| 72 | * const char *fclones[] = { "foo-gpio", "foo-mtd" }; | ||
| 73 | * err = mfd_clone_cells("foo", fclones, ARRAY_SIZE(fclones)); | ||
| 74 | * | ||
| 75 | * Each driver (MTD, GPIO, and platform driver) would then register | ||
| 76 | * platform_drivers for "foo-mtd", "foo-gpio", and "foo", respectively. | ||
| 77 | * The cell's .enable/.disable hooks should be used to deal with hardware | ||
| 78 | * resource contention. | ||
| 79 | */ | ||
| 80 | extern int mfd_clone_cell(const char *cell, const char **clones, | ||
| 81 | size_t n_clones); | ||
| 82 | |||
| 83 | /* | ||
| 66 | * Given a platform device that's been created by mfd_add_devices(), fetch | 84 | * Given a platform device that's been created by mfd_add_devices(), fetch |
| 67 | * the mfd_cell that created it. | 85 | * the mfd_cell that created it. |
| 68 | */ | 86 | */ |
| @@ -87,13 +105,4 @@ extern int mfd_add_devices(struct device *parent, int id, | |||
| 87 | 105 | ||
| 88 | extern void mfd_remove_devices(struct device *parent); | 106 | extern void mfd_remove_devices(struct device *parent); |
| 89 | 107 | ||
| 90 | /* | ||
| 91 | * For MFD drivers with clients sharing access to resources, these create | ||
| 92 | * multiple platform devices per cell. Contention handling must still be | ||
| 93 | * handled via drivers (ie, with enable/disable hooks). | ||
| 94 | */ | ||
| 95 | extern int mfd_shared_platform_driver_register(struct platform_driver *drv, | ||
| 96 | const char *cellname); | ||
| 97 | extern void mfd_shared_platform_driver_unregister(struct platform_driver *drv); | ||
| 98 | |||
| 99 | #endif | 108 | #endif |
diff --git a/include/linux/mfd/max8997-private.h b/include/linux/mfd/max8997-private.h index 93a9477e075..69d1010e2e5 100644 --- a/include/linux/mfd/max8997-private.h +++ b/include/linux/mfd/max8997-private.h | |||
| @@ -24,6 +24,8 @@ | |||
| 24 | 24 | ||
| 25 | #include <linux/i2c.h> | 25 | #include <linux/i2c.h> |
| 26 | 26 | ||
| 27 | #define MAX8997_REG_INVALID (0xff) | ||
| 28 | |||
| 27 | enum max8997_pmic_reg { | 29 | enum max8997_pmic_reg { |
| 28 | MAX8997_REG_PMIC_ID0 = 0x00, | 30 | MAX8997_REG_PMIC_ID0 = 0x00, |
| 29 | MAX8997_REG_PMIC_ID1 = 0x01, | 31 | MAX8997_REG_PMIC_ID1 = 0x01, |
| @@ -313,6 +315,7 @@ enum max8997_irq { | |||
| 313 | #define MAX8997_REG_BUCK2DVS(x) (MAX8997_REG_BUCK2DVS1 + (x) - 1) | 315 | #define MAX8997_REG_BUCK2DVS(x) (MAX8997_REG_BUCK2DVS1 + (x) - 1) |
| 314 | #define MAX8997_REG_BUCK5DVS(x) (MAX8997_REG_BUCK5DVS1 + (x) - 1) | 316 | #define MAX8997_REG_BUCK5DVS(x) (MAX8997_REG_BUCK5DVS1 + (x) - 1) |
| 315 | 317 | ||
| 318 | #define MAX8997_NUM_GPIO 12 | ||
| 316 | struct max8997_dev { | 319 | struct max8997_dev { |
| 317 | struct device *dev; | 320 | struct device *dev; |
| 318 | struct i2c_client *i2c; /* 0xcc / PMIC, Battery Control, and FLASH */ | 321 | struct i2c_client *i2c; /* 0xcc / PMIC, Battery Control, and FLASH */ |
| @@ -324,11 +327,19 @@ struct max8997_dev { | |||
| 324 | int type; | 327 | int type; |
| 325 | struct platform_device *battery; /* battery control (not fuel gauge) */ | 328 | struct platform_device *battery; /* battery control (not fuel gauge) */ |
| 326 | 329 | ||
| 330 | int irq; | ||
| 331 | int ono; | ||
| 332 | int irq_base; | ||
| 327 | bool wakeup; | 333 | bool wakeup; |
| 334 | struct mutex irqlock; | ||
| 335 | int irq_masks_cur[MAX8997_IRQ_GROUP_NR]; | ||
| 336 | int irq_masks_cache[MAX8997_IRQ_GROUP_NR]; | ||
| 328 | 337 | ||
| 329 | /* For hibernation */ | 338 | /* For hibernation */ |
| 330 | u8 reg_dump[MAX8997_REG_PMIC_END + MAX8997_MUIC_REG_END + | 339 | u8 reg_dump[MAX8997_REG_PMIC_END + MAX8997_MUIC_REG_END + |
| 331 | MAX8997_HAPTIC_REG_END]; | 340 | MAX8997_HAPTIC_REG_END]; |
| 341 | |||
| 342 | bool gpio_status[MAX8997_NUM_GPIO]; | ||
| 332 | }; | 343 | }; |
| 333 | 344 | ||
| 334 | enum max8997_types { | 345 | enum max8997_types { |
| @@ -336,6 +347,10 @@ enum max8997_types { | |||
| 336 | TYPE_MAX8966, | 347 | TYPE_MAX8966, |
| 337 | }; | 348 | }; |
| 338 | 349 | ||
| 350 | extern int max8997_irq_init(struct max8997_dev *max8997); | ||
| 351 | extern void max8997_irq_exit(struct max8997_dev *max8997); | ||
| 352 | extern int max8997_irq_resume(struct max8997_dev *max8997); | ||
| 353 | |||
| 339 | extern int max8997_read_reg(struct i2c_client *i2c, u8 reg, u8 *dest); | 354 | extern int max8997_read_reg(struct i2c_client *i2c, u8 reg, u8 *dest); |
| 340 | extern int max8997_bulk_read(struct i2c_client *i2c, u8 reg, int count, | 355 | extern int max8997_bulk_read(struct i2c_client *i2c, u8 reg, int count, |
| 341 | u8 *buf); | 356 | u8 *buf); |
| @@ -344,4 +359,10 @@ extern int max8997_bulk_write(struct i2c_client *i2c, u8 reg, int count, | |||
| 344 | u8 *buf); | 359 | u8 *buf); |
| 345 | extern int max8997_update_reg(struct i2c_client *i2c, u8 reg, u8 val, u8 mask); | 360 | extern int max8997_update_reg(struct i2c_client *i2c, u8 reg, u8 val, u8 mask); |
| 346 | 361 | ||
| 362 | #define MAX8997_GPIO_INT_BOTH (0x3 << 4) | ||
| 363 | #define MAX8997_GPIO_INT_RISE (0x2 << 4) | ||
| 364 | #define MAX8997_GPIO_INT_FALL (0x1 << 4) | ||
| 365 | |||
| 366 | #define MAX8997_GPIO_INT_MASK (0x3 << 4) | ||
| 367 | #define MAX8997_GPIO_DATA_MASK (0x1 << 2) | ||
| 347 | #endif /* __LINUX_MFD_MAX8997_PRIV_H */ | 368 | #endif /* __LINUX_MFD_MAX8997_PRIV_H */ |
diff --git a/include/linux/mfd/max8997.h b/include/linux/mfd/max8997.h index cb671b3451b..60931d08942 100644 --- a/include/linux/mfd/max8997.h +++ b/include/linux/mfd/max8997.h | |||
| @@ -78,8 +78,11 @@ struct max8997_regulator_data { | |||
| 78 | }; | 78 | }; |
| 79 | 79 | ||
| 80 | struct max8997_platform_data { | 80 | struct max8997_platform_data { |
| 81 | bool wakeup; | 81 | /* IRQ */ |
| 82 | /* IRQ: Not implemented */ | 82 | int irq_base; |
| 83 | int ono; | ||
| 84 | int wakeup; | ||
| 85 | |||
| 83 | /* ---- PMIC ---- */ | 86 | /* ---- PMIC ---- */ |
| 84 | struct max8997_regulator_data *regulators; | 87 | struct max8997_regulator_data *regulators; |
| 85 | int num_regulators; | 88 | int num_regulators; |
diff --git a/include/linux/mtd/blktrans.h b/include/linux/mtd/blktrans.h index 26529ebd59c..1bbd9f28924 100644 --- a/include/linux/mtd/blktrans.h +++ b/include/linux/mtd/blktrans.h | |||
| @@ -36,6 +36,7 @@ struct mtd_blktrans_dev { | |||
| 36 | struct mtd_info *mtd; | 36 | struct mtd_info *mtd; |
| 37 | struct mutex lock; | 37 | struct mutex lock; |
| 38 | int devnum; | 38 | int devnum; |
| 39 | bool bg_stop; | ||
| 39 | unsigned long size; | 40 | unsigned long size; |
| 40 | int readonly; | 41 | int readonly; |
| 41 | int open; | 42 | int open; |
| @@ -62,6 +63,7 @@ struct mtd_blktrans_ops { | |||
| 62 | unsigned long block, char *buffer); | 63 | unsigned long block, char *buffer); |
| 63 | int (*discard)(struct mtd_blktrans_dev *dev, | 64 | int (*discard)(struct mtd_blktrans_dev *dev, |
| 64 | unsigned long block, unsigned nr_blocks); | 65 | unsigned long block, unsigned nr_blocks); |
| 66 | void (*background)(struct mtd_blktrans_dev *dev); | ||
| 65 | 67 | ||
| 66 | /* Block layer ioctls */ | 68 | /* Block layer ioctls */ |
| 67 | int (*getgeo)(struct mtd_blktrans_dev *dev, struct hd_geometry *geo); | 69 | int (*getgeo)(struct mtd_blktrans_dev *dev, struct hd_geometry *geo); |
| @@ -85,6 +87,7 @@ extern int register_mtd_blktrans(struct mtd_blktrans_ops *tr); | |||
| 85 | extern int deregister_mtd_blktrans(struct mtd_blktrans_ops *tr); | 87 | extern int deregister_mtd_blktrans(struct mtd_blktrans_ops *tr); |
| 86 | extern int add_mtd_blktrans_dev(struct mtd_blktrans_dev *dev); | 88 | extern int add_mtd_blktrans_dev(struct mtd_blktrans_dev *dev); |
| 87 | extern int del_mtd_blktrans_dev(struct mtd_blktrans_dev *dev); | 89 | extern int del_mtd_blktrans_dev(struct mtd_blktrans_dev *dev); |
| 90 | extern int mtd_blktrans_cease_background(struct mtd_blktrans_dev *dev); | ||
| 88 | 91 | ||
| 89 | 92 | ||
| 90 | #endif /* __MTD_TRANS_H__ */ | 93 | #endif /* __MTD_TRANS_H__ */ |
diff --git a/include/linux/mtd/cfi.h b/include/linux/mtd/cfi.h index a9baee6864a..0d823f2dd66 100644 --- a/include/linux/mtd/cfi.h +++ b/include/linux/mtd/cfi.h | |||
| @@ -535,6 +535,7 @@ struct cfi_fixup { | |||
| 535 | #define CFI_MFR_CONTINUATION 0x007F | 535 | #define CFI_MFR_CONTINUATION 0x007F |
| 536 | 536 | ||
| 537 | #define CFI_MFR_AMD 0x0001 | 537 | #define CFI_MFR_AMD 0x0001 |
| 538 | #define CFI_MFR_AMIC 0x0037 | ||
| 538 | #define CFI_MFR_ATMEL 0x001F | 539 | #define CFI_MFR_ATMEL 0x001F |
| 539 | #define CFI_MFR_EON 0x001C | 540 | #define CFI_MFR_EON 0x001C |
| 540 | #define CFI_MFR_FUJITSU 0x0004 | 541 | #define CFI_MFR_FUJITSU 0x0004 |
diff --git a/include/linux/mtd/latch-addr-flash.h b/include/linux/mtd/latch-addr-flash.h new file mode 100644 index 00000000000..e94b8e12807 --- /dev/null +++ b/include/linux/mtd/latch-addr-flash.h | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | /* | ||
| 2 | * Interface for NOR flash driver whose high address lines are latched | ||
| 3 | * | ||
| 4 | * Copyright © 2008 MontaVista Software, Inc. <source@mvista.com> | ||
| 5 | * | ||
| 6 | * This file is licensed under the terms of the GNU General Public License | ||
| 7 | * version 2. This program is licensed "as is" without any warranty of any | ||
| 8 | * kind, whether express or implied. | ||
| 9 | */ | ||
| 10 | #ifndef __LATCH_ADDR_FLASH__ | ||
| 11 | #define __LATCH_ADDR_FLASH__ | ||
| 12 | |||
| 13 | struct map_info; | ||
| 14 | struct mtd_partition; | ||
| 15 | |||
| 16 | struct latch_addr_flash_data { | ||
| 17 | unsigned int width; | ||
| 18 | unsigned int size; | ||
| 19 | |||
| 20 | int (*init)(void *data, int cs); | ||
| 21 | void (*done)(void *data); | ||
| 22 | void (*set_window)(unsigned long offset, void *data); | ||
| 23 | void *data; | ||
| 24 | |||
| 25 | unsigned int nr_parts; | ||
| 26 | struct mtd_partition *parts; | ||
| 27 | }; | ||
| 28 | |||
| 29 | #endif | ||
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index 1f489b247a2..ae67ef56a8f 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h | |||
| @@ -140,6 +140,7 @@ typedef enum { | |||
| 140 | NAND_ECC_HW, | 140 | NAND_ECC_HW, |
| 141 | NAND_ECC_HW_SYNDROME, | 141 | NAND_ECC_HW_SYNDROME, |
| 142 | NAND_ECC_HW_OOB_FIRST, | 142 | NAND_ECC_HW_OOB_FIRST, |
| 143 | NAND_ECC_SOFT_BCH, | ||
| 143 | } nand_ecc_modes_t; | 144 | } nand_ecc_modes_t; |
| 144 | 145 | ||
| 145 | /* | 146 | /* |
| @@ -339,6 +340,7 @@ struct nand_hw_control { | |||
| 339 | * @prepad: padding information for syndrome based ecc generators | 340 | * @prepad: padding information for syndrome based ecc generators |
| 340 | * @postpad: padding information for syndrome based ecc generators | 341 | * @postpad: padding information for syndrome based ecc generators |
| 341 | * @layout: ECC layout control struct pointer | 342 | * @layout: ECC layout control struct pointer |
| 343 | * @priv: pointer to private ecc control data | ||
| 342 | * @hwctl: function to control hardware ecc generator. Must only | 344 | * @hwctl: function to control hardware ecc generator. Must only |
| 343 | * be provided if an hardware ECC is available | 345 | * be provided if an hardware ECC is available |
| 344 | * @calculate: function for ecc calculation or readback from ecc hardware | 346 | * @calculate: function for ecc calculation or readback from ecc hardware |
| @@ -362,6 +364,7 @@ struct nand_ecc_ctrl { | |||
| 362 | int prepad; | 364 | int prepad; |
| 363 | int postpad; | 365 | int postpad; |
| 364 | struct nand_ecclayout *layout; | 366 | struct nand_ecclayout *layout; |
| 367 | void *priv; | ||
| 365 | void (*hwctl)(struct mtd_info *mtd, int mode); | 368 | void (*hwctl)(struct mtd_info *mtd, int mode); |
| 366 | int (*calculate)(struct mtd_info *mtd, const uint8_t *dat, | 369 | int (*calculate)(struct mtd_info *mtd, const uint8_t *dat, |
| 367 | uint8_t *ecc_code); | 370 | uint8_t *ecc_code); |
diff --git a/include/linux/mtd/nand_bch.h b/include/linux/mtd/nand_bch.h new file mode 100644 index 00000000000..74acf536755 --- /dev/null +++ b/include/linux/mtd/nand_bch.h | |||
| @@ -0,0 +1,72 @@ | |||
| 1 | /* | ||
| 2 | * Copyright © 2011 Ivan Djelic <ivan.djelic@parrot.com> | ||
| 3 | * | ||
| 4 | * This program is free software; you can redistribute it and/or modify | ||
| 5 | * it under the terms of the GNU General Public License version 2 as | ||
| 6 | * published by the Free Software Foundation. | ||
| 7 | * | ||
| 8 | * This file is the header for the NAND BCH ECC implementation. | ||
| 9 | */ | ||
| 10 | |||
| 11 | #ifndef __MTD_NAND_BCH_H__ | ||
| 12 | #define __MTD_NAND_BCH_H__ | ||
| 13 | |||
| 14 | struct mtd_info; | ||
| 15 | struct nand_bch_control; | ||
| 16 | |||
| 17 | #if defined(CONFIG_MTD_NAND_ECC_BCH) | ||
| 18 | |||
| 19 | static inline int mtd_nand_has_bch(void) { return 1; } | ||
| 20 | |||
| 21 | /* | ||
| 22 | * Calculate BCH ecc code | ||
| 23 | */ | ||
| 24 | int nand_bch_calculate_ecc(struct mtd_info *mtd, const u_char *dat, | ||
| 25 | u_char *ecc_code); | ||
| 26 | |||
| 27 | /* | ||
| 28 | * Detect and correct bit errors | ||
| 29 | */ | ||
| 30 | int nand_bch_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, | ||
| 31 | u_char *calc_ecc); | ||
| 32 | /* | ||
| 33 | * Initialize BCH encoder/decoder | ||
| 34 | */ | ||
| 35 | struct nand_bch_control * | ||
| 36 | nand_bch_init(struct mtd_info *mtd, unsigned int eccsize, | ||
| 37 | unsigned int eccbytes, struct nand_ecclayout **ecclayout); | ||
| 38 | /* | ||
| 39 | * Release BCH encoder/decoder resources | ||
| 40 | */ | ||
| 41 | void nand_bch_free(struct nand_bch_control *nbc); | ||
| 42 | |||
| 43 | #else /* !CONFIG_MTD_NAND_ECC_BCH */ | ||
| 44 | |||
| 45 | static inline int mtd_nand_has_bch(void) { return 0; } | ||
| 46 | |||
| 47 | static inline int | ||
| 48 | nand_bch_calculate_ecc(struct mtd_info *mtd, const u_char *dat, | ||
| 49 | u_char *ecc_code) | ||
| 50 | { | ||
| 51 | return -1; | ||
| 52 | } | ||
| 53 | |||
| 54 | static inline int | ||
| 55 | nand_bch_correct_data(struct mtd_info *mtd, unsigned char *buf, | ||
| 56 | unsigned char *read_ecc, unsigned char *calc_ecc) | ||
| 57 | { | ||
| 58 | return -1; | ||
| 59 | } | ||
| 60 | |||
| 61 | static inline struct nand_bch_control * | ||
| 62 | nand_bch_init(struct mtd_info *mtd, unsigned int eccsize, | ||
| 63 | unsigned int eccbytes, struct nand_ecclayout **ecclayout) | ||
| 64 | { | ||
| 65 | return NULL; | ||
| 66 | } | ||
| 67 | |||
| 68 | static inline void nand_bch_free(struct nand_bch_control *nbc) {} | ||
| 69 | |||
| 70 | #endif /* CONFIG_MTD_NAND_ECC_BCH */ | ||
| 71 | |||
| 72 | #endif /* __MTD_NAND_BCH_H__ */ | ||
diff --git a/include/linux/mtd/onenand.h b/include/linux/mtd/onenand.h index ae418e41d8f..52b6f187bf4 100644 --- a/include/linux/mtd/onenand.h +++ b/include/linux/mtd/onenand.h | |||
| @@ -198,6 +198,7 @@ struct onenand_chip { | |||
| 198 | #define ONENAND_SKIP_UNLOCK_CHECK (0x0100) | 198 | #define ONENAND_SKIP_UNLOCK_CHECK (0x0100) |
| 199 | #define ONENAND_PAGEBUF_ALLOC (0x1000) | 199 | #define ONENAND_PAGEBUF_ALLOC (0x1000) |
| 200 | #define ONENAND_OOBBUF_ALLOC (0x2000) | 200 | #define ONENAND_OOBBUF_ALLOC (0x2000) |
| 201 | #define ONENAND_SKIP_INITIAL_UNLOCKING (0x4000) | ||
| 201 | 202 | ||
| 202 | #define ONENAND_IS_4KB_PAGE(this) \ | 203 | #define ONENAND_IS_4KB_PAGE(this) \ |
| 203 | (this->options & ONENAND_HAS_4KB_PAGE) | 204 | (this->options & ONENAND_HAS_4KB_PAGE) |
diff --git a/include/linux/nfs_page.h b/include/linux/nfs_page.h index 8023e4e2513..91af2e49fa3 100644 --- a/include/linux/nfs_page.h +++ b/include/linux/nfs_page.h | |||
| @@ -78,7 +78,6 @@ extern struct nfs_page *nfs_create_request(struct nfs_open_context *ctx, | |||
| 78 | struct page *page, | 78 | struct page *page, |
| 79 | unsigned int offset, | 79 | unsigned int offset, |
| 80 | unsigned int count); | 80 | unsigned int count); |
| 81 | extern void nfs_clear_request(struct nfs_page *req); | ||
| 82 | extern void nfs_release_request(struct nfs_page *req); | 81 | extern void nfs_release_request(struct nfs_page *req); |
| 83 | 82 | ||
| 84 | 83 | ||
diff --git a/include/linux/regulator/ab8500.h b/include/linux/regulator/ab8500.h index 6a210f1511f..76579f964a2 100644 --- a/include/linux/regulator/ab8500.h +++ b/include/linux/regulator/ab8500.h | |||
| @@ -3,8 +3,8 @@ | |||
| 3 | * | 3 | * |
| 4 | * License Terms: GNU General Public License v2 | 4 | * License Terms: GNU General Public License v2 |
| 5 | * | 5 | * |
| 6 | * Author: Sundar Iyer <sundar.iyer@stericsson.com> for ST-Ericsson | 6 | * Authors: Sundar Iyer <sundar.iyer@stericsson.com> for ST-Ericsson |
| 7 | * | 7 | * Bengt Jonsson <bengt.g.jonsson@stericsson.com> for ST-Ericsson |
| 8 | */ | 8 | */ |
| 9 | 9 | ||
| 10 | #ifndef __LINUX_MFD_AB8500_REGULATOR_H | 10 | #ifndef __LINUX_MFD_AB8500_REGULATOR_H |
| @@ -17,6 +17,7 @@ enum ab8500_regulator_id { | |||
| 17 | AB8500_LDO_AUX3, | 17 | AB8500_LDO_AUX3, |
| 18 | AB8500_LDO_INTCORE, | 18 | AB8500_LDO_INTCORE, |
| 19 | AB8500_LDO_TVOUT, | 19 | AB8500_LDO_TVOUT, |
| 20 | AB8500_LDO_USB, | ||
| 20 | AB8500_LDO_AUDIO, | 21 | AB8500_LDO_AUDIO, |
| 21 | AB8500_LDO_ANAMIC1, | 22 | AB8500_LDO_ANAMIC1, |
| 22 | AB8500_LDO_ANAMIC2, | 23 | AB8500_LDO_ANAMIC2, |
| @@ -24,4 +25,50 @@ enum ab8500_regulator_id { | |||
| 24 | AB8500_LDO_ANA, | 25 | AB8500_LDO_ANA, |
| 25 | AB8500_NUM_REGULATORS, | 26 | AB8500_NUM_REGULATORS, |
| 26 | }; | 27 | }; |
| 28 | |||
| 29 | /* AB8500 register initialization */ | ||
| 30 | struct ab8500_regulator_reg_init { | ||
| 31 | int id; | ||
| 32 | u8 value; | ||
| 33 | }; | ||
| 34 | |||
| 35 | #define INIT_REGULATOR_REGISTER(_id, _value) \ | ||
| 36 | { \ | ||
| 37 | .id = _id, \ | ||
| 38 | .value = _value, \ | ||
| 39 | } | ||
| 40 | |||
| 41 | /* AB8500 registers */ | ||
| 42 | enum ab8500_regulator_reg { | ||
| 43 | AB8500_REGUREQUESTCTRL2, | ||
| 44 | AB8500_REGUREQUESTCTRL3, | ||
| 45 | AB8500_REGUREQUESTCTRL4, | ||
| 46 | AB8500_REGUSYSCLKREQ1HPVALID1, | ||
| 47 | AB8500_REGUSYSCLKREQ1HPVALID2, | ||
| 48 | AB8500_REGUHWHPREQ1VALID1, | ||
| 49 | AB8500_REGUHWHPREQ1VALID2, | ||
| 50 | AB8500_REGUHWHPREQ2VALID1, | ||
| 51 | AB8500_REGUHWHPREQ2VALID2, | ||
| 52 | AB8500_REGUSWHPREQVALID1, | ||
| 53 | AB8500_REGUSWHPREQVALID2, | ||
| 54 | AB8500_REGUSYSCLKREQVALID1, | ||
| 55 | AB8500_REGUSYSCLKREQVALID2, | ||
| 56 | AB8500_REGUMISC1, | ||
| 57 | AB8500_VAUDIOSUPPLY, | ||
| 58 | AB8500_REGUCTRL1VAMIC, | ||
| 59 | AB8500_VPLLVANAREGU, | ||
| 60 | AB8500_VREFDDR, | ||
| 61 | AB8500_EXTSUPPLYREGU, | ||
| 62 | AB8500_VAUX12REGU, | ||
| 63 | AB8500_VRF1VAUX3REGU, | ||
| 64 | AB8500_VAUX1SEL, | ||
| 65 | AB8500_VAUX2SEL, | ||
| 66 | AB8500_VRF1VAUX3SEL, | ||
| 67 | AB8500_REGUCTRL2SPARE, | ||
| 68 | AB8500_REGUCTRLDISCH, | ||
| 69 | AB8500_REGUCTRLDISCH2, | ||
| 70 | AB8500_VSMPS1SEL1, | ||
| 71 | AB8500_NUM_REGULATOR_REGISTERS, | ||
| 72 | }; | ||
| 73 | |||
| 27 | #endif | 74 | #endif |
diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h index 7954f6bd7ed..9e87c1cb727 100644 --- a/include/linux/regulator/consumer.h +++ b/include/linux/regulator/consumer.h | |||
| @@ -153,6 +153,8 @@ int regulator_list_voltage(struct regulator *regulator, unsigned selector); | |||
| 153 | int regulator_is_supported_voltage(struct regulator *regulator, | 153 | int regulator_is_supported_voltage(struct regulator *regulator, |
| 154 | int min_uV, int max_uV); | 154 | int min_uV, int max_uV); |
| 155 | int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV); | 155 | int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV); |
| 156 | int regulator_set_voltage_time(struct regulator *regulator, | ||
| 157 | int old_uV, int new_uV); | ||
| 156 | int regulator_get_voltage(struct regulator *regulator); | 158 | int regulator_get_voltage(struct regulator *regulator); |
| 157 | int regulator_sync_voltage(struct regulator *regulator); | 159 | int regulator_sync_voltage(struct regulator *regulator); |
| 158 | int regulator_set_current_limit(struct regulator *regulator, | 160 | int regulator_set_current_limit(struct regulator *regulator, |
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h index b8ed16a33c4..6c433b89c80 100644 --- a/include/linux/regulator/driver.h +++ b/include/linux/regulator/driver.h | |||
| @@ -63,7 +63,11 @@ enum regulator_status { | |||
| 63 | * when running with the specified parameters. | 63 | * when running with the specified parameters. |
| 64 | * | 64 | * |
| 65 | * @enable_time: Time taken for the regulator voltage output voltage to | 65 | * @enable_time: Time taken for the regulator voltage output voltage to |
| 66 | * stabalise after being enabled, in microseconds. | 66 | * stabilise after being enabled, in microseconds. |
| 67 | * @set_voltage_time_sel: Time taken for the regulator voltage output voltage | ||
| 68 | * to stabilise after being set to a new value, in microseconds. | ||
| 69 | * The function provides the from and to voltage selector, the | ||
| 70 | * function should return the worst case. | ||
| 67 | * | 71 | * |
| 68 | * @set_suspend_voltage: Set the voltage for the regulator when the system | 72 | * @set_suspend_voltage: Set the voltage for the regulator when the system |
| 69 | * is suspended. | 73 | * is suspended. |
| @@ -103,8 +107,11 @@ struct regulator_ops { | |||
| 103 | int (*set_mode) (struct regulator_dev *, unsigned int mode); | 107 | int (*set_mode) (struct regulator_dev *, unsigned int mode); |
| 104 | unsigned int (*get_mode) (struct regulator_dev *); | 108 | unsigned int (*get_mode) (struct regulator_dev *); |
| 105 | 109 | ||
| 106 | /* Time taken to enable the regulator */ | 110 | /* Time taken to enable or set voltage on the regulator */ |
| 107 | int (*enable_time) (struct regulator_dev *); | 111 | int (*enable_time) (struct regulator_dev *); |
| 112 | int (*set_voltage_time_sel) (struct regulator_dev *, | ||
| 113 | unsigned int old_selector, | ||
| 114 | unsigned int new_selector); | ||
| 108 | 115 | ||
| 109 | /* report regulator status ... most other accessors report | 116 | /* report regulator status ... most other accessors report |
| 110 | * control inputs, this reports results of combining inputs | 117 | * control inputs, this reports results of combining inputs |
diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h index 761c745b9c2..c4c4fc45f85 100644 --- a/include/linux/regulator/machine.h +++ b/include/linux/regulator/machine.h | |||
| @@ -186,6 +186,7 @@ struct regulator_init_data { | |||
| 186 | }; | 186 | }; |
| 187 | 187 | ||
| 188 | int regulator_suspend_prepare(suspend_state_t state); | 188 | int regulator_suspend_prepare(suspend_state_t state); |
| 189 | int regulator_suspend_finish(void); | ||
| 189 | 190 | ||
| 190 | #ifdef CONFIG_REGULATOR | 191 | #ifdef CONFIG_REGULATOR |
| 191 | void regulator_has_full_constraints(void); | 192 | void regulator_has_full_constraints(void); |
diff --git a/include/sound/pcm.h b/include/sound/pcm.h index 430a9cc045e..e1bad113061 100644 --- a/include/sound/pcm.h +++ b/include/sound/pcm.h | |||
| @@ -1031,9 +1031,7 @@ int snd_pcm_lib_mmap_iomem(struct snd_pcm_substream *substream, struct vm_area_s | |||
| 1031 | #define snd_pcm_lib_mmap_iomem NULL | 1031 | #define snd_pcm_lib_mmap_iomem NULL |
| 1032 | #endif | 1032 | #endif |
| 1033 | 1033 | ||
| 1034 | int snd_pcm_lib_mmap_noncached(struct snd_pcm_substream *substream, | 1034 | #define snd_pcm_lib_mmap_vmalloc NULL |
| 1035 | struct vm_area_struct *area); | ||
| 1036 | #define snd_pcm_lib_mmap_vmalloc snd_pcm_lib_mmap_noncached | ||
| 1037 | 1035 | ||
| 1038 | static inline void snd_pcm_limit_isa_dma_size(int dma, size_t *max) | 1036 | static inline void snd_pcm_limit_isa_dma_size(int dma, size_t *max) |
| 1039 | { | 1037 | { |
diff --git a/ipc/util.c b/ipc/util.c index 8fd1b891ec0..5c0d28921ba 100644 --- a/ipc/util.c +++ b/ipc/util.c | |||
| @@ -317,6 +317,7 @@ retry: | |||
| 317 | 317 | ||
| 318 | /** | 318 | /** |
| 319 | * ipc_check_perms - check security and permissions for an IPC | 319 | * ipc_check_perms - check security and permissions for an IPC |
| 320 | * @ns: IPC namespace | ||
| 320 | * @ipcp: ipc permission set | 321 | * @ipcp: ipc permission set |
| 321 | * @ops: the actual security routine to call | 322 | * @ops: the actual security routine to call |
| 322 | * @params: its parameters | 323 | * @params: its parameters |
| @@ -607,6 +608,7 @@ void ipc_rcu_putref(void *ptr) | |||
| 607 | 608 | ||
| 608 | /** | 609 | /** |
| 609 | * ipcperms - check IPC permissions | 610 | * ipcperms - check IPC permissions |
| 611 | * @ns: IPC namespace | ||
| 610 | * @ipcp: IPC permission set | 612 | * @ipcp: IPC permission set |
| 611 | * @flag: desired permission set. | 613 | * @flag: desired permission set. |
| 612 | * | 614 | * |
| @@ -769,7 +771,7 @@ void ipc_update_perm(struct ipc64_perm *in, struct kern_ipc_perm *out) | |||
| 769 | 771 | ||
| 770 | /** | 772 | /** |
| 771 | * ipcctl_pre_down - retrieve an ipc and check permissions for some IPC_XXX cmd | 773 | * ipcctl_pre_down - retrieve an ipc and check permissions for some IPC_XXX cmd |
| 772 | * @ids: the ipc namespace | 774 | * @ns: the ipc namespace |
| 773 | * @ids: the table of ids where to look for the ipc | 775 | * @ids: the table of ids where to look for the ipc |
| 774 | * @id: the id of the ipc to retrieve | 776 | * @id: the id of the ipc to retrieve |
| 775 | * @cmd: the cmd to check | 777 | * @cmd: the cmd to check |
diff --git a/lib/Kconfig b/lib/Kconfig index 23fa7a359db..9c10e38fc60 100644 --- a/lib/Kconfig +++ b/lib/Kconfig | |||
| @@ -158,6 +158,45 @@ config REED_SOLOMON_DEC16 | |||
| 158 | boolean | 158 | boolean |
| 159 | 159 | ||
| 160 | # | 160 | # |
| 161 | # BCH support is selected if needed | ||
| 162 | # | ||
| 163 | config BCH | ||
| 164 | tristate | ||
| 165 | |||
| 166 | config BCH_CONST_PARAMS | ||
| 167 | boolean | ||
| 168 | help | ||
| 169 | Drivers may select this option to force specific constant | ||
| 170 | values for parameters 'm' (Galois field order) and 't' | ||
| 171 | (error correction capability). Those specific values must | ||
| 172 | be set by declaring default values for symbols BCH_CONST_M | ||
| 173 | and BCH_CONST_T. | ||
| 174 | Doing so will enable extra compiler optimizations, | ||
| 175 | improving encoding and decoding performance up to 2x for | ||
| 176 | usual (m,t) values (typically such that m*t < 200). | ||
| 177 | When this option is selected, the BCH library supports | ||
| 178 | only a single (m,t) configuration. This is mainly useful | ||
| 179 | for NAND flash board drivers requiring known, fixed BCH | ||
| 180 | parameters. | ||
| 181 | |||
| 182 | config BCH_CONST_M | ||
| 183 | int | ||
| 184 | range 5 15 | ||
| 185 | help | ||
| 186 | Constant value for Galois field order 'm'. If 'k' is the | ||
| 187 | number of data bits to protect, 'm' should be chosen such | ||
| 188 | that (k + m*t) <= 2**m - 1. | ||
| 189 | Drivers should declare a default value for this symbol if | ||
| 190 | they select option BCH_CONST_PARAMS. | ||
| 191 | |||
| 192 | config BCH_CONST_T | ||
| 193 | int | ||
| 194 | help | ||
| 195 | Constant value for error correction capability in bits 't'. | ||
| 196 | Drivers should declare a default value for this symbol if | ||
| 197 | they select option BCH_CONST_PARAMS. | ||
| 198 | |||
| 199 | # | ||
| 161 | # Textsearch support is select'ed if needed | 200 | # Textsearch support is select'ed if needed |
| 162 | # | 201 | # |
| 163 | config TEXTSEARCH | 202 | config TEXTSEARCH |
diff --git a/lib/Makefile b/lib/Makefile index d7872b5c4c1..ef0f2857115 100644 --- a/lib/Makefile +++ b/lib/Makefile | |||
| @@ -69,6 +69,7 @@ obj-$(CONFIG_GENERIC_ALLOCATOR) += genalloc.o | |||
| 69 | obj-$(CONFIG_ZLIB_INFLATE) += zlib_inflate/ | 69 | obj-$(CONFIG_ZLIB_INFLATE) += zlib_inflate/ |
| 70 | obj-$(CONFIG_ZLIB_DEFLATE) += zlib_deflate/ | 70 | obj-$(CONFIG_ZLIB_DEFLATE) += zlib_deflate/ |
| 71 | obj-$(CONFIG_REED_SOLOMON) += reed_solomon/ | 71 | obj-$(CONFIG_REED_SOLOMON) += reed_solomon/ |
| 72 | obj-$(CONFIG_BCH) += bch.o | ||
| 72 | obj-$(CONFIG_LZO_COMPRESS) += lzo/ | 73 | obj-$(CONFIG_LZO_COMPRESS) += lzo/ |
| 73 | obj-$(CONFIG_LZO_DECOMPRESS) += lzo/ | 74 | obj-$(CONFIG_LZO_DECOMPRESS) += lzo/ |
| 74 | obj-$(CONFIG_XZ_DEC) += xz/ | 75 | obj-$(CONFIG_XZ_DEC) += xz/ |
diff --git a/lib/bch.c b/lib/bch.c new file mode 100644 index 00000000000..bc89dfe4d1b --- /dev/null +++ b/lib/bch.c | |||
| @@ -0,0 +1,1368 @@ | |||
| 1 | /* | ||
| 2 | * Generic binary BCH encoding/decoding library | ||
| 3 | * | ||
| 4 | * This program is free software; you can redistribute it and/or modify it | ||
| 5 | * under the terms of the GNU General Public License version 2 as published by | ||
| 6 | * the Free Software Foundation. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
| 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| 11 | * more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License along with | ||
| 14 | * this program; if not, write to the Free Software Foundation, Inc., 51 | ||
| 15 | * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| 16 | * | ||
| 17 | * Copyright © 2011 Parrot S.A. | ||
| 18 | * | ||
| 19 | * Author: Ivan Djelic <ivan.djelic@parrot.com> | ||
| 20 | * | ||
| 21 | * Description: | ||
| 22 | * | ||
| 23 | * This library provides runtime configurable encoding/decoding of binary | ||
| 24 | * Bose-Chaudhuri-Hocquenghem (BCH) codes. | ||
| 25 | * | ||
| 26 | * Call init_bch to get a pointer to a newly allocated bch_control structure for | ||
| 27 | * the given m (Galois field order), t (error correction capability) and | ||
| 28 | * (optional) primitive polynomial parameters. | ||
| 29 | * | ||
| 30 | * Call encode_bch to compute and store ecc parity bytes to a given buffer. | ||
| 31 | * Call decode_bch to detect and locate errors in received data. | ||
| 32 | * | ||
| 33 | * On systems supporting hw BCH features, intermediate results may be provided | ||
| 34 | * to decode_bch in order to skip certain steps. See decode_bch() documentation | ||
| 35 | * for details. | ||
| 36 | * | ||
| 37 | * Option CONFIG_BCH_CONST_PARAMS can be used to force fixed values of | ||
| 38 | * parameters m and t; thus allowing extra compiler optimizations and providing | ||
| 39 | * better (up to 2x) encoding performance. Using this option makes sense when | ||
| 40 | * (m,t) are fixed and known in advance, e.g. when using BCH error correction | ||
| 41 | * on a particular NAND flash device. | ||
| 42 | * | ||
| 43 | * Algorithmic details: | ||
| 44 | * | ||
| 45 | * Encoding is performed by processing 32 input bits in parallel, using 4 | ||
| 46 | * remainder lookup tables. | ||
| 47 | * | ||
| 48 | * The final stage of decoding involves the following internal steps: | ||
| 49 | * a. Syndrome computation | ||
| 50 | * b. Error locator polynomial computation using Berlekamp-Massey algorithm | ||
| 51 | * c. Error locator root finding (by far the most expensive step) | ||
| 52 | * | ||
| 53 | * In this implementation, step c is not performed using the usual Chien search. | ||
| 54 | * Instead, an alternative approach described in [1] is used. It consists in | ||
| 55 | * factoring the error locator polynomial using the Berlekamp Trace algorithm | ||
| 56 | * (BTA) down to a certain degree (4), after which ad hoc low-degree polynomial | ||
| 57 | * solving techniques [2] are used. The resulting algorithm, called BTZ, yields | ||
| 58 | * much better performance than Chien search for usual (m,t) values (typically | ||
| 59 | * m >= 13, t < 32, see [1]). | ||
| 60 | * | ||
| 61 | * [1] B. Biswas, V. Herbert. Efficient root finding of polynomials over fields | ||
| 62 | * of characteristic 2, in: Western European Workshop on Research in Cryptology | ||
| 63 | * - WEWoRC 2009, Graz, Austria, LNCS, Springer, July 2009, to appear. | ||
| 64 | * [2] [Zin96] V.A. Zinoviev. On the solution of equations of degree 10 over | ||
| 65 | * finite fields GF(2^q). In Rapport de recherche INRIA no 2829, 1996. | ||
| 66 | */ | ||
| 67 | |||
| 68 | #include <linux/kernel.h> | ||
| 69 | #include <linux/errno.h> | ||
| 70 | #include <linux/init.h> | ||
| 71 | #include <linux/module.h> | ||
| 72 | #include <linux/slab.h> | ||
| 73 | #include <linux/bitops.h> | ||
| 74 | #include <asm/byteorder.h> | ||
| 75 | #include <linux/bch.h> | ||
| 76 | |||
| 77 | #if defined(CONFIG_BCH_CONST_PARAMS) | ||
| 78 | #define GF_M(_p) (CONFIG_BCH_CONST_M) | ||
| 79 | #define GF_T(_p) (CONFIG_BCH_CONST_T) | ||
| 80 | #define GF_N(_p) ((1 << (CONFIG_BCH_CONST_M))-1) | ||
| 81 | #else | ||
| 82 | #define GF_M(_p) ((_p)->m) | ||
| 83 | #define GF_T(_p) ((_p)->t) | ||
| 84 | #define GF_N(_p) ((_p)->n) | ||
| 85 | #endif | ||
| 86 | |||
| 87 | #define BCH_ECC_WORDS(_p) DIV_ROUND_UP(GF_M(_p)*GF_T(_p), 32) | ||
| 88 | #define BCH_ECC_BYTES(_p) DIV_ROUND_UP(GF_M(_p)*GF_T(_p), 8) | ||
| 89 | |||
| 90 | #ifndef dbg | ||
| 91 | #define dbg(_fmt, args...) do {} while (0) | ||
| 92 | #endif | ||
| 93 | |||
| 94 | /* | ||
| 95 | * represent a polynomial over GF(2^m) | ||
| 96 | */ | ||
| 97 | struct gf_poly { | ||
| 98 | unsigned int deg; /* polynomial degree */ | ||
| 99 | unsigned int c[0]; /* polynomial terms */ | ||
| 100 | }; | ||
| 101 | |||
| 102 | /* given its degree, compute a polynomial size in bytes */ | ||
| 103 | #define GF_POLY_SZ(_d) (sizeof(struct gf_poly)+((_d)+1)*sizeof(unsigned int)) | ||
| 104 | |||
| 105 | /* polynomial of degree 1 */ | ||
| 106 | struct gf_poly_deg1 { | ||
| 107 | struct gf_poly poly; | ||
| 108 | unsigned int c[2]; | ||
| 109 | }; | ||
| 110 | |||
| 111 | /* | ||
| 112 | * same as encode_bch(), but process input data one byte at a time | ||
| 113 | */ | ||
| 114 | static void encode_bch_unaligned(struct bch_control *bch, | ||
| 115 | const unsigned char *data, unsigned int len, | ||
| 116 | uint32_t *ecc) | ||
| 117 | { | ||
| 118 | int i; | ||
| 119 | const uint32_t *p; | ||
| 120 | const int l = BCH_ECC_WORDS(bch)-1; | ||
| 121 | |||
| 122 | while (len--) { | ||
| 123 | p = bch->mod8_tab + (l+1)*(((ecc[0] >> 24)^(*data++)) & 0xff); | ||
| 124 | |||
| 125 | for (i = 0; i < l; i++) | ||
| 126 | ecc[i] = ((ecc[i] << 8)|(ecc[i+1] >> 24))^(*p++); | ||
| 127 | |||
| 128 | ecc[l] = (ecc[l] << 8)^(*p); | ||
| 129 | } | ||
| 130 | } | ||
| 131 | |||
| 132 | /* | ||
| 133 | * convert ecc bytes to aligned, zero-padded 32-bit ecc words | ||
| 134 | */ | ||
| 135 | static void load_ecc8(struct bch_control *bch, uint32_t *dst, | ||
| 136 | const uint8_t *src) | ||
| 137 | { | ||
| 138 | uint8_t pad[4] = {0, 0, 0, 0}; | ||
| 139 | unsigned int i, nwords = BCH_ECC_WORDS(bch)-1; | ||
| 140 | |||
| 141 | for (i = 0; i < nwords; i++, src += 4) | ||
| 142 | dst[i] = (src[0] << 24)|(src[1] << 16)|(src[2] << 8)|src[3]; | ||
| 143 | |||
| 144 | memcpy(pad, src, BCH_ECC_BYTES(bch)-4*nwords); | ||
| 145 | dst[nwords] = (pad[0] << 24)|(pad[1] << 16)|(pad[2] << 8)|pad[3]; | ||
| 146 | } | ||
| 147 | |||
| 148 | /* | ||
| 149 | * convert 32-bit ecc words to ecc bytes | ||
| 150 | */ | ||
| 151 | static void store_ecc8(struct bch_control *bch, uint8_t *dst, | ||
| 152 | const uint32_t *src) | ||
| 153 | { | ||
| 154 | uint8_t pad[4]; | ||
| 155 | unsigned int i, nwords = BCH_ECC_WORDS(bch)-1; | ||
| 156 | |||
| 157 | for (i = 0; i < nwords; i++) { | ||
| 158 | *dst++ = (src[i] >> 24); | ||
| 159 | *dst++ = (src[i] >> 16) & 0xff; | ||
| 160 | *dst++ = (src[i] >> 8) & 0xff; | ||
| 161 | *dst++ = (src[i] >> 0) & 0xff; | ||
| 162 | } | ||
| 163 | pad[0] = (src[nwords] >> 24); | ||
| 164 | pad[1] = (src[nwords] >> 16) & 0xff; | ||
| 165 | pad[2] = (src[nwords] >> 8) & 0xff; | ||
| 166 | pad[3] = (src[nwords] >> 0) & 0xff; | ||
| 167 | memcpy(dst, pad, BCH_ECC_BYTES(bch)-4*nwords); | ||
| 168 | } | ||
| 169 | |||
| 170 | /** | ||
| 171 | * encode_bch - calculate BCH ecc parity of data | ||
| 172 | * @bch: BCH control structure | ||
| 173 | * @data: data to encode | ||
| 174 | * @len: data length in bytes | ||
| 175 | * @ecc: ecc parity data, must be initialized by caller | ||
| 176 | * | ||
| 177 | * The @ecc parity array is used both as input and output parameter, in order to | ||
| 178 | * allow incremental computations. It should be of the size indicated by member | ||
| 179 | * @ecc_bytes of @bch, and should be initialized to 0 before the first call. | ||
| 180 | * | ||
| 181 | * The exact number of computed ecc parity bits is given by member @ecc_bits of | ||
| 182 | * @bch; it may be less than m*t for large values of t. | ||
| 183 | */ | ||
| 184 | void encode_bch(struct bch_control *bch, const uint8_t *data, | ||
| 185 | unsigned int len, uint8_t *ecc) | ||
| 186 | { | ||
| 187 | const unsigned int l = BCH_ECC_WORDS(bch)-1; | ||
| 188 | unsigned int i, mlen; | ||
| 189 | unsigned long m; | ||
| 190 | uint32_t w, r[l+1]; | ||
| 191 | const uint32_t * const tab0 = bch->mod8_tab; | ||
| 192 | const uint32_t * const tab1 = tab0 + 256*(l+1); | ||
| 193 | const uint32_t * const tab2 = tab1 + 256*(l+1); | ||
| 194 | const uint32_t * const tab3 = tab2 + 256*(l+1); | ||
| 195 | const uint32_t *pdata, *p0, *p1, *p2, *p3; | ||
| 196 | |||
| 197 | if (ecc) { | ||
| 198 | /* load ecc parity bytes into internal 32-bit buffer */ | ||
| 199 | load_ecc8(bch, bch->ecc_buf, ecc); | ||
| 200 | } else { | ||
| 201 | memset(bch->ecc_buf, 0, sizeof(r)); | ||
| 202 | } | ||
| 203 | |||
| 204 | /* process first unaligned data bytes */ | ||
| 205 | m = ((unsigned long)data) & 3; | ||
| 206 | if (m) { | ||
| 207 | mlen = (len < (4-m)) ? len : 4-m; | ||
| 208 | encode_bch_unaligned(bch, data, mlen, bch->ecc_buf); | ||
| 209 | data += mlen; | ||
| 210 | len -= mlen; | ||
| 211 | } | ||
| 212 | |||
| 213 | /* process 32-bit aligned data words */ | ||
| 214 | pdata = (uint32_t *)data; | ||
| 215 | mlen = len/4; | ||
| 216 | data += 4*mlen; | ||
| 217 | len -= 4*mlen; | ||
| 218 | memcpy(r, bch->ecc_buf, sizeof(r)); | ||
| 219 | |||
| 220 | /* | ||
| 221 | * split each 32-bit word into 4 polynomials of weight 8 as follows: | ||
| 222 | * | ||
| 223 | * 31 ...24 23 ...16 15 ... 8 7 ... 0 | ||
| 224 | * xxxxxxxx yyyyyyyy zzzzzzzz tttttttt | ||
| 225 | * tttttttt mod g = r0 (precomputed) | ||
| 226 | * zzzzzzzz 00000000 mod g = r1 (precomputed) | ||
| 227 | * yyyyyyyy 00000000 00000000 mod g = r2 (precomputed) | ||
| 228 | * xxxxxxxx 00000000 00000000 00000000 mod g = r3 (precomputed) | ||
| 229 | * xxxxxxxx yyyyyyyy zzzzzzzz tttttttt mod g = r0^r1^r2^r3 | ||
| 230 | */ | ||
| 231 | while (mlen--) { | ||
| 232 | /* input data is read in big-endian format */ | ||
| 233 | w = r[0]^cpu_to_be32(*pdata++); | ||
| 234 | p0 = tab0 + (l+1)*((w >> 0) & 0xff); | ||
| 235 | p1 = tab1 + (l+1)*((w >> 8) & 0xff); | ||
| 236 | p2 = tab2 + (l+1)*((w >> 16) & 0xff); | ||
| 237 | p3 = tab3 + (l+1)*((w >> 24) & 0xff); | ||
| 238 | |||
| 239 | for (i = 0; i < l; i++) | ||
| 240 | r[i] = r[i+1]^p0[i]^p1[i]^p2[i]^p3[i]; | ||
| 241 | |||
| 242 | r[l] = p0[l]^p1[l]^p2[l]^p3[l]; | ||
| 243 | } | ||
| 244 | memcpy(bch->ecc_buf, r, sizeof(r)); | ||
| 245 | |||
| 246 | /* process last unaligned bytes */ | ||
| 247 | if (len) | ||
| 248 | encode_bch_unaligned(bch, data, len, bch->ecc_buf); | ||
| 249 | |||
| 250 | /* store ecc parity bytes into original parity buffer */ | ||
| 251 | if (ecc) | ||
| 252 | store_ecc8(bch, ecc, bch->ecc_buf); | ||
| 253 | } | ||
| 254 | EXPORT_SYMBOL_GPL(encode_bch); | ||
| 255 | |||
| 256 | static inline int modulo(struct bch_control *bch, unsigned int v) | ||
| 257 | { | ||
| 258 | const unsigned int n = GF_N(bch); | ||
| 259 | while (v >= n) { | ||
| 260 | v -= n; | ||
| 261 | v = (v & n) + (v >> GF_M(bch)); | ||
| 262 | } | ||
| 263 | return v; | ||
| 264 | } | ||
| 265 | |||
| 266 | /* | ||
| 267 | * shorter and faster modulo function, only works when v < 2N. | ||
| 268 | */ | ||
| 269 | static inline int mod_s(struct bch_control *bch, unsigned int v) | ||
| 270 | { | ||
| 271 | const unsigned int n = GF_N(bch); | ||
| 272 | return (v < n) ? v : v-n; | ||
| 273 | } | ||
| 274 | |||
| 275 | static inline int deg(unsigned int poly) | ||
| 276 | { | ||
| 277 | /* polynomial degree is the most-significant bit index */ | ||
| 278 | return fls(poly)-1; | ||
| 279 | } | ||
| 280 | |||
| 281 | static inline int parity(unsigned int x) | ||
| 282 | { | ||
| 283 | /* | ||
| 284 | * public domain code snippet, lifted from | ||
| 285 | * http://www-graphics.stanford.edu/~seander/bithacks.html | ||
| 286 | */ | ||
| 287 | x ^= x >> 1; | ||
| 288 | x ^= x >> 2; | ||
| 289 | x = (x & 0x11111111U) * 0x11111111U; | ||
| 290 | return (x >> 28) & 1; | ||
| 291 | } | ||
| 292 | |||
| 293 | /* Galois field basic operations: multiply, divide, inverse, etc. */ | ||
| 294 | |||
| 295 | static inline unsigned int gf_mul(struct bch_control *bch, unsigned int a, | ||
| 296 | unsigned int b) | ||
| 297 | { | ||
| 298 | return (a && b) ? bch->a_pow_tab[mod_s(bch, bch->a_log_tab[a]+ | ||
| 299 | bch->a_log_tab[b])] : 0; | ||
| 300 | } | ||
| 301 | |||
| 302 | static inline unsigned int gf_sqr(struct bch_control *bch, unsigned int a) | ||
| 303 | { | ||
| 304 | return a ? bch->a_pow_tab[mod_s(bch, 2*bch->a_log_tab[a])] : 0; | ||
| 305 | } | ||
| 306 | |||
| 307 | static inline unsigned int gf_div(struct bch_control *bch, unsigned int a, | ||
| 308 | unsigned int b) | ||
| 309 | { | ||
| 310 | return a ? bch->a_pow_tab[mod_s(bch, bch->a_log_tab[a]+ | ||
| 311 | GF_N(bch)-bch->a_log_tab[b])] : 0; | ||
| 312 | } | ||
| 313 | |||
| 314 | static inline unsigned int gf_inv(struct bch_control *bch, unsigned int a) | ||
| 315 | { | ||
| 316 | return bch->a_pow_tab[GF_N(bch)-bch->a_log_tab[a]]; | ||
| 317 | } | ||
| 318 | |||
| 319 | static inline unsigned int a_pow(struct bch_control *bch, int i) | ||
| 320 | { | ||
| 321 | return bch->a_pow_tab[modulo(bch, i)]; | ||
| 322 | } | ||
| 323 | |||
| 324 | static inline int a_log(struct bch_control *bch, unsigned int x) | ||
| 325 | { | ||
| 326 | return bch->a_log_tab[x]; | ||
| 327 | } | ||
| 328 | |||
| 329 | static inline int a_ilog(struct bch_control *bch, unsigned int x) | ||
| 330 | { | ||
| 331 | return mod_s(bch, GF_N(bch)-bch->a_log_tab[x]); | ||
| 332 | } | ||
| 333 | |||
| 334 | /* | ||
| 335 | * compute 2t syndromes of ecc polynomial, i.e. ecc(a^j) for j=1..2t | ||
| 336 | */ | ||
| 337 | static void compute_syndromes(struct bch_control *bch, uint32_t *ecc, | ||
| 338 | unsigned int *syn) | ||
| 339 | { | ||
| 340 | int i, j, s; | ||
| 341 | unsigned int m; | ||
| 342 | uint32_t poly; | ||
| 343 | const int t = GF_T(bch); | ||
| 344 | |||
| 345 | s = bch->ecc_bits; | ||
| 346 | |||
| 347 | /* make sure extra bits in last ecc word are cleared */ | ||
| 348 | m = ((unsigned int)s) & 31; | ||
| 349 | if (m) | ||
| 350 | ecc[s/32] &= ~((1u << (32-m))-1); | ||
| 351 | memset(syn, 0, 2*t*sizeof(*syn)); | ||
| 352 | |||
| 353 | /* compute v(a^j) for j=1 .. 2t-1 */ | ||
| 354 | do { | ||
| 355 | poly = *ecc++; | ||
| 356 | s -= 32; | ||
| 357 | while (poly) { | ||
| 358 | i = deg(poly); | ||
| 359 | for (j = 0; j < 2*t; j += 2) | ||
| 360 | syn[j] ^= a_pow(bch, (j+1)*(i+s)); | ||
| 361 | |||
| 362 | poly ^= (1 << i); | ||
| 363 | } | ||
| 364 | } while (s > 0); | ||
| 365 | |||
| 366 | /* v(a^(2j)) = v(a^j)^2 */ | ||
| 367 | for (j = 0; j < t; j++) | ||
| 368 | syn[2*j+1] = gf_sqr(bch, syn[j]); | ||
| 369 | } | ||
| 370 | |||
| 371 | static void gf_poly_copy(struct gf_poly *dst, struct gf_poly *src) | ||
| 372 | { | ||
| 373 | memcpy(dst, src, GF_POLY_SZ(src->deg)); | ||
| 374 | } | ||
| 375 | |||
| 376 | static int compute_error_locator_polynomial(struct bch_control *bch, | ||
| 377 | const unsigned int *syn) | ||
| 378 | { | ||
| 379 | const unsigned int t = GF_T(bch); | ||
| 380 | const unsigned int n = GF_N(bch); | ||
| 381 | unsigned int i, j, tmp, l, pd = 1, d = syn[0]; | ||
| 382 | struct gf_poly *elp = bch->elp; | ||
| 383 | struct gf_poly *pelp = bch->poly_2t[0]; | ||
| 384 | struct gf_poly *elp_copy = bch->poly_2t[1]; | ||
| 385 | int k, pp = -1; | ||
| 386 | |||
| 387 | memset(pelp, 0, GF_POLY_SZ(2*t)); | ||
| 388 | memset(elp, 0, GF_POLY_SZ(2*t)); | ||
| 389 | |||
| 390 | pelp->deg = 0; | ||
| 391 | pelp->c[0] = 1; | ||
| 392 | elp->deg = 0; | ||
| 393 | elp->c[0] = 1; | ||
| 394 | |||
| 395 | /* use simplified binary Berlekamp-Massey algorithm */ | ||
| 396 | for (i = 0; (i < t) && (elp->deg <= t); i++) { | ||
| 397 | if (d) { | ||
| 398 | k = 2*i-pp; | ||
| 399 | gf_poly_copy(elp_copy, elp); | ||
| 400 | /* e[i+1](X) = e[i](X)+di*dp^-1*X^2(i-p)*e[p](X) */ | ||
| 401 | tmp = a_log(bch, d)+n-a_log(bch, pd); | ||
| 402 | for (j = 0; j <= pelp->deg; j++) { | ||
| 403 | if (pelp->c[j]) { | ||
| 404 | l = a_log(bch, pelp->c[j]); | ||
| 405 | elp->c[j+k] ^= a_pow(bch, tmp+l); | ||
| 406 | } | ||
| 407 | } | ||
| 408 | /* compute l[i+1] = max(l[i]->c[l[p]+2*(i-p]) */ | ||
| 409 | tmp = pelp->deg+k; | ||
| 410 | if (tmp > elp->deg) { | ||
| 411 | elp->deg = tmp; | ||
| 412 | gf_poly_copy(pelp, elp_copy); | ||
| 413 | pd = d; | ||
| 414 | pp = 2*i; | ||
| 415 | } | ||
| 416 | } | ||
| 417 | /* di+1 = S(2i+3)+elp[i+1].1*S(2i+2)+...+elp[i+1].lS(2i+3-l) */ | ||
| 418 | if (i < t-1) { | ||
| 419 | d = syn[2*i+2]; | ||
| 420 | for (j = 1; j <= elp->deg; j++) | ||
| 421 | d ^= gf_mul(bch, elp->c[j], syn[2*i+2-j]); | ||
| 422 | } | ||
| 423 | } | ||
| 424 | dbg("elp=%s\n", gf_poly_str(elp)); | ||
| 425 | return (elp->deg > t) ? -1 : (int)elp->deg; | ||
| 426 | } | ||
| 427 | |||
| 428 | /* | ||
| 429 | * solve a m x m linear system in GF(2) with an expected number of solutions, | ||
| 430 | * and return the number of found solutions | ||
| 431 | */ | ||
| 432 | static int solve_linear_system(struct bch_control *bch, unsigned int *rows, | ||
| 433 | unsigned int *sol, int nsol) | ||
| 434 | { | ||
| 435 | const int m = GF_M(bch); | ||
| 436 | unsigned int tmp, mask; | ||
| 437 | int rem, c, r, p, k, param[m]; | ||
| 438 | |||
| 439 | k = 0; | ||
| 440 | mask = 1 << m; | ||
| 441 | |||
| 442 | /* Gaussian elimination */ | ||
| 443 | for (c = 0; c < m; c++) { | ||
| 444 | rem = 0; | ||
| 445 | p = c-k; | ||
| 446 | /* find suitable row for elimination */ | ||
| 447 | for (r = p; r < m; r++) { | ||
| 448 | if (rows[r] & mask) { | ||
| 449 | if (r != p) { | ||
| 450 | tmp = rows[r]; | ||
| 451 | rows[r] = rows[p]; | ||
| 452 | rows[p] = tmp; | ||
| 453 | } | ||
| 454 | rem = r+1; | ||
| 455 | break; | ||
| 456 | } | ||
| 457 | } | ||
| 458 | if (rem) { | ||
| 459 | /* perform elimination on remaining rows */ | ||
| 460 | tmp = rows[p]; | ||
| 461 | for (r = rem; r < m; r++) { | ||
| 462 | if (rows[r] & mask) | ||
| 463 | rows[r] ^= tmp; | ||
| 464 | } | ||
| 465 | } else { | ||
| 466 | /* elimination not needed, store defective row index */ | ||
| 467 | param[k++] = c; | ||
| 468 | } | ||
| 469 | mask >>= 1; | ||
| 470 | } | ||
| 471 | /* rewrite system, inserting fake parameter rows */ | ||
| 472 | if (k > 0) { | ||
| 473 | p = k; | ||
| 474 | for (r = m-1; r >= 0; r--) { | ||
| 475 | if ((r > m-1-k) && rows[r]) | ||
| 476 | /* system has no solution */ | ||
| 477 | return 0; | ||
| 478 | |||
| 479 | rows[r] = (p && (r == param[p-1])) ? | ||
| 480 | p--, 1u << (m-r) : rows[r-p]; | ||
| 481 | } | ||
| 482 | } | ||
| 483 | |||
| 484 | if (nsol != (1 << k)) | ||
| 485 | /* unexpected number of solutions */ | ||
| 486 | return 0; | ||
| 487 | |||
| 488 | for (p = 0; p < nsol; p++) { | ||
| 489 | /* set parameters for p-th solution */ | ||
| 490 | for (c = 0; c < k; c++) | ||
| 491 | rows[param[c]] = (rows[param[c]] & ~1)|((p >> c) & 1); | ||
| 492 | |||
| 493 | /* compute unique solution */ | ||
| 494 | tmp = 0; | ||
| 495 | for (r = m-1; r >= 0; r--) { | ||
| 496 | mask = rows[r] & (tmp|1); | ||
| 497 | tmp |= parity(mask) << (m-r); | ||
| 498 | } | ||
| 499 | sol[p] = tmp >> 1; | ||
| 500 | } | ||
| 501 | return nsol; | ||
| 502 | } | ||
| 503 | |||
| 504 | /* | ||
| 505 | * this function builds and solves a linear system for finding roots of a degree | ||
| 506 | * 4 affine monic polynomial X^4+aX^2+bX+c over GF(2^m). | ||
| 507 | */ | ||
| 508 | static int find_affine4_roots(struct bch_control *bch, unsigned int a, | ||
| 509 | unsigned int b, unsigned int c, | ||
| 510 | unsigned int *roots) | ||
| 511 | { | ||
| 512 | int i, j, k; | ||
| 513 | const int m = GF_M(bch); | ||
| 514 | unsigned int mask = 0xff, t, rows[16] = {0,}; | ||
| 515 | |||
| 516 | j = a_log(bch, b); | ||
| 517 | k = a_log(bch, a); | ||
| 518 | rows[0] = c; | ||
| 519 | |||
| 520 | /* buid linear system to solve X^4+aX^2+bX+c = 0 */ | ||
| 521 | for (i = 0; i < m; i++) { | ||
| 522 | rows[i+1] = bch->a_pow_tab[4*i]^ | ||
| 523 | (a ? bch->a_pow_tab[mod_s(bch, k)] : 0)^ | ||
| 524 | (b ? bch->a_pow_tab[mod_s(bch, j)] : 0); | ||
| 525 | j++; | ||
| 526 | k += 2; | ||
| 527 | } | ||
| 528 | /* | ||
| 529 | * transpose 16x16 matrix before passing it to linear solver | ||
| 530 | * warning: this code assumes m < 16 | ||
| 531 | */ | ||
| 532 | for (j = 8; j != 0; j >>= 1, mask ^= (mask << j)) { | ||
| 533 | for (k = 0; k < 16; k = (k+j+1) & ~j) { | ||
| 534 | t = ((rows[k] >> j)^rows[k+j]) & mask; | ||
| 535 | rows[k] ^= (t << j); | ||
| 536 | rows[k+j] ^= t; | ||
| 537 | } | ||
| 538 | } | ||
| 539 | return solve_linear_system(bch, rows, roots, 4); | ||
| 540 | } | ||
| 541 | |||
| 542 | /* | ||
| 543 | * compute root r of a degree 1 polynomial over GF(2^m) (returned as log(1/r)) | ||
| 544 | */ | ||
| 545 | static int find_poly_deg1_roots(struct bch_control *bch, struct gf_poly *poly, | ||
| 546 | unsigned int *roots) | ||
| 547 | { | ||
| 548 | int n = 0; | ||
| 549 | |||
| 550 | if (poly->c[0]) | ||
| 551 | /* poly[X] = bX+c with c!=0, root=c/b */ | ||
| 552 | roots[n++] = mod_s(bch, GF_N(bch)-bch->a_log_tab[poly->c[0]]+ | ||
| 553 | bch->a_log_tab[poly->c[1]]); | ||
| 554 | return n; | ||
| 555 | } | ||
| 556 | |||
| 557 | /* | ||
| 558 | * compute roots of a degree 2 polynomial over GF(2^m) | ||
| 559 | */ | ||
| 560 | static int find_poly_deg2_roots(struct bch_control *bch, struct gf_poly *poly, | ||
| 561 | unsigned int *roots) | ||
| 562 | { | ||
| 563 | int n = 0, i, l0, l1, l2; | ||
| 564 | unsigned int u, v, r; | ||
| 565 | |||
| 566 | if (poly->c[0] && poly->c[1]) { | ||
| 567 | |||
| 568 | l0 = bch->a_log_tab[poly->c[0]]; | ||
| 569 | l1 = bch->a_log_tab[poly->c[1]]; | ||
| 570 | l2 = bch->a_log_tab[poly->c[2]]; | ||
| 571 | |||
| 572 | /* using z=a/bX, transform aX^2+bX+c into z^2+z+u (u=ac/b^2) */ | ||
| 573 | u = a_pow(bch, l0+l2+2*(GF_N(bch)-l1)); | ||
| 574 | /* | ||
| 575 | * let u = sum(li.a^i) i=0..m-1; then compute r = sum(li.xi): | ||
| 576 | * r^2+r = sum(li.(xi^2+xi)) = sum(li.(a^i+Tr(a^i).a^k)) = | ||
| 577 | * u + sum(li.Tr(a^i).a^k) = u+a^k.Tr(sum(li.a^i)) = u+a^k.Tr(u) | ||
| 578 | * i.e. r and r+1 are roots iff Tr(u)=0 | ||
| 579 | */ | ||
| 580 | r = 0; | ||
| 581 | v = u; | ||
| 582 | while (v) { | ||
| 583 | i = deg(v); | ||
| 584 | r ^= bch->xi_tab[i]; | ||
| 585 | v ^= (1 << i); | ||
| 586 | } | ||
| 587 | /* verify root */ | ||
| 588 | if ((gf_sqr(bch, r)^r) == u) { | ||
| 589 | /* reverse z=a/bX transformation and compute log(1/r) */ | ||
| 590 | roots[n++] = modulo(bch, 2*GF_N(bch)-l1- | ||
| 591 | bch->a_log_tab[r]+l2); | ||
| 592 | roots[n++] = modulo(bch, 2*GF_N(bch)-l1- | ||
| 593 | bch->a_log_tab[r^1]+l2); | ||
| 594 | } | ||
| 595 | } | ||
| 596 | return n; | ||
| 597 | } | ||
| 598 | |||
| 599 | /* | ||
| 600 | * compute roots of a degree 3 polynomial over GF(2^m) | ||
| 601 | */ | ||
| 602 | static int find_poly_deg3_roots(struct bch_control *bch, struct gf_poly *poly, | ||
| 603 | unsigned int *roots) | ||
| 604 | { | ||
| 605 | int i, n = 0; | ||
| 606 | unsigned int a, b, c, a2, b2, c2, e3, tmp[4]; | ||
| 607 | |||
| 608 | if (poly->c[0]) { | ||
| 609 | /* transform polynomial into monic X^3 + a2X^2 + b2X + c2 */ | ||
| 610 | e3 = poly->c[3]; | ||
| 611 | c2 = gf_div(bch, poly->c[0], e3); | ||
| 612 | b2 = gf_div(bch, poly->c[1], e3); | ||
| 613 | a2 = gf_div(bch, poly->c[2], e3); | ||
| 614 | |||
| 615 | /* (X+a2)(X^3+a2X^2+b2X+c2) = X^4+aX^2+bX+c (affine) */ | ||
| 616 | c = gf_mul(bch, a2, c2); /* c = a2c2 */ | ||
| 617 | b = gf_mul(bch, a2, b2)^c2; /* b = a2b2 + c2 */ | ||
| 618 | a = gf_sqr(bch, a2)^b2; /* a = a2^2 + b2 */ | ||
| 619 | |||
| 620 | /* find the 4 roots of this affine polynomial */ | ||
| 621 | if (find_affine4_roots(bch, a, b, c, tmp) == 4) { | ||
| 622 | /* remove a2 from final list of roots */ | ||
| 623 | for (i = 0; i < 4; i++) { | ||
| 624 | if (tmp[i] != a2) | ||
| 625 | roots[n++] = a_ilog(bch, tmp[i]); | ||
| 626 | } | ||
| 627 | } | ||
| 628 | } | ||
| 629 | return n; | ||
| 630 | } | ||
| 631 | |||
| 632 | /* | ||
| 633 | * compute roots of a degree 4 polynomial over GF(2^m) | ||
| 634 | */ | ||
| 635 | static int find_poly_deg4_roots(struct bch_control *bch, struct gf_poly *poly, | ||
| 636 | unsigned int *roots) | ||
| 637 | { | ||
| 638 | int i, l, n = 0; | ||
| 639 | unsigned int a, b, c, d, e = 0, f, a2, b2, c2, e4; | ||
| 640 | |||
| 641 | if (poly->c[0] == 0) | ||
| 642 | return 0; | ||
| 643 | |||
| 644 | /* transform polynomial into monic X^4 + aX^3 + bX^2 + cX + d */ | ||
| 645 | e4 = poly->c[4]; | ||
| 646 | d = gf_div(bch, poly->c[0], e4); | ||
| 647 | c = gf_div(bch, poly->c[1], e4); | ||
| 648 | b = gf_div(bch, poly->c[2], e4); | ||
| 649 | a = gf_div(bch, poly->c[3], e4); | ||
| 650 | |||
| 651 | /* use Y=1/X transformation to get an affine polynomial */ | ||
| 652 | if (a) { | ||
| 653 | /* first, eliminate cX by using z=X+e with ae^2+c=0 */ | ||
| 654 | if (c) { | ||
| 655 | /* compute e such that e^2 = c/a */ | ||
| 656 | f = gf_div(bch, c, a); | ||
| 657 | l = a_log(bch, f); | ||
| 658 | l += (l & 1) ? GF_N(bch) : 0; | ||
| 659 | e = a_pow(bch, l/2); | ||
| 660 | /* | ||
| 661 | * use transformation z=X+e: | ||
| 662 | * z^4+e^4 + a(z^3+ez^2+e^2z+e^3) + b(z^2+e^2) +cz+ce+d | ||
| 663 | * z^4 + az^3 + (ae+b)z^2 + (ae^2+c)z+e^4+be^2+ae^3+ce+d | ||
| 664 | * z^4 + az^3 + (ae+b)z^2 + e^4+be^2+d | ||
| 665 | * z^4 + az^3 + b'z^2 + d' | ||
| 666 | */ | ||
| 667 | d = a_pow(bch, 2*l)^gf_mul(bch, b, f)^d; | ||
| 668 | b = gf_mul(bch, a, e)^b; | ||
| 669 | } | ||
| 670 | /* now, use Y=1/X to get Y^4 + b/dY^2 + a/dY + 1/d */ | ||
| 671 | if (d == 0) | ||
| 672 | /* assume all roots have multiplicity 1 */ | ||
| 673 | return 0; | ||
| 674 | |||
| 675 | c2 = gf_inv(bch, d); | ||
| 676 | b2 = gf_div(bch, a, d); | ||
| 677 | a2 = gf_div(bch, b, d); | ||
| 678 | } else { | ||
| 679 | /* polynomial is already affine */ | ||
| 680 | c2 = d; | ||
| 681 | b2 = c; | ||
| 682 | a2 = b; | ||
| 683 | } | ||
| 684 | /* find the 4 roots of this affine polynomial */ | ||
| 685 | if (find_affine4_roots(bch, a2, b2, c2, roots) == 4) { | ||
| 686 | for (i = 0; i < 4; i++) { | ||
| 687 | /* post-process roots (reverse transformations) */ | ||
| 688 | f = a ? gf_inv(bch, roots[i]) : roots[i]; | ||
| 689 | roots[i] = a_ilog(bch, f^e); | ||
| 690 | } | ||
| 691 | n = 4; | ||
| 692 | } | ||
| 693 | return n; | ||
| 694 | } | ||
| 695 | |||
| 696 | /* | ||
| 697 | * build monic, log-based representation of a polynomial | ||
| 698 | */ | ||
| 699 | static void gf_poly_logrep(struct bch_control *bch, | ||
| 700 | const struct gf_poly *a, int *rep) | ||
| 701 | { | ||
| 702 | int i, d = a->deg, l = GF_N(bch)-a_log(bch, a->c[a->deg]); | ||
| 703 | |||
| 704 | /* represent 0 values with -1; warning, rep[d] is not set to 1 */ | ||
| 705 | for (i = 0; i < d; i++) | ||
| 706 | rep[i] = a->c[i] ? mod_s(bch, a_log(bch, a->c[i])+l) : -1; | ||
| 707 | } | ||
| 708 | |||
| 709 | /* | ||
| 710 | * compute polynomial Euclidean division remainder in GF(2^m)[X] | ||
| 711 | */ | ||
| 712 | static void gf_poly_mod(struct bch_control *bch, struct gf_poly *a, | ||
| 713 | const struct gf_poly *b, int *rep) | ||
| 714 | { | ||
| 715 | int la, p, m; | ||
| 716 | unsigned int i, j, *c = a->c; | ||
| 717 | const unsigned int d = b->deg; | ||
| 718 | |||
| 719 | if (a->deg < d) | ||
| 720 | return; | ||
| 721 | |||
| 722 | /* reuse or compute log representation of denominator */ | ||
| 723 | if (!rep) { | ||
| 724 | rep = bch->cache; | ||
| 725 | gf_poly_logrep(bch, b, rep); | ||
| 726 | } | ||
| 727 | |||
| 728 | for (j = a->deg; j >= d; j--) { | ||
| 729 | if (c[j]) { | ||
| 730 | la = a_log(bch, c[j]); | ||
| 731 | p = j-d; | ||
| 732 | for (i = 0; i < d; i++, p++) { | ||
| 733 | m = rep[i]; | ||
| 734 | if (m >= 0) | ||
| 735 | c[p] ^= bch->a_pow_tab[mod_s(bch, | ||
| 736 | m+la)]; | ||
| 737 | } | ||
| 738 | } | ||
| 739 | } | ||
| 740 | a->deg = d-1; | ||
| 741 | while (!c[a->deg] && a->deg) | ||
| 742 | a->deg--; | ||
| 743 | } | ||
| 744 | |||
| 745 | /* | ||
| 746 | * compute polynomial Euclidean division quotient in GF(2^m)[X] | ||
| 747 | */ | ||
| 748 | static void gf_poly_div(struct bch_control *bch, struct gf_poly *a, | ||
| 749 | const struct gf_poly *b, struct gf_poly *q) | ||
| 750 | { | ||
| 751 | if (a->deg >= b->deg) { | ||
| 752 | q->deg = a->deg-b->deg; | ||
| 753 | /* compute a mod b (modifies a) */ | ||
| 754 | gf_poly_mod(bch, a, b, NULL); | ||
| 755 | /* quotient is stored in upper part of polynomial a */ | ||
| 756 | memcpy(q->c, &a->c[b->deg], (1+q->deg)*sizeof(unsigned int)); | ||
| 757 | } else { | ||
| 758 | q->deg = 0; | ||
| 759 | q->c[0] = 0; | ||
| 760 | } | ||
| 761 | } | ||
| 762 | |||
| 763 | /* | ||
| 764 | * compute polynomial GCD (Greatest Common Divisor) in GF(2^m)[X] | ||
| 765 | */ | ||
| 766 | static struct gf_poly *gf_poly_gcd(struct bch_control *bch, struct gf_poly *a, | ||
| 767 | struct gf_poly *b) | ||
| 768 | { | ||
| 769 | struct gf_poly *tmp; | ||
| 770 | |||
| 771 | dbg("gcd(%s,%s)=", gf_poly_str(a), gf_poly_str(b)); | ||
| 772 | |||
| 773 | if (a->deg < b->deg) { | ||
| 774 | tmp = b; | ||
| 775 | b = a; | ||
| 776 | a = tmp; | ||
| 777 | } | ||
| 778 | |||
| 779 | while (b->deg > 0) { | ||
| 780 | gf_poly_mod(bch, a, b, NULL); | ||
| 781 | tmp = b; | ||
| 782 | b = a; | ||
| 783 | a = tmp; | ||
| 784 | } | ||
| 785 | |||
| 786 | dbg("%s\n", gf_poly_str(a)); | ||
| 787 | |||
| 788 | return a; | ||
| 789 | } | ||
| 790 | |||
| 791 | /* | ||
| 792 | * Given a polynomial f and an integer k, compute Tr(a^kX) mod f | ||
| 793 | * This is used in Berlekamp Trace algorithm for splitting polynomials | ||
| 794 | */ | ||
| 795 | static void compute_trace_bk_mod(struct bch_control *bch, int k, | ||
| 796 | const struct gf_poly *f, struct gf_poly *z, | ||
| 797 | struct gf_poly *out) | ||
| 798 | { | ||
| 799 | const int m = GF_M(bch); | ||
| 800 | int i, j; | ||
| 801 | |||
| 802 | /* z contains z^2j mod f */ | ||
| 803 | z->deg = 1; | ||
| 804 | z->c[0] = 0; | ||
| 805 | z->c[1] = bch->a_pow_tab[k]; | ||
| 806 | |||
| 807 | out->deg = 0; | ||
| 808 | memset(out, 0, GF_POLY_SZ(f->deg)); | ||
| 809 | |||
| 810 | /* compute f log representation only once */ | ||
| 811 | gf_poly_logrep(bch, f, bch->cache); | ||
| 812 | |||
| 813 | for (i = 0; i < m; i++) { | ||
| 814 | /* add a^(k*2^i)(z^(2^i) mod f) and compute (z^(2^i) mod f)^2 */ | ||
| 815 | for (j = z->deg; j >= 0; j--) { | ||
| 816 | out->c[j] ^= z->c[j]; | ||
| 817 | z->c[2*j] = gf_sqr(bch, z->c[j]); | ||
| 818 | z->c[2*j+1] = 0; | ||
| 819 | } | ||
| 820 | if (z->deg > out->deg) | ||
| 821 | out->deg = z->deg; | ||
| 822 | |||
| 823 | if (i < m-1) { | ||
| 824 | z->deg *= 2; | ||
| 825 | /* z^(2(i+1)) mod f = (z^(2^i) mod f)^2 mod f */ | ||
| 826 | gf_poly_mod(bch, z, f, bch->cache); | ||
| 827 | } | ||
| 828 | } | ||
| 829 | while (!out->c[out->deg] && out->deg) | ||
| 830 | out->deg--; | ||
| 831 | |||
| 832 | dbg("Tr(a^%d.X) mod f = %s\n", k, gf_poly_str(out)); | ||
| 833 | } | ||
| 834 | |||
| 835 | /* | ||
| 836 | * factor a polynomial using Berlekamp Trace algorithm (BTA) | ||
| 837 | */ | ||
| 838 | static void factor_polynomial(struct bch_control *bch, int k, struct gf_poly *f, | ||
| 839 | struct gf_poly **g, struct gf_poly **h) | ||
| 840 | { | ||
| 841 | struct gf_poly *f2 = bch->poly_2t[0]; | ||
| 842 | struct gf_poly *q = bch->poly_2t[1]; | ||
| 843 | struct gf_poly *tk = bch->poly_2t[2]; | ||
| 844 | struct gf_poly *z = bch->poly_2t[3]; | ||
| 845 | struct gf_poly *gcd; | ||
| 846 | |||
| 847 | dbg("factoring %s...\n", gf_poly_str(f)); | ||
| 848 | |||
| 849 | *g = f; | ||
| 850 | *h = NULL; | ||
| 851 | |||
| 852 | /* tk = Tr(a^k.X) mod f */ | ||
| 853 | compute_trace_bk_mod(bch, k, f, z, tk); | ||
| 854 | |||
| 855 | if (tk->deg > 0) { | ||
| 856 | /* compute g = gcd(f, tk) (destructive operation) */ | ||
| 857 | gf_poly_copy(f2, f); | ||
| 858 | gcd = gf_poly_gcd(bch, f2, tk); | ||
| 859 | if (gcd->deg < f->deg) { | ||
| 860 | /* compute h=f/gcd(f,tk); this will modify f and q */ | ||
| 861 | gf_poly_div(bch, f, gcd, q); | ||
| 862 | /* store g and h in-place (clobbering f) */ | ||
| 863 | *h = &((struct gf_poly_deg1 *)f)[gcd->deg].poly; | ||
| 864 | gf_poly_copy(*g, gcd); | ||
| 865 | gf_poly_copy(*h, q); | ||
| 866 | } | ||
| 867 | } | ||
| 868 | } | ||
| 869 | |||
| 870 | /* | ||
| 871 | * find roots of a polynomial, using BTZ algorithm; see the beginning of this | ||
| 872 | * file for details | ||
| 873 | */ | ||
| 874 | static int find_poly_roots(struct bch_control *bch, unsigned int k, | ||
| 875 | struct gf_poly *poly, unsigned int *roots) | ||
| 876 | { | ||
| 877 | int cnt; | ||
| 878 | struct gf_poly *f1, *f2; | ||
| 879 | |||
| 880 | switch (poly->deg) { | ||
| 881 | /* handle low degree polynomials with ad hoc techniques */ | ||
| 882 | case 1: | ||
| 883 | cnt = find_poly_deg1_roots(bch, poly, roots); | ||
| 884 | break; | ||
| 885 | case 2: | ||
| 886 | cnt = find_poly_deg2_roots(bch, poly, roots); | ||
| 887 | break; | ||
| 888 | case 3: | ||
| 889 | cnt = find_poly_deg3_roots(bch, poly, roots); | ||
| 890 | break; | ||
| 891 | case 4: | ||
| 892 | cnt = find_poly_deg4_roots(bch, poly, roots); | ||
| 893 | break; | ||
| 894 | default: | ||
| 895 | /* factor polynomial using Berlekamp Trace Algorithm (BTA) */ | ||
| 896 | cnt = 0; | ||
| 897 | if (poly->deg && (k <= GF_M(bch))) { | ||
| 898 | factor_polynomial(bch, k, poly, &f1, &f2); | ||
| 899 | if (f1) | ||
| 900 | cnt += find_poly_roots(bch, k+1, f1, roots); | ||
| 901 | if (f2) | ||
| 902 | cnt += find_poly_roots(bch, k+1, f2, roots+cnt); | ||
| 903 | } | ||
| 904 | break; | ||
| 905 | } | ||
| 906 | return cnt; | ||
| 907 | } | ||
| 908 | |||
| 909 | #if defined(USE_CHIEN_SEARCH) | ||
| 910 | /* | ||
| 911 | * exhaustive root search (Chien) implementation - not used, included only for | ||
| 912 | * reference/comparison tests | ||
| 913 | */ | ||
| 914 | static int chien_search(struct bch_control *bch, unsigned int len, | ||
| 915 | struct gf_poly *p, unsigned int *roots) | ||
| 916 | { | ||
| 917 | int m; | ||
| 918 | unsigned int i, j, syn, syn0, count = 0; | ||
| 919 | const unsigned int k = 8*len+bch->ecc_bits; | ||
| 920 | |||
| 921 | /* use a log-based representation of polynomial */ | ||
| 922 | gf_poly_logrep(bch, p, bch->cache); | ||
| 923 | bch->cache[p->deg] = 0; | ||
| 924 | syn0 = gf_div(bch, p->c[0], p->c[p->deg]); | ||
| 925 | |||
| 926 | for (i = GF_N(bch)-k+1; i <= GF_N(bch); i++) { | ||
| 927 | /* compute elp(a^i) */ | ||
| 928 | for (j = 1, syn = syn0; j <= p->deg; j++) { | ||
| 929 | m = bch->cache[j]; | ||
| 930 | if (m >= 0) | ||
| 931 | syn ^= a_pow(bch, m+j*i); | ||
| 932 | } | ||
| 933 | if (syn == 0) { | ||
| 934 | roots[count++] = GF_N(bch)-i; | ||
| 935 | if (count == p->deg) | ||
| 936 | break; | ||
| 937 | } | ||
| 938 | } | ||
| 939 | return (count == p->deg) ? count : 0; | ||
| 940 | } | ||
| 941 | #define find_poly_roots(_p, _k, _elp, _loc) chien_search(_p, len, _elp, _loc) | ||
| 942 | #endif /* USE_CHIEN_SEARCH */ | ||
| 943 | |||
| 944 | /** | ||
| 945 | * decode_bch - decode received codeword and find bit error locations | ||
| 946 | * @bch: BCH control structure | ||
| 947 | * @data: received data, ignored if @calc_ecc is provided | ||
| 948 | * @len: data length in bytes, must always be provided | ||
| 949 | * @recv_ecc: received ecc, if NULL then assume it was XORed in @calc_ecc | ||
| 950 | * @calc_ecc: calculated ecc, if NULL then calc_ecc is computed from @data | ||
| 951 | * @syn: hw computed syndrome data (if NULL, syndrome is calculated) | ||
| 952 | * @errloc: output array of error locations | ||
| 953 | * | ||
| 954 | * Returns: | ||
| 955 | * The number of errors found, or -EBADMSG if decoding failed, or -EINVAL if | ||
| 956 | * invalid parameters were provided | ||
| 957 | * | ||
| 958 | * Depending on the available hw BCH support and the need to compute @calc_ecc | ||
| 959 | * separately (using encode_bch()), this function should be called with one of | ||
| 960 | * the following parameter configurations - | ||
| 961 | * | ||
| 962 | * by providing @data and @recv_ecc only: | ||
| 963 | * decode_bch(@bch, @data, @len, @recv_ecc, NULL, NULL, @errloc) | ||
| 964 | * | ||
| 965 | * by providing @recv_ecc and @calc_ecc: | ||
| 966 | * decode_bch(@bch, NULL, @len, @recv_ecc, @calc_ecc, NULL, @errloc) | ||
| 967 | * | ||
| 968 | * by providing ecc = recv_ecc XOR calc_ecc: | ||
| 969 | * decode_bch(@bch, NULL, @len, NULL, ecc, NULL, @errloc) | ||
| 970 | * | ||
| 971 | * by providing syndrome results @syn: | ||
| 972 | * decode_bch(@bch, NULL, @len, NULL, NULL, @syn, @errloc) | ||
| 973 | * | ||
| 974 | * Once decode_bch() has successfully returned with a positive value, error | ||
| 975 | * locations returned in array @errloc should be interpreted as follows - | ||
| 976 | * | ||
| 977 | * if (errloc[n] >= 8*len), then n-th error is located in ecc (no need for | ||
| 978 | * data correction) | ||
| 979 | * | ||
| 980 | * if (errloc[n] < 8*len), then n-th error is located in data and can be | ||
| 981 | * corrected with statement data[errloc[n]/8] ^= 1 << (errloc[n] % 8); | ||
| 982 | * | ||
| 983 | * Note that this function does not perform any data correction by itself, it | ||
| 984 | * merely indicates error locations. | ||
| 985 | */ | ||
| 986 | int decode_bch(struct bch_control *bch, const uint8_t *data, unsigned int len, | ||
| 987 | const uint8_t *recv_ecc, const uint8_t *calc_ecc, | ||
| 988 | const unsigned int *syn, unsigned int *errloc) | ||
| 989 | { | ||
| 990 | const unsigned int ecc_words = BCH_ECC_WORDS(bch); | ||
| 991 | unsigned int nbits; | ||
| 992 | int i, err, nroots; | ||
| 993 | uint32_t sum; | ||
| 994 | |||
| 995 | /* sanity check: make sure data length can be handled */ | ||
| 996 | if (8*len > (bch->n-bch->ecc_bits)) | ||
| 997 | return -EINVAL; | ||
| 998 | |||
| 999 | /* if caller does not provide syndromes, compute them */ | ||
| 1000 | if (!syn) { | ||
| 1001 | if (!calc_ecc) { | ||
| 1002 | /* compute received data ecc into an internal buffer */ | ||
| 1003 | if (!data || !recv_ecc) | ||
| 1004 | return -EINVAL; | ||
| 1005 | encode_bch(bch, data, len, NULL); | ||
| 1006 | } else { | ||
| 1007 | /* load provided calculated ecc */ | ||
| 1008 | load_ecc8(bch, bch->ecc_buf, calc_ecc); | ||
| 1009 | } | ||
| 1010 | /* load received ecc or assume it was XORed in calc_ecc */ | ||
| 1011 | if (recv_ecc) { | ||
| 1012 | load_ecc8(bch, bch->ecc_buf2, recv_ecc); | ||
| 1013 | /* XOR received and calculated ecc */ | ||
| 1014 | for (i = 0, sum = 0; i < (int)ecc_words; i++) { | ||
| 1015 | bch->ecc_buf[i] ^= bch->ecc_buf2[i]; | ||
| 1016 | sum |= bch->ecc_buf[i]; | ||
| 1017 | } | ||
| 1018 | if (!sum) | ||
| 1019 | /* no error found */ | ||
| 1020 | return 0; | ||
| 1021 | } | ||
| 1022 | compute_syndromes(bch, bch->ecc_buf, bch->syn); | ||
| 1023 | syn = bch->syn; | ||
| 1024 | } | ||
| 1025 | |||
| 1026 | err = compute_error_locator_polynomial(bch, syn); | ||
| 1027 | if (err > 0) { | ||
| 1028 | nroots = find_poly_roots(bch, 1, bch->elp, errloc); | ||
| 1029 | if (err != nroots) | ||
| 1030 | err = -1; | ||
| 1031 | } | ||
| 1032 | if (err > 0) { | ||
| 1033 | /* post-process raw error locations for easier correction */ | ||
| 1034 | nbits = (len*8)+bch->ecc_bits; | ||
| 1035 | for (i = 0; i < err; i++) { | ||
| 1036 | if (errloc[i] >= nbits) { | ||
| 1037 | err = -1; | ||
| 1038 | break; | ||
| 1039 | } | ||
| 1040 | errloc[i] = nbits-1-errloc[i]; | ||
| 1041 | errloc[i] = (errloc[i] & ~7)|(7-(errloc[i] & 7)); | ||
| 1042 | } | ||
| 1043 | } | ||
| 1044 | return (err >= 0) ? err : -EBADMSG; | ||
| 1045 | } | ||
| 1046 | EXPORT_SYMBOL_GPL(decode_bch); | ||
| 1047 | |||
| 1048 | /* | ||
| 1049 | * generate Galois field lookup tables | ||
| 1050 | */ | ||
| 1051 | static int build_gf_tables(struct bch_control *bch, unsigned int poly) | ||
| 1052 | { | ||
| 1053 | unsigned int i, x = 1; | ||
| 1054 | const unsigned int k = 1 << deg(poly); | ||
| 1055 | |||
| 1056 | /* primitive polynomial must be of degree m */ | ||
| 1057 | if (k != (1u << GF_M(bch))) | ||
| 1058 | return -1; | ||
| 1059 | |||
| 1060 | for (i = 0; i < GF_N(bch); i++) { | ||
| 1061 | bch->a_pow_tab[i] = x; | ||
| 1062 | bch->a_log_tab[x] = i; | ||
| 1063 | if (i && (x == 1)) | ||
| 1064 | /* polynomial is not primitive (a^i=1 with 0<i<2^m-1) */ | ||
| 1065 | return -1; | ||
| 1066 | x <<= 1; | ||
| 1067 | if (x & k) | ||
| 1068 | x ^= poly; | ||
| 1069 | } | ||
| 1070 | bch->a_pow_tab[GF_N(bch)] = 1; | ||
| 1071 | bch->a_log_tab[0] = 0; | ||
| 1072 | |||
| 1073 | return 0; | ||
| 1074 | } | ||
| 1075 | |||
| 1076 | /* | ||
| 1077 | * compute generator polynomial remainder tables for fast encoding | ||
| 1078 | */ | ||
| 1079 | static void build_mod8_tables(struct bch_control *bch, const uint32_t *g) | ||
| 1080 | { | ||
| 1081 | int i, j, b, d; | ||
| 1082 | uint32_t data, hi, lo, *tab; | ||
| 1083 | const int l = BCH_ECC_WORDS(bch); | ||
| 1084 | const int plen = DIV_ROUND_UP(bch->ecc_bits+1, 32); | ||
| 1085 | const int ecclen = DIV_ROUND_UP(bch->ecc_bits, 32); | ||
| 1086 | |||
| 1087 | memset(bch->mod8_tab, 0, 4*256*l*sizeof(*bch->mod8_tab)); | ||
| 1088 | |||
| 1089 | for (i = 0; i < 256; i++) { | ||
| 1090 | /* p(X)=i is a small polynomial of weight <= 8 */ | ||
| 1091 | for (b = 0; b < 4; b++) { | ||
| 1092 | /* we want to compute (p(X).X^(8*b+deg(g))) mod g(X) */ | ||
| 1093 | tab = bch->mod8_tab + (b*256+i)*l; | ||
| 1094 | data = i << (8*b); | ||
| 1095 | while (data) { | ||
| 1096 | d = deg(data); | ||
| 1097 | /* subtract X^d.g(X) from p(X).X^(8*b+deg(g)) */ | ||
| 1098 | data ^= g[0] >> (31-d); | ||
| 1099 | for (j = 0; j < ecclen; j++) { | ||
| 1100 | hi = (d < 31) ? g[j] << (d+1) : 0; | ||
| 1101 | lo = (j+1 < plen) ? | ||
| 1102 | g[j+1] >> (31-d) : 0; | ||
| 1103 | tab[j] ^= hi|lo; | ||
| 1104 | } | ||
| 1105 | } | ||
| 1106 | } | ||
| 1107 | } | ||
| 1108 | } | ||
| 1109 | |||
| 1110 | /* | ||
| 1111 | * build a base for factoring degree 2 polynomials | ||
| 1112 | */ | ||
| 1113 | static int build_deg2_base(struct bch_control *bch) | ||
| 1114 | { | ||
| 1115 | const int m = GF_M(bch); | ||
| 1116 | int i, j, r; | ||
| 1117 | unsigned int sum, x, y, remaining, ak = 0, xi[m]; | ||
| 1118 | |||
| 1119 | /* find k s.t. Tr(a^k) = 1 and 0 <= k < m */ | ||
| 1120 | for (i = 0; i < m; i++) { | ||
| 1121 | for (j = 0, sum = 0; j < m; j++) | ||
| 1122 | sum ^= a_pow(bch, i*(1 << j)); | ||
| 1123 | |||
| 1124 | if (sum) { | ||
| 1125 | ak = bch->a_pow_tab[i]; | ||
| 1126 | break; | ||
| 1127 | } | ||
| 1128 | } | ||
| 1129 | /* find xi, i=0..m-1 such that xi^2+xi = a^i+Tr(a^i).a^k */ | ||
| 1130 | remaining = m; | ||
| 1131 | memset(xi, 0, sizeof(xi)); | ||
| 1132 | |||
| 1133 | for (x = 0; (x <= GF_N(bch)) && remaining; x++) { | ||
| 1134 | y = gf_sqr(bch, x)^x; | ||
| 1135 | for (i = 0; i < 2; i++) { | ||
| 1136 | r = a_log(bch, y); | ||
| 1137 | if (y && (r < m) && !xi[r]) { | ||
| 1138 | bch->xi_tab[r] = x; | ||
| 1139 | xi[r] = 1; | ||
| 1140 | remaining--; | ||
| 1141 | dbg("x%d = %x\n", r, x); | ||
| 1142 | break; | ||
| 1143 | } | ||
| 1144 | y ^= ak; | ||
| 1145 | } | ||
| 1146 | } | ||
| 1147 | /* should not happen but check anyway */ | ||
| 1148 | return remaining ? -1 : 0; | ||
| 1149 | } | ||
| 1150 | |||
| 1151 | static void *bch_alloc(size_t size, int *err) | ||
| 1152 | { | ||
| 1153 | void *ptr; | ||
| 1154 | |||
| 1155 | ptr = kmalloc(size, GFP_KERNEL); | ||
| 1156 | if (ptr == NULL) | ||
| 1157 | *err = 1; | ||
| 1158 | return ptr; | ||
| 1159 | } | ||
| 1160 | |||
| 1161 | /* | ||
| 1162 | * compute generator polynomial for given (m,t) parameters. | ||
| 1163 | */ | ||
| 1164 | static uint32_t *compute_generator_polynomial(struct bch_control *bch) | ||
| 1165 | { | ||
| 1166 | const unsigned int m = GF_M(bch); | ||
| 1167 | const unsigned int t = GF_T(bch); | ||
| 1168 | int n, err = 0; | ||
| 1169 | unsigned int i, j, nbits, r, word, *roots; | ||
| 1170 | struct gf_poly *g; | ||
| 1171 | uint32_t *genpoly; | ||
| 1172 | |||
| 1173 | g = bch_alloc(GF_POLY_SZ(m*t), &err); | ||
| 1174 | roots = bch_alloc((bch->n+1)*sizeof(*roots), &err); | ||
| 1175 | genpoly = bch_alloc(DIV_ROUND_UP(m*t+1, 32)*sizeof(*genpoly), &err); | ||
| 1176 | |||
| 1177 | if (err) { | ||
| 1178 | kfree(genpoly); | ||
| 1179 | genpoly = NULL; | ||
| 1180 | goto finish; | ||
| 1181 | } | ||
| 1182 | |||
| 1183 | /* enumerate all roots of g(X) */ | ||
| 1184 | memset(roots , 0, (bch->n+1)*sizeof(*roots)); | ||
| 1185 | for (i = 0; i < t; i++) { | ||
| 1186 | for (j = 0, r = 2*i+1; j < m; j++) { | ||
| 1187 | roots[r] = 1; | ||
| 1188 | r = mod_s(bch, 2*r); | ||
| 1189 | } | ||
| 1190 | } | ||
| 1191 | /* build generator polynomial g(X) */ | ||
| 1192 | g->deg = 0; | ||
| 1193 | g->c[0] = 1; | ||
| 1194 | for (i = 0; i < GF_N(bch); i++) { | ||
| 1195 | if (roots[i]) { | ||
| 1196 | /* multiply g(X) by (X+root) */ | ||
| 1197 | r = bch->a_pow_tab[i]; | ||
| 1198 | g->c[g->deg+1] = 1; | ||
| 1199 | for (j = g->deg; j > 0; j--) | ||
| 1200 | g->c[j] = gf_mul(bch, g->c[j], r)^g->c[j-1]; | ||
| 1201 | |||
| 1202 | g->c[0] = gf_mul(bch, g->c[0], r); | ||
| 1203 | g->deg++; | ||
| 1204 | } | ||
| 1205 | } | ||
| 1206 | /* store left-justified binary representation of g(X) */ | ||
| 1207 | n = g->deg+1; | ||
| 1208 | i = 0; | ||
| 1209 | |||
| 1210 | while (n > 0) { | ||
| 1211 | nbits = (n > 32) ? 32 : n; | ||
| 1212 | for (j = 0, word = 0; j < nbits; j++) { | ||
| 1213 | if (g->c[n-1-j]) | ||
| 1214 | word |= 1u << (31-j); | ||
| 1215 | } | ||
| 1216 | genpoly[i++] = word; | ||
| 1217 | n -= nbits; | ||
| 1218 | } | ||
| 1219 | bch->ecc_bits = g->deg; | ||
| 1220 | |||
| 1221 | finish: | ||
| 1222 | kfree(g); | ||
| 1223 | kfree(roots); | ||
| 1224 | |||
| 1225 | return genpoly; | ||
| 1226 | } | ||
| 1227 | |||
| 1228 | /** | ||
| 1229 | * init_bch - initialize a BCH encoder/decoder | ||
| 1230 | * @m: Galois field order, should be in the range 5-15 | ||
| 1231 | * @t: maximum error correction capability, in bits | ||
| 1232 | * @prim_poly: user-provided primitive polynomial (or 0 to use default) | ||
| 1233 | * | ||
| 1234 | * Returns: | ||
| 1235 | * a newly allocated BCH control structure if successful, NULL otherwise | ||
| 1236 | * | ||
| 1237 | * This initialization can take some time, as lookup tables are built for fast | ||
| 1238 | * encoding/decoding; make sure not to call this function from a time critical | ||
| 1239 | * path. Usually, init_bch() should be called on module/driver init and | ||
| 1240 | * free_bch() should be called to release memory on exit. | ||
| 1241 | * | ||
| 1242 | * You may provide your own primitive polynomial of degree @m in argument | ||
| 1243 | * @prim_poly, or let init_bch() use its default polynomial. | ||
| 1244 | * | ||
| 1245 | * Once init_bch() has successfully returned a pointer to a newly allocated | ||
| 1246 | * BCH control structure, ecc length in bytes is given by member @ecc_bytes of | ||
| 1247 | * the structure. | ||
| 1248 | */ | ||
| 1249 | struct bch_control *init_bch(int m, int t, unsigned int prim_poly) | ||
| 1250 | { | ||
| 1251 | int err = 0; | ||
| 1252 | unsigned int i, words; | ||
| 1253 | uint32_t *genpoly; | ||
| 1254 | struct bch_control *bch = NULL; | ||
| 1255 | |||
| 1256 | const int min_m = 5; | ||
| 1257 | const int max_m = 15; | ||
| 1258 | |||
| 1259 | /* default primitive polynomials */ | ||
| 1260 | static const unsigned int prim_poly_tab[] = { | ||
| 1261 | 0x25, 0x43, 0x83, 0x11d, 0x211, 0x409, 0x805, 0x1053, 0x201b, | ||
| 1262 | 0x402b, 0x8003, | ||
| 1263 | }; | ||
| 1264 | |||
| 1265 | #if defined(CONFIG_BCH_CONST_PARAMS) | ||
| 1266 | if ((m != (CONFIG_BCH_CONST_M)) || (t != (CONFIG_BCH_CONST_T))) { | ||
| 1267 | printk(KERN_ERR "bch encoder/decoder was configured to support " | ||
| 1268 | "parameters m=%d, t=%d only!\n", | ||
| 1269 | CONFIG_BCH_CONST_M, CONFIG_BCH_CONST_T); | ||
| 1270 | goto fail; | ||
| 1271 | } | ||
| 1272 | #endif | ||
| 1273 | if ((m < min_m) || (m > max_m)) | ||
| 1274 | /* | ||
| 1275 | * values of m greater than 15 are not currently supported; | ||
| 1276 | * supporting m > 15 would require changing table base type | ||
| 1277 | * (uint16_t) and a small patch in matrix transposition | ||
| 1278 | */ | ||
| 1279 | goto fail; | ||
| 1280 | |||
| 1281 | /* sanity checks */ | ||
| 1282 | if ((t < 1) || (m*t >= ((1 << m)-1))) | ||
| 1283 | /* invalid t value */ | ||
| 1284 | goto fail; | ||
| 1285 | |||
| 1286 | /* select a primitive polynomial for generating GF(2^m) */ | ||
| 1287 | if (prim_poly == 0) | ||
| 1288 | prim_poly = prim_poly_tab[m-min_m]; | ||
| 1289 | |||
| 1290 | bch = kzalloc(sizeof(*bch), GFP_KERNEL); | ||
| 1291 | if (bch == NULL) | ||
| 1292 | goto fail; | ||
| 1293 | |||
| 1294 | bch->m = m; | ||
| 1295 | bch->t = t; | ||
| 1296 | bch->n = (1 << m)-1; | ||
| 1297 | words = DIV_ROUND_UP(m*t, 32); | ||
| 1298 | bch->ecc_bytes = DIV_ROUND_UP(m*t, 8); | ||
| 1299 | bch->a_pow_tab = bch_alloc((1+bch->n)*sizeof(*bch->a_pow_tab), &err); | ||
| 1300 | bch->a_log_tab = bch_alloc((1+bch->n)*sizeof(*bch->a_log_tab), &err); | ||
| 1301 | bch->mod8_tab = bch_alloc(words*1024*sizeof(*bch->mod8_tab), &err); | ||
| 1302 | bch->ecc_buf = bch_alloc(words*sizeof(*bch->ecc_buf), &err); | ||
| 1303 | bch->ecc_buf2 = bch_alloc(words*sizeof(*bch->ecc_buf2), &err); | ||
| 1304 | bch->xi_tab = bch_alloc(m*sizeof(*bch->xi_tab), &err); | ||
| 1305 | bch->syn = bch_alloc(2*t*sizeof(*bch->syn), &err); | ||
| 1306 | bch->cache = bch_alloc(2*t*sizeof(*bch->cache), &err); | ||
| 1307 | bch->elp = bch_alloc((t+1)*sizeof(struct gf_poly_deg1), &err); | ||
| 1308 | |||
| 1309 | for (i = 0; i < ARRAY_SIZE(bch->poly_2t); i++) | ||
| 1310 | bch->poly_2t[i] = bch_alloc(GF_POLY_SZ(2*t), &err); | ||
| 1311 | |||
| 1312 | if (err) | ||
| 1313 | goto fail; | ||
| 1314 | |||
| 1315 | err = build_gf_tables(bch, prim_poly); | ||
| 1316 | if (err) | ||
| 1317 | goto fail; | ||
| 1318 | |||
| 1319 | /* use generator polynomial for computing encoding tables */ | ||
| 1320 | genpoly = compute_generator_polynomial(bch); | ||
| 1321 | if (genpoly == NULL) | ||
| 1322 | goto fail; | ||
| 1323 | |||
| 1324 | build_mod8_tables(bch, genpoly); | ||
| 1325 | kfree(genpoly); | ||
| 1326 | |||
| 1327 | err = build_deg2_base(bch); | ||
| 1328 | if (err) | ||
| 1329 | goto fail; | ||
| 1330 | |||
| 1331 | return bch; | ||
| 1332 | |||
| 1333 | fail: | ||
| 1334 | free_bch(bch); | ||
| 1335 | return NULL; | ||
| 1336 | } | ||
| 1337 | EXPORT_SYMBOL_GPL(init_bch); | ||
| 1338 | |||
| 1339 | /** | ||
| 1340 | * free_bch - free the BCH control structure | ||
| 1341 | * @bch: BCH control structure to release | ||
| 1342 | */ | ||
| 1343 | void free_bch(struct bch_control *bch) | ||
| 1344 | { | ||
| 1345 | unsigned int i; | ||
| 1346 | |||
| 1347 | if (bch) { | ||
| 1348 | kfree(bch->a_pow_tab); | ||
| 1349 | kfree(bch->a_log_tab); | ||
| 1350 | kfree(bch->mod8_tab); | ||
| 1351 | kfree(bch->ecc_buf); | ||
| 1352 | kfree(bch->ecc_buf2); | ||
| 1353 | kfree(bch->xi_tab); | ||
| 1354 | kfree(bch->syn); | ||
| 1355 | kfree(bch->cache); | ||
| 1356 | kfree(bch->elp); | ||
| 1357 | |||
| 1358 | for (i = 0; i < ARRAY_SIZE(bch->poly_2t); i++) | ||
| 1359 | kfree(bch->poly_2t[i]); | ||
| 1360 | |||
| 1361 | kfree(bch); | ||
| 1362 | } | ||
| 1363 | } | ||
| 1364 | EXPORT_SYMBOL_GPL(free_bch); | ||
| 1365 | |||
| 1366 | MODULE_LICENSE("GPL"); | ||
| 1367 | MODULE_AUTHOR("Ivan Djelic <ivan.djelic@parrot.com>"); | ||
| 1368 | MODULE_DESCRIPTION("Binary BCH encoder/decoder"); | ||
diff --git a/mm/memory.c b/mm/memory.c index 51a5c23704a..9da8cab1b1b 100644 --- a/mm/memory.c +++ b/mm/memory.c | |||
| @@ -3715,7 +3715,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm, | |||
| 3715 | } | 3715 | } |
| 3716 | 3716 | ||
| 3717 | /** | 3717 | /** |
| 3718 | * @access_remote_vm - access another process' address space | 3718 | * access_remote_vm - access another process' address space |
| 3719 | * @mm: the mm_struct of the target address space | 3719 | * @mm: the mm_struct of the target address space |
| 3720 | * @addr: start address to access | 3720 | * @addr: start address to access |
| 3721 | * @buf: source or destination buffer | 3721 | * @buf: source or destination buffer |
diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c index ffb687671da..6b43ee7221d 100644 --- a/net/sunrpc/sched.c +++ b/net/sunrpc/sched.c | |||
| @@ -860,8 +860,10 @@ static void rpc_release_resources_task(struct rpc_task *task) | |||
| 860 | { | 860 | { |
| 861 | if (task->tk_rqstp) | 861 | if (task->tk_rqstp) |
| 862 | xprt_release(task); | 862 | xprt_release(task); |
| 863 | if (task->tk_msg.rpc_cred) | 863 | if (task->tk_msg.rpc_cred) { |
| 864 | put_rpccred(task->tk_msg.rpc_cred); | 864 | put_rpccred(task->tk_msg.rpc_cred); |
| 865 | task->tk_msg.rpc_cred = NULL; | ||
| 866 | } | ||
| 865 | rpc_task_release_client(task); | 867 | rpc_task_release_client(task); |
| 866 | } | 868 | } |
| 867 | 869 | ||
diff --git a/sound/core/init.c b/sound/core/init.c index 3e65da21a08..a0080aa45ae 100644 --- a/sound/core/init.c +++ b/sound/core/init.c | |||
| @@ -848,6 +848,7 @@ int snd_card_file_add(struct snd_card *card, struct file *file) | |||
| 848 | return -ENOMEM; | 848 | return -ENOMEM; |
| 849 | mfile->file = file; | 849 | mfile->file = file; |
| 850 | mfile->disconnected_f_op = NULL; | 850 | mfile->disconnected_f_op = NULL; |
| 851 | INIT_LIST_HEAD(&mfile->shutdown_list); | ||
| 851 | spin_lock(&card->files_lock); | 852 | spin_lock(&card->files_lock); |
| 852 | if (card->shutdown) { | 853 | if (card->shutdown) { |
| 853 | spin_unlock(&card->files_lock); | 854 | spin_unlock(&card->files_lock); |
| @@ -883,6 +884,9 @@ int snd_card_file_remove(struct snd_card *card, struct file *file) | |||
| 883 | list_for_each_entry(mfile, &card->files_list, list) { | 884 | list_for_each_entry(mfile, &card->files_list, list) { |
| 884 | if (mfile->file == file) { | 885 | if (mfile->file == file) { |
| 885 | list_del(&mfile->list); | 886 | list_del(&mfile->list); |
| 887 | spin_lock(&shutdown_lock); | ||
| 888 | list_del(&mfile->shutdown_list); | ||
| 889 | spin_unlock(&shutdown_lock); | ||
| 886 | if (mfile->disconnected_f_op) | 890 | if (mfile->disconnected_f_op) |
| 887 | fops_put(mfile->disconnected_f_op); | 891 | fops_put(mfile->disconnected_f_op); |
| 888 | found = mfile; | 892 | found = mfile; |
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index ae42b6509ce..fe5c8036beb 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c | |||
| @@ -3201,15 +3201,6 @@ int snd_pcm_lib_mmap_iomem(struct snd_pcm_substream *substream, | |||
| 3201 | EXPORT_SYMBOL(snd_pcm_lib_mmap_iomem); | 3201 | EXPORT_SYMBOL(snd_pcm_lib_mmap_iomem); |
| 3202 | #endif /* SNDRV_PCM_INFO_MMAP */ | 3202 | #endif /* SNDRV_PCM_INFO_MMAP */ |
| 3203 | 3203 | ||
| 3204 | /* mmap callback with pgprot_noncached */ | ||
| 3205 | int snd_pcm_lib_mmap_noncached(struct snd_pcm_substream *substream, | ||
| 3206 | struct vm_area_struct *area) | ||
| 3207 | { | ||
| 3208 | area->vm_page_prot = pgprot_noncached(area->vm_page_prot); | ||
| 3209 | return snd_pcm_default_mmap(substream, area); | ||
| 3210 | } | ||
| 3211 | EXPORT_SYMBOL(snd_pcm_lib_mmap_noncached); | ||
| 3212 | |||
| 3213 | /* | 3204 | /* |
| 3214 | * mmap DMA buffer | 3205 | * mmap DMA buffer |
| 3215 | */ | 3206 | */ |
diff --git a/sound/oss/dev_table.h b/sound/oss/dev_table.h index b7617bee638..0199a317c5a 100644 --- a/sound/oss/dev_table.h +++ b/sound/oss/dev_table.h | |||
| @@ -271,7 +271,7 @@ struct synth_operations | |||
| 271 | void (*reset) (int dev); | 271 | void (*reset) (int dev); |
| 272 | void (*hw_control) (int dev, unsigned char *event); | 272 | void (*hw_control) (int dev, unsigned char *event); |
| 273 | int (*load_patch) (int dev, int format, const char __user *addr, | 273 | int (*load_patch) (int dev, int format, const char __user *addr, |
| 274 | int offs, int count, int pmgr_flag); | 274 | int count, int pmgr_flag); |
| 275 | void (*aftertouch) (int dev, int voice, int pressure); | 275 | void (*aftertouch) (int dev, int voice, int pressure); |
| 276 | void (*controller) (int dev, int voice, int ctrl_num, int value); | 276 | void (*controller) (int dev, int voice, int ctrl_num, int value); |
| 277 | void (*panning) (int dev, int voice, int value); | 277 | void (*panning) (int dev, int voice, int value); |
diff --git a/sound/oss/midi_synth.c b/sound/oss/midi_synth.c index 3c09374ea5b..2292c230d7e 100644 --- a/sound/oss/midi_synth.c +++ b/sound/oss/midi_synth.c | |||
| @@ -476,7 +476,7 @@ EXPORT_SYMBOL(midi_synth_hw_control); | |||
| 476 | 476 | ||
| 477 | int | 477 | int |
| 478 | midi_synth_load_patch(int dev, int format, const char __user *addr, | 478 | midi_synth_load_patch(int dev, int format, const char __user *addr, |
| 479 | int offs, int count, int pmgr_flag) | 479 | int count, int pmgr_flag) |
| 480 | { | 480 | { |
| 481 | int orig_dev = synth_devs[dev]->midi_dev; | 481 | int orig_dev = synth_devs[dev]->midi_dev; |
| 482 | 482 | ||
| @@ -491,33 +491,29 @@ midi_synth_load_patch(int dev, int format, const char __user *addr, | |||
| 491 | if (!prefix_cmd(orig_dev, 0xf0)) | 491 | if (!prefix_cmd(orig_dev, 0xf0)) |
| 492 | return 0; | 492 | return 0; |
| 493 | 493 | ||
| 494 | /* Invalid patch format */ | ||
| 494 | if (format != SYSEX_PATCH) | 495 | if (format != SYSEX_PATCH) |
| 495 | { | ||
| 496 | /* printk("MIDI Error: Invalid patch format (key) 0x%x\n", format);*/ | ||
| 497 | return -EINVAL; | 496 | return -EINVAL; |
| 498 | } | 497 | |
| 498 | /* Patch header too short */ | ||
| 499 | if (count < hdr_size) | 499 | if (count < hdr_size) |
| 500 | { | ||
| 501 | /* printk("MIDI Error: Patch header too short\n");*/ | ||
| 502 | return -EINVAL; | 500 | return -EINVAL; |
| 503 | } | 501 | |
| 504 | count -= hdr_size; | 502 | count -= hdr_size; |
| 505 | 503 | ||
| 506 | /* | 504 | /* |
| 507 | * Copy the header from user space but ignore the first bytes which have | 505 | * Copy the header from user space |
| 508 | * been transferred already. | ||
| 509 | */ | 506 | */ |
| 510 | 507 | ||
| 511 | if(copy_from_user(&((char *) &sysex)[offs], &(addr)[offs], hdr_size - offs)) | 508 | if (copy_from_user(&sysex, addr, hdr_size)) |
| 512 | return -EFAULT; | 509 | return -EFAULT; |
| 513 | 510 | ||
| 514 | if (count < sysex.len) | 511 | /* Sysex record too short */ |
| 515 | { | 512 | if ((unsigned)count < (unsigned)sysex.len) |
| 516 | /* printk(KERN_WARNING "MIDI Warning: Sysex record too short (%d<%d)\n", count, (int) sysex.len);*/ | ||
| 517 | sysex.len = count; | 513 | sysex.len = count; |
| 518 | } | 514 | |
| 519 | left = sysex.len; | 515 | left = sysex.len; |
| 520 | src_offs = 0; | 516 | src_offs = 0; |
| 521 | 517 | ||
| 522 | for (i = 0; i < left && !signal_pending(current); i++) | 518 | for (i = 0; i < left && !signal_pending(current); i++) |
| 523 | { | 519 | { |
diff --git a/sound/oss/midi_synth.h b/sound/oss/midi_synth.h index 6bc9d00bc77..b64ddd6c4ab 100644 --- a/sound/oss/midi_synth.h +++ b/sound/oss/midi_synth.h | |||
| @@ -8,7 +8,7 @@ int midi_synth_open (int dev, int mode); | |||
| 8 | void midi_synth_close (int dev); | 8 | void midi_synth_close (int dev); |
| 9 | void midi_synth_hw_control (int dev, unsigned char *event); | 9 | void midi_synth_hw_control (int dev, unsigned char *event); |
| 10 | int midi_synth_load_patch (int dev, int format, const char __user * addr, | 10 | int midi_synth_load_patch (int dev, int format, const char __user * addr, |
| 11 | int offs, int count, int pmgr_flag); | 11 | int count, int pmgr_flag); |
| 12 | void midi_synth_panning (int dev, int channel, int pressure); | 12 | void midi_synth_panning (int dev, int channel, int pressure); |
| 13 | void midi_synth_aftertouch (int dev, int channel, int pressure); | 13 | void midi_synth_aftertouch (int dev, int channel, int pressure); |
| 14 | void midi_synth_controller (int dev, int channel, int ctrl_num, int value); | 14 | void midi_synth_controller (int dev, int channel, int ctrl_num, int value); |
diff --git a/sound/oss/opl3.c b/sound/oss/opl3.c index 938c48c4358..407cd677950 100644 --- a/sound/oss/opl3.c +++ b/sound/oss/opl3.c | |||
| @@ -820,7 +820,7 @@ static void opl3_hw_control(int dev, unsigned char *event) | |||
| 820 | } | 820 | } |
| 821 | 821 | ||
| 822 | static int opl3_load_patch(int dev, int format, const char __user *addr, | 822 | static int opl3_load_patch(int dev, int format, const char __user *addr, |
| 823 | int offs, int count, int pmgr_flag) | 823 | int count, int pmgr_flag) |
| 824 | { | 824 | { |
| 825 | struct sbi_instrument ins; | 825 | struct sbi_instrument ins; |
| 826 | 826 | ||
| @@ -830,11 +830,7 @@ static int opl3_load_patch(int dev, int format, const char __user *addr, | |||
| 830 | return -EINVAL; | 830 | return -EINVAL; |
| 831 | } | 831 | } |
| 832 | 832 | ||
| 833 | /* | 833 | if (copy_from_user(&ins, addr, sizeof(ins))) |
| 834 | * What the fuck is going on here? We leave junk in the beginning | ||
| 835 | * of ins and then check the field pretty close to that beginning? | ||
| 836 | */ | ||
| 837 | if(copy_from_user(&((char *) &ins)[offs], addr + offs, sizeof(ins) - offs)) | ||
| 838 | return -EFAULT; | 834 | return -EFAULT; |
| 839 | 835 | ||
| 840 | if (ins.channel < 0 || ins.channel >= SBFM_MAXINSTR) | 836 | if (ins.channel < 0 || ins.channel >= SBFM_MAXINSTR) |
| @@ -849,6 +845,10 @@ static int opl3_load_patch(int dev, int format, const char __user *addr, | |||
| 849 | 845 | ||
| 850 | static void opl3_panning(int dev, int voice, int value) | 846 | static void opl3_panning(int dev, int voice, int value) |
| 851 | { | 847 | { |
| 848 | |||
| 849 | if (voice < 0 || voice >= devc->nr_voice) | ||
| 850 | return; | ||
| 851 | |||
| 852 | devc->voc[voice].panning = value; | 852 | devc->voc[voice].panning = value; |
| 853 | } | 853 | } |
| 854 | 854 | ||
| @@ -1066,8 +1066,15 @@ static int opl3_alloc_voice(int dev, int chn, int note, struct voice_alloc_info | |||
| 1066 | 1066 | ||
| 1067 | static void opl3_setup_voice(int dev, int voice, int chn) | 1067 | static void opl3_setup_voice(int dev, int voice, int chn) |
| 1068 | { | 1068 | { |
| 1069 | struct channel_info *info = | 1069 | struct channel_info *info; |
| 1070 | &synth_devs[dev]->chn_info[chn]; | 1070 | |
| 1071 | if (voice < 0 || voice >= devc->nr_voice) | ||
| 1072 | return; | ||
| 1073 | |||
| 1074 | if (chn < 0 || chn > 15) | ||
| 1075 | return; | ||
| 1076 | |||
| 1077 | info = &synth_devs[dev]->chn_info[chn]; | ||
| 1071 | 1078 | ||
| 1072 | opl3_set_instr(dev, voice, info->pgm_num); | 1079 | opl3_set_instr(dev, voice, info->pgm_num); |
| 1073 | 1080 | ||
diff --git a/sound/oss/sequencer.c b/sound/oss/sequencer.c index 5ea1098ac42..30bcfe470f8 100644 --- a/sound/oss/sequencer.c +++ b/sound/oss/sequencer.c | |||
| @@ -241,7 +241,7 @@ int sequencer_write(int dev, struct file *file, const char __user *buf, int coun | |||
| 241 | return -ENXIO; | 241 | return -ENXIO; |
| 242 | 242 | ||
| 243 | fmt = (*(short *) &event_rec[0]) & 0xffff; | 243 | fmt = (*(short *) &event_rec[0]) & 0xffff; |
| 244 | err = synth_devs[dev]->load_patch(dev, fmt, buf, p + 4, c, 0); | 244 | err = synth_devs[dev]->load_patch(dev, fmt, buf + p, c, 0); |
| 245 | if (err < 0) | 245 | if (err < 0) |
| 246 | return err; | 246 | return err; |
| 247 | 247 | ||
diff --git a/sound/pci/asihpi/asihpi.c b/sound/pci/asihpi/asihpi.c index 0ac1f98d91a..f53a31e939c 100644 --- a/sound/pci/asihpi/asihpi.c +++ b/sound/pci/asihpi/asihpi.c | |||
| @@ -22,21 +22,6 @@ | |||
| 22 | * for any purpose including commercial applications. | 22 | * for any purpose including commercial applications. |
| 23 | */ | 23 | */ |
| 24 | 24 | ||
| 25 | /* >0: print Hw params, timer vars. >1: print stream write/copy sizes */ | ||
| 26 | #define REALLY_VERBOSE_LOGGING 0 | ||
| 27 | |||
| 28 | #if REALLY_VERBOSE_LOGGING | ||
| 29 | #define VPRINTK1 snd_printd | ||
| 30 | #else | ||
| 31 | #define VPRINTK1(...) | ||
| 32 | #endif | ||
| 33 | |||
| 34 | #if REALLY_VERBOSE_LOGGING > 1 | ||
| 35 | #define VPRINTK2 snd_printd | ||
| 36 | #else | ||
| 37 | #define VPRINTK2(...) | ||
| 38 | #endif | ||
| 39 | |||
| 40 | #include "hpi_internal.h" | 25 | #include "hpi_internal.h" |
| 41 | #include "hpimsginit.h" | 26 | #include "hpimsginit.h" |
| 42 | #include "hpioctl.h" | 27 | #include "hpioctl.h" |
| @@ -57,11 +42,25 @@ | |||
| 57 | #include <sound/tlv.h> | 42 | #include <sound/tlv.h> |
| 58 | #include <sound/hwdep.h> | 43 | #include <sound/hwdep.h> |
| 59 | 44 | ||
| 60 | |||
| 61 | MODULE_LICENSE("GPL"); | 45 | MODULE_LICENSE("GPL"); |
| 62 | MODULE_AUTHOR("AudioScience inc. <support@audioscience.com>"); | 46 | MODULE_AUTHOR("AudioScience inc. <support@audioscience.com>"); |
| 63 | MODULE_DESCRIPTION("AudioScience ALSA ASI5000 ASI6000 ASI87xx ASI89xx"); | 47 | MODULE_DESCRIPTION("AudioScience ALSA ASI5000 ASI6000 ASI87xx ASI89xx"); |
| 64 | 48 | ||
| 49 | #if defined CONFIG_SND_DEBUG_VERBOSE | ||
| 50 | /** | ||
| 51 | * snd_printddd - very verbose debug printk | ||
| 52 | * @format: format string | ||
| 53 | * | ||
| 54 | * Works like snd_printk() for debugging purposes. | ||
| 55 | * Ignored when CONFIG_SND_DEBUG_VERBOSE is not set. | ||
| 56 | * Must set snd module debug parameter to 3 to enable at runtime. | ||
| 57 | */ | ||
| 58 | #define snd_printddd(format, args...) \ | ||
| 59 | __snd_printk(3, __FILE__, __LINE__, format, ##args) | ||
| 60 | #else | ||
| 61 | #define snd_printddd(format, args...) do { } while (0) | ||
| 62 | #endif | ||
| 63 | |||
| 65 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* index 0-MAX */ | 64 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* index 0-MAX */ |
| 66 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ | 65 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ |
| 67 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; | 66 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; |
| @@ -289,7 +288,6 @@ static u16 handle_error(u16 err, int line, char *filename) | |||
| 289 | #define hpi_handle_error(x) handle_error(x, __LINE__, __FILE__) | 288 | #define hpi_handle_error(x) handle_error(x, __LINE__, __FILE__) |
| 290 | 289 | ||
| 291 | /***************************** GENERAL PCM ****************/ | 290 | /***************************** GENERAL PCM ****************/ |
| 292 | #if REALLY_VERBOSE_LOGGING | ||
| 293 | static void print_hwparams(struct snd_pcm_hw_params *p) | 291 | static void print_hwparams(struct snd_pcm_hw_params *p) |
| 294 | { | 292 | { |
| 295 | snd_printd("HWPARAMS \n"); | 293 | snd_printd("HWPARAMS \n"); |
| @@ -304,9 +302,6 @@ static void print_hwparams(struct snd_pcm_hw_params *p) | |||
| 304 | snd_printd("periods %d \n", params_periods(p)); | 302 | snd_printd("periods %d \n", params_periods(p)); |
| 305 | snd_printd("buffer_size %d \n", params_buffer_size(p)); | 303 | snd_printd("buffer_size %d \n", params_buffer_size(p)); |
| 306 | } | 304 | } |
| 307 | #else | ||
| 308 | #define print_hwparams(x) | ||
| 309 | #endif | ||
| 310 | 305 | ||
| 311 | static snd_pcm_format_t hpi_to_alsa_formats[] = { | 306 | static snd_pcm_format_t hpi_to_alsa_formats[] = { |
| 312 | -1, /* INVALID */ | 307 | -1, /* INVALID */ |
| @@ -381,13 +376,13 @@ static void snd_card_asihpi_pcm_samplerates(struct snd_card_asihpi *asihpi, | |||
| 381 | "No local sampleclock, err %d\n", err); | 376 | "No local sampleclock, err %d\n", err); |
| 382 | } | 377 | } |
| 383 | 378 | ||
| 384 | for (idx = 0; idx < 100; idx++) { | 379 | for (idx = -1; idx < 100; idx++) { |
| 385 | if (hpi_sample_clock_query_local_rate( | 380 | if (idx == -1) { |
| 386 | h_control, idx, &sample_rate)) { | 381 | if (hpi_sample_clock_get_sample_rate(h_control, |
| 387 | if (!idx) | 382 | &sample_rate)) |
| 388 | snd_printk(KERN_ERR | 383 | continue; |
| 389 | "Local rate query failed\n"); | 384 | } else if (hpi_sample_clock_query_local_rate(h_control, |
| 390 | 385 | idx, &sample_rate)) { | |
| 391 | break; | 386 | break; |
| 392 | } | 387 | } |
| 393 | 388 | ||
| @@ -440,8 +435,6 @@ static void snd_card_asihpi_pcm_samplerates(struct snd_card_asihpi *asihpi, | |||
| 440 | } | 435 | } |
| 441 | } | 436 | } |
| 442 | 437 | ||
| 443 | /* printk(KERN_INFO "Supported rates %X %d %d\n", | ||
| 444 | rates, rate_min, rate_max); */ | ||
| 445 | pcmhw->rates = rates; | 438 | pcmhw->rates = rates; |
| 446 | pcmhw->rate_min = rate_min; | 439 | pcmhw->rate_min = rate_min; |
| 447 | pcmhw->rate_max = rate_max; | 440 | pcmhw->rate_max = rate_max; |
| @@ -466,7 +459,7 @@ static int snd_card_asihpi_pcm_hw_params(struct snd_pcm_substream *substream, | |||
| 466 | if (err) | 459 | if (err) |
| 467 | return err; | 460 | return err; |
| 468 | 461 | ||
| 469 | VPRINTK1(KERN_INFO "format %d, %d chans, %d_hz\n", | 462 | snd_printdd("format %d, %d chans, %d_hz\n", |
| 470 | format, params_channels(params), | 463 | format, params_channels(params), |
| 471 | params_rate(params)); | 464 | params_rate(params)); |
| 472 | 465 | ||
| @@ -489,13 +482,12 @@ static int snd_card_asihpi_pcm_hw_params(struct snd_pcm_substream *substream, | |||
| 489 | err = hpi_stream_host_buffer_attach(dpcm->h_stream, | 482 | err = hpi_stream_host_buffer_attach(dpcm->h_stream, |
| 490 | params_buffer_bytes(params), runtime->dma_addr); | 483 | params_buffer_bytes(params), runtime->dma_addr); |
| 491 | if (err == 0) { | 484 | if (err == 0) { |
| 492 | VPRINTK1(KERN_INFO | 485 | snd_printdd( |
| 493 | "stream_host_buffer_attach succeeded %u %lu\n", | 486 | "stream_host_buffer_attach succeeded %u %lu\n", |
| 494 | params_buffer_bytes(params), | 487 | params_buffer_bytes(params), |
| 495 | (unsigned long)runtime->dma_addr); | 488 | (unsigned long)runtime->dma_addr); |
| 496 | } else { | 489 | } else { |
| 497 | snd_printd(KERN_INFO | 490 | snd_printd("stream_host_buffer_attach error %d\n", |
| 498 | "stream_host_buffer_attach error %d\n", | ||
| 499 | err); | 491 | err); |
| 500 | return -ENOMEM; | 492 | return -ENOMEM; |
| 501 | } | 493 | } |
| @@ -504,7 +496,7 @@ static int snd_card_asihpi_pcm_hw_params(struct snd_pcm_substream *substream, | |||
| 504 | &dpcm->hpi_buffer_attached, | 496 | &dpcm->hpi_buffer_attached, |
| 505 | NULL, NULL, NULL); | 497 | NULL, NULL, NULL); |
| 506 | 498 | ||
| 507 | VPRINTK1(KERN_INFO "stream_host_buffer_attach status 0x%x\n", | 499 | snd_printdd("stream_host_buffer_attach status 0x%x\n", |
| 508 | dpcm->hpi_buffer_attached); | 500 | dpcm->hpi_buffer_attached); |
| 509 | } | 501 | } |
| 510 | bytes_per_sec = params_rate(params) * params_channels(params); | 502 | bytes_per_sec = params_rate(params) * params_channels(params); |
| @@ -517,7 +509,7 @@ static int snd_card_asihpi_pcm_hw_params(struct snd_pcm_substream *substream, | |||
| 517 | dpcm->bytes_per_sec = bytes_per_sec; | 509 | dpcm->bytes_per_sec = bytes_per_sec; |
| 518 | dpcm->buffer_bytes = params_buffer_bytes(params); | 510 | dpcm->buffer_bytes = params_buffer_bytes(params); |
| 519 | dpcm->period_bytes = params_period_bytes(params); | 511 | dpcm->period_bytes = params_period_bytes(params); |
| 520 | VPRINTK1(KERN_INFO "buffer_bytes=%d, period_bytes=%d, bps=%d\n", | 512 | snd_printdd("buffer_bytes=%d, period_bytes=%d, bps=%d\n", |
| 521 | dpcm->buffer_bytes, dpcm->period_bytes, bytes_per_sec); | 513 | dpcm->buffer_bytes, dpcm->period_bytes, bytes_per_sec); |
| 522 | 514 | ||
| 523 | return 0; | 515 | return 0; |
| @@ -573,7 +565,7 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream, | |||
| 573 | struct snd_pcm_substream *s; | 565 | struct snd_pcm_substream *s; |
| 574 | u16 e; | 566 | u16 e; |
| 575 | 567 | ||
| 576 | VPRINTK1(KERN_INFO "%c%d trigger\n", | 568 | snd_printdd("%c%d trigger\n", |
| 577 | SCHR(substream->stream), substream->number); | 569 | SCHR(substream->stream), substream->number); |
| 578 | switch (cmd) { | 570 | switch (cmd) { |
| 579 | case SNDRV_PCM_TRIGGER_START: | 571 | case SNDRV_PCM_TRIGGER_START: |
| @@ -597,7 +589,7 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream, | |||
| 597 | * data?? | 589 | * data?? |
| 598 | */ | 590 | */ |
| 599 | unsigned int preload = ds->period_bytes * 1; | 591 | unsigned int preload = ds->period_bytes * 1; |
| 600 | VPRINTK2(KERN_INFO "%d preload x%x\n", s->number, preload); | 592 | snd_printddd("%d preload x%x\n", s->number, preload); |
| 601 | hpi_handle_error(hpi_outstream_write_buf( | 593 | hpi_handle_error(hpi_outstream_write_buf( |
| 602 | ds->h_stream, | 594 | ds->h_stream, |
| 603 | &runtime->dma_area[0], | 595 | &runtime->dma_area[0], |
| @@ -607,7 +599,7 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream, | |||
| 607 | } | 599 | } |
| 608 | 600 | ||
| 609 | if (card->support_grouping) { | 601 | if (card->support_grouping) { |
| 610 | VPRINTK1(KERN_INFO "\t%c%d group\n", | 602 | snd_printdd("\t%c%d group\n", |
| 611 | SCHR(s->stream), | 603 | SCHR(s->stream), |
| 612 | s->number); | 604 | s->number); |
| 613 | e = hpi_stream_group_add( | 605 | e = hpi_stream_group_add( |
| @@ -622,7 +614,7 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream, | |||
| 622 | } else | 614 | } else |
| 623 | break; | 615 | break; |
| 624 | } | 616 | } |
| 625 | VPRINTK1(KERN_INFO "start\n"); | 617 | snd_printdd("start\n"); |
| 626 | /* start the master stream */ | 618 | /* start the master stream */ |
| 627 | snd_card_asihpi_pcm_timer_start(substream); | 619 | snd_card_asihpi_pcm_timer_start(substream); |
| 628 | if ((substream->stream == SNDRV_PCM_STREAM_CAPTURE) || | 620 | if ((substream->stream == SNDRV_PCM_STREAM_CAPTURE) || |
| @@ -644,14 +636,14 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream, | |||
| 644 | s->runtime->status->state = SNDRV_PCM_STATE_SETUP; | 636 | s->runtime->status->state = SNDRV_PCM_STATE_SETUP; |
| 645 | 637 | ||
| 646 | if (card->support_grouping) { | 638 | if (card->support_grouping) { |
| 647 | VPRINTK1(KERN_INFO "\t%c%d group\n", | 639 | snd_printdd("\t%c%d group\n", |
| 648 | SCHR(s->stream), | 640 | SCHR(s->stream), |
| 649 | s->number); | 641 | s->number); |
| 650 | snd_pcm_trigger_done(s, substream); | 642 | snd_pcm_trigger_done(s, substream); |
| 651 | } else | 643 | } else |
| 652 | break; | 644 | break; |
| 653 | } | 645 | } |
| 654 | VPRINTK1(KERN_INFO "stop\n"); | 646 | snd_printdd("stop\n"); |
| 655 | 647 | ||
| 656 | /* _prepare and _hwparams reset the stream */ | 648 | /* _prepare and _hwparams reset the stream */ |
| 657 | hpi_handle_error(hpi_stream_stop(dpcm->h_stream)); | 649 | hpi_handle_error(hpi_stream_stop(dpcm->h_stream)); |
| @@ -664,12 +656,12 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream, | |||
| 664 | break; | 656 | break; |
| 665 | 657 | ||
| 666 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | 658 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: |
| 667 | VPRINTK1(KERN_INFO "pause release\n"); | 659 | snd_printdd("pause release\n"); |
| 668 | hpi_handle_error(hpi_stream_start(dpcm->h_stream)); | 660 | hpi_handle_error(hpi_stream_start(dpcm->h_stream)); |
| 669 | snd_card_asihpi_pcm_timer_start(substream); | 661 | snd_card_asihpi_pcm_timer_start(substream); |
| 670 | break; | 662 | break; |
| 671 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | 663 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: |
| 672 | VPRINTK1(KERN_INFO "pause\n"); | 664 | snd_printdd("pause\n"); |
| 673 | snd_card_asihpi_pcm_timer_stop(substream); | 665 | snd_card_asihpi_pcm_timer_stop(substream); |
| 674 | hpi_handle_error(hpi_stream_stop(dpcm->h_stream)); | 666 | hpi_handle_error(hpi_stream_stop(dpcm->h_stream)); |
| 675 | break; | 667 | break; |
| @@ -741,7 +733,7 @@ static void snd_card_asihpi_timer_function(unsigned long data) | |||
| 741 | u16 state; | 733 | u16 state; |
| 742 | u32 buffer_size, bytes_avail, samples_played, on_card_bytes; | 734 | u32 buffer_size, bytes_avail, samples_played, on_card_bytes; |
| 743 | 735 | ||
| 744 | VPRINTK1(KERN_INFO "%c%d snd_card_asihpi_timer_function\n", | 736 | snd_printdd("%c%d snd_card_asihpi_timer_function\n", |
| 745 | SCHR(substream->stream), substream->number); | 737 | SCHR(substream->stream), substream->number); |
| 746 | 738 | ||
| 747 | /* find minimum newdata and buffer pos in group */ | 739 | /* find minimum newdata and buffer pos in group */ |
| @@ -770,10 +762,10 @@ static void snd_card_asihpi_timer_function(unsigned long data) | |||
| 770 | if ((bytes_avail == 0) && | 762 | if ((bytes_avail == 0) && |
| 771 | (on_card_bytes < ds->pcm_buf_host_rw_ofs)) { | 763 | (on_card_bytes < ds->pcm_buf_host_rw_ofs)) { |
| 772 | hpi_handle_error(hpi_stream_start(ds->h_stream)); | 764 | hpi_handle_error(hpi_stream_start(ds->h_stream)); |
| 773 | VPRINTK1(KERN_INFO "P%d start\n", s->number); | 765 | snd_printdd("P%d start\n", s->number); |
| 774 | } | 766 | } |
| 775 | } else if (state == HPI_STATE_DRAINED) { | 767 | } else if (state == HPI_STATE_DRAINED) { |
| 776 | VPRINTK1(KERN_WARNING "P%d drained\n", | 768 | snd_printd(KERN_WARNING "P%d drained\n", |
| 777 | s->number); | 769 | s->number); |
| 778 | /*snd_pcm_stop(s, SNDRV_PCM_STATE_XRUN); | 770 | /*snd_pcm_stop(s, SNDRV_PCM_STATE_XRUN); |
| 779 | continue; */ | 771 | continue; */ |
| @@ -794,13 +786,13 @@ static void snd_card_asihpi_timer_function(unsigned long data) | |||
| 794 | newdata); | 786 | newdata); |
| 795 | } | 787 | } |
| 796 | 788 | ||
| 797 | VPRINTK1(KERN_INFO "PB timer hw_ptr x%04lX, appl_ptr x%04lX\n", | 789 | snd_printdd("hw_ptr x%04lX, appl_ptr x%04lX\n", |
| 798 | (unsigned long)frames_to_bytes(runtime, | 790 | (unsigned long)frames_to_bytes(runtime, |
| 799 | runtime->status->hw_ptr), | 791 | runtime->status->hw_ptr), |
| 800 | (unsigned long)frames_to_bytes(runtime, | 792 | (unsigned long)frames_to_bytes(runtime, |
| 801 | runtime->control->appl_ptr)); | 793 | runtime->control->appl_ptr)); |
| 802 | 794 | ||
| 803 | VPRINTK1(KERN_INFO "%d %c%d S=%d, rw=%04X, dma=x%04X, left=x%04X," | 795 | snd_printdd("%d %c%d S=%d, rw=%04X, dma=x%04X, left=x%04X," |
| 804 | " aux=x%04X space=x%04X\n", | 796 | " aux=x%04X space=x%04X\n", |
| 805 | loops, SCHR(s->stream), s->number, | 797 | loops, SCHR(s->stream), s->number, |
| 806 | state, ds->pcm_buf_host_rw_ofs, pcm_buf_dma_ofs, (int)bytes_avail, | 798 | state, ds->pcm_buf_host_rw_ofs, pcm_buf_dma_ofs, (int)bytes_avail, |
| @@ -822,7 +814,7 @@ static void snd_card_asihpi_timer_function(unsigned long data) | |||
| 822 | 814 | ||
| 823 | next_jiffies = max(next_jiffies, 1U); | 815 | next_jiffies = max(next_jiffies, 1U); |
| 824 | dpcm->timer.expires = jiffies + next_jiffies; | 816 | dpcm->timer.expires = jiffies + next_jiffies; |
| 825 | VPRINTK1(KERN_INFO "jif %d buf pos x%04X newdata x%04X xfer x%04X\n", | 817 | snd_printdd("jif %d buf pos x%04X newdata x%04X xfer x%04X\n", |
| 826 | next_jiffies, pcm_buf_dma_ofs, newdata, xfercount); | 818 | next_jiffies, pcm_buf_dma_ofs, newdata, xfercount); |
| 827 | 819 | ||
| 828 | snd_pcm_group_for_each_entry(s, substream) { | 820 | snd_pcm_group_for_each_entry(s, substream) { |
| @@ -837,7 +829,7 @@ static void snd_card_asihpi_timer_function(unsigned long data) | |||
| 837 | if (xfercount && (on_card_bytes <= ds->period_bytes)) { | 829 | if (xfercount && (on_card_bytes <= ds->period_bytes)) { |
| 838 | if (card->support_mmap) { | 830 | if (card->support_mmap) { |
| 839 | if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) { | 831 | if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) { |
| 840 | VPRINTK2(KERN_INFO "P%d write x%04x\n", | 832 | snd_printddd("P%d write x%04x\n", |
| 841 | s->number, | 833 | s->number, |
| 842 | ds->period_bytes); | 834 | ds->period_bytes); |
| 843 | hpi_handle_error( | 835 | hpi_handle_error( |
| @@ -848,7 +840,7 @@ static void snd_card_asihpi_timer_function(unsigned long data) | |||
| 848 | xfercount, | 840 | xfercount, |
| 849 | &ds->format)); | 841 | &ds->format)); |
| 850 | } else { | 842 | } else { |
| 851 | VPRINTK2(KERN_INFO "C%d read x%04x\n", | 843 | snd_printddd("C%d read x%04x\n", |
| 852 | s->number, | 844 | s->number, |
| 853 | xfercount); | 845 | xfercount); |
| 854 | hpi_handle_error( | 846 | hpi_handle_error( |
| @@ -871,7 +863,7 @@ static void snd_card_asihpi_timer_function(unsigned long data) | |||
| 871 | static int snd_card_asihpi_playback_ioctl(struct snd_pcm_substream *substream, | 863 | static int snd_card_asihpi_playback_ioctl(struct snd_pcm_substream *substream, |
| 872 | unsigned int cmd, void *arg) | 864 | unsigned int cmd, void *arg) |
| 873 | { | 865 | { |
| 874 | /* snd_printd(KERN_INFO "Playback ioctl %d\n", cmd); */ | 866 | snd_printdd(KERN_INFO "Playback ioctl %d\n", cmd); |
| 875 | return snd_pcm_lib_ioctl(substream, cmd, arg); | 867 | return snd_pcm_lib_ioctl(substream, cmd, arg); |
| 876 | } | 868 | } |
| 877 | 869 | ||
| @@ -881,7 +873,7 @@ static int snd_card_asihpi_playback_prepare(struct snd_pcm_substream * | |||
| 881 | struct snd_pcm_runtime *runtime = substream->runtime; | 873 | struct snd_pcm_runtime *runtime = substream->runtime; |
| 882 | struct snd_card_asihpi_pcm *dpcm = runtime->private_data; | 874 | struct snd_card_asihpi_pcm *dpcm = runtime->private_data; |
| 883 | 875 | ||
| 884 | VPRINTK1(KERN_INFO "playback prepare %d\n", substream->number); | 876 | snd_printdd("playback prepare %d\n", substream->number); |
| 885 | 877 | ||
| 886 | hpi_handle_error(hpi_outstream_reset(dpcm->h_stream)); | 878 | hpi_handle_error(hpi_outstream_reset(dpcm->h_stream)); |
| 887 | dpcm->pcm_buf_host_rw_ofs = 0; | 879 | dpcm->pcm_buf_host_rw_ofs = 0; |
| @@ -898,7 +890,7 @@ snd_card_asihpi_playback_pointer(struct snd_pcm_substream *substream) | |||
| 898 | snd_pcm_uframes_t ptr; | 890 | snd_pcm_uframes_t ptr; |
| 899 | 891 | ||
| 900 | ptr = bytes_to_frames(runtime, dpcm->pcm_buf_dma_ofs % dpcm->buffer_bytes); | 892 | ptr = bytes_to_frames(runtime, dpcm->pcm_buf_dma_ofs % dpcm->buffer_bytes); |
| 901 | /* VPRINTK2(KERN_INFO "playback_pointer=x%04lx\n", (unsigned long)ptr); */ | 893 | snd_printddd("playback_pointer=x%04lx\n", (unsigned long)ptr); |
| 902 | return ptr; | 894 | return ptr; |
| 903 | } | 895 | } |
| 904 | 896 | ||
| @@ -1014,12 +1006,13 @@ static int snd_card_asihpi_playback_open(struct snd_pcm_substream *substream) | |||
| 1014 | 1006 | ||
| 1015 | snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, | 1007 | snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, |
| 1016 | card->update_interval_frames); | 1008 | card->update_interval_frames); |
| 1009 | |||
| 1017 | snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, | 1010 | snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, |
| 1018 | card->update_interval_frames * 2, UINT_MAX); | 1011 | card->update_interval_frames * 2, UINT_MAX); |
| 1019 | 1012 | ||
| 1020 | snd_pcm_set_sync(substream); | 1013 | snd_pcm_set_sync(substream); |
| 1021 | 1014 | ||
| 1022 | VPRINTK1(KERN_INFO "playback open\n"); | 1015 | snd_printdd("playback open\n"); |
| 1023 | 1016 | ||
| 1024 | return 0; | 1017 | return 0; |
| 1025 | } | 1018 | } |
| @@ -1030,7 +1023,7 @@ static int snd_card_asihpi_playback_close(struct snd_pcm_substream *substream) | |||
| 1030 | struct snd_card_asihpi_pcm *dpcm = runtime->private_data; | 1023 | struct snd_card_asihpi_pcm *dpcm = runtime->private_data; |
| 1031 | 1024 | ||
| 1032 | hpi_handle_error(hpi_outstream_close(dpcm->h_stream)); | 1025 | hpi_handle_error(hpi_outstream_close(dpcm->h_stream)); |
| 1033 | VPRINTK1(KERN_INFO "playback close\n"); | 1026 | snd_printdd("playback close\n"); |
| 1034 | 1027 | ||
| 1035 | return 0; | 1028 | return 0; |
| 1036 | } | 1029 | } |
| @@ -1050,13 +1043,13 @@ static int snd_card_asihpi_playback_copy(struct snd_pcm_substream *substream, | |||
| 1050 | if (copy_from_user(runtime->dma_area, src, len)) | 1043 | if (copy_from_user(runtime->dma_area, src, len)) |
| 1051 | return -EFAULT; | 1044 | return -EFAULT; |
| 1052 | 1045 | ||
| 1053 | VPRINTK2(KERN_DEBUG "playback copy%d %u bytes\n", | 1046 | snd_printddd("playback copy%d %u bytes\n", |
| 1054 | substream->number, len); | 1047 | substream->number, len); |
| 1055 | 1048 | ||
| 1056 | hpi_handle_error(hpi_outstream_write_buf(dpcm->h_stream, | 1049 | hpi_handle_error(hpi_outstream_write_buf(dpcm->h_stream, |
| 1057 | runtime->dma_area, len, &dpcm->format)); | 1050 | runtime->dma_area, len, &dpcm->format)); |
| 1058 | 1051 | ||
| 1059 | dpcm->pcm_buf_host_rw_ofs = dpcm->pcm_buf_host_rw_ofs + len; | 1052 | dpcm->pcm_buf_host_rw_ofs += len; |
| 1060 | 1053 | ||
| 1061 | return 0; | 1054 | return 0; |
| 1062 | } | 1055 | } |
| @@ -1066,16 +1059,11 @@ static int snd_card_asihpi_playback_silence(struct snd_pcm_substream * | |||
| 1066 | snd_pcm_uframes_t pos, | 1059 | snd_pcm_uframes_t pos, |
| 1067 | snd_pcm_uframes_t count) | 1060 | snd_pcm_uframes_t count) |
| 1068 | { | 1061 | { |
| 1069 | unsigned int len; | 1062 | /* Usually writes silence to DMA buffer, which should be overwritten |
| 1070 | struct snd_pcm_runtime *runtime = substream->runtime; | 1063 | by real audio later. Our fifos cannot be overwritten, and are not |
| 1071 | struct snd_card_asihpi_pcm *dpcm = runtime->private_data; | 1064 | free-running DMAs. Silence is output on fifo underflow. |
| 1072 | 1065 | This callback is still required to allow the copy callback to be used. | |
| 1073 | len = frames_to_bytes(runtime, count); | 1066 | */ |
| 1074 | VPRINTK1(KERN_INFO "playback silence %u bytes\n", len); | ||
| 1075 | |||
| 1076 | memset(runtime->dma_area, 0, len); | ||
| 1077 | hpi_handle_error(hpi_outstream_write_buf(dpcm->h_stream, | ||
| 1078 | runtime->dma_area, len, &dpcm->format)); | ||
| 1079 | return 0; | 1067 | return 0; |
| 1080 | } | 1068 | } |
| 1081 | 1069 | ||
| @@ -1110,7 +1098,7 @@ snd_card_asihpi_capture_pointer(struct snd_pcm_substream *substream) | |||
| 1110 | struct snd_pcm_runtime *runtime = substream->runtime; | 1098 | struct snd_pcm_runtime *runtime = substream->runtime; |
| 1111 | struct snd_card_asihpi_pcm *dpcm = runtime->private_data; | 1099 | struct snd_card_asihpi_pcm *dpcm = runtime->private_data; |
| 1112 | 1100 | ||
| 1113 | VPRINTK2(KERN_INFO "capture pointer %d=%d\n", | 1101 | snd_printddd("capture pointer %d=%d\n", |
| 1114 | substream->number, dpcm->pcm_buf_dma_ofs); | 1102 | substream->number, dpcm->pcm_buf_dma_ofs); |
| 1115 | /* NOTE Unlike playback can't use actual samples_played | 1103 | /* NOTE Unlike playback can't use actual samples_played |
| 1116 | for the capture position, because those samples aren't yet in | 1104 | for the capture position, because those samples aren't yet in |
| @@ -1135,7 +1123,7 @@ static int snd_card_asihpi_capture_prepare(struct snd_pcm_substream *substream) | |||
| 1135 | dpcm->pcm_buf_dma_ofs = 0; | 1123 | dpcm->pcm_buf_dma_ofs = 0; |
| 1136 | dpcm->pcm_buf_elapsed_dma_ofs = 0; | 1124 | dpcm->pcm_buf_elapsed_dma_ofs = 0; |
| 1137 | 1125 | ||
| 1138 | VPRINTK1("Capture Prepare %d\n", substream->number); | 1126 | snd_printdd("Capture Prepare %d\n", substream->number); |
| 1139 | return 0; | 1127 | return 0; |
| 1140 | } | 1128 | } |
| 1141 | 1129 | ||
| @@ -1198,7 +1186,7 @@ static int snd_card_asihpi_capture_open(struct snd_pcm_substream *substream) | |||
| 1198 | if (dpcm == NULL) | 1186 | if (dpcm == NULL) |
| 1199 | return -ENOMEM; | 1187 | return -ENOMEM; |
| 1200 | 1188 | ||
| 1201 | VPRINTK1("hpi_instream_open adapter %d stream %d\n", | 1189 | snd_printdd("capture open adapter %d stream %d\n", |
| 1202 | card->adapter_index, substream->number); | 1190 | card->adapter_index, substream->number); |
| 1203 | 1191 | ||
| 1204 | err = hpi_handle_error( | 1192 | err = hpi_handle_error( |
| @@ -1268,7 +1256,7 @@ static int snd_card_asihpi_capture_copy(struct snd_pcm_substream *substream, | |||
| 1268 | 1256 | ||
| 1269 | len = frames_to_bytes(runtime, count); | 1257 | len = frames_to_bytes(runtime, count); |
| 1270 | 1258 | ||
| 1271 | VPRINTK2(KERN_INFO "capture copy%d %d bytes\n", substream->number, len); | 1259 | snd_printddd("capture copy%d %d bytes\n", substream->number, len); |
| 1272 | hpi_handle_error(hpi_instream_read_buf(dpcm->h_stream, | 1260 | hpi_handle_error(hpi_instream_read_buf(dpcm->h_stream, |
| 1273 | runtime->dma_area, len)); | 1261 | runtime->dma_area, len)); |
| 1274 | 1262 | ||
| @@ -2887,6 +2875,9 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev, | |||
| 2887 | if (err) | 2875 | if (err) |
| 2888 | asihpi->update_interval_frames = 512; | 2876 | asihpi->update_interval_frames = 512; |
| 2889 | 2877 | ||
| 2878 | if (!asihpi->support_mmap) | ||
| 2879 | asihpi->update_interval_frames *= 2; | ||
| 2880 | |||
| 2890 | hpi_handle_error(hpi_instream_open(asihpi->adapter_index, | 2881 | hpi_handle_error(hpi_instream_open(asihpi->adapter_index, |
| 2891 | 0, &h_stream)); | 2882 | 0, &h_stream)); |
| 2892 | 2883 | ||
| @@ -2909,7 +2900,6 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev, | |||
| 2909 | asihpi->support_mrx | 2900 | asihpi->support_mrx |
| 2910 | ); | 2901 | ); |
| 2911 | 2902 | ||
| 2912 | |||
| 2913 | err = snd_card_asihpi_pcm_new(asihpi, 0, pcm_substreams); | 2903 | err = snd_card_asihpi_pcm_new(asihpi, 0, pcm_substreams); |
| 2914 | if (err < 0) { | 2904 | if (err < 0) { |
| 2915 | snd_printk(KERN_ERR "pcm_new failed\n"); | 2905 | snd_printk(KERN_ERR "pcm_new failed\n"); |
| @@ -2944,6 +2934,7 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev, | |||
| 2944 | sprintf(card->longname, "%s %i", | 2934 | sprintf(card->longname, "%s %i", |
| 2945 | card->shortname, asihpi->adapter_index); | 2935 | card->shortname, asihpi->adapter_index); |
| 2946 | err = snd_card_register(card); | 2936 | err = snd_card_register(card); |
| 2937 | |||
| 2947 | if (!err) { | 2938 | if (!err) { |
| 2948 | hpi_card->snd_card_asihpi = card; | 2939 | hpi_card->snd_card_asihpi = card; |
| 2949 | dev++; | 2940 | dev++; |
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index 734c6ee55d8..2942d2a9ea1 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c | |||
| @@ -4256,6 +4256,84 @@ static int ad1984a_thinkpad_init(struct hda_codec *codec) | |||
| 4256 | } | 4256 | } |
| 4257 | 4257 | ||
| 4258 | /* | 4258 | /* |
| 4259 | * Precision R5500 | ||
| 4260 | * 0x12 - HP/line-out | ||
| 4261 | * 0x13 - speaker (mono) | ||
| 4262 | * 0x15 - mic-in | ||
| 4263 | */ | ||
| 4264 | |||
| 4265 | static struct hda_verb ad1984a_precision_verbs[] = { | ||
| 4266 | /* Unmute main output path */ | ||
| 4267 | {0x03, AC_VERB_SET_AMP_GAIN_MUTE, 0x27}, /* 0dB */ | ||
| 4268 | {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE + 0x1f}, /* 0dB */ | ||
| 4269 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) + 0x17}, /* 0dB */ | ||
| 4270 | /* Analog mixer; mute as default */ | ||
| 4271 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, | ||
| 4272 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, | ||
| 4273 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, | ||
| 4274 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, | ||
| 4275 | {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, | ||
| 4276 | /* Select mic as input */ | ||
| 4277 | {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1}, | ||
| 4278 | {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE + 0x27}, /* 0dB */ | ||
| 4279 | /* Configure as mic */ | ||
| 4280 | {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, | ||
| 4281 | {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x7002}, /* raise mic as default */ | ||
| 4282 | /* HP unmute */ | ||
| 4283 | {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, | ||
| 4284 | /* turn on EAPD */ | ||
| 4285 | {0x13, AC_VERB_SET_EAPD_BTLENABLE, 0x02}, | ||
| 4286 | /* unsolicited event for pin-sense */ | ||
| 4287 | {0x12, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1884A_HP_EVENT}, | ||
| 4288 | { } /* end */ | ||
| 4289 | }; | ||
| 4290 | |||
| 4291 | static struct snd_kcontrol_new ad1984a_precision_mixers[] = { | ||
| 4292 | HDA_CODEC_VOLUME("Master Playback Volume", 0x21, 0x0, HDA_OUTPUT), | ||
| 4293 | HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT), | ||
| 4294 | HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT), | ||
| 4295 | HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT), | ||
| 4296 | HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x01, HDA_INPUT), | ||
| 4297 | HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT), | ||
| 4298 | HDA_CODEC_VOLUME("Mic Boost Volume", 0x15, 0x0, HDA_INPUT), | ||
| 4299 | HDA_CODEC_MUTE("Front Playback Switch", 0x12, 0x0, HDA_OUTPUT), | ||
| 4300 | HDA_CODEC_VOLUME("Speaker Playback Volume", 0x13, 0x0, HDA_OUTPUT), | ||
| 4301 | HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), | ||
| 4302 | HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT), | ||
| 4303 | { } /* end */ | ||
| 4304 | }; | ||
| 4305 | |||
| 4306 | |||
| 4307 | /* mute internal speaker if HP is plugged */ | ||
| 4308 | static void ad1984a_precision_automute(struct hda_codec *codec) | ||
| 4309 | { | ||
| 4310 | unsigned int present; | ||
| 4311 | |||
| 4312 | present = snd_hda_jack_detect(codec, 0x12); | ||
| 4313 | snd_hda_codec_amp_stereo(codec, 0x13, HDA_OUTPUT, 0, | ||
| 4314 | HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); | ||
| 4315 | } | ||
| 4316 | |||
| 4317 | |||
| 4318 | /* unsolicited event for HP jack sensing */ | ||
| 4319 | static void ad1984a_precision_unsol_event(struct hda_codec *codec, | ||
| 4320 | unsigned int res) | ||
| 4321 | { | ||
| 4322 | if ((res >> 26) != AD1884A_HP_EVENT) | ||
| 4323 | return; | ||
| 4324 | ad1984a_precision_automute(codec); | ||
| 4325 | } | ||
| 4326 | |||
| 4327 | /* initialize jack-sensing, too */ | ||
| 4328 | static int ad1984a_precision_init(struct hda_codec *codec) | ||
| 4329 | { | ||
| 4330 | ad198x_init(codec); | ||
| 4331 | ad1984a_precision_automute(codec); | ||
| 4332 | return 0; | ||
| 4333 | } | ||
| 4334 | |||
| 4335 | |||
| 4336 | /* | ||
| 4259 | * HP Touchsmart | 4337 | * HP Touchsmart |
| 4260 | * port-A (0x11) - front hp-out | 4338 | * port-A (0x11) - front hp-out |
| 4261 | * port-B (0x14) - unused | 4339 | * port-B (0x14) - unused |
| @@ -4384,6 +4462,7 @@ enum { | |||
| 4384 | AD1884A_MOBILE, | 4462 | AD1884A_MOBILE, |
| 4385 | AD1884A_THINKPAD, | 4463 | AD1884A_THINKPAD, |
| 4386 | AD1984A_TOUCHSMART, | 4464 | AD1984A_TOUCHSMART, |
| 4465 | AD1984A_PRECISION, | ||
| 4387 | AD1884A_MODELS | 4466 | AD1884A_MODELS |
| 4388 | }; | 4467 | }; |
| 4389 | 4468 | ||
| @@ -4393,9 +4472,11 @@ static const char * const ad1884a_models[AD1884A_MODELS] = { | |||
| 4393 | [AD1884A_MOBILE] = "mobile", | 4472 | [AD1884A_MOBILE] = "mobile", |
| 4394 | [AD1884A_THINKPAD] = "thinkpad", | 4473 | [AD1884A_THINKPAD] = "thinkpad", |
| 4395 | [AD1984A_TOUCHSMART] = "touchsmart", | 4474 | [AD1984A_TOUCHSMART] = "touchsmart", |
| 4475 | [AD1984A_PRECISION] = "precision", | ||
| 4396 | }; | 4476 | }; |
| 4397 | 4477 | ||
| 4398 | static struct snd_pci_quirk ad1884a_cfg_tbl[] = { | 4478 | static struct snd_pci_quirk ad1884a_cfg_tbl[] = { |
| 4479 | SND_PCI_QUIRK(0x1028, 0x04ac, "Precision R5500", AD1984A_PRECISION), | ||
| 4399 | SND_PCI_QUIRK(0x103c, 0x3030, "HP", AD1884A_MOBILE), | 4480 | SND_PCI_QUIRK(0x103c, 0x3030, "HP", AD1884A_MOBILE), |
| 4400 | SND_PCI_QUIRK(0x103c, 0x3037, "HP 2230s", AD1884A_LAPTOP), | 4481 | SND_PCI_QUIRK(0x103c, 0x3037, "HP 2230s", AD1884A_LAPTOP), |
| 4401 | SND_PCI_QUIRK(0x103c, 0x3056, "HP", AD1884A_MOBILE), | 4482 | SND_PCI_QUIRK(0x103c, 0x3056, "HP", AD1884A_MOBILE), |
| @@ -4489,6 +4570,14 @@ static int patch_ad1884a(struct hda_codec *codec) | |||
| 4489 | codec->patch_ops.unsol_event = ad1984a_thinkpad_unsol_event; | 4570 | codec->patch_ops.unsol_event = ad1984a_thinkpad_unsol_event; |
| 4490 | codec->patch_ops.init = ad1984a_thinkpad_init; | 4571 | codec->patch_ops.init = ad1984a_thinkpad_init; |
| 4491 | break; | 4572 | break; |
| 4573 | case AD1984A_PRECISION: | ||
| 4574 | spec->mixers[0] = ad1984a_precision_mixers; | ||
| 4575 | spec->init_verbs[spec->num_init_verbs++] = | ||
| 4576 | ad1984a_precision_verbs; | ||
| 4577 | spec->multiout.dig_out_nid = 0; | ||
| 4578 | codec->patch_ops.unsol_event = ad1984a_precision_unsol_event; | ||
| 4579 | codec->patch_ops.init = ad1984a_precision_init; | ||
| 4580 | break; | ||
| 4492 | case AD1984A_TOUCHSMART: | 4581 | case AD1984A_TOUCHSMART: |
| 4493 | spec->mixers[0] = ad1984a_touchsmart_mixers; | 4582 | spec->mixers[0] = ad1984a_touchsmart_mixers; |
| 4494 | spec->init_verbs[0] = ad1984a_touchsmart_verbs; | 4583 | spec->init_verbs[0] = ad1984a_touchsmart_verbs; |
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 5d582de91c1..0ef0035fe99 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c | |||
| @@ -1290,7 +1290,7 @@ static void alc_auto_init_amp(struct hda_codec *codec, int type) | |||
| 1290 | case 0x10ec0883: | 1290 | case 0x10ec0883: |
| 1291 | case 0x10ec0885: | 1291 | case 0x10ec0885: |
| 1292 | case 0x10ec0887: | 1292 | case 0x10ec0887: |
| 1293 | case 0x10ec0889: | 1293 | /*case 0x10ec0889:*/ /* this causes an SPDIF problem */ |
| 1294 | alc889_coef_init(codec); | 1294 | alc889_coef_init(codec); |
| 1295 | break; | 1295 | break; |
| 1296 | case 0x10ec0888: | 1296 | case 0x10ec0888: |
diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h index c0dcfca9b5b..c66d3f64dcf 100644 --- a/sound/usb/quirks-table.h +++ b/sound/usb/quirks-table.h | |||
| @@ -1568,6 +1568,46 @@ YAMAHA_DEVICE(0x7010, "UB99"), | |||
| 1568 | } | 1568 | } |
| 1569 | }, | 1569 | }, |
| 1570 | { | 1570 | { |
| 1571 | USB_DEVICE_VENDOR_SPEC(0x0582, 0x0104), | ||
| 1572 | .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { | ||
| 1573 | /* .vendor_name = "Roland", */ | ||
| 1574 | /* .product_name = "UM-1G", */ | ||
| 1575 | .ifnum = 0, | ||
| 1576 | .type = QUIRK_MIDI_FIXED_ENDPOINT, | ||
| 1577 | .data = & (const struct snd_usb_midi_endpoint_info) { | ||
| 1578 | .out_cables = 0x0001, | ||
| 1579 | .in_cables = 0x0001 | ||
| 1580 | } | ||
| 1581 | } | ||
| 1582 | }, | ||
| 1583 | { | ||
| 1584 | /* Boss JS-8 Jam Station */ | ||
| 1585 | USB_DEVICE(0x0582, 0x0109), | ||
| 1586 | .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { | ||
| 1587 | /* .vendor_name = "BOSS", */ | ||
| 1588 | /* .product_name = "JS-8", */ | ||
| 1589 | .ifnum = QUIRK_ANY_INTERFACE, | ||
| 1590 | .type = QUIRK_COMPOSITE, | ||
| 1591 | .data = (const struct snd_usb_audio_quirk[]) { | ||
| 1592 | { | ||
| 1593 | .ifnum = 0, | ||
| 1594 | .type = QUIRK_AUDIO_STANDARD_INTERFACE | ||
| 1595 | }, | ||
| 1596 | { | ||
| 1597 | .ifnum = 1, | ||
| 1598 | .type = QUIRK_AUDIO_STANDARD_INTERFACE | ||
| 1599 | }, | ||
| 1600 | { | ||
| 1601 | .ifnum = 2, | ||
| 1602 | .type = QUIRK_MIDI_STANDARD_INTERFACE | ||
| 1603 | }, | ||
| 1604 | { | ||
| 1605 | .ifnum = -1 | ||
| 1606 | } | ||
| 1607 | } | ||
| 1608 | } | ||
| 1609 | }, | ||
| 1610 | { | ||
| 1571 | /* has ID 0x0110 when not in Advanced Driver mode */ | 1611 | /* has ID 0x0110 when not in Advanced Driver mode */ |
| 1572 | USB_DEVICE_VENDOR_SPEC(0x0582, 0x010f), | 1612 | USB_DEVICE_VENDOR_SPEC(0x0582, 0x010f), |
| 1573 | .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { | 1613 | .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { |
