From olaf at sgi.com Wed Feb 1 13:32:13 2017 From: olaf at sgi.com (Olaf Weber) Date: Wed, 1 Feb 2017 14:32:13 +0100 Subject: [lustre-devel] [PATCH 60/60] staging: lustre: libcfs: fix minimum size check for libcfs ioctl In-Reply-To: References: <1485648328-2141-1-git-send-email-jsimmons@infradead.org> <1485648328-2141-61-git-send-email-jsimmons@infradead.org> <20170130105156.GA6881@mwanda> Message-ID: <57e8b9b1-e1c8-a5df-e34d-7124671c6888@sgi.com> On 31-01-17 03:25, James Simmons wrote: [...] >> Also I'm uncomfortable with: >> >> data = container_of(hdr, struct libcfs_ioctl_data, ioc_hdr); >> >> If hdr isn't the first member of the struct then the code is broken but >> container_of() implies that that isn't a hard requirement. It should >> just be: >> >> data = (struct libcfs_ioctl_data *)hdr; > > Don't know if hdr being first is a hard requirment. Doug, Amir do you know > if it is an requirement? It's a requirement. -- Olaf Weber SGI Phone: +31(0)30-6696796 Veldzigt 2b Fax: +31(0)30-6696799 Sr Software Engineer 3454 PW de Meern Vnet: 955-6796 Storage Software The Netherlands Email: olaf at sgi.com From gregkh at linuxfoundation.org Wed Feb 1 16:39:21 2017 From: gregkh at linuxfoundation.org (Greg Kroah-Hartman) Date: Wed, 1 Feb 2017 17:39:21 +0100 Subject: [lustre-devel] [PATCH 60/60] staging: lustre: libcfs: fix minimum size check for libcfs ioctl In-Reply-To: <57e8b9b1-e1c8-a5df-e34d-7124671c6888@sgi.com> References: <1485648328-2141-1-git-send-email-jsimmons@infradead.org> <1485648328-2141-61-git-send-email-jsimmons@infradead.org> <20170130105156.GA6881@mwanda> <57e8b9b1-e1c8-a5df-e34d-7124671c6888@sgi.com> Message-ID: <20170201163921.GA25524@kroah.com> On Wed, Feb 01, 2017 at 02:32:13PM +0100, Olaf Weber wrote: > On 31-01-17 03:25, James Simmons wrote: > > [...] > > > > Also I'm uncomfortable with: > > > > > > data = container_of(hdr, struct libcfs_ioctl_data, ioc_hdr); > > > > > > If hdr isn't the first member of the struct then the code is broken but > > > container_of() implies that that isn't a hard requirement. It should > > > just be: > > > > > > data = (struct libcfs_ioctl_data *)hdr; > > > > Don't know if hdr being first is a hard requirment. Doug, Amir do you know > > if it is an requirement? > > It's a requirement. That's horrid. Use container_of to be "safe" here please... From arnd at arndb.de Wed Feb 1 16:52:38 2017 From: arnd at arndb.de (Arnd Bergmann) Date: Wed, 1 Feb 2017 17:52:38 +0100 Subject: [lustre-devel] [PATCH] staging: lustre: shut up clang warnings on CLASSERT() Message-ID: <20170201165314.2588373-1-arnd@arndb.de> lustre uses a fake switch() statement as a compile-time assert, but unfortunately each use of that causes a warning when building with clang: drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c:2907:2: warning: no case matching constant switch condition '42' drivers/staging/lustre/lnet/klnds/socklnd/../../../include/linux/libcfs/libcfs_private.h:294:36: note: expanded from macro 'CLASSERT' #define CLASSERT(cond) do {switch (42) {case (cond): case 0: break; } } while (0) Adding a 'default:' label in there shuts up the warning. Signed-off-by: Arnd Bergmann --- drivers/staging/lustre/include/linux/libcfs/libcfs_private.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h index aab15d8112a4..2d5435029185 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h @@ -291,7 +291,7 @@ do { \ * value after conversion... * */ -#define CLASSERT(cond) do {switch (42) {case (cond): case 0: break; } } while (0) +#define CLASSERT(cond) do {switch (42) {case (cond): case 0: default: break; } } while (0) /* max value for numeric network address */ #define MAX_NUMERIC_VALUE 0xffffffff -- 2.9.0 From andreas.dilger at intel.com Thu Feb 2 07:50:24 2017 From: andreas.dilger at intel.com (Dilger, Andreas) Date: Thu, 2 Feb 2017 07:50:24 +0000 Subject: [lustre-devel] [PATCH] staging: lustre: shut up clang warnings on CLASSERT() In-Reply-To: <20170201165314.2588373-1-arnd@arndb.de> References: <20170201165314.2588373-1-arnd@arndb.de> Message-ID: On Feb 1, 2017, at 09:52, Arnd Bergmann wrote: > > lustre uses a fake switch() statement as a compile-time assert, but unfortunately > each use of that causes a warning when building with clang: > > drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c:2907:2: warning: no case matching constant switch condition '42' > drivers/staging/lustre/lnet/klnds/socklnd/../../../include/linux/libcfs/libcfs_private.h:294:36: note: expanded from macro 'CLASSERT' > #define CLASSERT(cond) do {switch (42) {case (cond): case 0: break; } } while (0) > > Adding a 'default:' label in there shuts up the warning. > > Signed-off-by: Arnd Bergmann Reviewed-by: Andreas Dilger > --- > drivers/staging/lustre/include/linux/libcfs/libcfs_private.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h > index aab15d8112a4..2d5435029185 100644 > --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h > +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h > @@ -291,7 +291,7 @@ do { \ > * value after conversion... > * > */ > -#define CLASSERT(cond) do {switch (42) {case (cond): case 0: break; } } while (0) > +#define CLASSERT(cond) do {switch (42) {case (cond): case 0: default: break; } } while (0) > > /* max value for numeric network address */ > #define MAX_NUMERIC_VALUE 0xffffffff > -- > 2.9.0 > Cheers, Andreas -- Andreas Dilger Lustre Principal Architect Intel Corporation From viro at ZenIV.linux.org.uk Thu Feb 2 09:51:25 2017 From: viro at ZenIV.linux.org.uk (Al Viro) Date: Thu, 2 Feb 2017 09:51:25 +0000 Subject: [lustre-devel] [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call In-Reply-To: <20170125133205.21704-1-jlayton@redhat.com> References: <20170124212327.14517-1-jlayton@redhat.com> <20170125133205.21704-1-jlayton@redhat.com> Message-ID: <20170202095125.GF27291@ZenIV.linux.org.uk> On Wed, Jan 25, 2017 at 08:32:03AM -0500, Jeff Layton wrote: > Small respin of the patch that I sent yesterday for the same thing. > > This moves the maxsize handling into iov_iter_pvec_size, so that we don't > end up iterating past the max size we'll use anyway when trying to > determine the pagevec length. > > Also, a respun patch to make ceph use iov_iter_get_pages_alloc instead of > trying to do it via its own routine. > > Al, if these look ok, do you want to pick these up or shall I ask > Ilya to merge them via the ceph tree? I'd rather have that kind of work go through the vfs tree; said that, I really wonder if this is the right approach. Most of the users of iov_iter_get_pages()/iov_iter_get_pages_alloc() look like they want something like iov_iter_for_each_page(iter, size, f, data) with int (*f)(struct page *page, size_t from, size_t size, void *data) passed as callback. Not everything fits that model, but there's a whole lot of things that do. Examples: * fs/direct_io.c:do_direct_IO(). We loop through the pages returned by dio_get_page(). For each of those we find the subrange of page (from/to) and handle IO on that range. Then we drop the reference to page and move on to the next one. dio_get_page() uses dio->pages and sdio->{head,tail,from,to} to avoid calling iov_iter_get_pages() on each page - iov_iter_get_pages() is called for bigger chunks (up to 64 pages, AFAICS) and results are kept in dio->pages for subsequent calls of dio_get_page(). Unconsumed references are dropped by dio_cleanup(); AFAICS, it could've been called unconditionally right after the call of do_direct_IO() (or from it, for that matter) - all remaining references to pages are never looked at after do_direct_IO(). As it is, we call it immediately on failure return from do_direct_IO() and then unconditionally after blk_finish_plug(). That oddity aside (and AFAICS it's really pointless - all pages we'd done something with in do_direct_IO() won't be affected by dio_cleanup()), there's potentially more interesting issue. If iov_iter_get_pages() fails on write at the moment when we have pending mapped blocks, we treat that as write from zero page. Once that has happened, we remember to stop mapping new blocks and arrange for having the error eventually treated as if it had come from IO failure. I'm not sure if this sucker handles all cases correctly, BTW - can we end up with a few pages worth of pending mapped blocks? But aside of that, it's really a "loop through all page subranges" kind of code. The inner loop in do_direct_IO() could be converted into a callback quite easily * nfs_direct_read_schedule_iovec(): same kind of batching, only there we have an outer loop calling iov_iter_get_pages_alloc() and then the inner loop goes through the page subranges, with the same work done for each. In this case we grab a reference inside the would-be callback and drop all references from iov_iter_get_pages_alloc() after the inner loop is done. Could've gotten rid of grabbing extra refs - that would mean dropping only the unused ones if the 'callback' (== inner loop body) has told us to bugger off early. IMO that would be a better model. Incidentally, we keep allocating/freeing the array used to store page references for each batch. * nfs_direct_write_schedule_iovec(): very similar to the read side. * zerocopy_sg_from_iter(): similar loop, batch size is MAX_SKB_FRAGS (i.e. 16 or 17, depending upon the PAGE_SIZE; unless somebody has done a port with 2Kb pages it shouldn't be greater than 17). Array of references is on stack, skb_fill_page_desc(skb, frag++, page, from, size) should become the callback. References are consumed by it and it can't fail, so there's nothing left to drop. * af_alg_make_sg(). Looks like it might be massaged to the same model; the tricky part is af_alg_free_sg() users. We keep references to pages in sgl->pages[] *and* store them in sgl->sg[...] (via sg_set_page()). af_alg_free_sg() drops them using ->pages[] instead of sg_page(...->sg + ...). Might or might not be a problem - I'm not familiar with that code. * fuse_get_user_pages(). It pretty much fills an equivalent of bio_vec array; the difference is, array of struct page * and arrays of (start, len) pairs are kept separately. The only benefit is using the first array as destination of iov_iter_get_pages(); might as well work into a separate batching array instead - copying struct page * is noise compared to storing (and calculating) start/len pairs we have to do there. Again, what we do there is a pure loop over page subranges. * fuse_copy_fill(). I'm not at all sure that iov_iter_get_pages() is a good idea there - fuse_copy_do() could bloody well just use copy_{to,from}_iter(). * fs/splice.c:iter_to_pipe(). Loop over page subranges, consuming page references. Unused ones are dropped. * bio_iov_iter_get_pages(). Wants to populate bio_vec array; should've been a loop calling iov_iter_get_pages(); gets tripped on each iovec boundary instead. IMO would've been better off with a loop and separate 'batching' array; would've killed the "Deep magic" mess in there, while we are at it. That's the majority of iov_iter_get_pages{,_alloc} callers. There's one I'm not sure about in lustre (looks like their O_DIRECT is complicated by rudiments of lloop stuff), there's a mess in p9_get_mapped_pages() (with special-casing the kvec-backed iterators using kmap_to_page() and vmalloc_to_page(), no less), there's default_file_splice_read() and there's ceph stuff. Everything else is covered by the 'loop over page subranges' stuff. I'm massaging that code (along with a lot of RTFS); the interesting questions related to VM side of things are * what are the relative costs of doing small vs. large batches? Some of get_user_pages_fast() instances have comments along the lines of "we ought to limit the batch size, but then nobody's doing more than 64 pages at a time anyway". * Not a question: any ->fault() that returns VM_FAULT_RETRY when *not* passed FAULT_FLAG_ALLOW_RETRY in flags ought to be shot. cxlflash one sure as hell is. * drivers/gpu/drm/vgem/vgem_drv.c:vgem_gem_fault() is bloody odd - shmem_read_mapping_page() can't return -EBUSY, AFAICS. vm_insert_page() used to (and back then vgem_gem_fault() used to be broken), but these days it looks like dead code... * ->page_mkwrite() instances sometimes return VM_FAULT_RETRY; AFAICS, it's only (ab)used there as 'not zero, but doesn't contain any error bits'; VM_FAULT_RETRY from that source does *not* reach handle_mm_fault() callers, right? * get_user_pages_fast() only returns 0 on zero size. AFAICS, that's true and some callers seems to rely upon that. Correct? * aligning the start address passed to get_user_pages_fast() et.al. Happens in many callers, but not all of them. Most of the instances forcibly align it in get_user_pages_fast() itself, but... not the fallback one. I'm not sure if it can be used to screw the things up, but it feels like aligning the sucker in get_user_pages...() would be safer - callers outnumber them and they are scattered in bad places (including drivers/staging) Comments? From gregkh at linuxfoundation.org Thu Feb 2 09:54:53 2017 From: gregkh at linuxfoundation.org (Greg Kroah-Hartman) Date: Thu, 2 Feb 2017 10:54:53 +0100 Subject: [lustre-devel] [PATCH] staging: lustre: shut up clang warnings on CLASSERT() In-Reply-To: References: <20170201165314.2588373-1-arnd@arndb.de> Message-ID: <20170202095453.GA30437@kroah.com> On Thu, Feb 02, 2017 at 07:50:24AM +0000, Dilger, Andreas wrote: > On Feb 1, 2017, at 09:52, Arnd Bergmann wrote: > > > > lustre uses a fake switch() statement as a compile-time assert, but unfortunately > > each use of that causes a warning when building with clang: > > > > drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c:2907:2: warning: no case matching constant switch condition '42' > > drivers/staging/lustre/lnet/klnds/socklnd/../../../include/linux/libcfs/libcfs_private.h:294:36: note: expanded from macro 'CLASSERT' > > #define CLASSERT(cond) do {switch (42) {case (cond): case 0: break; } } while (0) > > > > Adding a 'default:' label in there shuts up the warning. > > > > Signed-off-by: Arnd Bergmann > > Reviewed-by: Andreas Dilger > > > --- > > drivers/staging/lustre/include/linux/libcfs/libcfs_private.h | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h > > index aab15d8112a4..2d5435029185 100644 > > --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h > > +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h > > @@ -291,7 +291,7 @@ do { \ > > * value after conversion... > > * > > */ > > -#define CLASSERT(cond) do {switch (42) {case (cond): case 0: break; } } while (0) > > +#define CLASSERT(cond) do {switch (42) {case (cond): case 0: default: break; } } while (0) Ugh, why not just use the in-kernel ASSERT macro instead? thanks, greg k-h From arnd at arndb.de Thu Feb 2 10:40:32 2017 From: arnd at arndb.de (Arnd Bergmann) Date: Thu, 2 Feb 2017 11:40:32 +0100 Subject: [lustre-devel] [PATCH] staging: lustre: shut up clang warnings on CLASSERT() In-Reply-To: <20170202095453.GA30437@kroah.com> References: <20170201165314.2588373-1-arnd@arndb.de> <20170202095453.GA30437@kroah.com> Message-ID: On Thu, Feb 2, 2017 at 10:54 AM, Greg Kroah-Hartman wrote: b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h >> > index aab15d8112a4..2d5435029185 100644 >> > --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h >> > +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h >> > @@ -291,7 +291,7 @@ do { \ >> > * value after conversion... >> > * >> > */ >> > -#define CLASSERT(cond) do {switch (42) {case (cond): case 0: break; } } while (0) >> > +#define CLASSERT(cond) do {switch (42) {case (cond): case 0: default: break; } } while (0) > > Ugh, why not just use the in-kernel ASSERT macro instead? We don't have one ;-) I've done a semi-automated patch to replace CLASSERT() with the respective BUILD_BUG_ON() now, but that patch is quite large. Arnd From gregkh at linuxfoundation.org Thu Feb 2 10:43:57 2017 From: gregkh at linuxfoundation.org (Greg Kroah-Hartman) Date: Thu, 2 Feb 2017 11:43:57 +0100 Subject: [lustre-devel] [PATCH] staging: lustre: shut up clang warnings on CLASSERT() In-Reply-To: References: <20170201165314.2588373-1-arnd@arndb.de> <20170202095453.GA30437@kroah.com> Message-ID: <20170202104357.GB22904@kroah.com> On Thu, Feb 02, 2017 at 11:40:32AM +0100, Arnd Bergmann wrote: > On Thu, Feb 2, 2017 at 10:54 AM, Greg Kroah-Hartman > wrote: > b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h > >> > index aab15d8112a4..2d5435029185 100644 > >> > --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h > >> > +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h > >> > @@ -291,7 +291,7 @@ do { \ > >> > * value after conversion... > >> > * > >> > */ > >> > -#define CLASSERT(cond) do {switch (42) {case (cond): case 0: break; } } while (0) > >> > +#define CLASSERT(cond) do {switch (42) {case (cond): case 0: default: break; } } while (0) > > > > Ugh, why not just use the in-kernel ASSERT macro instead? > > We don't have one ;-) Oh nice! > I've done a semi-automated patch to replace CLASSERT() with the respective > BUILD_BUG_ON() now, but that patch is quite large. Should be easy to script, I missed that this was a build-time check. Heck, I'll take a script to do this, or I can just do it in my end. thanks, greg k-h From hch at infradead.org Thu Feb 2 10:56:51 2017 From: hch at infradead.org (Christoph Hellwig) Date: Thu, 2 Feb 2017 02:56:51 -0800 Subject: [lustre-devel] [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call In-Reply-To: <20170202095125.GF27291@ZenIV.linux.org.uk> References: <20170124212327.14517-1-jlayton@redhat.com> <20170125133205.21704-1-jlayton@redhat.com> <20170202095125.GF27291@ZenIV.linux.org.uk> Message-ID: <20170202105651.GA32111@infradead.org> On Thu, Feb 02, 2017 at 09:51:25AM +0000, Al Viro wrote: > On Wed, Jan 25, 2017 at 08:32:03AM -0500, Jeff Layton wrote: > > Small respin of the patch that I sent yesterday for the same thing. > > > > This moves the maxsize handling into iov_iter_pvec_size, so that we don't > > end up iterating past the max size we'll use anyway when trying to > > determine the pagevec length. > > > > Also, a respun patch to make ceph use iov_iter_get_pages_alloc instead of > > trying to do it via its own routine. > > > > Al, if these look ok, do you want to pick these up or shall I ask > > Ilya to merge them via the ceph tree? > > I'd rather have that kind of work go through the vfs tree; said that, > I really wonder if this is the right approach. Most of the users of > iov_iter_get_pages()/iov_iter_get_pages_alloc() look like they want > something like > iov_iter_for_each_page(iter, size, f, data) > with int (*f)(struct page *page, size_t from, size_t size, void *data) > passed as callback. Not everything fits that model, but there's a whole > lot of things that do. I was planning to do that, mostly because of the iomap dio code that would not only get a lot cleaner with this, but also support multi-page bvecs that we hope to have in the block layer soon. The issue with it is that we need to touch all the arch get_user_pages_fast implementations, so it's going to be a relatively invasive change that I didn't want to fix with just introducing the new direct I/O code. From viro at ZenIV.linux.org.uk Thu Feb 2 11:16:25 2017 From: viro at ZenIV.linux.org.uk (Al Viro) Date: Thu, 2 Feb 2017 11:16:25 +0000 Subject: [lustre-devel] [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call In-Reply-To: <20170202105651.GA32111@infradead.org> References: <20170124212327.14517-1-jlayton@redhat.com> <20170125133205.21704-1-jlayton@redhat.com> <20170202095125.GF27291@ZenIV.linux.org.uk> <20170202105651.GA32111@infradead.org> Message-ID: <20170202111625.GG27291@ZenIV.linux.org.uk> On Thu, Feb 02, 2017 at 02:56:51AM -0800, Christoph Hellwig wrote: > > I really wonder if this is the right approach. Most of the users of > > iov_iter_get_pages()/iov_iter_get_pages_alloc() look like they want > > something like > > iov_iter_for_each_page(iter, size, f, data) > > with int (*f)(struct page *page, size_t from, size_t size, void *data) > > passed as callback. Not everything fits that model, but there's a whole > > lot of things that do. > > I was planning to do that, mostly because of the iomap dio code that > would not only get a lot cleaner with this, but also support multi-page > bvecs that we hope to have in the block layer soon. The issue with it > is that we need to touch all the arch get_user_pages_fast > implementations, so it's going to be a relatively invasive change that I > didn't want to fix with just introducing the new direct I/O code. I'm not sure we need to touch any get_user_pages_fast() at all; let it fill a medium-sized array and use that as a buffer. In particular, I *really* don't like the idea of having the callbacks done in an inconsistent locking environment - sometimes under ->mmap_sem, sometimes not. I played with "let it fill bio_vec array", but it doesn't really fit the users; variant with callbacks is cleaner, IMO. From arnd at arndb.de Thu Feb 2 11:22:52 2017 From: arnd at arndb.de (Arnd Bergmann) Date: Thu, 2 Feb 2017 12:22:52 +0100 Subject: [lustre-devel] [PATCH] staging: lustre: shut up clang warnings on CLASSERT() In-Reply-To: <20170202104357.GB22904@kroah.com> References: <20170201165314.2588373-1-arnd@arndb.de> <20170202095453.GA30437@kroah.com> <20170202104357.GB22904@kroah.com> Message-ID: On Feb 2, 2017 11:43 AM, "Greg Kroah-Hartman" wrote: > On Thu, Feb 02, 2017 at 11:40:32AM +0100, Arnd Bergmann wrote: > > I've done a semi-automated patch to replace CLASSERT() with the respective > > BUILD_BUG_ON() now, but that patch is quite large. > > Should be easy to script, I missed that this was a build-time check. > Heck, I'll take a script to do this, or I can just do it in my end My patch has been through a couple of randconfig and allmodconfig builds now, should be good. If it's wrong, it will at least blow up at compile time. Arnd From arnd at arndb.de Thu Feb 2 11:26:51 2017 From: arnd at arndb.de (Arnd Bergmann) Date: Thu, 2 Feb 2017 12:26:51 +0100 Subject: [lustre-devel] [PATCH] staging: lustre: remove CLASSERT macro Message-ID: <20170202113209.612528-1-arnd@arndb.de> lustre uses a fake switch() statement as a compile-time assert, but unfortunately each use of that causes a warning when building with clang: drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c:2907:2: warning: no case matching constant switch condition '42' drivers/staging/lustre/lnet/klnds/socklnd/../../../include/linux/libcfs/libcfs_private.h:294:36: note: expanded from macro 'CLASSERT' #define CLASSERT(cond) do {switch (42) {case (cond): case 0: break; } } while (0) As Greg suggested, let's just kill off this macro completely instead of fixing it. This replaces it with BUILD_BUG_ON(), which means we have to negate all the conditions in the process. Signed-off-by: Arnd Bergmann --- .../lustre/include/linux/libcfs/libcfs_private.h | 16 -- .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 16 +- .../staging/lustre/lnet/klnds/socklnd/socklnd.c | 4 +- .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 2 +- .../lustre/lnet/klnds/socklnd/socklnd_proto.c | 2 +- drivers/staging/lustre/lnet/libcfs/hash.c | 2 +- drivers/staging/lustre/lnet/lnet/acceptor.c | 4 +- drivers/staging/lustre/lnet/lnet/api-ni.c | 134 +++++++------- drivers/staging/lustre/lnet/lnet/lib-socket.c | 2 +- drivers/staging/lustre/lnet/lnet/net_fault.c | 8 +- drivers/staging/lustre/lnet/lnet/router_proc.c | 4 +- drivers/staging/lustre/lustre/include/cl_object.h | 2 +- drivers/staging/lustre/lustre/include/lu_object.h | 2 +- drivers/staging/lustre/lustre/include/lustre_net.h | 4 +- drivers/staging/lustre/lustre/ldlm/ldlm_request.c | 2 +- drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 2 +- drivers/staging/lustre/lustre/llite/super25.c | 2 +- drivers/staging/lustre/lustre/llite/vvp_dev.c | 2 +- drivers/staging/lustre/lustre/lov/lov_pack.c | 6 +- drivers/staging/lustre/lustre/mdc/mdc_lib.c | 12 +- drivers/staging/lustre/lustre/mdc/mdc_locks.c | 2 +- drivers/staging/lustre/lustre/mdc/mdc_request.c | 2 +- drivers/staging/lustre/lustre/osc/osc_io.c | 2 +- drivers/staging/lustre/lustre/osc/osc_request.c | 16 +- drivers/staging/lustre/lustre/ptlrpc/client.c | 4 +- drivers/staging/lustre/lustre/ptlrpc/import.c | 2 +- .../staging/lustre/lustre/ptlrpc/pack_generic.c | 102 +++++------ drivers/staging/lustre/lustre/ptlrpc/pers.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/wiretest.c | 194 ++++++++++----------- 29 files changed, 269 insertions(+), 285 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h index aab15d8112a4..2dae85798ec1 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h @@ -277,22 +277,6 @@ do { \ #define CFS_ALLOC_PTR(ptr) LIBCFS_ALLOC(ptr, sizeof(*(ptr))) #define CFS_FREE_PTR(ptr) LIBCFS_FREE(ptr, sizeof(*(ptr))) -/** Compile-time assertion. - * - * Check an invariant described by a constant expression at compile time by - * forcing a compiler error if it does not hold. \a cond must be a constant - * expression as defined by the ISO C Standard: - * - * 6.8.4.2 The switch statement - * .... - * [#3] The expression of each case label shall be an integer - * constant expression and no two of the case constant - * expressions in the same switch statement shall have the same - * value after conversion... - * - */ -#define CLASSERT(cond) do {switch (42) {case (cond): case 0: break; } } while (0) - /* max value for numeric network address */ #define MAX_NUMERIC_VALUE 0xffffffff diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c index 7f761b327166..b1e8508f9fc7 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c @@ -258,8 +258,8 @@ int kiblnd_unpack_msg(struct kib_msg *msg, int nob) if (flip) { /* leave magic unflipped as a clue to peer endianness */ msg->ibm_version = version; - CLASSERT(sizeof(msg->ibm_type) == 1); - CLASSERT(sizeof(msg->ibm_credits) == 1); + BUILD_BUG_ON(sizeof(msg->ibm_type) != 1); + BUILD_BUG_ON(sizeof(msg->ibm_credits) != 1); msg->ibm_nob = msg_nob; __swab64s(&msg->ibm_srcnid); __swab64s(&msg->ibm_srcstamp); @@ -1247,10 +1247,10 @@ static void kiblnd_map_tx_pool(struct kib_tx_pool *tpo) dev = net->ibn_dev; /* pre-mapped messages are not bigger than 1 page */ - CLASSERT(IBLND_MSG_SIZE <= PAGE_SIZE); + BUILD_BUG_ON(IBLND_MSG_SIZE > PAGE_SIZE); /* No fancy arithmetic when we do the buffer calculations */ - CLASSERT(!(PAGE_SIZE % IBLND_MSG_SIZE)); + BUILD_BUG_ON(PAGE_SIZE % IBLND_MSG_SIZE); tpo->tpo_hdev = kiblnd_current_hdev(dev); @@ -2943,7 +2943,7 @@ static int kiblnd_startup(lnet_ni_t *ni) if (ni->ni_interfaces[0]) { /* Use the IPoIB interface specified in 'networks=' */ - CLASSERT(LNET_MAX_INTERFACES > 1); + BUILD_BUG_ON(LNET_MAX_INTERFACES <= 1); if (ni->ni_interfaces[1]) { CERROR("Multiple interfaces not supported\n"); goto failed; @@ -3020,11 +3020,11 @@ static void __exit ko2iblnd_exit(void) static int __init ko2iblnd_init(void) { - CLASSERT(sizeof(struct kib_msg) <= IBLND_MSG_SIZE); - CLASSERT(offsetof(struct kib_msg, + BUILD_BUG_ON(sizeof(struct kib_msg) > IBLND_MSG_SIZE); + BUILD_BUG_ON(!offsetof(struct kib_msg, ibm_u.get.ibgm_rd.rd_frags[IBLND_MAX_RDMA_FRAGS]) <= IBLND_MSG_SIZE); - CLASSERT(offsetof(struct kib_msg, + BUILD_BUG_ON(!offsetof(struct kib_msg, ibm_u.putack.ibpam_rd.rd_frags[IBLND_MAX_RDMA_FRAGS]) <= IBLND_MSG_SIZE); diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c index 2181c67a95e8..148db65185cb 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c @@ -2904,8 +2904,8 @@ static int __init ksocklnd_init(void) int rc; /* check ksnr_connected/connecting field large enough */ - CLASSERT(SOCKLND_CONN_NTYPES <= 4); - CLASSERT(SOCKLND_CONN_ACK == SOCKLND_CONN_BULK_IN); + BUILD_BUG_ON(SOCKLND_CONN_NTYPES > 4); + BUILD_BUG_ON(SOCKLND_CONN_ACK != SOCKLND_CONN_BULK_IN); /* initialize the_ksocklnd */ the_ksocklnd.lnd_type = SOCKLND; diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c index 3531e7d99349..95334a80e8b8 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c @@ -1658,7 +1658,7 @@ ksocknal_parse_proto_version(ksock_hello_msg_t *hello) if (hello->kshm_magic == le32_to_cpu(LNET_PROTO_TCP_MAGIC)) { struct lnet_magicversion *hmv = (struct lnet_magicversion *)hello; - CLASSERT(sizeof(struct lnet_magicversion) == + BUILD_BUG_ON(sizeof(struct lnet_magicversion) != offsetof(ksock_hello_msg_t, kshm_src_nid)); if (hmv->version_major == cpu_to_le16(KSOCK_PROTO_V1_MAJOR) && diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c index b36f181db08e..d367e74d46c2 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c @@ -464,7 +464,7 @@ ksocknal_send_hello_v1(struct ksock_conn *conn, ksock_hello_msg_t *hello) int rc; int i; - CLASSERT(sizeof(struct lnet_magicversion) == offsetof(struct lnet_hdr, src_nid)); + BUILD_BUG_ON(sizeof(struct lnet_magicversion) != offsetof(struct lnet_hdr, src_nid)); LIBCFS_ALLOC(hdr, sizeof(*hdr)); if (!hdr) { diff --git a/drivers/staging/lustre/lnet/libcfs/hash.c b/drivers/staging/lustre/lnet/libcfs/hash.c index c93c59d8fe6c..5c2ce2ee6fd9 100644 --- a/drivers/staging/lustre/lnet/libcfs/hash.c +++ b/drivers/staging/lustre/lnet/libcfs/hash.c @@ -1000,7 +1000,7 @@ cfs_hash_create(char *name, unsigned int cur_bits, unsigned int max_bits, struct cfs_hash *hs; int len; - CLASSERT(CFS_HASH_THETA_BITS < 15); + BUILD_BUG_ON(CFS_HASH_THETA_BITS >= 15); LASSERT(name); LASSERT(ops->hs_key); diff --git a/drivers/staging/lustre/lnet/lnet/acceptor.c b/drivers/staging/lustre/lnet/lnet/acceptor.c index a55c6cd6ff37..d5d27e534919 100644 --- a/drivers/staging/lustre/lnet/lnet/acceptor.c +++ b/drivers/staging/lustre/lnet/lnet/acceptor.c @@ -149,7 +149,7 @@ lnet_connect(struct socket **sockp, lnet_nid_t peer_nid, int port; int fatal; - CLASSERT(sizeof(cr) <= 16); /* not too big to be on the stack */ + BUILD_BUG_ON(sizeof(cr) > 16); /* too big to be on the stack */ for (port = LNET_ACCEPTOR_MAX_RESERVED_PORT; port >= LNET_ACCEPTOR_MIN_RESERVED_PORT; @@ -164,7 +164,7 @@ lnet_connect(struct socket **sockp, lnet_nid_t peer_nid, continue; } - CLASSERT(LNET_PROTO_ACCEPTOR_VERSION == 1); + BUILD_BUG_ON(LNET_PROTO_ACCEPTOR_VERSION != 1); cr.acr_magic = LNET_PROTO_ACCEPTOR_MAGIC; cr.acr_version = LNET_PROTO_ACCEPTOR_VERSION; diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index 79f8534d1056..08b38ef67784 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -180,89 +180,89 @@ static void lnet_assert_wire_constants(void) */ /* Constants... */ - CLASSERT(LNET_PROTO_TCP_MAGIC == 0xeebc0ded); - CLASSERT(LNET_PROTO_TCP_VERSION_MAJOR == 1); - CLASSERT(LNET_PROTO_TCP_VERSION_MINOR == 0); - CLASSERT(LNET_MSG_ACK == 0); - CLASSERT(LNET_MSG_PUT == 1); - CLASSERT(LNET_MSG_GET == 2); - CLASSERT(LNET_MSG_REPLY == 3); - CLASSERT(LNET_MSG_HELLO == 4); + BUILD_BUG_ON(LNET_PROTO_TCP_MAGIC != 0xeebc0ded); + BUILD_BUG_ON(LNET_PROTO_TCP_VERSION_MAJOR != 1); + BUILD_BUG_ON(LNET_PROTO_TCP_VERSION_MINOR != 0); + BUILD_BUG_ON(LNET_MSG_ACK != 0); + BUILD_BUG_ON(LNET_MSG_PUT != 1); + BUILD_BUG_ON(LNET_MSG_GET != 2); + BUILD_BUG_ON(LNET_MSG_REPLY != 3); + BUILD_BUG_ON(LNET_MSG_HELLO != 4); /* Checks for struct ptl_handle_wire_t */ - CLASSERT((int)sizeof(struct lnet_handle_wire) == 16); - CLASSERT((int)offsetof(struct lnet_handle_wire, wh_interface_cookie) == 0); - CLASSERT((int)sizeof(((struct lnet_handle_wire *)0)->wh_interface_cookie) == 8); - CLASSERT((int)offsetof(struct lnet_handle_wire, wh_object_cookie) == 8); - CLASSERT((int)sizeof(((struct lnet_handle_wire *)0)->wh_object_cookie) == 8); + BUILD_BUG_ON((int)sizeof(struct lnet_handle_wire) != 16); + BUILD_BUG_ON((int)offsetof(struct lnet_handle_wire, wh_interface_cookie) != 0); + BUILD_BUG_ON((int)sizeof(((struct lnet_handle_wire *)0)->wh_interface_cookie) != 8); + BUILD_BUG_ON((int)offsetof(struct lnet_handle_wire, wh_object_cookie) != 8); + BUILD_BUG_ON((int)sizeof(((struct lnet_handle_wire *)0)->wh_object_cookie) != 8); /* Checks for struct struct lnet_magicversion */ - CLASSERT((int)sizeof(struct lnet_magicversion) == 8); - CLASSERT((int)offsetof(struct lnet_magicversion, magic) == 0); - CLASSERT((int)sizeof(((struct lnet_magicversion *)0)->magic) == 4); - CLASSERT((int)offsetof(struct lnet_magicversion, version_major) == 4); - CLASSERT((int)sizeof(((struct lnet_magicversion *)0)->version_major) == 2); - CLASSERT((int)offsetof(struct lnet_magicversion, version_minor) == 6); - CLASSERT((int)sizeof(((struct lnet_magicversion *)0)->version_minor) == 2); + BUILD_BUG_ON((int)sizeof(struct lnet_magicversion) != 8); + BUILD_BUG_ON((int)offsetof(struct lnet_magicversion, magic) != 0); + BUILD_BUG_ON((int)sizeof(((struct lnet_magicversion *)0)->magic) != 4); + BUILD_BUG_ON((int)offsetof(struct lnet_magicversion, version_major) != 4); + BUILD_BUG_ON((int)sizeof(((struct lnet_magicversion *)0)->version_major) != 2); + BUILD_BUG_ON((int)offsetof(struct lnet_magicversion, version_minor) != 6); + BUILD_BUG_ON((int)sizeof(((struct lnet_magicversion *)0)->version_minor) != 2); /* Checks for struct struct lnet_hdr */ - CLASSERT((int)sizeof(struct lnet_hdr) == 72); - CLASSERT((int)offsetof(struct lnet_hdr, dest_nid) == 0); - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->dest_nid) == 8); - CLASSERT((int)offsetof(struct lnet_hdr, src_nid) == 8); - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->src_nid) == 8); - CLASSERT((int)offsetof(struct lnet_hdr, dest_pid) == 16); - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->dest_pid) == 4); - CLASSERT((int)offsetof(struct lnet_hdr, src_pid) == 20); - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->src_pid) == 4); - CLASSERT((int)offsetof(struct lnet_hdr, type) == 24); - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->type) == 4); - CLASSERT((int)offsetof(struct lnet_hdr, payload_length) == 28); - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->payload_length) == 4); - CLASSERT((int)offsetof(struct lnet_hdr, msg) == 32); - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->msg) == 40); + BUILD_BUG_ON((int)sizeof(struct lnet_hdr) != 72); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, dest_nid) != 0); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->dest_nid) != 8); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, src_nid) != 8); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->src_nid) != 8); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, dest_pid) != 16); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->dest_pid) != 4); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, src_pid) != 20); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->src_pid) != 4); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, type) != 24); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->type) != 4); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, payload_length) != 28); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->payload_length) != 4); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg) != 32); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg) != 40); /* Ack */ - CLASSERT((int)offsetof(struct lnet_hdr, msg.ack.dst_wmd) == 32); - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->msg.ack.dst_wmd) == 16); - CLASSERT((int)offsetof(struct lnet_hdr, msg.ack.match_bits) == 48); - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->msg.ack.match_bits) == 8); - CLASSERT((int)offsetof(struct lnet_hdr, msg.ack.mlength) == 56); - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->msg.ack.mlength) == 4); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.ack.dst_wmd) != 32); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.ack.dst_wmd) != 16); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.ack.match_bits) != 48); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.ack.match_bits) != 8); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.ack.mlength) != 56); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.ack.mlength) != 4); /* Put */ - CLASSERT((int)offsetof(struct lnet_hdr, msg.put.ack_wmd) == 32); - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->msg.put.ack_wmd) == 16); - CLASSERT((int)offsetof(struct lnet_hdr, msg.put.match_bits) == 48); - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->msg.put.match_bits) == 8); - CLASSERT((int)offsetof(struct lnet_hdr, msg.put.hdr_data) == 56); - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->msg.put.hdr_data) == 8); - CLASSERT((int)offsetof(struct lnet_hdr, msg.put.ptl_index) == 64); - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->msg.put.ptl_index) == 4); - CLASSERT((int)offsetof(struct lnet_hdr, msg.put.offset) == 68); - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->msg.put.offset) == 4); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.put.ack_wmd) != 32); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.put.ack_wmd) != 16); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.put.match_bits) != 48); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.put.match_bits) != 8); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.put.hdr_data) != 56); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.put.hdr_data) != 8); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.put.ptl_index) != 64); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.put.ptl_index) != 4); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.put.offset) != 68); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.put.offset) != 4); /* Get */ - CLASSERT((int)offsetof(struct lnet_hdr, msg.get.return_wmd) == 32); - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->msg.get.return_wmd) == 16); - CLASSERT((int)offsetof(struct lnet_hdr, msg.get.match_bits) == 48); - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->msg.get.match_bits) == 8); - CLASSERT((int)offsetof(struct lnet_hdr, msg.get.ptl_index) == 56); - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->msg.get.ptl_index) == 4); - CLASSERT((int)offsetof(struct lnet_hdr, msg.get.src_offset) == 60); - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->msg.get.src_offset) == 4); - CLASSERT((int)offsetof(struct lnet_hdr, msg.get.sink_length) == 64); - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->msg.get.sink_length) == 4); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.get.return_wmd) != 32); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.get.return_wmd) != 16); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.get.match_bits) != 48); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.get.match_bits) != 8); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.get.ptl_index) != 56); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.get.ptl_index) != 4); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.get.src_offset) != 60); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.get.src_offset) != 4); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.get.sink_length) != 64); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.get.sink_length) != 4); /* Reply */ - CLASSERT((int)offsetof(struct lnet_hdr, msg.reply.dst_wmd) == 32); - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->msg.reply.dst_wmd) == 16); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.reply.dst_wmd) != 32); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.reply.dst_wmd) != 16); /* Hello */ - CLASSERT((int)offsetof(struct lnet_hdr, msg.hello.incarnation) == 32); - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->msg.hello.incarnation) == 8); - CLASSERT((int)offsetof(struct lnet_hdr, msg.hello.type) == 40); - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->msg.hello.type) == 4); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.hello.incarnation) != 32); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.hello.incarnation) != 8); + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.hello.type) != 40); + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.hello.type) != 4); } static lnd_t * diff --git a/drivers/staging/lustre/lnet/lnet/lib-socket.c b/drivers/staging/lustre/lnet/lnet/lib-socket.c index 4e6dd5149b4f..654a7b262188 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-socket.c +++ b/drivers/staging/lustre/lnet/lnet/lib-socket.c @@ -97,7 +97,7 @@ lnet_ipif_query(char *name, int *up, __u32 *ip, __u32 *mask) return -EINVAL; } - CLASSERT(sizeof(ifr.ifr_name) >= IFNAMSIZ); + BUILD_BUG_ON(sizeof(ifr.ifr_name) < IFNAMSIZ); if (strlen(name) > sizeof(ifr.ifr_name) - 1) return -E2BIG; diff --git a/drivers/staging/lustre/lnet/lnet/net_fault.c b/drivers/staging/lustre/lnet/lnet/net_fault.c index bb6e4576a119..18183cbb9859 100644 --- a/drivers/staging/lustre/lnet/lnet/net_fault.c +++ b/drivers/staging/lustre/lnet/lnet/net_fault.c @@ -997,10 +997,10 @@ lnet_fault_ctl(int opc, struct libcfs_ioctl_data *data) int lnet_fault_init(void) { - CLASSERT(LNET_PUT_BIT == 1 << LNET_MSG_PUT); - CLASSERT(LNET_ACK_BIT == 1 << LNET_MSG_ACK); - CLASSERT(LNET_GET_BIT == 1 << LNET_MSG_GET); - CLASSERT(LNET_REPLY_BIT == 1 << LNET_MSG_REPLY); + BUILD_BUG_ON(LNET_PUT_BIT != 1 << LNET_MSG_PUT); + BUILD_BUG_ON(LNET_ACK_BIT != 1 << LNET_MSG_ACK); + BUILD_BUG_ON(LNET_GET_BIT != 1 << LNET_MSG_GET); + BUILD_BUG_ON(LNET_REPLY_BIT != 1 << LNET_MSG_REPLY); mutex_init(&delay_dd.dd_mutex); spin_lock_init(&delay_dd.dd_lock); diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c index 65f65a3fc901..a19e1405e3ea 100644 --- a/drivers/staging/lustre/lnet/lnet/router_proc.c +++ b/drivers/staging/lustre/lnet/lnet/router_proc.c @@ -139,7 +139,7 @@ static int proc_lnet_routes(struct ctl_table *table, int write, int ver; int off; - CLASSERT(sizeof(loff_t) >= 4); + BUILD_BUG_ON(sizeof(loff_t) < 4); off = LNET_PROC_HOFF_GET(*ppos); ver = LNET_PROC_VER_GET(*ppos); @@ -404,7 +404,7 @@ static int proc_lnet_peers(struct ctl_table *table, int write, int rc = 0; int len; - CLASSERT(LNET_PROC_HASH_BITS >= LNET_PEER_HASH_BITS); + BUILD_BUG_ON(LNET_PROC_HASH_BITS < LNET_PEER_HASH_BITS); LASSERT(!write); if (!*lenp) diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h index dc685610c4c4..9a91090819da 100644 --- a/drivers/staging/lustre/lustre/include/cl_object.h +++ b/drivers/staging/lustre/lustre/include/cl_object.h @@ -2311,7 +2311,7 @@ struct cl_io *cl_io_top(struct cl_io *io); do { \ typeof(foo_io) __foo_io = (foo_io); \ \ - CLASSERT(offsetof(typeof(*__foo_io), base) == 0); \ + BUILD_BUG_ON(offsetof(typeof(*__foo_io), base) != 0); \ memset(&__foo_io->base + 1, 0, \ sizeof(*__foo_io) - sizeof(__foo_io->base)); \ } while (0) diff --git a/drivers/staging/lustre/lustre/include/lu_object.h b/drivers/staging/lustre/lustre/include/lu_object.h index 69b281252db0..f283a036a748 100644 --- a/drivers/staging/lustre/lustre/include/lu_object.h +++ b/drivers/staging/lustre/lustre/include/lu_object.h @@ -1120,7 +1120,7 @@ struct lu_context_key { { \ type *value; \ \ - CLASSERT(PAGE_SIZE >= sizeof(*value)); \ + BUILD_BUG_ON(PAGE_SIZE < sizeof(*value)); \ \ value = kzalloc(sizeof(*value), GFP_NOFS); \ if (!value) \ diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h index 411eb0dc7f38..ef7311b4fbde 100644 --- a/drivers/staging/lustre/lustre/include/lustre_net.h +++ b/drivers/staging/lustre/lustre/include/lustre_net.h @@ -315,8 +315,8 @@ struct ptlrpc_client { union ptlrpc_async_args { /** * Scratchpad for passing args to completion interpreter. Users - * cast to the struct of their choosing, and CLASSERT that this is - * big enough. For _tons_ of context, kmalloc a struct and store + * cast to the struct of their choosing, and BUILD_BUG_ON oversized + * arguments. For _tons_ of context, kmalloc a struct and store * a pointer to it here. The pointer_arg ensures this struct is at * least big enough for that. */ diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c index c1f8693f94a5..ebfda368b057 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c @@ -1972,7 +1972,7 @@ static int replay_one_lock(struct obd_import *imp, struct ldlm_lock *lock) LDLM_DEBUG(lock, "replaying lock:"); atomic_inc(&req->rq_import->imp_replay_inflight); - CLASSERT(sizeof(*aa) <= sizeof(req->rq_async_args)); + BUILD_BUG_ON(sizeof(*aa) > sizeof(req->rq_async_args)); aa = ptlrpc_req_async_args(req); aa->lock_handle = body->lock_handle[0]; req->rq_interpret_reply = (ptlrpc_interpterer_t)replay_lock_interpret; diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index b22f5bae7201..d16f5e95ef0b 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -1368,7 +1368,7 @@ void ldlm_resource_dump(int level, struct ldlm_resource *res) struct ldlm_lock *lock; unsigned int granted = 0; - CLASSERT(RES_NAME_SIZE == 4); + BUILD_BUG_ON(RES_NAME_SIZE != 4); if (!((libcfs_debug | D_ERROR) & level)) return; diff --git a/drivers/staging/lustre/lustre/llite/super25.c b/drivers/staging/lustre/lustre/llite/super25.c index 106cd00910a7..4759802e062d 100644 --- a/drivers/staging/lustre/lustre/llite/super25.c +++ b/drivers/staging/lustre/lustre/llite/super25.c @@ -88,7 +88,7 @@ static int __init lustre_init(void) struct timespec64 ts; int i, rc, seed[2]; - CLASSERT(sizeof(LUSTRE_VOLATILE_HDR) == LUSTRE_VOLATILE_HDR_LEN + 1); + BUILD_BUG_ON(sizeof(LUSTRE_VOLATILE_HDR) != LUSTRE_VOLATILE_HDR_LEN + 1); /* print an address of _any_ initialized kernel symbol from this * module, to allow debugging with gdb that doesn't support data diff --git a/drivers/staging/lustre/lustre/llite/vvp_dev.c b/drivers/staging/lustre/lustre/llite/vvp_dev.c index 12c129f7e4ad..3669ea77ee93 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_dev.c +++ b/drivers/staging/lustre/lustre/llite/vvp_dev.c @@ -391,7 +391,7 @@ struct vvp_pgcache_id { static void vvp_pgcache_id_unpack(loff_t pos, struct vvp_pgcache_id *id) { - CLASSERT(sizeof(pos) == sizeof(__u64)); + BUILD_BUG_ON(sizeof(pos) != sizeof(__u64)); id->vpi_index = pos & 0xffffffff; id->vpi_depth = (pos >> PGC_DEPTH_SHIFT) & 0xf; diff --git a/drivers/staging/lustre/lustre/lov/lov_pack.c b/drivers/staging/lustre/lustre/lov/lov_pack.c index 68fa2de7a6ff..2e1bd47337fd 100644 --- a/drivers/staging/lustre/lustre/lov/lov_pack.c +++ b/drivers/staging/lustre/lustre/lov/lov_pack.c @@ -136,7 +136,7 @@ ssize_t lov_lsm_pack(const struct lov_stripe_md *lsm, void *buf, lmmv1->lmm_layout_gen = cpu_to_le16(lsm->lsm_layout_gen); if (lsm->lsm_magic == LOV_MAGIC_V3) { - CLASSERT(sizeof(lsm->lsm_pool_name) == + BUILD_BUG_ON(sizeof(lsm->lsm_pool_name) != sizeof(lmmv3->lmm_pool_name)); strlcpy(lmmv3->lmm_pool_name, lsm->lsm_pool_name, sizeof(lmmv3->lmm_pool_name)); @@ -357,8 +357,8 @@ int lov_getstripe(struct lov_object *obj, struct lov_stripe_md *lsm, /* FIXME: Bug 1185 - copy fields properly when structs change */ /* struct lov_user_md_v3 and struct lov_mds_md_v3 must be the same */ - CLASSERT(sizeof(lum) == sizeof(struct lov_mds_md_v3)); - CLASSERT(sizeof(lum.lmm_objects[0]) == sizeof(lmmk->lmm_objects[0])); + BUILD_BUG_ON(sizeof(lum) != sizeof(struct lov_mds_md_v3)); + BUILD_BUG_ON(sizeof(lum.lmm_objects[0]) != sizeof(lmmk->lmm_objects[0])); if (cpu_to_le32(LOV_MAGIC) != LOV_MAGIC && (lmmk->lmm_magic == cpu_to_le32(LOV_MAGIC_V1) || diff --git a/drivers/staging/lustre/lustre/mdc/mdc_lib.c b/drivers/staging/lustre/lustre/mdc/mdc_lib.c index f35e1f9afdef..b1853ff7f8b9 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_lib.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_lib.c @@ -125,7 +125,7 @@ void mdc_create_pack(struct ptlrpc_request *req, struct md_op_data *op_data, char *tmp; __u64 flags; - CLASSERT(sizeof(struct mdt_rec_reint) == sizeof(struct mdt_rec_create)); + BUILD_BUG_ON(sizeof(struct mdt_rec_reint) != sizeof(struct mdt_rec_create)); rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT); rec->cr_opcode = REINT_CREATE; @@ -189,7 +189,7 @@ void mdc_open_pack(struct ptlrpc_request *req, struct md_op_data *op_data, char *tmp; __u64 cr_flags; - CLASSERT(sizeof(struct mdt_rec_reint) == sizeof(struct mdt_rec_create)); + BUILD_BUG_ON(sizeof(struct mdt_rec_reint) != sizeof(struct mdt_rec_create)); rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT); /* XXX do something about time, uid, gid */ @@ -313,7 +313,7 @@ void mdc_setattr_pack(struct ptlrpc_request *req, struct md_op_data *op_data, struct mdt_rec_setattr *rec; struct lov_user_md *lum = NULL; - CLASSERT(sizeof(struct mdt_rec_reint) == + BUILD_BUG_ON(sizeof(struct mdt_rec_reint) != sizeof(struct mdt_rec_setattr)); rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT); mdc_setattr_pack_rec(rec, op_data); @@ -336,7 +336,7 @@ void mdc_unlink_pack(struct ptlrpc_request *req, struct md_op_data *op_data) { struct mdt_rec_unlink *rec; - CLASSERT(sizeof(struct mdt_rec_reint) == sizeof(struct mdt_rec_unlink)); + BUILD_BUG_ON(sizeof(struct mdt_rec_reint) != sizeof(struct mdt_rec_unlink)); rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT); rec->ul_opcode = op_data->op_cli_flags & CLI_RM_ENTRY ? @@ -359,7 +359,7 @@ void mdc_link_pack(struct ptlrpc_request *req, struct md_op_data *op_data) { struct mdt_rec_link *rec; - CLASSERT(sizeof(struct mdt_rec_reint) == sizeof(struct mdt_rec_link)); + BUILD_BUG_ON(sizeof(struct mdt_rec_reint) != sizeof(struct mdt_rec_link)); rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT); rec->lk_opcode = REINT_LINK; @@ -407,7 +407,7 @@ void mdc_rename_pack(struct ptlrpc_request *req, struct md_op_data *op_data, { struct mdt_rec_rename *rec; - CLASSERT(sizeof(struct mdt_rec_reint) == sizeof(struct mdt_rec_rename)); + BUILD_BUG_ON(sizeof(struct mdt_rec_reint) != sizeof(struct mdt_rec_rename)); rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT); /* XXX do something about time, uid, gid */ diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c b/drivers/staging/lustre/lustre/mdc/mdc_locks.c index 54ebb9952d66..41165f4536d0 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c @@ -1196,7 +1196,7 @@ int mdc_intent_getattr_async(struct obd_export *exp, return rc; } - CLASSERT(sizeof(*ga) <= sizeof(req->rq_async_args)); + BUILD_BUG_ON(sizeof(*ga) > sizeof(req->rq_async_args)); ga = ptlrpc_req_async_args(req); ga->ga_exp = exp; ga->ga_minfo = minfo; diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index 2cfd913f9bc5..b0dfb6b62a44 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -295,7 +295,7 @@ static int mdc_xattr_common(struct obd_export *exp, if (opcode == MDS_REINT) { struct mdt_rec_setxattr *rec; - CLASSERT(sizeof(struct mdt_rec_setxattr) == + BUILD_BUG_ON(sizeof(struct mdt_rec_setxattr) != sizeof(struct mdt_rec_reint)); rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT); rec->sx_opcode = REINT_SETXATTR; diff --git a/drivers/staging/lustre/lustre/osc/osc_io.c b/drivers/staging/lustre/lustre/osc/osc_io.c index 9402dfc01668..9f08f0308a57 100644 --- a/drivers/staging/lustre/lustre/osc/osc_io.c +++ b/drivers/staging/lustre/lustre/osc/osc_io.c @@ -699,7 +699,7 @@ static int osc_io_data_version_start(const struct lu_env *env, ptlrpc_request_set_replen(req); req->rq_interpret_reply = osc_data_version_interpret; - CLASSERT(sizeof(*dva) <= sizeof(req->rq_async_args)); + BUILD_BUG_ON(sizeof(*dva) > sizeof(req->rq_async_args)); dva = ptlrpc_req_async_args(req); dva->dva_oio = oio; diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 3efae759bdfa..f7352560bbe0 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -251,7 +251,7 @@ int osc_setattr_async(struct obd_export *exp, struct obdo *oa, req->rq_interpret_reply = (ptlrpc_interpterer_t)osc_setattr_interpret; - CLASSERT(sizeof(*sa) <= sizeof(req->rq_async_args)); + BUILD_BUG_ON(sizeof(*sa) > sizeof(req->rq_async_args)); sa = ptlrpc_req_async_args(req); sa->sa_oa = oa; sa->sa_upcall = upcall; @@ -349,7 +349,7 @@ int osc_punch_base(struct obd_export *exp, struct obdo *oa, ptlrpc_request_set_replen(req); req->rq_interpret_reply = (ptlrpc_interpterer_t)osc_setattr_interpret; - CLASSERT(sizeof(*sa) <= sizeof(req->rq_async_args)); + BUILD_BUG_ON(sizeof(*sa) > sizeof(req->rq_async_args)); sa = ptlrpc_req_async_args(req); sa->sa_oa = oa; sa->sa_upcall = upcall; @@ -430,7 +430,7 @@ int osc_sync_base(struct osc_object *obj, struct obdo *oa, ptlrpc_request_set_replen(req); req->rq_interpret_reply = osc_sync_interpret; - CLASSERT(sizeof(*fa) <= sizeof(req->rq_async_args)); + BUILD_BUG_ON(sizeof(*fa) > sizeof(req->rq_async_args)); fa = ptlrpc_req_async_args(req); fa->fa_obj = obj; fa->fa_oa = oa; @@ -1171,7 +1171,7 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli, } ptlrpc_request_set_replen(req); - CLASSERT(sizeof(*aa) <= sizeof(req->rq_async_args)); + BUILD_BUG_ON(sizeof(*aa) > sizeof(req->rq_async_args)); aa = ptlrpc_req_async_args(req); aa->aa_oa = oa; aa->aa_requested_nob = requested_nob; @@ -1758,7 +1758,7 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, cl_req_attr_set(env, osc2cl(obj), crattr); lustre_msg_set_jobid(req->rq_reqmsg, crattr->cra_jobid); - CLASSERT(sizeof(*aa) <= sizeof(req->rq_async_args)); + BUILD_BUG_ON(sizeof(*aa) > sizeof(req->rq_async_args)); aa = ptlrpc_req_async_args(req); INIT_LIST_HEAD(&aa->aa_oaps); list_splice_init(&rpc_list, &aa->aa_oaps); @@ -2039,7 +2039,7 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, if (!rc) { struct osc_enqueue_args *aa; - CLASSERT(sizeof(*aa) <= sizeof(req->rq_async_args)); + BUILD_BUG_ON(sizeof(*aa) > sizeof(req->rq_async_args)); aa = ptlrpc_req_async_args(req); aa->oa_exp = exp; aa->oa_mode = einfo->ei_mode; @@ -2196,7 +2196,7 @@ static int osc_statfs_async(struct obd_export *exp, } req->rq_interpret_reply = (ptlrpc_interpterer_t)osc_statfs_interpret; - CLASSERT(sizeof(*aa) <= sizeof(req->rq_async_args)); + BUILD_BUG_ON(sizeof(*aa) > sizeof(req->rq_async_args)); aa = ptlrpc_req_async_args(req); aa->aa_oi = oinfo; @@ -2401,7 +2401,7 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, struct osc_brw_async_args *aa; struct obdo *oa; - CLASSERT(sizeof(*aa) <= sizeof(req->rq_async_args)); + BUILD_BUG_ON(sizeof(*aa) > sizeof(req->rq_async_args)); aa = ptlrpc_req_async_args(req); oa = kmem_cache_zalloc(obdo_cachep, GFP_NOFS); if (!oa) { diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c index 804741362bc0..44d8eab6f5af 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c @@ -3070,7 +3070,7 @@ void ptlrpc_init_xid(void) } /* Always need to be aligned to a power-of-two for multi-bulk BRW */ - CLASSERT(((PTLRPC_BULK_OPS_COUNT - 1) & PTLRPC_BULK_OPS_COUNT) == 0); + BUILD_BUG_ON(((PTLRPC_BULK_OPS_COUNT - 1) & PTLRPC_BULK_OPS_COUNT) != 0); ptlrpc_last_xid &= PTLRPC_BULK_OPS_MASK; } @@ -3256,7 +3256,7 @@ void *ptlrpcd_alloc_work(struct obd_import *imp, req->rq_no_resend = 1; req->rq_pill.rc_fmt = (void *)&worker_format; - CLASSERT(sizeof(*args) <= sizeof(req->rq_async_args)); + BUILD_BUG_ON(sizeof(*args) > sizeof(req->rq_async_args)); args = ptlrpc_req_async_args(req); args->cb = cb; args->cbdata = cbdata; diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c index e8280194001c..93e172fe9ce4 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/import.c +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c @@ -703,7 +703,7 @@ int ptlrpc_connect_import(struct obd_import *imp) ptlrpc_request_set_replen(request); request->rq_interpret_reply = ptlrpc_connect_interpret; - CLASSERT(sizeof(*aa) <= sizeof(request->rq_async_args)); + BUILD_BUG_ON(sizeof(*aa) > sizeof(request->rq_async_args)); aa = ptlrpc_req_async_args(request); memset(aa, 0, sizeof(*aa)); diff --git a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c index b1170277fd84..9456a1825918 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c @@ -510,8 +510,8 @@ static int lustre_unpack_msg_v2(struct lustre_msg_v2 *m, int len) __swab32s(&m->lm_repsize); __swab32s(&m->lm_cksum); __swab32s(&m->lm_flags); - CLASSERT(offsetof(typeof(*m), lm_padding_2) != 0); - CLASSERT(offsetof(typeof(*m), lm_padding_3) != 0); + BUILD_BUG_ON(offsetof(typeof(*m), lm_padding_2) == 0); + BUILD_BUG_ON(offsetof(typeof(*m), lm_padding_3) == 0); } required_len = lustre_msg_hdr_size_v2(m->lm_bufcount); @@ -1526,18 +1526,18 @@ void lustre_swab_ptlrpc_body(struct ptlrpc_body *b) __swab64s(&b->pb_pre_versions[2]); __swab64s(&b->pb_pre_versions[3]); __swab64s(&b->pb_mbits); - CLASSERT(offsetof(typeof(*b), pb_padding0) != 0); - CLASSERT(offsetof(typeof(*b), pb_padding1) != 0); - CLASSERT(offsetof(typeof(*b), pb_padding64_0) != 0); - CLASSERT(offsetof(typeof(*b), pb_padding64_1) != 0); - CLASSERT(offsetof(typeof(*b), pb_padding64_2) != 0); + BUILD_BUG_ON(offsetof(typeof(*b), pb_padding0) == 0); + BUILD_BUG_ON(offsetof(typeof(*b), pb_padding1) == 0); + BUILD_BUG_ON(offsetof(typeof(*b), pb_padding64_0) == 0); + BUILD_BUG_ON(offsetof(typeof(*b), pb_padding64_1) == 0); + BUILD_BUG_ON(offsetof(typeof(*b), pb_padding64_2) == 0); /* While we need to maintain compatibility between * clients and servers without ptlrpc_body_v2 (< 2.3) * do not swab any fields beyond pb_jobid, as we are * using this swab function for both ptlrpc_body * and ptlrpc_body_v2. */ - CLASSERT(offsetof(typeof(*b), pb_jobid) != 0); + BUILD_BUG_ON(offsetof(typeof(*b), pb_jobid) == 0); } void lustre_swab_connect(struct obd_connect_data *ocd) @@ -1568,23 +1568,23 @@ void lustre_swab_connect(struct obd_connect_data *ocd) __swab64s(&ocd->ocd_maxbytes); if (ocd->ocd_connect_flags & OBD_CONNECT_MULTIMODRPCS) __swab16s(&ocd->ocd_maxmodrpcs); - CLASSERT(offsetof(typeof(*ocd), padding0)); - CLASSERT(offsetof(typeof(*ocd), padding1) != 0); + BUILD_BUG_ON(!offsetof(typeof(*ocd), padding0)); + BUILD_BUG_ON(offsetof(typeof(*ocd), padding1) == 0); if (ocd->ocd_connect_flags & OBD_CONNECT_FLAGS2) __swab64s(&ocd->ocd_connect_flags2); - CLASSERT(offsetof(typeof(*ocd), padding3) != 0); - CLASSERT(offsetof(typeof(*ocd), padding4) != 0); - CLASSERT(offsetof(typeof(*ocd), padding5) != 0); - CLASSERT(offsetof(typeof(*ocd), padding6) != 0); - CLASSERT(offsetof(typeof(*ocd), padding7) != 0); - CLASSERT(offsetof(typeof(*ocd), padding8) != 0); - CLASSERT(offsetof(typeof(*ocd), padding9) != 0); - CLASSERT(offsetof(typeof(*ocd), paddingA) != 0); - CLASSERT(offsetof(typeof(*ocd), paddingB) != 0); - CLASSERT(offsetof(typeof(*ocd), paddingC) != 0); - CLASSERT(offsetof(typeof(*ocd), paddingD) != 0); - CLASSERT(offsetof(typeof(*ocd), paddingE) != 0); - CLASSERT(offsetof(typeof(*ocd), paddingF) != 0); + BUILD_BUG_ON(offsetof(typeof(*ocd), padding3) == 0); + BUILD_BUG_ON(offsetof(typeof(*ocd), padding4) == 0); + BUILD_BUG_ON(offsetof(typeof(*ocd), padding5) == 0); + BUILD_BUG_ON(offsetof(typeof(*ocd), padding6) == 0); + BUILD_BUG_ON(offsetof(typeof(*ocd), padding7) == 0); + BUILD_BUG_ON(offsetof(typeof(*ocd), padding8) == 0); + BUILD_BUG_ON(offsetof(typeof(*ocd), padding9) == 0); + BUILD_BUG_ON(offsetof(typeof(*ocd), paddingA) == 0); + BUILD_BUG_ON(offsetof(typeof(*ocd), paddingB) == 0); + BUILD_BUG_ON(offsetof(typeof(*ocd), paddingC) == 0); + BUILD_BUG_ON(offsetof(typeof(*ocd), paddingD) == 0); + BUILD_BUG_ON(offsetof(typeof(*ocd), paddingE) == 0); + BUILD_BUG_ON(offsetof(typeof(*ocd), paddingF) == 0); } static void lustre_swab_obdo(struct obdo *o) @@ -1614,9 +1614,9 @@ static void lustre_swab_obdo(struct obdo *o) __swab32s(&o->o_uid_h); __swab32s(&o->o_gid_h); __swab64s(&o->o_data_version); - CLASSERT(offsetof(typeof(*o), o_padding_4) != 0); - CLASSERT(offsetof(typeof(*o), o_padding_5) != 0); - CLASSERT(offsetof(typeof(*o), o_padding_6) != 0); + BUILD_BUG_ON(offsetof(typeof(*o), o_padding_4) == 0); + BUILD_BUG_ON(offsetof(typeof(*o), o_padding_5) == 0); + BUILD_BUG_ON(offsetof(typeof(*o), o_padding_6) == 0); } void lustre_swab_obd_statfs(struct obd_statfs *os) @@ -1632,15 +1632,15 @@ void lustre_swab_obd_statfs(struct obd_statfs *os) __swab32s(&os->os_namelen); __swab64s(&os->os_maxbytes); __swab32s(&os->os_state); - CLASSERT(offsetof(typeof(*os), os_fprecreated) != 0); - CLASSERT(offsetof(typeof(*os), os_spare2) != 0); - CLASSERT(offsetof(typeof(*os), os_spare3) != 0); - CLASSERT(offsetof(typeof(*os), os_spare4) != 0); - CLASSERT(offsetof(typeof(*os), os_spare5) != 0); - CLASSERT(offsetof(typeof(*os), os_spare6) != 0); - CLASSERT(offsetof(typeof(*os), os_spare7) != 0); - CLASSERT(offsetof(typeof(*os), os_spare8) != 0); - CLASSERT(offsetof(typeof(*os), os_spare9) != 0); + BUILD_BUG_ON(offsetof(typeof(*os), os_fprecreated) == 0); + BUILD_BUG_ON(offsetof(typeof(*os), os_spare2) == 0); + BUILD_BUG_ON(offsetof(typeof(*os), os_spare3) == 0); + BUILD_BUG_ON(offsetof(typeof(*os), os_spare4) == 0); + BUILD_BUG_ON(offsetof(typeof(*os), os_spare5) == 0); + BUILD_BUG_ON(offsetof(typeof(*os), os_spare6) == 0); + BUILD_BUG_ON(offsetof(typeof(*os), os_spare7) == 0); + BUILD_BUG_ON(offsetof(typeof(*os), os_spare8) == 0); + BUILD_BUG_ON(offsetof(typeof(*os), os_spare9) == 0); } void lustre_swab_obd_ioobj(struct obd_ioobj *ioo) @@ -1680,7 +1680,7 @@ void lustre_swab_gl_desc(union ldlm_gl_desc *desc) __swab64s(&desc->lquota_desc.gl_hardlimit); __swab64s(&desc->lquota_desc.gl_softlimit); __swab64s(&desc->lquota_desc.gl_time); - CLASSERT(offsetof(typeof(desc->lquota_desc), gl_pad2) != 0); + BUILD_BUG_ON(offsetof(typeof(desc->lquota_desc), gl_pad2) == 0); } void lustre_swab_ost_lvb_v1(struct ost_lvb_v1 *lvb) @@ -1739,24 +1739,24 @@ void lustre_swab_mdt_body(struct mdt_body *b) __swab32s(&b->mbo_flags); __swab32s(&b->mbo_rdev); __swab32s(&b->mbo_nlink); - CLASSERT(offsetof(typeof(*b), mbo_unused2) != 0); + BUILD_BUG_ON(offsetof(typeof(*b), mbo_unused2) == 0); __swab32s(&b->mbo_suppgid); __swab32s(&b->mbo_eadatasize); __swab32s(&b->mbo_aclsize); __swab32s(&b->mbo_max_mdsize); - CLASSERT(offsetof(typeof(*b), mbo_unused3)); + BUILD_BUG_ON(!offsetof(typeof(*b), mbo_unused3)); __swab32s(&b->mbo_uid_h); __swab32s(&b->mbo_gid_h); - CLASSERT(offsetof(typeof(*b), mbo_padding_5) != 0); + BUILD_BUG_ON(offsetof(typeof(*b), mbo_padding_5) == 0); } void lustre_swab_mdt_ioepoch(struct mdt_ioepoch *b) { /* handle is opaque */ /* mio_handle is opaque */ - CLASSERT(offsetof(typeof(*b), mio_unused1)); - CLASSERT(offsetof(typeof(*b), mio_unused2)); - CLASSERT(offsetof(typeof(*b), mio_padding)); + BUILD_BUG_ON(!offsetof(typeof(*b), mio_unused1)); + BUILD_BUG_ON(!offsetof(typeof(*b), mio_unused2)); + BUILD_BUG_ON(!offsetof(typeof(*b), mio_padding)); } void lustre_swab_mgs_target_info(struct mgs_target_info *mti) @@ -1769,7 +1769,7 @@ void lustre_swab_mgs_target_info(struct mgs_target_info *mti) __swab32s(&mti->mti_flags); __swab32s(&mti->mti_instance); __swab32s(&mti->mti_nid_count); - CLASSERT(sizeof(lnet_nid_t) == sizeof(__u64)); + BUILD_BUG_ON(sizeof(lnet_nid_t) != sizeof(__u64)); for (i = 0; i < MTI_NIDS_MAX; i++) __swab64s(&mti->mti_nids[i]); } @@ -1785,13 +1785,13 @@ void lustre_swab_mgs_nidtbl_entry(struct mgs_nidtbl_entry *entry) /* mne_nid_(count|type) must be one byte size because we're gonna * access it w/o swapping. */ - CLASSERT(sizeof(entry->mne_nid_count) == sizeof(__u8)); - CLASSERT(sizeof(entry->mne_nid_type) == sizeof(__u8)); + BUILD_BUG_ON(sizeof(entry->mne_nid_count) != sizeof(__u8)); + BUILD_BUG_ON(sizeof(entry->mne_nid_type) != sizeof(__u8)); /* remove this assertion if ipv6 is supported. */ LASSERT(entry->mne_nid_type == 0); for (i = 0; i < entry->mne_nid_count; i++) { - CLASSERT(sizeof(lnet_nid_t) == sizeof(__u64)); + BUILD_BUG_ON(sizeof(lnet_nid_t) != sizeof(__u64)); __swab64s(&entry->u.nids[i]); } } @@ -1829,7 +1829,7 @@ static void lustre_swab_obd_dqblk(struct obd_dqblk *b) __swab64s(&b->dqb_btime); __swab64s(&b->dqb_itime); __swab32s(&b->dqb_valid); - CLASSERT(offsetof(typeof(*b), dqb_padding) != 0); + BUILD_BUG_ON(offsetof(typeof(*b), dqb_padding) == 0); } void lustre_swab_obd_quotactl(struct obd_quotactl *q) @@ -1900,7 +1900,7 @@ void lustre_swab_mdt_rec_reint (struct mdt_rec_reint *rr) __swab32s(&rr->rr_flags_h); __swab32s(&rr->rr_umask); - CLASSERT(offsetof(typeof(*rr), rr_padding_4) != 0); + BUILD_BUG_ON(offsetof(typeof(*rr), rr_padding_4) == 0); }; void lustre_swab_lov_desc(struct lov_desc *ld) @@ -1949,7 +1949,7 @@ void lustre_swab_lmv_user_md(struct lmv_user_md *lum) __swab32s(&lum->lum_stripe_offset); __swab32s(&lum->lum_hash_type); __swab32s(&lum->lum_type); - CLASSERT(offsetof(typeof(*lum), lum_padding1)); + BUILD_BUG_ON(!offsetof(typeof(*lum), lum_padding1)); } EXPORT_SYMBOL(lustre_swab_lmv_user_md); @@ -2038,7 +2038,7 @@ void lustre_swab_ldlm_intent(struct ldlm_intent *i) static void lustre_swab_ldlm_resource_desc(struct ldlm_resource_desc *r) { __swab32s(&r->lr_type); - CLASSERT(offsetof(typeof(*r), lr_padding) != 0); + BUILD_BUG_ON(offsetof(typeof(*r), lr_padding) == 0); lustre_swab_ldlm_res_id(&r->lr_name); } @@ -2061,7 +2061,7 @@ void lustre_swab_ldlm_request(struct ldlm_request *rq) void lustre_swab_ldlm_reply(struct ldlm_reply *r) { __swab32s(&r->lock_flags); - CLASSERT(offsetof(typeof(*r), lock_padding) != 0); + BUILD_BUG_ON(offsetof(typeof(*r), lock_padding) == 0); lustre_swab_ldlm_lock_desc(&r->lock_desc); /* lock_handle opaque */ __swab64s(&r->lock_policy_res1); diff --git a/drivers/staging/lustre/lustre/ptlrpc/pers.c b/drivers/staging/lustre/lustre/ptlrpc/pers.c index 94e9fa85d774..601acb84f343 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pers.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pers.c @@ -45,7 +45,7 @@ void ptlrpc_fill_bulk_md(lnet_md_t *md, struct ptlrpc_bulk_desc *desc, { int offset = mdidx * LNET_MAX_IOV; - CLASSERT(PTLRPC_MAX_BRW_PAGES < LI_POISON); + BUILD_BUG_ON(PTLRPC_MAX_BRW_PAGES >= LI_POISON); LASSERT(mdidx < desc->bd_md_max_brw); LASSERT(desc->bd_iov_count <= PTLRPC_MAX_BRW_PAGES); diff --git a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c index a04e36cf6dd4..367f7e24e3da 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c +++ b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c @@ -61,7 +61,7 @@ void lustre_assert_wire_constants(void) MDS_DIR_END_OFF); LASSERTF(DEAD_HANDLE_MAGIC == 0xdeadbeefcafebabeULL, "found 0x%.16llxULL\n", DEAD_HANDLE_MAGIC); - CLASSERT(MTI_NAME_MAXLEN == 64); + BUILD_BUG_ON(MTI_NAME_MAXLEN != 64); LASSERTF(OST_REPLY == 0, "found %lld\n", (long long)OST_REPLY); LASSERTF(OST_GETATTR == 1, "found %lld\n", @@ -306,16 +306,16 @@ void lustre_assert_wire_constants(void) (long long)LCK_MAXMODE); LASSERTF(LCK_MODE_NUM == 8, "found %lld\n", (long long)LCK_MODE_NUM); - CLASSERT(LDLM_PLAIN == 10); - CLASSERT(LDLM_EXTENT == 11); - CLASSERT(LDLM_FLOCK == 12); - CLASSERT(LDLM_IBITS == 13); - CLASSERT(LDLM_MAX_TYPE == 14); - CLASSERT(LUSTRE_RES_ID_SEQ_OFF == 0); - CLASSERT(LUSTRE_RES_ID_VER_OID_OFF == 1); - CLASSERT(LUSTRE_RES_ID_QUOTA_SEQ_OFF == 2); - CLASSERT(LUSTRE_RES_ID_QUOTA_VER_OID_OFF == 3); - CLASSERT(LUSTRE_RES_ID_HSH_OFF == 3); + BUILD_BUG_ON(LDLM_PLAIN != 10); + BUILD_BUG_ON(LDLM_EXTENT != 11); + BUILD_BUG_ON(LDLM_FLOCK != 12); + BUILD_BUG_ON(LDLM_IBITS != 13); + BUILD_BUG_ON(LDLM_MAX_TYPE != 14); + BUILD_BUG_ON(LUSTRE_RES_ID_SEQ_OFF != 0); + BUILD_BUG_ON(LUSTRE_RES_ID_VER_OID_OFF != 1); + BUILD_BUG_ON(LUSTRE_RES_ID_QUOTA_SEQ_OFF != 2); + BUILD_BUG_ON(LUSTRE_RES_ID_QUOTA_VER_OID_OFF != 3); + BUILD_BUG_ON(LUSTRE_RES_ID_HSH_OFF != 3); LASSERTF(OBD_PING == 400, "found %lld\n", (long long)OBD_PING); LASSERTF(OBD_LOG_CANCEL == 401, "found %lld\n", @@ -661,7 +661,7 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct ptlrpc_body_v3, pb_slv)); LASSERTF((int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_slv) == 8, "found %lld\n", (long long)(int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_slv)); - CLASSERT(PTLRPC_NUM_VERSIONS == 4); + BUILD_BUG_ON(PTLRPC_NUM_VERSIONS != 4); LASSERTF((int)offsetof(struct ptlrpc_body_v3, pb_pre_versions) == 88, "found %lld\n", (long long)(int)offsetof(struct ptlrpc_body_v3, pb_pre_versions)); LASSERTF((int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_pre_versions) == 32, "found %lld\n", @@ -682,7 +682,7 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct ptlrpc_body_v3, pb_padding64_2)); LASSERTF((int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_padding64_2) == 8, "found %lld\n", (long long)(int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_padding64_2)); - CLASSERT(LUSTRE_JOBID_SIZE == 32); + BUILD_BUG_ON(LUSTRE_JOBID_SIZE != 32); LASSERTF((int)offsetof(struct ptlrpc_body_v3, pb_jobid) == 152, "found %lld\n", (long long)(int)offsetof(struct ptlrpc_body_v3, pb_jobid)); LASSERTF((int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_jobid) == 32, "found %lld\n", @@ -1319,27 +1319,27 @@ void lustre_assert_wire_constants(void) OBD_MD_FLGETATTRLOCK); LASSERTF(OBD_MD_FLDATAVERSION == (0x0010000000000000ULL), "found 0x%.16llxULL\n", OBD_MD_FLDATAVERSION); - CLASSERT(OBD_FL_INLINEDATA == 0x00000001); - CLASSERT(OBD_FL_OBDMDEXISTS == 0x00000002); - CLASSERT(OBD_FL_DELORPHAN == 0x00000004); - CLASSERT(OBD_FL_NORPC == 0x00000008); - CLASSERT(OBD_FL_IDONLY == 0x00000010); - CLASSERT(OBD_FL_RECREATE_OBJS == 0x00000020); - CLASSERT(OBD_FL_DEBUG_CHECK == 0x00000040); - CLASSERT(OBD_FL_NO_USRQUOTA == 0x00000100); - CLASSERT(OBD_FL_NO_GRPQUOTA == 0x00000200); - CLASSERT(OBD_FL_CREATE_CROW == 0x00000400); - CLASSERT(OBD_FL_SRVLOCK == 0x00000800); - CLASSERT(OBD_FL_CKSUM_CRC32 == 0x00001000); - CLASSERT(OBD_FL_CKSUM_ADLER == 0x00002000); - CLASSERT(OBD_FL_CKSUM_CRC32C == 0x00004000); - CLASSERT(OBD_FL_CKSUM_RSVD2 == 0x00008000); - CLASSERT(OBD_FL_CKSUM_RSVD3 == 0x00010000); - CLASSERT(OBD_FL_SHRINK_GRANT == 0x00020000); - CLASSERT(OBD_FL_MMAP == 0x00040000); - CLASSERT(OBD_FL_RECOV_RESEND == 0x00080000); - CLASSERT(OBD_FL_NOSPC_BLK == 0x00100000); - CLASSERT(OBD_FL_LOCAL_MASK == 0xf0000000); + BUILD_BUG_ON(OBD_FL_INLINEDATA != 0x00000001); + BUILD_BUG_ON(OBD_FL_OBDMDEXISTS != 0x00000002); + BUILD_BUG_ON(OBD_FL_DELORPHAN != 0x00000004); + BUILD_BUG_ON(OBD_FL_NORPC != 0x00000008); + BUILD_BUG_ON(OBD_FL_IDONLY != 0x00000010); + BUILD_BUG_ON(OBD_FL_RECREATE_OBJS != 0x00000020); + BUILD_BUG_ON(OBD_FL_DEBUG_CHECK != 0x00000040); + BUILD_BUG_ON(OBD_FL_NO_USRQUOTA != 0x00000100); + BUILD_BUG_ON(OBD_FL_NO_GRPQUOTA != 0x00000200); + BUILD_BUG_ON(OBD_FL_CREATE_CROW != 0x00000400); + BUILD_BUG_ON(OBD_FL_SRVLOCK != 0x00000800); + BUILD_BUG_ON(OBD_FL_CKSUM_CRC32 != 0x00001000); + BUILD_BUG_ON(OBD_FL_CKSUM_ADLER != 0x00002000); + BUILD_BUG_ON(OBD_FL_CKSUM_CRC32C != 0x00004000); + BUILD_BUG_ON(OBD_FL_CKSUM_RSVD2 != 0x00008000); + BUILD_BUG_ON(OBD_FL_CKSUM_RSVD3 != 0x00010000); + BUILD_BUG_ON(OBD_FL_SHRINK_GRANT != 0x00020000); + BUILD_BUG_ON(OBD_FL_MMAP != 0x00040000); + BUILD_BUG_ON(OBD_FL_RECOV_RESEND != 0x00080000); + BUILD_BUG_ON(OBD_FL_NOSPC_BLK != 0x00100000); + BUILD_BUG_ON(OBD_FL_LOCAL_MASK != 0xf0000000); /* Checks for struct lov_ost_data_v1 */ LASSERTF((int)sizeof(struct lov_ost_data_v1) == 24, "found %lld\n", @@ -1388,7 +1388,7 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct lov_mds_md_v1, lmm_objects[0])); LASSERTF((int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_objects[0]) == 24, "found %lld\n", (long long)(int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_objects[0])); - CLASSERT(LOV_MAGIC_V1 == (0x0BD10000 | 0x0BD0)); + BUILD_BUG_ON(LOV_MAGIC_V1 != (0x0BD10000 | 0x0BD0)); /* Checks for struct lov_mds_md_v3 */ LASSERTF((int)sizeof(struct lov_mds_md_v3) == 48, "found %lld\n", @@ -1417,7 +1417,7 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct lov_mds_md_v3, lmm_layout_gen)); LASSERTF((int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_layout_gen) == 2, "found %lld\n", (long long)(int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_layout_gen)); - CLASSERT(LOV_MAXPOOLNAME == 15); + BUILD_BUG_ON(LOV_MAXPOOLNAME != 15); LASSERTF((int)offsetof(struct lov_mds_md_v3, lmm_pool_name[16]) == 48, "found %lld\n", (long long)(int)offsetof(struct lov_mds_md_v3, lmm_pool_name[16])); LASSERTF((int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_pool_name[16]) == 1, "found %lld\n", @@ -1426,7 +1426,7 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct lov_mds_md_v3, lmm_objects[0])); LASSERTF((int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_objects[0]) == 24, "found %lld\n", (long long)(int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_objects[0])); - CLASSERT(LOV_MAGIC_V3 == (0x0BD30000 | 0x0BD0)); + BUILD_BUG_ON(LOV_MAGIC_V3 != (0x0BD30000 | 0x0BD0)); LASSERTF(LOV_PATTERN_RAID0 == 0x00000001UL, "found 0x%.8xUL\n", (unsigned int)LOV_PATTERN_RAID0); LASSERTF(LOV_PATTERN_RAID1 == 0x00000002UL, "found 0x%.8xUL\n", @@ -1479,11 +1479,11 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct lmv_mds_md_v1, lmv_stripe_fids[0])); LASSERTF((int)sizeof(((struct lmv_mds_md_v1 *)0)->lmv_stripe_fids[0]) == 16, "found %lld\n", (long long)(int)sizeof(((struct lmv_mds_md_v1 *)0)->lmv_stripe_fids[0])); - CLASSERT(LMV_MAGIC_V1 == 0x0CD20CD0); - CLASSERT(LMV_MAGIC_STRIPE == 0x0CD40CD0); - CLASSERT(LMV_HASH_TYPE_MASK == 0x0000ffff); - CLASSERT(LMV_HASH_FLAG_MIGRATION == 0x80000000); - CLASSERT(LMV_HASH_FLAG_DEAD == 0x40000000); + BUILD_BUG_ON(LMV_MAGIC_V1 != 0x0CD20CD0); + BUILD_BUG_ON(LMV_MAGIC_STRIPE != 0x0CD40CD0); + BUILD_BUG_ON(LMV_HASH_TYPE_MASK != 0x0000ffff); + BUILD_BUG_ON(LMV_HASH_FLAG_MIGRATION != 0x80000000); + BUILD_BUG_ON(LMV_HASH_FLAG_DEAD != 0x40000000); /* Checks for struct obd_statfs */ LASSERTF((int)sizeof(struct obd_statfs) == 144, "found %lld\n", @@ -2761,12 +2761,12 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct lov_desc, ld_uuid)); LASSERTF((int)sizeof(((struct lov_desc *)0)->ld_uuid) == 40, "found %lld\n", (long long)(int)sizeof(((struct lov_desc *)0)->ld_uuid)); - CLASSERT(LOV_DESC_MAGIC == 0xB0CCDE5C); + BUILD_BUG_ON(LOV_DESC_MAGIC != 0xB0CCDE5C); /* Checks for struct ldlm_res_id */ LASSERTF((int)sizeof(struct ldlm_res_id) == 32, "found %lld\n", (long long)(int)sizeof(struct ldlm_res_id)); - CLASSERT(RES_NAME_SIZE == 4); + BUILD_BUG_ON(RES_NAME_SIZE != 4); LASSERTF((int)offsetof(struct ldlm_res_id, name[4]) == 32, "found %lld\n", (long long)(int)offsetof(struct ldlm_res_id, name[4])); LASSERTF((int)sizeof(((struct ldlm_res_id *)0)->name[4]) == 8, "found %lld\n", @@ -3037,7 +3037,7 @@ void lustre_assert_wire_constants(void) /* Checks for struct mgs_send_param */ LASSERTF((int)sizeof(struct mgs_send_param) == 1024, "found %lld\n", (long long)(int)sizeof(struct mgs_send_param)); - CLASSERT(MGS_PARAM_MAXLEN == 1024); + BUILD_BUG_ON(MGS_PARAM_MAXLEN != 1024); LASSERTF((int)offsetof(struct mgs_send_param, mgs_param[1024]) == 1024, "found %lld\n", (long long)(int)offsetof(struct mgs_send_param, mgs_param[1024])); LASSERTF((int)sizeof(((struct mgs_send_param *)0)->mgs_param[1024]) == 1, "found %lld\n", @@ -3090,16 +3090,16 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct llog_logid, lgl_ogen)); LASSERTF((int)sizeof(((struct llog_logid *)0)->lgl_ogen) == 4, "found %lld\n", (long long)(int)sizeof(((struct llog_logid *)0)->lgl_ogen)); - CLASSERT(OST_SZ_REC == 274730752); - CLASSERT(MDS_UNLINK_REC == 274801668); - CLASSERT(MDS_UNLINK64_REC == 275325956); - CLASSERT(MDS_SETATTR64_REC == 275325953); - CLASSERT(OBD_CFG_REC == 274857984); - CLASSERT(LLOG_GEN_REC == 274989056); - CLASSERT(CHANGELOG_REC == 275120128); - CLASSERT(CHANGELOG_USER_REC == 275185664); - CLASSERT(LLOG_HDR_MAGIC == 275010873); - CLASSERT(LLOG_LOGID_MAGIC == 275010875); + BUILD_BUG_ON(OST_SZ_REC != 274730752); + BUILD_BUG_ON(MDS_UNLINK_REC != 274801668); + BUILD_BUG_ON(MDS_UNLINK64_REC != 275325956); + BUILD_BUG_ON(MDS_SETATTR64_REC != 275325953); + BUILD_BUG_ON(OBD_CFG_REC != 274857984); + BUILD_BUG_ON(LLOG_GEN_REC != 274989056); + BUILD_BUG_ON(CHANGELOG_REC != 275120128); + BUILD_BUG_ON(CHANGELOG_USER_REC != 275185664); + BUILD_BUG_ON(LLOG_HDR_MAGIC != 275010873); + BUILD_BUG_ON(LLOG_LOGID_MAGIC != 275010875); /* Checks for struct llog_catid */ LASSERTF((int)sizeof(struct llog_catid) == 32, "found %lld\n", @@ -3519,30 +3519,30 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct llogd_body, lgd_cur_offset)); LASSERTF((int)sizeof(((struct llogd_body *)0)->lgd_cur_offset) == 8, "found %lld\n", (long long)(int)sizeof(((struct llogd_body *)0)->lgd_cur_offset)); - CLASSERT(LLOG_ORIGIN_HANDLE_CREATE == 501); - CLASSERT(LLOG_ORIGIN_HANDLE_NEXT_BLOCK == 502); - CLASSERT(LLOG_ORIGIN_HANDLE_READ_HEADER == 503); - CLASSERT(LLOG_ORIGIN_HANDLE_WRITE_REC == 504); - CLASSERT(LLOG_ORIGIN_HANDLE_CLOSE == 505); - CLASSERT(LLOG_ORIGIN_CONNECT == 506); - CLASSERT(LLOG_CATINFO == 507); - CLASSERT(LLOG_ORIGIN_HANDLE_PREV_BLOCK == 508); - CLASSERT(LLOG_ORIGIN_HANDLE_DESTROY == 509); - CLASSERT(LLOG_FIRST_OPC == 501); - CLASSERT(LLOG_LAST_OPC == 510); - CLASSERT(LLOG_CONFIG_ORIG_CTXT == 0); - CLASSERT(LLOG_CONFIG_REPL_CTXT == 1); - CLASSERT(LLOG_MDS_OST_ORIG_CTXT == 2); - CLASSERT(LLOG_MDS_OST_REPL_CTXT == 3); - CLASSERT(LLOG_SIZE_ORIG_CTXT == 4); - CLASSERT(LLOG_SIZE_REPL_CTXT == 5); - CLASSERT(LLOG_TEST_ORIG_CTXT == 8); - CLASSERT(LLOG_TEST_REPL_CTXT == 9); - CLASSERT(LLOG_CHANGELOG_ORIG_CTXT == 12); - CLASSERT(LLOG_CHANGELOG_REPL_CTXT == 13); - CLASSERT(LLOG_CHANGELOG_USER_ORIG_CTXT == 14); - CLASSERT(LLOG_AGENT_ORIG_CTXT == 15); - CLASSERT(LLOG_MAX_CTXTS == 16); + BUILD_BUG_ON(LLOG_ORIGIN_HANDLE_CREATE != 501); + BUILD_BUG_ON(LLOG_ORIGIN_HANDLE_NEXT_BLOCK != 502); + BUILD_BUG_ON(LLOG_ORIGIN_HANDLE_READ_HEADER != 503); + BUILD_BUG_ON(LLOG_ORIGIN_HANDLE_WRITE_REC != 504); + BUILD_BUG_ON(LLOG_ORIGIN_HANDLE_CLOSE != 505); + BUILD_BUG_ON(LLOG_ORIGIN_CONNECT != 506); + BUILD_BUG_ON(LLOG_CATINFO != 507); + BUILD_BUG_ON(LLOG_ORIGIN_HANDLE_PREV_BLOCK != 508); + BUILD_BUG_ON(LLOG_ORIGIN_HANDLE_DESTROY != 509); + BUILD_BUG_ON(LLOG_FIRST_OPC != 501); + BUILD_BUG_ON(LLOG_LAST_OPC != 510); + BUILD_BUG_ON(LLOG_CONFIG_ORIG_CTXT != 0); + BUILD_BUG_ON(LLOG_CONFIG_REPL_CTXT != 1); + BUILD_BUG_ON(LLOG_MDS_OST_ORIG_CTXT != 2); + BUILD_BUG_ON(LLOG_MDS_OST_REPL_CTXT != 3); + BUILD_BUG_ON(LLOG_SIZE_ORIG_CTXT != 4); + BUILD_BUG_ON(LLOG_SIZE_REPL_CTXT != 5); + BUILD_BUG_ON(LLOG_TEST_ORIG_CTXT != 8); + BUILD_BUG_ON(LLOG_TEST_REPL_CTXT != 9); + BUILD_BUG_ON(LLOG_CHANGELOG_ORIG_CTXT != 12); + BUILD_BUG_ON(LLOG_CHANGELOG_REPL_CTXT != 13); + BUILD_BUG_ON(LLOG_CHANGELOG_USER_ORIG_CTXT != 14); + BUILD_BUG_ON(LLOG_AGENT_ORIG_CTXT != 15); + BUILD_BUG_ON(LLOG_MAX_CTXTS != 16); /* Checks for struct llogd_conn_body */ LASSERTF((int)sizeof(struct llogd_conn_body) == 40, "found %lld\n", @@ -3659,7 +3659,7 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct lustre_capa, lc_expiry)); LASSERTF((int)sizeof(((struct lustre_capa *)0)->lc_expiry) == 4, "found %lld\n", (long long)(int)sizeof(((struct lustre_capa *)0)->lc_expiry)); - CLASSERT(CAPA_HMAC_MAX_LEN == 64); + BUILD_BUG_ON(CAPA_HMAC_MAX_LEN != 64); LASSERTF((int)offsetof(struct lustre_capa, lc_hmac[64]) == 120, "found %lld\n", (long long)(int)offsetof(struct lustre_capa, lc_hmac[64])); LASSERTF((int)sizeof(((struct lustre_capa *)0)->lc_hmac[64]) == 1, "found %lld\n", @@ -3680,7 +3680,7 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct lustre_capa_key, lk_padding)); LASSERTF((int)sizeof(((struct lustre_capa_key *)0)->lk_padding) == 4, "found %lld\n", (long long)(int)sizeof(((struct lustre_capa_key *)0)->lk_padding)); - CLASSERT(CAPA_HMAC_KEY_MAX_LEN == 56); + BUILD_BUG_ON(CAPA_HMAC_KEY_MAX_LEN != 56); LASSERTF((int)offsetof(struct lustre_capa_key, lk_key[56]) == 72, "found %lld\n", (long long)(int)offsetof(struct lustre_capa_key, lk_key[56])); LASSERTF((int)sizeof(((struct lustre_capa_key *)0)->lk_key[56]) == 1, "found %lld\n", @@ -3741,9 +3741,9 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct fiemap, fm_extents)); LASSERTF((int)sizeof(((struct fiemap *)0)->fm_extents) == 0, "found %lld\n", (long long)(int)sizeof(((struct fiemap *)0)->fm_extents)); - CLASSERT(FIEMAP_FLAG_SYNC == 0x00000001); - CLASSERT(FIEMAP_FLAG_XATTR == 0x00000002); - CLASSERT(FIEMAP_FLAG_DEVICE_ORDER == 0x40000000); + BUILD_BUG_ON(FIEMAP_FLAG_SYNC != 0x00000001); + BUILD_BUG_ON(FIEMAP_FLAG_XATTR != 0x00000002); + BUILD_BUG_ON(FIEMAP_FLAG_DEVICE_ORDER != 0x40000000); /* Checks for struct fiemap_extent */ LASSERTF((int)sizeof(struct fiemap_extent) == 56, "found %lld\n", @@ -3768,18 +3768,18 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct fiemap_extent, fe_reserved[0])); LASSERTF((int)sizeof(((struct fiemap_extent *)0)->fe_reserved[0]) == 4, "found %lld\n", (long long)(int)sizeof(((struct fiemap_extent *)0)->fe_reserved[0])); - CLASSERT(FIEMAP_EXTENT_LAST == 0x00000001); - CLASSERT(FIEMAP_EXTENT_UNKNOWN == 0x00000002); - CLASSERT(FIEMAP_EXTENT_DELALLOC == 0x00000004); - CLASSERT(FIEMAP_EXTENT_ENCODED == 0x00000008); - CLASSERT(FIEMAP_EXTENT_DATA_ENCRYPTED == 0x00000080); - CLASSERT(FIEMAP_EXTENT_NOT_ALIGNED == 0x00000100); - CLASSERT(FIEMAP_EXTENT_DATA_INLINE == 0x00000200); - CLASSERT(FIEMAP_EXTENT_DATA_TAIL == 0x00000400); - CLASSERT(FIEMAP_EXTENT_UNWRITTEN == 0x00000800); - CLASSERT(FIEMAP_EXTENT_MERGED == 0x00001000); - CLASSERT(FIEMAP_EXTENT_NO_DIRECT == 0x40000000); - CLASSERT(FIEMAP_EXTENT_NET == 0x80000000); + BUILD_BUG_ON(FIEMAP_EXTENT_LAST != 0x00000001); + BUILD_BUG_ON(FIEMAP_EXTENT_UNKNOWN != 0x00000002); + BUILD_BUG_ON(FIEMAP_EXTENT_DELALLOC != 0x00000004); + BUILD_BUG_ON(FIEMAP_EXTENT_ENCODED != 0x00000008); + BUILD_BUG_ON(FIEMAP_EXTENT_DATA_ENCRYPTED != 0x00000080); + BUILD_BUG_ON(FIEMAP_EXTENT_NOT_ALIGNED != 0x00000100); + BUILD_BUG_ON(FIEMAP_EXTENT_DATA_INLINE != 0x00000200); + BUILD_BUG_ON(FIEMAP_EXTENT_DATA_TAIL != 0x00000400); + BUILD_BUG_ON(FIEMAP_EXTENT_UNWRITTEN != 0x00000800); + BUILD_BUG_ON(FIEMAP_EXTENT_MERGED != 0x00001000); + BUILD_BUG_ON(FIEMAP_EXTENT_NO_DIRECT != 0x40000000); + BUILD_BUG_ON(FIEMAP_EXTENT_NET != 0x80000000); /* Checks for type posix_acl_xattr_entry */ LASSERTF((int)sizeof(struct posix_acl_xattr_entry) == 8, "found %lld\n", @@ -3828,7 +3828,7 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct link_ea_header, padding2)); LASSERTF((int)sizeof(((struct link_ea_header *)0)->padding2) == 4, "found %lld\n", (long long)(int)sizeof(((struct link_ea_header *)0)->padding2)); - CLASSERT(LINK_EA_MAGIC == 0x11EAF1DFUL); + BUILD_BUG_ON(LINK_EA_MAGIC != 0x11EAF1DFUL); /* Checks for struct link_ea_entry */ LASSERTF((int)sizeof(struct link_ea_entry) == 18, "found %lld\n", -- 2.9.0 From jack at suse.cz Thu Feb 2 14:48:17 2017 From: jack at suse.cz (Jan Kara) Date: Thu, 2 Feb 2017 15:48:17 +0100 Subject: [lustre-devel] [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call In-Reply-To: <20170202095125.GF27291@ZenIV.linux.org.uk> References: <20170124212327.14517-1-jlayton@redhat.com> <20170125133205.21704-1-jlayton@redhat.com> <20170202095125.GF27291@ZenIV.linux.org.uk> Message-ID: <20170202144817.GB15545@quack2.suse.cz> On Thu 02-02-17 09:51:25, Al Viro wrote: > I'm massaging that code (along with a lot of RTFS); the interesting questions > related to VM side of things are > * what are the relative costs of doing small vs. large batches? Some > of get_user_pages_fast() instances have comments along the lines of "we ought > to limit the batch size, but then nobody's doing more than 64 pages at a time > anyway". Well, I believe it's only about the cost of setting up page table walk and walking down those several levels of page tables. It is cheaper to copy several PTE entries from the leaf level than doing the full walk every time. But I didn't ever profile it to get actual numbers. Large batches are only a problem because of possible soft-lockups and irq latencies AFAIK. So the batch just should not be insanely large... > * Not a question: any ->fault() that returns VM_FAULT_RETRY when > *not* passed FAULT_FLAG_ALLOW_RETRY in flags ought to be shot. cxlflash one > sure as hell is. Yep. > * drivers/gpu/drm/vgem/vgem_drv.c:vgem_gem_fault() is bloody odd - > shmem_read_mapping_page() can't return -EBUSY, AFAICS. vm_insert_page() > used to (and back then vgem_gem_fault() used to be broken), but these days > it looks like dead code... Looks like that. > * ->page_mkwrite() instances sometimes return VM_FAULT_RETRY; AFAICS, > it's only (ab)used there as 'not zero, but doesn't contain any error bits'; > VM_FAULT_RETRY from that source does *not* reach handle_mm_fault() callers, > right? I can see only Lustre doing it and IMHO it is abuse. VM_FAULT_RETRY is used for mmap_sem latency reduction when paging in pages and so not everybody handles it. If a handler wants to simply retry the fault, returning VM_FAULT_NOPAGE is a more common way to do that... Honza -- Jan Kara SUSE Labs, CR From bevans at cray.com Thu Feb 2 15:20:29 2017 From: bevans at cray.com (Ben Evans) Date: Thu, 2 Feb 2017 15:20:29 +0000 Subject: [lustre-devel] Proposal for JobID caching In-Reply-To: References: <6E2CFE03-A158-4D82-82BA-AF0A175AA358@intel.com> <9BEFFD88-0537-43AB-8352-6477F30906DA@intel.com> Message-ID: https://review.whamcloud.com/#/c/25208/ is a working version of what I had proposed, including the suggested changes to default to procname_uid. This is not perfect, but the performance is much improved over the current methods, and unlike inode-based caching Metadata performance isn't negatively affected. Multiple simultaneous jobs can be run on the same file, and get appropriate metrics. -Ben On 1/20/17, 5:00 PM, "Ben Evans" wrote: > > >On 1/20/17, 4:50 PM, "Dilger, Andreas" wrote: > >>On Jan 18, 2017, at 13:39, Oleg Drokin wrote: >>> >>> >>> On Jan 18, 2017, at 3:08 PM, Ben Evans wrote: >>> >>>> Overview >>>> The Lustre filesystem added the ability to track I/O >>>>performance of a job across a cluster. The initial algorithm was >>>>relatively simplistic: for every I/O, look up the job ID of the >>>>process and include it in the RPC being sent to the server. This >>>>imposed a non-trivial performance impact on client I/O performance. >>>> An additional algorithm was introduced to handle the single >>>>job per node case, where instead of looking up the job ID of the >>>>process, Lustre simply accesses the value of a variable set through the >>>>proc interface. This improved performance greatly, but only functions >>>>when a single job is being run. >>>> A new approach is needed for multiple job per node systems. >>>> >>>> Proposed Solution >>>> The proposed solution to this is to create a small >>>>PID->JobID table in kernel memory. When a process performs an IO, a >>>>lookup is done in the table for the PID, if a JobID exists for that >>>>PID, it is used, otherwise it is retrieved via the same methods as the >>>>original Jobstats algorithm. Once located the JobID is stored in a >>>>PID/JobID table in memory. The existing cfs_hash_table structure and >>>>functions will be used to implement the table. >>>> >>>> Rationale >>>> This reduces the number of calls into userspace, minimizing >>>>the time taken on each I/O. It also easily supports multiple job per >>>>node scenarios, and like other proposed solutions has no issue with >>>>multiple jobs performing I/O on the same file at the same time. >>>> >>>> Requirements >>>> · Performance cannot significantly detract from baseline >>>>performance without jobstats >>>> · Supports multiple jobs per node >>>> · Coordination with the scheduler is not required, but interfaces >>>>may be provided >>>> · Supports multiple PIDs per job >>>> >>>> New Data Structures >>>> pid_to_jobid { >>>> struct hlist_node pj_hash; >>>> u54 pj_pid; >>>> char pj_jobid[LUSTRE_JOBID_SIZE]; >>>> spinlock_t jp_lock; >>>> time_t jp_time; >>>> } >>>> Proc Variables >>>> Writing to /proc/fs/lustre/jobid_name while not in ³nodelocal² mode >>>>will cause all entries in the cache for that jobID to be removed from >>>>the cache >>>> >>>> Populating the Cache >>>> When lustre_get_jobid is called, the process, and in the >>>>cached mode, first a check will be done in the cache for a valid PID to >>>>JobID mapping. If none exists, it uses the same mechanisms to get the >>>>JobID and populates the appropriate PID to JobID map. >>>> If a lookup is performed and the PID to JobID mapping exists, but is >>>>more than 30 seconds old, the JobID is refreshed. >>>> Purging the Cache >>>> The cache can be purged of a specific job by writing the >>>>JobID to the jobid_name proc file. Any items in the cache that are >>>>more than 300 seconds out of date will also be purged at this time. >>> >>> >>> I'd much rather prefer you go to the table that's populated outside of >>>the kernel >>> somehow. >>> Let's be realistic, poking around in userspace process environments for >>>random >>> strings is not such a great idea at all even though it did look like a >>>good idea >>> in the past for simplicity reasons. >>> Similar to nodelocal, we probably just switch to a method where you >>>call a >>> particular lctl command that would mark the whole session as belonging >>> to some job. This might take several forms, e.g. nodelocal itself could >>> be extended to only apply to a current namespace/container >>> But if you do really run different jobs in the global namespace, we >>>probably can >>> probably just make the lctl to spawn a shell with commands that all >>>would >>> be marked as a particular job? Or we can probably trace the parent of >>>lctl and >>> mark that so that all its children become somehow marked too. >> >>Having lctl spawn a shell or requiring everything to run in a container >>is impractical for users, and will just make it harder to use JobID, >>IMHO. The job scheduler is _already_ storing the JobID in the process >>environment so that it is available to all of the threads running as part >>of the job. The question is how the job prolog script can communicate >>the JobID directly to Lustre without using a global /proc file? Doing an >>upcall to userspace per JobID lookup is going to be *worse* for >>performance than the current searching through the process environment. >> >>I'm not against Ben's proposal to implement a cache in the kernel for >>different processes. It is unfortunate that we can't have proper >>thread-local storage for Lustre, so a hash table is probably reasonable >>for this (there may be thousands of threads involved). I don't think the >>cl_env struct would be useful, since it is not tied to a specific thread >>(AFAIK), but rather assigned as different threads enter/exit kernel >>context. Note that we already have similar time-limited caches for the >>identity upcall and FMD (lustre/ofd/ofd_fmd.c), so it may be useful to >>see whether the code can be shared. > >I'll take a look at those, but implementing the hash table was a pretty >simple solution, I need to work out a few kinks with memory leaks before >doing real performance tests on it to make sure it performs similarly to >nodelocal. > >>Another (not very nice) option to avoid looking through the environment >>variables (which IMHO isn't so bad, even though the upstream folks don't >>like it) is to associate the JobID set via /proc with a process group >>internally and look the PGID up in the kernel to find the JobID. That >>can be repeated each time a new JobID is set via /proc, since the PGID >>would stick around for each new job/shell/process created under the PGID. >> It won't be as robust as looking up the JobID in the environment, but >>probably good enough for most uses. >> >>I would definitely also be in favor of having some way to fall back to >>procname_uid if the PGID cannot be found, the job environment variable is >>not available, and there is nothing in nodelocal. > >That's simple enough. > From jack at suse.cz Thu Feb 2 17:34:04 2017 From: jack at suse.cz (Jan Kara) Date: Thu, 2 Feb 2017 18:34:04 +0100 Subject: [lustre-devel] [PATCH 06/24] lustre: Convert to separately allocated bdi In-Reply-To: <20170202173422.3240-1-jack@suse.cz> References: <20170202173422.3240-1-jack@suse.cz> Message-ID: <20170202173422.3240-7-jack@suse.cz> Allocate struct backing_dev_info separately instead of embedding it inside superblock. This unifies handling of bdi among users. CC: Oleg Drokin CC: Andreas Dilger CC: James Simmons CC: lustre-devel at lists.lustre.org Signed-off-by: Jan Kara --- .../staging/lustre/lustre/include/lustre_disk.h | 4 ---- drivers/staging/lustre/lustre/llite/llite_lib.c | 24 +++------------------- 2 files changed, 3 insertions(+), 25 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_disk.h b/drivers/staging/lustre/lustre/include/lustre_disk.h index 8886458748c1..a676bccabd43 100644 --- a/drivers/staging/lustre/lustre/include/lustre_disk.h +++ b/drivers/staging/lustre/lustre/include/lustre_disk.h @@ -133,13 +133,9 @@ struct lustre_sb_info { struct obd_export *lsi_osd_exp; char lsi_osd_type[16]; char lsi_fstype[16]; - struct backing_dev_info lsi_bdi; /* each client mountpoint needs - * own backing_dev_info - */ }; #define LSI_UMOUNT_FAILOVER 0x00200000 -#define LSI_BDI_INITIALIZED 0x00400000 #define s2lsi(sb) ((struct lustre_sb_info *)((sb)->s_fs_info)) #define s2lsi_nocast(sb) ((sb)->s_fs_info) diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 25f5aed97f63..4f07d2e60d40 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -861,15 +861,6 @@ void ll_lli_init(struct ll_inode_info *lli) mutex_init(&lli->lli_layout_mutex); } -static inline int ll_bdi_register(struct backing_dev_info *bdi) -{ - static atomic_t ll_bdi_num = ATOMIC_INIT(0); - - bdi->name = "lustre"; - return bdi_register(bdi, NULL, "lustre-%d", - atomic_inc_return(&ll_bdi_num)); -} - int ll_fill_super(struct super_block *sb, struct vfsmount *mnt) { struct lustre_profile *lprof = NULL; @@ -879,6 +870,7 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt) char *profilenm = get_profile_name(sb); struct config_llog_instance *cfg; int err; + static atomic_t ll_bdi_num = ATOMIC_INIT(0); CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb); @@ -901,16 +893,11 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt) if (err) goto out_free; - err = bdi_init(&lsi->lsi_bdi); - if (err) - goto out_free; - lsi->lsi_flags |= LSI_BDI_INITIALIZED; - lsi->lsi_bdi.capabilities = 0; - err = ll_bdi_register(&lsi->lsi_bdi); + err = super_setup_bdi_name(sb, "lustre-%d", + atomic_inc_return(&ll_bdi_num)); if (err) goto out_free; - sb->s_bdi = &lsi->lsi_bdi; /* kernel >= 2.6.38 store dentry operations in sb->s_d_op. */ sb->s_d_op = &ll_d_ops; @@ -1031,11 +1018,6 @@ void ll_put_super(struct super_block *sb) if (profilenm) class_del_profile(profilenm); - if (lsi->lsi_flags & LSI_BDI_INITIALIZED) { - bdi_destroy(&lsi->lsi_bdi); - lsi->lsi_flags &= ~LSI_BDI_INITIALIZED; - } - ll_free_sbi(sb); lsi->lsi_llsbi = NULL; -- 2.10.2 From jack at suse.cz Thu Feb 2 17:34:02 2017 From: jack at suse.cz (Jan Kara) Date: Thu, 2 Feb 2017 18:34:02 +0100 Subject: [lustre-devel] [PATCH 04/24] fs: Provide infrastructure for dynamic BDIs in filesystems In-Reply-To: <20170202173422.3240-1-jack@suse.cz> References: <20170202173422.3240-1-jack@suse.cz> Message-ID: <20170202173422.3240-5-jack@suse.cz> Provide helper functions for setting up dynamically allocated backing_dev_info structures for filesystems and cleaning them up on superblock destruction. CC: linux-mtd at lists.infradead.org CC: linux-nfs at vger.kernel.org CC: Petr Vandrovec CC: linux-nilfs at vger.kernel.org CC: cluster-devel at redhat.com CC: osd-dev at open-osd.org CC: codalist at coda.cs.cmu.edu CC: linux-afs at lists.infradead.org CC: ecryptfs at vger.kernel.org CC: linux-cifs at vger.kernel.org CC: ceph-devel at vger.kernel.org CC: linux-btrfs at vger.kernel.org CC: v9fs-developer at lists.sourceforge.net CC: lustre-devel at lists.lustre.org Signed-off-by: Jan Kara --- fs/super.c | 49 ++++++++++++++++++++++++++++++++++++++++ include/linux/backing-dev-defs.h | 2 +- include/linux/fs.h | 6 +++++ 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/fs/super.c b/fs/super.c index ea662b0e5e78..31dc4c6450ef 100644 --- a/fs/super.c +++ b/fs/super.c @@ -446,6 +446,11 @@ void generic_shutdown_super(struct super_block *sb) hlist_del_init(&sb->s_instances); spin_unlock(&sb_lock); up_write(&sb->s_umount); + if (sb->s_iflags & SB_I_DYNBDI) { + bdi_put(sb->s_bdi); + sb->s_bdi = &noop_backing_dev_info; + sb->s_iflags &= ~SB_I_DYNBDI; + } } EXPORT_SYMBOL(generic_shutdown_super); @@ -1249,6 +1254,50 @@ mount_fs(struct file_system_type *type, int flags, const char *name, void *data) } /* + * Setup private BDI for given superblock. I gets automatically cleaned up + * in generic_shutdown_super(). + */ +int super_setup_bdi_name(struct super_block *sb, char *fmt, ...) +{ + struct backing_dev_info *bdi; + int err; + va_list args; + + bdi = bdi_alloc(GFP_KERNEL); + if (!bdi) + return -ENOMEM; + + bdi->name = sb->s_type->name; + + va_start(args, fmt); + err = bdi_register_va(bdi, NULL, fmt, args); + va_end(args); + if (err) { + bdi_put(bdi); + return err; + } + WARN_ON(sb->s_bdi != &noop_backing_dev_info); + sb->s_bdi = bdi; + sb->s_iflags |= SB_I_DYNBDI; + + return 0; +} +EXPORT_SYMBOL(super_setup_bdi_name); + +/* + * Setup private BDI for given superblock. I gets automatically cleaned up + * in generic_shutdown_super(). + */ +int super_setup_bdi(struct super_block *sb) +{ + static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0); + + return super_setup_bdi_name(sb, "%.28s-%ld", sb->s_type->name, + atomic_long_inc_return(&bdi_seq)); +} +EXPORT_SYMBOL(super_setup_bdi); + +/* * This is an internal function, please use sb_end_{write,pagefault,intwrite} * instead. */ diff --git a/include/linux/backing-dev-defs.h b/include/linux/backing-dev-defs.h index 2ecafc8a2d06..70080b4217f4 100644 --- a/include/linux/backing-dev-defs.h +++ b/include/linux/backing-dev-defs.h @@ -143,7 +143,7 @@ struct backing_dev_info { congested_fn *congested_fn; /* Function pointer if device is md/dm */ void *congested_data; /* Pointer to aux data for congested func */ - char *name; + const char *name; struct kref refcnt; /* Reference counter for the structure */ unsigned int registered:1; /* Is bdi registered? */ diff --git a/include/linux/fs.h b/include/linux/fs.h index c930cbc19342..8ed8b6d1bc54 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1267,6 +1267,9 @@ struct mm_struct; /* sb->s_iflags to limit user namespace mounts */ #define SB_I_USERNS_VISIBLE 0x00000010 /* fstype already mounted */ +/* Temporary flag until all filesystems are converted to dynamic bdis */ +#define SB_I_DYNBDI 0x00000100 + /* Possible states of 'frozen' field */ enum { SB_UNFROZEN = 0, /* FS is unfrozen */ @@ -2103,6 +2106,9 @@ extern int vfs_ustat(dev_t, struct kstatfs *); extern int freeze_super(struct super_block *super); extern int thaw_super(struct super_block *super); extern bool our_mnt(struct vfsmount *mnt); +extern __printf(2, 3) +int super_setup_bdi_name(struct super_block *sb, char *fmt, ...); +extern int super_setup_bdi(struct super_block *sb); extern int current_umask(void); -- 2.10.2 From jack at suse.cz Thu Feb 2 17:33:58 2017 From: jack at suse.cz (Jan Kara) Date: Thu, 2 Feb 2017 18:33:58 +0100 Subject: [lustre-devel] [PATCH 0/24 RFC] fs: Convert all embedded bdis into separate ones Message-ID: <20170202173422.3240-1-jack@suse.cz> Hello, this patch series converts all embedded occurences of struct backing_dev_info to use standalone dynamically allocated structures. This makes bdi handling unified across all bdi users and generally removes some boilerplate code from filesystems setting up their own bdi. It also allows us to remove some code from generic bdi implementation. The patches were only compile-tested for most filesystems (I've tested mounting only for NFS & btrfs) so fs maintainers please have a look whether the changes look sound to you. This series is based on top of bdi fixes that were merged into linux-block git tree. Honza From viro at ZenIV.linux.org.uk Thu Feb 2 18:28:02 2017 From: viro at ZenIV.linux.org.uk (Al Viro) Date: Thu, 2 Feb 2017 18:28:02 +0000 Subject: [lustre-devel] [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call In-Reply-To: <20170202144817.GB15545@quack2.suse.cz> References: <20170124212327.14517-1-jlayton@redhat.com> <20170125133205.21704-1-jlayton@redhat.com> <20170202095125.GF27291@ZenIV.linux.org.uk> <20170202144817.GB15545@quack2.suse.cz> Message-ID: <20170202182802.GH27291@ZenIV.linux.org.uk> On Thu, Feb 02, 2017 at 03:48:17PM +0100, Jan Kara wrote: > > * ->page_mkwrite() instances sometimes return VM_FAULT_RETRY; AFAICS, > > it's only (ab)used there as 'not zero, but doesn't contain any error bits'; > > VM_FAULT_RETRY from that source does *not* reach handle_mm_fault() callers, > > right? > > I can see only Lustre doing it and IMHO it is abuse. VM_FAULT_RETRY is used > for mmap_sem latency reduction when paging in pages and so not everybody > handles it. If a handler wants to simply retry the fault, returning > VM_FAULT_NOPAGE is a more common way to do that... /* Convert errno to return value from ->page_mkwrite() call */ static inline int block_page_mkwrite_return(int err) { if (err == 0) return VM_FAULT_LOCKED; if (err == -EFAULT) return VM_FAULT_NOPAGE; if (err == -ENOMEM) return VM_FAULT_OOM; if (err == -EAGAIN) return VM_FAULT_RETRY; /* -ENOSPC, -EDQUOT, -EIO ... */ return VM_FAULT_SIGBUS; } and a bunch of ->page_mkwrite() instances using that. However, the only callers of ->page_mkwrite() are wp_page_shared()->do_page_mkwrite() and do_shared_fault()->do_page_mkwrite(). do_page_mkwrite() treates VM_FAULT_RETRY as "lock page and return VM_FAULT_RETRY|VM_FAULT_LOCKED". Both callers do the same check - if (unlikely(!tmp || (tmp & (VM_FAULT_ERROR | VM_FAULT_NOPAGE)))) { and the return value if that predicate is false. FWIW, use of VM_FAULT_RETRY comes from your patch back in 2011 and AFAICS the same analysis used to apply back then, except for the open-coded method calls where we use do_page_mkwrite() these days... From andreas.dilger at intel.com Fri Feb 3 01:00:02 2017 From: andreas.dilger at intel.com (Dilger, Andreas) Date: Fri, 3 Feb 2017 01:00:02 +0000 Subject: [lustre-devel] [PATCH] staging: lustre: remove CLASSERT macro In-Reply-To: <20170202113209.612528-1-arnd@arndb.de> References: <20170202113209.612528-1-arnd@arndb.de> Message-ID: On Feb 2, 2017, at 04:26, Arnd Bergmann wrote: > > lustre uses a fake switch() statement as a compile-time assert, but unfortunately > each use of that causes a warning when building with clang: > > drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c:2907:2: warning: no case matching constant switch condition '42' > drivers/staging/lustre/lnet/klnds/socklnd/../../../include/linux/libcfs/libcfs_private.h:294:36: note: expanded from macro 'CLASSERT' > #define CLASSERT(cond) do {switch (42) {case (cond): case 0: break; } } while (0) > > As Greg suggested, let's just kill off this macro completely instead of > fixing it. This replaces it with BUILD_BUG_ON(), which means we have > to negate all the conditions in the process. > > Signed-off-by: Arnd Bergmann I appreciate that you also fixed the comments where needed. Reviewed-by: Andreas Dilger Cheers, Andreas > --- > .../lustre/include/linux/libcfs/libcfs_private.h | 16 -- > .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 16 +- > .../staging/lustre/lnet/klnds/socklnd/socklnd.c | 4 +- > .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 2 +- > .../lustre/lnet/klnds/socklnd/socklnd_proto.c | 2 +- > drivers/staging/lustre/lnet/libcfs/hash.c | 2 +- > drivers/staging/lustre/lnet/lnet/acceptor.c | 4 +- > drivers/staging/lustre/lnet/lnet/api-ni.c | 134 +++++++------- > drivers/staging/lustre/lnet/lnet/lib-socket.c | 2 +- > drivers/staging/lustre/lnet/lnet/net_fault.c | 8 +- > drivers/staging/lustre/lnet/lnet/router_proc.c | 4 +- > drivers/staging/lustre/lustre/include/cl_object.h | 2 +- > drivers/staging/lustre/lustre/include/lu_object.h | 2 +- > drivers/staging/lustre/lustre/include/lustre_net.h | 4 +- > drivers/staging/lustre/lustre/ldlm/ldlm_request.c | 2 +- > drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 2 +- > drivers/staging/lustre/lustre/llite/super25.c | 2 +- > drivers/staging/lustre/lustre/llite/vvp_dev.c | 2 +- > drivers/staging/lustre/lustre/lov/lov_pack.c | 6 +- > drivers/staging/lustre/lustre/mdc/mdc_lib.c | 12 +- > drivers/staging/lustre/lustre/mdc/mdc_locks.c | 2 +- > drivers/staging/lustre/lustre/mdc/mdc_request.c | 2 +- > drivers/staging/lustre/lustre/osc/osc_io.c | 2 +- > drivers/staging/lustre/lustre/osc/osc_request.c | 16 +- > drivers/staging/lustre/lustre/ptlrpc/client.c | 4 +- > drivers/staging/lustre/lustre/ptlrpc/import.c | 2 +- > .../staging/lustre/lustre/ptlrpc/pack_generic.c | 102 +++++------ > drivers/staging/lustre/lustre/ptlrpc/pers.c | 2 +- > drivers/staging/lustre/lustre/ptlrpc/wiretest.c | 194 ++++++++++----------- > 29 files changed, 269 insertions(+), 285 deletions(-) > > diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h > index aab15d8112a4..2dae85798ec1 100644 > --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h > +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h > @@ -277,22 +277,6 @@ do { \ > #define CFS_ALLOC_PTR(ptr) LIBCFS_ALLOC(ptr, sizeof(*(ptr))) > #define CFS_FREE_PTR(ptr) LIBCFS_FREE(ptr, sizeof(*(ptr))) > > -/** Compile-time assertion. > - * > - * Check an invariant described by a constant expression at compile time by > - * forcing a compiler error if it does not hold. \a cond must be a constant > - * expression as defined by the ISO C Standard: > - * > - * 6.8.4.2 The switch statement > - * .... > - * [#3] The expression of each case label shall be an integer > - * constant expression and no two of the case constant > - * expressions in the same switch statement shall have the same > - * value after conversion... > - * > - */ > -#define CLASSERT(cond) do {switch (42) {case (cond): case 0: break; } } while (0) > - > /* max value for numeric network address */ > #define MAX_NUMERIC_VALUE 0xffffffff > > diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c > index 7f761b327166..b1e8508f9fc7 100644 > --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c > +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c > @@ -258,8 +258,8 @@ int kiblnd_unpack_msg(struct kib_msg *msg, int nob) > if (flip) { > /* leave magic unflipped as a clue to peer endianness */ > msg->ibm_version = version; > - CLASSERT(sizeof(msg->ibm_type) == 1); > - CLASSERT(sizeof(msg->ibm_credits) == 1); > + BUILD_BUG_ON(sizeof(msg->ibm_type) != 1); > + BUILD_BUG_ON(sizeof(msg->ibm_credits) != 1); > msg->ibm_nob = msg_nob; > __swab64s(&msg->ibm_srcnid); > __swab64s(&msg->ibm_srcstamp); > @@ -1247,10 +1247,10 @@ static void kiblnd_map_tx_pool(struct kib_tx_pool *tpo) > dev = net->ibn_dev; > > /* pre-mapped messages are not bigger than 1 page */ > - CLASSERT(IBLND_MSG_SIZE <= PAGE_SIZE); > + BUILD_BUG_ON(IBLND_MSG_SIZE > PAGE_SIZE); > > /* No fancy arithmetic when we do the buffer calculations */ > - CLASSERT(!(PAGE_SIZE % IBLND_MSG_SIZE)); > + BUILD_BUG_ON(PAGE_SIZE % IBLND_MSG_SIZE); > > tpo->tpo_hdev = kiblnd_current_hdev(dev); > > @@ -2943,7 +2943,7 @@ static int kiblnd_startup(lnet_ni_t *ni) > if (ni->ni_interfaces[0]) { > /* Use the IPoIB interface specified in 'networks=' */ > > - CLASSERT(LNET_MAX_INTERFACES > 1); > + BUILD_BUG_ON(LNET_MAX_INTERFACES <= 1); > if (ni->ni_interfaces[1]) { > CERROR("Multiple interfaces not supported\n"); > goto failed; > @@ -3020,11 +3020,11 @@ static void __exit ko2iblnd_exit(void) > > static int __init ko2iblnd_init(void) > { > - CLASSERT(sizeof(struct kib_msg) <= IBLND_MSG_SIZE); > - CLASSERT(offsetof(struct kib_msg, > + BUILD_BUG_ON(sizeof(struct kib_msg) > IBLND_MSG_SIZE); > + BUILD_BUG_ON(!offsetof(struct kib_msg, > ibm_u.get.ibgm_rd.rd_frags[IBLND_MAX_RDMA_FRAGS]) > <= IBLND_MSG_SIZE); > - CLASSERT(offsetof(struct kib_msg, > + BUILD_BUG_ON(!offsetof(struct kib_msg, > ibm_u.putack.ibpam_rd.rd_frags[IBLND_MAX_RDMA_FRAGS]) > <= IBLND_MSG_SIZE); > > diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c > index 2181c67a95e8..148db65185cb 100644 > --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c > +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c > @@ -2904,8 +2904,8 @@ static int __init ksocklnd_init(void) > int rc; > > /* check ksnr_connected/connecting field large enough */ > - CLASSERT(SOCKLND_CONN_NTYPES <= 4); > - CLASSERT(SOCKLND_CONN_ACK == SOCKLND_CONN_BULK_IN); > + BUILD_BUG_ON(SOCKLND_CONN_NTYPES > 4); > + BUILD_BUG_ON(SOCKLND_CONN_ACK != SOCKLND_CONN_BULK_IN); > > /* initialize the_ksocklnd */ > the_ksocklnd.lnd_type = SOCKLND; > diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c > index 3531e7d99349..95334a80e8b8 100644 > --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c > +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c > @@ -1658,7 +1658,7 @@ ksocknal_parse_proto_version(ksock_hello_msg_t *hello) > if (hello->kshm_magic == le32_to_cpu(LNET_PROTO_TCP_MAGIC)) { > struct lnet_magicversion *hmv = (struct lnet_magicversion *)hello; > > - CLASSERT(sizeof(struct lnet_magicversion) == > + BUILD_BUG_ON(sizeof(struct lnet_magicversion) != > offsetof(ksock_hello_msg_t, kshm_src_nid)); > > if (hmv->version_major == cpu_to_le16(KSOCK_PROTO_V1_MAJOR) && > diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c > index b36f181db08e..d367e74d46c2 100644 > --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c > +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c > @@ -464,7 +464,7 @@ ksocknal_send_hello_v1(struct ksock_conn *conn, ksock_hello_msg_t *hello) > int rc; > int i; > > - CLASSERT(sizeof(struct lnet_magicversion) == offsetof(struct lnet_hdr, src_nid)); > + BUILD_BUG_ON(sizeof(struct lnet_magicversion) != offsetof(struct lnet_hdr, src_nid)); > > LIBCFS_ALLOC(hdr, sizeof(*hdr)); > if (!hdr) { > diff --git a/drivers/staging/lustre/lnet/libcfs/hash.c b/drivers/staging/lustre/lnet/libcfs/hash.c > index c93c59d8fe6c..5c2ce2ee6fd9 100644 > --- a/drivers/staging/lustre/lnet/libcfs/hash.c > +++ b/drivers/staging/lustre/lnet/libcfs/hash.c > @@ -1000,7 +1000,7 @@ cfs_hash_create(char *name, unsigned int cur_bits, unsigned int max_bits, > struct cfs_hash *hs; > int len; > > - CLASSERT(CFS_HASH_THETA_BITS < 15); > + BUILD_BUG_ON(CFS_HASH_THETA_BITS >= 15); > > LASSERT(name); > LASSERT(ops->hs_key); > diff --git a/drivers/staging/lustre/lnet/lnet/acceptor.c b/drivers/staging/lustre/lnet/lnet/acceptor.c > index a55c6cd6ff37..d5d27e534919 100644 > --- a/drivers/staging/lustre/lnet/lnet/acceptor.c > +++ b/drivers/staging/lustre/lnet/lnet/acceptor.c > @@ -149,7 +149,7 @@ lnet_connect(struct socket **sockp, lnet_nid_t peer_nid, > int port; > int fatal; > > - CLASSERT(sizeof(cr) <= 16); /* not too big to be on the stack */ > + BUILD_BUG_ON(sizeof(cr) > 16); /* too big to be on the stack */ > > for (port = LNET_ACCEPTOR_MAX_RESERVED_PORT; > port >= LNET_ACCEPTOR_MIN_RESERVED_PORT; > @@ -164,7 +164,7 @@ lnet_connect(struct socket **sockp, lnet_nid_t peer_nid, > continue; > } > > - CLASSERT(LNET_PROTO_ACCEPTOR_VERSION == 1); > + BUILD_BUG_ON(LNET_PROTO_ACCEPTOR_VERSION != 1); > > cr.acr_magic = LNET_PROTO_ACCEPTOR_MAGIC; > cr.acr_version = LNET_PROTO_ACCEPTOR_VERSION; > diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c > index 79f8534d1056..08b38ef67784 100644 > --- a/drivers/staging/lustre/lnet/lnet/api-ni.c > +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c > @@ -180,89 +180,89 @@ static void lnet_assert_wire_constants(void) > */ > > /* Constants... */ > - CLASSERT(LNET_PROTO_TCP_MAGIC == 0xeebc0ded); > - CLASSERT(LNET_PROTO_TCP_VERSION_MAJOR == 1); > - CLASSERT(LNET_PROTO_TCP_VERSION_MINOR == 0); > - CLASSERT(LNET_MSG_ACK == 0); > - CLASSERT(LNET_MSG_PUT == 1); > - CLASSERT(LNET_MSG_GET == 2); > - CLASSERT(LNET_MSG_REPLY == 3); > - CLASSERT(LNET_MSG_HELLO == 4); > + BUILD_BUG_ON(LNET_PROTO_TCP_MAGIC != 0xeebc0ded); > + BUILD_BUG_ON(LNET_PROTO_TCP_VERSION_MAJOR != 1); > + BUILD_BUG_ON(LNET_PROTO_TCP_VERSION_MINOR != 0); > + BUILD_BUG_ON(LNET_MSG_ACK != 0); > + BUILD_BUG_ON(LNET_MSG_PUT != 1); > + BUILD_BUG_ON(LNET_MSG_GET != 2); > + BUILD_BUG_ON(LNET_MSG_REPLY != 3); > + BUILD_BUG_ON(LNET_MSG_HELLO != 4); > > /* Checks for struct ptl_handle_wire_t */ > - CLASSERT((int)sizeof(struct lnet_handle_wire) == 16); > - CLASSERT((int)offsetof(struct lnet_handle_wire, wh_interface_cookie) == 0); > - CLASSERT((int)sizeof(((struct lnet_handle_wire *)0)->wh_interface_cookie) == 8); > - CLASSERT((int)offsetof(struct lnet_handle_wire, wh_object_cookie) == 8); > - CLASSERT((int)sizeof(((struct lnet_handle_wire *)0)->wh_object_cookie) == 8); > + BUILD_BUG_ON((int)sizeof(struct lnet_handle_wire) != 16); > + BUILD_BUG_ON((int)offsetof(struct lnet_handle_wire, wh_interface_cookie) != 0); > + BUILD_BUG_ON((int)sizeof(((struct lnet_handle_wire *)0)->wh_interface_cookie) != 8); > + BUILD_BUG_ON((int)offsetof(struct lnet_handle_wire, wh_object_cookie) != 8); > + BUILD_BUG_ON((int)sizeof(((struct lnet_handle_wire *)0)->wh_object_cookie) != 8); > > /* Checks for struct struct lnet_magicversion */ > - CLASSERT((int)sizeof(struct lnet_magicversion) == 8); > - CLASSERT((int)offsetof(struct lnet_magicversion, magic) == 0); > - CLASSERT((int)sizeof(((struct lnet_magicversion *)0)->magic) == 4); > - CLASSERT((int)offsetof(struct lnet_magicversion, version_major) == 4); > - CLASSERT((int)sizeof(((struct lnet_magicversion *)0)->version_major) == 2); > - CLASSERT((int)offsetof(struct lnet_magicversion, version_minor) == 6); > - CLASSERT((int)sizeof(((struct lnet_magicversion *)0)->version_minor) == 2); > + BUILD_BUG_ON((int)sizeof(struct lnet_magicversion) != 8); > + BUILD_BUG_ON((int)offsetof(struct lnet_magicversion, magic) != 0); > + BUILD_BUG_ON((int)sizeof(((struct lnet_magicversion *)0)->magic) != 4); > + BUILD_BUG_ON((int)offsetof(struct lnet_magicversion, version_major) != 4); > + BUILD_BUG_ON((int)sizeof(((struct lnet_magicversion *)0)->version_major) != 2); > + BUILD_BUG_ON((int)offsetof(struct lnet_magicversion, version_minor) != 6); > + BUILD_BUG_ON((int)sizeof(((struct lnet_magicversion *)0)->version_minor) != 2); > > /* Checks for struct struct lnet_hdr */ > - CLASSERT((int)sizeof(struct lnet_hdr) == 72); > - CLASSERT((int)offsetof(struct lnet_hdr, dest_nid) == 0); > - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->dest_nid) == 8); > - CLASSERT((int)offsetof(struct lnet_hdr, src_nid) == 8); > - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->src_nid) == 8); > - CLASSERT((int)offsetof(struct lnet_hdr, dest_pid) == 16); > - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->dest_pid) == 4); > - CLASSERT((int)offsetof(struct lnet_hdr, src_pid) == 20); > - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->src_pid) == 4); > - CLASSERT((int)offsetof(struct lnet_hdr, type) == 24); > - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->type) == 4); > - CLASSERT((int)offsetof(struct lnet_hdr, payload_length) == 28); > - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->payload_length) == 4); > - CLASSERT((int)offsetof(struct lnet_hdr, msg) == 32); > - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->msg) == 40); > + BUILD_BUG_ON((int)sizeof(struct lnet_hdr) != 72); > + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, dest_nid) != 0); > + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->dest_nid) != 8); > + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, src_nid) != 8); > + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->src_nid) != 8); > + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, dest_pid) != 16); > + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->dest_pid) != 4); > + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, src_pid) != 20); > + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->src_pid) != 4); > + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, type) != 24); > + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->type) != 4); > + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, payload_length) != 28); > + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->payload_length) != 4); > + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg) != 32); > + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg) != 40); > > /* Ack */ > - CLASSERT((int)offsetof(struct lnet_hdr, msg.ack.dst_wmd) == 32); > - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->msg.ack.dst_wmd) == 16); > - CLASSERT((int)offsetof(struct lnet_hdr, msg.ack.match_bits) == 48); > - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->msg.ack.match_bits) == 8); > - CLASSERT((int)offsetof(struct lnet_hdr, msg.ack.mlength) == 56); > - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->msg.ack.mlength) == 4); > + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.ack.dst_wmd) != 32); > + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.ack.dst_wmd) != 16); > + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.ack.match_bits) != 48); > + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.ack.match_bits) != 8); > + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.ack.mlength) != 56); > + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.ack.mlength) != 4); > > /* Put */ > - CLASSERT((int)offsetof(struct lnet_hdr, msg.put.ack_wmd) == 32); > - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->msg.put.ack_wmd) == 16); > - CLASSERT((int)offsetof(struct lnet_hdr, msg.put.match_bits) == 48); > - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->msg.put.match_bits) == 8); > - CLASSERT((int)offsetof(struct lnet_hdr, msg.put.hdr_data) == 56); > - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->msg.put.hdr_data) == 8); > - CLASSERT((int)offsetof(struct lnet_hdr, msg.put.ptl_index) == 64); > - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->msg.put.ptl_index) == 4); > - CLASSERT((int)offsetof(struct lnet_hdr, msg.put.offset) == 68); > - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->msg.put.offset) == 4); > + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.put.ack_wmd) != 32); > + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.put.ack_wmd) != 16); > + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.put.match_bits) != 48); > + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.put.match_bits) != 8); > + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.put.hdr_data) != 56); > + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.put.hdr_data) != 8); > + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.put.ptl_index) != 64); > + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.put.ptl_index) != 4); > + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.put.offset) != 68); > + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.put.offset) != 4); > > /* Get */ > - CLASSERT((int)offsetof(struct lnet_hdr, msg.get.return_wmd) == 32); > - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->msg.get.return_wmd) == 16); > - CLASSERT((int)offsetof(struct lnet_hdr, msg.get.match_bits) == 48); > - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->msg.get.match_bits) == 8); > - CLASSERT((int)offsetof(struct lnet_hdr, msg.get.ptl_index) == 56); > - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->msg.get.ptl_index) == 4); > - CLASSERT((int)offsetof(struct lnet_hdr, msg.get.src_offset) == 60); > - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->msg.get.src_offset) == 4); > - CLASSERT((int)offsetof(struct lnet_hdr, msg.get.sink_length) == 64); > - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->msg.get.sink_length) == 4); > + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.get.return_wmd) != 32); > + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.get.return_wmd) != 16); > + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.get.match_bits) != 48); > + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.get.match_bits) != 8); > + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.get.ptl_index) != 56); > + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.get.ptl_index) != 4); > + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.get.src_offset) != 60); > + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.get.src_offset) != 4); > + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.get.sink_length) != 64); > + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.get.sink_length) != 4); > > /* Reply */ > - CLASSERT((int)offsetof(struct lnet_hdr, msg.reply.dst_wmd) == 32); > - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->msg.reply.dst_wmd) == 16); > + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.reply.dst_wmd) != 32); > + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.reply.dst_wmd) != 16); > > /* Hello */ > - CLASSERT((int)offsetof(struct lnet_hdr, msg.hello.incarnation) == 32); > - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->msg.hello.incarnation) == 8); > - CLASSERT((int)offsetof(struct lnet_hdr, msg.hello.type) == 40); > - CLASSERT((int)sizeof(((struct lnet_hdr *)0)->msg.hello.type) == 4); > + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.hello.incarnation) != 32); > + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.hello.incarnation) != 8); > + BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.hello.type) != 40); > + BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.hello.type) != 4); > } > > static lnd_t * > diff --git a/drivers/staging/lustre/lnet/lnet/lib-socket.c b/drivers/staging/lustre/lnet/lnet/lib-socket.c > index 4e6dd5149b4f..654a7b262188 100644 > --- a/drivers/staging/lustre/lnet/lnet/lib-socket.c > +++ b/drivers/staging/lustre/lnet/lnet/lib-socket.c > @@ -97,7 +97,7 @@ lnet_ipif_query(char *name, int *up, __u32 *ip, __u32 *mask) > return -EINVAL; > } > > - CLASSERT(sizeof(ifr.ifr_name) >= IFNAMSIZ); > + BUILD_BUG_ON(sizeof(ifr.ifr_name) < IFNAMSIZ); > > if (strlen(name) > sizeof(ifr.ifr_name) - 1) > return -E2BIG; > diff --git a/drivers/staging/lustre/lnet/lnet/net_fault.c b/drivers/staging/lustre/lnet/lnet/net_fault.c > index bb6e4576a119..18183cbb9859 100644 > --- a/drivers/staging/lustre/lnet/lnet/net_fault.c > +++ b/drivers/staging/lustre/lnet/lnet/net_fault.c > @@ -997,10 +997,10 @@ lnet_fault_ctl(int opc, struct libcfs_ioctl_data *data) > int > lnet_fault_init(void) > { > - CLASSERT(LNET_PUT_BIT == 1 << LNET_MSG_PUT); > - CLASSERT(LNET_ACK_BIT == 1 << LNET_MSG_ACK); > - CLASSERT(LNET_GET_BIT == 1 << LNET_MSG_GET); > - CLASSERT(LNET_REPLY_BIT == 1 << LNET_MSG_REPLY); > + BUILD_BUG_ON(LNET_PUT_BIT != 1 << LNET_MSG_PUT); > + BUILD_BUG_ON(LNET_ACK_BIT != 1 << LNET_MSG_ACK); > + BUILD_BUG_ON(LNET_GET_BIT != 1 << LNET_MSG_GET); > + BUILD_BUG_ON(LNET_REPLY_BIT != 1 << LNET_MSG_REPLY); > > mutex_init(&delay_dd.dd_mutex); > spin_lock_init(&delay_dd.dd_lock); > diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c > index 65f65a3fc901..a19e1405e3ea 100644 > --- a/drivers/staging/lustre/lnet/lnet/router_proc.c > +++ b/drivers/staging/lustre/lnet/lnet/router_proc.c > @@ -139,7 +139,7 @@ static int proc_lnet_routes(struct ctl_table *table, int write, > int ver; > int off; > > - CLASSERT(sizeof(loff_t) >= 4); > + BUILD_BUG_ON(sizeof(loff_t) < 4); > > off = LNET_PROC_HOFF_GET(*ppos); > ver = LNET_PROC_VER_GET(*ppos); > @@ -404,7 +404,7 @@ static int proc_lnet_peers(struct ctl_table *table, int write, > int rc = 0; > int len; > > - CLASSERT(LNET_PROC_HASH_BITS >= LNET_PEER_HASH_BITS); > + BUILD_BUG_ON(LNET_PROC_HASH_BITS < LNET_PEER_HASH_BITS); > LASSERT(!write); > > if (!*lenp) > diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h > index dc685610c4c4..9a91090819da 100644 > --- a/drivers/staging/lustre/lustre/include/cl_object.h > +++ b/drivers/staging/lustre/lustre/include/cl_object.h > @@ -2311,7 +2311,7 @@ struct cl_io *cl_io_top(struct cl_io *io); > do { \ > typeof(foo_io) __foo_io = (foo_io); \ > \ > - CLASSERT(offsetof(typeof(*__foo_io), base) == 0); \ > + BUILD_BUG_ON(offsetof(typeof(*__foo_io), base) != 0); \ > memset(&__foo_io->base + 1, 0, \ > sizeof(*__foo_io) - sizeof(__foo_io->base)); \ > } while (0) > diff --git a/drivers/staging/lustre/lustre/include/lu_object.h b/drivers/staging/lustre/lustre/include/lu_object.h > index 69b281252db0..f283a036a748 100644 > --- a/drivers/staging/lustre/lustre/include/lu_object.h > +++ b/drivers/staging/lustre/lustre/include/lu_object.h > @@ -1120,7 +1120,7 @@ struct lu_context_key { > { \ > type *value; \ > \ > - CLASSERT(PAGE_SIZE >= sizeof(*value)); \ > + BUILD_BUG_ON(PAGE_SIZE < sizeof(*value)); \ > \ > value = kzalloc(sizeof(*value), GFP_NOFS); \ > if (!value) \ > diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h > index 411eb0dc7f38..ef7311b4fbde 100644 > --- a/drivers/staging/lustre/lustre/include/lustre_net.h > +++ b/drivers/staging/lustre/lustre/include/lustre_net.h > @@ -315,8 +315,8 @@ struct ptlrpc_client { > union ptlrpc_async_args { > /** > * Scratchpad for passing args to completion interpreter. Users > - * cast to the struct of their choosing, and CLASSERT that this is > - * big enough. For _tons_ of context, kmalloc a struct and store > + * cast to the struct of their choosing, and BUILD_BUG_ON oversized > + * arguments. For _tons_ of context, kmalloc a struct and store > * a pointer to it here. The pointer_arg ensures this struct is at > * least big enough for that. > */ > diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c > index c1f8693f94a5..ebfda368b057 100644 > --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c > +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c > @@ -1972,7 +1972,7 @@ static int replay_one_lock(struct obd_import *imp, struct ldlm_lock *lock) > LDLM_DEBUG(lock, "replaying lock:"); > > atomic_inc(&req->rq_import->imp_replay_inflight); > - CLASSERT(sizeof(*aa) <= sizeof(req->rq_async_args)); > + BUILD_BUG_ON(sizeof(*aa) > sizeof(req->rq_async_args)); > aa = ptlrpc_req_async_args(req); > aa->lock_handle = body->lock_handle[0]; > req->rq_interpret_reply = (ptlrpc_interpterer_t)replay_lock_interpret; > diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c > index b22f5bae7201..d16f5e95ef0b 100644 > --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c > +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c > @@ -1368,7 +1368,7 @@ void ldlm_resource_dump(int level, struct ldlm_resource *res) > struct ldlm_lock *lock; > unsigned int granted = 0; > > - CLASSERT(RES_NAME_SIZE == 4); > + BUILD_BUG_ON(RES_NAME_SIZE != 4); > > if (!((libcfs_debug | D_ERROR) & level)) > return; > diff --git a/drivers/staging/lustre/lustre/llite/super25.c b/drivers/staging/lustre/lustre/llite/super25.c > index 106cd00910a7..4759802e062d 100644 > --- a/drivers/staging/lustre/lustre/llite/super25.c > +++ b/drivers/staging/lustre/lustre/llite/super25.c > @@ -88,7 +88,7 @@ static int __init lustre_init(void) > struct timespec64 ts; > int i, rc, seed[2]; > > - CLASSERT(sizeof(LUSTRE_VOLATILE_HDR) == LUSTRE_VOLATILE_HDR_LEN + 1); > + BUILD_BUG_ON(sizeof(LUSTRE_VOLATILE_HDR) != LUSTRE_VOLATILE_HDR_LEN + 1); > > /* print an address of _any_ initialized kernel symbol from this > * module, to allow debugging with gdb that doesn't support data > diff --git a/drivers/staging/lustre/lustre/llite/vvp_dev.c b/drivers/staging/lustre/lustre/llite/vvp_dev.c > index 12c129f7e4ad..3669ea77ee93 100644 > --- a/drivers/staging/lustre/lustre/llite/vvp_dev.c > +++ b/drivers/staging/lustre/lustre/llite/vvp_dev.c > @@ -391,7 +391,7 @@ struct vvp_pgcache_id { > > static void vvp_pgcache_id_unpack(loff_t pos, struct vvp_pgcache_id *id) > { > - CLASSERT(sizeof(pos) == sizeof(__u64)); > + BUILD_BUG_ON(sizeof(pos) != sizeof(__u64)); > > id->vpi_index = pos & 0xffffffff; > id->vpi_depth = (pos >> PGC_DEPTH_SHIFT) & 0xf; > diff --git a/drivers/staging/lustre/lustre/lov/lov_pack.c b/drivers/staging/lustre/lustre/lov/lov_pack.c > index 68fa2de7a6ff..2e1bd47337fd 100644 > --- a/drivers/staging/lustre/lustre/lov/lov_pack.c > +++ b/drivers/staging/lustre/lustre/lov/lov_pack.c > @@ -136,7 +136,7 @@ ssize_t lov_lsm_pack(const struct lov_stripe_md *lsm, void *buf, > lmmv1->lmm_layout_gen = cpu_to_le16(lsm->lsm_layout_gen); > > if (lsm->lsm_magic == LOV_MAGIC_V3) { > - CLASSERT(sizeof(lsm->lsm_pool_name) == > + BUILD_BUG_ON(sizeof(lsm->lsm_pool_name) != > sizeof(lmmv3->lmm_pool_name)); > strlcpy(lmmv3->lmm_pool_name, lsm->lsm_pool_name, > sizeof(lmmv3->lmm_pool_name)); > @@ -357,8 +357,8 @@ int lov_getstripe(struct lov_object *obj, struct lov_stripe_md *lsm, > > /* FIXME: Bug 1185 - copy fields properly when structs change */ > /* struct lov_user_md_v3 and struct lov_mds_md_v3 must be the same */ > - CLASSERT(sizeof(lum) == sizeof(struct lov_mds_md_v3)); > - CLASSERT(sizeof(lum.lmm_objects[0]) == sizeof(lmmk->lmm_objects[0])); > + BUILD_BUG_ON(sizeof(lum) != sizeof(struct lov_mds_md_v3)); > + BUILD_BUG_ON(sizeof(lum.lmm_objects[0]) != sizeof(lmmk->lmm_objects[0])); > > if (cpu_to_le32(LOV_MAGIC) != LOV_MAGIC && > (lmmk->lmm_magic == cpu_to_le32(LOV_MAGIC_V1) || > diff --git a/drivers/staging/lustre/lustre/mdc/mdc_lib.c b/drivers/staging/lustre/lustre/mdc/mdc_lib.c > index f35e1f9afdef..b1853ff7f8b9 100644 > --- a/drivers/staging/lustre/lustre/mdc/mdc_lib.c > +++ b/drivers/staging/lustre/lustre/mdc/mdc_lib.c > @@ -125,7 +125,7 @@ void mdc_create_pack(struct ptlrpc_request *req, struct md_op_data *op_data, > char *tmp; > __u64 flags; > > - CLASSERT(sizeof(struct mdt_rec_reint) == sizeof(struct mdt_rec_create)); > + BUILD_BUG_ON(sizeof(struct mdt_rec_reint) != sizeof(struct mdt_rec_create)); > rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT); > > rec->cr_opcode = REINT_CREATE; > @@ -189,7 +189,7 @@ void mdc_open_pack(struct ptlrpc_request *req, struct md_op_data *op_data, > char *tmp; > __u64 cr_flags; > > - CLASSERT(sizeof(struct mdt_rec_reint) == sizeof(struct mdt_rec_create)); > + BUILD_BUG_ON(sizeof(struct mdt_rec_reint) != sizeof(struct mdt_rec_create)); > rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT); > > /* XXX do something about time, uid, gid */ > @@ -313,7 +313,7 @@ void mdc_setattr_pack(struct ptlrpc_request *req, struct md_op_data *op_data, > struct mdt_rec_setattr *rec; > struct lov_user_md *lum = NULL; > > - CLASSERT(sizeof(struct mdt_rec_reint) == > + BUILD_BUG_ON(sizeof(struct mdt_rec_reint) != > sizeof(struct mdt_rec_setattr)); > rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT); > mdc_setattr_pack_rec(rec, op_data); > @@ -336,7 +336,7 @@ void mdc_unlink_pack(struct ptlrpc_request *req, struct md_op_data *op_data) > { > struct mdt_rec_unlink *rec; > > - CLASSERT(sizeof(struct mdt_rec_reint) == sizeof(struct mdt_rec_unlink)); > + BUILD_BUG_ON(sizeof(struct mdt_rec_reint) != sizeof(struct mdt_rec_unlink)); > rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT); > > rec->ul_opcode = op_data->op_cli_flags & CLI_RM_ENTRY ? > @@ -359,7 +359,7 @@ void mdc_link_pack(struct ptlrpc_request *req, struct md_op_data *op_data) > { > struct mdt_rec_link *rec; > > - CLASSERT(sizeof(struct mdt_rec_reint) == sizeof(struct mdt_rec_link)); > + BUILD_BUG_ON(sizeof(struct mdt_rec_reint) != sizeof(struct mdt_rec_link)); > rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT); > > rec->lk_opcode = REINT_LINK; > @@ -407,7 +407,7 @@ void mdc_rename_pack(struct ptlrpc_request *req, struct md_op_data *op_data, > { > struct mdt_rec_rename *rec; > > - CLASSERT(sizeof(struct mdt_rec_reint) == sizeof(struct mdt_rec_rename)); > + BUILD_BUG_ON(sizeof(struct mdt_rec_reint) != sizeof(struct mdt_rec_rename)); > rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT); > > /* XXX do something about time, uid, gid */ > diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c b/drivers/staging/lustre/lustre/mdc/mdc_locks.c > index 54ebb9952d66..41165f4536d0 100644 > --- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c > +++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c > @@ -1196,7 +1196,7 @@ int mdc_intent_getattr_async(struct obd_export *exp, > return rc; > } > > - CLASSERT(sizeof(*ga) <= sizeof(req->rq_async_args)); > + BUILD_BUG_ON(sizeof(*ga) > sizeof(req->rq_async_args)); > ga = ptlrpc_req_async_args(req); > ga->ga_exp = exp; > ga->ga_minfo = minfo; > diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c > index 2cfd913f9bc5..b0dfb6b62a44 100644 > --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c > +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c > @@ -295,7 +295,7 @@ static int mdc_xattr_common(struct obd_export *exp, > if (opcode == MDS_REINT) { > struct mdt_rec_setxattr *rec; > > - CLASSERT(sizeof(struct mdt_rec_setxattr) == > + BUILD_BUG_ON(sizeof(struct mdt_rec_setxattr) != > sizeof(struct mdt_rec_reint)); > rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT); > rec->sx_opcode = REINT_SETXATTR; > diff --git a/drivers/staging/lustre/lustre/osc/osc_io.c b/drivers/staging/lustre/lustre/osc/osc_io.c > index 9402dfc01668..9f08f0308a57 100644 > --- a/drivers/staging/lustre/lustre/osc/osc_io.c > +++ b/drivers/staging/lustre/lustre/osc/osc_io.c > @@ -699,7 +699,7 @@ static int osc_io_data_version_start(const struct lu_env *env, > > ptlrpc_request_set_replen(req); > req->rq_interpret_reply = osc_data_version_interpret; > - CLASSERT(sizeof(*dva) <= sizeof(req->rq_async_args)); > + BUILD_BUG_ON(sizeof(*dva) > sizeof(req->rq_async_args)); > dva = ptlrpc_req_async_args(req); > dva->dva_oio = oio; > > diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c > index 3efae759bdfa..f7352560bbe0 100644 > --- a/drivers/staging/lustre/lustre/osc/osc_request.c > +++ b/drivers/staging/lustre/lustre/osc/osc_request.c > @@ -251,7 +251,7 @@ int osc_setattr_async(struct obd_export *exp, struct obdo *oa, > req->rq_interpret_reply = > (ptlrpc_interpterer_t)osc_setattr_interpret; > > - CLASSERT(sizeof(*sa) <= sizeof(req->rq_async_args)); > + BUILD_BUG_ON(sizeof(*sa) > sizeof(req->rq_async_args)); > sa = ptlrpc_req_async_args(req); > sa->sa_oa = oa; > sa->sa_upcall = upcall; > @@ -349,7 +349,7 @@ int osc_punch_base(struct obd_export *exp, struct obdo *oa, > ptlrpc_request_set_replen(req); > > req->rq_interpret_reply = (ptlrpc_interpterer_t)osc_setattr_interpret; > - CLASSERT(sizeof(*sa) <= sizeof(req->rq_async_args)); > + BUILD_BUG_ON(sizeof(*sa) > sizeof(req->rq_async_args)); > sa = ptlrpc_req_async_args(req); > sa->sa_oa = oa; > sa->sa_upcall = upcall; > @@ -430,7 +430,7 @@ int osc_sync_base(struct osc_object *obj, struct obdo *oa, > ptlrpc_request_set_replen(req); > req->rq_interpret_reply = osc_sync_interpret; > > - CLASSERT(sizeof(*fa) <= sizeof(req->rq_async_args)); > + BUILD_BUG_ON(sizeof(*fa) > sizeof(req->rq_async_args)); > fa = ptlrpc_req_async_args(req); > fa->fa_obj = obj; > fa->fa_oa = oa; > @@ -1171,7 +1171,7 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli, > } > ptlrpc_request_set_replen(req); > > - CLASSERT(sizeof(*aa) <= sizeof(req->rq_async_args)); > + BUILD_BUG_ON(sizeof(*aa) > sizeof(req->rq_async_args)); > aa = ptlrpc_req_async_args(req); > aa->aa_oa = oa; > aa->aa_requested_nob = requested_nob; > @@ -1758,7 +1758,7 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, > cl_req_attr_set(env, osc2cl(obj), crattr); > lustre_msg_set_jobid(req->rq_reqmsg, crattr->cra_jobid); > > - CLASSERT(sizeof(*aa) <= sizeof(req->rq_async_args)); > + BUILD_BUG_ON(sizeof(*aa) > sizeof(req->rq_async_args)); > aa = ptlrpc_req_async_args(req); > INIT_LIST_HEAD(&aa->aa_oaps); > list_splice_init(&rpc_list, &aa->aa_oaps); > @@ -2039,7 +2039,7 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, > if (!rc) { > struct osc_enqueue_args *aa; > > - CLASSERT(sizeof(*aa) <= sizeof(req->rq_async_args)); > + BUILD_BUG_ON(sizeof(*aa) > sizeof(req->rq_async_args)); > aa = ptlrpc_req_async_args(req); > aa->oa_exp = exp; > aa->oa_mode = einfo->ei_mode; > @@ -2196,7 +2196,7 @@ static int osc_statfs_async(struct obd_export *exp, > } > > req->rq_interpret_reply = (ptlrpc_interpterer_t)osc_statfs_interpret; > - CLASSERT(sizeof(*aa) <= sizeof(req->rq_async_args)); > + BUILD_BUG_ON(sizeof(*aa) > sizeof(req->rq_async_args)); > aa = ptlrpc_req_async_args(req); > aa->aa_oi = oinfo; > > @@ -2401,7 +2401,7 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, > struct osc_brw_async_args *aa; > struct obdo *oa; > > - CLASSERT(sizeof(*aa) <= sizeof(req->rq_async_args)); > + BUILD_BUG_ON(sizeof(*aa) > sizeof(req->rq_async_args)); > aa = ptlrpc_req_async_args(req); > oa = kmem_cache_zalloc(obdo_cachep, GFP_NOFS); > if (!oa) { > diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c > index 804741362bc0..44d8eab6f5af 100644 > --- a/drivers/staging/lustre/lustre/ptlrpc/client.c > +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c > @@ -3070,7 +3070,7 @@ void ptlrpc_init_xid(void) > } > > /* Always need to be aligned to a power-of-two for multi-bulk BRW */ > - CLASSERT(((PTLRPC_BULK_OPS_COUNT - 1) & PTLRPC_BULK_OPS_COUNT) == 0); > + BUILD_BUG_ON(((PTLRPC_BULK_OPS_COUNT - 1) & PTLRPC_BULK_OPS_COUNT) != 0); > ptlrpc_last_xid &= PTLRPC_BULK_OPS_MASK; > } > > @@ -3256,7 +3256,7 @@ void *ptlrpcd_alloc_work(struct obd_import *imp, > req->rq_no_resend = 1; > req->rq_pill.rc_fmt = (void *)&worker_format; > > - CLASSERT(sizeof(*args) <= sizeof(req->rq_async_args)); > + BUILD_BUG_ON(sizeof(*args) > sizeof(req->rq_async_args)); > args = ptlrpc_req_async_args(req); > args->cb = cb; > args->cbdata = cbdata; > diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c > index e8280194001c..93e172fe9ce4 100644 > --- a/drivers/staging/lustre/lustre/ptlrpc/import.c > +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c > @@ -703,7 +703,7 @@ int ptlrpc_connect_import(struct obd_import *imp) > ptlrpc_request_set_replen(request); > request->rq_interpret_reply = ptlrpc_connect_interpret; > > - CLASSERT(sizeof(*aa) <= sizeof(request->rq_async_args)); > + BUILD_BUG_ON(sizeof(*aa) > sizeof(request->rq_async_args)); > aa = ptlrpc_req_async_args(request); > memset(aa, 0, sizeof(*aa)); > > diff --git a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c > index b1170277fd84..9456a1825918 100644 > --- a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c > +++ b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c > @@ -510,8 +510,8 @@ static int lustre_unpack_msg_v2(struct lustre_msg_v2 *m, int len) > __swab32s(&m->lm_repsize); > __swab32s(&m->lm_cksum); > __swab32s(&m->lm_flags); > - CLASSERT(offsetof(typeof(*m), lm_padding_2) != 0); > - CLASSERT(offsetof(typeof(*m), lm_padding_3) != 0); > + BUILD_BUG_ON(offsetof(typeof(*m), lm_padding_2) == 0); > + BUILD_BUG_ON(offsetof(typeof(*m), lm_padding_3) == 0); > } > > required_len = lustre_msg_hdr_size_v2(m->lm_bufcount); > @@ -1526,18 +1526,18 @@ void lustre_swab_ptlrpc_body(struct ptlrpc_body *b) > __swab64s(&b->pb_pre_versions[2]); > __swab64s(&b->pb_pre_versions[3]); > __swab64s(&b->pb_mbits); > - CLASSERT(offsetof(typeof(*b), pb_padding0) != 0); > - CLASSERT(offsetof(typeof(*b), pb_padding1) != 0); > - CLASSERT(offsetof(typeof(*b), pb_padding64_0) != 0); > - CLASSERT(offsetof(typeof(*b), pb_padding64_1) != 0); > - CLASSERT(offsetof(typeof(*b), pb_padding64_2) != 0); > + BUILD_BUG_ON(offsetof(typeof(*b), pb_padding0) == 0); > + BUILD_BUG_ON(offsetof(typeof(*b), pb_padding1) == 0); > + BUILD_BUG_ON(offsetof(typeof(*b), pb_padding64_0) == 0); > + BUILD_BUG_ON(offsetof(typeof(*b), pb_padding64_1) == 0); > + BUILD_BUG_ON(offsetof(typeof(*b), pb_padding64_2) == 0); > /* While we need to maintain compatibility between > * clients and servers without ptlrpc_body_v2 (< 2.3) > * do not swab any fields beyond pb_jobid, as we are > * using this swab function for both ptlrpc_body > * and ptlrpc_body_v2. > */ > - CLASSERT(offsetof(typeof(*b), pb_jobid) != 0); > + BUILD_BUG_ON(offsetof(typeof(*b), pb_jobid) == 0); > } > > void lustre_swab_connect(struct obd_connect_data *ocd) > @@ -1568,23 +1568,23 @@ void lustre_swab_connect(struct obd_connect_data *ocd) > __swab64s(&ocd->ocd_maxbytes); > if (ocd->ocd_connect_flags & OBD_CONNECT_MULTIMODRPCS) > __swab16s(&ocd->ocd_maxmodrpcs); > - CLASSERT(offsetof(typeof(*ocd), padding0)); > - CLASSERT(offsetof(typeof(*ocd), padding1) != 0); > + BUILD_BUG_ON(!offsetof(typeof(*ocd), padding0)); > + BUILD_BUG_ON(offsetof(typeof(*ocd), padding1) == 0); > if (ocd->ocd_connect_flags & OBD_CONNECT_FLAGS2) > __swab64s(&ocd->ocd_connect_flags2); > - CLASSERT(offsetof(typeof(*ocd), padding3) != 0); > - CLASSERT(offsetof(typeof(*ocd), padding4) != 0); > - CLASSERT(offsetof(typeof(*ocd), padding5) != 0); > - CLASSERT(offsetof(typeof(*ocd), padding6) != 0); > - CLASSERT(offsetof(typeof(*ocd), padding7) != 0); > - CLASSERT(offsetof(typeof(*ocd), padding8) != 0); > - CLASSERT(offsetof(typeof(*ocd), padding9) != 0); > - CLASSERT(offsetof(typeof(*ocd), paddingA) != 0); > - CLASSERT(offsetof(typeof(*ocd), paddingB) != 0); > - CLASSERT(offsetof(typeof(*ocd), paddingC) != 0); > - CLASSERT(offsetof(typeof(*ocd), paddingD) != 0); > - CLASSERT(offsetof(typeof(*ocd), paddingE) != 0); > - CLASSERT(offsetof(typeof(*ocd), paddingF) != 0); > + BUILD_BUG_ON(offsetof(typeof(*ocd), padding3) == 0); > + BUILD_BUG_ON(offsetof(typeof(*ocd), padding4) == 0); > + BUILD_BUG_ON(offsetof(typeof(*ocd), padding5) == 0); > + BUILD_BUG_ON(offsetof(typeof(*ocd), padding6) == 0); > + BUILD_BUG_ON(offsetof(typeof(*ocd), padding7) == 0); > + BUILD_BUG_ON(offsetof(typeof(*ocd), padding8) == 0); > + BUILD_BUG_ON(offsetof(typeof(*ocd), padding9) == 0); > + BUILD_BUG_ON(offsetof(typeof(*ocd), paddingA) == 0); > + BUILD_BUG_ON(offsetof(typeof(*ocd), paddingB) == 0); > + BUILD_BUG_ON(offsetof(typeof(*ocd), paddingC) == 0); > + BUILD_BUG_ON(offsetof(typeof(*ocd), paddingD) == 0); > + BUILD_BUG_ON(offsetof(typeof(*ocd), paddingE) == 0); > + BUILD_BUG_ON(offsetof(typeof(*ocd), paddingF) == 0); > } > > static void lustre_swab_obdo(struct obdo *o) > @@ -1614,9 +1614,9 @@ static void lustre_swab_obdo(struct obdo *o) > __swab32s(&o->o_uid_h); > __swab32s(&o->o_gid_h); > __swab64s(&o->o_data_version); > - CLASSERT(offsetof(typeof(*o), o_padding_4) != 0); > - CLASSERT(offsetof(typeof(*o), o_padding_5) != 0); > - CLASSERT(offsetof(typeof(*o), o_padding_6) != 0); > + BUILD_BUG_ON(offsetof(typeof(*o), o_padding_4) == 0); > + BUILD_BUG_ON(offsetof(typeof(*o), o_padding_5) == 0); > + BUILD_BUG_ON(offsetof(typeof(*o), o_padding_6) == 0); > } > > void lustre_swab_obd_statfs(struct obd_statfs *os) > @@ -1632,15 +1632,15 @@ void lustre_swab_obd_statfs(struct obd_statfs *os) > __swab32s(&os->os_namelen); > __swab64s(&os->os_maxbytes); > __swab32s(&os->os_state); > - CLASSERT(offsetof(typeof(*os), os_fprecreated) != 0); > - CLASSERT(offsetof(typeof(*os), os_spare2) != 0); > - CLASSERT(offsetof(typeof(*os), os_spare3) != 0); > - CLASSERT(offsetof(typeof(*os), os_spare4) != 0); > - CLASSERT(offsetof(typeof(*os), os_spare5) != 0); > - CLASSERT(offsetof(typeof(*os), os_spare6) != 0); > - CLASSERT(offsetof(typeof(*os), os_spare7) != 0); > - CLASSERT(offsetof(typeof(*os), os_spare8) != 0); > - CLASSERT(offsetof(typeof(*os), os_spare9) != 0); > + BUILD_BUG_ON(offsetof(typeof(*os), os_fprecreated) == 0); > + BUILD_BUG_ON(offsetof(typeof(*os), os_spare2) == 0); > + BUILD_BUG_ON(offsetof(typeof(*os), os_spare3) == 0); > + BUILD_BUG_ON(offsetof(typeof(*os), os_spare4) == 0); > + BUILD_BUG_ON(offsetof(typeof(*os), os_spare5) == 0); > + BUILD_BUG_ON(offsetof(typeof(*os), os_spare6) == 0); > + BUILD_BUG_ON(offsetof(typeof(*os), os_spare7) == 0); > + BUILD_BUG_ON(offsetof(typeof(*os), os_spare8) == 0); > + BUILD_BUG_ON(offsetof(typeof(*os), os_spare9) == 0); > } > > void lustre_swab_obd_ioobj(struct obd_ioobj *ioo) > @@ -1680,7 +1680,7 @@ void lustre_swab_gl_desc(union ldlm_gl_desc *desc) > __swab64s(&desc->lquota_desc.gl_hardlimit); > __swab64s(&desc->lquota_desc.gl_softlimit); > __swab64s(&desc->lquota_desc.gl_time); > - CLASSERT(offsetof(typeof(desc->lquota_desc), gl_pad2) != 0); > + BUILD_BUG_ON(offsetof(typeof(desc->lquota_desc), gl_pad2) == 0); > } > > void lustre_swab_ost_lvb_v1(struct ost_lvb_v1 *lvb) > @@ -1739,24 +1739,24 @@ void lustre_swab_mdt_body(struct mdt_body *b) > __swab32s(&b->mbo_flags); > __swab32s(&b->mbo_rdev); > __swab32s(&b->mbo_nlink); > - CLASSERT(offsetof(typeof(*b), mbo_unused2) != 0); > + BUILD_BUG_ON(offsetof(typeof(*b), mbo_unused2) == 0); > __swab32s(&b->mbo_suppgid); > __swab32s(&b->mbo_eadatasize); > __swab32s(&b->mbo_aclsize); > __swab32s(&b->mbo_max_mdsize); > - CLASSERT(offsetof(typeof(*b), mbo_unused3)); > + BUILD_BUG_ON(!offsetof(typeof(*b), mbo_unused3)); > __swab32s(&b->mbo_uid_h); > __swab32s(&b->mbo_gid_h); > - CLASSERT(offsetof(typeof(*b), mbo_padding_5) != 0); > + BUILD_BUG_ON(offsetof(typeof(*b), mbo_padding_5) == 0); > } > > void lustre_swab_mdt_ioepoch(struct mdt_ioepoch *b) > { > /* handle is opaque */ > /* mio_handle is opaque */ > - CLASSERT(offsetof(typeof(*b), mio_unused1)); > - CLASSERT(offsetof(typeof(*b), mio_unused2)); > - CLASSERT(offsetof(typeof(*b), mio_padding)); > + BUILD_BUG_ON(!offsetof(typeof(*b), mio_unused1)); > + BUILD_BUG_ON(!offsetof(typeof(*b), mio_unused2)); > + BUILD_BUG_ON(!offsetof(typeof(*b), mio_padding)); > } > > void lustre_swab_mgs_target_info(struct mgs_target_info *mti) > @@ -1769,7 +1769,7 @@ void lustre_swab_mgs_target_info(struct mgs_target_info *mti) > __swab32s(&mti->mti_flags); > __swab32s(&mti->mti_instance); > __swab32s(&mti->mti_nid_count); > - CLASSERT(sizeof(lnet_nid_t) == sizeof(__u64)); > + BUILD_BUG_ON(sizeof(lnet_nid_t) != sizeof(__u64)); > for (i = 0; i < MTI_NIDS_MAX; i++) > __swab64s(&mti->mti_nids[i]); > } > @@ -1785,13 +1785,13 @@ void lustre_swab_mgs_nidtbl_entry(struct mgs_nidtbl_entry *entry) > > /* mne_nid_(count|type) must be one byte size because we're gonna > * access it w/o swapping. */ > - CLASSERT(sizeof(entry->mne_nid_count) == sizeof(__u8)); > - CLASSERT(sizeof(entry->mne_nid_type) == sizeof(__u8)); > + BUILD_BUG_ON(sizeof(entry->mne_nid_count) != sizeof(__u8)); > + BUILD_BUG_ON(sizeof(entry->mne_nid_type) != sizeof(__u8)); > > /* remove this assertion if ipv6 is supported. */ > LASSERT(entry->mne_nid_type == 0); > for (i = 0; i < entry->mne_nid_count; i++) { > - CLASSERT(sizeof(lnet_nid_t) == sizeof(__u64)); > + BUILD_BUG_ON(sizeof(lnet_nid_t) != sizeof(__u64)); > __swab64s(&entry->u.nids[i]); > } > } > @@ -1829,7 +1829,7 @@ static void lustre_swab_obd_dqblk(struct obd_dqblk *b) > __swab64s(&b->dqb_btime); > __swab64s(&b->dqb_itime); > __swab32s(&b->dqb_valid); > - CLASSERT(offsetof(typeof(*b), dqb_padding) != 0); > + BUILD_BUG_ON(offsetof(typeof(*b), dqb_padding) == 0); > } > > void lustre_swab_obd_quotactl(struct obd_quotactl *q) > @@ -1900,7 +1900,7 @@ void lustre_swab_mdt_rec_reint (struct mdt_rec_reint *rr) > __swab32s(&rr->rr_flags_h); > __swab32s(&rr->rr_umask); > > - CLASSERT(offsetof(typeof(*rr), rr_padding_4) != 0); > + BUILD_BUG_ON(offsetof(typeof(*rr), rr_padding_4) == 0); > }; > > void lustre_swab_lov_desc(struct lov_desc *ld) > @@ -1949,7 +1949,7 @@ void lustre_swab_lmv_user_md(struct lmv_user_md *lum) > __swab32s(&lum->lum_stripe_offset); > __swab32s(&lum->lum_hash_type); > __swab32s(&lum->lum_type); > - CLASSERT(offsetof(typeof(*lum), lum_padding1)); > + BUILD_BUG_ON(!offsetof(typeof(*lum), lum_padding1)); > } > EXPORT_SYMBOL(lustre_swab_lmv_user_md); > > @@ -2038,7 +2038,7 @@ void lustre_swab_ldlm_intent(struct ldlm_intent *i) > static void lustre_swab_ldlm_resource_desc(struct ldlm_resource_desc *r) > { > __swab32s(&r->lr_type); > - CLASSERT(offsetof(typeof(*r), lr_padding) != 0); > + BUILD_BUG_ON(offsetof(typeof(*r), lr_padding) == 0); > lustre_swab_ldlm_res_id(&r->lr_name); > } > > @@ -2061,7 +2061,7 @@ void lustre_swab_ldlm_request(struct ldlm_request *rq) > void lustre_swab_ldlm_reply(struct ldlm_reply *r) > { > __swab32s(&r->lock_flags); > - CLASSERT(offsetof(typeof(*r), lock_padding) != 0); > + BUILD_BUG_ON(offsetof(typeof(*r), lock_padding) == 0); > lustre_swab_ldlm_lock_desc(&r->lock_desc); > /* lock_handle opaque */ > __swab64s(&r->lock_policy_res1); > diff --git a/drivers/staging/lustre/lustre/ptlrpc/pers.c b/drivers/staging/lustre/lustre/ptlrpc/pers.c > index 94e9fa85d774..601acb84f343 100644 > --- a/drivers/staging/lustre/lustre/ptlrpc/pers.c > +++ b/drivers/staging/lustre/lustre/ptlrpc/pers.c > @@ -45,7 +45,7 @@ void ptlrpc_fill_bulk_md(lnet_md_t *md, struct ptlrpc_bulk_desc *desc, > { > int offset = mdidx * LNET_MAX_IOV; > > - CLASSERT(PTLRPC_MAX_BRW_PAGES < LI_POISON); > + BUILD_BUG_ON(PTLRPC_MAX_BRW_PAGES >= LI_POISON); > > LASSERT(mdidx < desc->bd_md_max_brw); > LASSERT(desc->bd_iov_count <= PTLRPC_MAX_BRW_PAGES); > diff --git a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c > index a04e36cf6dd4..367f7e24e3da 100644 > --- a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c > +++ b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c > @@ -61,7 +61,7 @@ void lustre_assert_wire_constants(void) > MDS_DIR_END_OFF); > LASSERTF(DEAD_HANDLE_MAGIC == 0xdeadbeefcafebabeULL, "found 0x%.16llxULL\n", > DEAD_HANDLE_MAGIC); > - CLASSERT(MTI_NAME_MAXLEN == 64); > + BUILD_BUG_ON(MTI_NAME_MAXLEN != 64); > LASSERTF(OST_REPLY == 0, "found %lld\n", > (long long)OST_REPLY); > LASSERTF(OST_GETATTR == 1, "found %lld\n", > @@ -306,16 +306,16 @@ void lustre_assert_wire_constants(void) > (long long)LCK_MAXMODE); > LASSERTF(LCK_MODE_NUM == 8, "found %lld\n", > (long long)LCK_MODE_NUM); > - CLASSERT(LDLM_PLAIN == 10); > - CLASSERT(LDLM_EXTENT == 11); > - CLASSERT(LDLM_FLOCK == 12); > - CLASSERT(LDLM_IBITS == 13); > - CLASSERT(LDLM_MAX_TYPE == 14); > - CLASSERT(LUSTRE_RES_ID_SEQ_OFF == 0); > - CLASSERT(LUSTRE_RES_ID_VER_OID_OFF == 1); > - CLASSERT(LUSTRE_RES_ID_QUOTA_SEQ_OFF == 2); > - CLASSERT(LUSTRE_RES_ID_QUOTA_VER_OID_OFF == 3); > - CLASSERT(LUSTRE_RES_ID_HSH_OFF == 3); > + BUILD_BUG_ON(LDLM_PLAIN != 10); > + BUILD_BUG_ON(LDLM_EXTENT != 11); > + BUILD_BUG_ON(LDLM_FLOCK != 12); > + BUILD_BUG_ON(LDLM_IBITS != 13); > + BUILD_BUG_ON(LDLM_MAX_TYPE != 14); > + BUILD_BUG_ON(LUSTRE_RES_ID_SEQ_OFF != 0); > + BUILD_BUG_ON(LUSTRE_RES_ID_VER_OID_OFF != 1); > + BUILD_BUG_ON(LUSTRE_RES_ID_QUOTA_SEQ_OFF != 2); > + BUILD_BUG_ON(LUSTRE_RES_ID_QUOTA_VER_OID_OFF != 3); > + BUILD_BUG_ON(LUSTRE_RES_ID_HSH_OFF != 3); > LASSERTF(OBD_PING == 400, "found %lld\n", > (long long)OBD_PING); > LASSERTF(OBD_LOG_CANCEL == 401, "found %lld\n", > @@ -661,7 +661,7 @@ void lustre_assert_wire_constants(void) > (long long)(int)offsetof(struct ptlrpc_body_v3, pb_slv)); > LASSERTF((int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_slv) == 8, "found %lld\n", > (long long)(int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_slv)); > - CLASSERT(PTLRPC_NUM_VERSIONS == 4); > + BUILD_BUG_ON(PTLRPC_NUM_VERSIONS != 4); > LASSERTF((int)offsetof(struct ptlrpc_body_v3, pb_pre_versions) == 88, "found %lld\n", > (long long)(int)offsetof(struct ptlrpc_body_v3, pb_pre_versions)); > LASSERTF((int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_pre_versions) == 32, "found %lld\n", > @@ -682,7 +682,7 @@ void lustre_assert_wire_constants(void) > (long long)(int)offsetof(struct ptlrpc_body_v3, pb_padding64_2)); > LASSERTF((int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_padding64_2) == 8, "found %lld\n", > (long long)(int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_padding64_2)); > - CLASSERT(LUSTRE_JOBID_SIZE == 32); > + BUILD_BUG_ON(LUSTRE_JOBID_SIZE != 32); > LASSERTF((int)offsetof(struct ptlrpc_body_v3, pb_jobid) == 152, "found %lld\n", > (long long)(int)offsetof(struct ptlrpc_body_v3, pb_jobid)); > LASSERTF((int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_jobid) == 32, "found %lld\n", > @@ -1319,27 +1319,27 @@ void lustre_assert_wire_constants(void) > OBD_MD_FLGETATTRLOCK); > LASSERTF(OBD_MD_FLDATAVERSION == (0x0010000000000000ULL), "found 0x%.16llxULL\n", > OBD_MD_FLDATAVERSION); > - CLASSERT(OBD_FL_INLINEDATA == 0x00000001); > - CLASSERT(OBD_FL_OBDMDEXISTS == 0x00000002); > - CLASSERT(OBD_FL_DELORPHAN == 0x00000004); > - CLASSERT(OBD_FL_NORPC == 0x00000008); > - CLASSERT(OBD_FL_IDONLY == 0x00000010); > - CLASSERT(OBD_FL_RECREATE_OBJS == 0x00000020); > - CLASSERT(OBD_FL_DEBUG_CHECK == 0x00000040); > - CLASSERT(OBD_FL_NO_USRQUOTA == 0x00000100); > - CLASSERT(OBD_FL_NO_GRPQUOTA == 0x00000200); > - CLASSERT(OBD_FL_CREATE_CROW == 0x00000400); > - CLASSERT(OBD_FL_SRVLOCK == 0x00000800); > - CLASSERT(OBD_FL_CKSUM_CRC32 == 0x00001000); > - CLASSERT(OBD_FL_CKSUM_ADLER == 0x00002000); > - CLASSERT(OBD_FL_CKSUM_CRC32C == 0x00004000); > - CLASSERT(OBD_FL_CKSUM_RSVD2 == 0x00008000); > - CLASSERT(OBD_FL_CKSUM_RSVD3 == 0x00010000); > - CLASSERT(OBD_FL_SHRINK_GRANT == 0x00020000); > - CLASSERT(OBD_FL_MMAP == 0x00040000); > - CLASSERT(OBD_FL_RECOV_RESEND == 0x00080000); > - CLASSERT(OBD_FL_NOSPC_BLK == 0x00100000); > - CLASSERT(OBD_FL_LOCAL_MASK == 0xf0000000); > + BUILD_BUG_ON(OBD_FL_INLINEDATA != 0x00000001); > + BUILD_BUG_ON(OBD_FL_OBDMDEXISTS != 0x00000002); > + BUILD_BUG_ON(OBD_FL_DELORPHAN != 0x00000004); > + BUILD_BUG_ON(OBD_FL_NORPC != 0x00000008); > + BUILD_BUG_ON(OBD_FL_IDONLY != 0x00000010); > + BUILD_BUG_ON(OBD_FL_RECREATE_OBJS != 0x00000020); > + BUILD_BUG_ON(OBD_FL_DEBUG_CHECK != 0x00000040); > + BUILD_BUG_ON(OBD_FL_NO_USRQUOTA != 0x00000100); > + BUILD_BUG_ON(OBD_FL_NO_GRPQUOTA != 0x00000200); > + BUILD_BUG_ON(OBD_FL_CREATE_CROW != 0x00000400); > + BUILD_BUG_ON(OBD_FL_SRVLOCK != 0x00000800); > + BUILD_BUG_ON(OBD_FL_CKSUM_CRC32 != 0x00001000); > + BUILD_BUG_ON(OBD_FL_CKSUM_ADLER != 0x00002000); > + BUILD_BUG_ON(OBD_FL_CKSUM_CRC32C != 0x00004000); > + BUILD_BUG_ON(OBD_FL_CKSUM_RSVD2 != 0x00008000); > + BUILD_BUG_ON(OBD_FL_CKSUM_RSVD3 != 0x00010000); > + BUILD_BUG_ON(OBD_FL_SHRINK_GRANT != 0x00020000); > + BUILD_BUG_ON(OBD_FL_MMAP != 0x00040000); > + BUILD_BUG_ON(OBD_FL_RECOV_RESEND != 0x00080000); > + BUILD_BUG_ON(OBD_FL_NOSPC_BLK != 0x00100000); > + BUILD_BUG_ON(OBD_FL_LOCAL_MASK != 0xf0000000); > > /* Checks for struct lov_ost_data_v1 */ > LASSERTF((int)sizeof(struct lov_ost_data_v1) == 24, "found %lld\n", > @@ -1388,7 +1388,7 @@ void lustre_assert_wire_constants(void) > (long long)(int)offsetof(struct lov_mds_md_v1, lmm_objects[0])); > LASSERTF((int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_objects[0]) == 24, "found %lld\n", > (long long)(int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_objects[0])); > - CLASSERT(LOV_MAGIC_V1 == (0x0BD10000 | 0x0BD0)); > + BUILD_BUG_ON(LOV_MAGIC_V1 != (0x0BD10000 | 0x0BD0)); > > /* Checks for struct lov_mds_md_v3 */ > LASSERTF((int)sizeof(struct lov_mds_md_v3) == 48, "found %lld\n", > @@ -1417,7 +1417,7 @@ void lustre_assert_wire_constants(void) > (long long)(int)offsetof(struct lov_mds_md_v3, lmm_layout_gen)); > LASSERTF((int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_layout_gen) == 2, "found %lld\n", > (long long)(int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_layout_gen)); > - CLASSERT(LOV_MAXPOOLNAME == 15); > + BUILD_BUG_ON(LOV_MAXPOOLNAME != 15); > LASSERTF((int)offsetof(struct lov_mds_md_v3, lmm_pool_name[16]) == 48, "found %lld\n", > (long long)(int)offsetof(struct lov_mds_md_v3, lmm_pool_name[16])); > LASSERTF((int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_pool_name[16]) == 1, "found %lld\n", > @@ -1426,7 +1426,7 @@ void lustre_assert_wire_constants(void) > (long long)(int)offsetof(struct lov_mds_md_v3, lmm_objects[0])); > LASSERTF((int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_objects[0]) == 24, "found %lld\n", > (long long)(int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_objects[0])); > - CLASSERT(LOV_MAGIC_V3 == (0x0BD30000 | 0x0BD0)); > + BUILD_BUG_ON(LOV_MAGIC_V3 != (0x0BD30000 | 0x0BD0)); > LASSERTF(LOV_PATTERN_RAID0 == 0x00000001UL, "found 0x%.8xUL\n", > (unsigned int)LOV_PATTERN_RAID0); > LASSERTF(LOV_PATTERN_RAID1 == 0x00000002UL, "found 0x%.8xUL\n", > @@ -1479,11 +1479,11 @@ void lustre_assert_wire_constants(void) > (long long)(int)offsetof(struct lmv_mds_md_v1, lmv_stripe_fids[0])); > LASSERTF((int)sizeof(((struct lmv_mds_md_v1 *)0)->lmv_stripe_fids[0]) == 16, "found %lld\n", > (long long)(int)sizeof(((struct lmv_mds_md_v1 *)0)->lmv_stripe_fids[0])); > - CLASSERT(LMV_MAGIC_V1 == 0x0CD20CD0); > - CLASSERT(LMV_MAGIC_STRIPE == 0x0CD40CD0); > - CLASSERT(LMV_HASH_TYPE_MASK == 0x0000ffff); > - CLASSERT(LMV_HASH_FLAG_MIGRATION == 0x80000000); > - CLASSERT(LMV_HASH_FLAG_DEAD == 0x40000000); > + BUILD_BUG_ON(LMV_MAGIC_V1 != 0x0CD20CD0); > + BUILD_BUG_ON(LMV_MAGIC_STRIPE != 0x0CD40CD0); > + BUILD_BUG_ON(LMV_HASH_TYPE_MASK != 0x0000ffff); > + BUILD_BUG_ON(LMV_HASH_FLAG_MIGRATION != 0x80000000); > + BUILD_BUG_ON(LMV_HASH_FLAG_DEAD != 0x40000000); > > /* Checks for struct obd_statfs */ > LASSERTF((int)sizeof(struct obd_statfs) == 144, "found %lld\n", > @@ -2761,12 +2761,12 @@ void lustre_assert_wire_constants(void) > (long long)(int)offsetof(struct lov_desc, ld_uuid)); > LASSERTF((int)sizeof(((struct lov_desc *)0)->ld_uuid) == 40, "found %lld\n", > (long long)(int)sizeof(((struct lov_desc *)0)->ld_uuid)); > - CLASSERT(LOV_DESC_MAGIC == 0xB0CCDE5C); > + BUILD_BUG_ON(LOV_DESC_MAGIC != 0xB0CCDE5C); > > /* Checks for struct ldlm_res_id */ > LASSERTF((int)sizeof(struct ldlm_res_id) == 32, "found %lld\n", > (long long)(int)sizeof(struct ldlm_res_id)); > - CLASSERT(RES_NAME_SIZE == 4); > + BUILD_BUG_ON(RES_NAME_SIZE != 4); > LASSERTF((int)offsetof(struct ldlm_res_id, name[4]) == 32, "found %lld\n", > (long long)(int)offsetof(struct ldlm_res_id, name[4])); > LASSERTF((int)sizeof(((struct ldlm_res_id *)0)->name[4]) == 8, "found %lld\n", > @@ -3037,7 +3037,7 @@ void lustre_assert_wire_constants(void) > /* Checks for struct mgs_send_param */ > LASSERTF((int)sizeof(struct mgs_send_param) == 1024, "found %lld\n", > (long long)(int)sizeof(struct mgs_send_param)); > - CLASSERT(MGS_PARAM_MAXLEN == 1024); > + BUILD_BUG_ON(MGS_PARAM_MAXLEN != 1024); > LASSERTF((int)offsetof(struct mgs_send_param, mgs_param[1024]) == 1024, "found %lld\n", > (long long)(int)offsetof(struct mgs_send_param, mgs_param[1024])); > LASSERTF((int)sizeof(((struct mgs_send_param *)0)->mgs_param[1024]) == 1, "found %lld\n", > @@ -3090,16 +3090,16 @@ void lustre_assert_wire_constants(void) > (long long)(int)offsetof(struct llog_logid, lgl_ogen)); > LASSERTF((int)sizeof(((struct llog_logid *)0)->lgl_ogen) == 4, "found %lld\n", > (long long)(int)sizeof(((struct llog_logid *)0)->lgl_ogen)); > - CLASSERT(OST_SZ_REC == 274730752); > - CLASSERT(MDS_UNLINK_REC == 274801668); > - CLASSERT(MDS_UNLINK64_REC == 275325956); > - CLASSERT(MDS_SETATTR64_REC == 275325953); > - CLASSERT(OBD_CFG_REC == 274857984); > - CLASSERT(LLOG_GEN_REC == 274989056); > - CLASSERT(CHANGELOG_REC == 275120128); > - CLASSERT(CHANGELOG_USER_REC == 275185664); > - CLASSERT(LLOG_HDR_MAGIC == 275010873); > - CLASSERT(LLOG_LOGID_MAGIC == 275010875); > + BUILD_BUG_ON(OST_SZ_REC != 274730752); > + BUILD_BUG_ON(MDS_UNLINK_REC != 274801668); > + BUILD_BUG_ON(MDS_UNLINK64_REC != 275325956); > + BUILD_BUG_ON(MDS_SETATTR64_REC != 275325953); > + BUILD_BUG_ON(OBD_CFG_REC != 274857984); > + BUILD_BUG_ON(LLOG_GEN_REC != 274989056); > + BUILD_BUG_ON(CHANGELOG_REC != 275120128); > + BUILD_BUG_ON(CHANGELOG_USER_REC != 275185664); > + BUILD_BUG_ON(LLOG_HDR_MAGIC != 275010873); > + BUILD_BUG_ON(LLOG_LOGID_MAGIC != 275010875); > > /* Checks for struct llog_catid */ > LASSERTF((int)sizeof(struct llog_catid) == 32, "found %lld\n", > @@ -3519,30 +3519,30 @@ void lustre_assert_wire_constants(void) > (long long)(int)offsetof(struct llogd_body, lgd_cur_offset)); > LASSERTF((int)sizeof(((struct llogd_body *)0)->lgd_cur_offset) == 8, "found %lld\n", > (long long)(int)sizeof(((struct llogd_body *)0)->lgd_cur_offset)); > - CLASSERT(LLOG_ORIGIN_HANDLE_CREATE == 501); > - CLASSERT(LLOG_ORIGIN_HANDLE_NEXT_BLOCK == 502); > - CLASSERT(LLOG_ORIGIN_HANDLE_READ_HEADER == 503); > - CLASSERT(LLOG_ORIGIN_HANDLE_WRITE_REC == 504); > - CLASSERT(LLOG_ORIGIN_HANDLE_CLOSE == 505); > - CLASSERT(LLOG_ORIGIN_CONNECT == 506); > - CLASSERT(LLOG_CATINFO == 507); > - CLASSERT(LLOG_ORIGIN_HANDLE_PREV_BLOCK == 508); > - CLASSERT(LLOG_ORIGIN_HANDLE_DESTROY == 509); > - CLASSERT(LLOG_FIRST_OPC == 501); > - CLASSERT(LLOG_LAST_OPC == 510); > - CLASSERT(LLOG_CONFIG_ORIG_CTXT == 0); > - CLASSERT(LLOG_CONFIG_REPL_CTXT == 1); > - CLASSERT(LLOG_MDS_OST_ORIG_CTXT == 2); > - CLASSERT(LLOG_MDS_OST_REPL_CTXT == 3); > - CLASSERT(LLOG_SIZE_ORIG_CTXT == 4); > - CLASSERT(LLOG_SIZE_REPL_CTXT == 5); > - CLASSERT(LLOG_TEST_ORIG_CTXT == 8); > - CLASSERT(LLOG_TEST_REPL_CTXT == 9); > - CLASSERT(LLOG_CHANGELOG_ORIG_CTXT == 12); > - CLASSERT(LLOG_CHANGELOG_REPL_CTXT == 13); > - CLASSERT(LLOG_CHANGELOG_USER_ORIG_CTXT == 14); > - CLASSERT(LLOG_AGENT_ORIG_CTXT == 15); > - CLASSERT(LLOG_MAX_CTXTS == 16); > + BUILD_BUG_ON(LLOG_ORIGIN_HANDLE_CREATE != 501); > + BUILD_BUG_ON(LLOG_ORIGIN_HANDLE_NEXT_BLOCK != 502); > + BUILD_BUG_ON(LLOG_ORIGIN_HANDLE_READ_HEADER != 503); > + BUILD_BUG_ON(LLOG_ORIGIN_HANDLE_WRITE_REC != 504); > + BUILD_BUG_ON(LLOG_ORIGIN_HANDLE_CLOSE != 505); > + BUILD_BUG_ON(LLOG_ORIGIN_CONNECT != 506); > + BUILD_BUG_ON(LLOG_CATINFO != 507); > + BUILD_BUG_ON(LLOG_ORIGIN_HANDLE_PREV_BLOCK != 508); > + BUILD_BUG_ON(LLOG_ORIGIN_HANDLE_DESTROY != 509); > + BUILD_BUG_ON(LLOG_FIRST_OPC != 501); > + BUILD_BUG_ON(LLOG_LAST_OPC != 510); > + BUILD_BUG_ON(LLOG_CONFIG_ORIG_CTXT != 0); > + BUILD_BUG_ON(LLOG_CONFIG_REPL_CTXT != 1); > + BUILD_BUG_ON(LLOG_MDS_OST_ORIG_CTXT != 2); > + BUILD_BUG_ON(LLOG_MDS_OST_REPL_CTXT != 3); > + BUILD_BUG_ON(LLOG_SIZE_ORIG_CTXT != 4); > + BUILD_BUG_ON(LLOG_SIZE_REPL_CTXT != 5); > + BUILD_BUG_ON(LLOG_TEST_ORIG_CTXT != 8); > + BUILD_BUG_ON(LLOG_TEST_REPL_CTXT != 9); > + BUILD_BUG_ON(LLOG_CHANGELOG_ORIG_CTXT != 12); > + BUILD_BUG_ON(LLOG_CHANGELOG_REPL_CTXT != 13); > + BUILD_BUG_ON(LLOG_CHANGELOG_USER_ORIG_CTXT != 14); > + BUILD_BUG_ON(LLOG_AGENT_ORIG_CTXT != 15); > + BUILD_BUG_ON(LLOG_MAX_CTXTS != 16); > > /* Checks for struct llogd_conn_body */ > LASSERTF((int)sizeof(struct llogd_conn_body) == 40, "found %lld\n", > @@ -3659,7 +3659,7 @@ void lustre_assert_wire_constants(void) > (long long)(int)offsetof(struct lustre_capa, lc_expiry)); > LASSERTF((int)sizeof(((struct lustre_capa *)0)->lc_expiry) == 4, "found %lld\n", > (long long)(int)sizeof(((struct lustre_capa *)0)->lc_expiry)); > - CLASSERT(CAPA_HMAC_MAX_LEN == 64); > + BUILD_BUG_ON(CAPA_HMAC_MAX_LEN != 64); > LASSERTF((int)offsetof(struct lustre_capa, lc_hmac[64]) == 120, "found %lld\n", > (long long)(int)offsetof(struct lustre_capa, lc_hmac[64])); > LASSERTF((int)sizeof(((struct lustre_capa *)0)->lc_hmac[64]) == 1, "found %lld\n", > @@ -3680,7 +3680,7 @@ void lustre_assert_wire_constants(void) > (long long)(int)offsetof(struct lustre_capa_key, lk_padding)); > LASSERTF((int)sizeof(((struct lustre_capa_key *)0)->lk_padding) == 4, "found %lld\n", > (long long)(int)sizeof(((struct lustre_capa_key *)0)->lk_padding)); > - CLASSERT(CAPA_HMAC_KEY_MAX_LEN == 56); > + BUILD_BUG_ON(CAPA_HMAC_KEY_MAX_LEN != 56); > LASSERTF((int)offsetof(struct lustre_capa_key, lk_key[56]) == 72, "found %lld\n", > (long long)(int)offsetof(struct lustre_capa_key, lk_key[56])); > LASSERTF((int)sizeof(((struct lustre_capa_key *)0)->lk_key[56]) == 1, "found %lld\n", > @@ -3741,9 +3741,9 @@ void lustre_assert_wire_constants(void) > (long long)(int)offsetof(struct fiemap, fm_extents)); > LASSERTF((int)sizeof(((struct fiemap *)0)->fm_extents) == 0, "found %lld\n", > (long long)(int)sizeof(((struct fiemap *)0)->fm_extents)); > - CLASSERT(FIEMAP_FLAG_SYNC == 0x00000001); > - CLASSERT(FIEMAP_FLAG_XATTR == 0x00000002); > - CLASSERT(FIEMAP_FLAG_DEVICE_ORDER == 0x40000000); > + BUILD_BUG_ON(FIEMAP_FLAG_SYNC != 0x00000001); > + BUILD_BUG_ON(FIEMAP_FLAG_XATTR != 0x00000002); > + BUILD_BUG_ON(FIEMAP_FLAG_DEVICE_ORDER != 0x40000000); > > /* Checks for struct fiemap_extent */ > LASSERTF((int)sizeof(struct fiemap_extent) == 56, "found %lld\n", > @@ -3768,18 +3768,18 @@ void lustre_assert_wire_constants(void) > (long long)(int)offsetof(struct fiemap_extent, fe_reserved[0])); > LASSERTF((int)sizeof(((struct fiemap_extent *)0)->fe_reserved[0]) == 4, "found %lld\n", > (long long)(int)sizeof(((struct fiemap_extent *)0)->fe_reserved[0])); > - CLASSERT(FIEMAP_EXTENT_LAST == 0x00000001); > - CLASSERT(FIEMAP_EXTENT_UNKNOWN == 0x00000002); > - CLASSERT(FIEMAP_EXTENT_DELALLOC == 0x00000004); > - CLASSERT(FIEMAP_EXTENT_ENCODED == 0x00000008); > - CLASSERT(FIEMAP_EXTENT_DATA_ENCRYPTED == 0x00000080); > - CLASSERT(FIEMAP_EXTENT_NOT_ALIGNED == 0x00000100); > - CLASSERT(FIEMAP_EXTENT_DATA_INLINE == 0x00000200); > - CLASSERT(FIEMAP_EXTENT_DATA_TAIL == 0x00000400); > - CLASSERT(FIEMAP_EXTENT_UNWRITTEN == 0x00000800); > - CLASSERT(FIEMAP_EXTENT_MERGED == 0x00001000); > - CLASSERT(FIEMAP_EXTENT_NO_DIRECT == 0x40000000); > - CLASSERT(FIEMAP_EXTENT_NET == 0x80000000); > + BUILD_BUG_ON(FIEMAP_EXTENT_LAST != 0x00000001); > + BUILD_BUG_ON(FIEMAP_EXTENT_UNKNOWN != 0x00000002); > + BUILD_BUG_ON(FIEMAP_EXTENT_DELALLOC != 0x00000004); > + BUILD_BUG_ON(FIEMAP_EXTENT_ENCODED != 0x00000008); > + BUILD_BUG_ON(FIEMAP_EXTENT_DATA_ENCRYPTED != 0x00000080); > + BUILD_BUG_ON(FIEMAP_EXTENT_NOT_ALIGNED != 0x00000100); > + BUILD_BUG_ON(FIEMAP_EXTENT_DATA_INLINE != 0x00000200); > + BUILD_BUG_ON(FIEMAP_EXTENT_DATA_TAIL != 0x00000400); > + BUILD_BUG_ON(FIEMAP_EXTENT_UNWRITTEN != 0x00000800); > + BUILD_BUG_ON(FIEMAP_EXTENT_MERGED != 0x00001000); > + BUILD_BUG_ON(FIEMAP_EXTENT_NO_DIRECT != 0x40000000); > + BUILD_BUG_ON(FIEMAP_EXTENT_NET != 0x80000000); > > /* Checks for type posix_acl_xattr_entry */ > LASSERTF((int)sizeof(struct posix_acl_xattr_entry) == 8, "found %lld\n", > @@ -3828,7 +3828,7 @@ void lustre_assert_wire_constants(void) > (long long)(int)offsetof(struct link_ea_header, padding2)); > LASSERTF((int)sizeof(((struct link_ea_header *)0)->padding2) == 4, "found %lld\n", > (long long)(int)sizeof(((struct link_ea_header *)0)->padding2)); > - CLASSERT(LINK_EA_MAGIC == 0x11EAF1DFUL); > + BUILD_BUG_ON(LINK_EA_MAGIC != 0x11EAF1DFUL); > > /* Checks for struct link_ea_entry */ > LASSERTF((int)sizeof(struct link_ea_entry) == 18, "found %lld\n", > -- > 2.9.0 > Cheers, Andreas -- Andreas Dilger Lustre Principal Architect Intel Corporation From viro at ZenIV.linux.org.uk Fri Feb 3 07:29:52 2017 From: viro at ZenIV.linux.org.uk (Al Viro) Date: Fri, 3 Feb 2017 07:29:52 +0000 Subject: [lustre-devel] [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call In-Reply-To: <1486040452.2812.6.camel@redhat.com> References: <20170124212327.14517-1-jlayton@redhat.com> <20170125133205.21704-1-jlayton@redhat.com> <20170202095125.GF27291@ZenIV.linux.org.uk> <20170202105651.GA32111@infradead.org> <20170202111625.GG27291@ZenIV.linux.org.uk> <1486040452.2812.6.camel@redhat.com> Message-ID: <20170203072952.GI27291@ZenIV.linux.org.uk> On Thu, Feb 02, 2017 at 08:00:52AM -0500, Jeff Layton wrote: > > I'm not sure we need to touch any get_user_pages_fast() at all; let it > > fill a medium-sized array and use that as a buffer. In particular, > > I *really* don't like the idea of having the callbacks done in an > > inconsistent locking environment - sometimes under ->mmap_sem, sometimes > > not. > > > > Yeah, that might work. You could kmalloc the buffer array according to > the maxsize value. For small ones we could even consider using an on- > stack buffer. Yes. FWIW, I'm not proposing to kill iov_iter_get_pages{,_alloc}() immediately - the new primitive would initially use the damn thing. That can be backported without any problems, and conversions would be one-by-one. If/when we get to the point where most of the users have been switched to the new helper, we could try and see if what remains could be dealt with; if that works, it might be possible to fold iov_iter_get_pages() into it. In particular, for ITER_BVEC and ITER_PIPE we don't need to bother with any intermediate arrays at all, etc. But that's only after several cycles when everyone is asked to try and use the new primitive instead of iov_iter_get_pages(). The calling conventions of iov_iter_get_pages() are ugly and I would love to get rid of them, but doing that in a flagday conversion is a lot of PITA for no good reason. Speaking of get_user_pages() and conversions: get_user_pages() relies upon find_extend_vma() to reject kernel addresses; the fast side of get_user_pages_fast() doesn't have anything of that sort in case e.g. HAVE_GENERIC_RCU_GUP. Sure, usually we have that verified and rejected earlier anyway, but it's a fairly subtle difference that doesn't seem to be documented anywhere. For example, /dev/st* reads and writes (st_read()/st_write()) feed the address of buffer to get_user_pages_unlocked(). If somebody replaced those with get_user_pages_fast(), we'd be in trouble as soon as some code got tricked into using kernel_write() on /dev/st*. access_ok() in HAVE_GENERIC_RCU_GUP {__,}get_user_pages_fast() obviously doesn't help in that scenario. What am I missing here? From hch at infradead.org Fri Feb 3 07:49:01 2017 From: hch at infradead.org (Christoph Hellwig) Date: Thu, 2 Feb 2017 23:49:01 -0800 Subject: [lustre-devel] [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call In-Reply-To: <1486040452.2812.6.camel@redhat.com> References: <20170124212327.14517-1-jlayton@redhat.com> <20170125133205.21704-1-jlayton@redhat.com> <20170202095125.GF27291@ZenIV.linux.org.uk> <20170202105651.GA32111@infradead.org> <20170202111625.GG27291@ZenIV.linux.org.uk> <1486040452.2812.6.camel@redhat.com> Message-ID: <20170203074901.GA19808@infradead.org> On Thu, Feb 02, 2017 at 08:00:52AM -0500, Jeff Layton wrote: > Yeah, that might work. You could kmalloc the buffer array according to > the maxsize value. For small ones we could even consider using an on- > stack buffer. For the block direct I/O code we defintively want to avoid any allocations for small I/O a that shows up in the performance numbers. And we'd like to reuse the on-stack bio_vec so that the defintion of a small I/O can be as big as possible without blowing up the stack. From viro at ZenIV.linux.org.uk Fri Feb 3 08:54:15 2017 From: viro at ZenIV.linux.org.uk (Al Viro) Date: Fri, 3 Feb 2017 08:54:15 +0000 Subject: [lustre-devel] [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call In-Reply-To: <20170203074901.GA19808@infradead.org> References: <20170124212327.14517-1-jlayton@redhat.com> <20170125133205.21704-1-jlayton@redhat.com> <20170202095125.GF27291@ZenIV.linux.org.uk> <20170202105651.GA32111@infradead.org> <20170202111625.GG27291@ZenIV.linux.org.uk> <1486040452.2812.6.camel@redhat.com> <20170203074901.GA19808@infradead.org> Message-ID: <20170203085415.GJ27291@ZenIV.linux.org.uk> On Thu, Feb 02, 2017 at 11:49:01PM -0800, Christoph Hellwig wrote: > On Thu, Feb 02, 2017 at 08:00:52AM -0500, Jeff Layton wrote: > > Yeah, that might work. You could kmalloc the buffer array according to > > the maxsize value. For small ones we could even consider using an on- > > stack buffer. > > For the block direct I/O code we defintively want to avoid any > allocations for small I/O a that shows up in the performance numbers. > And we'd like to reuse the on-stack bio_vec so that the defintion of > a small I/O can be as big as possible without blowing up the stack. Hmm... Reuse part is really nasty ;-/ OTOH, it might make sense to have a "fill bio_vec array" as separate primitive - having that sucker come from bio looks like an artificial restriction. OK, next question, seeing that you've dealt with O_DIRECT guts more than I have. When we have iov_iter_get_pages() fail on do_direct_IO() write with some blocks already allocated, we pick zero page as data source. So far, so good, but: * should we bother zeroing anything unless buffer_new() is true? * why, in case of more than a page worth of pending allocated blocks, do we bother with calling iov_iter_get_pages() again and again? We *do* take care not to allocate anything else after that point, but dio_get_page() will be calling iov_iter_get_pages() every time in that case - there's only one page in queue. From gregkh at linuxfoundation.org Fri Feb 3 10:33:04 2017 From: gregkh at linuxfoundation.org (Greg Kroah-Hartman) Date: Fri, 3 Feb 2017 11:33:04 +0100 Subject: [lustre-devel] [PATCH 10/60] staging: lustre: obdclass: add more info to sysfs version string In-Reply-To: <1485648328-2141-11-git-send-email-jsimmons@infradead.org> References: <1485648328-2141-1-git-send-email-jsimmons@infradead.org> <1485648328-2141-11-git-send-email-jsimmons@infradead.org> Message-ID: <20170203103304.GA2600@kroah.com> On Sat, Jan 28, 2017 at 07:04:38PM -0500, James Simmons wrote: > From: Andreas Dilger > > Update the sysfs "version" file to print "lustre: " with > the version number. > > Signed-off-by: Andreas Dilger > Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5969 > Reviewed-on: http://review.whamcloud.com/16721 > Reviewed-by: James Simmons > Reviewed-by: Dmitry Eremin > Reviewed-by: Oleg Drokin > Signed-off-by: James Simmons > --- > drivers/staging/lustre/lustre/obdclass/linux/linux-module.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c > index 9f5e829..22e6d1f 100644 > --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c > +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c > @@ -208,7 +208,7 @@ struct miscdevice obd_psdev = { > static ssize_t version_show(struct kobject *kobj, struct attribute *attr, > char *buf) > { > - return sprintf(buf, "%s\n", LUSTRE_VERSION_STRING); > + return sprintf(buf, "lustre: %s\n", LUSTRE_VERSION_STRING); > } Why? You "know" this is lustre, why say it again? Doesn't this affect userspace tools? thanks, greg k-h From gregkh at linuxfoundation.org Fri Feb 3 10:46:30 2017 From: gregkh at linuxfoundation.org (Greg Kroah-Hartman) Date: Fri, 3 Feb 2017 11:46:30 +0100 Subject: [lustre-devel] [PATCH 00/60] staging: lustre: batches of fixes for lustre client In-Reply-To: <1485648328-2141-1-git-send-email-jsimmons@infradead.org> References: <1485648328-2141-1-git-send-email-jsimmons@infradead.org> Message-ID: <20170203104630.GA12870@kroah.com> On Sat, Jan 28, 2017 at 07:04:28PM -0500, James Simmons wrote: > Batch of missing fixes for lustre for the upstream client. I've applied most of these, please fix up the rest, rebase, and resend. thanks, greg k-h From hch at infradead.org Fri Feb 3 11:09:30 2017 From: hch at infradead.org (Christoph Hellwig) Date: Fri, 3 Feb 2017 03:09:30 -0800 Subject: [lustre-devel] [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call In-Reply-To: <20170203085415.GJ27291@ZenIV.linux.org.uk> References: <20170124212327.14517-1-jlayton@redhat.com> <20170125133205.21704-1-jlayton@redhat.com> <20170202095125.GF27291@ZenIV.linux.org.uk> <20170202105651.GA32111@infradead.org> <20170202111625.GG27291@ZenIV.linux.org.uk> <1486040452.2812.6.camel@redhat.com> <20170203074901.GA19808@infradead.org> <20170203085415.GJ27291@ZenIV.linux.org.uk> Message-ID: <20170203110930.GA22173@infradead.org> On Fri, Feb 03, 2017 at 08:54:15AM +0000, Al Viro wrote: > Hmm... Reuse part is really nasty ;-/ OTOH, it might make sense to have > a "fill bio_vec array" as separate primitive - having that sucker come > from bio looks like an artificial restriction. Or just the only usecase :) But yes, it could be generalized to take a bio_vec without too much effort. > OK, next question, seeing that you've dealt with O_DIRECT guts more than > I have. When we have iov_iter_get_pages() fail on do_direct_IO() write > with some blocks already allocated, we pick zero page as data source. > So far, so good, but: > * should we bother zeroing anything unless buffer_new() is true? I don't think so. > * why, in case of more than a page worth of pending allocated > blocks, do we bother with calling iov_iter_get_pages() again and again? > We *do* take care not to allocate anything else after that point, but > dio_get_page() will be calling iov_iter_get_pages() every time in that > case - there's only one page in queue. There shouldn't be a need for it. But take it with a grain of salt - fs/direct-io.c is a hairy mess, that's one of the reasons why I replaced it with the new iomap code instead of trying to gradually move it to iomap API. From jack at suse.cz Fri Feb 3 13:50:42 2017 From: jack at suse.cz (Jan Kara) Date: Fri, 3 Feb 2017 14:50:42 +0100 Subject: [lustre-devel] [PATCH 04/24] fs: Provide infrastructure for dynamic BDIs in filesystems In-Reply-To: <20170202192827.GF6550@localhost.localdomain> References: <20170202173422.3240-1-jack@suse.cz> <20170202173422.3240-5-jack@suse.cz> <20170202192827.GF6550@localhost.localdomain> Message-ID: <20170203135042.GB5844@quack2.suse.cz> On Thu 02-02-17 11:28:27, Liu Bo wrote: > Hi, > > On Thu, Feb 02, 2017 at 06:34:02PM +0100, Jan Kara wrote: > > Provide helper functions for setting up dynamically allocated > > backing_dev_info structures for filesystems and cleaning them up on > > superblock destruction. > > Just one concern, will this cause problems for multiple superblock cases > like nfs with nosharecache? Can you ellaborate a bit? I've looked for a while what nfs with nosharecache does but I didn't see how it would influence anything with bdis... Honza -- Jan Kara SUSE Labs, CR From jack at suse.cz Fri Feb 3 14:47:56 2017 From: jack at suse.cz (Jan Kara) Date: Fri, 3 Feb 2017 15:47:56 +0100 Subject: [lustre-devel] [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call In-Reply-To: <20170202182802.GH27291@ZenIV.linux.org.uk> References: <20170124212327.14517-1-jlayton@redhat.com> <20170125133205.21704-1-jlayton@redhat.com> <20170202095125.GF27291@ZenIV.linux.org.uk> <20170202144817.GB15545@quack2.suse.cz> <20170202182802.GH27291@ZenIV.linux.org.uk> Message-ID: <20170203144756.GC5844@quack2.suse.cz> On Thu 02-02-17 18:28:02, Al Viro wrote: > On Thu, Feb 02, 2017 at 03:48:17PM +0100, Jan Kara wrote: > > > > * ->page_mkwrite() instances sometimes return VM_FAULT_RETRY; AFAICS, > > > it's only (ab)used there as 'not zero, but doesn't contain any error bits'; > > > VM_FAULT_RETRY from that source does *not* reach handle_mm_fault() callers, > > > right? > > > > I can see only Lustre doing it and IMHO it is abuse. VM_FAULT_RETRY is used > > for mmap_sem latency reduction when paging in pages and so not everybody > > handles it. If a handler wants to simply retry the fault, returning > > VM_FAULT_NOPAGE is a more common way to do that... > > /* Convert errno to return value from ->page_mkwrite() call */ > static inline int block_page_mkwrite_return(int err) > { > if (err == 0) > return VM_FAULT_LOCKED; > if (err == -EFAULT) > return VM_FAULT_NOPAGE; > if (err == -ENOMEM) > return VM_FAULT_OOM; > if (err == -EAGAIN) > return VM_FAULT_RETRY; > /* -ENOSPC, -EDQUOT, -EIO ... */ > return VM_FAULT_SIGBUS; > } > > and a bunch of ->page_mkwrite() instances using that. However, the only > callers of ->page_mkwrite() are wp_page_shared()->do_page_mkwrite() and > do_shared_fault()->do_page_mkwrite(). do_page_mkwrite() treates > VM_FAULT_RETRY as "lock page and return VM_FAULT_RETRY|VM_FAULT_LOCKED". > Both callers do the same check - > if (unlikely(!tmp || (tmp & > (VM_FAULT_ERROR | VM_FAULT_NOPAGE)))) { > and the return value if that predicate is false. FWIW, use of VM_FAULT_RETRY > comes from your patch back in 2011 and AFAICS the same analysis used to > apply back then, except for the open-coded method calls where we use > do_page_mkwrite() these days... Yeah, back then I was not aware of VM_FAULT_RETRY limitations and your analysis above just shows that its handling from do_page_mkwrite() is simply broken (or better non-existent). Actually that VM_FAULT_RETRY return was added by fs freeze handling patch. The freeze handling was later changed but that change to block_page_mkwrite_return() remained. I'll send a patch to remove it. Thanks for spotting this. Honza -- Jan Kara SUSE Labs, CR From jack at suse.cz Fri Feb 3 15:07:29 2017 From: jack at suse.cz (Jan Kara) Date: Fri, 3 Feb 2017 16:07:29 +0100 Subject: [lustre-devel] [PATCH] mm: Avoid returning VM_FAULT_RETRY from ->page_mkwrite handlers Message-ID: <20170203150729.15863-1-jack@suse.cz> Some ->page_mkwrite handlers may return VM_FAULT_RETRY as its return code (GFS2 or Lustre can definitely do this). However VM_FAULT_RETRY from ->page_mkwrite is completely unhandled by the mm code and results in locking and writeably mapping the page which definitely is not what the caller wanted. Fix Lustre and block_page_mkwrite_ret() used by other filesystems (notably GFS2) to return VM_FAULT_NOPAGE instead which results in bailing out from the fault code, the CPU then retries the access, and we fault again effectively doing what the handler wanted. CC: lustre-devel at lists.lustre.org CC: cluster-devel at redhat.com Reported-by: Al Viro Signed-off-by: Jan Kara --- drivers/staging/lustre/lustre/llite/llite_mmap.c | 4 +--- include/linux/buffer_head.h | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_mmap.c b/drivers/staging/lustre/lustre/llite/llite_mmap.c index ee01f20d8b11..9afa6bec3e6f 100644 --- a/drivers/staging/lustre/lustre/llite/llite_mmap.c +++ b/drivers/staging/lustre/lustre/llite/llite_mmap.c @@ -390,15 +390,13 @@ static int ll_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) result = VM_FAULT_LOCKED; break; case -ENODATA: + case -EAGAIN: case -EFAULT: result = VM_FAULT_NOPAGE; break; case -ENOMEM: result = VM_FAULT_OOM; break; - case -EAGAIN: - result = VM_FAULT_RETRY; - break; default: result = VM_FAULT_SIGBUS; break; diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index d67ab83823ad..79591c3660cc 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -243,12 +243,10 @@ static inline int block_page_mkwrite_return(int err) { if (err == 0) return VM_FAULT_LOCKED; - if (err == -EFAULT) + if (err == -EFAULT || err == -EAGAIN) return VM_FAULT_NOPAGE; if (err == -ENOMEM) return VM_FAULT_OOM; - if (err == -EAGAIN) - return VM_FAULT_RETRY; /* -ENOSPC, -EDQUOT, -EIO ... */ return VM_FAULT_SIGBUS; } -- 2.10.2 From jack at suse.cz Fri Feb 3 15:46:40 2017 From: jack at suse.cz (Jan Kara) Date: Fri, 3 Feb 2017 16:46:40 +0100 Subject: [lustre-devel] [PATCH] mm: Avoid returning VM_FAULT_RETRY from ->page_mkwrite handlers In-Reply-To: <20170203151356.GB2267@bombadil.infradead.org> References: <20170203150729.15863-1-jack@suse.cz> <20170203151356.GB2267@bombadil.infradead.org> Message-ID: <20170203154640.GA25586@quack2.suse.cz> On Fri 03-02-17 07:13:59, Matthew Wilcox wrote: > On Fri, Feb 03, 2017 at 04:07:29PM +0100, Jan Kara wrote: > > Some ->page_mkwrite handlers may return VM_FAULT_RETRY as its return > > code (GFS2 or Lustre can definitely do this). However VM_FAULT_RETRY > > from ->page_mkwrite is completely unhandled by the mm code and results > > in locking and writeably mapping the page which definitely is not what > > the caller wanted. Fix Lustre and block_page_mkwrite_ret() used by other > > filesystems (notably GFS2) to return VM_FAULT_NOPAGE instead which > > results in bailing out from the fault code, the CPU then retries the > > access, and we fault again effectively doing what the handler wanted. > > Reading this commit message makes me wonder if this is the best fix. > It would seem logical that if I want the fault to be retried that I should > return VM_FAULT_RETRY, not VM_FAULT_NOPAGE. Why don't we have the MM > treat VM_FAULT_RETRY the same way that it treats VM_FAULT_NOPAGE and give > driver / filesystem writers one fewer way to shoot themselves in the foot? VM_FAULT_RETRY is special, it may be used only if FAULT_FLAG_ALLOW_RETRY was set in page fault flags and it means - we have dropped mmap_sem, we loaded page needed to satisfy the fault and now we need to try again (have a look at __lock_page_or_retry()). I have my reservations about this interface but it works... Honza -- Jan Kara SUSE Labs, CR From jack at suse.cz Fri Feb 3 16:10:05 2017 From: jack at suse.cz (Jan Kara) Date: Fri, 3 Feb 2017 17:10:05 +0100 Subject: [lustre-devel] [PATCH] mm: Avoid returning VM_FAULT_RETRY from ->page_mkwrite handlers In-Reply-To: <20170203155326.GE2267@bombadil.infradead.org> References: <20170203150729.15863-1-jack@suse.cz> <20170203151356.GB2267@bombadil.infradead.org> <20170203154640.GA25586@quack2.suse.cz> <20170203155326.GE2267@bombadil.infradead.org> Message-ID: <20170203161005.GB25586@quack2.suse.cz> On Fri 03-02-17 07:53:26, Matthew Wilcox wrote: > On Fri, Feb 03, 2017 at 04:46:40PM +0100, Jan Kara wrote: > > On Fri 03-02-17 07:13:59, Matthew Wilcox wrote: > > > On Fri, Feb 03, 2017 at 04:07:29PM +0100, Jan Kara wrote: > > > > Some ->page_mkwrite handlers may return VM_FAULT_RETRY as its return > > > > code (GFS2 or Lustre can definitely do this). However VM_FAULT_RETRY > > > > from ->page_mkwrite is completely unhandled by the mm code and results > > > > in locking and writeably mapping the page which definitely is not what > > > > the caller wanted. Fix Lustre and block_page_mkwrite_ret() used by other > > > > filesystems (notably GFS2) to return VM_FAULT_NOPAGE instead which > > > > results in bailing out from the fault code, the CPU then retries the > > > > access, and we fault again effectively doing what the handler wanted. > > > > > > Reading this commit message makes me wonder if this is the best fix. > > > It would seem logical that if I want the fault to be retried that I should > > > return VM_FAULT_RETRY, not VM_FAULT_NOPAGE. Why don't we have the MM > > > treat VM_FAULT_RETRY the same way that it treats VM_FAULT_NOPAGE and give > > > driver / filesystem writers one fewer way to shoot themselves in the foot? > > > > VM_FAULT_RETRY is special, it may be used only if FAULT_FLAG_ALLOW_RETRY > > was set in page fault flags and it means - we have dropped mmap_sem, we > > loaded page needed to satisfy the fault and now we need to try again (have > > a look at __lock_page_or_retry()). I have my reservations about this > > interface but it works... > > Oh, I understand what it's *supposed* to be used for ;-) It's just > a bit of an attractive nuisance. Maybe renaming it to something like > VM_FAULT_PAGE_RETRY would stop people from thinking that it meant "retry > the fault". And we could #define VM_FAULT_RETRY VM_FAULT_NOPAGE so that > people who want to retry the fault in a normal way could use a return > value that sounds like it does what they want instead of a return value > that is supposed to be used to indicate that we put a PFN into the > page table? So a better name for VM_FAULT_RETRY and disentangling VM_FAULT_NOPAGE so that it is not misused for retrying the fault would be nice. But it is a much larger endeavor (I actually had a look into this some time ago) than this simple bugfix... Honza -- Jan Kara SUSE Labs, CR From torvalds at linux-foundation.org Fri Feb 3 18:29:23 2017 From: torvalds at linux-foundation.org (Linus Torvalds) Date: Fri, 3 Feb 2017 10:29:23 -0800 Subject: [lustre-devel] [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call In-Reply-To: <20170203072952.GI27291@ZenIV.linux.org.uk> References: <20170124212327.14517-1-jlayton@redhat.com> <20170125133205.21704-1-jlayton@redhat.com> <20170202095125.GF27291@ZenIV.linux.org.uk> <20170202105651.GA32111@infradead.org> <20170202111625.GG27291@ZenIV.linux.org.uk> <1486040452.2812.6.camel@redhat.com> <20170203072952.GI27291@ZenIV.linux.org.uk> Message-ID: On Thu, Feb 2, 2017 at 11:29 PM, Al Viro wrote: > > get_user_pages() relies upon find_extend_vma() to reject kernel > addresses; the fast side of get_user_pages_fast() doesn't have anything > of that sort It is *supposed* to have it. See pte_allows_gup(), for example. In particular, it requires the _PAGE_USER bit in the PTE (and the devpte case should require _PAGE_BIT_DEVMAP). So no, get_user_pages_fast() can not look up kernel pages. If it does, that would be a bug. Linus From viro at ZenIV.linux.org.uk Fri Feb 3 19:08:17 2017 From: viro at ZenIV.linux.org.uk (Al Viro) Date: Fri, 3 Feb 2017 19:08:17 +0000 Subject: [lustre-devel] [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call In-Reply-To: References: <20170124212327.14517-1-jlayton@redhat.com> <20170125133205.21704-1-jlayton@redhat.com> <20170202095125.GF27291@ZenIV.linux.org.uk> <20170202105651.GA32111@infradead.org> <20170202111625.GG27291@ZenIV.linux.org.uk> <1486040452.2812.6.camel@redhat.com> <20170203072952.GI27291@ZenIV.linux.org.uk> Message-ID: <20170203190816.GK27291@ZenIV.linux.org.uk> On Fri, Feb 03, 2017 at 10:29:23AM -0800, Linus Torvalds wrote: > On Thu, Feb 2, 2017 at 11:29 PM, Al Viro wrote: > > > > get_user_pages() relies upon find_extend_vma() to reject kernel > > addresses; the fast side of get_user_pages_fast() doesn't have anything > > of that sort > > It is *supposed* to have it. > > See pte_allows_gup(), for example. In particular, it requires the > _PAGE_USER bit in the PTE (and the devpte case should require > _PAGE_BIT_DEVMAP). On x86 it does. I don't see anything equivalent in mm/gup.c one, and the only kinda-sorta similar thing (access_ok() in __get_user_pages_fast() there) is vulnerable to e.g. access via kernel_write(). The comment in there * Before activating this code, please be aware that the following assumptions * are currently made: * * *) HAVE_RCU_TABLE_FREE is enabled, and tlb_remove_table is used to free * pages containing page tables. * * *) ptes can be read atomically by the architecture. * * *) access_ok is sufficient to validate userspace address ranges. * * The last two assumptions can be relaxed by the addition of helper functions. doesn't look promising - access_ok() is never sufficient. Something like _PAGE_USER tests in x86 one solves that problem, but if anything similar works for HAVE_GENERIC_RCU_GUP I don't see it. Thus the question re what am I missing here... From torvalds at linux-foundation.org Fri Feb 3 19:28:48 2017 From: torvalds at linux-foundation.org (Linus Torvalds) Date: Fri, 3 Feb 2017 11:28:48 -0800 Subject: [lustre-devel] [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call In-Reply-To: <20170203190816.GK27291@ZenIV.linux.org.uk> References: <20170124212327.14517-1-jlayton@redhat.com> <20170125133205.21704-1-jlayton@redhat.com> <20170202095125.GF27291@ZenIV.linux.org.uk> <20170202105651.GA32111@infradead.org> <20170202111625.GG27291@ZenIV.linux.org.uk> <1486040452.2812.6.camel@redhat.com> <20170203072952.GI27291@ZenIV.linux.org.uk> <20170203190816.GK27291@ZenIV.linux.org.uk> Message-ID: On Fri, Feb 3, 2017 at 11:08 AM, Al Viro wrote: > > On x86 it does. I don't see anything equivalent in mm/gup.c one, and the > only kinda-sorta similar thing (access_ok() in __get_user_pages_fast() > there) is vulnerable to e.g. access via kernel_write(). Yeah, access_ok() is bogus. It needs to just check against TASK_SIZE or whatever. > doesn't look promising - access_ok() is never sufficient. Something like > _PAGE_USER tests in x86 one solves that problem, but if anything similar > works for HAVE_GENERIC_RCU_GUP I don't see it. Thus the question re > what am I missing here... Ok, I definitely agree that it looks like __get_user_pages_fast() just needs to get rid of the access_ok() and replace it with a proper check for the user address space range. Looks like arm[64] and powerpc.are the current users. Adding in some people involved with the original submission a few years ago. I do note that the x86 __get_user_pages_fast() thing looks dodgy too. In particular, we do it right in the *real* get_user_pages_fast(), see commit 7f8189068726 ("x86: don't use 'access_ok()' as a range check in get_user_pages_fast()"). But then the same bug was re-introduced when the "irq safe" version was merged. As well as in the GENERIC_RCU_GUP version. Gaah. Apparently PeterZ copied the old buggy version before the fix when he added __get_user_pages_fast() in commit 465a454f254e ("x86, mm: Add __get_user_pages_fast()"). I guess it could be considered a merge error (both happened during the 2.6.31 merge window). Linus From jinshan.xiong at intel.com Fri Feb 3 23:44:57 2017 From: jinshan.xiong at intel.com (Xiong, Jinshan) Date: Fri, 3 Feb 2017 23:44:57 +0000 Subject: [lustre-devel] [PATCH] mm: Avoid returning VM_FAULT_RETRY from ->page_mkwrite handlers In-Reply-To: <20170203150729.15863-1-jack@suse.cz> References: <20170203150729.15863-1-jack@suse.cz> Message-ID: Hi Jan, Thanks for the patch. The proposed patch should be able to fix the problem, however, do you think it would be a better approach by revising it as: … case -EAGAIN: if (vmf->flags & FAULT_FLAG_ALLOW_RETRY) { up_read(&mm->mmap_sem); return VM_FAULT_RETRY; } return VM_FAULT_NOPAGE; … This way it can retry fault routine in mm instead of letting CPU have a new fault access. Thanks, Jinshan > On Feb 3, 2017, at 7:07 AM, Jan Kara wrote: > > Some ->page_mkwrite handlers may return VM_FAULT_RETRY as its return > code (GFS2 or Lustre can definitely do this). However VM_FAULT_RETRY > from ->page_mkwrite is completely unhandled by the mm code and results > in locking and writeably mapping the page which definitely is not what > the caller wanted. Fix Lustre and block_page_mkwrite_ret() used by other > filesystems (notably GFS2) to return VM_FAULT_NOPAGE instead which > results in bailing out from the fault code, the CPU then retries the > access, and we fault again effectively doing what the handler wanted. > > CC: lustre-devel at lists.lustre.org > CC: cluster-devel at redhat.com > Reported-by: Al Viro > Signed-off-by: Jan Kara > --- > drivers/staging/lustre/lustre/llite/llite_mmap.c | 4 +--- > include/linux/buffer_head.h | 4 +--- > 2 files changed, 2 insertions(+), 6 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/llite/llite_mmap.c b/drivers/staging/lustre/lustre/llite/llite_mmap.c > index ee01f20d8b11..9afa6bec3e6f 100644 > --- a/drivers/staging/lustre/lustre/llite/llite_mmap.c > +++ b/drivers/staging/lustre/lustre/llite/llite_mmap.c > @@ -390,15 +390,13 @@ static int ll_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) > result = VM_FAULT_LOCKED; > break; > case -ENODATA: > + case -EAGAIN: > case -EFAULT: > result = VM_FAULT_NOPAGE; > break; > case -ENOMEM: > result = VM_FAULT_OOM; > break; > - case -EAGAIN: > - result = VM_FAULT_RETRY; > - break; > default: > result = VM_FAULT_SIGBUS; > break; > diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h > index d67ab83823ad..79591c3660cc 100644 > --- a/include/linux/buffer_head.h > +++ b/include/linux/buffer_head.h > @@ -243,12 +243,10 @@ static inline int block_page_mkwrite_return(int err) > { > if (err == 0) > return VM_FAULT_LOCKED; > - if (err == -EFAULT) > + if (err == -EFAULT || err == -EAGAIN) > return VM_FAULT_NOPAGE; > if (err == -ENOMEM) > return VM_FAULT_OOM; > - if (err == -EAGAIN) > - return VM_FAULT_RETRY; > /* -ENOSPC, -EDQUOT, -EIO ... */ > return VM_FAULT_SIGBUS; > } > -- > 2.10.2 > > _______________________________________________ > lustre-devel mailing list > lustre-devel at lists.lustre.org > http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org From viro at ZenIV.linux.org.uk Sat Feb 4 03:08:42 2017 From: viro at ZenIV.linux.org.uk (Al Viro) Date: Sat, 4 Feb 2017 03:08:42 +0000 Subject: [lustre-devel] [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call In-Reply-To: <20170202095125.GF27291@ZenIV.linux.org.uk> References: <20170124212327.14517-1-jlayton@redhat.com> <20170125133205.21704-1-jlayton@redhat.com> <20170202095125.GF27291@ZenIV.linux.org.uk> Message-ID: <20170204030842.GL27291@ZenIV.linux.org.uk> On Thu, Feb 02, 2017 at 09:51:25AM +0000, Al Viro wrote: > * fuse_copy_fill(). I'm not at all sure that iov_iter_get_pages() > is a good idea there - fuse_copy_do() could bloody well just use > copy_{to,from}_iter(). Miklos, could you explain why does lock_request() prohibit page faults until the matching unlock_request()? All it does is setting FR_LOCKED on our request and the only thing that even looks at that is fuse_abort_conn(), which doesn't (AFAICS) wait for anything. Where does the deadlock come from, and if it's not a deadlock - what is it? Or is that comment stale since "fuse: simplify request abort"? From viro at ZenIV.linux.org.uk Sat Feb 4 19:26:55 2017 From: viro at ZenIV.linux.org.uk (Al Viro) Date: Sat, 4 Feb 2017 19:26:55 +0000 Subject: [lustre-devel] [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call In-Reply-To: <20170204030842.GL27291@ZenIV.linux.org.uk> References: <20170124212327.14517-1-jlayton@redhat.com> <20170125133205.21704-1-jlayton@redhat.com> <20170202095125.GF27291@ZenIV.linux.org.uk> <20170204030842.GL27291@ZenIV.linux.org.uk> Message-ID: <20170204192655.GA13195@ZenIV.linux.org.uk> On Sat, Feb 04, 2017 at 03:08:42AM +0000, Al Viro wrote: > On Thu, Feb 02, 2017 at 09:51:25AM +0000, Al Viro wrote: > > > * fuse_copy_fill(). I'm not at all sure that iov_iter_get_pages() > > is a good idea there - fuse_copy_do() could bloody well just use > > copy_{to,from}_iter(). > > Miklos, could you explain why does lock_request() prohibit page faults until > the matching unlock_request()? All it does is setting FR_LOCKED on > our request and the only thing that even looks at that is fuse_abort_conn(), > which doesn't (AFAICS) wait for anything. > > Where does the deadlock come from, and if it's not a deadlock - what is > it? Or is that comment stale since "fuse: simplify request abort"? While we are at it... How can fuse_copy_page() ever get called with *pagep == NULL? AFAICS, for that to happen you need either i < req->num_pages && req->pages[i] == NULL or in fuse_notify_store() have err = fuse_copy_page(cs, &page, offset, this_num, 0); reached with page == NULL. The latter is flat-out impossible - we have if (!page) goto out_iput; this_num = min_t(unsigned, num, PAGE_SIZE - offset); immediately before the call in question. As for the former... I don't see any place where we would increase ->num_pages without having all additional ->pages[] elements guaranteed to be non-NULL. Stores to ->num_pages are in cuse_send_init(): req->num_pages = 1; with req->pages[0] = page; shortly before that and if (!page) goto err_put_req; earlier. In fuse_retrieve(): if (!page) break; this_num = min_t(unsigned, num, PAGE_SIZE - offset); req->pages[req->num_pages] = page; req->page_descs[req->num_pages].length = this_num; req->num_pages++; In fuse_readdir(): req->num_pages = 1; req->pages[0] = page; with if (!page) { fuse_put_request(fc, req); return -ENOMEM; } several lines above. In fuse_do_readpage(): req->num_pages = 1; req->pages[0] = page; with page dereferenced earlier. In fuse_fill_write_pages(): req->pages[req->num_pages] = page; req->page_descs[req->num_pages].length = tmp; req->num_pages++; with if (!page) break; earlier. In fuse_get_user_pages(): ret = iov_iter_get_pages(ii, &req->pages[req->num_pages], *nbytesp - nbytes, req->max_pages - req->num_pages, &start); if (ret < 0) break; iov_iter_advance(ii, ret); nbytes += ret; ret += start; npages = (ret + PAGE_SIZE - 1) / PAGE_SIZE; req->page_descs[req->num_pages].offset = start; fuse_page_descs_length_init(req, req->num_pages, npages); req->num_pages += npages; which also shouldn't leave any NULLs in the area in question. In fuse_writepage_locked(): req->num_pages = 1; req->pages[0] = tmp_page; with if (!tmp_page) goto err_free; done earlier. In fuse_writepage_in_flight(): req->num_pages = 1; with BUG_ON(new_req->num_pages != 0); earlier and req->pages[req->num_pages] = tmp_page; done in the caller (which passes req as new_req). Earlier in the caller we have if (!tmp_page) goto out_unlock; In fuse_writepages_fill(): req->num_pages = 0; is obviously OK and req->num_pages++; in the end of the same function is preceded by the same req->pages[req->num_pages] = tmp_page; (fuse_writepages_fill() is the caller of fuse_writepage_in_flight(); reassignment in fuse_writepage_in_flight() happens only in case when it returns 1 and in that case we don't reach the increment in fuse_writepages_fill() at all). In fuse_do_ioctl(): memcpy(req->pages, pages, sizeof(req->pages[0]) * num_pages); req->num_pages = num_pages; and all increments of num_pages in there are pages[num_pages] = alloc_page(GFP_KERNEL | __GFP_HIGHMEM); if (!pages[num_pages]) goto out; num_pages++; so the array we copy into req->pages has the same property wrt num_pages. req->pages is assigned only in fuse_request_init(); that gets called in two places - one is at request allocation time, another (from put_reserved_req()) passes the current req->pages value, so that leaves it unchanged. The contents of req->pages[] is changed only in the aforementioned places + fuse_request_init(), which zeros ->num_pages + fuse_copy_page() called from fuse_copy_pages() with &req->pages[i] as argument. The last one can modify the damn thing, but only if it hits err = fuse_try_move_page(cs, pagep); and that sucker never stores a NULL in there - *pagep = newpage; with get_page(newpage) upstream from that point. What am I missing here? Looks like those checks in fuse_copy_page() are dead code... They had been there since the initial merge, but AFAICS they were just as useless in 2.6.14. Rudiments of some prehistorical stuff that never had been cleaned out, perhaps? From viro at ZenIV.linux.org.uk Sun Feb 5 01:51:49 2017 From: viro at ZenIV.linux.org.uk (Al Viro) Date: Sun, 5 Feb 2017 01:51:49 +0000 Subject: [lustre-devel] [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call In-Reply-To: References: <20170124212327.14517-1-jlayton@redhat.com> <20170125133205.21704-1-jlayton@redhat.com> <20170202095125.GF27291@ZenIV.linux.org.uk> <20170204030842.GL27291@ZenIV.linux.org.uk> Message-ID: <20170205015145.GB13195@ZenIV.linux.org.uk> On Sat, Feb 04, 2017 at 11:11:27PM +0100, Miklos Szeredi wrote: > Well, it's not historical; at least not yet. The deadlock is there > alright: mmap fuse file to addr; read byte from mapped page -> page > locked; this triggeres read request served in same process but > separate thread; write addr-headerlen to fuse dev; trying to lock same > page -> deadlock. Let me see if I got it straight - you have the same fuse file mmapped in two processes, one of them being fuse server (either sharing the entire address space, or the same area mapped in both). Another process faults the sucker in; filemap_fault() locks the page and goes fuse_readpage() -> fuse_do_readpage() -> fuse_send_read() -> -> fuse_request_send() -> __fuse_request_send() which puts request into queue and goes to sleep in request_wait_answer(). Eventually, read() on /dev/fuse (or splice(), whatever) by server picks that request and reply is formed and fed back into /dev/fuse. There we (in fuse_do_dev_write()) call copy_out_args(), which tries to copy into our (still locked) page a piece of data coming from server-supplied iovec. As it is, you are calling get_user_pages_fast(), triggering handle_mm_fault(). Since that malicous FPOS of a server tried to feed you the _same_ mmapped file, you hit a deadlock. In server's context. Correct? Convoluted, but possible. But. Why the hell do we care whether that deadlock hits in get_user_pages_fast() or in copy_from_user()? Put it another way, what difference does it make whether we take that fault with or without FR_LOCKED in req->flags? > The deadlock can be broken by aborting or force unmounting: return > error for original read request; page unlocked; device write can get > page lock and return. > > The reason we need to prohibit pagefault while copying is that when > request is aborted and the caller returns the memory in the request > may become invalid (e.g. data from stack). ??? IDGI. Your request is marked aborted and should presumably fail, so that when request_wait_answer() wakes up and finds it screwed, fuse_readpage() would just return an error and filemap_fault() will return VM_FAULT_SIGBUS, with page left not uptodate and _not_ inserted into page tables. What's leaking where? From viro at ZenIV.linux.org.uk Sun Feb 5 20:56:17 2017 From: viro at ZenIV.linux.org.uk (Al Viro) Date: Sun, 5 Feb 2017 20:56:17 +0000 Subject: [lustre-devel] [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call In-Reply-To: <20170205015145.GB13195@ZenIV.linux.org.uk> References: <20170124212327.14517-1-jlayton@redhat.com> <20170125133205.21704-1-jlayton@redhat.com> <20170202095125.GF27291@ZenIV.linux.org.uk> <20170204030842.GL27291@ZenIV.linux.org.uk> <20170205015145.GB13195@ZenIV.linux.org.uk> Message-ID: <20170205205617.GC13195@ZenIV.linux.org.uk> On Sun, Feb 05, 2017 at 01:51:49AM +0000, Al Viro wrote: > IDGI. Your request is marked aborted and should presumably fail, so > that when request_wait_answer() wakes up and finds it screwed, fuse_readpage() > would just return an error and filemap_fault() will return VM_FAULT_SIGBUS, > with page left not uptodate and _not_ inserted into page tables. What's > leaking where? Egads... Do you mean that req->pages[] contents can be dropped by connection abort right under fuse_copy_pages()? Or is it that args[...].value can end up freed under you? end() callbacks> Both, apparently, plus the request initiator might have seen that request has failed and buggered off, with args[...].value pointing to what used to be initiator's stack frame. Is that what you are talking about? If so, why not mark request as "being handled by fuse_dev_do_{read,write}()" for the duration, and leave the request_end() on such requests for fuse_dev_do_{read,write}(), seeing that they will call request_end() for such anyway? Looks like your FR_LOCKED is not far from that already. Why not stop dropping/regaining FR_LOCKED in lock_request()/unlock_request() and simply have your end_requests(fc, &to_end2); in fuse_abort_conn() skip the actual calls of request_end()? From viro at ZenIV.linux.org.uk Sun Feb 5 21:01:51 2017 From: viro at ZenIV.linux.org.uk (Al Viro) Date: Sun, 5 Feb 2017 21:01:51 +0000 Subject: [lustre-devel] [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call In-Reply-To: References: <20170124212327.14517-1-jlayton@redhat.com> <20170125133205.21704-1-jlayton@redhat.com> <20170202095125.GF27291@ZenIV.linux.org.uk> <20170204030842.GL27291@ZenIV.linux.org.uk> <20170205015145.GB13195@ZenIV.linux.org.uk> Message-ID: <20170205210151.GD13195@ZenIV.linux.org.uk> On Sun, Feb 05, 2017 at 09:15:24PM +0100, Miklos Szeredi wrote: > That case is fine. But nothing guarantees that fuse_abort_conn() > won't be called (in the non-deadlock case) when data is being copied > to the request args. Ending the request at such a point could easily > lead to use after free, So why not leave ending it to your fuse_dev_do_write()/fuse_dev_do_read()? See the reply I'd just sent (your mail arrived while I'd been writing that one - saw it only after I'd sent mine). Basically, what if we keep FR_LOCKED through *all* fuse_dev_do_{read,write}(), rather than dropping and regaining it many times and have fuse_abort_conn() skip request_end() on FR_LOCKED ones? From viro at ZenIV.linux.org.uk Sun Feb 5 22:04:45 2017 From: viro at ZenIV.linux.org.uk (Al Viro) Date: Sun, 5 Feb 2017 22:04:45 +0000 Subject: [lustre-devel] [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call In-Reply-To: References: <20170124212327.14517-1-jlayton@redhat.com> <20170125133205.21704-1-jlayton@redhat.com> <20170202095125.GF27291@ZenIV.linux.org.uk> <20170204030842.GL27291@ZenIV.linux.org.uk> <20170205015145.GB13195@ZenIV.linux.org.uk> <20170205210151.GD13195@ZenIV.linux.org.uk> Message-ID: <20170205220445.GE13195@ZenIV.linux.org.uk> On Sun, Feb 05, 2017 at 10:19:20PM +0100, Miklos Szeredi wrote: > Then we can't break out of that deadlock: we wait until > fuse_dev_do_write() is done until calling request_end() which > ultimately results in unlocking page. But fuse_dev_do_write() won't > complete until the page is unlocked. Wait a sec. What happens if process A: fuse_lookup() struct fuse_entry_out outarg on stack ... fuse_request_send() with req->out.args[0].value = &outarg sleep in request_wait_answer() on req->waitq server: read the request, write reply fuse_dev_do_write() copy_out_args() fuse_copy_args() fuse_copy_one() FR_LOCKED is guaranteed to be set fuse_copy_do() process C on another CPU: umount -f fuse_conn_abort() end_requests() request_end() set FR_FINISHED wake A up (via req->waitq) process A: regain CPU bugger off from request_wait_answer(), through __fuse_request_send(), fuse_request_send(), fuse_simple_request(), fuse_lookup_name(), fuse_lookup() and out of fuse_lookup(). In the meanwhile, server in fuse_copy_do() does memcpy() to what used to be outarg, corrupting the stack of process A. Sure, you need to hit a fairly narrow window, especially if you are to cause damage in A, but AFAICS it's not impossible. Consider e.g. the situation when you lose CPU on preempt on the way to memcpy(); in that case server might come back when A has incremented its stack footprint again. Or A might end up taking a hardware interrupt and handling it on the normal kernel stack, etc. Looks like *any* scenario where fuse_conn_abort() manages to run during that memcpy() has potential for that kind of trouble; any SMP box appears to be vulnerable, along with preempt UP... Am I missing something that prevents that kind of problem? > The only way out that I see is to have a refcount on all pages in > args. Which means copying everything not already in refcountable page > (i.e. args on stack) to a page array. It's definitely doable, but > needs time to sort out, and I'm definitely lacking that (overlayfs > currently trumps fuse). Hrm... Then maybe I'll have to try and cook something along those lines; AFAICS the current mainline is vulnerable... From viro at ZenIV.linux.org.uk Mon Feb 6 03:05:32 2017 From: viro at ZenIV.linux.org.uk (Al Viro) Date: Mon, 6 Feb 2017 03:05:32 +0000 Subject: [lustre-devel] [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call In-Reply-To: <20170205220445.GE13195@ZenIV.linux.org.uk> References: <20170124212327.14517-1-jlayton@redhat.com> <20170125133205.21704-1-jlayton@redhat.com> <20170202095125.GF27291@ZenIV.linux.org.uk> <20170204030842.GL27291@ZenIV.linux.org.uk> <20170205015145.GB13195@ZenIV.linux.org.uk> <20170205210151.GD13195@ZenIV.linux.org.uk> <20170205220445.GE13195@ZenIV.linux.org.uk> Message-ID: <20170206030532.GF13195@ZenIV.linux.org.uk> On Sun, Feb 05, 2017 at 10:04:45PM +0000, Al Viro wrote: > Sure, you need to hit a fairly narrow window, especially if you are to > cause damage in A, but AFAICS it's not impossible. Consider e.g. the > situation when you lose CPU on preempt on the way to memcpy(); in that > case server might come back when A has incremented its stack footprint > again. Or A might end up taking a hardware interrupt and handling it > on the normal kernel stack, etc. > > Looks like *any* scenario where fuse_conn_abort() manages to run during > that memcpy() has potential for that kind of trouble; any SMP box appears > to be vulnerable, along with preempt UP... > > Am I missing something that prevents that kind of problem? For that matter, it doesn't have to be on-stack - e.g. fuse_get_link() has kmalloc'ed buffer for destination, kfree'd upon failure. Have the damn thing lose the timeslice in fuse_copy_do() and you might very well end up spraying user-supplied data over whatever ends up picking your kfreed buffer. That one could be reasonably dealt with if we switched to page_alloc() and stuffed it into the ->pages[] instead... Some observations regarding the arguments: * stack footprint is atrocious. Consider e.g. fuse_mknod() - you get 16 bytes of fuse_mknod_in + 120 bytes of struct fuse_args + 128 bytes of fuse_entry_out. All on stack, and that's on top of whatever the callchain already has eaten, which might include e.g. nfsd stuff or ecryptfs, etc. Or fuse_get_parent(), for that matter, with 128 bytes of fuse_entry_out + 120 bytes of fuse_args, both on stack. This one is guaranteed to have a nasty call chain - fuse_get_parent() <- reconnect_one() <- reconnect_path() <- exportfs_decode_fh() (itself with a 256-byte array of char on stack) <- nfsd_set_fh_dentry() <- fh_verify() <- a bunch of call chains in nfsd. * "out" args (i.e. reply) are probably best dealt with by having coallocated with request itself - some already are and the sizes tend to be fixed and not too large (->get_link() is an exception, and it's probably better handled as mentioned above). * "in" args (request) are in some cases easily dealt with by coallocating with request, but there's a large class of situations where we are passing dentry->d_name.name and then there's fuse_symlink(). The last one is ugly - potentially up to a page worth of data, coming straight from method caller; usually it's a part of getname() result, but e.g. ecryptfs might have it kmalloc'ed, nfsd - picked from sunrpc request payload, etc. AFAICS, your argument applies to the requests that have some page(s) locked until the request completion (unlock_page() either by ->end() callback or in the originator of request). If so, I would rather mark those as "call request_end() early"; they seem to have the non-page parts of args hosted in req->misc, so for them it's not a problem. So how about this: * explicit FR_END_IMMEDIATELY on read/write-related requests * no FR_LOCKED flipping in lock_request()/unlock_request() * modifying the call of end_requests() in fuse_abort_conn() so that it would skip request_end() for everything that isn't marked FR_END_IMMEDIATELY * make fuse_copy_pages() grab page references around the actual fuse_copy_page() - grab req->waitq.lock, check FR_ABORTED, grab a page reference in case it's not, drop req->waitq.lock and bugger off if FR_ABORTED was set. Adjust fuse_try_move_page() accordingly. Do you see any problems with that approach for minimal fix? If all requests in need of FR_END_IMMEDIATELY turn out to have non-page part of args already embedded into req->misc, it looks like this ought to suffice. I probably could post something along those lines tomorrow, if you see any serious problems with that - please yell... From jack at suse.cz Mon Feb 6 08:59:27 2017 From: jack at suse.cz (Jan Kara) Date: Mon, 6 Feb 2017 09:59:27 +0100 Subject: [lustre-devel] [PATCH] mm: Avoid returning VM_FAULT_RETRY from ->page_mkwrite handlers In-Reply-To: References: <20170203150729.15863-1-jack@suse.cz> Message-ID: <20170206085927.GC4004@quack2.suse.cz> Hi Xiong, On Fri 03-02-17 23:44:57, Xiong, Jinshan wrote: > Thanks for the patch. > > The proposed patch should be able to fix the problem, however, do you > think it would be a better approach by revising it as: > > … > case -EAGAIN: > if (vmf->flags & FAULT_FLAG_ALLOW_RETRY) { > up_read(&mm->mmap_sem); > return VM_FAULT_RETRY; > } > return VM_FAULT_NOPAGE; > … > > This way it can retry fault routine in mm instead of letting CPU have a > new fault access. Well, we could do that but IMHO that is a negligible benefit not worth the complications in the code. After all these retries should better be rare or you have bigger problems with your fault handler... What would be worthwhile is something like: if (vmf->flags & FAULT_FLAG_ALLOW_RETRY) { up_read(&mm->mmap_sem); return VM_FAULT_RETRY; } However that wait is specific to the fault handler so we cannot do that in the generic code. Honza > > On Feb 3, 2017, at 7:07 AM, Jan Kara wrote: > > > > Some ->page_mkwrite handlers may return VM_FAULT_RETRY as its return > > code (GFS2 or Lustre can definitely do this). However VM_FAULT_RETRY > > from ->page_mkwrite is completely unhandled by the mm code and results > > in locking and writeably mapping the page which definitely is not what > > the caller wanted. Fix Lustre and block_page_mkwrite_ret() used by other > > filesystems (notably GFS2) to return VM_FAULT_NOPAGE instead which > > results in bailing out from the fault code, the CPU then retries the > > access, and we fault again effectively doing what the handler wanted. > > > > CC: lustre-devel at lists.lustre.org > > CC: cluster-devel at redhat.com > > Reported-by: Al Viro > > Signed-off-by: Jan Kara > > --- > > drivers/staging/lustre/lustre/llite/llite_mmap.c | 4 +--- > > include/linux/buffer_head.h | 4 +--- > > 2 files changed, 2 insertions(+), 6 deletions(-) > > > > diff --git a/drivers/staging/lustre/lustre/llite/llite_mmap.c b/drivers/staging/lustre/lustre/llite/llite_mmap.c > > index ee01f20d8b11..9afa6bec3e6f 100644 > > --- a/drivers/staging/lustre/lustre/llite/llite_mmap.c > > +++ b/drivers/staging/lustre/lustre/llite/llite_mmap.c > > @@ -390,15 +390,13 @@ static int ll_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) > > result = VM_FAULT_LOCKED; > > break; > > case -ENODATA: > > + case -EAGAIN: > > case -EFAULT: > > result = VM_FAULT_NOPAGE; > > break; > > case -ENOMEM: > > result = VM_FAULT_OOM; > > break; > > - case -EAGAIN: > > - result = VM_FAULT_RETRY; > > - break; > > default: > > result = VM_FAULT_SIGBUS; > > break; > > diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h > > index d67ab83823ad..79591c3660cc 100644 > > --- a/include/linux/buffer_head.h > > +++ b/include/linux/buffer_head.h > > @@ -243,12 +243,10 @@ static inline int block_page_mkwrite_return(int err) > > { > > if (err == 0) > > return VM_FAULT_LOCKED; > > - if (err == -EFAULT) > > + if (err == -EFAULT || err == -EAGAIN) > > return VM_FAULT_NOPAGE; > > if (err == -ENOMEM) > > return VM_FAULT_OOM; > > - if (err == -EAGAIN) > > - return VM_FAULT_RETRY; > > /* -ENOSPC, -EDQUOT, -EIO ... */ > > return VM_FAULT_SIGBUS; > > } > > -- > > 2.10.2 > > > > _______________________________________________ > > lustre-devel mailing list > > lustre-devel at lists.lustre.org > > http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org > -- Jan Kara SUSE Labs, CR From jack at suse.cz Mon Feb 6 09:24:15 2017 From: jack at suse.cz (Jan Kara) Date: Mon, 6 Feb 2017 10:24:15 +0100 Subject: [lustre-devel] [PATCH] mm: Avoid returning VM_FAULT_RETRY from ->page_mkwrite handlers In-Reply-To: <20170203152054.6ee9f8a920e6d0ac8a93d2b9@linux-foundation.org> References: <20170203150729.15863-1-jack@suse.cz> <20170203152054.6ee9f8a920e6d0ac8a93d2b9@linux-foundation.org> Message-ID: <20170206092415.GD4004@quack2.suse.cz> On Fri 03-02-17 15:20:54, Andrew Morton wrote: > On Fri, 3 Feb 2017 16:07:29 +0100 Jan Kara wrote: > > > Some ->page_mkwrite handlers may return VM_FAULT_RETRY as its return > > code (GFS2 or Lustre can definitely do this). However VM_FAULT_RETRY > > from ->page_mkwrite is completely unhandled by the mm code and results > > in locking and writeably mapping the page which definitely is not what > > the caller wanted. Fix Lustre and block_page_mkwrite_ret() used by other > > filesystems (notably GFS2) to return VM_FAULT_NOPAGE instead which > > results in bailing out from the fault code, the CPU then retries the > > access, and we fault again effectively doing what the handler wanted. > > I'm not getting any sense of the urgency of this fix. The bug *sounds* > bad? Which kernel versions need fixing? So I did more analysis of GFS2 and Lustre behavior. AFAICS GFS2 returns EAGAIN only for truncated page, when we then return with VM_FAULT_RETRY, do_page_mkwrite() locks the page, sees it is truncated and bails out properly thus silently fixes up the problem. The Lustre bug looks like it could actually result in some real problems and the bug is there since the initial commit in which Lustre was added in 3.11 (d7e09d0397e84). So overall the issue doesn't look like too serious currently but it is certainly a serious bug waiting to happen. Honza -- Jan Kara SUSE Labs, CR From viro at ZenIV.linux.org.uk Mon Feb 6 09:57:07 2017 From: viro at ZenIV.linux.org.uk (Al Viro) Date: Mon, 6 Feb 2017 09:57:07 +0000 Subject: [lustre-devel] [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call In-Reply-To: References: <20170202095125.GF27291@ZenIV.linux.org.uk> <20170204030842.GL27291@ZenIV.linux.org.uk> <20170205015145.GB13195@ZenIV.linux.org.uk> <20170205210151.GD13195@ZenIV.linux.org.uk> <20170205220445.GE13195@ZenIV.linux.org.uk> <20170206030532.GF13195@ZenIV.linux.org.uk> Message-ID: <20170206095706.GG13195@ZenIV.linux.org.uk> On Mon, Feb 06, 2017 at 10:08:06AM +0100, Miklos Szeredi wrote: > Yes, I think only page lock can be used to deadlock inside > fuse_dev_read/write(). So requests that don't have locked pages > should be okay with just waiting until copy_to/from_user() finishes > and only then proceeding with the abort. Actually, looking at that some more, this might be not true. Anything that takes ->mmap_sem exclusive and *not* killable makes for another source of deadlock. Initial page fault takes ->mmap_sem shared. OK, request sent to server and server tries to read() it. In the meanwhile, something has closed userfaultfd for the same mm_struct. We have userfaultfd_release() block on attempt to take ->mmap_sem exclusive and from now on any attempt to grab ->mmap_sem shared will deadlock. And get_user_pages(), as well as copy_to_user(), etc. can end up doing just that. It doesn't have to be an mmap of the same file, BTW - any page fault would do. All you really need is to have server sharing address space with the process that steps into original page fault, plus an evicted page of any nature (anon mmap, whatever) being used as a destination of read() in server. down_read() inside down_read() is fine, unless there had been down_write() in between. And there are unkillable down_write() on ->mmap_sem - userfaultfd_release() being one example of such. Many of those can and probably should become down_write_killable(), but this one can't - there might be nothing to deliver the signal to, if the final close() happens e.g. from exit(2). Warning: the above might be completely bogus - I'm on way too large uptime at the moment and most of the last day had been spent digging through various convoluted code, so take the above with a cartload of salt. _If_ it's true, that kind of deadlock won't be possible to break with killing anything or doing umount -f, though. > > Those that have locked pages must be able to be aborted during > copy_to/from_user() because the copy itself may try to acquire the > page lock. > > So yes, if we want to switch to copy_to/from_user(), then we can just > fix the page refcounting for read and write requests and handle the > two cases differently. > > > So how about this: > > > > * explicit FR_END_IMMEDIATELY on read/write-related requests > > * no FR_LOCKED flipping in lock_request()/unlock_request() > > * modifying the call of end_requests() in fuse_abort_conn() so that it > > would skip request_end() for everything that isn't marked FR_END_IMMEDIATELY > > * make fuse_copy_pages() grab page references around the actual > > fuse_copy_page() - grab req->waitq.lock, check FR_ABORTED, grab a page > > reference in case it's not, drop req->waitq.lock and bugger off if FR_ABORTED > > was set. Adjust fuse_try_move_page() accordingly. > > > > Do you see any problems with that approach for minimal fix? If all requests > > in need of FR_END_IMMEDIATELY turn out to have non-page part of args already > > embedded into req->misc, it looks like this ought to suffice. I probably > > could post something along those lines tomorrow, if you see any serious > > problems with that - please yell... > > See previous mail, I don't think there's an issue with the current > code. Other than being convoluted as hell. OK - I'm an idiot and I've managed to misread fuse_abort_conn() despite having reread it many times last couple of days. And yes, state transitions of requests are convoluted as hell ;-/ Anyway, bedtime for me. With any luck the scare above re ->mmap_sem *is* bogus and I'll find "Al, you are an idiot - deadlock on ->mmap_sem can't happen for " from somebody in the mailbox when I get up... From jinshan.xiong at intel.com Mon Feb 6 20:52:29 2017 From: jinshan.xiong at intel.com (Xiong, Jinshan) Date: Mon, 6 Feb 2017 20:52:29 +0000 Subject: [lustre-devel] [PATCH] mm: Avoid returning VM_FAULT_RETRY from ->page_mkwrite handlers In-Reply-To: <20170203150729.15863-1-jack@suse.cz> References: <20170203150729.15863-1-jack@suse.cz> Message-ID: <4CD0030B-EA76-4E3D-B9F4-B2E96D05C5B6@intel.com> looks good to me. Reviewed-by: Jinshan Xiong > On Feb 3, 2017, at 7:07 AM, Jan Kara wrote: > > Some ->page_mkwrite handlers may return VM_FAULT_RETRY as its return > code (GFS2 or Lustre can definitely do this). However VM_FAULT_RETRY > from ->page_mkwrite is completely unhandled by the mm code and results > in locking and writeably mapping the page which definitely is not what > the caller wanted. Fix Lustre and block_page_mkwrite_ret() used by other > filesystems (notably GFS2) to return VM_FAULT_NOPAGE instead which > results in bailing out from the fault code, the CPU then retries the > access, and we fault again effectively doing what the handler wanted. > > CC: lustre-devel at lists.lustre.org > CC: cluster-devel at redhat.com > Reported-by: Al Viro > Signed-off-by: Jan Kara > --- > drivers/staging/lustre/lustre/llite/llite_mmap.c | 4 +--- > include/linux/buffer_head.h | 4 +--- > 2 files changed, 2 insertions(+), 6 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/llite/llite_mmap.c b/drivers/staging/lustre/lustre/llite/llite_mmap.c > index ee01f20d8b11..9afa6bec3e6f 100644 > --- a/drivers/staging/lustre/lustre/llite/llite_mmap.c > +++ b/drivers/staging/lustre/lustre/llite/llite_mmap.c > @@ -390,15 +390,13 @@ static int ll_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) > result = VM_FAULT_LOCKED; > break; > case -ENODATA: > + case -EAGAIN: > case -EFAULT: > result = VM_FAULT_NOPAGE; > break; > case -ENOMEM: > result = VM_FAULT_OOM; > break; > - case -EAGAIN: > - result = VM_FAULT_RETRY; > - break; > default: > result = VM_FAULT_SIGBUS; > break; > diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h > index d67ab83823ad..79591c3660cc 100644 > --- a/include/linux/buffer_head.h > +++ b/include/linux/buffer_head.h > @@ -243,12 +243,10 @@ static inline int block_page_mkwrite_return(int err) > { > if (err == 0) > return VM_FAULT_LOCKED; > - if (err == -EFAULT) > + if (err == -EFAULT || err == -EAGAIN) > return VM_FAULT_NOPAGE; > if (err == -ENOMEM) > return VM_FAULT_OOM; > - if (err == -EAGAIN) > - return VM_FAULT_RETRY; > /* -ENOSPC, -EDQUOT, -EIO ... */ > return VM_FAULT_SIGBUS; > } > -- > 2.10.2 > > _______________________________________________ > lustre-devel mailing list > lustre-devel at lists.lustre.org > http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org From viro at ZenIV.linux.org.uk Tue Feb 7 07:19:09 2017 From: viro at ZenIV.linux.org.uk (Al Viro) Date: Tue, 7 Feb 2017 07:19:09 +0000 Subject: [lustre-devel] [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call In-Reply-To: References: <20170205015145.GB13195@ZenIV.linux.org.uk> <20170205210151.GD13195@ZenIV.linux.org.uk> <20170205220445.GE13195@ZenIV.linux.org.uk> <20170206030532.GF13195@ZenIV.linux.org.uk> <20170206095706.GG13195@ZenIV.linux.org.uk> Message-ID: <20170207071909.GI13195@ZenIV.linux.org.uk> On Mon, Feb 06, 2017 at 03:18:42PM +0100, Miklos Szeredi wrote: > But I think it's breakable in the same way: if the deadlocked request > is aborted, the fault will release the page lock as well as mmap_sem, > and from there things will resolve themselves. Right you are - original holder of ->mmap_sem is waiting for request and abort will wake it up... > But you are definitely right about needing to clean up that mess in > fuse/dev.c and doing so by fixing up the arg refcounting for just the > read and write requests is going to be a lot simpler than having to do > that for all of them (which was my original plan). Speaking of refcounting - what's going on with fuse_file one? My reading of that code is that you have 4 states of that thing: * new (just created, fallback request allocated, use fuse_file_free() to kill). Refcount is 0. * intermediate - in fact it's already opened, but still not put into ->private_data. Refcount is still 0. Use fuse_sync_release() to kill. * live - normal refcounting (fuse_file_get()/fuse_file_put()). * shutdown - refcount has reached 0. Can't happen until ->release() (obviously - ->private_data holds a counting reference), some pieces of fuse_sync_release() correspond to some stuff in fuse_release_common(), some - to final fuse_file_put(). To make it even more convoluted, cuse is using fuse_sync_release() and apparently relies upon no references being grabbed after fuse_do_open(), so that thing can be called with refcount 0 *or* refcount 1. Another thing: what guarantees that places in writepages-related paths where we store a reference into req->ff won't hit a request with already non-NULL ->ff? From dan.carpenter at oracle.com Tue Feb 7 12:22:44 2017 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Tue, 7 Feb 2017 15:22:44 +0300 Subject: [lustre-devel] [bug report] staging: lustre: lmv: Error not handled for lmv_find_target Message-ID: <20170207122243.GA23469@mwanda> Hello Ulka Vaze, You didn't introduce this warning but you were fixing nearby code so you might know the answer. drivers/staging/lustre/lustre/lmv/lmv_obd.c:1069 lmv_iocontrol() warn: check 'reqlen' for integer overflows 'obd_iocontrol()' drivers/staging/lustre/lustre/lmv/lmv_obd.c 1056 1057 /* build a request with fids for this MDS */ 1058 reqlen = offsetof(typeof(*hur), 1059 hur_user_item[nr]) 1060 + hur->hur_request.hr_data_len; It looks like this addition can have an integer overflow bug. 1061 req = libcfs_kvzalloc(reqlen, GFP_NOFS); Leading to a req that is smaller than necessary. 1062 if (!req) 1063 return -ENOMEM; 1064 1065 rc1 = lmv_hsm_req_build(lmv, hur, tgt, req); Which could be a problem in here. 1066 if (rc1 < 0) 1067 goto hsm_req_err; 1068 1069 rc1 = obd_iocontrol(cmd, tgt->ltd_exp, reqlen, 1070 req, uarg); 1071 hsm_req_err: 1072 if (rc1 != 0 && rc == 0) 1073 rc = rc1; 1074 kvfree(req); regards, dan carpenter From andreas.dilger at intel.com Tue Feb 7 23:01:43 2017 From: andreas.dilger at intel.com (Dilger, Andreas) Date: Tue, 7 Feb 2017 23:01:43 +0000 Subject: [lustre-devel] Proposal for JobID caching In-Reply-To: References: <6E2CFE03-A158-4D82-82BA-AF0A175AA358@intel.com> <9BEFFD88-0537-43AB-8352-6477F30906DA@intel.com> Message-ID: On Feb 2, 2017, at 08:20, Ben Evans wrote: > > https://review.whamcloud.com/#/c/25208/ is a working version of what I had > proposed, including the suggested changes to default to procname_uid. > This is not perfect, but the performance is much improved over the current > methods, and unlike inode-based caching Metadata performance isn't > negatively affected. Multiple simultaneous jobs can be run on the same > file, and get appropriate metrics. I reviewed the patch, and one question that I had is whether you've tested if the JobID is correct when read/write RPCs are generated by readahead or ptlrpcd? That may be more relevant once the async readahead threads are implemented by Dmitry. With an inode-based JobID cache then the JobID can (usually) be correctly determined even if the RPC is not generated in the context of the user process. I don't think that is necessarily a fault in your patch, but it may be that the JobID determination hasn't kept pace with other changes in the code. It would be great if you would verify (possibly with a test attached to your patch) that JobID is assigned to all the RPCs that need it. Cheers, Andreas > On 1/20/17, 5:00 PM, "Ben Evans" wrote: > >> >> >> On 1/20/17, 4:50 PM, "Dilger, Andreas" wrote: >> >>> On Jan 18, 2017, at 13:39, Oleg Drokin wrote: >>>> >>>> >>>> On Jan 18, 2017, at 3:08 PM, Ben Evans wrote: >>>> >>>>> Overview >>>>> The Lustre filesystem added the ability to track I/O >>>>> performance of a job across a cluster. The initial algorithm was >>>>> relatively simplistic: for every I/O, look up the job ID of the >>>>> process and include it in the RPC being sent to the server. This >>>>> imposed a non-trivial performance impact on client I/O performance. >>>>> An additional algorithm was introduced to handle the single >>>>> job per node case, where instead of looking up the job ID of the >>>>> process, Lustre simply accesses the value of a variable set through the >>>>> proc interface. This improved performance greatly, but only functions >>>>> when a single job is being run. >>>>> A new approach is needed for multiple job per node systems. >>>>> >>>>> Proposed Solution >>>>> The proposed solution to this is to create a small >>>>> PID->JobID table in kernel memory. When a process performs an IO, a >>>>> lookup is done in the table for the PID, if a JobID exists for that >>>>> PID, it is used, otherwise it is retrieved via the same methods as the >>>>> original Jobstats algorithm. Once located the JobID is stored in a >>>>> PID/JobID table in memory. The existing cfs_hash_table structure and >>>>> functions will be used to implement the table. >>>>> >>>>> Rationale >>>>> This reduces the number of calls into userspace, minimizing >>>>> the time taken on each I/O. It also easily supports multiple job per >>>>> node scenarios, and like other proposed solutions has no issue with >>>>> multiple jobs performing I/O on the same file at the same time. >>>>> >>>>> Requirements >>>>> · Performance cannot significantly detract from baseline >>>>> performance without jobstats >>>>> · Supports multiple jobs per node >>>>> · Coordination with the scheduler is not required, but interfaces >>>>> may be provided >>>>> · Supports multiple PIDs per job >>>>> >>>>> New Data Structures >>>>> pid_to_jobid { >>>>> struct hlist_node pj_hash; >>>>> u54 pj_pid; >>>>> char pj_jobid[LUSTRE_JOBID_SIZE]; >>>>> spinlock_t jp_lock; >>>>> time_t jp_time; >>>>> } >>>>> Proc Variables >>>>> Writing to /proc/fs/lustre/jobid_name while not in ³nodelocal² mode >>>>> will cause all entries in the cache for that jobID to be removed from >>>>> the cache >>>>> >>>>> Populating the Cache >>>>> When lustre_get_jobid is called, the process, and in the >>>>> cached mode, first a check will be done in the cache for a valid PID to >>>>> JobID mapping. If none exists, it uses the same mechanisms to get the >>>>> JobID and populates the appropriate PID to JobID map. >>>>> If a lookup is performed and the PID to JobID mapping exists, but is >>>>> more than 30 seconds old, the JobID is refreshed. >>>>> Purging the Cache >>>>> The cache can be purged of a specific job by writing the >>>>> JobID to the jobid_name proc file. Any items in the cache that are >>>>> more than 300 seconds out of date will also be purged at this time. >>>> >>>> >>>> I'd much rather prefer you go to the table that's populated outside of >>>> the kernel >>>> somehow. >>>> Let's be realistic, poking around in userspace process environments for >>>> random >>>> strings is not such a great idea at all even though it did look like a >>>> good idea >>>> in the past for simplicity reasons. >>>> Similar to nodelocal, we probably just switch to a method where you >>>> call a >>>> particular lctl command that would mark the whole session as belonging >>>> to some job. This might take several forms, e.g. nodelocal itself could >>>> be extended to only apply to a current namespace/container >>>> But if you do really run different jobs in the global namespace, we >>>> probably can >>>> probably just make the lctl to spawn a shell with commands that all >>>> would >>>> be marked as a particular job? Or we can probably trace the parent of >>>> lctl and >>>> mark that so that all its children become somehow marked too. >>> >>> Having lctl spawn a shell or requiring everything to run in a container >>> is impractical for users, and will just make it harder to use JobID, >>> IMHO. The job scheduler is _already_ storing the JobID in the process >>> environment so that it is available to all of the threads running as part >>> of the job. The question is how the job prolog script can communicate >>> the JobID directly to Lustre without using a global /proc file? Doing an >>> upcall to userspace per JobID lookup is going to be *worse* for >>> performance than the current searching through the process environment. >>> >>> I'm not against Ben's proposal to implement a cache in the kernel for >>> different processes. It is unfortunate that we can't have proper >>> thread-local storage for Lustre, so a hash table is probably reasonable >>> for this (there may be thousands of threads involved). I don't think the >>> cl_env struct would be useful, since it is not tied to a specific thread >>> (AFAIK), but rather assigned as different threads enter/exit kernel >>> context. Note that we already have similar time-limited caches for the >>> identity upcall and FMD (lustre/ofd/ofd_fmd.c), so it may be useful to >>> see whether the code can be shared. >> >> I'll take a look at those, but implementing the hash table was a pretty >> simple solution, I need to work out a few kinks with memory leaks before >> doing real performance tests on it to make sure it performs similarly to >> nodelocal. >> >>> Another (not very nice) option to avoid looking through the environment >>> variables (which IMHO isn't so bad, even though the upstream folks don't >>> like it) is to associate the JobID set via /proc with a process group >>> internally and look the PGID up in the kernel to find the JobID. That >>> can be repeated each time a new JobID is set via /proc, since the PGID >>> would stick around for each new job/shell/process created under the PGID. >>> It won't be as robust as looking up the JobID in the environment, but >>> probably good enough for most uses. >>> >>> I would definitely also be in favor of having some way to fall back to >>> procname_uid if the PGID cannot be found, the job environment variable is >>> not available, and there is nothing in nodelocal. >> >> That's simple enough. >> > Cheers, Andreas -- Andreas Dilger Lustre Principal Architect Intel Corporation From andreas.dilger at intel.com Wed Feb 8 00:38:17 2017 From: andreas.dilger at intel.com (Dilger, Andreas) Date: Wed, 8 Feb 2017 00:38:17 +0000 Subject: [lustre-devel] [PATCH 04/24] fs: Provide infrastructure for dynamic BDIs in filesystems In-Reply-To: <20170202173422.3240-5-jack@suse.cz> References: <20170202173422.3240-1-jack@suse.cz> <20170202173422.3240-5-jack@suse.cz> Message-ID: On Feb 2, 2017, at 10:34, Jan Kara wrote: > > Provide helper functions for setting up dynamically allocated > backing_dev_info structures for filesystems and cleaning them up on > superblock destruction. > > CC: linux-mtd at lists.infradead.org > CC: linux-nfs at vger.kernel.org > CC: Petr Vandrovec > CC: linux-nilfs at vger.kernel.org > CC: cluster-devel at redhat.com > CC: osd-dev at open-osd.org > CC: codalist at coda.cs.cmu.edu > CC: linux-afs at lists.infradead.org > CC: ecryptfs at vger.kernel.org > CC: linux-cifs at vger.kernel.org > CC: ceph-devel at vger.kernel.org > CC: linux-btrfs at vger.kernel.org > CC: v9fs-developer at lists.sourceforge.net > CC: lustre-devel at lists.lustre.org > Signed-off-by: Jan Kara > --- > fs/super.c | 49 ++++++++++++++++++++++++++++++++++++++++ > include/linux/backing-dev-defs.h | 2 +- > include/linux/fs.h | 6 +++++ > 3 files changed, 56 insertions(+), 1 deletion(-) > > diff --git a/fs/super.c b/fs/super.c > index ea662b0e5e78..31dc4c6450ef 100644 > --- a/fs/super.c > +++ b/fs/super.c > @@ -446,6 +446,11 @@ void generic_shutdown_super(struct super_block *sb) > hlist_del_init(&sb->s_instances); > spin_unlock(&sb_lock); > up_write(&sb->s_umount); > + if (sb->s_iflags & SB_I_DYNBDI) { > + bdi_put(sb->s_bdi); > + sb->s_bdi = &noop_backing_dev_info; > + sb->s_iflags &= ~SB_I_DYNBDI; > + } > } > > EXPORT_SYMBOL(generic_shutdown_super); > @@ -1249,6 +1254,50 @@ mount_fs(struct file_system_type *type, int flags, const char *name, void *data) > } > > /* > + * Setup private BDI for given superblock. I gets automatically cleaned up (typo) s/I/It/ Looks fine otherwise. > + * in generic_shutdown_super(). > + */ > +int super_setup_bdi_name(struct super_block *sb, char *fmt, ...) > +{ > + struct backing_dev_info *bdi; > + int err; > + va_list args; > + > + bdi = bdi_alloc(GFP_KERNEL); > + if (!bdi) > + return -ENOMEM; > + > + bdi->name = sb->s_type->name; > + > + va_start(args, fmt); > + err = bdi_register_va(bdi, NULL, fmt, args); > + va_end(args); > + if (err) { > + bdi_put(bdi); > + return err; > + } > + WARN_ON(sb->s_bdi != &noop_backing_dev_info); > + sb->s_bdi = bdi; > + sb->s_iflags |= SB_I_DYNBDI; > + > + return 0; > +} > +EXPORT_SYMBOL(super_setup_bdi_name); > + > +/* > + * Setup private BDI for given superblock. I gets automatically cleaned up > + * in generic_shutdown_super(). > + */ > +int super_setup_bdi(struct super_block *sb) > +{ > + static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0); > + > + return super_setup_bdi_name(sb, "%.28s-%ld", sb->s_type->name, > + atomic_long_inc_return(&bdi_seq)); > +} > +EXPORT_SYMBOL(super_setup_bdi); > + > +/* > * This is an internal function, please use sb_end_{write,pagefault,intwrite} > * instead. > */ > diff --git a/include/linux/backing-dev-defs.h b/include/linux/backing-dev-defs.h > index 2ecafc8a2d06..70080b4217f4 100644 > --- a/include/linux/backing-dev-defs.h > +++ b/include/linux/backing-dev-defs.h > @@ -143,7 +143,7 @@ struct backing_dev_info { > congested_fn *congested_fn; /* Function pointer if device is md/dm */ > void *congested_data; /* Pointer to aux data for congested func */ > > - char *name; > + const char *name; > > struct kref refcnt; /* Reference counter for the structure */ > unsigned int registered:1; /* Is bdi registered? */ > diff --git a/include/linux/fs.h b/include/linux/fs.h > index c930cbc19342..8ed8b6d1bc54 100644 > --- a/include/linux/fs.h > +++ b/include/linux/fs.h > @@ -1267,6 +1267,9 @@ struct mm_struct; > /* sb->s_iflags to limit user namespace mounts */ > #define SB_I_USERNS_VISIBLE 0x00000010 /* fstype already mounted */ > > +/* Temporary flag until all filesystems are converted to dynamic bdis */ > +#define SB_I_DYNBDI 0x00000100 > + > /* Possible states of 'frozen' field */ > enum { > SB_UNFROZEN = 0, /* FS is unfrozen */ > @@ -2103,6 +2106,9 @@ extern int vfs_ustat(dev_t, struct kstatfs *); > extern int freeze_super(struct super_block *super); > extern int thaw_super(struct super_block *super); > extern bool our_mnt(struct vfsmount *mnt); > +extern __printf(2, 3) > +int super_setup_bdi_name(struct super_block *sb, char *fmt, ...); > +extern int super_setup_bdi(struct super_block *sb); > > extern int current_umask(void); > > -- > 2.10.2 > > _______________________________________________ > lustre-devel mailing list > lustre-devel at lists.lustre.org > http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org Cheers, Andreas -- Andreas Dilger Lustre Principal Architect Intel Corporation From andreas.dilger at intel.com Wed Feb 8 00:38:58 2017 From: andreas.dilger at intel.com (Dilger, Andreas) Date: Wed, 8 Feb 2017 00:38:58 +0000 Subject: [lustre-devel] [PATCH 06/24] lustre: Convert to separately allocated bdi In-Reply-To: <20170202173422.3240-7-jack@suse.cz> References: <20170202173422.3240-1-jack@suse.cz> <20170202173422.3240-7-jack@suse.cz> Message-ID: <4CFDE4F9-4A4C-4A69-A3C5-AAEA1641D3CF@intel.com> On Feb 2, 2017, at 10:34, Jan Kara wrote: > > Allocate struct backing_dev_info separately instead of embedding it > inside superblock. This unifies handling of bdi among users. > > CC: Oleg Drokin > CC: Andreas Dilger > CC: James Simmons > CC: lustre-devel at lists.lustre.org > Signed-off-by: Jan Kara Reviewed-by: Andreas Dilger > --- > .../staging/lustre/lustre/include/lustre_disk.h | 4 ---- > drivers/staging/lustre/lustre/llite/llite_lib.c | 24 +++------------------- > 2 files changed, 3 insertions(+), 25 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/include/lustre_disk.h b/drivers/staging/lustre/lustre/include/lustre_disk.h > index 8886458748c1..a676bccabd43 100644 > --- a/drivers/staging/lustre/lustre/include/lustre_disk.h > +++ b/drivers/staging/lustre/lustre/include/lustre_disk.h > @@ -133,13 +133,9 @@ struct lustre_sb_info { > struct obd_export *lsi_osd_exp; > char lsi_osd_type[16]; > char lsi_fstype[16]; > - struct backing_dev_info lsi_bdi; /* each client mountpoint needs > - * own backing_dev_info > - */ > }; > > #define LSI_UMOUNT_FAILOVER 0x00200000 > -#define LSI_BDI_INITIALIZED 0x00400000 > > #define s2lsi(sb) ((struct lustre_sb_info *)((sb)->s_fs_info)) > #define s2lsi_nocast(sb) ((sb)->s_fs_info) > diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c > index 25f5aed97f63..4f07d2e60d40 100644 > --- a/drivers/staging/lustre/lustre/llite/llite_lib.c > +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c > @@ -861,15 +861,6 @@ void ll_lli_init(struct ll_inode_info *lli) > mutex_init(&lli->lli_layout_mutex); > } > > -static inline int ll_bdi_register(struct backing_dev_info *bdi) > -{ > - static atomic_t ll_bdi_num = ATOMIC_INIT(0); > - > - bdi->name = "lustre"; > - return bdi_register(bdi, NULL, "lustre-%d", > - atomic_inc_return(&ll_bdi_num)); > -} > - > int ll_fill_super(struct super_block *sb, struct vfsmount *mnt) > { > struct lustre_profile *lprof = NULL; > @@ -879,6 +870,7 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt) > char *profilenm = get_profile_name(sb); > struct config_llog_instance *cfg; > int err; > + static atomic_t ll_bdi_num = ATOMIC_INIT(0); > > CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb); > > @@ -901,16 +893,11 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt) > if (err) > goto out_free; > > - err = bdi_init(&lsi->lsi_bdi); > - if (err) > - goto out_free; > - lsi->lsi_flags |= LSI_BDI_INITIALIZED; > - lsi->lsi_bdi.capabilities = 0; > - err = ll_bdi_register(&lsi->lsi_bdi); > + err = super_setup_bdi_name(sb, "lustre-%d", > + atomic_inc_return(&ll_bdi_num)); > if (err) > goto out_free; > > - sb->s_bdi = &lsi->lsi_bdi; > /* kernel >= 2.6.38 store dentry operations in sb->s_d_op. */ > sb->s_d_op = &ll_d_ops; > > @@ -1031,11 +1018,6 @@ void ll_put_super(struct super_block *sb) > if (profilenm) > class_del_profile(profilenm); > > - if (lsi->lsi_flags & LSI_BDI_INITIALIZED) { > - bdi_destroy(&lsi->lsi_bdi); > - lsi->lsi_flags &= ~LSI_BDI_INITIALIZED; > - } > - > ll_free_sbi(sb); > lsi->lsi_llsbi = NULL; > > -- > 2.10.2 > > _______________________________________________ > lustre-devel mailing list > lustre-devel at lists.lustre.org > http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org Cheers, Andreas -- Andreas Dilger Lustre Principal Architect Intel Corporation From andreas.dilger at intel.com Wed Feb 8 01:04:52 2017 From: andreas.dilger at intel.com (Dilger, Andreas) Date: Wed, 8 Feb 2017 01:04:52 +0000 Subject: [lustre-devel] [PATCH 10/60] staging: lustre: obdclass: add more info to sysfs version string In-Reply-To: <20170203103304.GA2600@kroah.com> References: <1485648328-2141-1-git-send-email-jsimmons@infradead.org> <1485648328-2141-11-git-send-email-jsimmons@infradead.org> <20170203103304.GA2600@kroah.com> Message-ID: > On Feb 3, 2017, at 03:33, Greg Kroah-Hartman wrote: > > On Sat, Jan 28, 2017 at 07:04:38PM -0500, James Simmons wrote: >> From: Andreas Dilger >> >> Update the sysfs "version" file to print "lustre: " with >> the version number. >> >> Signed-off-by: Andreas Dilger >> Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5969 >> Reviewed-on: http://review.whamcloud.com/16721 >> Reviewed-by: James Simmons >> Reviewed-by: Dmitry Eremin >> Reviewed-by: Oleg Drokin >> Signed-off-by: James Simmons >> --- >> drivers/staging/lustre/lustre/obdclass/linux/linux-module.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c >> index 9f5e829..22e6d1f 100644 >> --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c >> +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c >> @@ -208,7 +208,7 @@ struct miscdevice obd_psdev = { >> static ssize_t version_show(struct kobject *kobj, struct attribute *attr, >> char *buf) >> { >> - return sprintf(buf, "%s\n", LUSTRE_VERSION_STRING); >> + return sprintf(buf, "lustre: %s\n", LUSTRE_VERSION_STRING); >> } > > Why? You "know" this is lustre, why say it again? Doesn't this affect > userspace tools? It included "lustre: " as a prefix until commit 8b8284450569 when the code moved from /proc to /sys, and is what the userspace tools expect. Formerly there were multiple strings printed in this file, each with a different prefix, but the "lustre: " prefix was dropped in the move to sysfs. That didn't matter until a userspace patch to stop using ioctl(IOC_GET_VERSION) and instead get the version from the existing /proc or /sys files, so that we can deprecate and eventually drop the IOC_GET_VERSION ioctl completely. So this patch is returning to the previous format of the /proc file, but if there is a big objection to this patch we can also change the userspace tools to live with or without this prefix now that there is only a single value here. Cheers, Andreas -- Andreas Dilger Lustre Principal Architect Intel Corporation From viro at ZenIV.linux.org.uk Wed Feb 8 05:54:32 2017 From: viro at ZenIV.linux.org.uk (Al Viro) Date: Wed, 8 Feb 2017 05:54:32 +0000 Subject: [lustre-devel] [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call In-Reply-To: <20170207113554.GA30656@veci.piliscsaba.szeredi.hu> References: <20170205210151.GD13195@ZenIV.linux.org.uk> <20170205220445.GE13195@ZenIV.linux.org.uk> <20170206030532.GF13195@ZenIV.linux.org.uk> <20170206095706.GG13195@ZenIV.linux.org.uk> <20170207071909.GI13195@ZenIV.linux.org.uk> <20170207113554.GA30656@veci.piliscsaba.szeredi.hu> Message-ID: <20170208055431.GJ13195@ZenIV.linux.org.uk> On Tue, Feb 07, 2017 at 12:35:54PM +0100, Miklos Szeredi wrote: > > Another thing: what guarantees that places in writepages-related paths > > where we store a reference into req->ff won't hit a request with already > > non-NULL ->ff? > > Well, it is set before being sent (queued onto queued_writes or queued on the > fuse device), but not when queued as secondary request onto an already in-flight > one. It looks okay to me. > void fuse_sync_release(struct fuse_file *ff, int flags) > { > - WARN_ON(atomic_read(&ff->count) > 1); > + WARN_ON(atomic_read(&ff->count) != 1); > fuse_prepare_release(ff, flags, FUSE_RELEASE); > - __set_bit(FR_FORCE, &ff->reserved_req->flags); > - __clear_bit(FR_BACKGROUND, &ff->reserved_req->flags); > - fuse_request_send(ff->fc, ff->reserved_req); > - fuse_put_request(ff->fc, ff->reserved_req); > - kfree(ff); > + fuse_file_put(ff, true); Umm... At the very least, that deserves a comment re "iput(NULL) is a no-op and since the refcount is 1 and everything's synchronous, we are fine with not doing igrab/iput here". There's enough mysteries in that code as it is... Speaking of mysteries - how can ->private_data ever be NULL in fuse_release_common()? AFAICS, it's only called from ->release() instances and those are only called after ->open() or ->atomic_open() on that struct file has returned 0. On the ->open() side, it means fuse_do_open() having returned 0; on ->atomic_open() one - fuse_create_open() having done the same. Neither is possible with ->private_data remaining NULL, and I don't see any places that would modify it afterwards... Another thing: am I right assuming that ff->nodeid will be the same for all ff over given inode (== get_node_id(inode))? What about ff->fh? Is that a per-open thing, or will it be identical for all opens of the same inode? From gregkh at linuxfoundation.org Wed Feb 8 06:27:20 2017 From: gregkh at linuxfoundation.org (Greg Kroah-Hartman) Date: Wed, 8 Feb 2017 07:27:20 +0100 Subject: [lustre-devel] [PATCH 10/60] staging: lustre: obdclass: add more info to sysfs version string In-Reply-To: References: <1485648328-2141-1-git-send-email-jsimmons@infradead.org> <1485648328-2141-11-git-send-email-jsimmons@infradead.org> <20170203103304.GA2600@kroah.com> Message-ID: <20170208062720.GA24445@kroah.com> On Wed, Feb 08, 2017 at 01:04:52AM +0000, Dilger, Andreas wrote: > > > On Feb 3, 2017, at 03:33, Greg Kroah-Hartman wrote: > > > > On Sat, Jan 28, 2017 at 07:04:38PM -0500, James Simmons wrote: > >> From: Andreas Dilger > >> > >> Update the sysfs "version" file to print "lustre: " with > >> the version number. > >> > >> Signed-off-by: Andreas Dilger > >> Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5969 > >> Reviewed-on: http://review.whamcloud.com/16721 > >> Reviewed-by: James Simmons > >> Reviewed-by: Dmitry Eremin > >> Reviewed-by: Oleg Drokin > >> Signed-off-by: James Simmons > >> --- > >> drivers/staging/lustre/lustre/obdclass/linux/linux-module.c | 2 +- > >> 1 file changed, 1 insertion(+), 1 deletion(-) > >> > >> diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c > >> index 9f5e829..22e6d1f 100644 > >> --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c > >> +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c > >> @@ -208,7 +208,7 @@ struct miscdevice obd_psdev = { > >> static ssize_t version_show(struct kobject *kobj, struct attribute *attr, > >> char *buf) > >> { > >> - return sprintf(buf, "%s\n", LUSTRE_VERSION_STRING); > >> + return sprintf(buf, "lustre: %s\n", LUSTRE_VERSION_STRING); > >> } > > > > Why? You "know" this is lustre, why say it again? Doesn't this affect > > userspace tools? > > It included "lustre: " as a prefix until commit 8b8284450569 when the code > moved from /proc to /sys, and is what the userspace tools expect. Formerly > there were multiple strings printed in this file, each with a different prefix, > but the "lustre: " prefix was dropped in the move to sysfs. > > That didn't matter until a userspace patch to stop using ioctl(IOC_GET_VERSION) > and instead get the version from the existing /proc or /sys files, so that we > can deprecate and eventually drop the IOC_GET_VERSION ioctl completely. > > So this patch is returning to the previous format of the /proc file, but if > there is a big objection to this patch we can also change the userspace tools > to live with or without this prefix now that there is only a single value here. Think about it, it's a sysfs file, which should only have one value to start with, and you are opening it from userspace knowing exactly where it is (somewhere in the lustre subtree), so of course you know it is "lustre"... greg k-h From jack at suse.cz Thu Feb 9 12:12:12 2017 From: jack at suse.cz (Jan Kara) Date: Thu, 9 Feb 2017 13:12:12 +0100 Subject: [lustre-devel] [PATCH 04/24] fs: Provide infrastructure for dynamic BDIs in filesystems In-Reply-To: References: <20170202173422.3240-1-jack@suse.cz> <20170202173422.3240-5-jack@suse.cz> Message-ID: <20170209121212.GD16825@quack2.suse.cz> > > @@ -1249,6 +1254,50 @@ mount_fs(struct file_system_type *type, int flags, const char *name, void *data) > > } > > > > /* > > + * Setup private BDI for given superblock. I gets automatically cleaned up > > (typo) s/I/It/ > > Looks fine otherwise. Thanks, fixed. Honza -- Jan Kara SUSE Labs, CR From jsimmons at infradead.org Sat Feb 11 17:12:22 2017 From: jsimmons at infradead.org (James Simmons) Date: Sat, 11 Feb 2017 17:12:22 +0000 (GMT) Subject: [lustre-devel] [PATCH 05/60] staging: lustre: llite: check request != NULL in ll_migrate In-Reply-To: <20170130113423.GB6881@mwanda> References: <1485648328-2141-1-git-send-email-jsimmons@infradead.org> <1485648328-2141-6-git-send-email-jsimmons@infradead.org> <20170130113423.GB6881@mwanda> Message-ID: > On Sat, Jan 28, 2017 at 07:04:33PM -0500, James Simmons wrote: > > From: wang di > > > > Check if the request is NULL, before retrieve reply body > > from the request. > > > > Signed-off-by: wang di > > Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7396 > > Reviewed-on: http://review.whamcloud.com/17079 > > Reviewed-by: John L. Hammond > > Reviewed-by: Andreas Dilger > > Signed-off-by: James Simmons > > --- > > drivers/staging/lustre/lustre/llite/file.c | 41 +++++++++++++++++------------- > > 1 file changed, 23 insertions(+), 18 deletions(-) > > > > diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c > > index a1e51a5..b681e15 100644 > > --- a/drivers/staging/lustre/lustre/llite/file.c > > +++ b/drivers/staging/lustre/lustre/llite/file.c > > @@ -2656,28 +2656,33 @@ int ll_migrate(struct inode *parent, struct file *file, int mdtidx, > > if (!rc) > > ll_update_times(request, parent); > > > > I don't like how we return a non-NULL request on many error paths. It > would be simpler to understand if mdc_rename() freed request on error. > So mdc_reint() fails but we still continue? I don't understand that but > there are no comments about it. > > > > - body = req_capsule_server_get(&request->rq_pill, &RMF_MDT_BODY); > > - if (!body) { > > - rc = -EPROTO; > > - goto out_free; > > - } > > + if (request) { > > + body = req_capsule_server_get(&request->rq_pill, &RMF_MDT_BODY); > > + if (!body) { > > + rc = -EPROTO; > > + goto out_free; > > We should call ptlrpc_req_finished(request) before returning on this > path. Their are more patches coming that fix the issues you pointed out. Its just I have been pushing patches that are order independent first. I will push out the patches to address other issues with ll_migrate(). From jsimmons at infradead.org Sat Feb 11 17:12:36 2017 From: jsimmons at infradead.org (James Simmons) Date: Sat, 11 Feb 2017 12:12:36 -0500 Subject: [lustre-devel] [PATCH 0/3] staging: lustre: llite: fixups for ll_migrate() Message-ID: <1486833159-16251-1-git-send-email-jsimmons@infradead.org> This patch series covers all the current fixes for the function ll_migrate(). Originally only the first patch was submitted but it was pointed out other flaws existed in the code. Two more patches that cover those flaws are included in this patch set. These patches are order dependent. Niu Yawei (1): staging: lustre: llite: check reply status in ll_migrate() wang di (2): staging: lustre: llite: check request != NULL in ll_migrate staging: lustre: llite: root inode checking for migration drivers/staging/lustre/lustre/llite/file.c | 63 ++++++++++++++++-------------- 1 file changed, 34 insertions(+), 29 deletions(-) -- 1.8.3.1 From jsimmons at infradead.org Sat Feb 11 17:12:37 2017 From: jsimmons at infradead.org (James Simmons) Date: Sat, 11 Feb 2017 12:12:37 -0500 Subject: [lustre-devel] [PATCH 1/3] staging: lustre: llite: check request != NULL in ll_migrate In-Reply-To: <1486833159-16251-1-git-send-email-jsimmons@infradead.org> References: <1486833159-16251-1-git-send-email-jsimmons@infradead.org> Message-ID: <1486833159-16251-2-git-send-email-jsimmons@infradead.org> From: wang di Check if the request is NULL, before retrieve reply body from the request. Signed-off-by: wang di Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7396 Reviewed-on: http://review.whamcloud.com/17079 Reviewed-by: John L. Hammond Reviewed-by: Andreas Dilger Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/file.c | 41 +++++++++++++++++------------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 9870901..0c83bd7 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -2667,28 +2667,33 @@ int ll_migrate(struct inode *parent, struct file *file, int mdtidx, if (!rc) ll_update_times(request, parent); - body = req_capsule_server_get(&request->rq_pill, &RMF_MDT_BODY); - if (!body) { - rc = -EPROTO; - goto out_free; - } + if (request) { + body = req_capsule_server_get(&request->rq_pill, &RMF_MDT_BODY); + if (!body) { + rc = -EPROTO; + goto out_free; + } - /* - * If the server does release layout lock, then we cleanup - * the client och here, otherwise release it in out_free: - */ - if (och && body->mbo_valid & OBD_MD_CLOSE_INTENT_EXECED) { - obd_mod_put(och->och_mod); - md_clear_open_replay_data(ll_i2sbi(parent)->ll_md_exp, och); - och->och_fh.cookie = DEAD_HANDLE_MAGIC; - kfree(och); - och = NULL; - } + /* + * If the server does release layout lock, then we cleanup + * the client och here, otherwise release it in out_free: + */ + if (och && body->mbo_valid & OBD_MD_CLOSE_INTENT_EXECED) { + obd_mod_put(och->och_mod); + md_clear_open_replay_data(ll_i2sbi(parent)->ll_md_exp, + och); + och->och_fh.cookie = DEAD_HANDLE_MAGIC; + kfree(och); + och = NULL; + } - ptlrpc_req_finished(request); + ptlrpc_req_finished(request); + } /* Try again if the file layout has changed. */ - if (rc == -EAGAIN && S_ISREG(child_inode->i_mode)) + if (rc == -EAGAIN && S_ISREG(child_inode->i_mode)) { + request = NULL; goto again; + } out_free: if (child_inode) { if (och) /* close the file */ -- 1.8.3.1 From jsimmons at infradead.org Sat Feb 11 17:12:38 2017 From: jsimmons at infradead.org (James Simmons) Date: Sat, 11 Feb 2017 12:12:38 -0500 Subject: [lustre-devel] [PATCH 2/3] staging: lustre: llite: root inode checking for migration In-Reply-To: <1486833159-16251-1-git-send-email-jsimmons@infradead.org> References: <1486833159-16251-1-git-send-email-jsimmons@infradead.org> Message-ID: <1486833159-16251-3-git-send-email-jsimmons@infradead.org> From: wang di Do not migrate root inode. Signed-off-by: wang di Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7577 Reviewed-on: http://review.whamcloud.com/17669 Reviewed-by: Lai Siyao Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/file.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 0c83bd7..271608d 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -2626,18 +2626,18 @@ int ll_migrate(struct inode *parent, struct file *file, int mdtidx, ll_get_fsname(parent->i_sb, NULL, 0), name, PFID(&op_data->op_fid3)); rc = -EINVAL; - goto out_free; + goto out_unlock; } rc = ll_get_mdt_idx_by_fid(ll_i2sbi(parent), &op_data->op_fid3); if (rc < 0) - goto out_free; + goto out_unlock; if (rc == mdtidx) { CDEBUG(D_INFO, "%s:"DFID" is already on MDT%d.\n", name, PFID(&op_data->op_fid3), mdtidx); rc = 0; - goto out_free; + goto out_unlock; } again: if (S_ISREG(child_inode->i_mode)) { @@ -2645,13 +2645,13 @@ int ll_migrate(struct inode *parent, struct file *file, int mdtidx, if (IS_ERR(och)) { rc = PTR_ERR(och); och = NULL; - goto out_free; + goto out_unlock; } rc = ll_data_version(child_inode, &data_version, LL_DV_WR_FLUSH); if (rc) - goto out_free; + goto out_close; op_data->op_handle = och->och_fh; op_data->op_data = och->och_mod; @@ -2671,12 +2671,12 @@ int ll_migrate(struct inode *parent, struct file *file, int mdtidx, body = req_capsule_server_get(&request->rq_pill, &RMF_MDT_BODY); if (!body) { rc = -EPROTO; - goto out_free; + goto out_close; } /* * If the server does release layout lock, then we cleanup - * the client och here, otherwise release it in out_free: + * the client och here, otherwise release it in out_close: */ if (och && body->mbo_valid & OBD_MD_CLOSE_INTENT_EXECED) { obd_mod_put(och->och_mod); @@ -2694,15 +2694,15 @@ int ll_migrate(struct inode *parent, struct file *file, int mdtidx, request = NULL; goto again; } -out_free: - if (child_inode) { - if (och) /* close the file */ - ll_lease_close(och, child_inode, NULL); +out_close: + if (och) /* close the file */ + ll_lease_close(och, child_inode, NULL); + if (!rc) clear_nlink(child_inode); - inode_unlock(child_inode); - iput(child_inode); - } - +out_unlock: + inode_unlock(child_inode); + iput(child_inode); +out_free: ll_finish_md_op_data(op_data); return rc; } -- 1.8.3.1 From jsimmons at infradead.org Sat Feb 11 17:12:39 2017 From: jsimmons at infradead.org (James Simmons) Date: Sat, 11 Feb 2017 12:12:39 -0500 Subject: [lustre-devel] [PATCH 3/3] staging: lustre: llite: check reply status in ll_migrate() In-Reply-To: <1486833159-16251-1-git-send-email-jsimmons@infradead.org> References: <1486833159-16251-1-git-send-email-jsimmons@infradead.org> Message-ID: <1486833159-16251-4-git-send-email-jsimmons@infradead.org> From: Niu Yawei ll_migrate() should check reply status before trying to read reply buffer, checking if request is NULL doesn't make sense. Signed-off-by: Niu Yawei Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8807 Reviewed-on: https://review.whamcloud.com/23666 Reviewed-by: Andreas Dilger Reviewed-by: Lai Siyao Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/file.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 271608d..10adfcd 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -2664,15 +2664,12 @@ int ll_migrate(struct inode *parent, struct file *file, int mdtidx, op_data->op_cli_flags = CLI_MIGRATE; rc = md_rename(ll_i2sbi(parent)->ll_md_exp, op_data, name, namelen, name, namelen, &request); - if (!rc) + if (!rc) { + LASSERT(request); ll_update_times(request, parent); - if (request) { body = req_capsule_server_get(&request->rq_pill, &RMF_MDT_BODY); - if (!body) { - rc = -EPROTO; - goto out_close; - } + LASSERT(body); /* * If the server does release layout lock, then we cleanup @@ -2686,14 +2683,17 @@ int ll_migrate(struct inode *parent, struct file *file, int mdtidx, kfree(och); och = NULL; } + } + if (request) { ptlrpc_req_finished(request); + request = NULL; } + /* Try again if the file layout has changed. */ - if (rc == -EAGAIN && S_ISREG(child_inode->i_mode)) { - request = NULL; + if (rc == -EAGAIN && S_ISREG(child_inode->i_mode)) goto again; - } + out_close: if (och) /* close the file */ ll_lease_close(och, child_inode, NULL); -- 1.8.3.1 From doug.s.oucharek at intel.com Sun Feb 12 06:56:29 2017 From: doug.s.oucharek at intel.com (Doug Oucharek) Date: Sat, 11 Feb 2017 22:56:29 -0800 Subject: [lustre-devel] [PATCH] staging: lustre: ko2iblnd: Adapt to the removal of ib_get_dma_mr() Message-ID: <1486882589-648-1-git-send-email-doug.s.oucharek@intel.com> In Linux kernel 4.9-rc1, the function ib_get_dma_mr() was removed and a second parameter was added to ib_alloc_pd(). As this broke the building of the ko2iblnd module in staging, the Kconfig for LNet has marked ko2iblnd as broken and stopped building it. This patch fixes this breakage by: - Removing the BROKEN tag from lnet/Kconfig. - Make it so the module parameter map_on_demand can no longer be zero (we have to configure FMR/FastReg pools; it can no longer be off). - No longer try to use the global DMA memory region, but make use of the FMR/FastReg pool for all RDMA Tx operations. - Everywhere we are using the device DMA mr to derive the L-key for non-registered memory regions, use the pd->local_dma_lkey value instead. - Make the default map_on_demand = 256. This will allow nodes with this patch to still connected to older nodes without this patch and FMR/FastReg turned off. When FMR/FastReg is turned off, we use 256 as the max frags so the two sides will still be able to communicate and work. Signed-off-by: Doug Oucharek Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-9026 --- drivers/staging/lustre/lnet/Kconfig | 1 - .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 69 +--------------------- .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h | 3 - .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 17 +----- .../lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c | 12 ++-- 5 files changed, 12 insertions(+), 90 deletions(-) diff --git a/drivers/staging/lustre/lnet/Kconfig b/drivers/staging/lustre/lnet/Kconfig index 13b4327..2b59301 100644 --- a/drivers/staging/lustre/lnet/Kconfig +++ b/drivers/staging/lustre/lnet/Kconfig @@ -35,7 +35,6 @@ config LNET_SELFTEST config LNET_XPRT_IB tristate "LNET infiniband support" depends on LNET && INFINIBAND && INFINIBAND_ADDR_TRANS - depends on BROKEN default LNET && INFINIBAND help This option allows the LNET users to use infiniband as an diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c index b1e8508..d39ba14 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c @@ -1281,27 +1281,6 @@ static void kiblnd_map_tx_pool(struct kib_tx_pool *tpo) } } -struct ib_mr *kiblnd_find_rd_dma_mr(struct lnet_ni *ni, struct kib_rdma_desc *rd, - int negotiated_nfrags) -{ - struct kib_net *net = ni->ni_data; - struct kib_hca_dev *hdev = net->ibn_dev->ibd_hdev; - struct lnet_ioctl_config_o2iblnd_tunables *tunables; - __u16 nfrags; - int mod; - - tunables = &ni->ni_lnd_tunables->lt_tun_u.lt_o2ib; - mod = tunables->lnd_map_on_demand; - nfrags = (negotiated_nfrags != -1) ? negotiated_nfrags : mod; - - LASSERT(hdev->ibh_mrs); - - if (mod > 0 && nfrags <= rd->rd_nfrags) - return NULL; - - return hdev->ibh_mrs; -} - static void kiblnd_destroy_fmr_pool(struct kib_fmr_pool *fpo) { LASSERT(!fpo->fpo_map_count); @@ -2168,21 +2147,12 @@ static int kiblnd_net_init_pools(struct kib_net *net, lnet_ni_t *ni, __u32 *cpts int ncpts) { struct lnet_ioctl_config_o2iblnd_tunables *tunables; - unsigned long flags; int cpt; int rc; int i; tunables = &ni->ni_lnd_tunables->lt_tun_u.lt_o2ib; - read_lock_irqsave(&kiblnd_data.kib_global_lock, flags); - if (!tunables->lnd_map_on_demand) { - read_unlock_irqrestore(&kiblnd_data.kib_global_lock, flags); - goto create_tx_pool; - } - - read_unlock_irqrestore(&kiblnd_data.kib_global_lock, flags); - if (tunables->lnd_fmr_pool_size < *kiblnd_tunables.kib_ntx / 4) { CERROR("Can't set fmr pool size (%d) < ntx / 4(%d)\n", tunables->lnd_fmr_pool_size, @@ -2227,7 +2197,6 @@ static int kiblnd_net_init_pools(struct kib_net *net, lnet_ni_t *ni, __u32 *cpts if (i > 0) LASSERT(i == ncpts); - create_tx_pool: /* * cfs_precpt_alloc is creating an array of struct kib_tx_poolset * The number of struct kib_tx_poolsets create is equal to the @@ -2283,20 +2252,8 @@ static int kiblnd_hdev_get_attr(struct kib_hca_dev *hdev) return -EINVAL; } -static void kiblnd_hdev_cleanup_mrs(struct kib_hca_dev *hdev) -{ - if (!hdev->ibh_mrs) - return; - - ib_dereg_mr(hdev->ibh_mrs); - - hdev->ibh_mrs = NULL; -} - void kiblnd_hdev_destroy(struct kib_hca_dev *hdev) { - kiblnd_hdev_cleanup_mrs(hdev); - if (hdev->ibh_pd) ib_dealloc_pd(hdev->ibh_pd); @@ -2306,28 +2263,6 @@ void kiblnd_hdev_destroy(struct kib_hca_dev *hdev) LIBCFS_FREE(hdev, sizeof(*hdev)); } -static int kiblnd_hdev_setup_mrs(struct kib_hca_dev *hdev) -{ - struct ib_mr *mr; - int rc; - int acflags = IB_ACCESS_LOCAL_WRITE | IB_ACCESS_REMOTE_WRITE; - - rc = kiblnd_hdev_get_attr(hdev); - if (rc) - return rc; - - mr = ib_get_dma_mr(hdev->ibh_pd, acflags); - if (IS_ERR(mr)) { - CERROR("Failed ib_get_dma_mr : %ld\n", PTR_ERR(mr)); - kiblnd_hdev_cleanup_mrs(hdev); - return PTR_ERR(mr); - } - - hdev->ibh_mrs = mr; - - return 0; -} - /* DUMMY */ static int kiblnd_dummy_callback(struct rdma_cm_id *cmid, struct rdma_cm_event *event) @@ -2482,9 +2417,9 @@ int kiblnd_dev_failover(struct kib_dev *dev) goto out; } - rc = kiblnd_hdev_setup_mrs(hdev); + rc = kiblnd_hdev_get_attr(hdev); if (rc) { - CERROR("Can't setup device: %d\n", rc); + CERROR("Can't get device attributes: %d\n", rc); goto out; } diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h index 2cb4298..366372d 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h @@ -172,7 +172,6 @@ struct kib_hca_dev { __u64 ibh_page_mask; /* page mask of current HCA */ int ibh_mr_shift; /* bits shift of max MR size */ __u64 ibh_mr_size; /* size of MR */ - struct ib_mr *ibh_mrs; /* global MR */ struct ib_pd *ibh_pd; /* PD */ struct kib_dev *ibh_dev; /* owner */ atomic_t ibh_ref; /* refcount */ @@ -978,8 +977,6 @@ static inline unsigned int kiblnd_sg_dma_len(struct ib_device *dev, #define KIBLND_CONN_PARAM(e) ((e)->param.conn.private_data) #define KIBLND_CONN_PARAM_LEN(e) ((e)->param.conn.private_data_len) -struct ib_mr *kiblnd_find_rd_dma_mr(struct lnet_ni *ni, struct kib_rdma_desc *rd, - int negotiated_nfrags); void kiblnd_map_rx_descs(struct kib_conn *conn); void kiblnd_unmap_rx_descs(struct kib_conn *conn); void kiblnd_pool_free_node(struct kib_pool *pool, struct list_head *node); diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c index e2f3f72..6eaa548 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c @@ -157,7 +157,6 @@ static int kiblnd_init_rdma(struct kib_conn *conn, struct kib_tx *tx, int type, struct kib_conn *conn = rx->rx_conn; struct kib_net *net = conn->ibc_peer->ibp_ni->ni_data; struct ib_recv_wr *bad_wrq = NULL; - struct ib_mr *mr = conn->ibc_hdev->ibh_mrs; int rc; LASSERT(net); @@ -165,9 +164,8 @@ static int kiblnd_init_rdma(struct kib_conn *conn, struct kib_tx *tx, int type, LASSERT(credit == IBLND_POSTRX_NO_CREDIT || credit == IBLND_POSTRX_PEER_CREDIT || credit == IBLND_POSTRX_RSRVD_CREDIT); - LASSERT(mr); - rx->rx_sge.lkey = mr->lkey; + rx->rx_sge.lkey = conn->ibc_hdev->ibh_pd->local_dma_lkey; rx->rx_sge.addr = rx->rx_msgaddr; rx->rx_sge.length = IBLND_MSG_SIZE; @@ -613,7 +611,6 @@ static int kiblnd_map_tx(lnet_ni_t *ni, struct kib_tx *tx, struct kib_rdma_desc { struct kib_net *net = ni->ni_data; struct kib_hca_dev *hdev = net->ibn_dev->ibd_hdev; - struct ib_mr *mr = NULL; __u32 nob; int i; @@ -635,14 +632,6 @@ static int kiblnd_map_tx(lnet_ni_t *ni, struct kib_tx *tx, struct kib_rdma_desc nob += rd->rd_frags[i].rf_nob; } - mr = kiblnd_find_rd_dma_mr(ni, rd, tx->tx_conn ? - tx->tx_conn->ibc_max_frags : -1); - if (mr) { - /* found pre-mapping MR */ - rd->rd_key = (rd != tx->tx_rd) ? mr->rkey : mr->lkey; - return 0; - } - if (net->ibn_fmr_ps) return kiblnd_fmr_map_tx(net, tx, rd, nob); @@ -1028,16 +1017,14 @@ static int kiblnd_map_tx(lnet_ni_t *ni, struct kib_tx *tx, struct kib_rdma_desc struct ib_sge *sge = &tx->tx_sge[tx->tx_nwrq]; struct ib_rdma_wr *wrq = &tx->tx_wrq[tx->tx_nwrq]; int nob = offsetof(struct kib_msg, ibm_u) + body_nob; - struct ib_mr *mr = hdev->ibh_mrs; LASSERT(tx->tx_nwrq >= 0); LASSERT(tx->tx_nwrq < IBLND_MAX_RDMA_FRAGS + 1); LASSERT(nob <= IBLND_MSG_SIZE); - LASSERT(mr); kiblnd_init_msg(tx->tx_msg, type, body_nob); - sge->lkey = mr->lkey; + sge->lkey = hdev->ibh_pd->local_dma_lkey; sge->addr = tx->tx_msgaddr; sge->length = nob; diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c index 44e960f..3c81b527 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c @@ -106,7 +106,8 @@ module_param(concurrent_sends, int, 0444); MODULE_PARM_DESC(concurrent_sends, "send work-queue sizing"); -static int map_on_demand; +#define IBLND_DEFAULT_MAP_ON_DEMAND IBLND_MAX_RDMA_FRAGS +static int map_on_demand = IBLND_DEFAULT_MAP_ON_DEMAND; module_param(map_on_demand, int, 0444); MODULE_PARM_DESC(map_on_demand, "map on demand"); @@ -228,10 +229,13 @@ int kiblnd_tunables_setup(struct lnet_ni *ni) if (tunables->lnd_peercredits_hiw >= ni->ni_peertxcredits) tunables->lnd_peercredits_hiw = ni->ni_peertxcredits - 1; - if (tunables->lnd_map_on_demand < 0 || + if (tunables->lnd_map_on_demand <= 0 || tunables->lnd_map_on_demand > IBLND_MAX_RDMA_FRAGS) { - /* disable map-on-demand */ - tunables->lnd_map_on_demand = 0; + /* Use the default */ + CWARN("Invalid map_on_demand (%d), expects 1 - %d. Using default of %d\n", + tunables->lnd_map_on_demand, + IBLND_MAX_RDMA_FRAGS, IBLND_DEFAULT_MAP_ON_DEMAND); + tunables->lnd_map_on_demand = IBLND_DEFAULT_MAP_ON_DEMAND; } if (tunables->lnd_map_on_demand == 1) { -- 1.8.3.1 From gregkh at linuxfoundation.org Sun Feb 12 12:13:01 2017 From: gregkh at linuxfoundation.org (Greg Kroah-Hartman) Date: Sun, 12 Feb 2017 13:13:01 +0100 Subject: [lustre-devel] [PATCH 2/3] staging: lustre: llite: root inode checking for migration In-Reply-To: <1486833159-16251-3-git-send-email-jsimmons@infradead.org> References: <1486833159-16251-1-git-send-email-jsimmons@infradead.org> <1486833159-16251-3-git-send-email-jsimmons@infradead.org> Message-ID: <20170212121301.GA12048@kroah.com> On Sat, Feb 11, 2017 at 12:12:38PM -0500, James Simmons wrote: > From: wang di > > Do not migrate root inode. That says _what_ happens here, but you aren't giving any hint as to _why_ this is needed. I'll take this, but be more careful about your changelog comments in the future... thanks, greg k-h From michael.kuhn at informatik.uni-hamburg.de Mon Feb 13 11:37:51 2017 From: michael.kuhn at informatik.uni-hamburg.de (Michael Kuhn) Date: Mon, 13 Feb 2017 12:37:51 +0100 Subject: [lustre-devel] Failing tests Message-ID: <1486985871.4090.13.camel@informatik.uni-hamburg.de> Dear all, I could not find any information about how to handle failing tests. One of my changes [0] on Gerrit has a failing test [1] that I think is not actually caused by the change itself. Due to this, the change is now marked as "Verified-1". How should I proceed? [0]: https://review.whamcloud.com/#/c/25307/ [1]: https://testing.hpdd.intel.com/test_sessions/93509fd6-ee24-11e6-bbfe-5254006e85c2 Best regards, Michael From paf at cray.com Mon Feb 13 12:34:08 2017 From: paf at cray.com (Patrick Farrell) Date: Mon, 13 Feb 2017 12:34:08 +0000 Subject: [lustre-devel] Failing tests In-Reply-To: <1486985871.4090.13.camel@informatik.uni-hamburg.de> References: <1486985871.4090.13.camel@informatik.uni-hamburg.de> Message-ID: Michael, You can either request someone from Intel re-start the tests (this message to the list may do the trick...), or you can re-submit your patch yourself (Re-make the commit with the same Change ID, etc, and just push again), to restart the test process. (I also concur your patch is unlikely to have caused that test failure.) - Patrick ________________________________ From: lustre-devel on behalf of Michael Kuhn Sent: Monday, February 13, 2017 5:37:51 AM To: lustre-devel at lists.lustre.org Subject: [lustre-devel] Failing tests Dear all, I could not find any information about how to handle failing tests. One of my changes [0] on Gerrit has a failing test [1] that I think is not actually caused by the change itself. Due to this, the change is now marked as "Verified-1". How should I proceed? [0]: https://review.whamcloud.com/#/c/25307/ [1]: https://testing.hpdd.intel.com/test_sessions/93509fd6-ee24-11e6-bbfe-5254006e85c2 Best regards, Michael _______________________________________________ lustre-devel mailing list lustre-devel at lists.lustre.org http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael.kuhn at informatik.uni-hamburg.de Mon Feb 13 12:47:22 2017 From: michael.kuhn at informatik.uni-hamburg.de (Michael Kuhn) Date: Mon, 13 Feb 2017 13:47:22 +0100 Subject: [lustre-devel] Failing tests In-Reply-To: References: <1486985871.4090.13.camel@informatik.uni-hamburg.de> Message-ID: <1486990042.4090.21.camel@informatik.uni-hamburg.de> Hi Patrick, thanks for the quick feedback! > [...] or you can re-submit your patch yourself (Re-make the commit with the same Change ID, etc, and just push again), to restart the test process. This forces all reviewers to redo their reviews, right? (That's why I first wanted to ask whether there was another way.) If this is not seen as a problem, though, I guess this is the easiest way. Best regards, Michael From paf at cray.com Mon Feb 13 13:46:18 2017 From: paf at cray.com (Patrick Farrell) Date: Mon, 13 Feb 2017 13:46:18 +0000 Subject: [lustre-devel] Failing tests In-Reply-To: <1486990042.4090.21.camel@informatik.uni-hamburg.de> References: <1486985871.4090.13.camel@informatik.uni-hamburg.de> , <1486990042.4090.21.camel@informatik.uni-hamburg.de> Message-ID: Unfortunately, that's the case. It's definitely suboptimal. - Patrick ________________________________ From: Michael Kuhn Sent: Monday, February 13, 2017 6:47:22 AM To: Patrick Farrell; lustre-devel at lists.lustre.org Subject: Re: [lustre-devel] Failing tests Hi Patrick, thanks for the quick feedback! > [...] or you can re-submit your patch yourself (Re-make the commit with the same Change ID, etc, and just push again), to restart the test process. This forces all reviewers to redo their reviews, right? (That's why I first wanted to ask whether there was another way.) If this is not seen as a problem, though, I guess this is the easiest way. Best regards, Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: From peter.a.jones at intel.com Mon Feb 13 14:31:06 2017 From: peter.a.jones at intel.com (Jones, Peter A) Date: Mon, 13 Feb 2017 14:31:06 +0000 Subject: [lustre-devel] Failing tests In-Reply-To: <1486985871.4090.13.camel@informatik.uni-hamburg.de> References: <1486985871.4090.13.camel@informatik.uni-hamburg.de> Message-ID: Hi Michael Thanks for speaking up about this. Yes it is possible to re-trigger the tests under such circumstances and we have re-triggered the test for you. Peter On 2/13/17, 3:37 AM, "lustre-devel on behalf of Michael Kuhn" wrote: >Dear all, > >I could not find any information about how to handle failing tests. One >of my changes [0] on Gerrit has a failing test [1] that I think is not >actually caused by the change itself. Due to this, the change is now >marked as "Verified-1". How should I proceed? > >[0]: https://review.whamcloud.com/#/c/25307/ >[1]: >https://testing.hpdd.intel.com/test_sessions/93509fd6-ee24-11e6-bbfe-52540 >06e85c2 > > >Best regards, >Michael >_______________________________________________ >lustre-devel mailing list >lustre-devel at lists.lustre.org >http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org From torvalds at linux-foundation.org Mon Feb 13 21:40:52 2017 From: torvalds at linux-foundation.org (Linus Torvalds) Date: Mon, 13 Feb 2017 13:40:52 -0800 Subject: [lustre-devel] [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call In-Reply-To: <20170213095616.GA18053@linaro.org> References: <20170124212327.14517-1-jlayton@redhat.com> <20170125133205.21704-1-jlayton@redhat.com> <20170202095125.GF27291@ZenIV.linux.org.uk> <20170202105651.GA32111@infradead.org> <20170202111625.GG27291@ZenIV.linux.org.uk> <1486040452.2812.6.camel@redhat.com> <20170203072952.GI27291@ZenIV.linux.org.uk> <20170203190816.GK27291@ZenIV.linux.org.uk> <20170213095616.GA18053@linaro.org> Message-ID: On Mon, Feb 13, 2017 at 1:56 AM, Steve Capper wrote: > > Okay so looking at what we have for access_ok(.) on arm64, my > understanding is that we perform a 65-bit add/compare (in assembler) to > see whether or not the range is below the current_thread_info->addr_limit. > So I think this is a roundabout way of checking for no-wrap around and <= TASK_SIZE. No, that's the problem. It's *not* testing against TASK_SIZE. Because add_limit is not always TASK_SIZE. When you do set_fs(KERNEL_DS), you set addr_limit to infinity. And yes, the kernel does read and write calls too. Seldom, but it happens. And walking the page tables with kernel addresses is not supposed to work (sometimes it happens to work by mistake). So if somebody finds a path that gets from that kind of situation into the get_user_pages() interface, bad things happen. Linus From jsimmons at infradead.org Tue Feb 14 01:57:50 2017 From: jsimmons at infradead.org (James Simmons) Date: Tue, 14 Feb 2017 01:57:50 +0000 (GMT) Subject: [lustre-devel] LUG 2017 questions Message-ID: Just want to make sure the details. I don't see anything about Developer's day on the OpenSFS site. It starts at 9AM tuesday from what I remember on the LWG call but the one detail missing is their a extra cost like in the past. Next question is on the presentations. How much time is given to each presentation. I plan on giving my standard upstream client presentation which can be done quickly but I also like to do a presentation on perf/tracepoint which is a much more in depth topic. From andreas.dilger at intel.com Tue Feb 14 08:23:02 2017 From: andreas.dilger at intel.com (Dilger, Andreas) Date: Tue, 14 Feb 2017 08:23:02 +0000 Subject: [lustre-devel] Failing tests In-Reply-To: <1486990042.4090.21.camel@informatik.uni-hamburg.de> References: <1486985871.4090.13.camel@informatik.uni-hamburg.de> <1486990042.4090.21.camel@informatik.uni-hamburg.de> Message-ID: On Feb 13, 2017, at 05:47, Michael Kuhn wrote: > > Hi Patrick, > > thanks for the quick feedback! > >> [...] or you can re-submit your patch yourself (Re-make the commit with the same Change ID, etc, and just push again), to restart the test process. > > This forces all reviewers to redo their reviews, right? (That's why I > first wanted to ask whether there was another way.) If this is not seen > as a problem, though, I guess this is the easiest way. Usually a comment on the patch can get the tests retriggered, assuming someone is CC'd on the patch. Alternately, if you edit only the commit comment (which can be done directly in Gerrit) and then re-push the patch, the reviews will be kept but the patch will be retested. Cheers, Andreas -- Andreas Dilger Lustre Principal Architect Intel Corporation From peter.a.jones at intel.com Tue Feb 14 12:22:31 2017 From: peter.a.jones at intel.com (Jones, Peter A) Date: Tue, 14 Feb 2017 12:22:31 +0000 Subject: [lustre-devel] LUG 2017 questions In-Reply-To: References: Message-ID: At the moment the hackathon is the only developer event being planned/promoted for LUG - https://lug17.sched.com/event/9bNm/hackathon On 2/13/17, 5:57 PM, "lustre-devel on behalf of James Simmons" wrote: > >Just want to make sure the details. I don't see anything about >Developer's >day on the OpenSFS site. It starts at 9AM tuesday from what I remember >on the LWG call but the one detail missing is their a extra cost like in >the past. Next question is on the presentations. How much time is given >to each presentation. I plan on giving my standard upstream client >presentation which can be done quickly but I also like to do a >presentation on perf/tracepoint which is a much more in depth topic. >_______________________________________________ >lustre-devel mailing list >lustre-devel at lists.lustre.org >http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org From oleg.drokin at intel.com Tue Feb 14 17:06:30 2017 From: oleg.drokin at intel.com (Oleg Drokin) Date: Tue, 14 Feb 2017 12:06:30 -0500 Subject: [lustre-devel] New tag 2.9.53 Message-ID: <681B1366-BADC-4E28-A814-6B84C1C26BFD@intel.com> Hello! I tagged new tag 2.9.53 in the Lustre development branch. Here's the changelog. Aditya Pandit (1): LU-8702 tests: parallel execution of IOR and MDTEST added. Alex Zhuravlev (3): LU-8972 osp: skip subsequent orphan cleanups LU-7910 osd: do not lookup child objects in osd_dir_insert() LU-8928 osd: convert osd-zfs to reference dnode, not db Alexey Lyashkov (2): LU-8411 ofd: handle last_rcvd file can't update properly LU-8995 tests: set debug size correctly Amir Shehata (30): LU-7734 lnet: Multi-Rail local NI split LU-7734 lnet: Multi-Rail peer split LU-7734 lnet: Multi-Rail local_ni/peer_ni selection LU-7734 lnet: configure peers from DLC LU-7734 lnet: configure local NI from DLC LU-7734 lnet: NUMA support LU-7734 lnet: Primary NID and traffic distribution LU-7734 lnet: handle non-MR peers LU-7734 lnet: handle N NIs to 1 LND peer LU-7734 lnet: rename LND peer to peer_ni LU-7734 lnet: peer/peer_ni handling adjustments LU-7734 lnet: proper cpt locking LU-7734 lnet: protect peer_ni credits LU-7734 lnet: simplify and fix lnet_select_pathway() LU-7734 lnet: Fix lnet_msg_free() LU-7734 lnet: configuration fixes LU-7734 lnet: fix lnet_select_pathway() LU-7734 lnet: Routing fixes part 1 LU-7734 lnet: Routing fixes part 2 LU-7734 lnet: fix routing selection LU-7734 lnet: Fix crash in router_proc.c LU-7734 lnet: minor fixes LU-7734 lnet: fix string.h header inclusion LU-7734 lnet: fix NULL access in lnet_peer_aliveness_enabled LU-7734 lnet: Enhance DLC ip2nets LU-7734 lnet: rename peer key_nid to prim_nid LU-7734 lnet: cpt locking LU-7734 lnet: Fix setting numa range LU-7734 lnet: multi-rail feature LU-9078 lnet: Fix route hops print Andreas Dilger (1): LU-9073 gss: quiet insecure key file warning Artem Blagodarenko (1): LU-8974 osd-ldiskfs: increase supported ldiskfs fs size Aya Mahfouz (1): LU-4423 libcfs: remove IS_PO2 and __is_po2 Bob Glossman (3): LU-8954 kernel: kernel update [SLES12 SP1 3.12.67-60.64.24] LU-9030 kernel: kernel update RHEL7.3 [3.10.0-514.6.1.el7] LU-9029 kernel: kernel update [SLES12 SP2 4.4.38-93] Chennaiah Palla (2): LU-8865 tests: add fs_test test LU-8903 tests: racer test_1 to drop all error messages Dmitry Eremin (1): LU-9032 tests: syntax error in cleanup_test32_mount Doug Oucharek (1): LU-7734 lnet: Add peer_ni and NI stats for DLC Fan Yong (1): LU-8900 mgs: use reference count for fs_db Gabriele Paciucci (1): LU-8457 pacemaker: Pacemaker script to monitor LNet Hongchao Zhang (1): LU-9034 mgc: relate sptlrpc & params to MGC Jadhav Vikram (1): LU-8687 tests: list pool on mds when mgs is separate James Nunez (2): LU-6455 tests: Re-enable replay-vbr and replay-single tests LU-6319 tests: Resume parallel-grouplock testing James Simmons (10): LU-7734 lnet: power8 compile fix LU-6245 libcfs: use libcfs_private.h only for kernel space LU-9019 mdt: use ktime_t for calculating elapsed time LU-8602 gss: Support GSS on linux 4.6+ kernels LU-7734 gnilnd: update GNI lnd driver to handle multirail api changes LU-9019 o2iblnd: use 64-bit ibn_incarnation computation LU-8066 obdclass: move lustre server sysctl to sysfs LU-6245 libcfs: replace IS_PO2 with is_power_of_2 in server code LU-9019 osd: migrate osd-ldiskfs thandle stats to 64 bit time LU-8843 client: fix all less than 0 comparison for unsigned values Jian Yu (1): LU-9045 osp: Revert "LU-8840 osp: handle EA cache properly" Jinshan Xiong (1): LU-8979 ldlm: disable brw lock request in recovery Nathaniel Clark (1): LU-4121 tests: Enable zfs tests dependent on ost,mgs ordering Niu Yawei (1): LU-9033 llite: don't zero timestamps internally Olaf Weber (3): LU-7734 lnet: fix lnet_peer_table_cleanup_locked() LU-7734 lnet: double free in lnet_add_net_common() LU-7734 lnet: set primary NID in ptlrpc_connection_get() Oleg Drokin (3): LU-8066 ldlm: move /proc/fs/lustre/ldlm to sysfs LU-8066 obdclass: Get rid of remaining /proc/sys/lustre plumbing New tag 2.9.53 Parinay Kondekar (1): LU-1573 recovery: Avoid data corruption for DIO during FOFB Qian Yingjin (1): LU-5620 ptlrpc: Add QoS for opcode in NRS-TBF Quentin Bouget (1): LU-8382 hsm: reorder coordinator's cleanup functions Sonia Sharma (1): LU-8769 lnet: removal of obsolete LNDs Stephen Champion (1): LU-7734 lnet: Update lnetctl usage Steve Guminski (2): LU-6210 lnet: Change positional struct initializers to C99 LU-6210 gss: Change positional struct initializers to C99 Vladimir Saveliev (1): LU-8420 ldlm: take at_current change into account on prolong Wei Liu (1): LU-9041 test: Add version check to sanity test_402 Yang Sheng (1): LU-9031 osd: handle jinode change for ldiskfs Bye, Oleg From mark.a.olson at intel.com Tue Feb 14 19:46:29 2017 From: mark.a.olson at intel.com (Olson, Mark A) Date: Tue, 14 Feb 2017 19:46:29 +0000 Subject: [lustre-devel] Intel HPDD Maintenance Notification Message-ID: Intel High Performance Data Division Maintenance Notification WHAT and WHEN: On Sunday, Feb 19, 2017 7:00am - 11:00am Pacific Standard Time the following web sites may experience brief service interruptions due to planned maintenance. https://id.hpdd.intel.com https://jira.hpdd.intel.com https://wiki.hpdd.intel.com https://review.whamcloud.com https://git.hpdd.intel.com https://downloads.hpdd.intel.com QUESTIONS: For questions or concerns contact Trent Geerdes e-mail: trent.geer... at intel.com From anna.fuchs at informatik.uni-hamburg.de Thu Feb 16 14:15:36 2017 From: anna.fuchs at informatik.uni-hamburg.de (Anna Fuchs) Date: Thu, 16 Feb 2017 15:15:36 +0100 Subject: [lustre-devel] Design proposal for client-side compression In-Reply-To: <1484749185.3965.114.camel@informatik.uni-hamburg.de> References: <1483967258.2622.24.camel@informatik.uni-hamburg.de> <1484223328.3937.60.camel@informatik.uni-hamburg.de> <1484749185.3965.114.camel@informatik.uni-hamburg.de> Message-ID: <1487254536.4777.51.camel@informatik.uni-hamburg.de> Dear all,  I would like to update you about my progress on the project.  Unfortunately, I can not publish a complete design of the feature, since it changes very much during the development.  First the work related to the client changes:  I had to discard my approach to introduce the changes within the sptlrpc layer for the moment. Compression of the data affects especially the resulting number of pages and therefore number and size of niobufs, size and structure of the descriptor and request, size of the bulk kiov, checksums and in the end the async arguments. Actually it affects everything, that is set within the osc_brw_prep_request function in osc_request.c. When entering the sptlrpc layer, most of that parameters are already set and I would need to update everything. That causes double work and requires a lot of code duplication from the osc module.  My current dirty prototype invokes compression just at the beginning of that function, before niocount is calculated. I need to have a separate bunch of pages to store compressed data so that I would not overwrite the content of the original pages, which may be exposed to the userspace process.  The original pages would be freed and the compressed pages processed for the request and finally also freed.  I also reconsidered the idea to do compression niobuf-wise. Due to the file layout, compression should be done record-wise. Since a niobuf is a technical requirement for the pages to be contiguous, a record (e.g. 128KB) is a logical unit. In my understanding, it can happen, that one record contains of several niobufs whenever we do not have enough contiguous pages for a complete record. For that reason, I would like to leave the niobuf structure as is it and introduce a record structure on top of it. That record structure will hold the logical(uncompressed) and physical(compressed) data sizes and the algorithm used for compression. Initially we wanted to extend the niobuf struct by those fields. I think that change would affect the RPC request structure very much since the first Lustre message fields will not be followed by an array of niobufs, but by an array of records, which can contain an array of niobufs.  On the server/storage side, the different niobufs must be then associated with the same record and provided to ZFS.  Server changes:  Since we work on the Lustre/ZFS interface, we think it would be the best to let Lustre compose the header information for every record (psize and algorithm, maybe also the checksum in the future). We will store these values at the beginning of every record in 4 Bytes each.  Currently, when ZFS does compression itself, the compressed size is stored only within the compressed data. Some algorithms get it when starting the decompression, for lz4 it is stored at the beginning. With our approach, we would unify the record-metadata for any algorithm, but at the moment it would not be accessible by ZFS without changes to ZFS structures.  ZFS will also hold an extra variable whether the data is compressed at all. When reading and the data is compressed, it is up to Lustre to get the original size and algorithm, to decompress the data and put it into page structure.  Any comments or ideas are very welcome!  Regards, Anna From bevans at cray.com Thu Feb 16 14:36:03 2017 From: bevans at cray.com (Ben Evans) Date: Thu, 16 Feb 2017 14:36:03 +0000 Subject: [lustre-devel] Proposal for JobID caching In-Reply-To: References: <6E2CFE03-A158-4D82-82BA-AF0A175AA358@intel.com> <9BEFFD88-0537-43AB-8352-6477F30906DA@intel.com> Message-ID: On 2/7/17, 6:01 PM, "Dilger, Andreas" wrote: >On Feb 2, 2017, at 08:20, Ben Evans wrote: >> >> https://review.whamcloud.com/#/c/25208/ is a working version of what I >>had >> proposed, including the suggested changes to default to procname_uid. >> This is not perfect, but the performance is much improved over the >>current >> methods, and unlike inode-based caching Metadata performance isn't >> negatively affected. Multiple simultaneous jobs can be run on the same >> file, and get appropriate metrics. > >I reviewed the patch, and one question that I had is whether you've tested >if the JobID is correct when read/write RPCs are generated by readahead or >ptlrpcd? That may be more relevant once the async readahead threads are >implemented by Dmitry. With an inode-based JobID cache then the JobID can >(usually) be correctly determined even if the RPC is not generated in the >context of the user process. > >I don't think that is necessarily a fault in your patch, but it may be >that >the JobID determination hasn't kept pace with other changes in the code. >It >would be great if you would verify (possibly with a test attached to your >patch) that JobID is assigned to all the RPCs that need it. I've seen some lustre thread names pop into the JobID under the procname_uid scheme when doing something like a dd test. Filtering them out would be relatively straightforward, and keeping the old JobID (if available) in the lookup table would be the way to get the most reliable info. There shouldn't be a difference with the current behavior in this regard. My issue with putting the information in the inode stems from 2 cases, the first is RobinHood, which stats *everything*. In the proposed solution, one lookup would be done every 30 seconds. Storing the inode, it would happen for every stat, then never used again. The other case is less probable, but still out there, in an environment with multiple jobs per node, you may be running two different jobs on the same input set, which would corrupt the counting. -Ben > >Cheers, Andreas > >> On 1/20/17, 5:00 PM, "Ben Evans" wrote: >> >>> >>> >>> On 1/20/17, 4:50 PM, "Dilger, Andreas" >>>wrote: >>> >>>> On Jan 18, 2017, at 13:39, Oleg Drokin wrote: >>>>> >>>>> >>>>> On Jan 18, 2017, at 3:08 PM, Ben Evans wrote: >>>>> >>>>>> Overview >>>>>> The Lustre filesystem added the ability to track I/O >>>>>> performance of a job across a cluster. The initial algorithm was >>>>>> relatively simplistic: for every I/O, look up the job ID of the >>>>>> process and include it in the RPC being sent to the server. This >>>>>> imposed a non-trivial performance impact on client I/O performance. >>>>>> An additional algorithm was introduced to handle the >>>>>>single >>>>>> job per node case, where instead of looking up the job ID of the >>>>>> process, Lustre simply accesses the value of a variable set through >>>>>>the >>>>>> proc interface. This improved performance greatly, but only >>>>>>functions >>>>>> when a single job is being run. >>>>>> A new approach is needed for multiple job per node >>>>>>systems. >>>>>> >>>>>> Proposed Solution >>>>>> The proposed solution to this is to create a small >>>>>> PID->JobID table in kernel memory. When a process performs an IO, a >>>>>> lookup is done in the table for the PID, if a JobID exists for that >>>>>> PID, it is used, otherwise it is retrieved via the same methods as >>>>>>the >>>>>> original Jobstats algorithm. Once located the JobID is stored in a >>>>>> PID/JobID table in memory. The existing cfs_hash_table structure and >>>>>> functions will be used to implement the table. >>>>>> >>>>>> Rationale >>>>>> This reduces the number of calls into userspace, >>>>>>minimizing >>>>>> the time taken on each I/O. It also easily supports multiple job >>>>>>per >>>>>> node scenarios, and like other proposed solutions has no issue with >>>>>> multiple jobs performing I/O on the same file at the same time. >>>>>> >>>>>> Requirements >>>>>> · Performance cannot significantly detract from baseline >>>>>> performance without jobstats >>>>>> · Supports multiple jobs per node >>>>>> · Coordination with the scheduler is not required, but >>>>>>interfaces >>>>>> may be provided >>>>>> · Supports multiple PIDs per job >>>>>> >>>>>> New Data Structures >>>>>> pid_to_jobid { >>>>>> struct hlist_node pj_hash; >>>>>> u54 pj_pid; >>>>>> char pj_jobid[LUSTRE_JOBID_SIZE]; >>>>>> spinlock_t jp_lock; >>>>>> time_t jp_time; >>>>>> } >>>>>> Proc Variables >>>>>> Writing to /proc/fs/lustre/jobid_name while not in ³nodelocal² mode >>>>>> will cause all entries in the cache for that jobID to be removed >>>>>>from >>>>>> the cache >>>>>> >>>>>> Populating the Cache >>>>>> When lustre_get_jobid is called, the process, and in the >>>>>> cached mode, first a check will be done in the cache for a valid >>>>>>PID to >>>>>> JobID mapping. If none exists, it uses the same mechanisms to get >>>>>>the >>>>>> JobID and populates the appropriate PID to JobID map. >>>>>> If a lookup is performed and the PID to JobID mapping exists, but is >>>>>> more than 30 seconds old, the JobID is refreshed. >>>>>> Purging the Cache >>>>>> The cache can be purged of a specific job by writing the >>>>>> JobID to the jobid_name proc file. Any items in the cache that are >>>>>> more than 300 seconds out of date will also be purged at this time. >>>>> >>>>> >>>>> I'd much rather prefer you go to the table that's populated outside >>>>>of >>>>> the kernel >>>>> somehow. >>>>> Let's be realistic, poking around in userspace process environments >>>>>for >>>>> random >>>>> strings is not such a great idea at all even though it did look like >>>>>a >>>>> good idea >>>>> in the past for simplicity reasons. >>>>> Similar to nodelocal, we probably just switch to a method where you >>>>> call a >>>>> particular lctl command that would mark the whole session as >>>>>belonging >>>>> to some job. This might take several forms, e.g. nodelocal itself >>>>>could >>>>> be extended to only apply to a current namespace/container >>>>> But if you do really run different jobs in the global namespace, we >>>>> probably can >>>>> probably just make the lctl to spawn a shell with commands that all >>>>> would >>>>> be marked as a particular job? Or we can probably trace the parent of >>>>> lctl and >>>>> mark that so that all its children become somehow marked too. >>>> >>>> Having lctl spawn a shell or requiring everything to run in a >>>>container >>>> is impractical for users, and will just make it harder to use JobID, >>>> IMHO. The job scheduler is _already_ storing the JobID in the process >>>> environment so that it is available to all of the threads running as >>>>part >>>> of the job. The question is how the job prolog script can communicate >>>> the JobID directly to Lustre without using a global /proc file? >>>>Doing an >>>> upcall to userspace per JobID lookup is going to be *worse* for >>>> performance than the current searching through the process >>>>environment. >>>> >>>> I'm not against Ben's proposal to implement a cache in the kernel for >>>> different processes. It is unfortunate that we can't have proper >>>> thread-local storage for Lustre, so a hash table is probably >>>>reasonable >>>> for this (there may be thousands of threads involved). I don't think >>>>the >>>> cl_env struct would be useful, since it is not tied to a specific >>>>thread >>>> (AFAIK), but rather assigned as different threads enter/exit kernel >>>> context. Note that we already have similar time-limited caches for >>>>the >>>> identity upcall and FMD (lustre/ofd/ofd_fmd.c), so it may be useful to >>>> see whether the code can be shared. >>> >>> I'll take a look at those, but implementing the hash table was a pretty >>> simple solution, I need to work out a few kinks with memory leaks >>>before >>> doing real performance tests on it to make sure it performs similarly >>>to >>> nodelocal. >>> >>>> Another (not very nice) option to avoid looking through the >>>>environment >>>> variables (which IMHO isn't so bad, even though the upstream folks >>>>don't >>>> like it) is to associate the JobID set via /proc with a process group >>>> internally and look the PGID up in the kernel to find the JobID. That >>>> can be repeated each time a new JobID is set via /proc, since the PGID >>>> would stick around for each new job/shell/process created under the >>>>PGID. >>>> It won't be as robust as looking up the JobID in the environment, but >>>> probably good enough for most uses. >>>> >>>> I would definitely also be in favor of having some way to fall back to >>>> procname_uid if the PGID cannot be found, the job environment >>>>variable is >>>> not available, and there is nothing in nodelocal. >>> >>> That's simple enough. >>> >> > >Cheers, Andreas >-- >Andreas Dilger >Lustre Principal Architect >Intel Corporation > > > > > > > From jsimmons at infradead.org Thu Feb 16 15:46:25 2017 From: jsimmons at infradead.org (James Simmons) Date: Thu, 16 Feb 2017 15:46:25 +0000 (GMT) Subject: [lustre-devel] [PATCH] staging: lustre: Fix incompatible argument in osc_match_base In-Reply-To: <1487242226-14972-1-git-send-email-mrossibellom@gmail.com> References: <1487242226-14972-1-git-send-email-mrossibellom@gmail.com> Message-ID: > From: Maxime Rossi Bellom > > sparse warn about _u32 used for two arguments in function > osc_match_base instead of enum ldlm_type and enum ldlm_mode as > used in the prototype. > > Signed-off-by: Maxime Rossi Bellom One of the pieces of a earlier patch I broke up that got lost :-( Thanks for finding it. Reviewed-by: James Simmons > --- > drivers/staging/lustre/lustre/osc/osc_request.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c > index 62c743b..c4cfe18 100644 > --- a/drivers/staging/lustre/lustre/osc/osc_request.c > +++ b/drivers/staging/lustre/lustre/osc/osc_request.c > @@ -2081,9 +2081,9 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, > } > > int osc_match_base(struct obd_export *exp, struct ldlm_res_id *res_id, > - __u32 type, union ldlm_policy_data *policy, __u32 mode, > - __u64 *flags, void *data, struct lustre_handle *lockh, > - int unref) > + enum ldlm_type type, union ldlm_policy_data *policy, > + enum ldlm_mode mode, __u64 *flags, void *data, > + struct lustre_handle *lockh, int unref) > { > struct obd_device *obd = exp->exp_obd; > __u64 lflags = *flags; > -- > 2.7.4 > > From andreas.dilger at intel.com Thu Feb 16 22:30:17 2017 From: andreas.dilger at intel.com (Dilger, Andreas) Date: Thu, 16 Feb 2017 22:30:17 +0000 Subject: [lustre-devel] Proposal for JobID caching In-Reply-To: References: <6E2CFE03-A158-4D82-82BA-AF0A175AA358@intel.com> <9BEFFD88-0537-43AB-8352-6477F30906DA@intel.com> Message-ID: <9F0ECE95-3C4B-495D-97BB-9B3AA211D43A@intel.com> On Feb 16, 2017, at 07:36, Ben Evans wrote: > > > > On 2/7/17, 6:01 PM, "Dilger, Andreas" wrote: > >> On Feb 2, 2017, at 08:20, Ben Evans wrote: >>> >>> https://review.whamcloud.com/#/c/25208/ is a working version of what I >>> had >>> proposed, including the suggested changes to default to procname_uid. >>> This is not perfect, but the performance is much improved over the >>> current >>> methods, and unlike inode-based caching Metadata performance isn't >>> negatively affected. Multiple simultaneous jobs can be run on the same >>> file, and get appropriate metrics. >> >> I reviewed the patch, and one question that I had is whether you've tested >> if the JobID is correct when read/write RPCs are generated by readahead or >> ptlrpcd? That may be more relevant once the async readahead threads are >> implemented by Dmitry. With an inode-based JobID cache then the JobID can >> (usually) be correctly determined even if the RPC is not generated in the >> context of the user process. >> >> I don't think that is necessarily a fault in your patch, but it may be >> that >> the JobID determination hasn't kept pace with other changes in the code. >> It >> would be great if you would verify (possibly with a test attached to your >> patch) that JobID is assigned to all the RPCs that need it. > > I've seen some lustre thread names pop into the JobID under the > procname_uid scheme when doing something like a dd test. Filtering them > out would be relatively straightforward, and keeping the old JobID (if > available) in the lookup table would be the way to get the most reliable > info. There shouldn't be a difference with the current behavior in this > regard. > > My issue with putting the information in the inode stems from 2 cases, the > first is RobinHood, which stats *everything*. In the proposed solution, > one lookup would be done every 30 seconds. Storing the inode, it would > happen for every stat, then never used again. > > The other case is less probable, but still out there, in an environment > with multiple jobs per node, you may be running two different jobs on the > same input set, which would corrupt the counting. If there are two jobs using the same input files, I suspect the second one would get the data from the client cache, and not log anything on the server at all. In any case, I don't think that would be any different than the two jobs are randomly interleaving their access to the same files on the server. Conversely, having "ptlrpcd/0" appear in the jobstats doesn't really help anyone figure out which user/job is causing IO traffic on the server. If RPCs generated by ptlrpcd, statahead, and other service threads that do work on behalf of user processes (including readahead in the near future) have the proper JobID then that would be much more useful. Some suggestions on how to handle this, off the top of my head: - blacklist service thread PIDs at startup in the JobID hash and have them get the JobID by some other method (e.g. inode, DLM lock/resource, other) - store the JobID explicitly with the IO request when it is being put into a cache/queue and use this when submitting the RPC if present, otherwise get it from the hash The latter may be preferable, since it doesn't need to do anything for sync RPCs generated in process context, and avoids an extra lookup when processing the RPC. You might consider the first method for debugging when/where such RPCs are generated, and have the backlisted threads dump a stack once if they are being looked up in the JobID hash. Cheers, Andreas > -Ben > >> >> Cheers, Andreas >> >>> On 1/20/17, 5:00 PM, "Ben Evans" wrote: >>> >>>> >>>> >>>> On 1/20/17, 4:50 PM, "Dilger, Andreas" >>>> wrote: >>>> >>>>> On Jan 18, 2017, at 13:39, Oleg Drokin wrote: >>>>>> >>>>>> >>>>>> On Jan 18, 2017, at 3:08 PM, Ben Evans wrote: >>>>>> >>>>>>> Overview >>>>>>> The Lustre filesystem added the ability to track I/O >>>>>>> performance of a job across a cluster. The initial algorithm was >>>>>>> relatively simplistic: for every I/O, look up the job ID of the >>>>>>> process and include it in the RPC being sent to the server. This >>>>>>> imposed a non-trivial performance impact on client I/O performance. >>>>>>> An additional algorithm was introduced to handle the >>>>>>> single >>>>>>> job per node case, where instead of looking up the job ID of the >>>>>>> process, Lustre simply accesses the value of a variable set through >>>>>>> the >>>>>>> proc interface. This improved performance greatly, but only >>>>>>> functions >>>>>>> when a single job is being run. >>>>>>> A new approach is needed for multiple job per node >>>>>>> systems. >>>>>>> >>>>>>> Proposed Solution >>>>>>> The proposed solution to this is to create a small >>>>>>> PID->JobID table in kernel memory. When a process performs an IO, a >>>>>>> lookup is done in the table for the PID, if a JobID exists for that >>>>>>> PID, it is used, otherwise it is retrieved via the same methods as >>>>>>> the >>>>>>> original Jobstats algorithm. Once located the JobID is stored in a >>>>>>> PID/JobID table in memory. The existing cfs_hash_table structure and >>>>>>> functions will be used to implement the table. >>>>>>> >>>>>>> Rationale >>>>>>> This reduces the number of calls into userspace, >>>>>>> minimizing >>>>>>> the time taken on each I/O. It also easily supports multiple job >>>>>>> per >>>>>>> node scenarios, and like other proposed solutions has no issue with >>>>>>> multiple jobs performing I/O on the same file at the same time. >>>>>>> >>>>>>> Requirements >>>>>>> · Performance cannot significantly detract from baseline >>>>>>> performance without jobstats >>>>>>> · Supports multiple jobs per node >>>>>>> · Coordination with the scheduler is not required, but >>>>>>> interfaces >>>>>>> may be provided >>>>>>> · Supports multiple PIDs per job >>>>>>> >>>>>>> New Data Structures >>>>>>> pid_to_jobid { >>>>>>> struct hlist_node pj_hash; >>>>>>> u54 pj_pid; >>>>>>> char pj_jobid[LUSTRE_JOBID_SIZE]; >>>>>>> spinlock_t jp_lock; >>>>>>> time_t jp_time; >>>>>>> } >>>>>>> Proc Variables >>>>>>> Writing to /proc/fs/lustre/jobid_name while not in ³nodelocal² mode >>>>>>> will cause all entries in the cache for that jobID to be removed >>>>>>> from >>>>>>> the cache >>>>>>> >>>>>>> Populating the Cache >>>>>>> When lustre_get_jobid is called, the process, and in the >>>>>>> cached mode, first a check will be done in the cache for a valid >>>>>>> PID to >>>>>>> JobID mapping. If none exists, it uses the same mechanisms to get >>>>>>> the >>>>>>> JobID and populates the appropriate PID to JobID map. >>>>>>> If a lookup is performed and the PID to JobID mapping exists, but is >>>>>>> more than 30 seconds old, the JobID is refreshed. >>>>>>> Purging the Cache >>>>>>> The cache can be purged of a specific job by writing the >>>>>>> JobID to the jobid_name proc file. Any items in the cache that are >>>>>>> more than 300 seconds out of date will also be purged at this time. >>>>>> >>>>>> >>>>>> I'd much rather prefer you go to the table that's populated outside >>>>>> of >>>>>> the kernel >>>>>> somehow. >>>>>> Let's be realistic, poking around in userspace process environments >>>>>> for >>>>>> random >>>>>> strings is not such a great idea at all even though it did look like >>>>>> a >>>>>> good idea >>>>>> in the past for simplicity reasons. >>>>>> Similar to nodelocal, we probably just switch to a method where you >>>>>> call a >>>>>> particular lctl command that would mark the whole session as >>>>>> belonging >>>>>> to some job. This might take several forms, e.g. nodelocal itself >>>>>> could >>>>>> be extended to only apply to a current namespace/container >>>>>> But if you do really run different jobs in the global namespace, we >>>>>> probably can >>>>>> probably just make the lctl to spawn a shell with commands that all >>>>>> would >>>>>> be marked as a particular job? Or we can probably trace the parent of >>>>>> lctl and >>>>>> mark that so that all its children become somehow marked too. >>>>> >>>>> Having lctl spawn a shell or requiring everything to run in a >>>>> container >>>>> is impractical for users, and will just make it harder to use JobID, >>>>> IMHO. The job scheduler is _already_ storing the JobID in the process >>>>> environment so that it is available to all of the threads running as >>>>> part >>>>> of the job. The question is how the job prolog script can communicate >>>>> the JobID directly to Lustre without using a global /proc file? >>>>> Doing an >>>>> upcall to userspace per JobID lookup is going to be *worse* for >>>>> performance than the current searching through the process >>>>> environment. >>>>> >>>>> I'm not against Ben's proposal to implement a cache in the kernel for >>>>> different processes. It is unfortunate that we can't have proper >>>>> thread-local storage for Lustre, so a hash table is probably >>>>> reasonable >>>>> for this (there may be thousands of threads involved). I don't think >>>>> the >>>>> cl_env struct would be useful, since it is not tied to a specific >>>>> thread >>>>> (AFAIK), but rather assigned as different threads enter/exit kernel >>>>> context. Note that we already have similar time-limited caches for >>>>> the >>>>> identity upcall and FMD (lustre/ofd/ofd_fmd.c), so it may be useful to >>>>> see whether the code can be shared. >>>> >>>> I'll take a look at those, but implementing the hash table was a pretty >>>> simple solution, I need to work out a few kinks with memory leaks >>>> before >>>> doing real performance tests on it to make sure it performs similarly >>>> to >>>> nodelocal. >>>> >>>>> Another (not very nice) option to avoid looking through the >>>>> environment >>>>> variables (which IMHO isn't so bad, even though the upstream folks >>>>> don't >>>>> like it) is to associate the JobID set via /proc with a process group >>>>> internally and look the PGID up in the kernel to find the JobID. That >>>>> can be repeated each time a new JobID is set via /proc, since the PGID >>>>> would stick around for each new job/shell/process created under the >>>>> PGID. >>>>> It won't be as robust as looking up the JobID in the environment, but >>>>> probably good enough for most uses. >>>>> >>>>> I would definitely also be in favor of having some way to fall back to >>>>> procname_uid if the PGID cannot be found, the job environment >>>>> variable is >>>>> not available, and there is nothing in nodelocal. >>>> >>>> That's simple enough. >>>> >>> >> >> Cheers, Andreas >> -- >> Andreas Dilger >> Lustre Principal Architect >> Intel Corporation >> >> >> >> >> >> >> > Cheers, Andreas -- Andreas Dilger Lustre Principal Architect Intel Corporation From jinshan.xiong at intel.com Fri Feb 17 19:15:26 2017 From: jinshan.xiong at intel.com (Xiong, Jinshan) Date: Fri, 17 Feb 2017 19:15:26 +0000 Subject: [lustre-devel] Design proposal for client-side compression In-Reply-To: <1487254536.4777.51.camel@informatik.uni-hamburg.de> References: <1483967258.2622.24.camel@informatik.uni-hamburg.de> <1484223328.3937.60.camel@informatik.uni-hamburg.de> <1484749185.3965.114.camel@informatik.uni-hamburg.de> <1487254536.4777.51.camel@informatik.uni-hamburg.de> Message-ID: <6D3CC4C5-E789-4E2B-8428-2EA20CC7674E@intel.com> Hi Anna, Thanks for updating. Please see inserted lines. On Feb 16, 2017, at 6:15 AM, Anna Fuchs > wrote: Dear all, I would like to update you about my progress on the project. Unfortunately, I can not publish a complete design of the feature, since it changes very much during the development. First the work related to the client changes: I had to discard my approach to introduce the changes within the sptlrpc layer for the moment. Compression of the data affects especially the resulting number of pages and therefore number and size of niobufs, size and structure of the descriptor and request, size of the bulk kiov, checksums and in the end the async arguments. Actually it affects everything, that is set within the osc_brw_prep_request function in osc_request.c. When entering the sptlrpc layer, most of that parameters are already set and I would need to update everything. That causes double work and requires a lot of code duplication from the osc module. My current dirty prototype invokes compression just at the beginning of that function, before niocount is calculated. I need to have a separate bunch of pages to store compressed data so that I would not overwrite the content of the original pages, which may be exposed to the userspace process. The original pages would be freed and the compressed pages processed for the request and finally also freed. Please remember to reserve some pages as emergency pool to avoid the problem that the system memory is in shortage and it needs some free pages for compression to writeback more pages. We may use the same pool to support partial block so it must be greater than the largest ZFS block size(I prefer to not compress data for partial blocks). After RPC is issued, the pages contain compressed data will be pinned in memory for a while for recovery reasons. Therefore, when emergency pages are used, you will have to issue the RPC in sync mode, so that the server can commit the write trans into persistent storage and client can use the emergency pages for new RPC immediately. I also reconsidered the idea to do compression niobuf-wise. Due to the file layout, compression should be done record-wise. Since a niobuf is a technical requirement for the pages to be contiguous, a record (e.g. 128KB) is a logical unit. In my understanding, it can happen, that one record contains of several niobufs whenever we do not have enough We use the terminology ‘chunk’ as the preferred block size on the OST. Let’s use the same terminology ;-) contiguous pages for a complete record. For that reason, I would like to leave the niobuf structure as is it and introduce a record structure on top of it. That record structure will hold the logical(uncompressed) and physical(compressed) data sizes and the algorithm used for hmm… not sure if this is the right approach. I tend to think the client will talk with the OST at connecting time and negotiate the compress algorithm, and after that they should use the same algorithm. There is no need to carry this information in every single RPC. Yes, it’s reasonable to have chunk descriptors in the RPC. When there are multiple compressed chunks packed in one RPC, the exact bufsize for each chunk will be packed as well. Right now, the LNET doesn’t support partial pages inside niobuf(except the first and last page), so clients have to provide enough information in the chunk descriptor so the server can deduce the padding size for each chunk in the niobuf. compression. Initially we wanted to extend the niobuf struct by those fields. I think that change would affect the RPC request structure very much since the first Lustre message fields will not be followed by an array of niobufs, but by an array of records, which can contain an array of niobufs. We just need a new format of RPC. Please take a look at RQF_OST_BRW_{READ,WRITE}. What we need is probably some thing like RQF_OST_COMP_BRW_{READ,WRITE}, which is basically the same thing but with chunk descriptor: static const struct req_msg_field *ost_comp_brw_client[] = { &RMF_PTLRPC_BODY, &RMF_OST_BODY, &RMF_OBD_IOOBJ, &RMF_NIOBUF_REMOTE, >>> &RMF_CHUNK_DESCR, &RMF_CAPA1 }; On the server/storage side, the different niobufs must be then associated with the same record and provided to ZFS. Server changes: Since we work on the Lustre/ZFS interface, we think it would be the best to let Lustre compose the header information for every record (psize and algorithm, maybe also the checksum in the future). We will I tend to let ZFS do this job especially for checksum otherwise if Lustre provided wrong data it would affect the consistency of ZFS. store these values at the beginning of every record in 4 Bytes each. Currently, when ZFS does compression itself, the compressed size is stored only within the compressed data. Some algorithms get it when starting the decompression, for lz4 it is stored at the beginning. With our approach, we would unify the record-metadata for any algorithm, but Wait, are you suggesting to store record/chunk-metadata into persistent storage? at the moment it would not be accessible by ZFS without changes to ZFS structures. ZFS will also hold an extra variable whether the data is compressed at all. When reading and the data is compressed, it is up to Lustre to get the original size and algorithm, to decompress the data and put it into page structure. Yes, the server will check the capability of client to decide if to return compressed data. I don't look into the corresponding code but matt mentioned before this is pretty much the same interface of ZFS send/recv. Thanks, Jinshan Any comments or ideas are very welcome! Regards, Anna _______________________________________________ lustre-devel mailing list lustre-devel at lists.lustre.org http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From andreas.dilger at intel.com Fri Feb 17 20:29:05 2017 From: andreas.dilger at intel.com (Dilger, Andreas) Date: Fri, 17 Feb 2017 20:29:05 +0000 Subject: [lustre-devel] Design proposal for client-side compression In-Reply-To: <6D3CC4C5-E789-4E2B-8428-2EA20CC7674E@intel.com> References: <1483967258.2622.24.camel@informatik.uni-hamburg.de> <1484223328.3937.60.camel@informatik.uni-hamburg.de> <1484749185.3965.114.camel@informatik.uni-hamburg.de> <1487254536.4777.51.camel@informatik.uni-hamburg.de> <6D3CC4C5-E789-4E2B-8428-2EA20CC7674E@intel.com> Message-ID: On Feb 17, 2017, at 12:15, Xiong, Jinshan wrote: > > Hi Anna, > > Thanks for updating. Please see inserted lines. > >> On Feb 16, 2017, at 6:15 AM, Anna Fuchs wrote: >> >> Dear all, >> >> I would like to update you about my progress on the project. >> Unfortunately, I can not publish a complete design of the feature, >> since it changes very much during the development. >> >> First the work related to the client changes: >> >> I had to discard my approach to introduce the changes within the >> sptlrpc layer for the moment. Compression of the data affects >> especially the resulting number of pages and therefore number and size >> of niobufs, size and structure of the descriptor and request, size of >> the bulk kiov, checksums and in the end the async arguments. Actually >> it affects everything, that is set within the osc_brw_prep_request >> function in osc_request.c. When entering the sptlrpc layer, most of >> that parameters are already set and I would need to update everything. >> That causes double work and requires a lot of code duplication from the >> osc module. >> >> My current dirty prototype invokes compression just at the beginning of >> that function, before niocount is calculated. I need to have a separate >> bunch of pages to store compressed data so that I would not overwrite >> the content of the original pages, which may be exposed to the >> userspace process. >> The original pages would be freed and the compressed pages processed >> for the request and finally also freed. > > Please remember to reserve some pages as emergency pool to avoid the problem that the system memory is in shortage and it needs some free pages for compression to writeback more pages. We may use the same pool to support partial block so it must be greater than the largest ZFS block size(I prefer to not compress data for partial blocks). > > After RPC is issued, the pages contain compressed data will be pinned in memory for a while for recovery reasons. Therefore, when emergency pages are used, you will have to issue the RPC in sync mode, so that the server can commit the write trans into persistent storage and client can use the emergency pages for new RPC immediately. > >> >> I also reconsidered the idea to do compression niobuf-wise. Due to the >> file layout, compression should be done record-wise. Since a niobuf is >> a technical requirement for the pages to be contiguous, a record (e.g. >> 128KB) is a logical unit. In my understanding, it can happen, that one >> record contains of several niobufs whenever we do not have enough > > We use the terminology ‘chunk’ as the preferred block size on the OST. Let’s use the same terminology ;-) > >> contiguous pages for a complete record. For that reason, I would like >> to leave the niobuf structure as is it and introduce a record structure >> on top of it. That record structure will hold the logical(uncompressed) >> and physical(compressed) data sizes and the algorithm used for > > hmm… not sure if this is the right approach. I tend to think the client will talk with the OST at connecting time and negotiate the compress algorithm, and after that they should use the same algorithm. There is no need to carry this information in every single RPC. I'm not sure I agree. The benefits of compression may be different on a per-file basis (e.g. .txt vs. .jpg) so there shouldn't be a fixed compression algorithm required for all RPCs. I could imagine that we don't want to allow a different compression type for each block (which ZFS allows), but one compression type per RPC should be OK. We do the same for the checksum type. > Yes, it’s reasonable to have chunk descriptors in the RPC. When there are multiple compressed chunks packed in one RPC, the exact bufsize for each chunk will be packed as well. Right now, the LNET doesn’t support partial pages inside niobuf(except the first and last page), so clients have to provide enough information in the chunk descriptor so the server can deduce the padding size for each chunk in the niobuf. > >> compression. Initially we wanted to extend the niobuf struct by those >> fields. I think that change would affect the RPC request structure very >> much since the first Lustre message fields will not be followed by an >> array of niobufs, but by an array of records, which can contain an >> array of niobufs. > > We just need a new format of RPC. Please take a look at RQF_OST_BRW_{READ,WRITE}. What we need is probably some thing like RQF_OST_COMP_BRW_{READ,WRITE}, which is basically the same thing but with chunk descriptor: > > static const struct req_msg_field *ost_comp_brw_client[] = { > &RMF_PTLRPC_BODY, > &RMF_OST_BODY, > &RMF_OBD_IOOBJ, > &RMF_NIOBUF_REMOTE, > >>> &RMF_CHUNK_DESCR, > &RMF_CAPA1 > }; > >> On the server/storage side, the different niobufs must be then >> associated with the same record and provided to ZFS. >> >> Server changes: >> >> Since we work on the Lustre/ZFS interface, we think it would be the >> best to let Lustre compose the header information for every record >> (psize and algorithm, maybe also the checksum in the future). We will > > I tend to let ZFS do this job especially for checksum otherwise if Lustre provided wrong data it would affect the consistency of ZFS. We want to allow Lustre clients to use the same ZFS checksum in the future, so there needs to be an interface to pass this. If ZFS verifies the checksum when the write is first submitted, and returns an error before doing actual filesystem modifications then it can verify the checksum is correct for that block, and we can skip the Lustre RPC checksum. This would probably work OK with the "zero copy" interface that we use, where data buffers are preallocated for RDMA without actually being attached to a TXG, and then the checksum would be verified by ZFS at submission. >> store these values at the beginning of every record in 4 Bytes each. >> Currently, when ZFS does compression itself, the compressed size is >> stored only within the compressed data. Some algorithms get it when >> starting the decompression, for lz4 it is stored at the beginning. With >> our approach, we would unify the record-metadata for any algorithm, but > > Wait, are you suggesting to store record/chunk-metadata into persistent storage? > >> at the moment it would not be accessible by ZFS without changes to ZFS >> structures. >> >> ZFS will also hold an extra variable whether the data is compressed at >> all. When reading and the data is compressed, it is up to Lustre to get >> the original size and algorithm, to decompress the data and put it into >> page structure. > > Yes, the server will check the capability of client to decide if to return compressed data. > > I don't look into the corresponding code but Matt mentioned before this is pretty much the same interface of ZFS send/recv. > > Thanks, > Jinshan > >> >> >> Any comments or ideas are very welcome! >> >> Regards, >> Anna >> >> >> >> >> >> _______________________________________________ >> lustre-devel mailing list >> lustre-devel at lists.lustre.org >> http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org Cheers, Andreas -- Andreas Dilger Lustre Principal Architect Intel Corporation From jinshan.xiong at intel.com Fri Feb 17 21:03:35 2017 From: jinshan.xiong at intel.com (Xiong, Jinshan) Date: Fri, 17 Feb 2017 21:03:35 +0000 Subject: [lustre-devel] Design proposal for client-side compression In-Reply-To: References: <1483967258.2622.24.camel@informatik.uni-hamburg.de> <1484223328.3937.60.camel@informatik.uni-hamburg.de> <1484749185.3965.114.camel@informatik.uni-hamburg.de> <1487254536.4777.51.camel@informatik.uni-hamburg.de> <6D3CC4C5-E789-4E2B-8428-2EA20CC7674E@intel.com> Message-ID: On Feb 17, 2017, at 12:29 PM, Dilger, Andreas > wrote: On Feb 17, 2017, at 12:15, Xiong, Jinshan > wrote: Hi Anna, Thanks for updating. Please see inserted lines. On Feb 16, 2017, at 6:15 AM, Anna Fuchs > wrote: Dear all, I would like to update you about my progress on the project. Unfortunately, I can not publish a complete design of the feature, since it changes very much during the development. First the work related to the client changes: I had to discard my approach to introduce the changes within the sptlrpc layer for the moment. Compression of the data affects especially the resulting number of pages and therefore number and size of niobufs, size and structure of the descriptor and request, size of the bulk kiov, checksums and in the end the async arguments. Actually it affects everything, that is set within the osc_brw_prep_request function in osc_request.c. When entering the sptlrpc layer, most of that parameters are already set and I would need to update everything. That causes double work and requires a lot of code duplication from the osc module. My current dirty prototype invokes compression just at the beginning of that function, before niocount is calculated. I need to have a separate bunch of pages to store compressed data so that I would not overwrite the content of the original pages, which may be exposed to the userspace process. The original pages would be freed and the compressed pages processed for the request and finally also freed. Please remember to reserve some pages as emergency pool to avoid the problem that the system memory is in shortage and it needs some free pages for compression to writeback more pages. We may use the same pool to support partial block so it must be greater than the largest ZFS block size(I prefer to not compress data for partial blocks). After RPC is issued, the pages contain compressed data will be pinned in memory for a while for recovery reasons. Therefore, when emergency pages are used, you will have to issue the RPC in sync mode, so that the server can commit the write trans into persistent storage and client can use the emergency pages for new RPC immediately. I also reconsidered the idea to do compression niobuf-wise. Due to the file layout, compression should be done record-wise. Since a niobuf is a technical requirement for the pages to be contiguous, a record (e.g. 128KB) is a logical unit. In my understanding, it can happen, that one record contains of several niobufs whenever we do not have enough We use the terminology ‘chunk’ as the preferred block size on the OST. Let’s use the same terminology ;-) contiguous pages for a complete record. For that reason, I would like to leave the niobuf structure as is it and introduce a record structure on top of it. That record structure will hold the logical(uncompressed) and physical(compressed) data sizes and the algorithm used for hmm… not sure if this is the right approach. I tend to think the client will talk with the OST at connecting time and negotiate the compress algorithm, and after that they should use the same algorithm. There is no need to carry this information in every single RPC. I'm not sure I agree. The benefits of compression may be different on a per-file basis (e.g. .txt vs. .jpg) so there shouldn't be a fixed compression algorithm required for all RPCs. I could imagine that we don't want to allow a different compression type for each block (which ZFS allows), but one compression type per RPC should be OK. We do the same for the checksum type. The difference between checksum and compression is that different types of checksum should produce the same results, therefore the clients can pick any checksum algorithm at its own discretion. As for your example, I think it’s more likely that the OSC will decide to turn off compression for the .jpg file after trying to compress few chunks and figure out there is no benefit by doing that. Jinshan Yes, it’s reasonable to have chunk descriptors in the RPC. When there are multiple compressed chunks packed in one RPC, the exact bufsize for each chunk will be packed as well. Right now, the LNET doesn’t support partial pages inside niobuf(except the first and last page), so clients have to provide enough information in the chunk descriptor so the server can deduce the padding size for each chunk in the niobuf. compression. Initially we wanted to extend the niobuf struct by those fields. I think that change would affect the RPC request structure very much since the first Lustre message fields will not be followed by an array of niobufs, but by an array of records, which can contain an array of niobufs. We just need a new format of RPC. Please take a look at RQF_OST_BRW_{READ,WRITE}. What we need is probably some thing like RQF_OST_COMP_BRW_{READ,WRITE}, which is basically the same thing but with chunk descriptor: static const struct req_msg_field *ost_comp_brw_client[] = { &RMF_PTLRPC_BODY, &RMF_OST_BODY, &RMF_OBD_IOOBJ, &RMF_NIOBUF_REMOTE, &RMF_CHUNK_DESCR, &RMF_CAPA1 }; On the server/storage side, the different niobufs must be then associated with the same record and provided to ZFS. Server changes: Since we work on the Lustre/ZFS interface, we think it would be the best to let Lustre compose the header information for every record (psize and algorithm, maybe also the checksum in the future). We will I tend to let ZFS do this job especially for checksum otherwise if Lustre provided wrong data it would affect the consistency of ZFS. We want to allow Lustre clients to use the same ZFS checksum in the future, so there needs to be an interface to pass this. If ZFS verifies the checksum when the write is first submitted, and returns an error before doing actual filesystem modifications then it can verify the checksum is correct for that block, and we can skip the Lustre RPC checksum. This would probably work OK with the "zero copy" interface that we use, where data buffers are preallocated for RDMA without actually being attached to a TXG, and then the checksum would be verified by ZFS at submission. store these values at the beginning of every record in 4 Bytes each. Currently, when ZFS does compression itself, the compressed size is stored only within the compressed data. Some algorithms get it when starting the decompression, for lz4 it is stored at the beginning. With our approach, we would unify the record-metadata for any algorithm, but Wait, are you suggesting to store record/chunk-metadata into persistent storage? at the moment it would not be accessible by ZFS without changes to ZFS structures. ZFS will also hold an extra variable whether the data is compressed at all. When reading and the data is compressed, it is up to Lustre to get the original size and algorithm, to decompress the data and put it into page structure. Yes, the server will check the capability of client to decide if to return compressed data. I don't look into the corresponding code but Matt mentioned before this is pretty much the same interface of ZFS send/recv. Thanks, Jinshan Any comments or ideas are very welcome! Regards, Anna _______________________________________________ lustre-devel mailing list lustre-devel at lists.lustre.org http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org Cheers, Andreas -- Andreas Dilger Lustre Principal Architect Intel Corporation -------------- next part -------------- An HTML attachment was scrubbed... URL: From andreas.dilger at intel.com Fri Feb 17 21:36:51 2017 From: andreas.dilger at intel.com (Dilger, Andreas) Date: Fri, 17 Feb 2017 21:36:51 +0000 Subject: [lustre-devel] Design proposal for client-side compression In-Reply-To: References: <1483967258.2622.24.camel@informatik.uni-hamburg.de> <1484223328.3937.60.camel@informatik.uni-hamburg.de> <1484749185.3965.114.camel@informatik.uni-hamburg.de> <1487254536.4777.51.camel@informatik.uni-hamburg.de> <6D3CC4C5-E789-4E2B-8428-2EA20CC7674E@intel.com> Message-ID: <38CECFD6-E1EB-4292-992C-F9C65A820A84@intel.com> On Feb 17, 2017, at 14:03, Xiong, Jinshan wrote: > >> >> On Feb 17, 2017, at 12:29 PM, Dilger, Andreas wrote: >> >> On Feb 17, 2017, at 12:15, Xiong, Jinshan wrote: >>> >>> Hi Anna, >>> >>> Thanks for updating. Please see inserted lines. >>> >>>> On Feb 16, 2017, at 6:15 AM, Anna Fuchs wrote: >>>> >>>> Dear all, >>>> >>>> I would like to update you about my progress on the project. >>>> Unfortunately, I can not publish a complete design of the feature, >>>> since it changes very much during the development. >>>> >>>> First the work related to the client changes: >>>> >>>> I had to discard my approach to introduce the changes within the >>>> sptlrpc layer for the moment. Compression of the data affects >>>> especially the resulting number of pages and therefore number and size >>>> of niobufs, size and structure of the descriptor and request, size of >>>> the bulk kiov, checksums and in the end the async arguments. Actually >>>> it affects everything, that is set within the osc_brw_prep_request >>>> function in osc_request.c. When entering the sptlrpc layer, most of >>>> that parameters are already set and I would need to update everything. >>>> That causes double work and requires a lot of code duplication from the >>>> osc module. >>>> >>>> My current dirty prototype invokes compression just at the beginning of >>>> that function, before niocount is calculated. I need to have a separate >>>> bunch of pages to store compressed data so that I would not overwrite >>>> the content of the original pages, which may be exposed to the >>>> userspace process. >>>> The original pages would be freed and the compressed pages processed >>>> for the request and finally also freed. >>> >>> Please remember to reserve some pages as emergency pool to avoid the problem that the system memory is in shortage and it needs some free pages for compression to writeback more pages. We may use the same pool to support partial block so it must be greater than the largest ZFS block size(I prefer to not compress data for partial blocks). >>> >>> After RPC is issued, the pages contain compressed data will be pinned in memory for a while for recovery reasons. Therefore, when emergency pages are used, you will have to issue the RPC in sync mode, so that the server can commit the write trans into persistent storage and client can use the emergency pages for new RPC immediately. >>> >>>> >>>> I also reconsidered the idea to do compression niobuf-wise. Due to the >>>> file layout, compression should be done record-wise. Since a niobuf is >>>> a technical requirement for the pages to be contiguous, a record (e.g. >>>> 128KB) is a logical unit. In my understanding, it can happen, that one >>>> record contains of several niobufs whenever we do not have enough >>> >>> We use the terminology ‘chunk’ as the preferred block size on the OST. Let’s use the same terminology ;-) >>> >>>> contiguous pages for a complete record. For that reason, I would like >>>> to leave the niobuf structure as is it and introduce a record structure >>>> on top of it. That record structure will hold the logical(uncompressed) >>>> and physical(compressed) data sizes and the algorithm used for >>> >>> hmm… not sure if this is the right approach. I tend to think the client will talk with the OST at connecting time and negotiate the compress algorithm, and after that they should use the same algorithm. There is no need to carry this information in every single RPC. >> >> I'm not sure I agree. The benefits of compression may be different on a per-file basis (e.g. .txt vs. .jpg) so there shouldn't be a fixed compression algorithm required for all RPCs. I could imagine that we don't want to allow a different compression type for each block (which ZFS allows), but one compression type per RPC should be OK. We do the same for the checksum type. > > The difference between checksum and compression is that different types of checksum should produce the same results, therefore the clients can pick any checksum algorithm at its own discretion. > > As for your example, I think it’s more likely that the OSC will decide to turn off compression for the .jpg file after trying to compress few chunks and figure out there is no benefit by doing that. Actually, Anna's research group did some testing with dynamic compression at the ZFS level on a per-block basis (which I would love to see submitted upstream to ZFS) so that the node can balance CPU usage vs. compression ratio for each file or potentially each block. I don't want to bake in a connect-time compression algorithm into the network protocol, even if we don't implement dynamic compression selection at runtime immediately. I'm sure we can find some space in the RPC for the compression algorithm, or even in a new niobuf_remote if the RPC format is changing anyway. If there were only a handful of compression algorithms we could encode the compression algorithm into 4 bits of rnb_flags. I don't _think_ we need to also specify the compression level or other parameters, just the algorithm (e.g. gzip, lz4), but I don't want to be too limiting if the number of compression algorithms continues to grow so a separate 32-bit field with a 32-bit padding would be safer if the protocol is already being changed. It would also be good to add some padding to obd_ioobj for future use while we are in there. Cheers, Andreas -- Andreas Dilger Lustre Principal Architect Intel Corporation From doug.s.oucharek at intel.com Fri Feb 17 22:16:33 2017 From: doug.s.oucharek at intel.com (Doug Oucharek) Date: Fri, 17 Feb 2017 14:16:33 -0800 Subject: [lustre-devel] [PATCH] staging: lustre: ko2iblnd: Adapt to the removal of ib_get_dma_mr() Message-ID: <1487369793-31155-1-git-send-email-doug.s.oucharek@intel.com> In Linux kernel 4.9-rc1, the function ib_get_dma_mr() was removed and a second parameter was added to ib_alloc_pd(). As this broke the building of the ko2iblnd module in staging, the Kconfig for LNet has marked ko2iblnd as broken and stopped building it. This patch fixes this breakage by: - Removing the BROKEN tag from lnet/Kconfig. - Make it so the module parameter map_on_demand can no longer be zero (we have to configure FMR/FastReg pools; it can no longer be off). - No longer try to use the global DMA memory region, but make use of the FMR/FastReg pool for all RDMA Tx operations. - Everywhere we are using the device DMA mr to derive the L-key for non-registered memory regions, use the pd->local_dma_lkey value instead. - Make the default map_on_demand = 256. This will allow nodes with this patch to still connected to older nodes without this patch and FMR/FastReg turned off. When FMR/FastReg is turned off, we use 256 as the max frags so the two sides will still be able to communicate and work. - Fix a mistake with BUILD_BUG_ON calls in o2iblnd.c which caused compiling to fail. Signed-off-by: Doug Oucharek Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-9026 Reviewed-on: https://review.whamcloud.com/#/c/24931/ Reviewed-by: James Simmons Changelog: v1) Initial patch v2) Rebased and handle a fix to BUILD_BUG_ON --- drivers/staging/lustre/lnet/Kconfig | 1 - .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 77 ++-------------------- .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h | 3 - .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 17 +---- .../lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c | 12 ++-- 5 files changed, 16 insertions(+), 94 deletions(-) diff --git a/drivers/staging/lustre/lnet/Kconfig b/drivers/staging/lustre/lnet/Kconfig index 13b4327..2b59301 100644 --- a/drivers/staging/lustre/lnet/Kconfig +++ b/drivers/staging/lustre/lnet/Kconfig @@ -35,7 +35,6 @@ config LNET_SELFTEST config LNET_XPRT_IB tristate "LNET infiniband support" depends on LNET && INFINIBAND && INFINIBAND_ADDR_TRANS - depends on BROKEN default LNET && INFINIBAND help This option allows the LNET users to use infiniband as an diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c index b1e8508..0618b79 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c @@ -1281,27 +1281,6 @@ static void kiblnd_map_tx_pool(struct kib_tx_pool *tpo) } } -struct ib_mr *kiblnd_find_rd_dma_mr(struct lnet_ni *ni, struct kib_rdma_desc *rd, - int negotiated_nfrags) -{ - struct kib_net *net = ni->ni_data; - struct kib_hca_dev *hdev = net->ibn_dev->ibd_hdev; - struct lnet_ioctl_config_o2iblnd_tunables *tunables; - __u16 nfrags; - int mod; - - tunables = &ni->ni_lnd_tunables->lt_tun_u.lt_o2ib; - mod = tunables->lnd_map_on_demand; - nfrags = (negotiated_nfrags != -1) ? negotiated_nfrags : mod; - - LASSERT(hdev->ibh_mrs); - - if (mod > 0 && nfrags <= rd->rd_nfrags) - return NULL; - - return hdev->ibh_mrs; -} - static void kiblnd_destroy_fmr_pool(struct kib_fmr_pool *fpo) { LASSERT(!fpo->fpo_map_count); @@ -2168,21 +2147,12 @@ static int kiblnd_net_init_pools(struct kib_net *net, lnet_ni_t *ni, __u32 *cpts int ncpts) { struct lnet_ioctl_config_o2iblnd_tunables *tunables; - unsigned long flags; int cpt; int rc; int i; tunables = &ni->ni_lnd_tunables->lt_tun_u.lt_o2ib; - read_lock_irqsave(&kiblnd_data.kib_global_lock, flags); - if (!tunables->lnd_map_on_demand) { - read_unlock_irqrestore(&kiblnd_data.kib_global_lock, flags); - goto create_tx_pool; - } - - read_unlock_irqrestore(&kiblnd_data.kib_global_lock, flags); - if (tunables->lnd_fmr_pool_size < *kiblnd_tunables.kib_ntx / 4) { CERROR("Can't set fmr pool size (%d) < ntx / 4(%d)\n", tunables->lnd_fmr_pool_size, @@ -2227,7 +2197,6 @@ static int kiblnd_net_init_pools(struct kib_net *net, lnet_ni_t *ni, __u32 *cpts if (i > 0) LASSERT(i == ncpts); - create_tx_pool: /* * cfs_precpt_alloc is creating an array of struct kib_tx_poolset * The number of struct kib_tx_poolsets create is equal to the @@ -2283,20 +2252,8 @@ static int kiblnd_hdev_get_attr(struct kib_hca_dev *hdev) return -EINVAL; } -static void kiblnd_hdev_cleanup_mrs(struct kib_hca_dev *hdev) -{ - if (!hdev->ibh_mrs) - return; - - ib_dereg_mr(hdev->ibh_mrs); - - hdev->ibh_mrs = NULL; -} - void kiblnd_hdev_destroy(struct kib_hca_dev *hdev) { - kiblnd_hdev_cleanup_mrs(hdev); - if (hdev->ibh_pd) ib_dealloc_pd(hdev->ibh_pd); @@ -2306,28 +2263,6 @@ void kiblnd_hdev_destroy(struct kib_hca_dev *hdev) LIBCFS_FREE(hdev, sizeof(*hdev)); } -static int kiblnd_hdev_setup_mrs(struct kib_hca_dev *hdev) -{ - struct ib_mr *mr; - int rc; - int acflags = IB_ACCESS_LOCAL_WRITE | IB_ACCESS_REMOTE_WRITE; - - rc = kiblnd_hdev_get_attr(hdev); - if (rc) - return rc; - - mr = ib_get_dma_mr(hdev->ibh_pd, acflags); - if (IS_ERR(mr)) { - CERROR("Failed ib_get_dma_mr : %ld\n", PTR_ERR(mr)); - kiblnd_hdev_cleanup_mrs(hdev); - return PTR_ERR(mr); - } - - hdev->ibh_mrs = mr; - - return 0; -} - /* DUMMY */ static int kiblnd_dummy_callback(struct rdma_cm_id *cmid, struct rdma_cm_event *event) @@ -2482,9 +2417,9 @@ int kiblnd_dev_failover(struct kib_dev *dev) goto out; } - rc = kiblnd_hdev_setup_mrs(hdev); + rc = kiblnd_hdev_get_attr(hdev); if (rc) { - CERROR("Can't setup device: %d\n", rc); + CERROR("Can't get device attributes: %d\n", rc); goto out; } @@ -3021,12 +2956,12 @@ static void __exit ko2iblnd_exit(void) static int __init ko2iblnd_init(void) { BUILD_BUG_ON(sizeof(struct kib_msg) > IBLND_MSG_SIZE); - BUILD_BUG_ON(!offsetof(struct kib_msg, + BUILD_BUG_ON(offsetof(struct kib_msg, ibm_u.get.ibgm_rd.rd_frags[IBLND_MAX_RDMA_FRAGS]) - <= IBLND_MSG_SIZE); - BUILD_BUG_ON(!offsetof(struct kib_msg, + > IBLND_MSG_SIZE); + BUILD_BUG_ON(offsetof(struct kib_msg, ibm_u.putack.ibpam_rd.rd_frags[IBLND_MAX_RDMA_FRAGS]) - <= IBLND_MSG_SIZE); + > IBLND_MSG_SIZE); kiblnd_tunables_init(); diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h index 2cb4298..366372d 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h @@ -172,7 +172,6 @@ struct kib_hca_dev { __u64 ibh_page_mask; /* page mask of current HCA */ int ibh_mr_shift; /* bits shift of max MR size */ __u64 ibh_mr_size; /* size of MR */ - struct ib_mr *ibh_mrs; /* global MR */ struct ib_pd *ibh_pd; /* PD */ struct kib_dev *ibh_dev; /* owner */ atomic_t ibh_ref; /* refcount */ @@ -978,8 +977,6 @@ static inline unsigned int kiblnd_sg_dma_len(struct ib_device *dev, #define KIBLND_CONN_PARAM(e) ((e)->param.conn.private_data) #define KIBLND_CONN_PARAM_LEN(e) ((e)->param.conn.private_data_len) -struct ib_mr *kiblnd_find_rd_dma_mr(struct lnet_ni *ni, struct kib_rdma_desc *rd, - int negotiated_nfrags); void kiblnd_map_rx_descs(struct kib_conn *conn); void kiblnd_unmap_rx_descs(struct kib_conn *conn); void kiblnd_pool_free_node(struct kib_pool *pool, struct list_head *node); diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c index e2f3f72..6eaa548 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c @@ -157,7 +157,6 @@ static int kiblnd_init_rdma(struct kib_conn *conn, struct kib_tx *tx, int type, struct kib_conn *conn = rx->rx_conn; struct kib_net *net = conn->ibc_peer->ibp_ni->ni_data; struct ib_recv_wr *bad_wrq = NULL; - struct ib_mr *mr = conn->ibc_hdev->ibh_mrs; int rc; LASSERT(net); @@ -165,9 +164,8 @@ static int kiblnd_init_rdma(struct kib_conn *conn, struct kib_tx *tx, int type, LASSERT(credit == IBLND_POSTRX_NO_CREDIT || credit == IBLND_POSTRX_PEER_CREDIT || credit == IBLND_POSTRX_RSRVD_CREDIT); - LASSERT(mr); - rx->rx_sge.lkey = mr->lkey; + rx->rx_sge.lkey = conn->ibc_hdev->ibh_pd->local_dma_lkey; rx->rx_sge.addr = rx->rx_msgaddr; rx->rx_sge.length = IBLND_MSG_SIZE; @@ -613,7 +611,6 @@ static int kiblnd_map_tx(lnet_ni_t *ni, struct kib_tx *tx, struct kib_rdma_desc { struct kib_net *net = ni->ni_data; struct kib_hca_dev *hdev = net->ibn_dev->ibd_hdev; - struct ib_mr *mr = NULL; __u32 nob; int i; @@ -635,14 +632,6 @@ static int kiblnd_map_tx(lnet_ni_t *ni, struct kib_tx *tx, struct kib_rdma_desc nob += rd->rd_frags[i].rf_nob; } - mr = kiblnd_find_rd_dma_mr(ni, rd, tx->tx_conn ? - tx->tx_conn->ibc_max_frags : -1); - if (mr) { - /* found pre-mapping MR */ - rd->rd_key = (rd != tx->tx_rd) ? mr->rkey : mr->lkey; - return 0; - } - if (net->ibn_fmr_ps) return kiblnd_fmr_map_tx(net, tx, rd, nob); @@ -1028,16 +1017,14 @@ static int kiblnd_map_tx(lnet_ni_t *ni, struct kib_tx *tx, struct kib_rdma_desc struct ib_sge *sge = &tx->tx_sge[tx->tx_nwrq]; struct ib_rdma_wr *wrq = &tx->tx_wrq[tx->tx_nwrq]; int nob = offsetof(struct kib_msg, ibm_u) + body_nob; - struct ib_mr *mr = hdev->ibh_mrs; LASSERT(tx->tx_nwrq >= 0); LASSERT(tx->tx_nwrq < IBLND_MAX_RDMA_FRAGS + 1); LASSERT(nob <= IBLND_MSG_SIZE); - LASSERT(mr); kiblnd_init_msg(tx->tx_msg, type, body_nob); - sge->lkey = mr->lkey; + sge->lkey = hdev->ibh_pd->local_dma_lkey; sge->addr = tx->tx_msgaddr; sge->length = nob; diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c index 44e960f..3c81b527 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c @@ -106,7 +106,8 @@ module_param(concurrent_sends, int, 0444); MODULE_PARM_DESC(concurrent_sends, "send work-queue sizing"); -static int map_on_demand; +#define IBLND_DEFAULT_MAP_ON_DEMAND IBLND_MAX_RDMA_FRAGS +static int map_on_demand = IBLND_DEFAULT_MAP_ON_DEMAND; module_param(map_on_demand, int, 0444); MODULE_PARM_DESC(map_on_demand, "map on demand"); @@ -228,10 +229,13 @@ int kiblnd_tunables_setup(struct lnet_ni *ni) if (tunables->lnd_peercredits_hiw >= ni->ni_peertxcredits) tunables->lnd_peercredits_hiw = ni->ni_peertxcredits - 1; - if (tunables->lnd_map_on_demand < 0 || + if (tunables->lnd_map_on_demand <= 0 || tunables->lnd_map_on_demand > IBLND_MAX_RDMA_FRAGS) { - /* disable map-on-demand */ - tunables->lnd_map_on_demand = 0; + /* Use the default */ + CWARN("Invalid map_on_demand (%d), expects 1 - %d. Using default of %d\n", + tunables->lnd_map_on_demand, + IBLND_MAX_RDMA_FRAGS, IBLND_DEFAULT_MAP_ON_DEMAND); + tunables->lnd_map_on_demand = IBLND_DEFAULT_MAP_ON_DEMAND; } if (tunables->lnd_map_on_demand == 1) { -- 1.8.3.1 From doug.s.oucharek at intel.com Sat Feb 18 18:04:09 2017 From: doug.s.oucharek at intel.com (Doug Oucharek) Date: Sat, 18 Feb 2017 10:04:09 -0800 Subject: [lustre-devel] [PATCH v2] staging: lustre: ko2iblnd: Adapt to the removal of ib_get_dma_mr() Message-ID: <1487441050-19728-1-git-send-email-doug.s.oucharek@intel.com> I tried to send this patch yesterday and it appeared to work. However, I did not see an email from the list. Assuming it failed and trying again. I apologize if this is a repeat. From doug.s.oucharek at intel.com Sat Feb 18 18:04:10 2017 From: doug.s.oucharek at intel.com (Doug Oucharek) Date: Sat, 18 Feb 2017 10:04:10 -0800 Subject: [lustre-devel] [PATCH] staging: lustre: ko2iblnd: Adapt to the removal of ib_get_dma_mr() In-Reply-To: <1487441050-19728-1-git-send-email-doug.s.oucharek@intel.com> References: <1487441050-19728-1-git-send-email-doug.s.oucharek@intel.com> Message-ID: <1487441050-19728-2-git-send-email-doug.s.oucharek@intel.com> In Linux kernel 4.9-rc1, the function ib_get_dma_mr() was removed and a second parameter was added to ib_alloc_pd(). As this broke the building of the ko2iblnd module in staging, the Kconfig for LNet has marked ko2iblnd as broken and stopped building it. This patch fixes this breakage by: - Removing the BROKEN tag from lnet/Kconfig. - Make it so the module parameter map_on_demand can no longer be zero (we have to configure FMR/FastReg pools; it can no longer be off). - No longer try to use the global DMA memory region, but make use of the FMR/FastReg pool for all RDMA Tx operations. - Everywhere we are using the device DMA mr to derive the L-key for non-registered memory regions, use the pd->local_dma_lkey value instead. - Make the default map_on_demand = 256. This will allow nodes with this patch to still connected to older nodes without this patch and FMR/FastReg turned off. When FMR/FastReg is turned off, we use 256 as the max frags so the two sides will still be able to communicate and work. - Fix a mistake with BUILD_BUG_ON calls in o2iblnd.c which caused compiling to fail. Signed-off-by: Doug Oucharek Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-9026 Reviewed-on: https://review.whamcloud.com/#/c/24931/ Reviewed-by: James Simmons Changelog: v1) Initial patch v2) Rebased and handle a fix to BUILD_BUG_ON --- drivers/staging/lustre/lnet/Kconfig | 1 - .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 77 ++-------------------- .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h | 3 - .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 17 +---- .../lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c | 12 ++-- 5 files changed, 16 insertions(+), 94 deletions(-) diff --git a/drivers/staging/lustre/lnet/Kconfig b/drivers/staging/lustre/lnet/Kconfig index 13b4327..2b59301 100644 --- a/drivers/staging/lustre/lnet/Kconfig +++ b/drivers/staging/lustre/lnet/Kconfig @@ -35,7 +35,6 @@ config LNET_SELFTEST config LNET_XPRT_IB tristate "LNET infiniband support" depends on LNET && INFINIBAND && INFINIBAND_ADDR_TRANS - depends on BROKEN default LNET && INFINIBAND help This option allows the LNET users to use infiniband as an diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c index b1e8508..0618b79 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c @@ -1281,27 +1281,6 @@ static void kiblnd_map_tx_pool(struct kib_tx_pool *tpo) } } -struct ib_mr *kiblnd_find_rd_dma_mr(struct lnet_ni *ni, struct kib_rdma_desc *rd, - int negotiated_nfrags) -{ - struct kib_net *net = ni->ni_data; - struct kib_hca_dev *hdev = net->ibn_dev->ibd_hdev; - struct lnet_ioctl_config_o2iblnd_tunables *tunables; - __u16 nfrags; - int mod; - - tunables = &ni->ni_lnd_tunables->lt_tun_u.lt_o2ib; - mod = tunables->lnd_map_on_demand; - nfrags = (negotiated_nfrags != -1) ? negotiated_nfrags : mod; - - LASSERT(hdev->ibh_mrs); - - if (mod > 0 && nfrags <= rd->rd_nfrags) - return NULL; - - return hdev->ibh_mrs; -} - static void kiblnd_destroy_fmr_pool(struct kib_fmr_pool *fpo) { LASSERT(!fpo->fpo_map_count); @@ -2168,21 +2147,12 @@ static int kiblnd_net_init_pools(struct kib_net *net, lnet_ni_t *ni, __u32 *cpts int ncpts) { struct lnet_ioctl_config_o2iblnd_tunables *tunables; - unsigned long flags; int cpt; int rc; int i; tunables = &ni->ni_lnd_tunables->lt_tun_u.lt_o2ib; - read_lock_irqsave(&kiblnd_data.kib_global_lock, flags); - if (!tunables->lnd_map_on_demand) { - read_unlock_irqrestore(&kiblnd_data.kib_global_lock, flags); - goto create_tx_pool; - } - - read_unlock_irqrestore(&kiblnd_data.kib_global_lock, flags); - if (tunables->lnd_fmr_pool_size < *kiblnd_tunables.kib_ntx / 4) { CERROR("Can't set fmr pool size (%d) < ntx / 4(%d)\n", tunables->lnd_fmr_pool_size, @@ -2227,7 +2197,6 @@ static int kiblnd_net_init_pools(struct kib_net *net, lnet_ni_t *ni, __u32 *cpts if (i > 0) LASSERT(i == ncpts); - create_tx_pool: /* * cfs_precpt_alloc is creating an array of struct kib_tx_poolset * The number of struct kib_tx_poolsets create is equal to the @@ -2283,20 +2252,8 @@ static int kiblnd_hdev_get_attr(struct kib_hca_dev *hdev) return -EINVAL; } -static void kiblnd_hdev_cleanup_mrs(struct kib_hca_dev *hdev) -{ - if (!hdev->ibh_mrs) - return; - - ib_dereg_mr(hdev->ibh_mrs); - - hdev->ibh_mrs = NULL; -} - void kiblnd_hdev_destroy(struct kib_hca_dev *hdev) { - kiblnd_hdev_cleanup_mrs(hdev); - if (hdev->ibh_pd) ib_dealloc_pd(hdev->ibh_pd); @@ -2306,28 +2263,6 @@ void kiblnd_hdev_destroy(struct kib_hca_dev *hdev) LIBCFS_FREE(hdev, sizeof(*hdev)); } -static int kiblnd_hdev_setup_mrs(struct kib_hca_dev *hdev) -{ - struct ib_mr *mr; - int rc; - int acflags = IB_ACCESS_LOCAL_WRITE | IB_ACCESS_REMOTE_WRITE; - - rc = kiblnd_hdev_get_attr(hdev); - if (rc) - return rc; - - mr = ib_get_dma_mr(hdev->ibh_pd, acflags); - if (IS_ERR(mr)) { - CERROR("Failed ib_get_dma_mr : %ld\n", PTR_ERR(mr)); - kiblnd_hdev_cleanup_mrs(hdev); - return PTR_ERR(mr); - } - - hdev->ibh_mrs = mr; - - return 0; -} - /* DUMMY */ static int kiblnd_dummy_callback(struct rdma_cm_id *cmid, struct rdma_cm_event *event) @@ -2482,9 +2417,9 @@ int kiblnd_dev_failover(struct kib_dev *dev) goto out; } - rc = kiblnd_hdev_setup_mrs(hdev); + rc = kiblnd_hdev_get_attr(hdev); if (rc) { - CERROR("Can't setup device: %d\n", rc); + CERROR("Can't get device attributes: %d\n", rc); goto out; } @@ -3021,12 +2956,12 @@ static void __exit ko2iblnd_exit(void) static int __init ko2iblnd_init(void) { BUILD_BUG_ON(sizeof(struct kib_msg) > IBLND_MSG_SIZE); - BUILD_BUG_ON(!offsetof(struct kib_msg, + BUILD_BUG_ON(offsetof(struct kib_msg, ibm_u.get.ibgm_rd.rd_frags[IBLND_MAX_RDMA_FRAGS]) - <= IBLND_MSG_SIZE); - BUILD_BUG_ON(!offsetof(struct kib_msg, + > IBLND_MSG_SIZE); + BUILD_BUG_ON(offsetof(struct kib_msg, ibm_u.putack.ibpam_rd.rd_frags[IBLND_MAX_RDMA_FRAGS]) - <= IBLND_MSG_SIZE); + > IBLND_MSG_SIZE); kiblnd_tunables_init(); diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h index 2cb4298..366372d 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h @@ -172,7 +172,6 @@ struct kib_hca_dev { __u64 ibh_page_mask; /* page mask of current HCA */ int ibh_mr_shift; /* bits shift of max MR size */ __u64 ibh_mr_size; /* size of MR */ - struct ib_mr *ibh_mrs; /* global MR */ struct ib_pd *ibh_pd; /* PD */ struct kib_dev *ibh_dev; /* owner */ atomic_t ibh_ref; /* refcount */ @@ -978,8 +977,6 @@ static inline unsigned int kiblnd_sg_dma_len(struct ib_device *dev, #define KIBLND_CONN_PARAM(e) ((e)->param.conn.private_data) #define KIBLND_CONN_PARAM_LEN(e) ((e)->param.conn.private_data_len) -struct ib_mr *kiblnd_find_rd_dma_mr(struct lnet_ni *ni, struct kib_rdma_desc *rd, - int negotiated_nfrags); void kiblnd_map_rx_descs(struct kib_conn *conn); void kiblnd_unmap_rx_descs(struct kib_conn *conn); void kiblnd_pool_free_node(struct kib_pool *pool, struct list_head *node); diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c index e2f3f72..6eaa548 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c @@ -157,7 +157,6 @@ static int kiblnd_init_rdma(struct kib_conn *conn, struct kib_tx *tx, int type, struct kib_conn *conn = rx->rx_conn; struct kib_net *net = conn->ibc_peer->ibp_ni->ni_data; struct ib_recv_wr *bad_wrq = NULL; - struct ib_mr *mr = conn->ibc_hdev->ibh_mrs; int rc; LASSERT(net); @@ -165,9 +164,8 @@ static int kiblnd_init_rdma(struct kib_conn *conn, struct kib_tx *tx, int type, LASSERT(credit == IBLND_POSTRX_NO_CREDIT || credit == IBLND_POSTRX_PEER_CREDIT || credit == IBLND_POSTRX_RSRVD_CREDIT); - LASSERT(mr); - rx->rx_sge.lkey = mr->lkey; + rx->rx_sge.lkey = conn->ibc_hdev->ibh_pd->local_dma_lkey; rx->rx_sge.addr = rx->rx_msgaddr; rx->rx_sge.length = IBLND_MSG_SIZE; @@ -613,7 +611,6 @@ static int kiblnd_map_tx(lnet_ni_t *ni, struct kib_tx *tx, struct kib_rdma_desc { struct kib_net *net = ni->ni_data; struct kib_hca_dev *hdev = net->ibn_dev->ibd_hdev; - struct ib_mr *mr = NULL; __u32 nob; int i; @@ -635,14 +632,6 @@ static int kiblnd_map_tx(lnet_ni_t *ni, struct kib_tx *tx, struct kib_rdma_desc nob += rd->rd_frags[i].rf_nob; } - mr = kiblnd_find_rd_dma_mr(ni, rd, tx->tx_conn ? - tx->tx_conn->ibc_max_frags : -1); - if (mr) { - /* found pre-mapping MR */ - rd->rd_key = (rd != tx->tx_rd) ? mr->rkey : mr->lkey; - return 0; - } - if (net->ibn_fmr_ps) return kiblnd_fmr_map_tx(net, tx, rd, nob); @@ -1028,16 +1017,14 @@ static int kiblnd_map_tx(lnet_ni_t *ni, struct kib_tx *tx, struct kib_rdma_desc struct ib_sge *sge = &tx->tx_sge[tx->tx_nwrq]; struct ib_rdma_wr *wrq = &tx->tx_wrq[tx->tx_nwrq]; int nob = offsetof(struct kib_msg, ibm_u) + body_nob; - struct ib_mr *mr = hdev->ibh_mrs; LASSERT(tx->tx_nwrq >= 0); LASSERT(tx->tx_nwrq < IBLND_MAX_RDMA_FRAGS + 1); LASSERT(nob <= IBLND_MSG_SIZE); - LASSERT(mr); kiblnd_init_msg(tx->tx_msg, type, body_nob); - sge->lkey = mr->lkey; + sge->lkey = hdev->ibh_pd->local_dma_lkey; sge->addr = tx->tx_msgaddr; sge->length = nob; diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c index 44e960f..3c81b527 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c @@ -106,7 +106,8 @@ module_param(concurrent_sends, int, 0444); MODULE_PARM_DESC(concurrent_sends, "send work-queue sizing"); -static int map_on_demand; +#define IBLND_DEFAULT_MAP_ON_DEMAND IBLND_MAX_RDMA_FRAGS +static int map_on_demand = IBLND_DEFAULT_MAP_ON_DEMAND; module_param(map_on_demand, int, 0444); MODULE_PARM_DESC(map_on_demand, "map on demand"); @@ -228,10 +229,13 @@ int kiblnd_tunables_setup(struct lnet_ni *ni) if (tunables->lnd_peercredits_hiw >= ni->ni_peertxcredits) tunables->lnd_peercredits_hiw = ni->ni_peertxcredits - 1; - if (tunables->lnd_map_on_demand < 0 || + if (tunables->lnd_map_on_demand <= 0 || tunables->lnd_map_on_demand > IBLND_MAX_RDMA_FRAGS) { - /* disable map-on-demand */ - tunables->lnd_map_on_demand = 0; + /* Use the default */ + CWARN("Invalid map_on_demand (%d), expects 1 - %d. Using default of %d\n", + tunables->lnd_map_on_demand, + IBLND_MAX_RDMA_FRAGS, IBLND_DEFAULT_MAP_ON_DEMAND); + tunables->lnd_map_on_demand = IBLND_DEFAULT_MAP_ON_DEMAND; } if (tunables->lnd_map_on_demand == 1) { -- 1.8.3.1 From jsimmons at infradead.org Sat Feb 18 21:47:01 2017 From: jsimmons at infradead.org (James Simmons) Date: Sat, 18 Feb 2017 16:47:01 -0500 Subject: [lustre-devel] [PATCH 00/14] staging: lustre: missing fixes from lustre 2.8 Message-ID: <1487454435-4895-1-git-send-email-jsimmons@infradead.org> This patch series is a batch of fixes from the lustre 2.8 release that is missing from the upstream client. These patches are dependent on the order applied. Alex Zhuravlev (1): staging: lustre: llog: limit file size of plain logs Andreas Dilger (1): staging: lustre: llite: remove extraneous export parameter Bobi Jam (2): staging: lustre: llite: lower message level for ll_setattr_raw() staging: lustre: llite: omit to update wire data James Simmons (1): staging: lustre: lprocfs: move lprocfs_stats_[un]lock to a source file Jinshan Xiong (4): staging: lustre: osc: remove obsolete asserts staging: lustre: lov: cleanup when cl_io_iter_init() fails staging: lustre: ldlm: handle ldlm lock cancel race when evicting client. staging: lustre: osc: further LRU OSC cleanup after eviction Niu Yawei (1): staging: lustre: ldlm: fix race of starting bl threads Vitaly Fertman (2): staging: lustre: ldlm: reduce ldlm pool recalc window staging: lustre: ldlm: disconnect speedup Yang Sheng (1): staging: lustre: lov: trying smaller memory allocations wang di (1): staging: lustre: llog: change lgh_hdr_lock to mutex drivers/staging/lustre/lustre/include/cl_object.h | 13 +- .../staging/lustre/lustre/include/lprocfs_status.h | 120 ++------------ drivers/staging/lustre/lustre/include/lustre_dlm.h | 11 +- .../lustre/lustre/include/lustre_dlm_flags.h | 3 + drivers/staging/lustre/lustre/include/lustre_log.h | 2 +- .../staging/lustre/lustre/include/obd_support.h | 1 + drivers/staging/lustre/lustre/ldlm/ldlm_internal.h | 5 +- drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 47 ++++-- drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c | 178 +++++++++++++-------- drivers/staging/lustre/lustre/ldlm/ldlm_pool.c | 7 +- drivers/staging/lustre/lustre/ldlm/ldlm_request.c | 14 +- drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 2 +- drivers/staging/lustre/lustre/llite/file.c | 49 +++--- drivers/staging/lustre/lustre/llite/glimpse.c | 4 +- drivers/staging/lustre/lustre/llite/lcommon_cl.c | 8 +- drivers/staging/lustre/lustre/llite/lcommon_misc.c | 2 +- .../staging/lustre/lustre/llite/llite_internal.h | 2 +- drivers/staging/lustre/lustre/llite/llite_lib.c | 14 +- drivers/staging/lustre/lustre/llite/llite_mmap.c | 4 +- drivers/staging/lustre/lustre/llite/lproc_llite.c | 2 +- drivers/staging/lustre/lustre/llite/rw.c | 2 +- drivers/staging/lustre/lustre/llite/vvp_dev.c | 10 +- drivers/staging/lustre/lustre/llite/vvp_io.c | 1 + drivers/staging/lustre/lustre/llite/xattr.c | 2 +- .../staging/lustre/lustre/lov/lov_cl_internal.h | 41 +++-- drivers/staging/lustre/lustre/lov/lov_io.c | 24 +-- drivers/staging/lustre/lustre/lov/lov_object.c | 2 +- drivers/staging/lustre/lustre/obdclass/cl_object.c | 6 +- drivers/staging/lustre/lustre/obdclass/llog.c | 18 ++- .../lustre/lustre/obdclass/lprocfs_status.c | 111 +++++++++++++ .../staging/lustre/lustre/obdecho/echo_client.c | 6 +- drivers/staging/lustre/lustre/osc/lproc_osc.c | 2 +- drivers/staging/lustre/lustre/osc/osc_cache.c | 3 +- .../staging/lustre/lustre/osc/osc_cl_internal.h | 4 +- drivers/staging/lustre/lustre/osc/osc_internal.h | 3 +- drivers/staging/lustre/lustre/osc/osc_io.c | 48 ++---- drivers/staging/lustre/lustre/osc/osc_lock.c | 60 ++++--- drivers/staging/lustre/lustre/osc/osc_object.c | 12 +- drivers/staging/lustre/lustre/osc/osc_page.c | 77 +++++++-- drivers/staging/lustre/lustre/osc/osc_request.c | 12 +- 40 files changed, 554 insertions(+), 378 deletions(-) -- 1.8.3.1 From jsimmons at infradead.org Sat Feb 18 21:47:03 2017 From: jsimmons at infradead.org (James Simmons) Date: Sat, 18 Feb 2017 16:47:03 -0500 Subject: [lustre-devel] [PATCH 02/14] staging: lustre: llite: omit to update wire data In-Reply-To: <1487454435-4895-1-git-send-email-jsimmons@infradead.org> References: <1487454435-4895-1-git-send-email-jsimmons@infradead.org> Message-ID: <1487454435-4895-3-git-send-email-jsimmons@infradead.org> From: Bobi Jam In ll_setattr_raw(), after op_data->op_attr has been copied, the attr is updated and op_data->op_attr does not get updated afterward. Signed-off-by: Bobi Jam Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6813 Reviewed-on: http://review.whamcloud.com/16462 Reviewed-by: Jinshan Xiong Reviewed-by: Niu Yawei Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/llite_lib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 34422df..973eee6 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -1504,8 +1504,6 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import) goto out; } - op_data->op_attr = *attr; - if (!hsm_import && attr->ia_valid & ATTR_SIZE) { /* * If we are changing file size, file content is @@ -1516,6 +1514,8 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import) clear_bit(LLIF_DATA_MODIFIED, &lli->lli_flags); } + op_data->op_attr = *attr; + rc = ll_md_setattr(dentry, op_data); if (rc) goto out; -- 1.8.3.1 From jsimmons at infradead.org Sat Feb 18 21:47:08 2017 From: jsimmons at infradead.org (James Simmons) Date: Sat, 18 Feb 2017 16:47:08 -0500 Subject: [lustre-devel] [PATCH 07/14] staging: lustre: lov: trying smaller memory allocations In-Reply-To: <1487454435-4895-1-git-send-email-jsimmons@infradead.org> References: <1487454435-4895-1-git-send-email-jsimmons@infradead.org> Message-ID: <1487454435-4895-8-git-send-email-jsimmons@infradead.org> From: Yang Sheng Reduce struct lov_io_sub to smaller memory usage on wide-stripe file systems. Signed-off-by: Yang Sheng Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7085 Reviewed-on: http://review.whamcloud.com/17476 Reviewed-by: Bob Glossman Reviewed-by: Jian Yu Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/include/cl_object.h | 6 ++-- drivers/staging/lustre/lustre/llite/file.c | 16 ++++----- drivers/staging/lustre/lustre/llite/glimpse.c | 4 +-- drivers/staging/lustre/lustre/llite/lcommon_cl.c | 8 ++--- drivers/staging/lustre/lustre/llite/lcommon_misc.c | 2 +- .../staging/lustre/lustre/llite/llite_internal.h | 2 +- drivers/staging/lustre/lustre/llite/llite_mmap.c | 4 +-- drivers/staging/lustre/lustre/llite/lproc_llite.c | 2 +- drivers/staging/lustre/lustre/llite/rw.c | 2 +- drivers/staging/lustre/lustre/llite/vvp_dev.c | 10 +++--- drivers/staging/lustre/lustre/llite/xattr.c | 2 +- .../staging/lustre/lustre/lov/lov_cl_internal.h | 41 +++++++++++----------- drivers/staging/lustre/lustre/lov/lov_object.c | 2 +- drivers/staging/lustre/lustre/obdclass/cl_object.c | 6 ++-- .../staging/lustre/lustre/obdecho/echo_client.c | 6 ++-- drivers/staging/lustre/lustre/osc/lproc_osc.c | 2 +- drivers/staging/lustre/lustre/osc/osc_cache.c | 2 +- drivers/staging/lustre/lustre/osc/osc_lock.c | 12 +++---- drivers/staging/lustre/lustre/osc/osc_page.c | 4 +-- drivers/staging/lustre/lustre/osc/osc_request.c | 2 +- 20 files changed, 67 insertions(+), 68 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h index 12b3222..2bc3ee5 100644 --- a/drivers/staging/lustre/lustre/include/cl_object.h +++ b/drivers/staging/lustre/lustre/include/cl_object.h @@ -2437,9 +2437,9 @@ void cl_sync_io_note(const struct lu_env *env, struct cl_sync_io *anchor, * @{ */ -struct lu_env *cl_env_get(int *refcheck); -struct lu_env *cl_env_alloc(int *refcheck, __u32 tags); -void cl_env_put(struct lu_env *env, int *refcheck); +struct lu_env *cl_env_get(u16 *refcheck); +struct lu_env *cl_env_alloc(u16 *refcheck, __u32 tags); +void cl_env_put(struct lu_env *env, u16 *refcheck); unsigned int cl_env_cache_purge(unsigned int nr); struct lu_env *cl_env_percpu_get(void); void cl_env_percpu_put(struct lu_env *env); diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 10adfcd..b1c9573 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -1159,7 +1159,7 @@ static ssize_t ll_file_read_iter(struct kiocb *iocb, struct iov_iter *to) struct lu_env *env; struct vvp_io_args *args; ssize_t result; - int refcheck; + u16 refcheck; env = cl_env_get(&refcheck); if (IS_ERR(env)) @@ -1183,7 +1183,7 @@ static ssize_t ll_file_write_iter(struct kiocb *iocb, struct iov_iter *from) struct lu_env *env; struct vvp_io_args *args; ssize_t result; - int refcheck; + u16 refcheck; env = cl_env_get(&refcheck); if (IS_ERR(env)) @@ -1340,7 +1340,7 @@ static int ll_file_getstripe(struct inode *inode, struct lov_user_md __user *lum) { struct lu_env *env; - int refcheck; + u16 refcheck; int rc; env = cl_env_get(&refcheck); @@ -1517,7 +1517,7 @@ static int ll_do_fiemap(struct inode *inode, struct fiemap *fiemap, { struct ll_fiemap_info_key fmkey = { .lfik_name = KEY_FIEMAP, }; struct lu_env *env; - int refcheck; + u16 refcheck; int rc = 0; /* Checks for fiemap flags */ @@ -1623,7 +1623,7 @@ int ll_data_version(struct inode *inode, __u64 *data_version, int flags) struct cl_object *obj = ll_i2info(inode)->lli_clob; struct lu_env *env; struct cl_io *io; - int refcheck; + u16 refcheck; int result; /* If no file object initialized, we consider its version is 0. */ @@ -1668,7 +1668,7 @@ int ll_hsm_release(struct inode *inode) struct obd_client_handle *och = NULL; __u64 data_version = 0; int rc; - int refcheck; + u16 refcheck; CDEBUG(D_INODE, "%s: Releasing file "DFID".\n", ll_get_fsname(inode->i_sb, NULL, 0), @@ -2324,7 +2324,7 @@ int cl_sync_file_range(struct inode *inode, loff_t start, loff_t end, struct cl_io *io; struct cl_fsync_io *fio; int result; - int refcheck; + u16 refcheck; if (mode != CL_FSYNC_NONE && mode != CL_FSYNC_LOCAL && mode != CL_FSYNC_DISCARD && mode != CL_FSYNC_ALL) @@ -3271,7 +3271,7 @@ int ll_layout_conf(struct inode *inode, const struct cl_object_conf *conf) struct cl_object *obj = lli->lli_clob; struct lu_env *env; int rc; - int refcheck; + u16 refcheck; if (!obj) return 0; diff --git a/drivers/staging/lustre/lustre/llite/glimpse.c b/drivers/staging/lustre/lustre/llite/glimpse.c index 504498d..0143112 100644 --- a/drivers/staging/lustre/lustre/llite/glimpse.c +++ b/drivers/staging/lustre/lustre/llite/glimpse.c @@ -138,7 +138,7 @@ int cl_glimpse_lock(const struct lu_env *env, struct cl_io *io, } static int cl_io_get(struct inode *inode, struct lu_env **envout, - struct cl_io **ioout, int *refcheck) + struct cl_io **ioout, u16 *refcheck) { struct lu_env *env; struct cl_io *io; @@ -178,7 +178,7 @@ int cl_glimpse_size0(struct inode *inode, int agl) struct lu_env *env = NULL; struct cl_io *io = NULL; int result; - int refcheck; + u16 refcheck; result = cl_io_get(inode, &env, &io, &refcheck); if (result > 0) { diff --git a/drivers/staging/lustre/lustre/llite/lcommon_cl.c b/drivers/staging/lustre/lustre/llite/lcommon_cl.c index f1036f4..8af6110 100644 --- a/drivers/staging/lustre/lustre/llite/lcommon_cl.c +++ b/drivers/staging/lustre/lustre/llite/lcommon_cl.c @@ -72,7 +72,7 @@ * mutex. */ struct lu_env *cl_inode_fini_env; -int cl_inode_fini_refcheck; +u16 cl_inode_fini_refcheck; /** * A mutex serializing calls to slp_inode_fini() under extreme memory @@ -86,7 +86,7 @@ int cl_setattr_ost(struct cl_object *obj, const struct iattr *attr, struct lu_env *env; struct cl_io *io; int result; - int refcheck; + u16 refcheck; env = cl_env_get(&refcheck); if (IS_ERR(env)) @@ -149,7 +149,7 @@ int cl_file_inode_init(struct inode *inode, struct lustre_md *md) } }; int result = 0; - int refcheck; + u16 refcheck; LASSERT(md->body->mbo_valid & OBD_MD_FLID); LASSERT(S_ISREG(inode->i_mode)); @@ -237,7 +237,7 @@ void cl_inode_fini(struct inode *inode) struct lu_env *env; struct ll_inode_info *lli = ll_i2info(inode); struct cl_object *clob = lli->lli_clob; - int refcheck; + u16 refcheck; int emergency; if (clob) { diff --git a/drivers/staging/lustre/lustre/llite/lcommon_misc.c b/drivers/staging/lustre/lustre/llite/lcommon_misc.c index f0c132e..7f7f3f1 100644 --- a/drivers/staging/lustre/lustre/llite/lcommon_misc.c +++ b/drivers/staging/lustre/lustre/llite/lcommon_misc.c @@ -124,7 +124,7 @@ int cl_get_grouplock(struct cl_object *obj, unsigned long gid, int nonblock, struct cl_lock *lock; struct cl_lock_descr *descr; __u32 enqflags; - int refcheck; + u16 refcheck; int rc; env = cl_env_get(&refcheck); diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index ecdfd0c..99fb852 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -1329,7 +1329,7 @@ int cl_setattr_ost(struct cl_object *obj, const struct iattr *attr, unsigned int attr_flags); extern struct lu_env *cl_inode_fini_env; -extern int cl_inode_fini_refcheck; +extern u16 cl_inode_fini_refcheck; int cl_file_inode_init(struct inode *inode, struct lustre_md *md); void cl_inode_fini(struct inode *inode); diff --git a/drivers/staging/lustre/lustre/llite/llite_mmap.c b/drivers/staging/lustre/lustre/llite/llite_mmap.c index ee01f20..33dc935 100644 --- a/drivers/staging/lustre/lustre/llite/llite_mmap.c +++ b/drivers/staging/lustre/lustre/llite/llite_mmap.c @@ -150,7 +150,7 @@ static int ll_page_mkwrite0(struct vm_area_struct *vma, struct page *vmpage, struct cl_io *io; struct vvp_io *vio; int result; - int refcheck; + u16 refcheck; sigset_t set; struct inode *inode; struct ll_inode_info *lli; @@ -268,7 +268,7 @@ static int ll_fault0(struct vm_area_struct *vma, struct vm_fault *vmf) unsigned long ra_flags; int result = 0; int fault_ret = 0; - int refcheck; + u16 refcheck; env = cl_env_get(&refcheck); if (IS_ERR(env)) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index f3ee584..40f1fcf 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -386,7 +386,7 @@ static ssize_t ll_max_cached_mb_seq_write(struct file *file, struct lu_env *env; long diff = 0; long nrpages = 0; - int refcheck; + u16 refcheck; long pages_number; int mult; long rc; diff --git a/drivers/staging/lustre/lustre/llite/rw.c b/drivers/staging/lustre/lustre/llite/rw.c index 50d027e..1bac51f 100644 --- a/drivers/staging/lustre/lustre/llite/rw.c +++ b/drivers/staging/lustre/lustre/llite/rw.c @@ -905,7 +905,7 @@ int ll_writepage(struct page *vmpage, struct writeback_control *wbc) bool redirtied = false; bool unlocked = false; int result; - int refcheck; + u16 refcheck; LASSERT(PageLocked(vmpage)); LASSERT(!PageWriteback(vmpage)); diff --git a/drivers/staging/lustre/lustre/llite/vvp_dev.c b/drivers/staging/lustre/lustre/llite/vvp_dev.c index 3669ea7..6cb2db2 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_dev.c +++ b/drivers/staging/lustre/lustre/llite/vvp_dev.c @@ -313,7 +313,7 @@ int cl_sb_init(struct super_block *sb) struct cl_device *cl; struct lu_env *env; int rc = 0; - int refcheck; + u16 refcheck; sbi = ll_s2sbi(sb); env = cl_env_get(&refcheck); @@ -336,7 +336,7 @@ int cl_sb_fini(struct super_block *sb) struct ll_sb_info *sbi; struct lu_env *env; struct cl_device *cld; - int refcheck; + u16 refcheck; int result; sbi = ll_s2sbi(sb); @@ -535,7 +535,7 @@ static int vvp_pgcache_show(struct seq_file *f, void *v) struct cl_object *clob; struct lu_env *env; struct vvp_pgcache_id id; - int refcheck; + u16 refcheck; int result; env = cl_env_get(&refcheck); @@ -584,7 +584,7 @@ static void *vvp_pgcache_start(struct seq_file *f, loff_t *pos) { struct ll_sb_info *sbi; struct lu_env *env; - int refcheck; + u16 refcheck; sbi = f->private; @@ -608,7 +608,7 @@ static void *vvp_pgcache_next(struct seq_file *f, void *v, loff_t *pos) { struct ll_sb_info *sbi; struct lu_env *env; - int refcheck; + u16 refcheck; env = cl_env_get(&refcheck); if (!IS_ERR(env)) { diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c index 421cc04..3ef0291 100644 --- a/drivers/staging/lustre/lustre/llite/xattr.c +++ b/drivers/staging/lustre/lustre/llite/xattr.c @@ -427,7 +427,7 @@ static ssize_t ll_getxattr_lov(struct inode *inode, void *buf, size_t buf_size) .cl_buf.lb_len = buf_size, }; struct lu_env *env; - int refcheck; + u16 refcheck; if (!obj) return -ENODATA; diff --git a/drivers/staging/lustre/lustre/lov/lov_cl_internal.h b/drivers/staging/lustre/lustre/lov/lov_cl_internal.h index c49a34b..391c632 100644 --- a/drivers/staging/lustre/lustre/lov/lov_cl_internal.h +++ b/drivers/staging/lustre/lustre/lov/lov_cl_internal.h @@ -118,7 +118,7 @@ struct lov_device_emerg { * * \see cl_env_get() */ - int emrg_refcheck; + u16 emrg_refcheck; }; struct lov_device { @@ -378,40 +378,39 @@ struct lov_thread_info { * State that lov_io maintains for every sub-io. */ struct lov_io_sub { - int sub_stripe; - /** - * sub-io for a stripe. Ideally sub-io's can be stopped and resumed - * independently, with lov acting as a scheduler to maximize overall - * throughput. - */ - struct cl_io *sub_io; + u16 sub_stripe; /** - * Linkage into a list (hanging off lov_io::lis_active) of all - * sub-io's active for the current IO iteration. + * environment's refcheck. + * + * \see cl_env_get() */ - struct list_head sub_linkage; + u16 sub_refcheck; + u16 sub_reenter; /** * true, iff cl_io_init() was successfully executed against * lov_io_sub::sub_io. */ - int sub_io_initialized; + u16 sub_io_initialized:1, /** * True, iff lov_io_sub::sub_io and lov_io_sub::sub_env weren't * allocated, but borrowed from a per-device emergency pool. */ - int sub_borrowed; + sub_borrowed:1; /** - * environment, in which sub-io executes. + * Linkage into a list (hanging off lov_io::lis_active) of all + * sub-io's active for the current IO iteration. */ - struct lu_env *sub_env; + struct list_head sub_linkage; /** - * environment's refcheck. - * - * \see cl_env_get() + * sub-io for a stripe. Ideally sub-io's can be stopped and resumed + * independently, with lov acting as a scheduler to maximize overall + * throughput. + */ + struct cl_io *sub_io; + /** + * environment, in which sub-io executes. */ - int sub_refcheck; - int sub_refcheck2; - int sub_reenter; + struct lu_env *sub_env; }; /** diff --git a/drivers/staging/lustre/lustre/lov/lov_object.c b/drivers/staging/lustre/lustre/lov/lov_object.c index 977579c..ab3ecfe 100644 --- a/drivers/staging/lustre/lustre/lov/lov_object.c +++ b/drivers/staging/lustre/lustre/lov/lov_object.c @@ -746,7 +746,7 @@ static int lov_layout_change(const struct lu_env *unused, const struct lov_layout_operations *old_ops; const struct lov_layout_operations *new_ops; struct lu_env *env; - int refcheck; + u16 refcheck; int rc; LASSERT(0 <= lov->lo_type && lov->lo_type < ARRAY_SIZE(lov_dispatch)); diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c index 703cb67..08e55d4 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c @@ -688,7 +688,7 @@ static inline struct cl_env *cl_env_container(struct lu_env *env) * * \see cl_env_put() */ -struct lu_env *cl_env_get(int *refcheck) +struct lu_env *cl_env_get(u16 *refcheck) { struct lu_env *env; @@ -709,7 +709,7 @@ struct lu_env *cl_env_get(int *refcheck) * * \see cl_env_get() */ -struct lu_env *cl_env_alloc(int *refcheck, __u32 tags) +struct lu_env *cl_env_alloc(u16 *refcheck, u32 tags) { struct lu_env *env; @@ -769,7 +769,7 @@ unsigned int cl_env_cache_purge(unsigned int nr) * this thread is using environment and it is returned to the allocation * cache, or freed straight away, if cache is large enough. */ -void cl_env_put(struct lu_env *env, int *refcheck) +void cl_env_put(struct lu_env *env, u16 *refcheck) { struct cl_env *cle; diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c index 5490761..77b4c55 100644 --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c +++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c @@ -816,7 +816,7 @@ static struct lu_device *echo_device_free(const struct lu_env *env, struct echo_object *eco; struct cl_object *obj; struct lu_fid *fid; - int refcheck; + u16 refcheck; int rc; LASSERTF(ostid_id(oi), DOSTID "\n", POSTID(oi)); @@ -882,7 +882,7 @@ static int cl_echo_object_put(struct echo_object *eco) { struct lu_env *env; struct cl_object *obj = echo_obj2cl(eco); - int refcheck; + u16 refcheck; env = cl_env_get(&refcheck); if (IS_ERR(env)) @@ -999,7 +999,7 @@ static int cl_echo_object_brw(struct echo_object *eco, int rw, u64 offset, struct cl_page *clp; struct lustre_handle lh = { 0 }; size_t page_size = cl_page_size(obj); - int refcheck; + u16 refcheck; int rc; int i; diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index 575b296..86f252d 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -229,7 +229,7 @@ static ssize_t osc_cached_mb_seq_write(struct file *file, rc = atomic_long_read(&cli->cl_lru_in_list) - pages_number; if (rc > 0) { struct lu_env *env; - int refcheck; + u16 refcheck; env = cl_env_get(&refcheck); if (!IS_ERR(env)) { diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index 6445bbe..f8c5fc0 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -988,7 +988,7 @@ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index, int grants = 0; int nr_pages = 0; int rc = 0; - int refcheck; + u16 refcheck; LASSERT(sanity_check(ext) == 0); EASSERT(ext->oe_state == OES_TRUNC, ext); diff --git a/drivers/staging/lustre/lustre/osc/osc_lock.c b/drivers/staging/lustre/lustre/osc/osc_lock.c index 5f7c030..940c10c 100644 --- a/drivers/staging/lustre/lustre/osc/osc_lock.c +++ b/drivers/staging/lustre/lustre/osc/osc_lock.c @@ -297,7 +297,7 @@ static int osc_lock_upcall(void *cookie, struct lustre_handle *lockh, struct cl_lock_slice *slice = &oscl->ols_cl; struct lu_env *env; int rc; - int refcheck; + u16 refcheck; env = cl_env_get(&refcheck); /* should never happen, similar to osc_ldlm_blocking_ast(). */ @@ -349,7 +349,7 @@ static int osc_lock_upcall_agl(void *cookie, struct lustre_handle *lockh, struct osc_object *osc = cookie; struct ldlm_lock *dlmlock; struct lu_env *env; - int refcheck; + u16 refcheck; env = cl_env_get(&refcheck); LASSERT(!IS_ERR(env)); @@ -384,7 +384,7 @@ static int osc_lock_flush(struct osc_object *obj, pgoff_t start, pgoff_t end, enum cl_lock_mode mode, int discard) { struct lu_env *env; - int refcheck; + u16 refcheck; int rc = 0; int rc2 = 0; @@ -538,7 +538,7 @@ static int osc_ldlm_blocking_ast(struct ldlm_lock *dlmlock, } case LDLM_CB_CANCELING: { struct lu_env *env; - int refcheck; + u16 refcheck; /* * This can be called in the context of outer IO, e.g., @@ -575,7 +575,7 @@ static int osc_ldlm_glimpse_ast(struct ldlm_lock *dlmlock, void *data) struct req_capsule *cap; struct cl_object *obj = NULL; int result; - int refcheck; + u16 refcheck; LASSERT(lustre_msg_get_opc(req->rq_reqmsg) == LDLM_GL_CALLBACK); @@ -686,7 +686,7 @@ unsigned long osc_ldlm_weigh_ast(struct ldlm_lock *dlmlock) struct osc_lock *oscl; unsigned long weight; bool found = false; - int refcheck; + u16 refcheck; might_sleep(); /* diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c index 03ee340..ed8a0dc 100644 --- a/drivers/staging/lustre/lustre/osc/osc_page.c +++ b/drivers/staging/lustre/lustre/osc/osc_page.c @@ -681,7 +681,7 @@ static long osc_lru_reclaim(struct client_obd *cli, unsigned long npages) struct lu_env *env; struct cl_client_cache *cache = cli->cl_cache; int max_scans; - int refcheck; + u16 refcheck; long rc = 0; LASSERT(cache); @@ -1045,7 +1045,7 @@ unsigned long osc_cache_shrink_scan(struct shrinker *sk, struct client_obd *cli; struct lu_env *env; long shrank = 0; - int refcheck; + u16 refcheck; int rc; if (!sc->nr_to_scan) diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 8e22807..4cf0664 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -2538,7 +2538,7 @@ static int osc_import_event(struct obd_device *obd, case IMP_EVENT_INVALIDATE: { struct ldlm_namespace *ns = obd->obd_namespace; struct lu_env *env; - int refcheck; + u16 refcheck; ldlm_namespace_cleanup(ns, LDLM_FL_LOCAL_ONLY); -- 1.8.3.1 From jsimmons at infradead.org Sat Feb 18 21:47:07 2017 From: jsimmons at infradead.org (James Simmons) Date: Sat, 18 Feb 2017 16:47:07 -0500 Subject: [lustre-devel] [PATCH 06/14] staging: lustre: osc: further LRU OSC cleanup after eviction In-Reply-To: <1487454435-4895-1-git-send-email-jsimmons@infradead.org> References: <1487454435-4895-1-git-send-email-jsimmons@infradead.org> Message-ID: <1487454435-4895-7-git-send-email-jsimmons@infradead.org> From: Jinshan Xiong Define osc_lru_reserve() and osc_lru_unreserve() to reserve LRU slots in osc_io_write_iter_init() and unreserve them in fini(); Signed-off-by: Jinshan Xiong Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6271 Reviewed-on: http://review.whamcloud.com/16456 Reviewed-by: Bobi Jam Reviewed-by: John L. Hammond Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- .../staging/lustre/lustre/osc/osc_cl_internal.h | 4 +- drivers/staging/lustre/lustre/osc/osc_internal.h | 3 +- drivers/staging/lustre/lustre/osc/osc_io.c | 48 +++++--------- drivers/staging/lustre/lustre/osc/osc_lock.c | 46 ++++++++------ drivers/staging/lustre/lustre/osc/osc_object.c | 8 ++- drivers/staging/lustre/lustre/osc/osc_page.c | 73 +++++++++++++++++++--- 6 files changed, 118 insertions(+), 64 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h index c09ab97d..270212f 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h @@ -62,7 +62,9 @@ struct osc_io { /** super class */ struct cl_io_slice oi_cl; /** true if this io is lockless. */ - unsigned int oi_lockless; + unsigned int oi_lockless:1, + /** true if this io is counted as active IO */ + oi_is_active:1; /** how many LRU pages are reserved for this IO */ unsigned long oi_lru_reserved; diff --git a/drivers/staging/lustre/lustre/osc/osc_internal.h b/drivers/staging/lustre/lustre/osc/osc_internal.h index 8abd83f..845e795 100644 --- a/drivers/staging/lustre/lustre/osc/osc_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_internal.h @@ -133,7 +133,8 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, struct list_head *ext_list, int cmd); long osc_lru_shrink(const struct lu_env *env, struct client_obd *cli, long target, bool force); -long osc_lru_reclaim(struct client_obd *cli, unsigned long npages); +unsigned long osc_lru_reserve(struct client_obd *cli, unsigned long npages); +void osc_lru_unreserve(struct client_obd *cli, unsigned long npages); unsigned long osc_ldlm_weigh_ast(struct ldlm_lock *dlmlock); diff --git a/drivers/staging/lustre/lustre/osc/osc_io.c b/drivers/staging/lustre/lustre/osc/osc_io.c index 0b4cc42..f991bee 100644 --- a/drivers/staging/lustre/lustre/osc/osc_io.c +++ b/drivers/staging/lustre/lustre/osc/osc_io.c @@ -354,7 +354,10 @@ static int osc_io_iter_init(const struct lu_env *env, spin_lock(&imp->imp_lock); if (likely(!imp->imp_invalid)) { + struct osc_io *oio = osc_env_io(env); + atomic_inc(&osc->oo_nr_ios); + oio->oi_is_active = 1; rc = 0; } spin_unlock(&imp->imp_lock); @@ -368,10 +371,7 @@ static int osc_io_write_iter_init(const struct lu_env *env, struct cl_io *io = ios->cis_io; struct osc_io *oio = osc_env_io(env); struct osc_object *osc = cl2osc(ios->cis_obj); - struct client_obd *cli = osc_cli(osc); - unsigned long c; unsigned long npages; - unsigned long max_pages; if (cl_io_is_append(io)) return osc_io_iter_init(env, ios); @@ -380,31 +380,7 @@ static int osc_io_write_iter_init(const struct lu_env *env, if (io->u.ci_rw.crw_pos & ~PAGE_MASK) ++npages; - max_pages = cli->cl_max_pages_per_rpc * cli->cl_max_rpcs_in_flight; - if (npages > max_pages) - npages = max_pages; - - c = atomic_long_read(cli->cl_lru_left); - if (c < npages && osc_lru_reclaim(cli, npages) > 0) - c = atomic_long_read(cli->cl_lru_left); - while (c >= npages) { - if (c == atomic_long_cmpxchg(cli->cl_lru_left, c, c - npages)) { - oio->oi_lru_reserved = npages; - break; - } - c = atomic_long_read(cli->cl_lru_left); - } - if (atomic_long_read(cli->cl_lru_left) < max_pages) { - /* - * If there aren't enough pages in the per-OSC LRU then - * wake up the LRU thread to try and clear out space, so - * we don't block if pages are being dirtied quickly. - */ - CDEBUG(D_CACHE, "%s: queue LRU, left: %lu/%ld.\n", - cli_name(cli), atomic_long_read(cli->cl_lru_left), - max_pages); - (void)ptlrpcd_queue_work(cli->cl_lru_work); - } + oio->oi_lru_reserved = osc_lru_reserve(osc_cli(osc), npages); return osc_io_iter_init(env, ios); } @@ -412,11 +388,16 @@ static int osc_io_write_iter_init(const struct lu_env *env, static void osc_io_iter_fini(const struct lu_env *env, const struct cl_io_slice *ios) { - struct osc_object *osc = cl2osc(ios->cis_obj); + struct osc_io *oio = osc_env_io(env); - LASSERT(atomic_read(&osc->oo_nr_ios) > 0); - if (atomic_dec_and_test(&osc->oo_nr_ios)) - wake_up_all(&osc->oo_io_waitq); + if (oio->oi_is_active) { + struct osc_object *osc = cl2osc(ios->cis_obj); + + oio->oi_is_active = 0; + LASSERT(atomic_read(&osc->oo_nr_ios) > 0); + if (atomic_dec_and_test(&osc->oo_nr_ios)) + wake_up_all(&osc->oo_io_waitq); + } } static void osc_io_write_iter_fini(const struct lu_env *env, @@ -424,10 +405,9 @@ static void osc_io_write_iter_fini(const struct lu_env *env, { struct osc_io *oio = osc_env_io(env); struct osc_object *osc = cl2osc(ios->cis_obj); - struct client_obd *cli = osc_cli(osc); if (oio->oi_lru_reserved > 0) { - atomic_long_add(oio->oi_lru_reserved, cli->cl_lru_left); + osc_lru_unreserve(osc_cli(osc), oio->oi_lru_reserved); oio->oi_lru_reserved = 0; } oio->oi_write_osclock = NULL; diff --git a/drivers/staging/lustre/lustre/osc/osc_lock.c b/drivers/staging/lustre/lustre/osc/osc_lock.c index efecd92..5f7c030 100644 --- a/drivers/staging/lustre/lustre/osc/osc_lock.c +++ b/drivers/staging/lustre/lustre/osc/osc_lock.c @@ -840,13 +840,14 @@ static void osc_lock_wake_waiters(const struct lu_env *env, spin_unlock(&oscl->ols_lock); } -static void osc_lock_enqueue_wait(const struct lu_env *env, - struct osc_object *obj, - struct osc_lock *oscl) +static int osc_lock_enqueue_wait(const struct lu_env *env, + struct osc_object *obj, + struct osc_lock *oscl) { struct osc_lock *tmp_oscl; struct cl_lock_descr *need = &oscl->ols_cl.cls_lock->cll_descr; struct cl_sync_io *waiter = &osc_env_info(env)->oti_anchor; + int rc = 0; spin_lock(&obj->oo_ol_spin); list_add_tail(&oscl->ols_nextlock_oscobj, &obj->oo_ol_list); @@ -883,13 +884,17 @@ static void osc_lock_enqueue_wait(const struct lu_env *env, spin_unlock(&tmp_oscl->ols_lock); spin_unlock(&obj->oo_ol_spin); - (void)cl_sync_io_wait(env, waiter, 0); - + rc = cl_sync_io_wait(env, waiter, 0); spin_lock(&obj->oo_ol_spin); + if (rc < 0) + break; + oscl->ols_owner = NULL; goto restart; } spin_unlock(&obj->oo_ol_spin); + + return rc; } /** @@ -937,7 +942,9 @@ static int osc_lock_enqueue(const struct lu_env *env, goto enqueue_base; } - osc_lock_enqueue_wait(env, osc, oscl); + result = osc_lock_enqueue_wait(env, osc, oscl); + if (result < 0) + goto out; /* we can grant lockless lock right after all conflicting locks * are canceled. @@ -962,7 +969,6 @@ static int osc_lock_enqueue(const struct lu_env *env, * osc_lock. */ ostid_build_res_name(&osc->oo_oinfo->loi_oi, resname); - osc_lock_build_einfo(env, lock, osc, &oscl->ols_einfo); osc_lock_build_policy(env, lock, policy); if (oscl->ols_agl) { oscl->ols_einfo.ei_cbdata = NULL; @@ -977,18 +983,7 @@ static int osc_lock_enqueue(const struct lu_env *env, upcall, cookie, &oscl->ols_einfo, PTLRPCD_SET, async, oscl->ols_agl); - if (result != 0) { - oscl->ols_state = OLS_CANCELLED; - osc_lock_wake_waiters(env, osc, oscl); - - /* hide error for AGL lock. */ - if (oscl->ols_agl) { - cl_object_put(env, osc2cl(osc)); - result = 0; - } - if (anchor) - cl_sync_io_note(env, anchor, result); - } else { + if (!result) { if (osc_lock_is_lockless(oscl)) { oio->oi_lockless = 1; } else if (!async) { @@ -996,6 +991,18 @@ static int osc_lock_enqueue(const struct lu_env *env, LASSERT(oscl->ols_hold); LASSERT(oscl->ols_dlmlock); } + } else if (oscl->ols_agl) { + cl_object_put(env, osc2cl(osc)); + result = 0; + } + +out: + if (result < 0) { + oscl->ols_state = OLS_CANCELLED; + osc_lock_wake_waiters(env, osc, oscl); + + if (anchor) + cl_sync_io_note(env, anchor, result); } return result; } @@ -1159,6 +1166,7 @@ int osc_lock_init(const struct lu_env *env, oscl->ols_flags |= LDLM_FL_BLOCK_GRANTED; oscl->ols_glimpse = 1; } + osc_lock_build_einfo(env, lock, cl2osc(obj), &oscl->ols_einfo); cl_lock_slice_add(lock, &oscl->ols_cl, obj, &osc_lock_ops); diff --git a/drivers/staging/lustre/lustre/osc/osc_object.c b/drivers/staging/lustre/lustre/osc/osc_object.c index 4f8e78b..fa621bd 100644 --- a/drivers/staging/lustre/lustre/osc/osc_object.c +++ b/drivers/staging/lustre/lustre/osc/osc_object.c @@ -453,9 +453,15 @@ int osc_object_invalidate(const struct lu_env *env, struct osc_object *osc) l_wait_event(osc->oo_io_waitq, !atomic_read(&osc->oo_nr_ios), &lwi); - /* Discard all pages of this object. */ + /* Discard all dirty pages of this object. */ osc_cache_truncate_start(env, osc, 0, NULL); + /* Discard all caching pages */ + osc_lock_discard_pages(env, osc, 0, CL_PAGE_EOF, CLM_WRITE); + + /* Clear ast data of dlm lock. Do this after discarding all pages */ + osc_object_prune(env, osc2cl(osc)); + return 0; } diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c index ab9d0d7..03ee340 100644 --- a/drivers/staging/lustre/lustre/osc/osc_page.c +++ b/drivers/staging/lustre/lustre/osc/osc_page.c @@ -42,8 +42,8 @@ static void osc_lru_del(struct client_obd *cli, struct osc_page *opg); static void osc_lru_use(struct client_obd *cli, struct osc_page *opg); -static int osc_lru_reserve(const struct lu_env *env, struct osc_object *obj, - struct osc_page *opg); +static int osc_lru_alloc(const struct lu_env *env, struct client_obd *cli, + struct osc_page *opg); /** \addtogroup osc * @{ @@ -273,7 +273,7 @@ int osc_page_init(const struct lu_env *env, struct cl_object *obj, /* reserve an LRU space for this page */ if (page->cp_type == CPT_CACHEABLE && result == 0) { - result = osc_lru_reserve(env, osc, opg); + result = osc_lru_alloc(env, osc_cli(osc), opg); if (result == 0) { spin_lock(&osc->oo_tree_lock); result = radix_tree_insert(&osc->oo_tree, index, opg); @@ -676,7 +676,7 @@ long osc_lru_shrink(const struct lu_env *env, struct client_obd *cli, * LRU pages in batch. Therefore, the actual number is adjusted at least * max_pages_per_rpc. */ -long osc_lru_reclaim(struct client_obd *cli, unsigned long npages) +static long osc_lru_reclaim(struct client_obd *cli, unsigned long npages) { struct lu_env *env; struct cl_client_cache *cache = cli->cl_cache; @@ -749,18 +749,17 @@ long osc_lru_reclaim(struct client_obd *cli, unsigned long npages) } /** - * osc_lru_reserve() is called to reserve an LRU slot for a cl_page. + * osc_lru_alloc() is called to reserve an LRU slot for a cl_page. * * Usually the LRU slots are reserved in osc_io_iter_rw_init(). * Only in the case that the LRU slots are in extreme shortage, it should * have reserved enough slots for an IO. */ -static int osc_lru_reserve(const struct lu_env *env, struct osc_object *obj, - struct osc_page *opg) +static int osc_lru_alloc(const struct lu_env *env, struct client_obd *cli, + struct osc_page *opg) { struct l_wait_info lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL); struct osc_io *oio = osc_env_io(env); - struct client_obd *cli = osc_cli(obj); int rc = 0; if (!cli->cl_cache) /* shall not be in LRU */ @@ -801,6 +800,64 @@ static int osc_lru_reserve(const struct lu_env *env, struct osc_object *obj, } /** + * osc_lru_reserve() is called to reserve enough LRU slots for I/O. + * + * The benefit of doing this is to reduce contention against atomic counter + * cl_lru_left by changing it from per-page access to per-IO access. + */ +unsigned long osc_lru_reserve(struct client_obd *cli, unsigned long npages) +{ + unsigned long reserved = 0; + unsigned long max_pages; + unsigned long c; + + /* + * reserve a full RPC window at most to avoid that a thread accidentally + * consumes too many LRU slots + */ + max_pages = cli->cl_max_pages_per_rpc * cli->cl_max_rpcs_in_flight; + if (npages > max_pages) + npages = max_pages; + + c = atomic_long_read(cli->cl_lru_left); + if (c < npages && osc_lru_reclaim(cli, npages) > 0) + c = atomic_long_read(cli->cl_lru_left); + while (c >= npages) { + if (c == atomic_long_cmpxchg(cli->cl_lru_left, c, c - npages)) { + reserved = npages; + break; + } + c = atomic_long_read(cli->cl_lru_left); + } + if (atomic_long_read(cli->cl_lru_left) < max_pages) { + /* + * If there aren't enough pages in the per-OSC LRU then + * wake up the LRU thread to try and clear out space, so + * we don't block if pages are being dirtied quickly. + */ + CDEBUG(D_CACHE, "%s: queue LRU, left: %lu/%ld.\n", + cli_name(cli), atomic_long_read(cli->cl_lru_left), + max_pages); + (void)ptlrpcd_queue_work(cli->cl_lru_work); + } + + return reserved; +} + +/** + * osc_lru_unreserve() is called to unreserve LRU slots. + * + * LRU slots reserved by osc_lru_reserve() may have entries left due to several + * reasons such as page already existing or I/O error. Those reserved slots + * should be freed by calling this function. + */ +void osc_lru_unreserve(struct client_obd *cli, unsigned long npages) +{ + atomic_long_add(npages, cli->cl_lru_left); + wake_up_all(&osc_lru_waitq); +} + +/** * Atomic operations are expensive. We accumulate the accounting for the * same page pgdat to get better performance. * In practice this can work pretty good because the pages in the same RPC -- 1.8.3.1 From jsimmons at infradead.org Sat Feb 18 21:47:02 2017 From: jsimmons at infradead.org (James Simmons) Date: Sat, 18 Feb 2017 16:47:02 -0500 Subject: [lustre-devel] [PATCH 01/14] staging: lustre: llite: lower message level for ll_setattr_raw() In-Reply-To: <1487454435-4895-1-git-send-email-jsimmons@infradead.org> References: <1487454435-4895-1-git-send-email-jsimmons@infradead.org> Message-ID: <1487454435-4895-2-git-send-email-jsimmons@infradead.org> From: Bobi Jam Truncate and write can happen at the same time, so that a file can be set modified even though the file is not restored from released state, and ll_hsm_state_set() is not applicable for the file, and it will return error in this case, we'd lower the error message level in this case. Signed-off-by: Bobi Jam Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6817 Reviewed-on: http://review.whamcloud.com/15541 Reviewed-by: Andreas Dilger Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/llite_lib.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index b229cbc..34422df 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -1513,6 +1513,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import) */ attr->ia_valid |= MDS_OPEN_OWNEROVERRIDE; op_data->op_bias |= MDS_DATA_MODIFIED; + clear_bit(LLIF_DATA_MODIFIED, &lli->lli_flags); } rc = ll_md_setattr(dentry, op_data); @@ -1560,8 +1561,15 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import) int rc2; rc2 = ll_hsm_state_set(inode, &hss); + /* + * truncate and write can happen at the same time, so that + * the file can be set modified even though the file is not + * restored from released state, and ll_hsm_state_set() is + * not applicable for the file, and rc2 < 0 is normal in this + * case. + */ if (rc2 < 0) - CERROR(DFID "HSM set dirty failed: rc2 = %d\n", + CDEBUG(D_INFO, DFID "HSM set dirty failed: rc2 = %d\n", PFID(ll_inode2fid(inode)), rc2); } -- 1.8.3.1 From jsimmons at infradead.org Sat Feb 18 21:47:12 2017 From: jsimmons at infradead.org (James Simmons) Date: Sat, 18 Feb 2017 16:47:12 -0500 Subject: [lustre-devel] [PATCH 11/14] staging: lustre: ldlm: fix race of starting bl threads In-Reply-To: <1487454435-4895-1-git-send-email-jsimmons@infradead.org> References: <1487454435-4895-1-git-send-email-jsimmons@infradead.org> Message-ID: <1487454435-4895-12-git-send-email-jsimmons@infradead.org> From: Niu Yawei There is race in the code of starting bl threads which leads to thread number exceeds the maximum number when race happened, it can also lead to duplicated thread name. This patch fixes the race and cleanup the code a bit. Signed-off-by: Niu Yawei Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7330 Reviewed-on: http://review.whamcloud.com/17026 Reviewed-by: Bobi Jam Reviewed-by: Andreas Dilger Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c | 49 ++++++++++++++----------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c index 4c21b9b..6f9d540 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c @@ -714,7 +714,6 @@ static int ldlm_bl_get_work(struct ldlm_bl_pool *blp, /* This only contains temporary data until the thread starts */ struct ldlm_bl_thread_data { - char bltd_name[CFS_CURPROC_COMM_MAX]; struct ldlm_bl_pool *bltd_blp; struct completion bltd_comp; int bltd_num; @@ -722,19 +721,32 @@ struct ldlm_bl_thread_data { static int ldlm_bl_thread_main(void *arg); -static int ldlm_bl_thread_start(struct ldlm_bl_pool *blp) +static int ldlm_bl_thread_start(struct ldlm_bl_pool *blp, bool check_busy) { struct ldlm_bl_thread_data bltd = { .bltd_blp = blp }; struct task_struct *task; init_completion(&bltd.bltd_comp); - bltd.bltd_num = atomic_read(&blp->blp_num_threads); - snprintf(bltd.bltd_name, sizeof(bltd.bltd_name), - "ldlm_bl_%02d", bltd.bltd_num); - task = kthread_run(ldlm_bl_thread_main, &bltd, "%s", bltd.bltd_name); + + bltd.bltd_num = atomic_inc_return(&blp->blp_num_threads); + if (bltd.bltd_num >= blp->blp_max_threads) { + atomic_dec(&blp->blp_num_threads); + return 0; + } + + LASSERTF(bltd.bltd_num > 0, "thread num:%d\n", bltd.bltd_num); + if (check_busy && + atomic_read(&blp->blp_busy_threads) < (bltd.bltd_num - 1)) { + atomic_dec(&blp->blp_num_threads); + return 0; + } + + task = kthread_run(ldlm_bl_thread_main, &bltd, "ldlm_bl_%02d", + bltd.bltd_num); if (IS_ERR(task)) { CERROR("cannot start LDLM thread ldlm_bl_%02d: rc %ld\n", - atomic_read(&blp->blp_num_threads), PTR_ERR(task)); + bltd.bltd_num, PTR_ERR(task)); + atomic_dec(&blp->blp_num_threads); return PTR_ERR(task); } wait_for_completion(&bltd.bltd_comp); @@ -746,12 +758,11 @@ static int ldlm_bl_thread_start(struct ldlm_bl_pool *blp) static int ldlm_bl_thread_need_create(struct ldlm_bl_pool *blp, struct ldlm_bl_work_item *blwi) { - int busy = atomic_read(&blp->blp_busy_threads); - - if (busy >= blp->blp_max_threads) + if (atomic_read(&blp->blp_num_threads) >= blp->blp_max_threads) return 0; - if (busy < atomic_read(&blp->blp_num_threads)) + if (atomic_read(&blp->blp_busy_threads) < + atomic_read(&blp->blp_num_threads)) return 0; if (blwi && (!blwi->blwi_ns || blwi->blwi_mem_pressure)) @@ -815,9 +826,6 @@ static int ldlm_bl_thread_main(void *arg) blp = bltd->bltd_blp; - atomic_inc(&blp->blp_num_threads); - atomic_inc(&blp->blp_busy_threads); - complete(&bltd->bltd_comp); /* cannot use bltd after this, it is only on caller's stack */ @@ -828,27 +836,26 @@ static int ldlm_bl_thread_main(void *arg) int rc; rc = ldlm_bl_get_work(blp, &blwi, &exp); - if (!rc) { - atomic_dec(&blp->blp_busy_threads); + if (!rc) l_wait_event_exclusive(blp->blp_waitq, ldlm_bl_get_work(blp, &blwi, &exp), &lwi); - atomic_inc(&blp->blp_busy_threads); - } + atomic_inc(&blp->blp_busy_threads); if (ldlm_bl_thread_need_create(blp, blwi)) /* discard the return value, we tried */ - ldlm_bl_thread_start(blp); + ldlm_bl_thread_start(blp, true); if (blwi) rc = ldlm_bl_thread_blwi(blp, blwi); + atomic_dec(&blp->blp_busy_threads); + if (rc == LDLM_ITER_STOP) break; } - atomic_dec(&blp->blp_busy_threads); atomic_dec(&blp->blp_num_threads); complete(&blp->blp_comp); return 0; @@ -1028,7 +1035,7 @@ static int ldlm_setup(void) } for (i = 0; i < blp->blp_min_threads; i++) { - rc = ldlm_bl_thread_start(blp); + rc = ldlm_bl_thread_start(blp, false); if (rc < 0) goto out; } -- 1.8.3.1 From jsimmons at infradead.org Sat Feb 18 21:47:10 2017 From: jsimmons at infradead.org (James Simmons) Date: Sat, 18 Feb 2017 16:47:10 -0500 Subject: [lustre-devel] [PATCH 09/14] staging: lustre: ldlm: reduce ldlm pool recalc window In-Reply-To: <1487454435-4895-1-git-send-email-jsimmons@infradead.org> References: <1487454435-4895-1-git-send-email-jsimmons@infradead.org> Message-ID: <1487454435-4895-10-git-send-email-jsimmons@infradead.org> From: Vitaly Fertman Reduce the sleep period from 50 seconds down to LDLM_POOL_CLI_DEF_RECALC_PERIOD which is 10 seconds. Signed-off-by: Vitaly Fertman Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3031 Xyratex-bug-id: MRP-395 MRP-1366 MRP-1366 Reviewed-by: Andriy Skulysh Reviewed-by: Alexey Lyashkov Reviewed-on: http://review.whamcloud.com/5843 Reviewed-by: James Simmons Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/ldlm/ldlm_pool.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c index 8dfb3c8..13fbbed 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c @@ -900,8 +900,9 @@ static int ldlm_pools_recalc(enum ldlm_side client) { struct ldlm_namespace *ns; struct ldlm_namespace *ns_old = NULL; + /* seconds of sleep if no active namespaces */ + int time = LDLM_POOL_CLI_DEF_RECALC_PERIOD; int nr; - int time = 50; /* seconds of sleep if no active namespaces */ /* * Recalc at least ldlm_namespace_nr_read(client) namespaces. -- 1.8.3.1 From jsimmons at infradead.org Sat Feb 18 21:47:11 2017 From: jsimmons at infradead.org (James Simmons) Date: Sat, 18 Feb 2017 16:47:11 -0500 Subject: [lustre-devel] [PATCH 10/14] staging: lustre: ldlm: disconnect speedup In-Reply-To: <1487454435-4895-1-git-send-email-jsimmons@infradead.org> References: <1487454435-4895-1-git-send-email-jsimmons@infradead.org> Message-ID: <1487454435-4895-11-git-send-email-jsimmons@infradead.org> From: Vitaly Fertman disconnect takes too long time if there are many locks to cancel. besides the amount of time spent on each lock cancel, there is a resched() in cfs_hash_for_each_relax(), i.e. disconnect or eviction may take unexpectedly long time. While this patch only contains the client side fixes the original fix covered changes to both the server and client code to ensure proper disconnect handling. Below details the change done on both the server and client so people can examine the disconnect behavior with both source bases. - do not cancel locks on disconnect_export; - export will be left in obd_unlinked_exports list pinned by live locks; - new re-connects will created other non-conflicting exports; - new locks will cancel obsolete locks on conflicts; - once all the locks on the disconnected export will be cancelled, the export will be destroyed on the last ref put; - do not cancel in small portions, cancel all together in just 1 dedicated thread - use server side blocking thread for that; - cancel blocked locks first so that waiting locks could proceed; - take care about blocked waiting locks, so that they would get cancelled quickly too; - do not remove lock from waiting list on AST error before moving it to elt_expired_locks list, because it removes it from export list too; otherwise this blocked lock will not be cancelled immediately on failed export; - cancel lock instead of just destroy for failed export, to make full cleanup, i.e. remove it from export list. Signed-off-by: Vitaly Fertman Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3031 Xyratex-bug-id: MRP-395 MRP-1366 MRP-1366 Reviewed-by: Andriy Skulysh Reviewed-by: Alexey Lyashkov Reviewed-on: http://review.whamcloud.com/5843 Reviewed-by: James Simmons Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/include/lustre_dlm.h | 11 +- .../staging/lustre/lustre/include/obd_support.h | 1 + drivers/staging/lustre/lustre/ldlm/ldlm_internal.h | 5 +- drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 1 - drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c | 143 +++++++++++++-------- drivers/staging/lustre/lustre/ldlm/ldlm_pool.c | 4 + 6 files changed, 101 insertions(+), 64 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h index b7e61d0..1e86fb5 100644 --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h @@ -812,13 +812,6 @@ struct ldlm_lock { /** referenced export object */ struct obd_export *l_exp_refs_target; #endif - /** - * export blocking dlm lock list, protected by - * l_export->exp_bl_list_lock. - * Lock order of waiting_lists_spinlock, exp_bl_list_lock and res lock - * is: res lock -> exp_bl_list_lock -> wanting_lists_spinlock. - */ - struct list_head l_exp_list; }; /** @@ -1192,6 +1185,10 @@ struct ldlm_namespace * enum ldlm_side client, enum ldlm_appetite apt, enum ldlm_ns_type ns_type); int ldlm_namespace_cleanup(struct ldlm_namespace *ns, __u64 flags); +void ldlm_namespace_free_prior(struct ldlm_namespace *ns, + struct obd_import *imp, + int force); +void ldlm_namespace_free_post(struct ldlm_namespace *ns); void ldlm_namespace_get(struct ldlm_namespace *ns); void ldlm_namespace_put(struct ldlm_namespace *ns); int ldlm_debugfs_setup(void); diff --git a/drivers/staging/lustre/lustre/include/obd_support.h b/drivers/staging/lustre/lustre/include/obd_support.h index aaedec7..05a958a 100644 --- a/drivers/staging/lustre/lustre/include/obd_support.h +++ b/drivers/staging/lustre/lustre/include/obd_support.h @@ -316,6 +316,7 @@ #define OBD_FAIL_LDLM_AGL_NOLOCK 0x31b #define OBD_FAIL_LDLM_OST_LVB 0x31c #define OBD_FAIL_LDLM_ENQUEUE_HANG 0x31d +#define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f #define OBD_FAIL_LDLM_CP_CB_WAIT2 0x320 #define OBD_FAIL_LDLM_CP_CB_WAIT3 0x321 #define OBD_FAIL_LDLM_CP_CB_WAIT4 0x322 diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h index 5c02501..5d24b48 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h @@ -108,9 +108,7 @@ int ldlm_cancel_lru_local(struct ldlm_namespace *ns, /* ldlm_resource.c */ int ldlm_resource_putref_locked(struct ldlm_resource *res); -void ldlm_namespace_free_prior(struct ldlm_namespace *ns, - struct obd_import *imp, int force); -void ldlm_namespace_free_post(struct ldlm_namespace *ns); + /* ldlm_lock.c */ struct ldlm_cb_set_arg { @@ -156,6 +154,7 @@ int ldlm_bl_to_thread_list(struct ldlm_namespace *ns, struct ldlm_lock_desc *ld, struct list_head *cancels, int count, enum ldlm_cancel_flags cancel_flags); +int ldlm_bl_thread_wakeup(void); void ldlm_handle_bl_callback(struct ldlm_namespace *ns, struct ldlm_lock_desc *ld, struct ldlm_lock *lock); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index 16c2a8b..ddb4642 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -435,7 +435,6 @@ static struct ldlm_lock *ldlm_lock_new(struct ldlm_resource *resource) lock->l_exp_refs_nr = 0; lock->l_exp_refs_target = NULL; #endif - INIT_LIST_HEAD(&lock->l_exp_list); return lock; } diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c index 12647af..4c21b9b 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c @@ -454,6 +454,12 @@ int ldlm_bl_to_thread_list(struct ldlm_namespace *ns, struct ldlm_lock_desc *ld, return ldlm_bl_to_thread(ns, ld, NULL, cancels, count, cancel_flags); } +int ldlm_bl_thread_wakeup(void) +{ + wake_up(&ldlm_state->ldlm_bl_pool->blp_waitq); + return 0; +} + /* Setinfo coming from Server (eg MDT) to Client (eg MDC)! */ static int ldlm_handle_setinfo(struct ptlrpc_request *req) { @@ -675,8 +681,11 @@ static int ldlm_callback_handler(struct ptlrpc_request *req) return 0; } -static struct ldlm_bl_work_item *ldlm_bl_get_work(struct ldlm_bl_pool *blp) +static int ldlm_bl_get_work(struct ldlm_bl_pool *blp, + struct ldlm_bl_work_item **p_blwi, + struct obd_export **p_exp) { + int num_th = atomic_read(&blp->blp_num_threads); struct ldlm_bl_work_item *blwi = NULL; static unsigned int num_bl; @@ -693,13 +702,14 @@ static struct ldlm_bl_work_item *ldlm_bl_get_work(struct ldlm_bl_pool *blp) blwi_entry); if (blwi) { - if (++num_bl >= atomic_read(&blp->blp_num_threads)) + if (++num_bl >= num_th) num_bl = 0; list_del(&blwi->blwi_entry); } spin_unlock(&blp->blp_lock); + *p_blwi = blwi; - return blwi; + return (*p_blwi || *p_exp) ? 1 : 0; } /* This only contains temporary data until the thread starts */ @@ -732,6 +742,65 @@ static int ldlm_bl_thread_start(struct ldlm_bl_pool *blp) return 0; } +/* Not fatal if racy and have a few too many threads */ +static int ldlm_bl_thread_need_create(struct ldlm_bl_pool *blp, + struct ldlm_bl_work_item *blwi) +{ + int busy = atomic_read(&blp->blp_busy_threads); + + if (busy >= blp->blp_max_threads) + return 0; + + if (busy < atomic_read(&blp->blp_num_threads)) + return 0; + + if (blwi && (!blwi->blwi_ns || blwi->blwi_mem_pressure)) + return 0; + + return 1; +} + +static int ldlm_bl_thread_blwi(struct ldlm_bl_pool *blp, + struct ldlm_bl_work_item *blwi) +{ + if (!blwi->blwi_ns) + /* added by ldlm_cleanup() */ + return LDLM_ITER_STOP; + + if (blwi->blwi_mem_pressure) + memory_pressure_set(); + + OBD_FAIL_TIMEOUT(OBD_FAIL_LDLM_PAUSE_CANCEL2, 4); + + if (blwi->blwi_count) { + int count; + + /* + * The special case when we cancel locks in lru + * asynchronously, we pass the list of locks here. + * Thus locks are marked LDLM_FL_CANCELING, but NOT + * canceled locally yet. + */ + count = ldlm_cli_cancel_list_local(&blwi->blwi_head, + blwi->blwi_count, + LCF_BL_AST); + ldlm_cli_cancel_list(&blwi->blwi_head, count, NULL, + blwi->blwi_flags); + } else { + ldlm_handle_bl_callback(blwi->blwi_ns, &blwi->blwi_ld, + blwi->blwi_lock); + } + if (blwi->blwi_mem_pressure) + memory_pressure_clr(); + + if (blwi->blwi_flags & LCF_ASYNC) + kfree(blwi); + else + complete(&blwi->blwi_comp); + + return 0; +} + /** * Main blocking requests processing thread. * @@ -742,73 +811,41 @@ static int ldlm_bl_thread_start(struct ldlm_bl_pool *blp) static int ldlm_bl_thread_main(void *arg) { struct ldlm_bl_pool *blp; + struct ldlm_bl_thread_data *bltd = arg; - { - struct ldlm_bl_thread_data *bltd = arg; - - blp = bltd->bltd_blp; + blp = bltd->bltd_blp; - atomic_inc(&blp->blp_num_threads); - atomic_inc(&blp->blp_busy_threads); + atomic_inc(&blp->blp_num_threads); + atomic_inc(&blp->blp_busy_threads); - complete(&bltd->bltd_comp); - /* cannot use bltd after this, it is only on caller's stack */ - } + complete(&bltd->bltd_comp); + /* cannot use bltd after this, it is only on caller's stack */ while (1) { struct l_wait_info lwi = { 0 }; struct ldlm_bl_work_item *blwi = NULL; - int busy; + struct obd_export *exp = NULL; + int rc; - blwi = ldlm_bl_get_work(blp); - - if (!blwi) { + rc = ldlm_bl_get_work(blp, &blwi, &exp); + if (!rc) { atomic_dec(&blp->blp_busy_threads); l_wait_event_exclusive(blp->blp_waitq, - (blwi = ldlm_bl_get_work(blp)), + ldlm_bl_get_work(blp, &blwi, + &exp), &lwi); - busy = atomic_inc_return(&blp->blp_busy_threads); - } else { - busy = atomic_read(&blp->blp_busy_threads); + atomic_inc(&blp->blp_busy_threads); } - if (!blwi->blwi_ns) - /* added by ldlm_cleanup() */ - break; - - /* Not fatal if racy and have a few too many threads */ - if (unlikely(busy < blp->blp_max_threads && - busy >= atomic_read(&blp->blp_num_threads) && - !blwi->blwi_mem_pressure)) + if (ldlm_bl_thread_need_create(blp, blwi)) /* discard the return value, we tried */ ldlm_bl_thread_start(blp); - if (blwi->blwi_mem_pressure) - memory_pressure_set(); - - if (blwi->blwi_count) { - int count; - /* The special case when we cancel locks in LRU - * asynchronously, we pass the list of locks here. - * Thus locks are marked LDLM_FL_CANCELING, but NOT - * canceled locally yet. - */ - count = ldlm_cli_cancel_list_local(&blwi->blwi_head, - blwi->blwi_count, - LCF_BL_AST); - ldlm_cli_cancel_list(&blwi->blwi_head, count, NULL, - blwi->blwi_flags); - } else { - ldlm_handle_bl_callback(blwi->blwi_ns, &blwi->blwi_ld, - blwi->blwi_lock); - } - if (blwi->blwi_mem_pressure) - memory_pressure_clr(); + if (blwi) + rc = ldlm_bl_thread_blwi(blp, blwi); - if (blwi->blwi_flags & LCF_ASYNC) - kfree(blwi); - else - complete(&blwi->blwi_comp); + if (rc == LDLM_ITER_STOP) + break; } atomic_dec(&blp->blp_busy_threads); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c index 13fbbed..cf3fc57 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c @@ -975,6 +975,10 @@ static int ldlm_pools_recalc(enum ldlm_side client) ldlm_namespace_put(ns); } } + + /* Wake up the blocking threads from time to time. */ + ldlm_bl_thread_wakeup(); + return time; } -- 1.8.3.1 From jsimmons at infradead.org Sat Feb 18 21:47:13 2017 From: jsimmons at infradead.org (James Simmons) Date: Sat, 18 Feb 2017 16:47:13 -0500 Subject: [lustre-devel] [PATCH 12/14] staging: lustre: llog: change lgh_hdr_lock to mutex In-Reply-To: <1487454435-4895-1-git-send-email-jsimmons@infradead.org> References: <1487454435-4895-1-git-send-email-jsimmons@infradead.org> Message-ID: <1487454435-4895-13-git-send-email-jsimmons@infradead.org> From: wang di Change lgh_hdr_lock from spinlock to mutex because if the llog object is a remote object it can be stalled while being fetched. Signed-off-by: wang di Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6602 Reviewed-on: http://review.whamcloud.com/15274 Reviewed-by: James Simmons Reviewed-by: Lai Siyao Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/include/lustre_log.h | 2 +- drivers/staging/lustre/lustre/obdclass/llog.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_log.h b/drivers/staging/lustre/lustre/include/lustre_log.h index 35e37eb..33f56ff 100644 --- a/drivers/staging/lustre/lustre/include/lustre_log.h +++ b/drivers/staging/lustre/lustre/include/lustre_log.h @@ -211,7 +211,7 @@ struct llog_operations { /* In-memory descriptor for a log object or log catalog */ struct llog_handle { struct rw_semaphore lgh_lock; - spinlock_t lgh_hdr_lock; /* protect lgh_hdr data */ + struct mutex lgh_hdr_mutex; /* protect lgh_hdr data */ struct llog_logid lgh_id; /* id of this log */ struct llog_log_hdr *lgh_hdr; size_t lgh_hdr_size; diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c index 736ea10..83c5b62 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog.c +++ b/drivers/staging/lustre/lustre/obdclass/llog.c @@ -61,7 +61,7 @@ static struct llog_handle *llog_alloc_handle(void) return NULL; init_rwsem(&loghandle->lgh_lock); - spin_lock_init(&loghandle->lgh_hdr_lock); + mutex_init(&loghandle->lgh_hdr_mutex); INIT_LIST_HEAD(&loghandle->u.phd.phd_entry); atomic_set(&loghandle->lgh_refcount, 1); -- 1.8.3.1 From jsimmons at infradead.org Sat Feb 18 21:47:05 2017 From: jsimmons at infradead.org (James Simmons) Date: Sat, 18 Feb 2017 16:47:05 -0500 Subject: [lustre-devel] [PATCH 04/14] staging: lustre: lov: cleanup when cl_io_iter_init() fails In-Reply-To: <1487454435-4895-1-git-send-email-jsimmons@infradead.org> References: <1487454435-4895-1-git-send-email-jsimmons@infradead.org> Message-ID: <1487454435-4895-5-git-send-email-jsimmons@infradead.org> From: Jinshan Xiong In lov_io_iter_init(), if cl_io_iter_init() against sub io fails, it should call cl_io_iter_fini() to cleanup leftover information; Signed-off-by: Jinshan Xiong Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6271 Reviewed-on: http://review.whamcloud.com/16456 Reviewed-by: Bobi Jam Reviewed-by: John L. Hammond Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/lov/lov_io.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/staging/lustre/lustre/lov/lov_io.c b/drivers/staging/lustre/lustre/lov/lov_io.c index e0f0756..df77b25 100644 --- a/drivers/staging/lustre/lustre/lov/lov_io.c +++ b/drivers/staging/lustre/lustre/lov/lov_io.c @@ -424,21 +424,23 @@ static int lov_io_iter_init(const struct lu_env *env, end = lov_offset_mod(end, 1); sub = lov_sub_get(env, lio, stripe); - if (!IS_ERR(sub)) { - lov_io_sub_inherit(sub->sub_io, lio, stripe, - start, end); - rc = cl_io_iter_init(sub->sub_env, sub->sub_io); - lov_sub_put(sub); - CDEBUG(D_VFSTRACE, "shrink: %d [%llu, %llu)\n", - stripe, start, end); - } else { + if (IS_ERR(sub)) { rc = PTR_ERR(sub); + break; } - if (!rc) - list_add_tail(&sub->sub_linkage, &lio->lis_active); - else + lov_io_sub_inherit(sub->sub_io, lio, stripe, start, end); + rc = cl_io_iter_init(sub->sub_env, sub->sub_io); + if (rc) + cl_io_iter_fini(sub->sub_env, sub->sub_io); + lov_sub_put(sub); + if (rc) break; + + CDEBUG(D_VFSTRACE, "shrink: %d [%llu, %llu)\n", + stripe, start, end); + + list_add_tail(&sub->sub_linkage, &lio->lis_active); } return rc; } -- 1.8.3.1 From jsimmons at infradead.org Sat Feb 18 21:47:04 2017 From: jsimmons at infradead.org (James Simmons) Date: Sat, 18 Feb 2017 16:47:04 -0500 Subject: [lustre-devel] [PATCH 03/14] staging: lustre: osc: remove obsolete asserts In-Reply-To: <1487454435-4895-1-git-send-email-jsimmons@infradead.org> References: <1487454435-4895-1-git-send-email-jsimmons@infradead.org> Message-ID: <1487454435-4895-4-git-send-email-jsimmons@infradead.org> From: Jinshan Xiong Remove the no longer needed assert in the function osc_cache_truncate_start(). The assertion in osc_object_prune() will become faulty with upcoming changes. The reason this will become a problem is that there may exist freeing pages in object's radix tree at the time of osc_object_prune(), which causes failure at the assertion of (osc->oo_npages == 0). This patch prevents that problem from happening. Signed-off-by: Jinshan Xiong Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6271 Reviewed-on: http://review.whamcloud.com/16456 Reviewed-on: http://review.whamcloud.com/16727 Reviewed-by: Bobi Jam Reviewed-by: John L. Hammond Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/osc/osc_cache.c | 1 - drivers/staging/lustre/lustre/osc/osc_object.c | 4 ---- 2 files changed, 5 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index 0490478..6445bbe 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -2790,7 +2790,6 @@ int osc_cache_truncate_start(const struct lu_env *env, struct osc_object *obj, * We have to wait for this extent because we can't * truncate that page. */ - LASSERT(!ext->oe_hp); OSC_EXTENT_DUMP(D_CACHE, ext, "waiting for busy extent\n"); waiting = osc_extent_get(ext); diff --git a/drivers/staging/lustre/lustre/osc/osc_object.c b/drivers/staging/lustre/lustre/osc/osc_object.c index d3e5ca7..4f8e78b 100644 --- a/drivers/staging/lustre/lustre/osc/osc_object.c +++ b/drivers/staging/lustre/lustre/osc/osc_object.c @@ -200,10 +200,6 @@ static int osc_object_prune(const struct lu_env *env, struct cl_object *obj) struct osc_object *osc = cl2osc(obj); struct ldlm_res_id *resname = &osc_env_info(env)->oti_resname; - LASSERTF(osc->oo_npages == 0, - DFID "still have %lu pages, obj: %p, osc: %p\n", - PFID(lu_object_fid(&obj->co_lu)), osc->oo_npages, obj, osc); - /* DLM locks don't hold a reference of osc_object so we have to * clear it before the object is being destroyed. */ -- 1.8.3.1 From jsimmons at infradead.org Sat Feb 18 21:47:06 2017 From: jsimmons at infradead.org (James Simmons) Date: Sat, 18 Feb 2017 16:47:06 -0500 Subject: [lustre-devel] [PATCH 05/14] staging: lustre: ldlm: handle ldlm lock cancel race when evicting client. In-Reply-To: <1487454435-4895-1-git-send-email-jsimmons@infradead.org> References: <1487454435-4895-1-git-send-email-jsimmons@infradead.org> Message-ID: <1487454435-4895-6-git-send-email-jsimmons@infradead.org> From: Jinshan Xiong A ldlm lock could be canceled simutaneously by ldlm bl thread and cleanup_resource(). In this case, only one side will win the race and the other side should wait for the work to complete. Eviction on group lock is now well supported. Signed-off-by: Jinshan Xiong Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6271 Reviewed-on: http://review.whamcloud.com/16456 Reviewed-by: Bobi Jam Reviewed-by: John L. Hammond Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/include/cl_object.h | 7 +++- .../lustre/lustre/include/lustre_dlm_flags.h | 3 ++ drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 46 ++++++++++++++++------ drivers/staging/lustre/lustre/ldlm/ldlm_request.c | 14 ++++++- drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 2 +- drivers/staging/lustre/lustre/llite/vvp_io.c | 1 + drivers/staging/lustre/lustre/osc/osc_lock.c | 2 + drivers/staging/lustre/lustre/osc/osc_request.c | 10 ++++- 8 files changed, 68 insertions(+), 17 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h index e4c0c44..12b3222 100644 --- a/drivers/staging/lustre/lustre/include/cl_object.h +++ b/drivers/staging/lustre/lustre/include/cl_object.h @@ -1640,9 +1640,14 @@ enum cl_enq_flags { */ CEF_PEEK = 0x00000040, /** + * Lock match only. Used by group lock in I/O as group lock + * is known to exist. + */ + CEF_LOCK_MATCH = BIT(7), + /** * mask of enq_flags. */ - CEF_MASK = 0x0000007f, + CEF_MASK = 0x000000ff, }; /** diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h b/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h index a0f064d..11331ae 100644 --- a/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h +++ b/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h @@ -121,6 +121,9 @@ #define ldlm_set_test_lock(_l) LDLM_SET_FLAG((_l), 1ULL << 19) #define ldlm_clear_test_lock(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 19) +/** match lock only */ +#define LDLM_FL_MATCH_LOCK 0x0000000000100000ULL /* bit 20 */ + /** * Immediately cancel such locks when they block some other locks. Send * cancel notification to original lock holder, but expect no reply. This diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index 5a94265..16c2a8b 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -771,19 +771,11 @@ void ldlm_lock_decref_internal(struct ldlm_lock *lock, enum ldlm_mode mode) ldlm_lock_decref_internal_nolock(lock, mode); - if (ldlm_is_local(lock) && + if ((ldlm_is_local(lock) || lock->l_req_mode == LCK_GROUP) && !lock->l_readers && !lock->l_writers) { /* If this is a local lock on a server namespace and this was * the last reference, cancel the lock. - */ - CDEBUG(D_INFO, "forcing cancel of local lock\n"); - ldlm_set_cbpending(lock); - } - - if (!lock->l_readers && !lock->l_writers && - (ldlm_is_cbpending(lock) || lock->l_req_mode == LCK_GROUP)) { - /* If we received a blocked AST and this was the last reference, - * run the callback. + * * Group locks are special: * They must not go in LRU, but they are not called back * like non-group locks, instead they are manually released. @@ -791,6 +783,13 @@ void ldlm_lock_decref_internal(struct ldlm_lock *lock, enum ldlm_mode mode) * they are manually released, so we remove them when they have * no more reader or writer references. - LU-6368 */ + ldlm_set_cbpending(lock); + } + + if (!lock->l_readers && !lock->l_writers && ldlm_is_cbpending(lock)) { + /* If we received a blocked AST and this was the last reference, + * run the callback. + */ LDLM_DEBUG(lock, "final decref done on cbpending lock"); LDLM_LOCK_GET(lock); /* dropped by bl thread */ @@ -1882,6 +1881,19 @@ int ldlm_run_ast_work(struct ldlm_namespace *ns, struct list_head *rpc_list, return rc; } +static bool is_bl_done(struct ldlm_lock *lock) +{ + bool bl_done = true; + + if (!ldlm_is_bl_done(lock)) { + lock_res_and_lock(lock); + bl_done = ldlm_is_bl_done(lock); + unlock_res_and_lock(lock); + } + + return bl_done; +} + /** * Helper function to call blocking AST for LDLM lock \a lock in a * "cancelling" mode. @@ -1899,8 +1911,20 @@ void ldlm_cancel_callback(struct ldlm_lock *lock) } else { LDLM_DEBUG(lock, "no blocking ast"); } + /* only canceller can set bl_done bit */ + ldlm_set_bl_done(lock); + wake_up_all(&lock->l_waitq); + } else if (!ldlm_is_bl_done(lock)) { + struct l_wait_info lwi = { 0 }; + + /* + * The lock is guaranteed to have been canceled once + * returning from this function. + */ + unlock_res_and_lock(lock); + l_wait_event(lock->l_waitq, is_bl_done(lock), &lwi); + lock_res_and_lock(lock); } - ldlm_set_bl_done(lock); } /** diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c index ebfda36..84eeaa5 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c @@ -1029,13 +1029,23 @@ int ldlm_cli_cancel(const struct lustre_handle *lockh, struct ldlm_lock *lock; LIST_HEAD(cancels); - /* concurrent cancels on the same handle can happen */ - lock = ldlm_handle2lock_long(lockh, LDLM_FL_CANCELING); + lock = ldlm_handle2lock_long(lockh, 0); if (!lock) { LDLM_DEBUG_NOLOCK("lock is already being destroyed"); return 0; } + lock_res_and_lock(lock); + /* Lock is being canceled and the caller doesn't want to wait */ + if (ldlm_is_canceling(lock) && (cancel_flags & LCF_ASYNC)) { + unlock_res_and_lock(lock); + LDLM_LOCK_RELEASE(lock); + return 0; + } + + ldlm_set_canceling(lock); + unlock_res_and_lock(lock); + rc = ldlm_cli_cancel_local(lock); if (rc == LDLM_FL_LOCAL_ONLY || cancel_flags & LCF_LOCAL) { LDLM_LOCK_RELEASE(lock); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index d16f5e9..633f65b 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -806,7 +806,7 @@ static void cleanup_resource(struct ldlm_resource *res, struct list_head *q, unlock_res(res); ldlm_lock2handle(lock, &lockh); - rc = ldlm_cli_cancel(&lockh, LCF_ASYNC); + rc = ldlm_cli_cancel(&lockh, LCF_LOCAL); if (rc) CERROR("ldlm_cli_cancel: %d\n", rc); LDLM_LOCK_RELEASE(lock); diff --git a/drivers/staging/lustre/lustre/llite/vvp_io.c b/drivers/staging/lustre/lustre/llite/vvp_io.c index 3e9cf71..711126e 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_io.c +++ b/drivers/staging/lustre/lustre/llite/vvp_io.c @@ -219,6 +219,7 @@ static int vvp_io_one_lock_index(const struct lu_env *env, struct cl_io *io, if (vio->vui_fd && (vio->vui_fd->fd_flags & LL_FILE_GROUP_LOCKED)) { descr->cld_mode = CLM_GROUP; descr->cld_gid = vio->vui_fd->fd_grouplock.lg_gid; + enqflags |= CEF_LOCK_MATCH; } else { descr->cld_mode = mode; } diff --git a/drivers/staging/lustre/lustre/osc/osc_lock.c b/drivers/staging/lustre/lustre/osc/osc_lock.c index 5f799a4..efecd92 100644 --- a/drivers/staging/lustre/lustre/osc/osc_lock.c +++ b/drivers/staging/lustre/lustre/osc/osc_lock.c @@ -167,6 +167,8 @@ static __u64 osc_enq2ldlm_flags(__u32 enqflags) result |= LDLM_FL_AST_DISCARD_DATA; if (enqflags & CEF_PEEK) result |= LDLM_FL_TEST_LOCK; + if (enqflags & CEF_LOCK_MATCH) + result |= LDLM_FL_MATCH_LOCK; return result; } diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index c4cfe18..8e22807 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -2011,7 +2011,7 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, } no_match: - if (*flags & LDLM_FL_TEST_LOCK) + if (*flags & (LDLM_FL_TEST_LOCK | LDLM_FL_MATCH_LOCK)) return -ENOLCK; if (intent) { req = ptlrpc_request_alloc(class_exp2cliimp(exp), @@ -2495,7 +2495,13 @@ static int osc_ldlm_resource_invalidate(struct cfs_hash *hs, osc = lock->l_ast_data; cl_object_get(osc2cl(osc)); } - lock->l_ast_data = NULL; + + /* + * clear LDLM_FL_CLEANED flag to make sure it will be canceled + * by the 2nd round of ldlm_namespace_clean() call in + * osc_import_event(). + */ + ldlm_clear_cleaned(lock); } unlock_res(res); -- 1.8.3.1 From jsimmons at infradead.org Sat Feb 18 21:47:09 2017 From: jsimmons at infradead.org (James Simmons) Date: Sat, 18 Feb 2017 16:47:09 -0500 Subject: [lustre-devel] [PATCH 08/14] staging: lustre: llite: remove extraneous export parameter In-Reply-To: <1487454435-4895-1-git-send-email-jsimmons@infradead.org> References: <1487454435-4895-1-git-send-email-jsimmons@infradead.org> Message-ID: <1487454435-4895-9-git-send-email-jsimmons@infradead.org> From: Andreas Dilger The ll_close_inode_openhandle() and ll_md_close() functions passed an extra "obd_export *md_exp" parameter, but it turns out that all of the callers already pass inode->i_sb->s_fs_info->lsi_llsbi->ll_md_exp in one form or another, so it can just be extracted from "inode" directly as needed. Signed-off-by: Andreas Dilger Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6627 Reviewed-on: http://review.whamcloud.com/14953 Reviewed-by: Frank Zago Reviewed-by: Bobi Jam Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/llite/file.c | 33 +++++++++++++----------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index b1c9573..d8a5e70 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -116,13 +116,13 @@ static void ll_prepare_close(struct inode *inode, struct md_op_data *op_data, * If \a bias is MDS_CLOSE_LAYOUT_SWAP then \a data is a pointer to the inode to * swap layouts with. */ -static int ll_close_inode_openhandle(struct obd_export *md_exp, +static int ll_close_inode_openhandle(struct inode *inode, struct obd_client_handle *och, - struct inode *inode, enum mds_op_bias bias, void *data) { const struct ll_inode_info *lli = ll_i2info(inode); + struct obd_export *md_exp = ll_i2mdexp(inode); struct md_op_data *op_data; struct ptlrpc_request *req = NULL; int rc; @@ -231,15 +231,13 @@ int ll_md_real_close(struct inode *inode, fmode_t fmode) /* There might be a race and this handle may already * be closed. */ - rc = ll_close_inode_openhandle(ll_i2sbi(inode)->ll_md_exp, - och, inode, 0, NULL); + rc = ll_close_inode_openhandle(inode, och, 0, NULL); } return rc; } -static int ll_md_close(struct obd_export *md_exp, struct inode *inode, - struct file *file) +static int ll_md_close(struct inode *inode, struct file *file) { struct ll_file_data *fd = LUSTRE_FPRIVATE(file); struct ll_inode_info *lli = ll_i2info(inode); @@ -270,8 +268,7 @@ static int ll_md_close(struct obd_export *md_exp, struct inode *inode, } if (fd->fd_och) { - rc = ll_close_inode_openhandle(md_exp, fd->fd_och, inode, 0, - NULL); + rc = ll_close_inode_openhandle(inode, fd->fd_och, 0, NULL); fd->fd_och = NULL; goto out; } @@ -296,7 +293,7 @@ static int ll_md_close(struct obd_export *md_exp, struct inode *inode, } mutex_unlock(&lli->lli_och_mutex); - if (!md_lock_match(md_exp, flags, ll_inode2fid(inode), + if (!md_lock_match(ll_i2mdexp(inode), flags, ll_inode2fid(inode), LDLM_IBITS, &policy, lockmode, &lockh)) rc = ll_md_real_close(inode, fd->fd_omode); @@ -345,7 +342,7 @@ int ll_file_release(struct inode *inode, struct file *file) lli->lli_async_rc = 0; } - rc = ll_md_close(sbi->ll_md_exp, inode, file); + rc = ll_md_close(inode, file); if (CFS_FAIL_TIMEOUT_MS(OBD_FAIL_PTLRPC_DUMP_LOG, cfs_fail_val)) libcfs_debug_dumplog(); @@ -835,7 +832,7 @@ static int ll_md_blocking_lease_ast(struct ldlm_lock *lock, it.it_lock_mode = 0; och->och_lease_handle.cookie = 0ULL; } - rc2 = ll_close_inode_openhandle(sbi->ll_md_exp, och, inode, 0, NULL); + rc2 = ll_close_inode_openhandle(inode, och, 0, NULL); if (rc2 < 0) CERROR("%s: error closing file "DFID": %d\n", ll_get_fsname(inode->i_sb, NULL, 0), @@ -901,8 +898,8 @@ static int ll_swap_layouts_close(struct obd_client_handle *och, * NB: lease lock handle is released in mdc_close_layout_swap_pack() * because we still need it to pack l_remote_handle to MDT. */ - rc = ll_close_inode_openhandle(ll_i2sbi(inode)->ll_md_exp, och, inode, - MDS_CLOSE_LAYOUT_SWAP, inode2); + rc = ll_close_inode_openhandle(inode, och, MDS_CLOSE_LAYOUT_SWAP, + inode2); och = NULL; /* freed in ll_close_inode_openhandle() */ @@ -937,8 +934,7 @@ static int ll_lease_close(struct obd_client_handle *och, struct inode *inode, if (lease_broken) *lease_broken = cancelled; - return ll_close_inode_openhandle(ll_i2sbi(inode)->ll_md_exp, - och, inode, 0, NULL); + return ll_close_inode_openhandle(inode, och, 0, NULL); } int ll_merge_attr(const struct lu_env *env, struct inode *inode) @@ -1494,8 +1490,7 @@ int ll_release_openhandle(struct inode *inode, struct lookup_intent *it) ll_och_fill(ll_i2sbi(inode)->ll_md_exp, it, och); - rc = ll_close_inode_openhandle(ll_i2sbi(inode)->ll_md_exp, - och, inode, 0, NULL); + rc = ll_close_inode_openhandle(inode, och, 0, NULL); out: /* this one is in place of ll_file_open */ if (it_disposition(it, DISP_ENQ_OPEN_REF)) { @@ -1698,8 +1693,8 @@ int ll_hsm_release(struct inode *inode) * NB: lease lock handle is released in mdc_hsm_release_pack() because * we still need it to pack l_remote_handle to MDT. */ - rc = ll_close_inode_openhandle(ll_i2sbi(inode)->ll_md_exp, och, inode, - MDS_HSM_RELEASE, &data_version); + rc = ll_close_inode_openhandle(inode, och, MDS_HSM_RELEASE, + &data_version); och = NULL; out: -- 1.8.3.1 From jsimmons at infradead.org Sat Feb 18 21:47:14 2017 From: jsimmons at infradead.org (James Simmons) Date: Sat, 18 Feb 2017 16:47:14 -0500 Subject: [lustre-devel] [PATCH 13/14] staging: lustre: llog: limit file size of plain logs In-Reply-To: <1487454435-4895-1-git-send-email-jsimmons@infradead.org> References: <1487454435-4895-1-git-send-email-jsimmons@infradead.org> Message-ID: <1487454435-4895-14-git-send-email-jsimmons@infradead.org> From: Alex Zhuravlev on small filesystems plain log can grow dramatically. especially given large record sizes produced by DNE and extended chunksize. I saw >50% of space consumed by a single llog file which was still in use. this leads to test failures (sanityn, etc). the patch introduces additional limit on plain llog size, which is calculated as /64 (128MB at most) at llog creation time. Signed-off-by: Alex Zhuravlev Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6838 Reviewed-on: https://review.whamcloud.com/18028 Reviewed-by: Andreas Dilger Reviewed-by: wangdi Reviewed-by: Mike Pershin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/obdclass/llog.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c index 83c5b62..320ff6b 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog.c +++ b/drivers/staging/lustre/lustre/obdclass/llog.c @@ -319,10 +319,26 @@ static int llog_process_thread(void *arg) * the case and re-read the current chunk * otherwise. */ + int records; + if (index > loghandle->lgh_last_idx) { rc = 0; goto out; } + /* <2 records means no more records + * if the last record we processed was + * the final one, then the underlying + * object might have been destroyed yet. + * we better don't access that.. + */ + mutex_lock(&loghandle->lgh_hdr_mutex); + records = loghandle->lgh_hdr->llh_count; + mutex_unlock(&loghandle->lgh_hdr_mutex); + if (records <= 1) { + rc = 0; + goto out; + } + CDEBUG(D_OTHER, "Re-read last llog buffer for new records, index %u, last %u\n", index, loghandle->lgh_last_idx); /* save offset inside buffer for the re-read */ -- 1.8.3.1 From jsimmons at infradead.org Sat Feb 18 21:47:15 2017 From: jsimmons at infradead.org (James Simmons) Date: Sat, 18 Feb 2017 16:47:15 -0500 Subject: [lustre-devel] [PATCH 14/14] staging: lustre: lprocfs: move lprocfs_stats_[un]lock to a source file In-Reply-To: <1487454435-4895-1-git-send-email-jsimmons@infradead.org> References: <1487454435-4895-1-git-send-email-jsimmons@infradead.org> Message-ID: <1487454435-4895-15-git-send-email-jsimmons@infradead.org> When compiling the kernel without optimization, when using GCOV, the lprocfs_stats_alloc_one() symbol is not properly exported to other modules and causes the ptlrpc module to fail loading with an unknown symbol. There is no reason to export the function lprocfs_stats_alloc_one. The reason is due to the functions lprocfs_stats_[un]lock being inline functions in a header file. Lets untangle this mess and turn those inline functions into real functions in a source file. Signed-off-by: James Simmons Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8836 Reviewed-on: https://review.whamcloud.com/23773 Reviewed-by: Andreas Dilger Reviewed-by: Dmitry Eremin Reviewed-by: John L. Hammond Signed-off-by: James Simmons --- .../staging/lustre/lustre/include/lprocfs_status.h | 120 ++------------------- .../lustre/lustre/obdclass/lprocfs_status.c | 111 +++++++++++++++++++ 2 files changed, 121 insertions(+), 110 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index 62753da..242abb8 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -374,94 +374,15 @@ int lprocfs_write_frac_helper(const char __user *buffer, unsigned long count, int *val, int mult); int lprocfs_read_frac_helper(char *buffer, unsigned long count, long val, int mult); -int lprocfs_stats_alloc_one(struct lprocfs_stats *stats, unsigned int cpuid); -/** - * Lock statistics structure for access, possibly only on this CPU. - * - * The statistics struct may be allocated with per-CPU structures for - * efficient concurrent update (usually only on server-wide stats), or - * as a single global struct (e.g. for per-client or per-job statistics), - * so the required locking depends on the type of structure allocated. - * - * For per-CPU statistics, pin the thread to the current cpuid so that - * will only access the statistics for that CPU. If the stats structure - * for the current CPU has not been allocated (or previously freed), - * allocate it now. The per-CPU statistics do not need locking since - * the thread is pinned to the CPU during update. - * - * For global statistics, lock the stats structure to prevent concurrent update. - * - * \param[in] stats statistics structure to lock - * \param[in] opc type of operation: - * LPROCFS_GET_SMP_ID: "lock" and return current CPU index - * for incrementing statistics for that CPU - * LPROCFS_GET_NUM_CPU: "lock" and return number of used - * CPU indices to iterate over all indices - * \param[out] flags CPU interrupt saved state for IRQ-safe locking - * - * \retval cpuid of current thread or number of allocated structs - * \retval negative on error (only for opc LPROCFS_GET_SMP_ID + per-CPU stats) - */ -static inline int lprocfs_stats_lock(struct lprocfs_stats *stats, - enum lprocfs_stats_lock_ops opc, - unsigned long *flags) -{ - if (stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) { - if (stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) - spin_lock_irqsave(&stats->ls_lock, *flags); - else - spin_lock(&stats->ls_lock); - return opc == LPROCFS_GET_NUM_CPU ? 1 : 0; - } - - switch (opc) { - case LPROCFS_GET_SMP_ID: { - unsigned int cpuid = get_cpu(); - - if (unlikely(!stats->ls_percpu[cpuid])) { - int rc = lprocfs_stats_alloc_one(stats, cpuid); - - if (rc < 0) { - put_cpu(); - return rc; - } - } - return cpuid; - } - case LPROCFS_GET_NUM_CPU: - return stats->ls_biggest_alloc_num; - default: - LBUG(); - } -} - -/** - * Unlock statistics structure after access. - * - * Unlock the lock acquired via lprocfs_stats_lock() for global statistics, - * or unpin this thread from the current cpuid for per-CPU statistics. - * - * This function must be called using the same arguments as used when calling - * lprocfs_stats_lock() so that the correct operation can be performed. - * - * \param[in] stats statistics structure to unlock - * \param[in] opc type of operation (current cpuid or number of structs) - * \param[in] flags CPU interrupt saved state for IRQ-safe locking - */ -static inline void lprocfs_stats_unlock(struct lprocfs_stats *stats, - enum lprocfs_stats_lock_ops opc, - unsigned long *flags) -{ - if (stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) { - if (stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) - spin_unlock_irqrestore(&stats->ls_lock, *flags); - else - spin_unlock(&stats->ls_lock); - } else if (opc == LPROCFS_GET_SMP_ID) { - put_cpu(); - } -} +int lprocfs_stats_alloc_one(struct lprocfs_stats *stats, + unsigned int cpuid); +int lprocfs_stats_lock(struct lprocfs_stats *stats, + enum lprocfs_stats_lock_ops opc, + unsigned long *flags); +void lprocfs_stats_unlock(struct lprocfs_stats *stats, + enum lprocfs_stats_lock_ops opc, + unsigned long *flags); static inline unsigned int lprocfs_stats_counter_size(struct lprocfs_stats *stats) @@ -513,29 +434,8 @@ __s64 lprocfs_read_helper(struct lprocfs_counter *lc, struct lprocfs_counter_header *header, enum lprocfs_stats_flags flags, enum lprocfs_fields_flags field); -static inline __u64 lprocfs_stats_collector(struct lprocfs_stats *stats, - int idx, - enum lprocfs_fields_flags field) -{ - unsigned int i; - unsigned int num_cpu; - unsigned long flags = 0; - __u64 ret = 0; - - LASSERT(stats); - - num_cpu = lprocfs_stats_lock(stats, LPROCFS_GET_NUM_CPU, &flags); - for (i = 0; i < num_cpu; i++) { - if (!stats->ls_percpu[i]) - continue; - ret += lprocfs_read_helper( - lprocfs_stats_counter_get(stats, i, idx), - &stats->ls_cnt_header[idx], stats->ls_flags, - field); - } - lprocfs_stats_unlock(stats, LPROCFS_GET_NUM_CPU, &flags); - return ret; -} +__u64 lprocfs_stats_collector(struct lprocfs_stats *stats, int idx, + enum lprocfs_fields_flags field); extern struct lprocfs_stats * lprocfs_alloc_stats(unsigned int num, enum lprocfs_stats_flags flags); diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index 2c99717..1ec6e37 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -598,6 +598,93 @@ int lprocfs_rd_conn_uuid(struct seq_file *m, void *data) } EXPORT_SYMBOL(lprocfs_rd_conn_uuid); +/** + * Lock statistics structure for access, possibly only on this CPU. + * + * The statistics struct may be allocated with per-CPU structures for + * efficient concurrent update (usually only on server-wide stats), or + * as a single global struct (e.g. for per-client or per-job statistics), + * so the required locking depends on the type of structure allocated. + * + * For per-CPU statistics, pin the thread to the current cpuid so that + * will only access the statistics for that CPU. If the stats structure + * for the current CPU has not been allocated (or previously freed), + * allocate it now. The per-CPU statistics do not need locking since + * the thread is pinned to the CPU during update. + * + * For global statistics, lock the stats structure to prevent concurrent update. + * + * \param[in] stats statistics structure to lock + * \param[in] opc type of operation: + * LPROCFS_GET_SMP_ID: "lock" and return current CPU index + * for incrementing statistics for that CPU + * LPROCFS_GET_NUM_CPU: "lock" and return number of used + * CPU indices to iterate over all indices + * \param[out] flags CPU interrupt saved state for IRQ-safe locking + * + * \retval cpuid of current thread or number of allocated structs + * \retval negative on error (only for opc LPROCFS_GET_SMP_ID + per-CPU stats) + */ +int lprocfs_stats_lock(struct lprocfs_stats *stats, + enum lprocfs_stats_lock_ops opc, + unsigned long *flags) +{ + if (stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) { + if (stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) + spin_lock_irqsave(&stats->ls_lock, *flags); + else + spin_lock(&stats->ls_lock); + return opc == LPROCFS_GET_NUM_CPU ? 1 : 0; + } + + switch (opc) { + case LPROCFS_GET_SMP_ID: { + unsigned int cpuid = get_cpu(); + + if (unlikely(!stats->ls_percpu[cpuid])) { + int rc = lprocfs_stats_alloc_one(stats, cpuid); + + if (rc < 0) { + put_cpu(); + return rc; + } + } + return cpuid; + } + case LPROCFS_GET_NUM_CPU: + return stats->ls_biggest_alloc_num; + default: + LBUG(); + } +} + +/** + * Unlock statistics structure after access. + * + * Unlock the lock acquired via lprocfs_stats_lock() for global statistics, + * or unpin this thread from the current cpuid for per-CPU statistics. + * + * This function must be called using the same arguments as used when calling + * lprocfs_stats_lock() so that the correct operation can be performed. + * + * \param[in] stats statistics structure to unlock + * \param[in] opc type of operation (current cpuid or number of structs) + * \param[in] flags CPU interrupt saved state for IRQ-safe locking + */ +void lprocfs_stats_unlock(struct lprocfs_stats *stats, + enum lprocfs_stats_lock_ops opc, + unsigned long *flags) +{ + if (stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU) { + if (stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) + spin_unlock_irqrestore(&stats->ls_lock, *flags); + else + spin_unlock(&stats->ls_lock); + } else if (opc == LPROCFS_GET_SMP_ID) { + put_cpu(); + } +} + /** add up per-cpu counters */ void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx, struct lprocfs_counter *cnt) @@ -1146,6 +1233,30 @@ void lprocfs_free_stats(struct lprocfs_stats **statsh) } EXPORT_SYMBOL(lprocfs_free_stats); +__u64 lprocfs_stats_collector(struct lprocfs_stats *stats, int idx, + enum lprocfs_fields_flags field) +{ + unsigned int i; + unsigned int num_cpu; + unsigned long flags = 0; + __u64 ret = 0; + + LASSERT(stats); + + num_cpu = lprocfs_stats_lock(stats, LPROCFS_GET_NUM_CPU, &flags); + for (i = 0; i < num_cpu; i++) { + if (!stats->ls_percpu[i]) + continue; + ret += lprocfs_read_helper( + lprocfs_stats_counter_get(stats, i, idx), + &stats->ls_cnt_header[idx], stats->ls_flags, + field); + } + lprocfs_stats_unlock(stats, LPROCFS_GET_NUM_CPU, &flags); + return ret; +} +EXPORT_SYMBOL(lprocfs_stats_collector); + void lprocfs_clear_stats(struct lprocfs_stats *stats) { struct lprocfs_counter *percpu_cntr; -- 1.8.3.1 From jsimmons at infradead.org Mon Feb 20 02:37:51 2017 From: jsimmons at infradead.org (James Simmons) Date: Mon, 20 Feb 2017 02:37:51 +0000 (GMT) Subject: [lustre-devel] [PATCH] staging: lustre: ko2iblnd: Adapt to the removal of ib_get_dma_mr() In-Reply-To: <1487441050-19728-2-git-send-email-doug.s.oucharek@intel.com> References: <1487441050-19728-1-git-send-email-doug.s.oucharek@intel.com> <1487441050-19728-2-git-send-email-doug.s.oucharek@intel.com> Message-ID: > In Linux kernel 4.9-rc1, the function ib_get_dma_mr() > was removed and a second parameter was added to ib_alloc_pd(). > As this broke the building of the ko2iblnd module in > staging, the Kconfig for LNet has marked ko2iblnd as broken > and stopped building it. > > This patch fixes this breakage by: > > - Removing the BROKEN tag from lnet/Kconfig. > - Make it so the module parameter map_on_demand can no longer be > zero (we have to configure FMR/FastReg pools; it can no longer be > off). > - No longer try to use the global DMA memory region, but make use > of the FMR/FastReg pool for all RDMA Tx operations. > - Everywhere we are using the device DMA mr to derive the > L-key for non-registered memory regions, use the > pd->local_dma_lkey value instead. > - Make the default map_on_demand = 256. This will allow nodes with > this patch to still connected to older nodes without this patch > and FMR/FastReg turned off. When FMR/FastReg is turned off, we > use 256 as the max frags so the two sides will still be able to > communicate and work. > - Fix a mistake with BUILD_BUG_ON calls in o2iblnd.c which caused > compiling to fail. > > Signed-off-by: Doug Oucharek > Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-9026 > Reviewed-on: https://review.whamcloud.com/#/c/24931/ > Reviewed-by: James Simmons Reviewed-by: James Simmons > Changelog: > v1) Initial patch > v2) Rebased and handle a fix to BUILD_BUG_ON > --- > drivers/staging/lustre/lnet/Kconfig | 1 - > .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 77 ++-------------------- > .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h | 3 - > .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 17 +---- > .../lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c | 12 ++-- > 5 files changed, 16 insertions(+), 94 deletions(-) > > diff --git a/drivers/staging/lustre/lnet/Kconfig b/drivers/staging/lustre/lnet/Kconfig > index 13b4327..2b59301 100644 > --- a/drivers/staging/lustre/lnet/Kconfig > +++ b/drivers/staging/lustre/lnet/Kconfig > @@ -35,7 +35,6 @@ config LNET_SELFTEST > config LNET_XPRT_IB > tristate "LNET infiniband support" > depends on LNET && INFINIBAND && INFINIBAND_ADDR_TRANS > - depends on BROKEN > default LNET && INFINIBAND > help > This option allows the LNET users to use infiniband as an > diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c > index b1e8508..0618b79 100644 > --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c > +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c > @@ -1281,27 +1281,6 @@ static void kiblnd_map_tx_pool(struct kib_tx_pool *tpo) > } > } > > -struct ib_mr *kiblnd_find_rd_dma_mr(struct lnet_ni *ni, struct kib_rdma_desc *rd, > - int negotiated_nfrags) > -{ > - struct kib_net *net = ni->ni_data; > - struct kib_hca_dev *hdev = net->ibn_dev->ibd_hdev; > - struct lnet_ioctl_config_o2iblnd_tunables *tunables; > - __u16 nfrags; > - int mod; > - > - tunables = &ni->ni_lnd_tunables->lt_tun_u.lt_o2ib; > - mod = tunables->lnd_map_on_demand; > - nfrags = (negotiated_nfrags != -1) ? negotiated_nfrags : mod; > - > - LASSERT(hdev->ibh_mrs); > - > - if (mod > 0 && nfrags <= rd->rd_nfrags) > - return NULL; > - > - return hdev->ibh_mrs; > -} > - > static void kiblnd_destroy_fmr_pool(struct kib_fmr_pool *fpo) > { > LASSERT(!fpo->fpo_map_count); > @@ -2168,21 +2147,12 @@ static int kiblnd_net_init_pools(struct kib_net *net, lnet_ni_t *ni, __u32 *cpts > int ncpts) > { > struct lnet_ioctl_config_o2iblnd_tunables *tunables; > - unsigned long flags; > int cpt; > int rc; > int i; > > tunables = &ni->ni_lnd_tunables->lt_tun_u.lt_o2ib; > > - read_lock_irqsave(&kiblnd_data.kib_global_lock, flags); > - if (!tunables->lnd_map_on_demand) { > - read_unlock_irqrestore(&kiblnd_data.kib_global_lock, flags); > - goto create_tx_pool; > - } > - > - read_unlock_irqrestore(&kiblnd_data.kib_global_lock, flags); > - > if (tunables->lnd_fmr_pool_size < *kiblnd_tunables.kib_ntx / 4) { > CERROR("Can't set fmr pool size (%d) < ntx / 4(%d)\n", > tunables->lnd_fmr_pool_size, > @@ -2227,7 +2197,6 @@ static int kiblnd_net_init_pools(struct kib_net *net, lnet_ni_t *ni, __u32 *cpts > if (i > 0) > LASSERT(i == ncpts); > > - create_tx_pool: > /* > * cfs_precpt_alloc is creating an array of struct kib_tx_poolset > * The number of struct kib_tx_poolsets create is equal to the > @@ -2283,20 +2252,8 @@ static int kiblnd_hdev_get_attr(struct kib_hca_dev *hdev) > return -EINVAL; > } > > -static void kiblnd_hdev_cleanup_mrs(struct kib_hca_dev *hdev) > -{ > - if (!hdev->ibh_mrs) > - return; > - > - ib_dereg_mr(hdev->ibh_mrs); > - > - hdev->ibh_mrs = NULL; > -} > - > void kiblnd_hdev_destroy(struct kib_hca_dev *hdev) > { > - kiblnd_hdev_cleanup_mrs(hdev); > - > if (hdev->ibh_pd) > ib_dealloc_pd(hdev->ibh_pd); > > @@ -2306,28 +2263,6 @@ void kiblnd_hdev_destroy(struct kib_hca_dev *hdev) > LIBCFS_FREE(hdev, sizeof(*hdev)); > } > > -static int kiblnd_hdev_setup_mrs(struct kib_hca_dev *hdev) > -{ > - struct ib_mr *mr; > - int rc; > - int acflags = IB_ACCESS_LOCAL_WRITE | IB_ACCESS_REMOTE_WRITE; > - > - rc = kiblnd_hdev_get_attr(hdev); > - if (rc) > - return rc; > - > - mr = ib_get_dma_mr(hdev->ibh_pd, acflags); > - if (IS_ERR(mr)) { > - CERROR("Failed ib_get_dma_mr : %ld\n", PTR_ERR(mr)); > - kiblnd_hdev_cleanup_mrs(hdev); > - return PTR_ERR(mr); > - } > - > - hdev->ibh_mrs = mr; > - > - return 0; > -} > - > /* DUMMY */ > static int kiblnd_dummy_callback(struct rdma_cm_id *cmid, > struct rdma_cm_event *event) > @@ -2482,9 +2417,9 @@ int kiblnd_dev_failover(struct kib_dev *dev) > goto out; > } > > - rc = kiblnd_hdev_setup_mrs(hdev); > + rc = kiblnd_hdev_get_attr(hdev); > if (rc) { > - CERROR("Can't setup device: %d\n", rc); > + CERROR("Can't get device attributes: %d\n", rc); > goto out; > } > > @@ -3021,12 +2956,12 @@ static void __exit ko2iblnd_exit(void) > static int __init ko2iblnd_init(void) > { > BUILD_BUG_ON(sizeof(struct kib_msg) > IBLND_MSG_SIZE); > - BUILD_BUG_ON(!offsetof(struct kib_msg, > + BUILD_BUG_ON(offsetof(struct kib_msg, > ibm_u.get.ibgm_rd.rd_frags[IBLND_MAX_RDMA_FRAGS]) > - <= IBLND_MSG_SIZE); > - BUILD_BUG_ON(!offsetof(struct kib_msg, > + > IBLND_MSG_SIZE); > + BUILD_BUG_ON(offsetof(struct kib_msg, > ibm_u.putack.ibpam_rd.rd_frags[IBLND_MAX_RDMA_FRAGS]) > - <= IBLND_MSG_SIZE); > + > IBLND_MSG_SIZE); > > kiblnd_tunables_init(); > > diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h > index 2cb4298..366372d 100644 > --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h > +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h > @@ -172,7 +172,6 @@ struct kib_hca_dev { > __u64 ibh_page_mask; /* page mask of current HCA */ > int ibh_mr_shift; /* bits shift of max MR size */ > __u64 ibh_mr_size; /* size of MR */ > - struct ib_mr *ibh_mrs; /* global MR */ > struct ib_pd *ibh_pd; /* PD */ > struct kib_dev *ibh_dev; /* owner */ > atomic_t ibh_ref; /* refcount */ > @@ -978,8 +977,6 @@ static inline unsigned int kiblnd_sg_dma_len(struct ib_device *dev, > #define KIBLND_CONN_PARAM(e) ((e)->param.conn.private_data) > #define KIBLND_CONN_PARAM_LEN(e) ((e)->param.conn.private_data_len) > > -struct ib_mr *kiblnd_find_rd_dma_mr(struct lnet_ni *ni, struct kib_rdma_desc *rd, > - int negotiated_nfrags); > void kiblnd_map_rx_descs(struct kib_conn *conn); > void kiblnd_unmap_rx_descs(struct kib_conn *conn); > void kiblnd_pool_free_node(struct kib_pool *pool, struct list_head *node); > diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c > index e2f3f72..6eaa548 100644 > --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c > +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c > @@ -157,7 +157,6 @@ static int kiblnd_init_rdma(struct kib_conn *conn, struct kib_tx *tx, int type, > struct kib_conn *conn = rx->rx_conn; > struct kib_net *net = conn->ibc_peer->ibp_ni->ni_data; > struct ib_recv_wr *bad_wrq = NULL; > - struct ib_mr *mr = conn->ibc_hdev->ibh_mrs; > int rc; > > LASSERT(net); > @@ -165,9 +164,8 @@ static int kiblnd_init_rdma(struct kib_conn *conn, struct kib_tx *tx, int type, > LASSERT(credit == IBLND_POSTRX_NO_CREDIT || > credit == IBLND_POSTRX_PEER_CREDIT || > credit == IBLND_POSTRX_RSRVD_CREDIT); > - LASSERT(mr); > > - rx->rx_sge.lkey = mr->lkey; > + rx->rx_sge.lkey = conn->ibc_hdev->ibh_pd->local_dma_lkey; > rx->rx_sge.addr = rx->rx_msgaddr; > rx->rx_sge.length = IBLND_MSG_SIZE; > > @@ -613,7 +611,6 @@ static int kiblnd_map_tx(lnet_ni_t *ni, struct kib_tx *tx, struct kib_rdma_desc > { > struct kib_net *net = ni->ni_data; > struct kib_hca_dev *hdev = net->ibn_dev->ibd_hdev; > - struct ib_mr *mr = NULL; > __u32 nob; > int i; > > @@ -635,14 +632,6 @@ static int kiblnd_map_tx(lnet_ni_t *ni, struct kib_tx *tx, struct kib_rdma_desc > nob += rd->rd_frags[i].rf_nob; > } > > - mr = kiblnd_find_rd_dma_mr(ni, rd, tx->tx_conn ? > - tx->tx_conn->ibc_max_frags : -1); > - if (mr) { > - /* found pre-mapping MR */ > - rd->rd_key = (rd != tx->tx_rd) ? mr->rkey : mr->lkey; > - return 0; > - } > - > if (net->ibn_fmr_ps) > return kiblnd_fmr_map_tx(net, tx, rd, nob); > > @@ -1028,16 +1017,14 @@ static int kiblnd_map_tx(lnet_ni_t *ni, struct kib_tx *tx, struct kib_rdma_desc > struct ib_sge *sge = &tx->tx_sge[tx->tx_nwrq]; > struct ib_rdma_wr *wrq = &tx->tx_wrq[tx->tx_nwrq]; > int nob = offsetof(struct kib_msg, ibm_u) + body_nob; > - struct ib_mr *mr = hdev->ibh_mrs; > > LASSERT(tx->tx_nwrq >= 0); > LASSERT(tx->tx_nwrq < IBLND_MAX_RDMA_FRAGS + 1); > LASSERT(nob <= IBLND_MSG_SIZE); > - LASSERT(mr); > > kiblnd_init_msg(tx->tx_msg, type, body_nob); > > - sge->lkey = mr->lkey; > + sge->lkey = hdev->ibh_pd->local_dma_lkey; > sge->addr = tx->tx_msgaddr; > sge->length = nob; > > diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c > index 44e960f..3c81b527 100644 > --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c > +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c > @@ -106,7 +106,8 @@ > module_param(concurrent_sends, int, 0444); > MODULE_PARM_DESC(concurrent_sends, "send work-queue sizing"); > > -static int map_on_demand; > +#define IBLND_DEFAULT_MAP_ON_DEMAND IBLND_MAX_RDMA_FRAGS > +static int map_on_demand = IBLND_DEFAULT_MAP_ON_DEMAND; > module_param(map_on_demand, int, 0444); > MODULE_PARM_DESC(map_on_demand, "map on demand"); > > @@ -228,10 +229,13 @@ int kiblnd_tunables_setup(struct lnet_ni *ni) > if (tunables->lnd_peercredits_hiw >= ni->ni_peertxcredits) > tunables->lnd_peercredits_hiw = ni->ni_peertxcredits - 1; > > - if (tunables->lnd_map_on_demand < 0 || > + if (tunables->lnd_map_on_demand <= 0 || > tunables->lnd_map_on_demand > IBLND_MAX_RDMA_FRAGS) { > - /* disable map-on-demand */ > - tunables->lnd_map_on_demand = 0; > + /* Use the default */ > + CWARN("Invalid map_on_demand (%d), expects 1 - %d. Using default of %d\n", > + tunables->lnd_map_on_demand, > + IBLND_MAX_RDMA_FRAGS, IBLND_DEFAULT_MAP_ON_DEMAND); > + tunables->lnd_map_on_demand = IBLND_DEFAULT_MAP_ON_DEMAND; > } > > if (tunables->lnd_map_on_demand == 1) { > -- > 1.8.3.1 > > From quentin.bouget at cea.fr Tue Feb 21 08:27:48 2017 From: quentin.bouget at cea.fr (quentin.bouget at cea.fr) Date: Tue, 21 Feb 2017 09:27:48 +0100 Subject: [lustre-devel] [Maloo] using gdb in sanity-hsm Message-ID: <59ab1ca2-dbae-cd99-950b-82a5dd26d08b@cea.fr> Hi everyone, I am trying to speed up tests in sanity-hsm. On some occasions I would like to use gdb, but it does not seem to work on the test servers. It appears gdb is a privileged command: timeout: failed to run command 'gdb': Permission denied Is this by design? Is there a chance this can change or should I find another way to run the tests? Here is a link to the patch: https://review.whamcloud.com/#/c/24394/ and here is a link to Maloo's report: https://testing.hpdd.intel.com/test_sets/b252d2ca-f787-11e6-b118-5254006e85c2 Regards, Quentin Bouget From joe at perches.com Tue Feb 21 20:40:10 2017 From: joe at perches.com (Joe Perches) Date: Tue, 21 Feb 2017 12:40:10 -0800 Subject: [lustre-devel] [PATCH 5/6] staging: lustre: Using macro DIV_ROUND_UP In-Reply-To: <20170221174631.GA22466@singhal-Inspiron-5558> References: <20170221174631.GA22466@singhal-Inspiron-5558> Message-ID: <1487709610.2853.39.camel@perches.com> On Tue, 2017-02-21 at 23:16 +0530, simran singhal wrote: > The macro DIV_ROUND_UP performs the computation (((n) + (d) - 1) /(d)). > It clarifies the divisor calculations. This occurence was detected using > the coccinelle script: > > @@ > expression e1; > expression e2; > @@ > ( > - ((e1) + e2 - 1) / (e2) > + DIV_ROUND_UP(e1,e2) > > > > - ((e1) + (e2 - 1)) / (e2) > + DIV_ROUND_UP(e1,e2) > ) Coccinelle scripts are great but please inspect the results for appropriate style and simplify the patch where possible. > diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c [] > @@ -3136,8 +3136,7 @@ void ptlrpc_set_bulk_mbits(struct ptlrpc_request *req) > * that server can infer the number of bulks that were prepared, > * see LU-1431 > */ > - req->rq_mbits += ((bd->bd_iov_count + LNET_MAX_IOV - 1) / > - LNET_MAX_IOV) - 1; > + req->rq_mbits += (DIV_ROUND_UP(bd->bd_iov_count, LNET_MAX_IOV)) - 1; Unnecessary parentheses. > diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c [] > @@ -272,7 +272,7 @@ static unsigned long enc_pools_shrink_scan(struct shrinker *s, > static inline > int npages_to_npools(unsigned long npages) > { > - return (int)((npages + PAGES_PER_POOL - 1) / PAGES_PER_POOL); > + return (int)(DIV_ROUND_UP(npages, PAGES_PER_POOL)); > } Here too. From gregkh at linuxfoundation.org Fri Feb 24 16:58:29 2017 From: gregkh at linuxfoundation.org (Greg Kroah-Hartman) Date: Fri, 24 Feb 2017 17:58:29 +0100 Subject: [lustre-devel] [PATCH 12/14] staging: lustre: llog: change lgh_hdr_lock to mutex In-Reply-To: <1487454435-4895-13-git-send-email-jsimmons@infradead.org> References: <1487454435-4895-1-git-send-email-jsimmons@infradead.org> <1487454435-4895-13-git-send-email-jsimmons@infradead.org> Message-ID: <20170224165829.GA9990@kroah.com> On Sat, Feb 18, 2017 at 04:47:13PM -0500, James Simmons wrote: > From: wang di > > Change lgh_hdr_lock from spinlock to mutex because if > the llog object is a remote object it can be stalled > while being fetched. but this lock is never even used! Why have it at all? > > Signed-off-by: wang di > Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6602 > Reviewed-on: http://review.whamcloud.com/15274 > Reviewed-by: James Simmons > Reviewed-by: Lai Siyao > Reviewed-by: Oleg Drokin > Signed-off-by: James Simmons > --- > drivers/staging/lustre/lustre/include/lustre_log.h | 2 +- > drivers/staging/lustre/lustre/obdclass/llog.c | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/include/lustre_log.h b/drivers/staging/lustre/lustre/include/lustre_log.h > index 35e37eb..33f56ff 100644 > --- a/drivers/staging/lustre/lustre/include/lustre_log.h > +++ b/drivers/staging/lustre/lustre/include/lustre_log.h > @@ -211,7 +211,7 @@ struct llog_operations { > /* In-memory descriptor for a log object or log catalog */ > struct llog_handle { > struct rw_semaphore lgh_lock; > - spinlock_t lgh_hdr_lock; /* protect lgh_hdr data */ > + struct mutex lgh_hdr_mutex; /* protect lgh_hdr data */ > struct llog_logid lgh_id; /* id of this log */ > struct llog_log_hdr *lgh_hdr; > size_t lgh_hdr_size; > diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c > index 736ea10..83c5b62 100644 > --- a/drivers/staging/lustre/lustre/obdclass/llog.c > +++ b/drivers/staging/lustre/lustre/obdclass/llog.c > @@ -61,7 +61,7 @@ static struct llog_handle *llog_alloc_handle(void) > return NULL; > > init_rwsem(&loghandle->lgh_lock); > - spin_lock_init(&loghandle->lgh_hdr_lock); > + mutex_init(&loghandle->lgh_hdr_mutex); Can't we delete it? thanks, greg k-h From gregkh at linuxfoundation.org Fri Feb 24 16:59:10 2017 From: gregkh at linuxfoundation.org (Greg Kroah-Hartman) Date: Fri, 24 Feb 2017 17:59:10 +0100 Subject: [lustre-devel] [PATCH 13/14] staging: lustre: llog: limit file size of plain logs In-Reply-To: <1487454435-4895-14-git-send-email-jsimmons@infradead.org> References: <1487454435-4895-1-git-send-email-jsimmons@infradead.org> <1487454435-4895-14-git-send-email-jsimmons@infradead.org> Message-ID: <20170224165910.GB9990@kroah.com> On Sat, Feb 18, 2017 at 04:47:14PM -0500, James Simmons wrote: > From: Alex Zhuravlev > > on small filesystems plain log can grow dramatically. especially > given large record sizes produced by DNE and extended chunksize. > I saw >50% of space consumed by a single llog file which was still > in use. this leads to test failures (sanityn, etc). > the patch introduces additional limit on plain llog size, which > is calculated as /64 (128MB at most) at llog creation > time. > > Signed-off-by: Alex Zhuravlev > Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6838 > Reviewed-on: https://review.whamcloud.com/18028 > Reviewed-by: Andreas Dilger > Reviewed-by: wangdi > Reviewed-by: Mike Pershin > Reviewed-by: Oleg Drokin > Signed-off-by: James Simmons > --- > drivers/staging/lustre/lustre/obdclass/llog.c | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) > > diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c > index 83c5b62..320ff6b 100644 > --- a/drivers/staging/lustre/lustre/obdclass/llog.c > +++ b/drivers/staging/lustre/lustre/obdclass/llog.c > @@ -319,10 +319,26 @@ static int llog_process_thread(void *arg) > * the case and re-read the current chunk > * otherwise. > */ > + int records; > + > if (index > loghandle->lgh_last_idx) { > rc = 0; > goto out; > } > + /* <2 records means no more records > + * if the last record we processed was > + * the final one, then the underlying > + * object might have been destroyed yet. > + * we better don't access that.. > + */ > + mutex_lock(&loghandle->lgh_hdr_mutex); > + records = loghandle->lgh_hdr->llh_count; > + mutex_unlock(&loghandle->lgh_hdr_mutex); > + if (records <= 1) { > + rc = 0; > + goto out; > + } So you now use the lock, in only one place, when reading a single value? That makes no sense, it's obviously wrong, or not needed. Please fix up these two patches... thanks, greg k-h From oleg.drokin at intel.com Sat Feb 25 03:50:33 2017 From: oleg.drokin at intel.com (Oleg Drokin) Date: Fri, 24 Feb 2017 22:50:33 -0500 Subject: [lustre-devel] [PATCH 13/14] staging: lustre: llog: limit file size of plain logs In-Reply-To: <20170224165910.GB9990@kroah.com> References: <1487454435-4895-1-git-send-email-jsimmons@infradead.org> <1487454435-4895-14-git-send-email-jsimmons@infradead.org> <20170224165910.GB9990@kroah.com> Message-ID: <5978AF1E-CEE3-4016-A916-4DBF0B5A3BC4@intel.com> On Feb 24, 2017, at 11:59 AM, Greg Kroah-Hartman wrote: > On Sat, Feb 18, 2017 at 04:47:14PM -0500, James Simmons wrote: >> From: Alex Zhuravlev >> >> on small filesystems plain log can grow dramatically. especially >> given large record sizes produced by DNE and extended chunksize. >> I saw >50% of space consumed by a single llog file which was still >> in use. this leads to test failures (sanityn, etc). >> the patch introduces additional limit on plain llog size, which >> is calculated as /64 (128MB at most) at llog creation >> time. >> >> Signed-off-by: Alex Zhuravlev >> Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6838 >> Reviewed-on: https://review.whamcloud.com/18028 >> Reviewed-by: Andreas Dilger >> Reviewed-by: wangdi >> Reviewed-by: Mike Pershin >> Reviewed-by: Oleg Drokin >> Signed-off-by: James Simmons >> --- >> drivers/staging/lustre/lustre/obdclass/llog.c | 16 ++++++++++++++++ >> 1 file changed, 16 insertions(+) >> >> diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c >> index 83c5b62..320ff6b 100644 >> --- a/drivers/staging/lustre/lustre/obdclass/llog.c >> +++ b/drivers/staging/lustre/lustre/obdclass/llog.c >> @@ -319,10 +319,26 @@ static int llog_process_thread(void *arg) >> * the case and re-read the current chunk >> * otherwise. >> */ >> + int records; >> + >> if (index > loghandle->lgh_last_idx) { >> rc = 0; >> goto out; >> } >> + /* <2 records means no more records >> + * if the last record we processed was >> + * the final one, then the underlying >> + * object might have been destroyed yet. >> + * we better don't access that.. >> + */ >> + mutex_lock(&loghandle->lgh_hdr_mutex); >> + records = loghandle->lgh_hdr->llh_count; >> + mutex_unlock(&loghandle->lgh_hdr_mutex); >> + if (records <= 1) { >> + rc = 0; >> + goto out; >> + } > > > So you now use the lock, in only one place, when reading a single value? > That makes no sense, it's obviously wrong, or not needed. > > Please fix up these two patches… Ah, this is in fact server-side fix, so all the other users were in the parts not really present in the client. James, we don't really need this patch in the client, I guess. From oleg.drokin at intel.com Sat Feb 25 04:04:40 2017 From: oleg.drokin at intel.com (Oleg Drokin) Date: Fri, 24 Feb 2017 23:04:40 -0500 Subject: [lustre-devel] [PATCH 13/14] staging: lustre: llog: limit file size of plain logs In-Reply-To: <20170224165910.GB9990@kroah.com> References: <1487454435-4895-1-git-send-email-jsimmons@infradead.org> <1487454435-4895-14-git-send-email-jsimmons@infradead.org> <20170224165910.GB9990@kroah.com> Message-ID: <47EC722D-B672-4AD2-BC16-8343E7CA49F1@intel.com> On Feb 24, 2017, at 11:59 AM, Greg Kroah-Hartman wrote: > On Sat, Feb 18, 2017 at 04:47:14PM -0500, James Simmons wrote: >> From: Alex Zhuravlev >> >> on small filesystems plain log can grow dramatically. especially >> given large record sizes produced by DNE and extended chunksize. >> I saw >50% of space consumed by a single llog file which was still >> in use. this leads to test failures (sanityn, etc). >> the patch introduces additional limit on plain llog size, which >> is calculated as /64 (128MB at most) at llog creation >> time. >> >> Signed-off-by: Alex Zhuravlev >> Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6838 >> Reviewed-on: https://review.whamcloud.com/18028 >> Reviewed-by: Andreas Dilger >> Reviewed-by: wangdi >> Reviewed-by: Mike Pershin >> Reviewed-by: Oleg Drokin >> Signed-off-by: James Simmons >> --- >> drivers/staging/lustre/lustre/obdclass/llog.c | 16 ++++++++++++++++ >> 1 file changed, 16 insertions(+) >> >> diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c >> index 83c5b62..320ff6b 100644 >> --- a/drivers/staging/lustre/lustre/obdclass/llog.c >> +++ b/drivers/staging/lustre/lustre/obdclass/llog.c >> @@ -319,10 +319,26 @@ static int llog_process_thread(void *arg) >> * the case and re-read the current chunk >> * otherwise. >> */ >> + int records; >> + >> if (index > loghandle->lgh_last_idx) { >> rc = 0; >> goto out; >> } >> + /* <2 records means no more records >> + * if the last record we processed was >> + * the final one, then the underlying >> + * object might have been destroyed yet. >> + * we better don't access that.. >> + */ >> + mutex_lock(&loghandle->lgh_hdr_mutex); >> + records = loghandle->lgh_hdr->llh_count; >> + mutex_unlock(&loghandle->lgh_hdr_mutex); >> + if (records <= 1) { >> + rc = 0; >> + goto out; >> + } > > > So you now use the lock, in only one place, when reading a single value? > That makes no sense, it's obviously wrong, or not needed. > > Please fix up these two patches… Ah, this is in fact server-side fix, so all the other users were in the parts not really present in the client. James, we don't really need this patch in the client, I guess. From jsimmons at infradead.org Mon Feb 27 00:41:26 2017 From: jsimmons at infradead.org (James Simmons) Date: Sun, 26 Feb 2017 19:41:26 -0500 Subject: [lustre-devel] [PATCH 01/34] staging: lustre: socklnd: change UAPI typedefs to proper structure In-Reply-To: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> References: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> Message-ID: <1488156119-19670-2-git-send-email-jsimmons@infradead.org> The upstream kernel requires proper structures so convert all the UAPI typedefs in socklnd.h. Signed-off-by: James Simmons Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6142 Reviewed-on: https://review.whamcloud.com/18506 Reviewed-by: Dmitry Eremin Reviewed-by: Doug Oucharek Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- .../staging/lustre/include/linux/lnet/socklnd.h | 14 ++++---- .../staging/lustre/lnet/klnds/socklnd/socklnd.c | 8 ++--- .../staging/lustre/lnet/klnds/socklnd/socklnd.h | 14 ++++---- .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 22 ++++++------- .../lustre/lnet/klnds/socklnd/socklnd_proto.c | 38 +++++++++++----------- 5 files changed, 48 insertions(+), 48 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/socklnd.h b/drivers/staging/lustre/include/linux/lnet/socklnd.h index acf20ce..dd5bc0e 100644 --- a/drivers/staging/lustre/include/linux/lnet/socklnd.h +++ b/drivers/staging/lustre/include/linux/lnet/socklnd.h @@ -45,7 +45,7 @@ #define SOCKLND_CONN_ACK SOCKLND_CONN_BULK_IN -typedef struct { +struct ksock_hello_msg { __u32 kshm_magic; /* magic number of socklnd message */ __u32 kshm_version; /* version of socklnd message */ lnet_nid_t kshm_src_nid; /* sender's nid */ @@ -57,9 +57,9 @@ __u32 kshm_ctype; /* connection type */ __u32 kshm_nips; /* # IP addrs */ __u32 kshm_ips[0]; /* IP addrs */ -} WIRE_ATTR ksock_hello_msg_t; +} WIRE_ATTR; -typedef struct { +struct ksock_lnet_msg { struct lnet_hdr ksnm_hdr; /* lnet hdr */ /* @@ -68,17 +68,17 @@ * structure definitions. lnet payload will be stored just after * the body of structure ksock_lnet_msg_t */ -} WIRE_ATTR ksock_lnet_msg_t; +} WIRE_ATTR; -typedef struct { +struct ksock_msg { __u32 ksm_type; /* type of socklnd message */ __u32 ksm_csum; /* checksum if != 0 */ __u64 ksm_zc_cookies[2]; /* Zero-Copy request/ACK cookie */ union { - ksock_lnet_msg_t lnetmsg;/* lnet message, it's empty if + struct ksock_lnet_msg lnetmsg; /* lnet message, it's empty if * it's NOOP */ } WIRE_ATTR ksm_u; -} WIRE_ATTR ksock_msg_t; +} WIRE_ATTR; #define KSOCK_MSG_NOOP 0xC0 /* ksm_u empty */ #define KSOCK_MSG_LNET 0xC1 /* lnet msg */ diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c index f25de3d..3b08aff 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c @@ -1038,7 +1038,7 @@ struct ksock_peer * struct ksock_peer *peer = NULL; struct ksock_peer *peer2; struct ksock_sched *sched; - ksock_hello_msg_t *hello; + struct ksock_hello_msg *hello; int cpt; struct ksock_tx *tx; struct ksock_tx *txtmp; @@ -1077,7 +1077,7 @@ struct ksock_peer * conn->ksnc_tx_carrier = NULL; atomic_set(&conn->ksnc_tx_nob, 0); - LIBCFS_ALLOC(hello, offsetof(ksock_hello_msg_t, + LIBCFS_ALLOC(hello, offsetof(struct ksock_hello_msg, kshm_ips[LNET_MAX_INTERFACES])); if (!hello) { rc = -ENOMEM; @@ -1341,7 +1341,7 @@ struct ksock_peer * rc = ksocknal_send_hello(ni, conn, peerid.nid, hello); } - LIBCFS_FREE(hello, offsetof(ksock_hello_msg_t, + LIBCFS_FREE(hello, offsetof(struct ksock_hello_msg, kshm_ips[LNET_MAX_INTERFACES])); /* @@ -1423,7 +1423,7 @@ struct ksock_peer * failed_1: if (hello) - LIBCFS_FREE(hello, offsetof(ksock_hello_msg_t, + LIBCFS_FREE(hello, offsetof(struct ksock_hello_msg, kshm_ips[LNET_MAX_INTERFACES])); LIBCFS_FREE(conn, sizeof(*conn)); diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h index 9e86563..3631998 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h @@ -287,7 +287,7 @@ struct ksock_tx { /* transmit packet */ lnet_msg_t *tx_lnetmsg; /* lnet message for lnet_finalize() */ unsigned long tx_deadline; /* when (in jiffies) tx times out */ - ksock_msg_t tx_msg; /* socklnd message buffer */ + struct ksock_msg tx_msg; /* socklnd message buffer */ int tx_desc_size; /* size of this descriptor */ union { struct { @@ -369,7 +369,7 @@ struct ksock_conn { */ void *ksnc_cookie; /* rx lnet_finalize passthru arg */ - ksock_msg_t ksnc_msg; /* incoming message buffer: + struct ksock_msg ksnc_msg; /* incoming message buffer: * V2.x message takes the * whole struct * V1.x message is a bare @@ -474,16 +474,16 @@ struct ksock_proto { int pro_version; /* handshake function */ - int (*pro_send_hello)(struct ksock_conn *, ksock_hello_msg_t *); + int (*pro_send_hello)(struct ksock_conn *, struct ksock_hello_msg *); /* handshake function */ - int (*pro_recv_hello)(struct ksock_conn *, ksock_hello_msg_t *, int); + int (*pro_recv_hello)(struct ksock_conn *, struct ksock_hello_msg *, int); /* message pack */ void (*pro_pack)(struct ksock_tx *); /* message unpack */ - void (*pro_unpack)(ksock_msg_t *); + void (*pro_unpack)(struct ksock_msg *); /* queue tx on the connection */ struct ksock_tx *(*pro_queue_tx_msg)(struct ksock_conn *, struct ksock_tx *); @@ -691,9 +691,9 @@ int ksocknal_launch_packet(lnet_ni_t *ni, struct ksock_tx *tx, int ksocknal_connd(void *arg); int ksocknal_reaper(void *arg); int ksocknal_send_hello(lnet_ni_t *ni, struct ksock_conn *conn, - lnet_nid_t peer_nid, ksock_hello_msg_t *hello); + lnet_nid_t peer_nid, struct ksock_hello_msg *hello); int ksocknal_recv_hello(lnet_ni_t *ni, struct ksock_conn *conn, - ksock_hello_msg_t *hello, lnet_process_id_t *id, + struct ksock_hello_msg *hello, lnet_process_id_t *id, __u64 *incarnation); void ksocknal_read_callback(struct ksock_conn *conn); void ksocknal_write_callback(struct ksock_conn *conn); diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c index 4c9f927..9fbae62 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c @@ -695,7 +695,7 @@ struct ksock_conn * ksocknal_queue_tx_locked(struct ksock_tx *tx, struct ksock_conn *conn) { struct ksock_sched *sched = conn->ksnc_scheduler; - ksock_msg_t *msg = &tx->tx_msg; + struct ksock_msg *msg = &tx->tx_msg; struct ksock_tx *ztx = NULL; int bufnob = 0; @@ -1072,9 +1072,9 @@ struct ksock_route * conn->ksnc_rx_iov = (struct kvec *)&conn->ksnc_rx_iov_space; conn->ksnc_rx_iov[0].iov_base = &conn->ksnc_msg; - conn->ksnc_rx_nob_wanted = offsetof(ksock_msg_t, ksm_u); - conn->ksnc_rx_nob_left = offsetof(ksock_msg_t, ksm_u); - conn->ksnc_rx_iov[0].iov_len = offsetof(ksock_msg_t, ksm_u); + conn->ksnc_rx_nob_wanted = offsetof(struct ksock_msg, ksm_u); + conn->ksnc_rx_nob_left = offsetof(struct ksock_msg, ksm_u); + conn->ksnc_rx_iov[0].iov_len = offsetof(struct ksock_msg, ksm_u); break; case KSOCK_PROTO_V1: @@ -1232,12 +1232,12 @@ struct ksock_route * } conn->ksnc_rx_state = SOCKNAL_RX_LNET_HEADER; - conn->ksnc_rx_nob_wanted = sizeof(ksock_lnet_msg_t); - conn->ksnc_rx_nob_left = sizeof(ksock_lnet_msg_t); + conn->ksnc_rx_nob_wanted = sizeof(struct ksock_lnet_msg); + conn->ksnc_rx_nob_left = sizeof(struct ksock_lnet_msg); conn->ksnc_rx_iov = (struct kvec *)&conn->ksnc_rx_iov_space; conn->ksnc_rx_iov[0].iov_base = &conn->ksnc_msg.ksm_u.lnetmsg; - conn->ksnc_rx_iov[0].iov_len = sizeof(ksock_lnet_msg_t); + conn->ksnc_rx_iov[0].iov_len = sizeof(struct ksock_lnet_msg); conn->ksnc_rx_niov = 1; conn->ksnc_rx_kiov = NULL; @@ -1633,7 +1633,7 @@ void ksocknal_write_callback(struct ksock_conn *conn) } static struct ksock_proto * -ksocknal_parse_proto_version(ksock_hello_msg_t *hello) +ksocknal_parse_proto_version(struct ksock_hello_msg *hello) { __u32 version = 0; @@ -1664,7 +1664,7 @@ void ksocknal_write_callback(struct ksock_conn *conn) struct lnet_magicversion *hmv = (struct lnet_magicversion *)hello; BUILD_BUG_ON(sizeof(struct lnet_magicversion) != - offsetof(ksock_hello_msg_t, kshm_src_nid)); + offsetof(struct ksock_hello_msg, kshm_src_nid)); if (hmv->version_major == cpu_to_le16(KSOCK_PROTO_V1_MAJOR) && hmv->version_minor == cpu_to_le16(KSOCK_PROTO_V1_MINOR)) @@ -1676,7 +1676,7 @@ void ksocknal_write_callback(struct ksock_conn *conn) int ksocknal_send_hello(lnet_ni_t *ni, struct ksock_conn *conn, - lnet_nid_t peer_nid, ksock_hello_msg_t *hello) + lnet_nid_t peer_nid, struct ksock_hello_msg *hello) { /* CAVEAT EMPTOR: this byte flips 'ipaddrs' */ struct ksock_net *net = (struct ksock_net *)ni->ni_data; @@ -1714,7 +1714,7 @@ void ksocknal_write_callback(struct ksock_conn *conn) int ksocknal_recv_hello(lnet_ni_t *ni, struct ksock_conn *conn, - ksock_hello_msg_t *hello, lnet_process_id_t *peerid, + struct ksock_hello_msg *hello, lnet_process_id_t *peerid, __u64 *incarnation) { /* Return < 0 fatal error diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c index d367e74..84be9a5 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c @@ -287,11 +287,11 @@ if (!tx || !tx->tx_lnetmsg) { /* noop packet */ - nob = offsetof(ksock_msg_t, ksm_u); + nob = offsetof(struct ksock_msg, ksm_u); } else { nob = tx->tx_lnetmsg->msg_len + ((conn->ksnc_proto == &ksocknal_protocol_v1x) ? - sizeof(struct lnet_hdr) : sizeof(ksock_msg_t)); + sizeof(struct lnet_hdr) : sizeof(struct ksock_msg)); } /* default checking for typed connection */ @@ -325,9 +325,9 @@ int nob; if (!tx || !tx->tx_lnetmsg) - nob = offsetof(ksock_msg_t, ksm_u); + nob = offsetof(struct ksock_msg, ksm_u); else - nob = tx->tx_lnetmsg->msg_len + sizeof(ksock_msg_t); + nob = tx->tx_lnetmsg->msg_len + sizeof(struct ksock_msg); switch (conn->ksnc_type) { default: @@ -456,7 +456,7 @@ } static int -ksocknal_send_hello_v1(struct ksock_conn *conn, ksock_hello_msg_t *hello) +ksocknal_send_hello_v1(struct ksock_conn *conn, struct ksock_hello_msg *hello) { struct socket *sock = conn->ksnc_sock; struct lnet_hdr *hdr; @@ -531,7 +531,7 @@ } static int -ksocknal_send_hello_v2(struct ksock_conn *conn, ksock_hello_msg_t *hello) +ksocknal_send_hello_v2(struct ksock_conn *conn, struct ksock_hello_msg *hello) { struct socket *sock = conn->ksnc_sock; int rc; @@ -549,7 +549,7 @@ LNET_UNLOCK(); } - rc = lnet_sock_write(sock, hello, offsetof(ksock_hello_msg_t, kshm_ips), + rc = lnet_sock_write(sock, hello, offsetof(struct ksock_hello_msg, kshm_ips), lnet_acceptor_timeout()); if (rc) { CNETERR("Error %d sending HELLO hdr to %pI4h/%d\n", @@ -573,7 +573,7 @@ } static int -ksocknal_recv_hello_v1(struct ksock_conn *conn, ksock_hello_msg_t *hello, +ksocknal_recv_hello_v1(struct ksock_conn *conn, struct ksock_hello_msg *hello, int timeout) { struct socket *sock = conn->ksnc_sock; @@ -649,7 +649,7 @@ } static int -ksocknal_recv_hello_v2(struct ksock_conn *conn, ksock_hello_msg_t *hello, +ksocknal_recv_hello_v2(struct ksock_conn *conn, struct ksock_hello_msg *hello, int timeout) { struct socket *sock = conn->ksnc_sock; @@ -662,8 +662,8 @@ conn->ksnc_flip = 1; rc = lnet_sock_read(sock, &hello->kshm_src_nid, - offsetof(ksock_hello_msg_t, kshm_ips) - - offsetof(ksock_hello_msg_t, kshm_src_nid), + offsetof(struct ksock_hello_msg, kshm_ips) - + offsetof(struct ksock_hello_msg, kshm_src_nid), timeout); if (rc) { CERROR("Error %d reading HELLO from %pI4h\n", @@ -738,15 +738,15 @@ LASSERT(tx->tx_msg.ksm_type != KSOCK_MSG_NOOP); tx->tx_msg.ksm_u.lnetmsg.ksnm_hdr = tx->tx_lnetmsg->msg_hdr; - tx->tx_iov[0].iov_len = sizeof(ksock_msg_t); - tx->tx_nob = sizeof(ksock_msg_t) + tx->tx_lnetmsg->msg_len; - tx->tx_resid = sizeof(ksock_msg_t) + tx->tx_lnetmsg->msg_len; + tx->tx_iov[0].iov_len = sizeof(struct ksock_msg); + tx->tx_nob = sizeof(struct ksock_msg) + tx->tx_lnetmsg->msg_len; + tx->tx_resid = sizeof(struct ksock_msg) + tx->tx_lnetmsg->msg_len; } else { LASSERT(tx->tx_msg.ksm_type == KSOCK_MSG_NOOP); - tx->tx_iov[0].iov_len = offsetof(ksock_msg_t, ksm_u.lnetmsg.ksnm_hdr); - tx->tx_nob = offsetof(ksock_msg_t, ksm_u.lnetmsg.ksnm_hdr); - tx->tx_resid = offsetof(ksock_msg_t, ksm_u.lnetmsg.ksnm_hdr); + tx->tx_iov[0].iov_len = offsetof(struct ksock_msg, ksm_u.lnetmsg.ksnm_hdr); + tx->tx_nob = offsetof(struct ksock_msg, ksm_u.lnetmsg.ksnm_hdr); + tx->tx_resid = offsetof(struct ksock_msg, ksm_u.lnetmsg.ksnm_hdr); } /* * Don't checksum before start sending, because packet can be @@ -755,7 +755,7 @@ } static void -ksocknal_unpack_msg_v1(ksock_msg_t *msg) +ksocknal_unpack_msg_v1(struct ksock_msg *msg) { msg->ksm_csum = 0; msg->ksm_type = KSOCK_MSG_LNET; @@ -764,7 +764,7 @@ } static void -ksocknal_unpack_msg_v2(ksock_msg_t *msg) +ksocknal_unpack_msg_v2(struct ksock_msg *msg) { return; /* Do nothing */ } -- 1.8.3.1 From jsimmons at infradead.org Mon Feb 27 00:41:25 2017 From: jsimmons at infradead.org (James Simmons) Date: Sun, 26 Feb 2017 19:41:25 -0500 Subject: [lustre-devel] [PATCH 00/34] staging: lustre: lnet: remove most of typedefs from LNet headers Message-ID: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> Remove the majority of typedefs from the LNet headers. Change them into structures or enums instead. Currently only lnet_nid_t are lnet_pid_t are left. Removed the rest of the typedefs in socklnd.h as well James Simmons (34): staging: lustre: socklnd: change UAPI typedefs to proper structure staging: lustre: lnet: change lnet_handle_eq_t to proper struct staging: lustre: lnet: change lnet_handle_md_t to proper struct staging: lustre: lnet: change lnet_handle_me_t to proper struct staging: lustre: lnet: remove generic lnet_handle_any_t staging: lustre: lnet: change lnet_msg_t to proper structure staging: lustre: lnet: change lnet_libhandle_t to proper structure staging: lustre: lnet: change lnet_eq_t to proper structure staging: lustre: lnet: change lnet_me_t to proper structure staging: lustre: lnet: change lnet_libmd_t to proper structure staging: lustre: lnet: change lnet_test_peer_t to proper structure staging: lustre: lnet: change lnd_t to proper structure staging: lustre: lnet: change lnet_ni_t to proper structure staging: lustre: lnet: change lnet_rc_data_t to proper structure staging: lustre: lnet: change lnet_peer_t to proper structure staging: lustre: lnet: change lnet_route_t to proper structure staging: lustre: lnet: change lnet_remotenet_t to proper structure staging: lustre: lnet: change lnet_rtrbufpool_t to proper structure staging: lustre: lnet: change lnet_rtrbuf_t to proper structure staging: lustre: lnet: change lnet_portal_t to proper structure staging: lustre: lnet: change lnet_t to proper structure staging: lustre: lnet: give LNET_MATCH* enum a name staging: lustre: lnet: change lnet_counter_t to proper structure staging: lustre: lnet: change lnet_md_t to proper structure staging: lustre: lnet: change lnet_event_t to proper structure staging: lustre: lnet: change lnet_process_id_t to proper structure staging: lustre: lnet: change lnet_msg_type_t to proper enum staging: lustre: lnet: change lnet_unlink_t to proper enum staging: lustre: lnet: change lnet_ins_pos_t to proper enum staging: lustre: lnet: change lnet_event_kind_t to proper enum staging: lustre: lnet: change lnet_ack_req_t to proper enum staging: lustre: lnet: remove LNET_SEQ_BASETYPE staging: lustre: lnet: remove unused lnet_md_iovec_t staging: lustre: lnet: use struct bio_vec instead of typedef drivers/staging/lustre/include/linux/lnet/api.h | 65 +++--- .../staging/lustre/include/linux/lnet/lib-lnet.h | 232 +++++++++++---------- .../staging/lustre/include/linux/lnet/lib-types.h | 137 ++++++------ drivers/staging/lustre/include/linux/lnet/lnetst.h | 12 +- drivers/staging/lustre/include/linux/lnet/nidstr.h | 2 +- .../staging/lustre/include/linux/lnet/socklnd.h | 14 +- drivers/staging/lustre/include/linux/lnet/types.h | 155 +++++++------- .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 30 +-- .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h | 21 +- .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 65 +++--- .../lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c | 2 +- .../staging/lustre/lnet/klnds/socklnd/socklnd.c | 69 +++--- .../staging/lustre/lnet/klnds/socklnd/socklnd.h | 76 +++---- .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 54 ++--- .../lustre/lnet/klnds/socklnd/socklnd_lib.c | 4 +- .../lustre/lnet/klnds/socklnd/socklnd_proto.c | 38 ++-- drivers/staging/lustre/lnet/lnet/acceptor.c | 2 +- drivers/staging/lustre/lnet/lnet/api-ni.c | 151 +++++++------- drivers/staging/lustre/lnet/lnet/config.c | 8 +- drivers/staging/lustre/lnet/lnet/lib-eq.c | 26 +-- drivers/staging/lustre/lnet/lnet/lib-md.c | 29 +-- drivers/staging/lustre/lnet/lnet/lib-me.c | 28 +-- drivers/staging/lustre/lnet/lnet/lib-move.c | 195 ++++++++--------- drivers/staging/lustre/lnet/lnet/lib-msg.c | 41 ++-- drivers/staging/lustre/lnet/lnet/lib-ptl.c | 30 +-- drivers/staging/lustre/lnet/lnet/lo.c | 12 +- drivers/staging/lustre/lnet/lnet/nidstrings.c | 2 +- drivers/staging/lustre/lnet/lnet/peer.c | 38 ++-- drivers/staging/lustre/lnet/lnet/router.c | 164 ++++++++------- drivers/staging/lustre/lnet/lnet/router_proc.c | 34 +-- drivers/staging/lustre/lnet/selftest/brw_test.c | 4 +- drivers/staging/lustre/lnet/selftest/conrpc.c | 6 +- drivers/staging/lustre/lnet/selftest/console.c | 39 ++-- drivers/staging/lustre/lnet/selftest/console.h | 14 +- drivers/staging/lustre/lnet/selftest/framework.c | 4 +- drivers/staging/lustre/lnet/selftest/ping_test.c | 2 +- drivers/staging/lustre/lnet/selftest/rpc.c | 31 +-- drivers/staging/lustre/lnet/selftest/rpc.h | 2 +- drivers/staging/lustre/lnet/selftest/selftest.h | 42 ++-- drivers/staging/lustre/lustre/include/lustre_net.h | 32 +-- drivers/staging/lustre/lustre/llite/llite_lib.c | 2 +- drivers/staging/lustre/lustre/llite/super25.c | 2 +- drivers/staging/lustre/lustre/osc/osc_request.c | 5 +- drivers/staging/lustre/lustre/ptlrpc/client.c | 4 +- drivers/staging/lustre/lustre/ptlrpc/connection.c | 6 +- drivers/staging/lustre/lustre/ptlrpc/events.c | 18 +- drivers/staging/lustre/lustre/ptlrpc/niobuf.c | 24 +-- drivers/staging/lustre/lustre/ptlrpc/pers.c | 2 +- .../staging/lustre/lustre/ptlrpc/ptlrpc_internal.h | 2 +- 49 files changed, 1004 insertions(+), 973 deletions(-) -- 1.8.3.1 From jsimmons at infradead.org Mon Feb 27 00:41:43 2017 From: jsimmons at infradead.org (James Simmons) Date: Sun, 26 Feb 2017 19:41:43 -0500 Subject: [lustre-devel] [PATCH 18/34] staging: lustre: lnet: change lnet_rtrbufpool_t to proper structure In-Reply-To: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> References: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> Message-ID: <1488156119-19670-19-git-send-email-jsimmons@infradead.org> Change lnet_rtrbufpool_t from typedef to proper structure. Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/20831 Reviewed-by: Olaf Weber Reviewed-by: Doug Oucharek Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/include/linux/lnet/lib-lnet.h | 2 +- drivers/staging/lustre/include/linux/lnet/lib-types.h | 8 ++++---- drivers/staging/lustre/lnet/lnet/lib-move.c | 10 +++++----- drivers/staging/lustre/lnet/lnet/router.c | 18 +++++++++--------- drivers/staging/lustre/lnet/lnet/router_proc.c | 2 +- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h index 8483a4a..61a911a 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h @@ -496,7 +496,7 @@ void lnet_prep_send(struct lnet_msg *msg, int type, lnet_process_id_t target, int lnet_send(lnet_nid_t nid, struct lnet_msg *msg, lnet_nid_t rtr_nid); void lnet_return_tx_credits_locked(struct lnet_msg *msg); void lnet_return_rx_credits_locked(struct lnet_msg *msg); -void lnet_schedule_blocked_locked(lnet_rtrbufpool_t *rbp); +void lnet_schedule_blocked_locked(struct lnet_rtrbufpool *rbp); void lnet_drop_routed_msgs_locked(struct list_head *list, int cpt); /* portals functions */ diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index 04ad728..b654ab6 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -396,7 +396,7 @@ struct lnet_remotenet { /** lnet message is waiting for credit */ #define LNET_CREDIT_WAIT 1 -typedef struct { +struct lnet_rtrbufpool { struct list_head rbp_bufs; /* my free buffer pool */ struct list_head rbp_msgs; /* messages blocking for a buffer */ @@ -408,11 +408,11 @@ struct lnet_remotenet { int rbp_credits; /* # free buffers / blocked messages */ int rbp_mincredits; /* low water mark */ -} lnet_rtrbufpool_t; +}; typedef struct { struct list_head rb_list; /* chain on rbp_bufs */ - lnet_rtrbufpool_t *rb_pool; /* owning pool */ + struct lnet_rtrbufpool *rb_pool; /* owning pool */ lnet_kiov_t rb_kiov[0]; /* the buffer space */ } lnet_rtrbuf_t; @@ -596,7 +596,7 @@ struct lnet_msg_container { /* validity stamp */ __u64 ln_routers_version; /* percpt router buffer pools */ - lnet_rtrbufpool_t **ln_rtrpools; + struct lnet_rtrbufpool **ln_rtrpools; struct lnet_handle_md ln_ping_target_md; struct lnet_handle_eq ln_ping_target_eq; diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c index 3581100..2d31e1f 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-move.c +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c @@ -680,10 +680,10 @@ return LNET_CREDIT_OK; } -static lnet_rtrbufpool_t * +static struct lnet_rtrbufpool * lnet_msg2bufpool(struct lnet_msg *msg) { - lnet_rtrbufpool_t *rbp; + struct lnet_rtrbufpool *rbp; int cpt; LASSERT(msg->msg_rx_committed); @@ -710,7 +710,7 @@ * received or OK to receive */ struct lnet_peer *lp = msg->msg_rxpeer; - lnet_rtrbufpool_t *rbp; + struct lnet_rtrbufpool *rbp; lnet_rtrbuf_t *rb; LASSERT(!msg->msg_iov); @@ -835,7 +835,7 @@ } void -lnet_schedule_blocked_locked(lnet_rtrbufpool_t *rbp) +lnet_schedule_blocked_locked(struct lnet_rtrbufpool *rbp) { struct lnet_msg *msg; @@ -880,7 +880,7 @@ if (msg->msg_rtrcredit) { /* give back global router credits */ lnet_rtrbuf_t *rb; - lnet_rtrbufpool_t *rbp; + struct lnet_rtrbufpool *rbp; /* * NB If a msg ever blocks for a buffer in rbp_msgs, it stays diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c index 9a5faba..a5f1f85 100644 --- a/drivers/staging/lustre/lnet/lnet/router.c +++ b/drivers/staging/lustre/lnet/lnet/router.c @@ -558,7 +558,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) return rc; for (i = 0; i < LNET_NRBPOOLS; i++) { - lnet_rtrbufpool_t *rbp; + struct lnet_rtrbufpool *rbp; lnet_net_lock(LNET_LOCK_EX); cfs_percpt_for_each(rbp, j, the_lnet.ln_rtrpools) { @@ -1316,7 +1316,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) } static lnet_rtrbuf_t * -lnet_new_rtrbuf(lnet_rtrbufpool_t *rbp, int cpt) +lnet_new_rtrbuf(struct lnet_rtrbufpool *rbp, int cpt) { int npages = rbp->rbp_npages; int sz = offsetof(lnet_rtrbuf_t, rb_kiov[npages]); @@ -1351,7 +1351,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) } static void -lnet_rtrpool_free_bufs(lnet_rtrbufpool_t *rbp, int cpt) +lnet_rtrpool_free_bufs(struct lnet_rtrbufpool *rbp, int cpt) { int npages = rbp->rbp_npages; struct list_head tmp; @@ -1380,7 +1380,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) } static int -lnet_rtrpool_adjust_bufs(lnet_rtrbufpool_t *rbp, int nbufs, int cpt) +lnet_rtrpool_adjust_bufs(struct lnet_rtrbufpool *rbp, int nbufs, int cpt) { struct list_head rb_list; lnet_rtrbuf_t *rb; @@ -1467,7 +1467,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) } static void -lnet_rtrpool_init(lnet_rtrbufpool_t *rbp, int npages) +lnet_rtrpool_init(struct lnet_rtrbufpool *rbp, int npages) { INIT_LIST_HEAD(&rbp->rbp_msgs); INIT_LIST_HEAD(&rbp->rbp_bufs); @@ -1480,7 +1480,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) void lnet_rtrpools_free(int keep_pools) { - lnet_rtrbufpool_t *rtrp; + struct lnet_rtrbufpool *rtrp; int i; if (!the_lnet.ln_rtrpools) /* uninitialized or freed */ @@ -1558,7 +1558,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) int lnet_rtrpools_alloc(int im_a_router) { - lnet_rtrbufpool_t *rtrp; + struct lnet_rtrbufpool *rtrp; int nrb_tiny; int nrb_small; int nrb_large; @@ -1593,7 +1593,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) the_lnet.ln_rtrpools = cfs_percpt_alloc(lnet_cpt_table(), LNET_NRBPOOLS * - sizeof(lnet_rtrbufpool_t)); + sizeof(struct lnet_rtrbufpool)); if (!the_lnet.ln_rtrpools) { LCONSOLE_ERROR_MSG(0x10c, "Failed to initialize router buffe pool\n"); @@ -1639,7 +1639,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) int nrb = 0; int rc = 0; int i; - lnet_rtrbufpool_t *rtrp; + struct lnet_rtrbufpool *rtrp; /* * If the provided values for each buffer pool are different than the diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c index 779ec69..0065cc1 100644 --- a/drivers/staging/lustre/lnet/lnet/router_proc.c +++ b/drivers/staging/lustre/lnet/lnet/router_proc.c @@ -592,7 +592,7 @@ static int __proc_lnet_buffers(void *data, int write, goto out; /* I'm not a router */ for (idx = 0; idx < LNET_NRBPOOLS; idx++) { - lnet_rtrbufpool_t *rbp; + struct lnet_rtrbufpool *rbp; lnet_net_lock(LNET_LOCK_EX); cfs_percpt_for_each(rbp, i, the_lnet.ln_rtrpools) { -- 1.8.3.1 From jsimmons at infradead.org Mon Feb 27 00:41:38 2017 From: jsimmons at infradead.org (James Simmons) Date: Sun, 26 Feb 2017 19:41:38 -0500 Subject: [lustre-devel] [PATCH 13/34] staging: lustre: lnet: change lnet_ni_t to proper structure In-Reply-To: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> References: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> Message-ID: <1488156119-19670-14-git-send-email-jsimmons@infradead.org> Change lnet_ni_t from typedef to proper structure. Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/20831 Reviewed-by: Olaf Weber Reviewed-by: Doug Oucharek Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- .../staging/lustre/include/linux/lnet/lib-lnet.h | 42 ++++++++--------- .../staging/lustre/include/linux/lnet/lib-types.h | 10 ++-- .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 26 ++++++----- .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h | 17 +++---- .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 53 ++++++++++++---------- .../lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c | 2 +- .../staging/lustre/lnet/klnds/socklnd/socklnd.c | 43 +++++++++--------- .../staging/lustre/lnet/klnds/socklnd/socklnd.h | 41 +++++++++-------- .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 15 +++--- drivers/staging/lustre/lnet/lnet/acceptor.c | 2 +- drivers/staging/lustre/lnet/lnet/api-ni.c | 40 ++++++++-------- drivers/staging/lustre/lnet/lnet/config.c | 8 ++-- drivers/staging/lustre/lnet/lnet/lib-move.c | 38 ++++++++-------- drivers/staging/lustre/lnet/lnet/lib-msg.c | 2 +- drivers/staging/lustre/lnet/lnet/lo.c | 8 ++-- drivers/staging/lustre/lnet/lnet/peer.c | 8 ++-- drivers/staging/lustre/lnet/lnet/router.c | 14 +++--- drivers/staging/lustre/lnet/lnet/router_proc.c | 5 +- 18 files changed, 195 insertions(+), 179 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h index 9a29769..3d5913d 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h @@ -388,7 +388,7 @@ void lnet_res_lh_initialize(struct lnet_res_container *rec, } static inline void -lnet_ni_addref_locked(lnet_ni_t *ni, int cpt) +lnet_ni_addref_locked(struct lnet_ni *ni, int cpt) { LASSERT(cpt >= 0 && cpt < LNET_CPT_NUMBER); LASSERT(*ni->ni_refs[cpt] >= 0); @@ -397,7 +397,7 @@ void lnet_res_lh_initialize(struct lnet_res_container *rec, } static inline void -lnet_ni_addref(lnet_ni_t *ni) +lnet_ni_addref(struct lnet_ni *ni) { lnet_net_lock(0); lnet_ni_addref_locked(ni, 0); @@ -405,7 +405,7 @@ void lnet_res_lh_initialize(struct lnet_res_container *rec, } static inline void -lnet_ni_decref_locked(lnet_ni_t *ni, int cpt) +lnet_ni_decref_locked(struct lnet_ni *ni, int cpt) { LASSERT(cpt >= 0 && cpt < LNET_CPT_NUMBER); LASSERT(*ni->ni_refs[cpt] > 0); @@ -414,15 +414,15 @@ void lnet_res_lh_initialize(struct lnet_res_container *rec, } static inline void -lnet_ni_decref(lnet_ni_t *ni) +lnet_ni_decref(struct lnet_ni *ni) { lnet_net_lock(0); lnet_ni_decref_locked(ni, 0); lnet_net_unlock(0); } -void lnet_ni_free(lnet_ni_t *ni); -lnet_ni_t * +void lnet_ni_free(struct lnet_ni *ni); +struct lnet_ni * lnet_ni_alloc(__u32 net, struct cfs_expr_list *el, struct list_head *nilist); static inline int @@ -444,16 +444,16 @@ void lnet_res_lh_initialize(struct lnet_res_container *rec, int lnet_cpt_of_nid_locked(lnet_nid_t nid); int lnet_cpt_of_nid(lnet_nid_t nid); -lnet_ni_t *lnet_nid2ni_locked(lnet_nid_t nid, int cpt); -lnet_ni_t *lnet_net2ni_locked(__u32 net, int cpt); -lnet_ni_t *lnet_net2ni(__u32 net); +struct lnet_ni *lnet_nid2ni_locked(lnet_nid_t nid, int cpt); +struct lnet_ni *lnet_net2ni_locked(__u32 net, int cpt); +struct lnet_ni *lnet_net2ni(__u32 net); extern int portal_rotor; int lnet_lib_init(void); void lnet_lib_exit(void); -int lnet_notify(lnet_ni_t *ni, lnet_nid_t peer, int alive, unsigned long when); +int lnet_notify(struct lnet_ni *ni, lnet_nid_t peer, int alive, unsigned long when); void lnet_notify_locked(lnet_peer_t *lp, int notifylnd, int alive, unsigned long when); int lnet_add_route(__u32 net, __u32 hops, lnet_nid_t gateway_nid, @@ -552,26 +552,26 @@ void lnet_ptl_attach_md(struct lnet_me *me, struct lnet_libmd *md, void lnet_portals_destroy(void); /* message functions */ -int lnet_parse(lnet_ni_t *ni, struct lnet_hdr *hdr, +int lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t fromnid, void *private, int rdma_req); -int lnet_parse_local(lnet_ni_t *ni, struct lnet_msg *msg); -int lnet_parse_forward_locked(lnet_ni_t *ni, struct lnet_msg *msg); +int lnet_parse_local(struct lnet_ni *ni, struct lnet_msg *msg); +int lnet_parse_forward_locked(struct lnet_ni *ni, struct lnet_msg *msg); -void lnet_recv(lnet_ni_t *ni, void *private, struct lnet_msg *msg, +void lnet_recv(struct lnet_ni *ni, void *private, struct lnet_msg *msg, int delayed, unsigned int offset, unsigned int mlen, unsigned int rlen); -void lnet_ni_recv(lnet_ni_t *ni, void *private, struct lnet_msg *msg, +void lnet_ni_recv(struct lnet_ni *ni, void *private, struct lnet_msg *msg, int delayed, unsigned int offset, unsigned int mlen, unsigned int rlen); -struct lnet_msg *lnet_create_reply_msg(lnet_ni_t *ni, +struct lnet_msg *lnet_create_reply_msg(struct lnet_ni *ni, struct lnet_msg *get_msg); -void lnet_set_reply_msg_len(lnet_ni_t *ni, struct lnet_msg *msg, +void lnet_set_reply_msg_len(struct lnet_ni *ni, struct lnet_msg *msg, unsigned int len); -void lnet_finalize(lnet_ni_t *ni, struct lnet_msg *msg, int rc); +void lnet_finalize(struct lnet_ni *ni, struct lnet_msg *msg, int rc); -void lnet_drop_message(lnet_ni_t *ni, int cpt, void *private, +void lnet_drop_message(struct lnet_ni *ni, int cpt, void *private, unsigned int nob); void lnet_drop_delayed_msg_list(struct list_head *head, char *reason); void lnet_recv_delayed_msg_list(struct list_head *head); @@ -662,7 +662,7 @@ int lnet_sock_connect(struct socket **sockp, int *fatal, void libcfs_sock_release(struct socket *sock); int lnet_peers_start_down(void); -int lnet_peer_buffer_credits(lnet_ni_t *ni); +int lnet_peer_buffer_credits(struct lnet_ni *ni); int lnet_router_checker_start(void); void lnet_router_checker_stop(void); @@ -677,7 +677,7 @@ int lnet_sock_connect(struct socket **sockp, int *fatal, int lnet_nid2peer_locked(lnet_peer_t **lpp, lnet_nid_t nid, int cpt); lnet_peer_t *lnet_find_peer_locked(struct lnet_peer_table *ptable, lnet_nid_t nid); -void lnet_peer_tables_cleanup(lnet_ni_t *ni); +void lnet_peer_tables_cleanup(struct lnet_ni *ni); void lnet_peer_tables_destroy(void); int lnet_peer_tables_create(void); void lnet_debug_peer(lnet_nid_t nid); diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index 8a65db2..bcfb0c7 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -252,7 +252,7 @@ struct lnet_tx_queue { struct list_head tq_delayed; /* delayed TXs */ }; -typedef struct lnet_ni { +struct lnet_ni { spinlock_t ni_lock; struct list_head ni_list; /* chain on ln_nis */ struct list_head ni_cptlist; /* chain on ln_nis_cpt */ @@ -278,7 +278,7 @@ struct lnet_tx_queue { char *ni_interfaces[LNET_MAX_INTERFACES]; /* original net namespace */ struct net *ni_net_ns; -} lnet_ni_t; +}; #define LNET_PROTO_PING_MATCHBITS 0x8000000000000000LL @@ -336,7 +336,7 @@ struct lnet_tx_queue { unsigned long lp_last_alive; /* when I was last alive */ unsigned long lp_last_query; /* when lp_ni was queried last time */ - lnet_ni_t *lp_ni; /* interface peer is on */ + struct lnet_ni *lp_ni; /* interface peer is on */ lnet_nid_t lp_nid; /* peer's NID */ int lp_refcount; /* # refs */ int lp_cpt; /* CPT this peer attached on */ @@ -364,7 +364,7 @@ struct lnet_peer_table { /* * peer aliveness is enabled only on routers for peers in a network where the - * lnet_ni_t::ni_peertimeout has been set to a positive value + * lnet_ni::ni_peertimeout has been set to a positive value */ #define lnet_peer_aliveness_enabled(lp) (the_lnet.ln_routing && \ (lp)->lp_ni->ni_peertimeout > 0) @@ -585,7 +585,7 @@ struct lnet_msg_container { struct list_head ln_nis_cpt; /* dying LND instances */ struct list_head ln_nis_zombie; - lnet_ni_t *ln_loni; /* the loopback NI */ + struct lnet_ni *ln_loni; /* the loopback NI */ /* remote networks with routes to them */ struct list_head *ln_remote_nets_hash; diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c index 29a5263..79321e4 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c @@ -174,7 +174,7 @@ static int kiblnd_unpack_rd(struct kib_msg *msg, int flip) return 0; } -void kiblnd_pack_msg(lnet_ni_t *ni, struct kib_msg *msg, int version, +void kiblnd_pack_msg(struct lnet_ni *ni, struct kib_msg *msg, int version, int credits, lnet_nid_t dstnid, __u64 dststamp) { struct kib_net *net = ni->ni_data; @@ -313,7 +313,8 @@ int kiblnd_unpack_msg(struct kib_msg *msg, int nob) return 0; } -int kiblnd_create_peer(lnet_ni_t *ni, struct kib_peer **peerp, lnet_nid_t nid) +int kiblnd_create_peer(struct lnet_ni *ni, struct kib_peer **peerp, + lnet_nid_t nid) { struct kib_peer *peer; struct kib_net *net = ni->ni_data; @@ -412,7 +413,7 @@ void kiblnd_unlink_peer_locked(struct kib_peer *peer) kiblnd_peer_decref(peer); } -static int kiblnd_get_peer_info(lnet_ni_t *ni, int index, +static int kiblnd_get_peer_info(struct lnet_ni *ni, int index, lnet_nid_t *nidp, int *count) { struct kib_peer *peer; @@ -468,7 +469,7 @@ static void kiblnd_del_peer_locked(struct kib_peer *peer) */ } -static int kiblnd_del_peer(lnet_ni_t *ni, lnet_nid_t nid) +static int kiblnd_del_peer(struct lnet_ni *ni, lnet_nid_t nid) { LIST_HEAD(zombies); struct list_head *ptmp; @@ -520,7 +521,7 @@ static int kiblnd_del_peer(lnet_ni_t *ni, lnet_nid_t nid) return rc; } -static struct kib_conn *kiblnd_get_conn_by_idx(lnet_ni_t *ni, int index) +static struct kib_conn *kiblnd_get_conn_by_idx(struct lnet_ni *ni, int index) { struct kib_peer *peer; struct list_head *ptmp; @@ -947,7 +948,7 @@ int kiblnd_close_stale_conns_locked(struct kib_peer *peer, return count; } -static int kiblnd_close_matching_conns(lnet_ni_t *ni, lnet_nid_t nid) +static int kiblnd_close_matching_conns(struct lnet_ni *ni, lnet_nid_t nid) { struct kib_peer *peer; struct list_head *ptmp; @@ -992,7 +993,7 @@ static int kiblnd_close_matching_conns(lnet_ni_t *ni, lnet_nid_t nid) return !count ? -ENOENT : 0; } -static int kiblnd_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg) +static int kiblnd_ctl(struct lnet_ni *ni, unsigned int cmd, void *arg) { struct libcfs_ioctl_data *data = arg; int rc = -EINVAL; @@ -1045,7 +1046,8 @@ static int kiblnd_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg) return rc; } -static void kiblnd_query(lnet_ni_t *ni, lnet_nid_t nid, unsigned long *when) +static void kiblnd_query(struct lnet_ni *ni, lnet_nid_t nid, + unsigned long *when) { unsigned long last_alive = 0; unsigned long now = cfs_time_current(); @@ -2143,8 +2145,8 @@ static void kiblnd_net_fini_pools(struct kib_net *net) } } -static int kiblnd_net_init_pools(struct kib_net *net, lnet_ni_t *ni, __u32 *cpts, - int ncpts) +static int kiblnd_net_init_pools(struct kib_net *net, struct lnet_ni *ni, + __u32 *cpts, int ncpts) { struct lnet_ioctl_config_o2iblnd_tunables *tunables; int cpt; @@ -2587,7 +2589,7 @@ static void kiblnd_base_shutdown(void) module_put(THIS_MODULE); } -static void kiblnd_shutdown(lnet_ni_t *ni) +static void kiblnd_shutdown(struct lnet_ni *ni) { struct kib_net *net = ni->ni_data; rwlock_t *g_lock = &kiblnd_data.kib_global_lock; @@ -2844,7 +2846,7 @@ static struct kib_dev *kiblnd_dev_search(char *ifname) return alias; } -static int kiblnd_startup(lnet_ni_t *ni) +static int kiblnd_startup(struct lnet_ni *ni) { char *ifname; struct kib_dev *ibdev = NULL; diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h index dbd3b8e..16e437b 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h @@ -566,7 +566,7 @@ struct kib_conn { struct kib_peer { struct list_head ibp_list; /* stash on global peer list */ lnet_nid_t ibp_nid; /* who's on the other end(s) */ - lnet_ni_t *ibp_ni; /* LNet interface */ + struct lnet_ni *ibp_ni; /* LNet interface */ struct list_head ibp_conns; /* all active connections */ struct list_head ibp_tx_queue; /* msgs waiting for a conn */ __u64 ibp_incarnation; /* incarnation of peer */ @@ -763,7 +763,7 @@ struct kib_peer { kiblnd_need_noop(struct kib_conn *conn) { struct lnet_ioctl_config_o2iblnd_tunables *tunables; - lnet_ni_t *ni = conn->ibc_peer->ibp_ni; + struct lnet_ni *ni = conn->ibc_peer->ibp_ni; LASSERT(conn->ibc_state >= IBLND_CONN_ESTABLISHED); tunables = &ni->ni_lnd_tunables->lt_tun_u.lt_o2ib; @@ -1002,7 +1002,8 @@ int kiblnd_cm_callback(struct rdma_cm_id *cmid, int kiblnd_translate_mtu(int value); int kiblnd_dev_failover(struct kib_dev *dev); -int kiblnd_create_peer(lnet_ni_t *ni, struct kib_peer **peerp, lnet_nid_t nid); +int kiblnd_create_peer(struct lnet_ni *ni, struct kib_peer **peerp, + lnet_nid_t nid); void kiblnd_destroy_peer(struct kib_peer *peer); bool kiblnd_reconnect_peer(struct kib_peer *peer); void kiblnd_destroy_dev(struct kib_dev *dev); @@ -1019,19 +1020,19 @@ struct kib_conn *kiblnd_create_conn(struct kib_peer *peer, void kiblnd_close_conn(struct kib_conn *conn, int error); void kiblnd_close_conn_locked(struct kib_conn *conn, int error); -void kiblnd_launch_tx(lnet_ni_t *ni, struct kib_tx *tx, lnet_nid_t nid); -void kiblnd_txlist_done(lnet_ni_t *ni, struct list_head *txlist, +void kiblnd_launch_tx(struct lnet_ni *ni, struct kib_tx *tx, lnet_nid_t nid); +void kiblnd_txlist_done(struct lnet_ni *ni, struct list_head *txlist, int status); void kiblnd_qp_event(struct ib_event *event, void *arg); void kiblnd_cq_event(struct ib_event *event, void *arg); void kiblnd_cq_completion(struct ib_cq *cq, void *arg); -void kiblnd_pack_msg(lnet_ni_t *ni, struct kib_msg *msg, int version, +void kiblnd_pack_msg(struct lnet_ni *ni, struct kib_msg *msg, int version, int credits, lnet_nid_t dstnid, __u64 dststamp); int kiblnd_unpack_msg(struct kib_msg *msg, int nob); int kiblnd_post_rx(struct kib_rx *rx, int credit); -int kiblnd_send(lnet_ni_t *ni, void *private, struct lnet_msg *lntmsg); -int kiblnd_recv(lnet_ni_t *ni, void *private, struct lnet_msg *lntmsg, +int kiblnd_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg); +int kiblnd_recv(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg, int delayed, struct iov_iter *to, unsigned int rlen); diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c index 021e6ac..0c9b40f 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c @@ -40,18 +40,18 @@ static void kiblnd_peer_alive(struct kib_peer *peer); static void kiblnd_peer_connect_failed(struct kib_peer *peer, int active, int error); -static void kiblnd_init_tx_msg(lnet_ni_t *ni, struct kib_tx *tx, +static void kiblnd_init_tx_msg(struct lnet_ni *ni, struct kib_tx *tx, int type, int body_nob); static int kiblnd_init_rdma(struct kib_conn *conn, struct kib_tx *tx, int type, int resid, struct kib_rdma_desc *dstrd, __u64 dstcookie); static void kiblnd_queue_tx_locked(struct kib_tx *tx, struct kib_conn *conn); static void kiblnd_queue_tx(struct kib_tx *tx, struct kib_conn *conn); -static void kiblnd_unmap_tx(lnet_ni_t *ni, struct kib_tx *tx); +static void kiblnd_unmap_tx(struct lnet_ni *ni, struct kib_tx *tx); static void kiblnd_check_sends_locked(struct kib_conn *conn); static void -kiblnd_tx_done(lnet_ni_t *ni, struct kib_tx *tx) +kiblnd_tx_done(struct lnet_ni *ni, struct kib_tx *tx) { struct lnet_msg *lntmsg[2]; struct kib_net *net = ni->ni_data; @@ -94,7 +94,7 @@ static int kiblnd_init_rdma(struct kib_conn *conn, struct kib_tx *tx, int type, } void -kiblnd_txlist_done(lnet_ni_t *ni, struct list_head *txlist, int status) +kiblnd_txlist_done(struct lnet_ni *ni, struct list_head *txlist, int status) { struct kib_tx *tx; @@ -110,7 +110,7 @@ static int kiblnd_init_rdma(struct kib_conn *conn, struct kib_tx *tx, int type, } static struct kib_tx * -kiblnd_get_idle_tx(lnet_ni_t *ni, lnet_nid_t target) +kiblnd_get_idle_tx(struct lnet_ni *ni, lnet_nid_t target) { struct kib_net *net = (struct kib_net *)ni->ni_data; struct list_head *node; @@ -249,7 +249,7 @@ static int kiblnd_init_rdma(struct kib_conn *conn, struct kib_tx *tx, int type, kiblnd_handle_completion(struct kib_conn *conn, int txtype, int status, __u64 cookie) { struct kib_tx *tx; - lnet_ni_t *ni = conn->ibc_peer->ibp_ni; + struct lnet_ni *ni = conn->ibc_peer->ibp_ni; int idle; spin_lock(&conn->ibc_lock); @@ -286,7 +286,7 @@ static int kiblnd_init_rdma(struct kib_conn *conn, struct kib_tx *tx, int type, static void kiblnd_send_completion(struct kib_conn *conn, int type, int status, __u64 cookie) { - lnet_ni_t *ni = conn->ibc_peer->ibp_ni; + struct lnet_ni *ni = conn->ibc_peer->ibp_ni; struct kib_tx *tx = kiblnd_get_idle_tx(ni, conn->ibc_peer->ibp_nid); if (!tx) { @@ -307,7 +307,7 @@ static int kiblnd_init_rdma(struct kib_conn *conn, struct kib_tx *tx, int type, { struct kib_msg *msg = rx->rx_msg; struct kib_conn *conn = rx->rx_conn; - lnet_ni_t *ni = conn->ibc_peer->ibp_ni; + struct lnet_ni *ni = conn->ibc_peer->ibp_ni; int credits = msg->ibm_credits; struct kib_tx *tx; int rc = 0; @@ -468,7 +468,7 @@ static int kiblnd_init_rdma(struct kib_conn *conn, struct kib_tx *tx, int type, { struct kib_msg *msg = rx->rx_msg; struct kib_conn *conn = rx->rx_conn; - lnet_ni_t *ni = conn->ibc_peer->ibp_ni; + struct lnet_ni *ni = conn->ibc_peer->ibp_ni; struct kib_net *net = ni->ni_data; int rc; int err = -EIO; @@ -590,7 +590,7 @@ static int kiblnd_init_rdma(struct kib_conn *conn, struct kib_tx *tx, int type, return 0; } -static void kiblnd_unmap_tx(lnet_ni_t *ni, struct kib_tx *tx) +static void kiblnd_unmap_tx(struct lnet_ni *ni, struct kib_tx *tx) { struct kib_net *net = ni->ni_data; @@ -606,8 +606,8 @@ static void kiblnd_unmap_tx(lnet_ni_t *ni, struct kib_tx *tx) } } -static int kiblnd_map_tx(lnet_ni_t *ni, struct kib_tx *tx, struct kib_rdma_desc *rd, - int nfrags) +static int kiblnd_map_tx(struct lnet_ni *ni, struct kib_tx *tx, + struct kib_rdma_desc *rd, int nfrags) { struct kib_net *net = ni->ni_data; struct kib_hca_dev *hdev = net->ibn_dev->ibd_hdev; @@ -639,8 +639,9 @@ static int kiblnd_map_tx(lnet_ni_t *ni, struct kib_tx *tx, struct kib_rdma_desc } static int -kiblnd_setup_rd_iov(lnet_ni_t *ni, struct kib_tx *tx, struct kib_rdma_desc *rd, - unsigned int niov, const struct kvec *iov, int offset, int nob) +kiblnd_setup_rd_iov(struct lnet_ni *ni, struct kib_tx *tx, + struct kib_rdma_desc *rd, unsigned int niov, + const struct kvec *iov, int offset, int nob) { struct kib_net *net = ni->ni_data; struct page *page; @@ -696,8 +697,9 @@ static int kiblnd_map_tx(lnet_ni_t *ni, struct kib_tx *tx, struct kib_rdma_desc } static int -kiblnd_setup_rd_kiov(lnet_ni_t *ni, struct kib_tx *tx, struct kib_rdma_desc *rd, - int nkiov, const lnet_kiov_t *kiov, int offset, int nob) +kiblnd_setup_rd_kiov(struct lnet_ni *ni, struct kib_tx *tx, + struct kib_rdma_desc *rd, int nkiov, + const lnet_kiov_t *kiov, int offset, int nob) { struct kib_net *net = ni->ni_data; struct scatterlist *sg; @@ -899,7 +901,7 @@ static int kiblnd_map_tx(lnet_ni_t *ni, struct kib_tx *tx, struct kib_rdma_desc kiblnd_check_sends_locked(struct kib_conn *conn) { int ver = conn->ibc_version; - lnet_ni_t *ni = conn->ibc_peer->ibp_ni; + struct lnet_ni *ni = conn->ibc_peer->ibp_ni; struct kib_tx *tx; /* Don't send anything until after the connection is established */ @@ -1011,7 +1013,8 @@ static int kiblnd_map_tx(lnet_ni_t *ni, struct kib_tx *tx, struct kib_rdma_desc } static void -kiblnd_init_tx_msg(lnet_ni_t *ni, struct kib_tx *tx, int type, int body_nob) +kiblnd_init_tx_msg(struct lnet_ni *ni, struct kib_tx *tx, int type, + int body_nob) { struct kib_hca_dev *hdev = tx->tx_pool->tpo_hdev; struct ib_sge *sge = &tx->tx_sge[tx->tx_nwrq]; @@ -1353,7 +1356,7 @@ static int kiblnd_resolve_addr(struct rdma_cm_id *cmid, } void -kiblnd_launch_tx(lnet_ni_t *ni, struct kib_tx *tx, lnet_nid_t nid) +kiblnd_launch_tx(struct lnet_ni *ni, struct kib_tx *tx, lnet_nid_t nid) { struct kib_peer *peer; struct kib_peer *peer2; @@ -1475,7 +1478,7 @@ static int kiblnd_resolve_addr(struct rdma_cm_id *cmid, } int -kiblnd_send(lnet_ni_t *ni, void *private, struct lnet_msg *lntmsg) +kiblnd_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg) { struct lnet_hdr *hdr = &lntmsg->msg_hdr; int type = lntmsg->msg_type; @@ -1648,7 +1651,7 @@ static int kiblnd_resolve_addr(struct rdma_cm_id *cmid, } static void -kiblnd_reply(lnet_ni_t *ni, struct kib_rx *rx, struct lnet_msg *lntmsg) +kiblnd_reply(struct lnet_ni *ni, struct kib_rx *rx, struct lnet_msg *lntmsg) { lnet_process_id_t target = lntmsg->msg_target; unsigned int niov = lntmsg->msg_niov; @@ -1709,7 +1712,7 @@ static int kiblnd_resolve_addr(struct rdma_cm_id *cmid, } int -kiblnd_recv(lnet_ni_t *ni, void *private, struct lnet_msg *lntmsg, +kiblnd_recv(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg, int delayed, struct iov_iter *to, unsigned int rlen) { struct kib_rx *rx = private; @@ -2157,7 +2160,7 @@ static int kiblnd_resolve_addr(struct rdma_cm_id *cmid, if (!kiblnd_peer_active(peer) || /* peer has been deleted */ conn->ibc_comms_error) { /* error has happened already */ - lnet_ni_t *ni = peer->ibp_ni; + struct lnet_ni *ni = peer->ibp_ni; /* start to shut down connection */ kiblnd_close_conn_locked(conn, -ECONNABORTED); @@ -2214,7 +2217,7 @@ static int kiblnd_resolve_addr(struct rdma_cm_id *cmid, struct kib_peer *peer; struct kib_peer *peer2; struct kib_conn *conn; - lnet_ni_t *ni = NULL; + struct lnet_ni *ni = NULL; struct kib_net *net = NULL; lnet_nid_t nid; struct rdma_conn_param cp; @@ -2776,7 +2779,7 @@ static int kiblnd_resolve_addr(struct rdma_cm_id *cmid, kiblnd_check_connreply(struct kib_conn *conn, void *priv, int priv_nob) { struct kib_peer *peer = conn->ibc_peer; - lnet_ni_t *ni = peer->ibp_ni; + struct lnet_ni *ni = peer->ibp_ni; struct kib_net *net = ni->ni_data; struct kib_msg *msg = priv; int ver = conn->ibc_version; diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c index 3c81b527..3fe4d48 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c @@ -161,7 +161,7 @@ struct kib_tunables kiblnd_tunables = { static struct lnet_ioctl_config_o2iblnd_tunables default_tunables; /* # messages/RDMAs in-flight */ -int kiblnd_msg_queue_size(int version, lnet_ni_t *ni) +int kiblnd_msg_queue_size(int version, struct lnet_ni *ni) { if (version == IBLND_MSG_VERSION_1) return IBLND_MSG_QUEUE_SIZE_V1; diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c index 258507f..f92fa4b 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c @@ -43,7 +43,7 @@ struct ksock_nal_data ksocknal_data; static struct ksock_interface * -ksocknal_ip2iface(lnet_ni_t *ni, __u32 ip) +ksocknal_ip2iface(struct lnet_ni *ni, __u32 ip) { struct ksock_net *net = ni->ni_data; int i; @@ -96,7 +96,7 @@ } static int -ksocknal_create_peer(struct ksock_peer **peerp, lnet_ni_t *ni, +ksocknal_create_peer(struct ksock_peer **peerp, struct lnet_ni *ni, lnet_process_id_t id) { int cpt = lnet_cpt_of_nid(id.nid); @@ -173,7 +173,7 @@ } struct ksock_peer * -ksocknal_find_peer_locked(lnet_ni_t *ni, lnet_process_id_t id) +ksocknal_find_peer_locked(struct lnet_ni *ni, lnet_process_id_t id) { struct list_head *peer_list = ksocknal_nid2peerlist(id.nid); struct list_head *tmp; @@ -200,7 +200,7 @@ struct ksock_peer * } struct ksock_peer * -ksocknal_find_peer(lnet_ni_t *ni, lnet_process_id_t id) +ksocknal_find_peer(struct lnet_ni *ni, lnet_process_id_t id) { struct ksock_peer *peer; @@ -246,7 +246,7 @@ struct ksock_peer * } static int -ksocknal_get_peer_info(lnet_ni_t *ni, int index, +ksocknal_get_peer_info(struct lnet_ni *ni, int index, lnet_process_id_t *id, __u32 *myip, __u32 *peer_ip, int *port, int *conn_count, int *share_count) { @@ -450,7 +450,8 @@ struct ksock_peer * } int -ksocknal_add_peer(lnet_ni_t *ni, lnet_process_id_t id, __u32 ipaddr, int port) +ksocknal_add_peer(struct lnet_ni *ni, lnet_process_id_t id, __u32 ipaddr, + int port) { struct list_head *tmp; struct ksock_peer *peer; @@ -568,7 +569,7 @@ struct ksock_peer * } static int -ksocknal_del_peer(lnet_ni_t *ni, lnet_process_id_t id, __u32 ip) +ksocknal_del_peer(struct lnet_ni *ni, lnet_process_id_t id, __u32 ip) { LIST_HEAD(zombies); struct list_head *ptmp; @@ -627,7 +628,7 @@ struct ksock_peer * } static struct ksock_conn * -ksocknal_get_conn_by_idx(lnet_ni_t *ni, int index) +ksocknal_get_conn_by_idx(struct lnet_ni *ni, int index) { struct ksock_peer *peer; struct list_head *ptmp; @@ -687,7 +688,7 @@ struct ksock_peer * } static int -ksocknal_local_ipvec(lnet_ni_t *ni, __u32 *ipaddrs) +ksocknal_local_ipvec(struct lnet_ni *ni, __u32 *ipaddrs) { struct ksock_net *net = ni->ni_data; int i; @@ -866,7 +867,7 @@ struct ksock_peer * { struct ksock_route *newroute = NULL; rwlock_t *global_lock = &ksocknal_data.ksnd_global_lock; - lnet_ni_t *ni = peer->ksnp_ni; + struct lnet_ni *ni = peer->ksnp_ni; struct ksock_net *net = ni->ni_data; struct list_head *rtmp; struct ksock_route *route; @@ -982,7 +983,7 @@ struct ksock_peer * } int -ksocknal_accept(lnet_ni_t *ni, struct socket *sock) +ksocknal_accept(struct lnet_ni *ni, struct socket *sock) { struct ksock_connreq *cr; int rc; @@ -1025,7 +1026,7 @@ struct ksock_peer * } int -ksocknal_create_conn(lnet_ni_t *ni, struct ksock_route *route, +ksocknal_create_conn(struct lnet_ni *ni, struct ksock_route *route, struct socket *sock, int type) { rwlock_t *global_lock = &ksocknal_data.ksnd_global_lock; @@ -1810,7 +1811,7 @@ struct ksock_peer * } void -ksocknal_notify(lnet_ni_t *ni, lnet_nid_t gw_nid, int alive) +ksocknal_notify(struct lnet_ni *ni, lnet_nid_t gw_nid, int alive) { /* * The router is telling me she's been notified of a change in @@ -1837,7 +1838,7 @@ struct ksock_peer * } void -ksocknal_query(lnet_ni_t *ni, lnet_nid_t nid, unsigned long *when) +ksocknal_query(struct lnet_ni *ni, lnet_nid_t nid, unsigned long *when) { int connect = 1; unsigned long last_alive = 0; @@ -1932,7 +1933,7 @@ struct ksock_peer * } } -static int ksocknal_push(lnet_ni_t *ni, lnet_process_id_t id) +static int ksocknal_push(struct lnet_ni *ni, lnet_process_id_t id) { struct list_head *start; struct list_head *end; @@ -1982,7 +1983,7 @@ static int ksocknal_push(lnet_ni_t *ni, lnet_process_id_t id) } static int -ksocknal_add_interface(lnet_ni_t *ni, __u32 ipaddress, __u32 netmask) +ksocknal_add_interface(struct lnet_ni *ni, __u32 ipaddress, __u32 netmask) { struct ksock_net *net = ni->ni_data; struct ksock_interface *iface; @@ -2086,7 +2087,7 @@ static int ksocknal_push(lnet_ni_t *ni, lnet_process_id_t id) } static int -ksocknal_del_interface(lnet_ni_t *ni, __u32 ipaddress) +ksocknal_del_interface(struct lnet_ni *ni, __u32 ipaddress) { struct ksock_net *net = ni->ni_data; int rc = -ENOENT; @@ -2132,7 +2133,7 @@ static int ksocknal_push(lnet_ni_t *ni, lnet_process_id_t id) } int -ksocknal_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg) +ksocknal_ctl(struct lnet_ni *ni, unsigned int cmd, void *arg) { lnet_process_id_t id = {0}; struct libcfs_ioctl_data *data = arg; @@ -2534,7 +2535,7 @@ static int ksocknal_push(lnet_ni_t *ni, lnet_process_id_t id) } static void -ksocknal_debug_peerhash(lnet_ni_t *ni) +ksocknal_debug_peerhash(struct lnet_ni *ni) { struct ksock_peer *peer = NULL; struct list_head *tmp; @@ -2587,7 +2588,7 @@ static int ksocknal_push(lnet_ni_t *ni, lnet_process_id_t id) } void -ksocknal_shutdown(lnet_ni_t *ni) +ksocknal_shutdown(struct lnet_ni *ni) { struct ksock_net *net = ni->ni_data; int i; @@ -2810,7 +2811,7 @@ static int ksocknal_push(lnet_ni_t *ni, lnet_process_id_t id) } int -ksocknal_startup(lnet_ni_t *ni) +ksocknal_startup(struct lnet_ni *ni) { struct ksock_net *net; int rc; diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h index d03a029..99fec18 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h @@ -447,7 +447,7 @@ struct ksock_peer { * ACK */ unsigned long ksnp_send_keepalive; /* time to send keepalive */ - lnet_ni_t *ksnp_ni; /* which network */ + struct lnet_ni *ksnp_ni; /* which network */ int ksnp_n_passive_ips; /* # of... */ /* preferred local interfaces */ @@ -456,7 +456,7 @@ struct ksock_peer { struct ksock_connreq { struct list_head ksncr_list; /* stash on ksnd_connd_connreqs */ - lnet_ni_t *ksncr_ni; /* chosen NI */ + struct lnet_ni *ksncr_ni; /* chosen NI */ struct socket *ksncr_sock; /* accepted socket */ }; @@ -603,7 +603,7 @@ static inline __u32 ksocknal_csum(__u32 crc, unsigned char const *p, size_t len) } void ksocknal_tx_prep(struct ksock_conn *, struct ksock_tx *tx); -void ksocknal_tx_done(lnet_ni_t *ni, struct ksock_tx *tx); +void ksocknal_tx_done(struct lnet_ni *ni, struct ksock_tx *tx); static inline void ksocknal_tx_decref(struct ksock_tx *tx) @@ -647,19 +647,22 @@ static inline __u32 ksocknal_csum(__u32 crc, unsigned char const *p, size_t len) ksocknal_destroy_peer(peer); } -int ksocknal_startup(lnet_ni_t *ni); -void ksocknal_shutdown(lnet_ni_t *ni); -int ksocknal_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg); -int ksocknal_send(lnet_ni_t *ni, void *private, struct lnet_msg *lntmsg); -int ksocknal_recv(lnet_ni_t *ni, void *private, struct lnet_msg *lntmsg, +int ksocknal_startup(struct lnet_ni *ni); +void ksocknal_shutdown(struct lnet_ni *ni); +int ksocknal_ctl(struct lnet_ni *ni, unsigned int cmd, void *arg); +int ksocknal_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg); +int ksocknal_recv(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg, int delayed, struct iov_iter *to, unsigned int rlen); -int ksocknal_accept(lnet_ni_t *ni, struct socket *sock); - -int ksocknal_add_peer(lnet_ni_t *ni, lnet_process_id_t id, __u32 ip, int port); -struct ksock_peer *ksocknal_find_peer_locked(lnet_ni_t *ni, lnet_process_id_t id); -struct ksock_peer *ksocknal_find_peer(lnet_ni_t *ni, lnet_process_id_t id); +int ksocknal_accept(struct lnet_ni *ni, struct socket *sock); + +int ksocknal_add_peer(struct lnet_ni *ni, lnet_process_id_t id, __u32 ip, + int port); +struct ksock_peer *ksocknal_find_peer_locked(struct lnet_ni *ni, + lnet_process_id_t id); +struct ksock_peer *ksocknal_find_peer(struct lnet_ni *ni, + lnet_process_id_t id); void ksocknal_peer_failed(struct ksock_peer *peer); -int ksocknal_create_conn(lnet_ni_t *ni, struct ksock_route *route, +int ksocknal_create_conn(struct lnet_ni *ni, struct ksock_route *route, struct socket *sock, int type); void ksocknal_close_conn_locked(struct ksock_conn *conn, int why); void ksocknal_terminate_conn(struct ksock_conn *conn); @@ -671,15 +674,15 @@ int ksocknal_close_peer_conns_locked(struct ksock_peer *peer, struct ksock_conn *ksocknal_find_conn_locked(struct ksock_peer *peer, struct ksock_tx *tx, int nonblk); -int ksocknal_launch_packet(lnet_ni_t *ni, struct ksock_tx *tx, +int ksocknal_launch_packet(struct lnet_ni *ni, struct ksock_tx *tx, lnet_process_id_t id); struct ksock_tx *ksocknal_alloc_tx(int type, int size); void ksocknal_free_tx(struct ksock_tx *tx); struct ksock_tx *ksocknal_alloc_tx_noop(__u64 cookie, int nonblk); void ksocknal_next_tx_carrier(struct ksock_conn *conn); void ksocknal_queue_tx_locked(struct ksock_tx *tx, struct ksock_conn *conn); -void ksocknal_txlist_done(lnet_ni_t *ni, struct list_head *txlist, int error); -void ksocknal_notify(lnet_ni_t *ni, lnet_nid_t gw_nid, int alive); +void ksocknal_txlist_done(struct lnet_ni *ni, struct list_head *txlist, int error); +void ksocknal_notify(struct lnet_ni *ni, lnet_nid_t gw_nid, int alive); void ksocknal_query(struct lnet_ni *ni, lnet_nid_t nid, unsigned long *when); int ksocknal_thread_start(int (*fn)(void *arg), void *arg, char *name); void ksocknal_thread_fini(void); @@ -690,9 +693,9 @@ int ksocknal_launch_packet(lnet_ni_t *ni, struct ksock_tx *tx, int ksocknal_scheduler(void *arg); int ksocknal_connd(void *arg); int ksocknal_reaper(void *arg); -int ksocknal_send_hello(lnet_ni_t *ni, struct ksock_conn *conn, +int ksocknal_send_hello(struct lnet_ni *ni, struct ksock_conn *conn, lnet_nid_t peer_nid, struct ksock_hello_msg *hello); -int ksocknal_recv_hello(lnet_ni_t *ni, struct ksock_conn *conn, +int ksocknal_recv_hello(struct lnet_ni *ni, struct ksock_conn *conn, struct ksock_hello_msg *hello, lnet_process_id_t *id, __u64 *incarnation); void ksocknal_read_callback(struct ksock_conn *conn); diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c index 66827f2..8cea4f6 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c @@ -393,7 +393,7 @@ struct ksock_tx * } void -ksocknal_tx_done(lnet_ni_t *ni, struct ksock_tx *tx) +ksocknal_tx_done(struct lnet_ni *ni, struct ksock_tx *tx) { struct lnet_msg *lnetmsg = tx->tx_lnetmsg; int rc = (!tx->tx_resid && !tx->tx_zc_aborted) ? 0 : -EIO; @@ -412,7 +412,7 @@ struct ksock_tx * } void -ksocknal_txlist_done(lnet_ni_t *ni, struct list_head *txlist, int error) +ksocknal_txlist_done(struct lnet_ni *ni, struct list_head *txlist, int error) { struct ksock_tx *tx; @@ -845,7 +845,8 @@ struct ksock_route * } int -ksocknal_launch_packet(lnet_ni_t *ni, struct ksock_tx *tx, lnet_process_id_t id) +ksocknal_launch_packet(struct lnet_ni *ni, struct ksock_tx *tx, + lnet_process_id_t id) { struct ksock_peer *peer; struct ksock_conn *conn; @@ -938,7 +939,7 @@ struct ksock_route * } int -ksocknal_send(lnet_ni_t *ni, void *private, struct lnet_msg *lntmsg) +ksocknal_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg) { int mpflag = 1; int type = lntmsg->msg_type; @@ -1333,7 +1334,7 @@ struct ksock_route * } int -ksocknal_recv(lnet_ni_t *ni, void *private, struct lnet_msg *msg, +ksocknal_recv(struct lnet_ni *ni, void *private, struct lnet_msg *msg, int delayed, struct iov_iter *to, unsigned int rlen) { struct ksock_conn *conn = private; @@ -1675,7 +1676,7 @@ void ksocknal_write_callback(struct ksock_conn *conn) } int -ksocknal_send_hello(lnet_ni_t *ni, struct ksock_conn *conn, +ksocknal_send_hello(struct lnet_ni *ni, struct ksock_conn *conn, lnet_nid_t peer_nid, struct ksock_hello_msg *hello) { /* CAVEAT EMPTOR: this byte flips 'ipaddrs' */ @@ -1713,7 +1714,7 @@ void ksocknal_write_callback(struct ksock_conn *conn) } int -ksocknal_recv_hello(lnet_ni_t *ni, struct ksock_conn *conn, +ksocknal_recv_hello(struct lnet_ni *ni, struct ksock_conn *conn, struct ksock_hello_msg *hello, lnet_process_id_t *peerid, __u64 *incarnation) { diff --git a/drivers/staging/lustre/lnet/lnet/acceptor.c b/drivers/staging/lustre/lnet/lnet/acceptor.c index 69bbd59..a6f60c3 100644 --- a/drivers/staging/lustre/lnet/lnet/acceptor.c +++ b/drivers/staging/lustre/lnet/lnet/acceptor.c @@ -211,7 +211,7 @@ int peer_port; int rc; int flip; - lnet_ni_t *ni; + struct lnet_ni *ni; char *str; LASSERT(sizeof(cr) <= 16); /* not too big for the stack */ diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index d31a50b..88279ed 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -653,16 +653,16 @@ struct lnet_libhandle * return 0; } -lnet_ni_t * +struct lnet_ni * lnet_net2ni_locked(__u32 net, int cpt) { struct list_head *tmp; - lnet_ni_t *ni; + struct lnet_ni *ni; LASSERT(cpt != LNET_LOCK_EX); list_for_each(tmp, &the_lnet.ln_nis) { - ni = list_entry(tmp, lnet_ni_t, ni_list); + ni = list_entry(tmp, struct lnet_ni, ni_list); if (LNET_NIDNET(ni->ni_nid) == net) { lnet_ni_addref_locked(ni, cpt); @@ -673,10 +673,10 @@ struct lnet_libhandle * return NULL; } -lnet_ni_t * +struct lnet_ni * lnet_net2ni(__u32 net) { - lnet_ni_t *ni; + struct lnet_ni *ni; lnet_net_lock(0); ni = lnet_net2ni_locked(net, 0); @@ -766,7 +766,7 @@ struct lnet_libhandle * return !!ni; } -lnet_ni_t * +struct lnet_ni * lnet_nid2ni_locked(lnet_nid_t nid, int cpt) { struct lnet_ni *ni; @@ -775,7 +775,7 @@ struct lnet_libhandle * LASSERT(cpt != LNET_LOCK_EX); list_for_each(tmp, &the_lnet.ln_nis) { - ni = list_entry(tmp, lnet_ni_t, ni_list); + ni = list_entry(tmp, struct lnet_ni, ni_list); if (ni->ni_nid == nid) { lnet_ni_addref_locked(ni, cpt); @@ -812,7 +812,7 @@ struct lnet_libhandle * cpt = lnet_net_lock_current(); list_for_each(tmp, &the_lnet.ln_nis) { - ni = list_entry(tmp, lnet_ni_t, ni_list); + ni = list_entry(tmp, struct lnet_ni, ni_list); if (ni->ni_lnd->lnd_accept) count++; @@ -985,7 +985,7 @@ struct lnet_libhandle * lnet_ping_info_install_locked(struct lnet_ping_info *ping_info) { struct lnet_ni_status *ns; - lnet_ni_t *ni; + struct lnet_ni *ni; int i = 0; list_for_each_entry(ni, &the_lnet.ln_nis, ni_list) { @@ -1050,7 +1050,7 @@ struct lnet_libhandle * } static int -lnet_ni_tq_credits(lnet_ni_t *ni) +lnet_ni_tq_credits(struct lnet_ni *ni) { int credits; @@ -1067,7 +1067,7 @@ struct lnet_libhandle * } static void -lnet_ni_unlink_locked(lnet_ni_t *ni) +lnet_ni_unlink_locked(struct lnet_ni *ni) { if (!list_empty(&ni->ni_cptlist)) { list_del_init(&ni->ni_cptlist); @@ -1085,8 +1085,8 @@ struct lnet_libhandle * { int i; int islo; - lnet_ni_t *ni; - lnet_ni_t *temp; + struct lnet_ni *ni; + struct lnet_ni *temp; /* * Now wait for the NI's I just nuked to show up on ln_zombie_nis @@ -1145,8 +1145,8 @@ struct lnet_libhandle * static void lnet_shutdown_lndnis(void) { - lnet_ni_t *ni; - lnet_ni_t *temp; + struct lnet_ni *ni; + struct lnet_ni *temp; int i; /* NB called holding the global mutex */ @@ -1380,7 +1380,7 @@ struct lnet_libhandle * int ni_count = 0; while (!list_empty(nilist)) { - ni = list_entry(nilist->next, lnet_ni_t, ni_list); + ni = list_entry(nilist->next, struct lnet_ni, ni_list); list_del(&ni->ni_list); rc = lnet_startup_lndni(ni, NULL); @@ -1742,7 +1742,7 @@ void lnet_lib_exit(void) if (i++ != idx) continue; - ni = list_entry(tmp, lnet_ni_t, ni_list); + ni = list_entry(tmp, struct lnet_ni, ni_list); lnet_ni_lock(ni); lnet_fill_ni_info(ni, config); lnet_ni_unlock(ni); @@ -1837,7 +1837,7 @@ void lnet_lib_exit(void) int lnet_dyn_del_ni(__u32 net) { - lnet_ni_t *ni; + struct lnet_ni *ni; struct lnet_ping_info *pinfo; struct lnet_handle_md md_handle; int rc; @@ -1888,7 +1888,7 @@ void lnet_lib_exit(void) struct libcfs_ioctl_data *data = arg; struct lnet_ioctl_config_data *config; lnet_process_id_t id = {0}; - lnet_ni_t *ni; + struct lnet_ni *ni; int rc; unsigned long secs_passed; @@ -2115,7 +2115,7 @@ void LNetDebugPeer(lnet_process_id_t id) if (index--) continue; - ni = list_entry(tmp, lnet_ni_t, ni_list); + ni = list_entry(tmp, struct lnet_ni, ni_list); id->nid = ni->ni_nid; id->pid = the_lnet.ln_pid; diff --git a/drivers/staging/lustre/lnet/lnet/config.c b/drivers/staging/lustre/lnet/lnet/config.c index 9e2183f..933988d 100644 --- a/drivers/staging/lustre/lnet/lnet/config.c +++ b/drivers/staging/lustre/lnet/lnet/config.c @@ -79,10 +79,10 @@ struct lnet_text_buf { /* tmp struct for parsing routes */ lnet_net_unique(__u32 net, struct list_head *nilist) { struct list_head *tmp; - lnet_ni_t *ni; + struct lnet_ni *ni; list_for_each(tmp, nilist) { - ni = list_entry(tmp, lnet_ni_t, ni_list); + ni = list_entry(tmp, struct lnet_ni, ni_list); if (LNET_NIDNET(ni->ni_nid) == net) return 0; @@ -120,7 +120,7 @@ struct lnet_text_buf { /* tmp struct for parsing routes */ LIBCFS_FREE(ni, sizeof(*ni)); } -lnet_ni_t * +struct lnet_ni * lnet_ni_alloc(__u32 net, struct cfs_expr_list *el, struct list_head *nilist) { struct lnet_tx_queue *tq; @@ -390,7 +390,7 @@ struct lnet_text_buf { /* tmp struct for parsing routes */ lnet_syntax("networks", networks, (int)(tmp - tokens), strlen(tmp)); failed: while (!list_empty(nilist)) { - ni = list_entry(nilist->next, lnet_ni_t, ni_list); + ni = list_entry(nilist->next, struct lnet_ni, ni_list); list_del(&ni->ni_list); lnet_ni_free(ni); diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c index f919732..3aabb32 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-move.c +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c @@ -364,7 +364,7 @@ EXPORT_SYMBOL(lnet_extract_kiov); void -lnet_ni_recv(lnet_ni_t *ni, void *private, struct lnet_msg *msg, +lnet_ni_recv(struct lnet_ni *ni, void *private, struct lnet_msg *msg, int delayed, unsigned int offset, unsigned int mlen, unsigned int rlen) { @@ -450,7 +450,7 @@ } static void -lnet_ni_send(lnet_ni_t *ni, struct lnet_msg *msg) +lnet_ni_send(struct lnet_ni *ni, struct lnet_msg *msg) { void *priv = msg->msg_private; int rc; @@ -465,7 +465,7 @@ } static int -lnet_ni_eager_recv(lnet_ni_t *ni, struct lnet_msg *msg) +lnet_ni_eager_recv(struct lnet_ni *ni, struct lnet_msg *msg) { int rc; @@ -489,7 +489,7 @@ /* NB: caller shall hold a ref on 'lp' as I'd drop lnet_net_lock */ static void -lnet_ni_query_locked(lnet_ni_t *ni, lnet_peer_t *lp) +lnet_ni_query_locked(struct lnet_ni *ni, lnet_peer_t *lp) { unsigned long last_alive = 0; @@ -599,7 +599,7 @@ lnet_post_send_locked(struct lnet_msg *msg, int do_send) { lnet_peer_t *lp = msg->msg_txpeer; - lnet_ni_t *ni = lp->lp_ni; + struct lnet_ni *ni = lp->lp_ni; int cpt = msg->msg_tx_cpt; struct lnet_tx_queue *tq = ni->ni_tx_queues[cpt]; @@ -995,7 +995,8 @@ } static lnet_peer_t * -lnet_find_route_locked(lnet_ni_t *ni, lnet_nid_t target, lnet_nid_t rtr_nid) +lnet_find_route_locked(struct lnet_ni *ni, lnet_nid_t target, + lnet_nid_t rtr_nid) { lnet_remotenet_t *rnet; lnet_route_t *route; @@ -1233,7 +1234,7 @@ } void -lnet_drop_message(lnet_ni_t *ni, int cpt, void *private, unsigned int nob) +lnet_drop_message(struct lnet_ni *ni, int cpt, void *private, unsigned int nob) { lnet_net_lock(cpt); the_lnet.ln_counters[cpt]->drop_count++; @@ -1244,7 +1245,7 @@ } static void -lnet_recv_put(lnet_ni_t *ni, struct lnet_msg *msg) +lnet_recv_put(struct lnet_ni *ni, struct lnet_msg *msg) { struct lnet_hdr *hdr = &msg->msg_hdr; @@ -1265,7 +1266,7 @@ } static int -lnet_parse_put(lnet_ni_t *ni, struct lnet_msg *msg) +lnet_parse_put(struct lnet_ni *ni, struct lnet_msg *msg) { struct lnet_hdr *hdr = &msg->msg_hdr; struct lnet_match_info info; @@ -1323,7 +1324,7 @@ } static int -lnet_parse_get(lnet_ni_t *ni, struct lnet_msg *msg, int rdma_get) +lnet_parse_get(struct lnet_ni *ni, struct lnet_msg *msg, int rdma_get) { struct lnet_match_info info; struct lnet_hdr *hdr = &msg->msg_hdr; @@ -1387,7 +1388,7 @@ } static int -lnet_parse_reply(lnet_ni_t *ni, struct lnet_msg *msg) +lnet_parse_reply(struct lnet_ni *ni, struct lnet_msg *msg) { void *private = msg->msg_private; struct lnet_hdr *hdr = &msg->msg_hdr; @@ -1452,7 +1453,7 @@ } static int -lnet_parse_ack(lnet_ni_t *ni, struct lnet_msg *msg) +lnet_parse_ack(struct lnet_ni *ni, struct lnet_msg *msg) { struct lnet_hdr *hdr = &msg->msg_hdr; lnet_process_id_t src = {0}; @@ -1507,7 +1508,7 @@ * \retval -ve error code */ int -lnet_parse_forward_locked(lnet_ni_t *ni, struct lnet_msg *msg) +lnet_parse_forward_locked(struct lnet_ni *ni, struct lnet_msg *msg) { int rc = 0; @@ -1531,7 +1532,7 @@ } int -lnet_parse_local(lnet_ni_t *ni, struct lnet_msg *msg) +lnet_parse_local(struct lnet_ni *ni, struct lnet_msg *msg) { int rc; @@ -1635,7 +1636,7 @@ } int -lnet_parse(lnet_ni_t *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid, +lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid, void *private, int rdma_req) { int rc = 0; @@ -2074,7 +2075,7 @@ EXPORT_SYMBOL(LNetPut); struct lnet_msg * -lnet_create_reply_msg(lnet_ni_t *ni, struct lnet_msg *getmsg) +lnet_create_reply_msg(struct lnet_ni *ni, struct lnet_msg *getmsg) { /* * The LND can DMA direct to the GET md (i.e. no REPLY msg). This @@ -2152,7 +2153,8 @@ struct lnet_msg * EXPORT_SYMBOL(lnet_create_reply_msg); void -lnet_set_reply_msg_len(lnet_ni_t *ni, struct lnet_msg *reply, unsigned int len) +lnet_set_reply_msg_len(struct lnet_ni *ni, struct lnet_msg *reply, + unsigned int len) { /* * Set the REPLY length, now the RDMA that elides the REPLY message has @@ -2307,7 +2309,7 @@ struct lnet_msg * cpt = lnet_net_lock_current(); list_for_each(e, &the_lnet.ln_nis) { - ni = list_entry(e, lnet_ni_t, ni_list); + ni = list_entry(e, struct lnet_ni, ni_list); if (ni->ni_nid == dstnid) { if (srcnidp) diff --git a/drivers/staging/lustre/lnet/lnet/lib-msg.c b/drivers/staging/lustre/lnet/lnet/lib-msg.c index bcb5e24..128c335 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-msg.c +++ b/drivers/staging/lustre/lnet/lnet/lib-msg.c @@ -437,7 +437,7 @@ } void -lnet_finalize(lnet_ni_t *ni, struct lnet_msg *msg, int status) +lnet_finalize(struct lnet_ni *ni, struct lnet_msg *msg, int status) { struct lnet_msg_container *container; int my_slot; diff --git a/drivers/staging/lustre/lnet/lnet/lo.c b/drivers/staging/lustre/lnet/lnet/lo.c index d11b4f9..a7504b8 100644 --- a/drivers/staging/lustre/lnet/lnet/lo.c +++ b/drivers/staging/lustre/lnet/lnet/lo.c @@ -32,7 +32,7 @@ #include "../../include/linux/lnet/lib-lnet.h" static int -lolnd_send(lnet_ni_t *ni, void *private, struct lnet_msg *lntmsg) +lolnd_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg) { LASSERT(!lntmsg->msg_routing); LASSERT(!lntmsg->msg_target_is_router); @@ -41,7 +41,7 @@ } static int -lolnd_recv(lnet_ni_t *ni, void *private, struct lnet_msg *lntmsg, +lolnd_recv(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg, int delayed, struct iov_iter *to, unsigned int rlen) { struct lnet_msg *sendmsg = private; @@ -70,7 +70,7 @@ static int lolnd_instanced; static void -lolnd_shutdown(lnet_ni_t *ni) +lolnd_shutdown(struct lnet_ni *ni) { CDEBUG(D_NET, "shutdown\n"); LASSERT(lolnd_instanced); @@ -79,7 +79,7 @@ } static int -lolnd_startup(lnet_ni_t *ni) +lolnd_startup(struct lnet_ni *ni) { LASSERT(ni->ni_lnd == &the_lolnd); LASSERT(!lolnd_instanced); diff --git a/drivers/staging/lustre/lnet/lnet/peer.c b/drivers/staging/lustre/lnet/lnet/peer.c index e806191..4b1a632 100644 --- a/drivers/staging/lustre/lnet/lnet/peer.c +++ b/drivers/staging/lustre/lnet/lnet/peer.c @@ -101,7 +101,8 @@ } static void -lnet_peer_table_cleanup_locked(lnet_ni_t *ni, struct lnet_peer_table *ptable) +lnet_peer_table_cleanup_locked(struct lnet_ni *ni, + struct lnet_peer_table *ptable) { int i; lnet_peer_t *lp; @@ -141,7 +142,8 @@ } static void -lnet_peer_table_del_rtrs_locked(lnet_ni_t *ni, struct lnet_peer_table *ptable, +lnet_peer_table_del_rtrs_locked(struct lnet_ni *ni, + struct lnet_peer_table *ptable, int cpt_locked) { lnet_peer_t *lp; @@ -168,7 +170,7 @@ } void -lnet_peer_tables_cleanup(lnet_ni_t *ni) +lnet_peer_tables_cleanup(struct lnet_ni *ni) { struct lnet_peer_table *ptable; struct list_head deathrow; diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c index eb14ce2..85fdd08 100644 --- a/drivers/staging/lustre/lnet/lnet/router.c +++ b/drivers/staging/lustre/lnet/lnet/router.c @@ -53,7 +53,7 @@ MODULE_PARM_DESC(auto_down, "Automatically mark peers down on comms error"); int -lnet_peer_buffer_credits(lnet_ni_t *ni) +lnet_peer_buffer_credits(struct lnet_ni *ni) { /* NI option overrides LNet default */ if (ni->ni_peerrtrcredits > 0) @@ -128,7 +128,7 @@ } static void -lnet_ni_notify_locked(lnet_ni_t *ni, lnet_peer_t *lp) +lnet_ni_notify_locked(struct lnet_ni *ni, lnet_peer_t *lp) { int alive; int notifylnd; @@ -241,7 +241,7 @@ static void lnet_shuffle_seed(void) static int seeded; __u32 lnd_type, seed[2]; struct timespec64 ts; - lnet_ni_t *ni; + struct lnet_ni *ni; struct list_head *tmp; if (seeded) @@ -254,7 +254,7 @@ static void lnet_shuffle_seed(void) * the NID for this node gives the most entropy in the low bits */ list_for_each(tmp, &the_lnet.ln_nis) { - ni = list_entry(tmp, lnet_ni_t, ni_list); + ni = list_entry(tmp, struct lnet_ni, ni_list); lnd_type = LNET_NETTYP(LNET_NIDNET(ni->ni_nid)); if (lnd_type != LOLND) @@ -302,7 +302,7 @@ static void lnet_shuffle_seed(void) lnet_remotenet_t *rnet; lnet_remotenet_t *rnet2; lnet_route_t *route; - lnet_ni_t *ni; + struct lnet_ni *ni; int add_route; int rc; @@ -838,7 +838,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) static void lnet_update_ni_status_locked(void) { - lnet_ni_t *ni; + struct lnet_ni *ni; time64_t now; int timeout; @@ -1740,7 +1740,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) } int -lnet_notify(lnet_ni_t *ni, lnet_nid_t nid, int alive, unsigned long when) +lnet_notify(struct lnet_ni *ni, lnet_nid_t nid, int alive, unsigned long when) { struct lnet_peer *lp = NULL; unsigned long now = cfs_time_current(); diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c index a19e140..672d71d 100644 --- a/drivers/staging/lustre/lnet/lnet/router_proc.c +++ b/drivers/staging/lustre/lnet/lnet/router_proc.c @@ -652,7 +652,7 @@ static int proc_lnet_nis(struct ctl_table *table, int write, LASSERT(tmpstr + tmpsiz - s > 0); } else { struct list_head *n; - lnet_ni_t *ni = NULL; + struct lnet_ni *ni = NULL; int skip = *ppos - 1; lnet_net_lock(0); @@ -660,8 +660,9 @@ static int proc_lnet_nis(struct ctl_table *table, int write, n = the_lnet.ln_nis.next; while (n != &the_lnet.ln_nis) { - lnet_ni_t *a_ni = list_entry(n, lnet_ni_t, ni_list); + struct lnet_ni *a_ni; + a_ni = list_entry(n, struct lnet_ni, ni_list); if (!skip) { ni = a_ni; break; -- 1.8.3.1 From jsimmons at infradead.org Mon Feb 27 00:41:48 2017 From: jsimmons at infradead.org (James Simmons) Date: Sun, 26 Feb 2017 19:41:48 -0500 Subject: [lustre-devel] [PATCH 23/34] staging: lustre: lnet: change lnet_counter_t to proper structure In-Reply-To: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> References: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> Message-ID: <1488156119-19670-24-git-send-email-jsimmons@infradead.org> Change lnet_counter_t from typedef to proper structure. Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/20831 Reviewed-by: Olaf Weber Reviewed-by: Doug Oucharek Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/include/linux/lnet/lib-lnet.h | 2 +- drivers/staging/lustre/include/linux/lnet/lib-types.h | 2 +- drivers/staging/lustre/include/linux/lnet/types.h | 4 ++-- drivers/staging/lustre/lnet/lnet/api-ni.c | 10 +++++----- drivers/staging/lustre/lnet/lnet/lib-msg.c | 6 +++--- drivers/staging/lustre/lnet/lnet/router_proc.c | 2 +- drivers/staging/lustre/lnet/selftest/console.c | 4 ++-- drivers/staging/lustre/lnet/selftest/rpc.h | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h index 4ffe79c..4a1e0a1 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h @@ -603,7 +603,7 @@ int lnet_delay_rule_list(int pos, struct lnet_fault_attr *attr, /** @} lnet_fault_simulation */ -void lnet_counters_get(lnet_counters_t *counters); +void lnet_counters_get(struct lnet_counters *counters); void lnet_counters_reset(void); unsigned int lnet_iov_nob(unsigned int niov, struct kvec *iov); diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index ffc961f..c98af93 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -573,7 +573,7 @@ struct lnet { struct cfs_percpt_lock *ln_net_lock; /* percpt message containers for active/finalizing/freed message */ struct lnet_msg_container **ln_msg_containers; - lnet_counters_t **ln_counters; + struct lnet_counters **ln_counters; struct lnet_peer_table **ln_peer_tables; /* failure simulation */ struct list_head ln_test_peers; diff --git a/drivers/staging/lustre/include/linux/lnet/types.h b/drivers/staging/lustre/include/linux/lnet/types.h index e81b079..d2af335 100644 --- a/drivers/staging/lustre/include/linux/lnet/types.h +++ b/drivers/staging/lustre/include/linux/lnet/types.h @@ -250,7 +250,7 @@ struct lnet_ping_info { struct lnet_ni_status pi_ni[0]; } WIRE_ATTR; -typedef struct lnet_counters { +struct lnet_counters { __u32 msgs_alloc; __u32 msgs_max; __u32 errors; @@ -262,7 +262,7 @@ struct lnet_ping_info { __u64 recv_length; __u64 route_length; __u64 drop_length; -} WIRE_ATTR lnet_counters_t; +} WIRE_ATTR; #define LNET_NI_STATUS_UP 0x15aac0de #define LNET_NI_STATUS_DOWN 0xdeadface diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index 024b8e3..34b9b10 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -315,9 +315,9 @@ static void lnet_assert_wire_constants(void) EXPORT_SYMBOL(lnet_unregister_lnd); void -lnet_counters_get(lnet_counters_t *counters) +lnet_counters_get(struct lnet_counters *counters) { - lnet_counters_t *ctr; + struct lnet_counters *ctr; int i; memset(counters, 0, sizeof(*counters)); @@ -344,13 +344,13 @@ static void lnet_assert_wire_constants(void) void lnet_counters_reset(void) { - lnet_counters_t *counters; + struct lnet_counters *counters; int i; lnet_net_lock(LNET_LOCK_EX); cfs_percpt_for_each(counters, i, the_lnet.ln_counters) - memset(counters, 0, sizeof(lnet_counters_t)); + memset(counters, 0, sizeof(struct lnet_counters)); lnet_net_unlock(LNET_LOCK_EX); } @@ -560,7 +560,7 @@ struct lnet_libhandle * the_lnet.ln_interface_cookie = ktime_get_ns(); the_lnet.ln_counters = cfs_percpt_alloc(lnet_cpt_table(), - sizeof(lnet_counters_t)); + sizeof(struct lnet_counters)); if (!the_lnet.ln_counters) { CERROR("Failed to allocate counters for LNet\n"); rc = -ENOMEM; diff --git a/drivers/staging/lustre/lnet/lnet/lib-msg.c b/drivers/staging/lustre/lnet/lnet/lib-msg.c index 128c335..4b5e3a8 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-msg.c +++ b/drivers/staging/lustre/lnet/lnet/lib-msg.c @@ -132,7 +132,7 @@ lnet_msg_commit(struct lnet_msg *msg, int cpt) { struct lnet_msg_container *container = the_lnet.ln_msg_containers[cpt]; - lnet_counters_t *counters = the_lnet.ln_counters[cpt]; + struct lnet_counters *counters = the_lnet.ln_counters[cpt]; /* routed message can be committed for both receiving and sending */ LASSERT(!msg->msg_tx_committed); @@ -164,7 +164,7 @@ static void lnet_msg_decommit_tx(struct lnet_msg *msg, int status) { - lnet_counters_t *counters; + struct lnet_counters *counters; lnet_event_t *ev = &msg->msg_ev; LASSERT(msg->msg_tx_committed); @@ -216,7 +216,7 @@ static void lnet_msg_decommit_rx(struct lnet_msg *msg, int status) { - lnet_counters_t *counters; + struct lnet_counters *counters; lnet_event_t *ev = &msg->msg_ev; LASSERT(!msg->msg_tx_committed); /* decommitted or never committed */ diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c index 0065cc1..72b80c5 100644 --- a/drivers/staging/lustre/lnet/lnet/router_proc.c +++ b/drivers/staging/lustre/lnet/lnet/router_proc.c @@ -77,7 +77,7 @@ static int __proc_lnet_stats(void *data, int write, loff_t pos, void __user *buffer, int nob) { int rc; - lnet_counters_t *ctrs; + struct lnet_counters *ctrs; int len; char *tmpstr; const int tmpsiz = 256; /* 7 %u and 4 %llu */ diff --git a/drivers/staging/lustre/lnet/selftest/console.c b/drivers/staging/lustre/lnet/selftest/console.c index 4e7e5c8..358cae8 100644 --- a/drivers/staging/lustre/lnet/selftest/console.c +++ b/drivers/staging/lustre/lnet/selftest/console.c @@ -1469,14 +1469,14 @@ static void lstcon_group_ndlink_release(struct lstcon_group *, struct srpc_stat_reply *rep = &msg->msg_body.stat_reply; struct sfw_counters __user *sfwk_stat; struct srpc_counters __user *srpc_stat; - lnet_counters_t __user *lnet_stat; + struct lnet_counters __user *lnet_stat; if (rep->str_status) return 0; sfwk_stat = (struct sfw_counters __user *)&ent_up->rpe_payload[0]; srpc_stat = (struct srpc_counters __user *)(sfwk_stat + 1); - lnet_stat = (lnet_counters_t __user *)(srpc_stat + 1); + lnet_stat = (struct lnet_counters __user *)(srpc_stat + 1); if (copy_to_user(sfwk_stat, &rep->str_fw, sizeof(*sfwk_stat)) || copy_to_user(srpc_stat, &rep->str_rpc, sizeof(*srpc_stat)) || diff --git a/drivers/staging/lustre/lnet/selftest/rpc.h b/drivers/staging/lustre/lnet/selftest/rpc.h index 418c9c9..a765537 100644 --- a/drivers/staging/lustre/lnet/selftest/rpc.h +++ b/drivers/staging/lustre/lnet/selftest/rpc.h @@ -163,7 +163,7 @@ struct srpc_stat_reply { struct lst_sid str_sid; struct sfw_counters str_fw; struct srpc_counters str_rpc; - lnet_counters_t str_lnet; + struct lnet_counters str_lnet; } WIRE_ATTR; struct test_bulk_req { -- 1.8.3.1 From jsimmons at infradead.org Mon Feb 27 00:41:30 2017 From: jsimmons at infradead.org (James Simmons) Date: Sun, 26 Feb 2017 19:41:30 -0500 Subject: [lustre-devel] [PATCH 05/34] staging: lustre: lnet: remove generic lnet_handle_any_t In-Reply-To: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> References: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> Message-ID: <1488156119-19670-6-git-send-email-jsimmons@infradead.org> With the creation of unique handlers we can remove the barely used generic handlers. Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/20831 Reviewed-by: Olaf Weber Reviewed-by: Doug Oucharek Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/include/linux/lnet/api.h | 1 - drivers/staging/lustre/include/linux/lnet/types.h | 41 ++--------------------- drivers/staging/lustre/lnet/lnet/api-ni.c | 11 ------ 3 files changed, 3 insertions(+), 50 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/api.h b/drivers/staging/lustre/include/linux/lnet/api.h index af756e8..2585dbb 100644 --- a/drivers/staging/lustre/include/linux/lnet/api.h +++ b/drivers/staging/lustre/include/linux/lnet/api.h @@ -76,7 +76,6 @@ */ int LNetGetId(unsigned int index, lnet_process_id_t *id); int LNetDist(lnet_nid_t nid, lnet_nid_t *srcnid, __u32 *order); -void LNetSnprintHandle(char *str, int str_len, lnet_handle_any_t handle); /** @} lnet_addr */ diff --git a/drivers/staging/lustre/include/linux/lnet/types.h b/drivers/staging/lustre/include/linux/lnet/types.h index 513ad6f..e81b079 100644 --- a/drivers/staging/lustre/include/linux/lnet/types.h +++ b/drivers/staging/lustre/include/linux/lnet/types.h @@ -272,48 +272,13 @@ struct lnet_ping_info { /** * Objects maintained by the LNet are accessed through handles. Handle types - * have names of the form lnet_handle_xx_t, where xx is one of the two letter + * have names of the form lnet_handle_xx, where xx is one of the two letter * object type codes ('eq' for event queue, 'md' for memory descriptor, and - * 'me' for match entry). - * Each type of object is given a unique handle type to enhance type checking. - * The type lnet_handle_any_t can be used when a generic handle is needed. - * Every handle value can be converted into a value of type lnet_handle_any_t - * without loss of information. + * 'me' for match entry). Each type of object is given a unique handle type + * to enhance type checking. */ -typedef struct { - __u64 cookie; -} lnet_handle_any_t; - #define LNET_WIRE_HANDLE_COOKIE_NONE (-1) -/** - * Invalidate handle \a h. - */ -static inline void LNetInvalidateHandle(lnet_handle_any_t *h) -{ - h->cookie = LNET_WIRE_HANDLE_COOKIE_NONE; -} - -/** - * Compare handles \a h1 and \a h2. - * - * \return 1 if handles are equal, 0 if otherwise. - */ -static inline int LNetHandleIsEqual(lnet_handle_any_t h1, lnet_handle_any_t h2) -{ - return h1.cookie == h2.cookie; -} - -/** - * Check whether handle \a h is invalid. - * - * \return 1 if handle is invalid, 0 if valid. - */ -static inline int LNetHandleIsInvalid(lnet_handle_any_t h) -{ - return h.cookie == LNET_WIRE_HANDLE_COOKIE_NONE; -} - struct lnet_handle_eq { u64 cookie; }; diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index a650fe0..efafd42 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -2127,17 +2127,6 @@ void LNetDebugPeer(lnet_process_id_t id) } EXPORT_SYMBOL(LNetGetId); -/** - * Print a string representation of handle \a h into buffer \a str of - * \a len bytes. - */ -void -LNetSnprintHandle(char *str, int len, lnet_handle_any_t h) -{ - snprintf(str, len, "%#llx", h.cookie); -} -EXPORT_SYMBOL(LNetSnprintHandle); - static int lnet_ping(lnet_process_id_t id, int timeout_ms, lnet_process_id_t __user *ids, int n_ids) { -- 1.8.3.1 From jsimmons at infradead.org Mon Feb 27 00:41:35 2017 From: jsimmons at infradead.org (James Simmons) Date: Sun, 26 Feb 2017 19:41:35 -0500 Subject: [lustre-devel] [PATCH 10/34] staging: lustre: lnet: change lnet_libmd_t to proper structure In-Reply-To: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> References: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> Message-ID: <1488156119-19670-11-git-send-email-jsimmons@infradead.org> Change lnet_libmd_t from typedef to proper structure. Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/20831 Reviewed-by: Olaf Weber Reviewed-by: Doug Oucharek Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- .../staging/lustre/include/linux/lnet/lib-lnet.h | 40 +++++++++++----------- .../staging/lustre/include/linux/lnet/lib-types.h | 4 +-- drivers/staging/lustre/lnet/lnet/api-ni.c | 2 +- drivers/staging/lustre/lnet/lnet/lib-md.c | 12 +++---- drivers/staging/lustre/lnet/lnet/lib-me.c | 4 +-- drivers/staging/lustre/lnet/lnet/lib-move.c | 6 ++-- drivers/staging/lustre/lnet/lnet/lib-msg.c | 6 ++-- drivers/staging/lustre/lnet/lnet/lib-ptl.c | 6 ++-- 8 files changed, 40 insertions(+), 40 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h index a82bb3c..685c5d4 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h @@ -84,14 +84,14 @@ static inline int lnet_is_wire_handle_none(struct lnet_handle_wire *wh) wh->wh_object_cookie == LNET_WIRE_HANDLE_COOKIE_NONE); } -static inline int lnet_md_exhausted(lnet_libmd_t *md) +static inline int lnet_md_exhausted(struct lnet_libmd *md) { return (!md->md_threshold || ((md->md_options & LNET_MD_MAX_SIZE) && md->md_offset + md->md_max_size > md->md_length)); } -static inline int lnet_md_unlinkable(lnet_libmd_t *md) +static inline int lnet_md_unlinkable(struct lnet_libmd *md) { /* * Should unlink md when its refcount is 0 and either: @@ -193,19 +193,19 @@ static inline int lnet_md_unlinkable(lnet_libmd_t *md) LIBCFS_FREE(eq, sizeof(*eq)); } -static inline lnet_libmd_t * +static inline struct lnet_libmd * lnet_md_alloc(lnet_md_t *umd) { - lnet_libmd_t *md; + struct lnet_libmd *md; unsigned int size; unsigned int niov; if (umd->options & LNET_MD_KIOV) { niov = umd->length; - size = offsetof(lnet_libmd_t, md_iov.kiov[niov]); + size = offsetof(struct lnet_libmd, md_iov.kiov[niov]); } else { niov = umd->options & LNET_MD_IOVEC ? umd->length : 1; - size = offsetof(lnet_libmd_t, md_iov.iov[niov]); + size = offsetof(struct lnet_libmd, md_iov.iov[niov]); } LIBCFS_ALLOC(md, size); @@ -221,14 +221,14 @@ static inline int lnet_md_unlinkable(lnet_libmd_t *md) } static inline void -lnet_md_free(lnet_libmd_t *md) +lnet_md_free(struct lnet_libmd *md) { unsigned int size; if (md->md_options & LNET_MD_KIOV) - size = offsetof(lnet_libmd_t, md_iov.kiov[md->md_niov]); + size = offsetof(struct lnet_libmd, md_iov.kiov[md->md_niov]); else - size = offsetof(lnet_libmd_t, md_iov.iov[md->md_niov]); + size = offsetof(struct lnet_libmd, md_iov.iov[md->md_niov]); LIBCFS_FREE(md, size); } @@ -301,12 +301,12 @@ void lnet_res_lh_initialize(struct lnet_res_container *rec, } static inline void -lnet_md2handle(struct lnet_handle_md *handle, lnet_libmd_t *md) +lnet_md2handle(struct lnet_handle_md *handle, struct lnet_libmd *md) { handle->cookie = md->md_lh.lh_cookie; } -static inline lnet_libmd_t * +static inline struct lnet_libmd * lnet_handle2md(struct lnet_handle_md *handle) { /* ALWAYS called with resource lock held */ @@ -319,10 +319,10 @@ void lnet_res_lh_initialize(struct lnet_res_container *rec, if (!lh) return NULL; - return lh_entry(lh, lnet_libmd_t, md_lh); + return lh_entry(lh, struct lnet_libmd, md_lh); } -static inline lnet_libmd_t * +static inline struct lnet_libmd * lnet_wire_handle2md(struct lnet_handle_wire *wh) { /* ALWAYS called with resource lock held */ @@ -338,7 +338,7 @@ void lnet_res_lh_initialize(struct lnet_res_container *rec, if (!lh) return NULL; - return lh_entry(lh, lnet_libmd_t, md_lh); + return lh_entry(lh, struct lnet_libmd, md_lh); } static inline void @@ -482,10 +482,10 @@ int lnet_dyn_add_ni(lnet_pid_t requested_pid, int lnet_islocalnid(lnet_nid_t nid); int lnet_islocalnet(__u32 net); -void lnet_msg_attach_md(struct lnet_msg *msg, lnet_libmd_t *md, +void lnet_msg_attach_md(struct lnet_msg *msg, struct lnet_libmd *md, unsigned int offset, unsigned int mlen); void lnet_msg_detach_md(struct lnet_msg *msg, int status); -void lnet_build_unlink_event(lnet_libmd_t *md, lnet_event_t *ev); +void lnet_build_unlink_event(struct lnet_libmd *md, lnet_event_t *ev); void lnet_build_msg_event(struct lnet_msg *msg, lnet_event_kind_t ev_type); void lnet_msg_commit(struct lnet_msg *msg, int cpt); void lnet_msg_decommit(struct lnet_msg *msg, int cpt, int status); @@ -542,9 +542,9 @@ int lnet_mt_match_md(struct lnet_match_table *mtable, struct lnet_match_info *info, struct lnet_msg *msg); /* portals match/attach functions */ -void lnet_ptl_attach_md(struct lnet_me *me, lnet_libmd_t *md, +void lnet_ptl_attach_md(struct lnet_me *me, struct lnet_libmd *md, struct list_head *matches, struct list_head *drops); -void lnet_ptl_detach_md(struct lnet_me *me, lnet_libmd_t *md); +void lnet_ptl_detach_md(struct lnet_me *me, struct lnet_libmd *md); int lnet_ptl_match_md(struct lnet_match_info *info, struct lnet_msg *msg); /* initialized and finalize portals */ @@ -625,8 +625,8 @@ void lnet_copy_kiov2iter(struct iov_iter *to, void lnet_me_unlink(struct lnet_me *me); -void lnet_md_unlink(lnet_libmd_t *md); -void lnet_md_deconstruct(lnet_libmd_t *lmd, lnet_md_t *umd); +void lnet_md_unlink(struct lnet_libmd *md); +void lnet_md_deconstruct(struct lnet_libmd *lmd, lnet_md_t *umd); void lnet_register_lnd(lnd_t *lnd); void lnet_unregister_lnd(lnd_t *lnd); diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index 3384860..6dd7edd 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -139,7 +139,7 @@ struct lnet_me { struct lnet_libmd *me_md; }; -typedef struct lnet_libmd { +struct lnet_libmd { struct list_head md_list; struct lnet_libhandle md_lh; struct lnet_me *md_me; @@ -158,7 +158,7 @@ struct lnet_me { struct kvec iov[LNET_MAX_IOV]; lnet_kiov_t kiov[LNET_MAX_IOV]; } md_iov; -} lnet_libmd_t; +}; #define LNET_MD_FLAG_ZOMBIE (1 << 0) #define LNET_MD_FLAG_AUTO_UNLINK (1 << 1) diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index ee47ba9..aeb9e6f 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -386,7 +386,7 @@ static void lnet_assert_wire_constants(void) lnet_eq_free(list_entry(e, struct lnet_eq, eq_list)); } else if (rec->rec_type == LNET_COOKIE_TYPE_MD) { - lnet_md_free(list_entry(e, lnet_libmd_t, md_list)); + lnet_md_free(list_entry(e, struct lnet_libmd, md_list)); } else { /* NB: Active MEs should be attached on portals */ LBUG(); diff --git a/drivers/staging/lustre/lnet/lnet/lib-md.c b/drivers/staging/lustre/lnet/lnet/lib-md.c index dd3cdda..bb832c5 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-md.c +++ b/drivers/staging/lustre/lnet/lnet/lib-md.c @@ -40,7 +40,7 @@ /* must be called with lnet_res_lock held */ void -lnet_md_unlink(lnet_libmd_t *md) +lnet_md_unlink(struct lnet_libmd *md) { if (!(md->md_flags & LNET_MD_FLAG_ZOMBIE)) { /* first unlink attempt... */ @@ -84,7 +84,7 @@ } static int -lnet_md_build(lnet_libmd_t *lmd, lnet_md_t *umd, int unlink) +lnet_md_build(struct lnet_libmd *lmd, lnet_md_t *umd, int unlink) { int i; unsigned int niov; @@ -165,7 +165,7 @@ /* must be called with resource lock held */ static int -lnet_md_link(lnet_libmd_t *md, struct lnet_handle_eq eq_handle, int cpt) +lnet_md_link(struct lnet_libmd *md, struct lnet_handle_eq eq_handle, int cpt) { struct lnet_res_container *container = the_lnet.ln_md_containers[cpt]; @@ -204,7 +204,7 @@ /* must be called with lnet_res_lock held */ void -lnet_md_deconstruct(lnet_libmd_t *lmd, lnet_md_t *umd) +lnet_md_deconstruct(struct lnet_libmd *lmd, lnet_md_t *umd) { /* NB this doesn't copy out all the iov entries so when a * discontiguous MD is copied out, the target gets to know the @@ -353,7 +353,7 @@ LNetMDBind(lnet_md_t umd, lnet_unlink_t unlink, struct lnet_handle_md *handle) { - lnet_libmd_t *md; + struct lnet_libmd *md; int cpt; int rc; @@ -429,7 +429,7 @@ LNetMDUnlink(struct lnet_handle_md mdh) { lnet_event_t ev; - lnet_libmd_t *md; + struct lnet_libmd *md; int cpt; LASSERT(the_lnet.ln_refcount > 0); diff --git a/drivers/staging/lustre/lnet/lnet/lib-me.c b/drivers/staging/lustre/lnet/lnet/lib-me.c index 20cc8f8..75922a5 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-me.c +++ b/drivers/staging/lustre/lnet/lnet/lib-me.c @@ -223,7 +223,7 @@ LNetMEUnlink(struct lnet_handle_me meh) { struct lnet_me *me; - lnet_libmd_t *md; + struct lnet_libmd *md; lnet_event_t ev; int cpt; @@ -261,7 +261,7 @@ list_del(&me->me_list); if (me->me_md) { - lnet_libmd_t *md = me->me_md; + struct lnet_libmd *md = me->me_md; /* detach MD from portal of this ME */ lnet_ptl_detach_md(me, md); diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c index a789d7e..a55b58e 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-move.c +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c @@ -412,7 +412,7 @@ static void lnet_setpayloadbuffer(struct lnet_msg *msg) { - lnet_libmd_t *md = msg->msg_md; + struct lnet_libmd *md = msg->msg_md; LASSERT(msg->msg_len > 0); LASSERT(!msg->msg_routing); @@ -1392,7 +1392,7 @@ void *private = msg->msg_private; struct lnet_hdr *hdr = &msg->msg_hdr; lnet_process_id_t src = {0}; - lnet_libmd_t *md; + struct lnet_libmd *md; int rlength; int mlength; int cpt; @@ -1456,7 +1456,7 @@ { struct lnet_hdr *hdr = &msg->msg_hdr; lnet_process_id_t src = {0}; - lnet_libmd_t *md; + struct lnet_libmd *md; int cpt; src.nid = hdr->src_nid; diff --git a/drivers/staging/lustre/lnet/lnet/lib-msg.c b/drivers/staging/lustre/lnet/lnet/lib-msg.c index d35d28b..bcb5e24 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-msg.c +++ b/drivers/staging/lustre/lnet/lnet/lib-msg.c @@ -39,7 +39,7 @@ #include "../../include/linux/lnet/lib-lnet.h" void -lnet_build_unlink_event(lnet_libmd_t *md, lnet_event_t *ev) +lnet_build_unlink_event(struct lnet_libmd *md, lnet_event_t *ev) { memset(ev, 0, sizeof(*ev)); @@ -306,7 +306,7 @@ } void -lnet_msg_attach_md(struct lnet_msg *msg, lnet_libmd_t *md, +lnet_msg_attach_md(struct lnet_msg *msg, struct lnet_libmd *md, unsigned int offset, unsigned int mlen) { /* NB: @offset and @len are only useful for receiving */ @@ -338,7 +338,7 @@ void lnet_msg_detach_md(struct lnet_msg *msg, int status) { - lnet_libmd_t *md = msg->msg_md; + struct lnet_libmd *md = msg->msg_md; int unlink; /* Now it's safe to drop my caller's ref */ diff --git a/drivers/staging/lustre/lnet/lnet/lib-ptl.c b/drivers/staging/lustre/lnet/lnet/lib-ptl.c index b538939..9ea3c08 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-ptl.c +++ b/drivers/staging/lustre/lnet/lnet/lib-ptl.c @@ -131,7 +131,7 @@ } static int -lnet_try_match_md(lnet_libmd_t *md, +lnet_try_match_md(struct lnet_libmd *md, struct lnet_match_info *info, struct lnet_msg *msg) { /* @@ -641,7 +641,7 @@ struct list_head * } void -lnet_ptl_detach_md(struct lnet_me *me, lnet_libmd_t *md) +lnet_ptl_detach_md(struct lnet_me *me, struct lnet_libmd *md) { LASSERT(me->me_md == md && md->md_me == me); @@ -651,7 +651,7 @@ struct list_head * /* called with lnet_res_lock held */ void -lnet_ptl_attach_md(struct lnet_me *me, lnet_libmd_t *md, +lnet_ptl_attach_md(struct lnet_me *me, struct lnet_libmd *md, struct list_head *matches, struct list_head *drops) { struct lnet_portal *ptl = the_lnet.ln_portals[me->me_portal]; -- 1.8.3.1 From jsimmons at infradead.org Mon Feb 27 00:41:53 2017 From: jsimmons at infradead.org (James Simmons) Date: Sun, 26 Feb 2017 19:41:53 -0500 Subject: [lustre-devel] [PATCH 28/34] staging: lustre: lnet: change lnet_unlink_t to proper enum In-Reply-To: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> References: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> Message-ID: <1488156119-19670-29-git-send-email-jsimmons@infradead.org> Change lnet_unlink_t from typedef to proper enum. Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/20831 Reviewed-by: Olaf Weber Reviewed-by: Doug Oucharek Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/include/linux/lnet/api.h | 8 ++++---- drivers/staging/lustre/include/linux/lnet/lib-types.h | 2 +- drivers/staging/lustre/include/linux/lnet/types.h | 4 ++-- drivers/staging/lustre/lnet/lnet/lib-md.c | 4 ++-- drivers/staging/lustre/lnet/lnet/lib-me.c | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/api.h b/drivers/staging/lustre/include/linux/lnet/api.h index 7a67fd2..5537097 100644 --- a/drivers/staging/lustre/include/linux/lnet/api.h +++ b/drivers/staging/lustre/include/linux/lnet/api.h @@ -96,7 +96,7 @@ int LNetMEAttach(unsigned int portal, struct lnet_process_id match_id_in, __u64 match_bits_in, __u64 ignore_bits_in, - lnet_unlink_t unlink_in, + enum lnet_unlink unlink_in, lnet_ins_pos_t pos_in, struct lnet_handle_me *handle_out); @@ -104,7 +104,7 @@ int LNetMEInsert(struct lnet_handle_me current_in, struct lnet_process_id match_id_in, __u64 match_bits_in, __u64 ignore_bits_in, - lnet_unlink_t unlink_in, + enum lnet_unlink unlink_in, lnet_ins_pos_t position_in, struct lnet_handle_me *handle_out); @@ -126,11 +126,11 @@ int LNetMEInsert(struct lnet_handle_me current_in, */ int LNetMDAttach(struct lnet_handle_me current_in, struct lnet_md md_in, - lnet_unlink_t unlink_in, + enum lnet_unlink unlink_in, struct lnet_handle_md *md_handle_out); int LNetMDBind(struct lnet_md md_in, - lnet_unlink_t unlink_in, + enum lnet_unlink unlink_in, struct lnet_handle_md *md_handle_out); int LNetMDUnlink(struct lnet_handle_md md_in); diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index 81c93d4..b9f1bd2 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -135,7 +135,7 @@ struct lnet_me { unsigned int me_pos; /* hash offset in mt_hash */ __u64 me_match_bits; __u64 me_ignore_bits; - lnet_unlink_t me_unlink; + enum lnet_unlink me_unlink; struct lnet_libmd *me_md; }; diff --git a/drivers/staging/lustre/include/linux/lnet/types.h b/drivers/staging/lustre/include/linux/lnet/types.h index 6a24189..9010895 100644 --- a/drivers/staging/lustre/include/linux/lnet/types.h +++ b/drivers/staging/lustre/include/linux/lnet/types.h @@ -346,10 +346,10 @@ struct lnet_process_id { * Specifies whether the match entry or memory descriptor should be unlinked * automatically (LNET_UNLINK) or not (LNET_RETAIN). */ -typedef enum { +enum lnet_unlink { LNET_RETAIN = 0, LNET_UNLINK -} lnet_unlink_t; +}; /** * Values of the type lnet_ins_pos_t are used to control where a new match diff --git a/drivers/staging/lustre/lnet/lnet/lib-md.c b/drivers/staging/lustre/lnet/lnet/lib-md.c index 872f63f..f08e944 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-md.c +++ b/drivers/staging/lustre/lnet/lnet/lib-md.c @@ -268,7 +268,7 @@ */ int LNetMDAttach(struct lnet_handle_me meh, struct lnet_md umd, - lnet_unlink_t unlink, struct lnet_handle_md *handle) + enum lnet_unlink unlink, struct lnet_handle_md *handle) { LIST_HEAD(matches); LIST_HEAD(drops); @@ -350,7 +350,7 @@ * LNetInvalidateHandle() on it. */ int -LNetMDBind(struct lnet_md umd, lnet_unlink_t unlink, +LNetMDBind(struct lnet_md umd, enum lnet_unlink unlink, struct lnet_handle_md *handle) { struct lnet_libmd *md; diff --git a/drivers/staging/lustre/lnet/lnet/lib-me.c b/drivers/staging/lustre/lnet/lnet/lib-me.c index d8f40de..a944f1f 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-me.c +++ b/drivers/staging/lustre/lnet/lnet/lib-me.c @@ -72,7 +72,7 @@ LNetMEAttach(unsigned int portal, struct lnet_process_id match_id, __u64 match_bits, __u64 ignore_bits, - lnet_unlink_t unlink, lnet_ins_pos_t pos, + enum lnet_unlink unlink, lnet_ins_pos_t pos, struct lnet_handle_me *handle) { struct lnet_match_table *mtable; @@ -143,7 +143,7 @@ LNetMEInsert(struct lnet_handle_me current_meh, struct lnet_process_id match_id, __u64 match_bits, __u64 ignore_bits, - lnet_unlink_t unlink, lnet_ins_pos_t pos, + enum lnet_unlink unlink, lnet_ins_pos_t pos, struct lnet_handle_me *handle) { struct lnet_me *current_me; -- 1.8.3.1 From jsimmons at infradead.org Mon Feb 27 00:41:36 2017 From: jsimmons at infradead.org (James Simmons) Date: Sun, 26 Feb 2017 19:41:36 -0500 Subject: [lustre-devel] [PATCH 11/34] staging: lustre: lnet: change lnet_test_peer_t to proper structure In-Reply-To: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> References: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> Message-ID: <1488156119-19670-12-git-send-email-jsimmons@infradead.org> Change lnet_test_peer_t from typedef to proper structure. Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/20831 Reviewed-by: Olaf Weber Reviewed-by: Doug Oucharek Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/include/linux/lnet/lib-types.h | 4 ++-- drivers/staging/lustre/lnet/lnet/lib-move.c | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index 6dd7edd..59d7143 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -164,12 +164,12 @@ struct lnet_libmd { #define LNET_MD_FLAG_AUTO_UNLINK (1 << 1) #define LNET_MD_FLAG_ABORTED (1 << 2) -typedef struct { +struct lnet_test_peer { /* info about peers we are trying to fail */ struct list_head tp_list; /* ln_test_peers */ lnet_nid_t tp_nid; /* matching nid */ unsigned int tp_threshold; /* # failures to simulate */ -} lnet_test_peer_t; +}; #define LNET_COOKIE_TYPE_MD 1 #define LNET_COOKIE_TYPE_ME 2 diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c index a55b58e..f919732 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-move.c +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c @@ -47,8 +47,8 @@ int lnet_fail_nid(lnet_nid_t nid, unsigned int threshold) { - lnet_test_peer_t *tp; - lnet_test_peer_t *temp; + struct lnet_test_peer *tp; + struct lnet_test_peer *temp; struct list_head *el; struct list_head *next; struct list_head cull; @@ -75,7 +75,7 @@ lnet_net_lock(0); list_for_each_safe(el, next, &the_lnet.ln_test_peers) { - tp = list_entry(el, lnet_test_peer_t, tp_list); + tp = list_entry(el, struct lnet_test_peer, tp_list); if (!tp->tp_threshold || /* needs culling anyway */ nid == LNET_NID_ANY || /* removing all entries */ @@ -97,8 +97,8 @@ static int fail_peer(lnet_nid_t nid, int outgoing) { - lnet_test_peer_t *tp; - lnet_test_peer_t *temp; + struct lnet_test_peer *tp; + struct lnet_test_peer *temp; struct list_head *el; struct list_head *next; struct list_head cull; @@ -110,7 +110,7 @@ lnet_net_lock(0); list_for_each_safe(el, next, &the_lnet.ln_test_peers) { - tp = list_entry(el, lnet_test_peer_t, tp_list); + tp = list_entry(el, struct lnet_test_peer, tp_list); if (!tp->tp_threshold) { /* zombie entry */ -- 1.8.3.1 From jsimmons at infradead.org Mon Feb 27 00:41:40 2017 From: jsimmons at infradead.org (James Simmons) Date: Sun, 26 Feb 2017 19:41:40 -0500 Subject: [lustre-devel] [PATCH 15/34] staging: lustre: lnet: change lnet_peer_t to proper structure In-Reply-To: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> References: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> Message-ID: <1488156119-19670-16-git-send-email-jsimmons@infradead.org> Change lnet_peer_t from typedef to proper structure. Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/20831 Reviewed-by: Olaf Weber Reviewed-by: Doug Oucharek Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- .../staging/lustre/include/linux/lnet/lib-lnet.h | 20 +++++++-------- .../staging/lustre/include/linux/lnet/lib-types.h | 6 ++--- drivers/staging/lustre/lnet/lnet/lib-move.c | 20 +++++++-------- drivers/staging/lustre/lnet/lnet/peer.c | 30 +++++++++++----------- drivers/staging/lustre/lnet/lnet/router.c | 30 +++++++++++----------- drivers/staging/lustre/lnet/lnet/router_proc.c | 10 +++++--- 6 files changed, 59 insertions(+), 57 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h index 3d5913d..bcfbed1 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h @@ -364,16 +364,16 @@ void lnet_res_lh_initialize(struct lnet_res_container *rec, } static inline void -lnet_peer_addref_locked(lnet_peer_t *lp) +lnet_peer_addref_locked(struct lnet_peer *lp) { LASSERT(lp->lp_refcount > 0); lp->lp_refcount++; } -void lnet_destroy_peer_locked(lnet_peer_t *lp); +void lnet_destroy_peer_locked(struct lnet_peer *lp); static inline void -lnet_peer_decref_locked(lnet_peer_t *lp) +lnet_peer_decref_locked(struct lnet_peer *lp) { LASSERT(lp->lp_refcount > 0); lp->lp_refcount--; @@ -382,7 +382,7 @@ void lnet_res_lh_initialize(struct lnet_res_container *rec, } static inline int -lnet_isrouter(lnet_peer_t *lp) +lnet_isrouter(struct lnet_peer *lp) { return lp->lp_rtr_refcount ? 1 : 0; } @@ -454,7 +454,7 @@ struct lnet_ni * void lnet_lib_exit(void); int lnet_notify(struct lnet_ni *ni, lnet_nid_t peer, int alive, unsigned long when); -void lnet_notify_locked(lnet_peer_t *lp, int notifylnd, int alive, +void lnet_notify_locked(struct lnet_peer *lp, int notifylnd, int alive, unsigned long when); int lnet_add_route(__u32 net, __u32 hops, lnet_nid_t gateway_nid, unsigned int priority); @@ -666,7 +666,7 @@ int lnet_sock_connect(struct socket **sockp, int *fatal, int lnet_router_checker_start(void); void lnet_router_checker_stop(void); -void lnet_router_ni_update_locked(lnet_peer_t *gw, __u32 net); +void lnet_router_ni_update_locked(struct lnet_peer *gw, __u32 net); void lnet_swap_pinginfo(struct lnet_ping_info *info); int lnet_parse_ip2nets(char **networksp, char *ip2nets); @@ -674,9 +674,9 @@ int lnet_sock_connect(struct socket **sockp, int *fatal, int lnet_parse_networks(struct list_head *nilist, char *networks); int lnet_net_unique(__u32 net, struct list_head *nilist); -int lnet_nid2peer_locked(lnet_peer_t **lpp, lnet_nid_t nid, int cpt); -lnet_peer_t *lnet_find_peer_locked(struct lnet_peer_table *ptable, - lnet_nid_t nid); +int lnet_nid2peer_locked(struct lnet_peer **lpp, lnet_nid_t nid, int cpt); +struct lnet_peer *lnet_find_peer_locked(struct lnet_peer_table *ptable, + lnet_nid_t nid); void lnet_peer_tables_cleanup(struct lnet_ni *ni); void lnet_peer_tables_destroy(void); int lnet_peer_tables_create(void); @@ -689,7 +689,7 @@ int lnet_get_peer_info(__u32 peer_index, __u64 *nid, __u32 *peer_tx_qnob); static inline void -lnet_peer_set_alive(lnet_peer_t *lp) +lnet_peer_set_alive(struct lnet_peer *lp) { lp->lp_last_query = jiffies; lp->lp_last_alive = jiffies; diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index 10bf60f..2cfc1bf 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -305,7 +305,7 @@ struct lnet_rc_data { struct lnet_ping_info *rcd_pinginfo; /* ping buffer */ }; -typedef struct lnet_peer { +struct lnet_peer { struct list_head lp_hashlist; /* chain on peer hash */ struct list_head lp_txq; /* messages blocking for tx credits */ @@ -346,7 +346,7 @@ struct lnet_rc_data { unsigned int lp_ping_feats; struct list_head lp_routes; /* routers on this peer */ struct lnet_rc_data *lp_rcd; /* router checker state */ -} lnet_peer_t; +}; /* peer hash size */ #define LNET_PEER_HASH_BITS 9 @@ -372,7 +372,7 @@ struct lnet_peer_table { typedef struct { struct list_head lr_list; /* chain on net */ struct list_head lr_gwlist; /* chain on gateway */ - lnet_peer_t *lr_gateway; /* router node */ + struct lnet_peer *lr_gateway; /* router node */ __u32 lr_net; /* remote network number */ int lr_seq; /* sequence for round-robin */ unsigned int lr_downis; /* number of down NIs */ diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c index 3aabb32..9615dcd 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-move.c +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c @@ -489,7 +489,7 @@ /* NB: caller shall hold a ref on 'lp' as I'd drop lnet_net_lock */ static void -lnet_ni_query_locked(struct lnet_ni *ni, lnet_peer_t *lp) +lnet_ni_query_locked(struct lnet_ni *ni, struct lnet_peer *lp) { unsigned long last_alive = 0; @@ -508,7 +508,7 @@ /* NB: always called with lnet_net_lock held */ static inline int -lnet_peer_is_alive(lnet_peer_t *lp, unsigned long now) +lnet_peer_is_alive(struct lnet_peer *lp, unsigned long now) { int alive; unsigned long deadline; @@ -542,7 +542,7 @@ * may drop the lnet_net_lock */ static int -lnet_peer_alive_locked(lnet_peer_t *lp) +lnet_peer_alive_locked(struct lnet_peer *lp) { unsigned long now = cfs_time_current(); @@ -598,7 +598,7 @@ static int lnet_post_send_locked(struct lnet_msg *msg, int do_send) { - lnet_peer_t *lp = msg->msg_txpeer; + struct lnet_peer *lp = msg->msg_txpeer; struct lnet_ni *ni = lp->lp_ni; int cpt = msg->msg_tx_cpt; struct lnet_tx_queue *tq = ni->ni_tx_queues[cpt]; @@ -709,7 +709,7 @@ * I return LNET_CREDIT_WAIT if msg blocked and LNET_CREDIT_OK if * received or OK to receive */ - lnet_peer_t *lp = msg->msg_rxpeer; + struct lnet_peer *lp = msg->msg_rxpeer; lnet_rtrbufpool_t *rbp; lnet_rtrbuf_t *rb; @@ -779,7 +779,7 @@ void lnet_return_tx_credits_locked(struct lnet_msg *msg) { - lnet_peer_t *txpeer = msg->msg_txpeer; + struct lnet_peer *txpeer = msg->msg_txpeer; struct lnet_msg *msg2; if (msg->msg_txcredit) { @@ -874,7 +874,7 @@ void lnet_return_rx_credits_locked(struct lnet_msg *msg) { - lnet_peer_t *rxpeer = msg->msg_rxpeer; + struct lnet_peer *rxpeer = msg->msg_rxpeer; struct lnet_msg *msg2; if (msg->msg_rtrcredit) { @@ -959,8 +959,8 @@ static int lnet_compare_routes(lnet_route_t *r1, lnet_route_t *r2) { - lnet_peer_t *p1 = r1->lr_gateway; - lnet_peer_t *p2 = r2->lr_gateway; + struct lnet_peer *p1 = r1->lr_gateway; + struct lnet_peer *p2 = r2->lr_gateway; int r1_hops = (r1->lr_hops == LNET_UNDEFINED_HOPS) ? 1 : r1->lr_hops; int r2_hops = (r2->lr_hops == LNET_UNDEFINED_HOPS) ? 1 : r2->lr_hops; @@ -994,7 +994,7 @@ return -ERANGE; } -static lnet_peer_t * +static struct lnet_peer * lnet_find_route_locked(struct lnet_ni *ni, lnet_nid_t target, lnet_nid_t rtr_nid) { diff --git a/drivers/staging/lustre/lnet/lnet/peer.c b/drivers/staging/lustre/lnet/lnet/peer.c index 4b1a632..e62b21f 100644 --- a/drivers/staging/lustre/lnet/lnet/peer.c +++ b/drivers/staging/lustre/lnet/lnet/peer.c @@ -105,8 +105,8 @@ struct lnet_peer_table *ptable) { int i; - lnet_peer_t *lp; - lnet_peer_t *tmp; + struct lnet_peer *lp; + struct lnet_peer *tmp; for (i = 0; i < LNET_PEER_HASH_SIZE; i++) { list_for_each_entry_safe(lp, tmp, &ptable->pt_hash[i], @@ -146,8 +146,8 @@ struct lnet_peer_table *ptable, int cpt_locked) { - lnet_peer_t *lp; - lnet_peer_t *tmp; + struct lnet_peer *lp; + struct lnet_peer *tmp; lnet_nid_t lp_nid; int i; @@ -174,8 +174,8 @@ { struct lnet_peer_table *ptable; struct list_head deathrow; - lnet_peer_t *lp; - lnet_peer_t *temp; + struct lnet_peer *lp; + struct lnet_peer *temp; int i; INIT_LIST_HEAD(&deathrow); @@ -216,7 +216,7 @@ } void -lnet_destroy_peer_locked(lnet_peer_t *lp) +lnet_destroy_peer_locked(struct lnet_peer *lp) { struct lnet_peer_table *ptable; @@ -238,11 +238,11 @@ ptable->pt_zombies--; } -lnet_peer_t * +struct lnet_peer * lnet_find_peer_locked(struct lnet_peer_table *ptable, lnet_nid_t nid) { struct list_head *peers; - lnet_peer_t *lp; + struct lnet_peer *lp; LASSERT(!the_lnet.ln_shutdown); @@ -258,11 +258,11 @@ } int -lnet_nid2peer_locked(lnet_peer_t **lpp, lnet_nid_t nid, int cpt) +lnet_nid2peer_locked(struct lnet_peer **lpp, lnet_nid_t nid, int cpt) { struct lnet_peer_table *ptable; - lnet_peer_t *lp = NULL; - lnet_peer_t *lp2; + struct lnet_peer *lp = NULL; + struct lnet_peer *lp2; int cpt2; int rc = 0; @@ -282,7 +282,7 @@ if (!list_empty(&ptable->pt_deathrow)) { lp = list_entry(ptable->pt_deathrow.next, - lnet_peer_t, lp_hashlist); + struct lnet_peer, lp_hashlist); list_del(&lp->lp_hashlist); } @@ -364,7 +364,7 @@ lnet_debug_peer(lnet_nid_t nid) { char *aliveness = "NA"; - lnet_peer_t *lp; + struct lnet_peer *lp; int rc; int cpt; @@ -401,7 +401,7 @@ __u32 *peer_tx_qnob) { struct lnet_peer_table *peer_table; - lnet_peer_t *lp; + struct lnet_peer *lp; bool found = false; int lncpt, j; diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c index c73d7a0..eda829a 100644 --- a/drivers/staging/lustre/lnet/lnet/router.c +++ b/drivers/staging/lustre/lnet/lnet/router.c @@ -98,7 +98,7 @@ } void -lnet_notify_locked(lnet_peer_t *lp, int notifylnd, int alive, +lnet_notify_locked(struct lnet_peer *lp, int notifylnd, int alive, unsigned long when) { if (time_before(when, lp->lp_timestamp)) { /* out of date information */ @@ -128,7 +128,7 @@ } static void -lnet_ni_notify_locked(struct lnet_ni *ni, lnet_peer_t *lp) +lnet_ni_notify_locked(struct lnet_ni *ni, struct lnet_peer *lp) { int alive; int notifylnd; @@ -167,7 +167,7 @@ } static void -lnet_rtr_addref_locked(lnet_peer_t *lp) +lnet_rtr_addref_locked(struct lnet_peer *lp) { LASSERT(lp->lp_refcount > 0); LASSERT(lp->lp_rtr_refcount >= 0); @@ -179,9 +179,9 @@ /* a simple insertion sort */ list_for_each_prev(pos, &the_lnet.ln_routers) { - lnet_peer_t *rtr = list_entry(pos, lnet_peer_t, - lp_rtr_list); + struct lnet_peer *rtr; + rtr = list_entry(pos, struct lnet_peer, lp_rtr_list); if (rtr->lp_nid < lp->lp_nid) break; } @@ -194,7 +194,7 @@ } static void -lnet_rtr_decref_locked(lnet_peer_t *lp) +lnet_rtr_decref_locked(struct lnet_peer *lp) { LASSERT(lp->lp_refcount > 0); LASSERT(lp->lp_rtr_refcount > 0); @@ -791,7 +791,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) static void lnet_wait_known_routerstate(void) { - lnet_peer_t *rtr; + struct lnet_peer *rtr; struct list_head *entry; int all_known; @@ -802,7 +802,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) all_known = 1; list_for_each(entry, &the_lnet.ln_routers) { - rtr = list_entry(entry, lnet_peer_t, lp_rtr_list); + rtr = list_entry(entry,struct lnet_peer, lp_rtr_list); if (!rtr->lp_alive_count) { all_known = 0; @@ -821,7 +821,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) } void -lnet_router_ni_update_locked(lnet_peer_t *gw, __u32 net) +lnet_router_ni_update_locked(struct lnet_peer *gw, __u32 net) { lnet_route_t *rte; @@ -899,7 +899,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) } static struct lnet_rc_data * -lnet_create_rc_data_locked(lnet_peer_t *gateway) +lnet_create_rc_data_locked(struct lnet_peer *gateway) { struct lnet_rc_data *rcd = NULL; struct lnet_ping_info *pi; @@ -969,7 +969,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) } static int -lnet_router_check_interval(lnet_peer_t *rtr) +lnet_router_check_interval(struct lnet_peer *rtr) { int secs; @@ -982,7 +982,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) } static void -lnet_ping_router_locked(lnet_peer_t *rtr) +lnet_ping_router_locked(struct lnet_peer *rtr) { struct lnet_rc_data *rcd = NULL; unsigned long now = cfs_time_current(); @@ -1126,7 +1126,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) { struct lnet_rc_data *rcd; struct lnet_rc_data *tmp; - lnet_peer_t *lp; + struct lnet_peer *lp; struct list_head head; int i = 2; @@ -1232,7 +1232,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) static int lnet_router_checker(void *arg) { - lnet_peer_t *rtr; + struct lnet_peer *rtr; struct list_head *entry; cfs_block_allsigs(); @@ -1247,7 +1247,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) version = the_lnet.ln_routers_version; list_for_each(entry, &the_lnet.ln_routers) { - rtr = list_entry(entry, lnet_peer_t, lp_rtr_list); + rtr = list_entry(entry, struct lnet_peer, lp_rtr_list); cpt2 = lnet_cpt_of_nid_locked(rtr->lp_nid); if (cpt != cpt2) { diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c index 672d71d..e672148 100644 --- a/drivers/staging/lustre/lnet/lnet/router_proc.c +++ b/drivers/staging/lustre/lnet/lnet/router_proc.c @@ -307,9 +307,9 @@ static int proc_lnet_routers(struct ctl_table *table, int write, r = the_lnet.ln_routers.next; while (r != &the_lnet.ln_routers) { - lnet_peer_t *lp = list_entry(r, lnet_peer_t, - lp_rtr_list); + struct lnet_peer *lp; + lp = list_entry(r, struct lnet_peer, lp_rtr_list); if (!skip) { peer = lp; break; @@ -454,8 +454,10 @@ static int proc_lnet_peers(struct ctl_table *table, int write, p = ptable->pt_hash[hash].next; while (p != &ptable->pt_hash[hash]) { - lnet_peer_t *lp = list_entry(p, lnet_peer_t, - lp_hashlist); + struct lnet_peer *lp; + + lp = list_entry(p, struct lnet_peer, + lp_hashlist); if (!skip) { peer = lp; -- 1.8.3.1 From jsimmons at infradead.org Mon Feb 27 00:41:32 2017 From: jsimmons at infradead.org (James Simmons) Date: Sun, 26 Feb 2017 19:41:32 -0500 Subject: [lustre-devel] [PATCH 07/34] staging: lustre: lnet: change lnet_libhandle_t to proper structure In-Reply-To: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> References: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> Message-ID: <1488156119-19670-8-git-send-email-jsimmons@infradead.org> Change lnet_libhandle_t from typedef to proper structure. Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/20831 Reviewed-by: Olaf Weber Reviewed-by: Doug Oucharek Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/include/linux/lnet/lib-lnet.h | 16 ++++++++-------- drivers/staging/lustre/include/linux/lnet/lib-types.h | 10 +++++----- drivers/staging/lustre/lnet/lnet/api-ni.c | 7 ++++--- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h index e894990..1c147b3 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h @@ -266,12 +266,12 @@ static inline int lnet_md_unlinkable(lnet_libmd_t *md) LIBCFS_FREE(msg, sizeof(*msg)); } -lnet_libhandle_t *lnet_res_lh_lookup(struct lnet_res_container *rec, - __u64 cookie); +struct lnet_libhandle *lnet_res_lh_lookup(struct lnet_res_container *rec, + __u64 cookie); void lnet_res_lh_initialize(struct lnet_res_container *rec, - lnet_libhandle_t *lh); + struct lnet_libhandle *lh); static inline void -lnet_res_lh_invalidate(lnet_libhandle_t *lh) +lnet_res_lh_invalidate(struct lnet_libhandle *lh) { /* NB: cookie is still useful, don't reset it */ list_del(&lh->lh_hash_chain); @@ -291,7 +291,7 @@ void lnet_res_lh_initialize(struct lnet_res_container *rec, static inline lnet_eq_t * lnet_handle2eq(struct lnet_handle_eq *handle) { - lnet_libhandle_t *lh; + struct lnet_libhandle *lh; lh = lnet_res_lh_lookup(&the_lnet.ln_eq_container, handle->cookie); if (!lh) @@ -310,7 +310,7 @@ void lnet_res_lh_initialize(struct lnet_res_container *rec, lnet_handle2md(struct lnet_handle_md *handle) { /* ALWAYS called with resource lock held */ - lnet_libhandle_t *lh; + struct lnet_libhandle *lh; int cpt; cpt = lnet_cpt_of_cookie(handle->cookie); @@ -326,7 +326,7 @@ void lnet_res_lh_initialize(struct lnet_res_container *rec, lnet_wire_handle2md(struct lnet_handle_wire *wh) { /* ALWAYS called with resource lock held */ - lnet_libhandle_t *lh; + struct lnet_libhandle *lh; int cpt; if (wh->wh_interface_cookie != the_lnet.ln_interface_cookie) @@ -351,7 +351,7 @@ void lnet_res_lh_initialize(struct lnet_res_container *rec, lnet_handle2me(struct lnet_handle_me *handle) { /* ALWAYS called with resource lock held */ - lnet_libhandle_t *lh; + struct lnet_libhandle *lh; int cpt; cpt = lnet_cpt_of_cookie(handle->cookie); diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index e3cb795..9f301f4 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -108,17 +108,17 @@ struct lnet_msg { struct lnet_hdr msg_hdr; }; -typedef struct lnet_libhandle { +struct lnet_libhandle { struct list_head lh_hash_chain; __u64 lh_cookie; -} lnet_libhandle_t; +}; #define lh_entry(ptr, type, member) \ ((type *)((char *)(ptr) - (char *)(&((type *)0)->member))) typedef struct lnet_eq { struct list_head eq_list; - lnet_libhandle_t eq_lh; + struct lnet_libhandle eq_lh; lnet_seq_t eq_enq_seq; lnet_seq_t eq_deq_seq; unsigned int eq_size; @@ -129,7 +129,7 @@ struct lnet_msg { typedef struct lnet_me { struct list_head me_list; - lnet_libhandle_t me_lh; + struct lnet_libhandle me_lh; lnet_process_id_t me_match_id; unsigned int me_portal; unsigned int me_pos; /* hash offset in mt_hash */ @@ -141,7 +141,7 @@ struct lnet_msg { typedef struct lnet_libmd { struct list_head md_list; - lnet_libhandle_t md_lh; + struct lnet_libhandle md_lh; lnet_me_t *md_me; char *md_start; unsigned int md_offset; diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index 5161b8a..4c9a064 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -483,12 +483,12 @@ static void lnet_assert_wire_constants(void) return recs; } -lnet_libhandle_t * +struct lnet_libhandle * lnet_res_lh_lookup(struct lnet_res_container *rec, __u64 cookie) { /* ALWAYS called with lnet_res_lock held */ struct list_head *head; - lnet_libhandle_t *lh; + struct lnet_libhandle *lh; unsigned int hash; if ((cookie & LNET_COOKIE_MASK) != rec->rec_type) @@ -506,7 +506,8 @@ static void lnet_assert_wire_constants(void) } void -lnet_res_lh_initialize(struct lnet_res_container *rec, lnet_libhandle_t *lh) +lnet_res_lh_initialize(struct lnet_res_container *rec, + struct lnet_libhandle *lh) { /* ALWAYS called with lnet_res_lock held */ unsigned int ibits = LNET_COOKIE_TYPE_BITS + LNET_CPT_BITS; -- 1.8.3.1 From jsimmons at infradead.org Mon Feb 27 00:41:33 2017 From: jsimmons at infradead.org (James Simmons) Date: Sun, 26 Feb 2017 19:41:33 -0500 Subject: [lustre-devel] [PATCH 08/34] staging: lustre: lnet: change lnet_eq_t to proper structure In-Reply-To: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> References: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> Message-ID: <1488156119-19670-9-git-send-email-jsimmons@infradead.org> Change lnet_eq_t from typedef to proper structure. Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/20831 Reviewed-by: Olaf Weber Reviewed-by: Doug Oucharek Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/include/linux/lnet/lib-lnet.h | 14 +++++++------- drivers/staging/lustre/include/linux/lnet/lib-types.h | 6 +++--- drivers/staging/lustre/lnet/lnet/api-ni.c | 2 +- drivers/staging/lustre/lnet/lnet/lib-eq.c | 8 ++++---- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h index 1c147b3..9e33d0a 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h @@ -178,17 +178,17 @@ static inline int lnet_md_unlinkable(lnet_libmd_t *md) #define MAX_PORTALS 64 -static inline lnet_eq_t * +static inline struct lnet_eq * lnet_eq_alloc(void) { - lnet_eq_t *eq; + struct lnet_eq *eq; LIBCFS_ALLOC(eq, sizeof(*eq)); return eq; } static inline void -lnet_eq_free(lnet_eq_t *eq) +lnet_eq_free(struct lnet_eq *eq) { LIBCFS_FREE(eq, sizeof(*eq)); } @@ -278,7 +278,7 @@ void lnet_res_lh_initialize(struct lnet_res_container *rec, } static inline void -lnet_eq2handle(struct lnet_handle_eq *handle, lnet_eq_t *eq) +lnet_eq2handle(struct lnet_handle_eq *handle, struct lnet_eq *eq) { if (!eq) { LNetInvalidateEQHandle(handle); @@ -288,7 +288,7 @@ void lnet_res_lh_initialize(struct lnet_res_container *rec, handle->cookie = eq->eq_lh.lh_cookie; } -static inline lnet_eq_t * +static inline struct lnet_eq * lnet_handle2eq(struct lnet_handle_eq *handle) { struct lnet_libhandle *lh; @@ -297,7 +297,7 @@ void lnet_res_lh_initialize(struct lnet_res_container *rec, if (!lh) return NULL; - return lh_entry(lh, lnet_eq_t, eq_lh); + return lh_entry(lh, struct lnet_eq, eq_lh); } static inline void @@ -490,7 +490,7 @@ void lnet_msg_attach_md(struct lnet_msg *msg, lnet_libmd_t *md, void lnet_msg_commit(struct lnet_msg *msg, int cpt); void lnet_msg_decommit(struct lnet_msg *msg, int cpt, int status); -void lnet_eq_enqueue_event(lnet_eq_t *eq, lnet_event_t *ev); +void lnet_eq_enqueue_event(struct lnet_eq *eq, lnet_event_t *ev); void lnet_prep_send(struct lnet_msg *msg, int type, lnet_process_id_t target, unsigned int offset, unsigned int len); int lnet_send(lnet_nid_t nid, struct lnet_msg *msg, lnet_nid_t rtr_nid); diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index 9f301f4..19e01cc 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -116,7 +116,7 @@ struct lnet_libhandle { #define lh_entry(ptr, type, member) \ ((type *)((char *)(ptr) - (char *)(&((type *)0)->member))) -typedef struct lnet_eq { +struct lnet_eq { struct list_head eq_list; struct lnet_libhandle eq_lh; lnet_seq_t eq_enq_seq; @@ -125,7 +125,7 @@ struct lnet_libhandle { lnet_eq_handler_t eq_callback; lnet_event_t *eq_events; int **eq_refs; /* percpt refcount for EQ */ -} lnet_eq_t; +}; typedef struct lnet_me { struct list_head me_list; @@ -152,7 +152,7 @@ struct lnet_libhandle { unsigned int md_options; unsigned int md_flags; void *md_user_ptr; - lnet_eq_t *md_eq; + struct lnet_eq *md_eq; unsigned int md_niov; /* # frags */ union { struct kvec iov[LNET_MAX_IOV]; diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index 4c9a064..ee47ba9 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -383,7 +383,7 @@ static void lnet_assert_wire_constants(void) list_del_init(e); if (rec->rec_type == LNET_COOKIE_TYPE_EQ) { - lnet_eq_free(list_entry(e, lnet_eq_t, eq_list)); + lnet_eq_free(list_entry(e, struct lnet_eq, eq_list)); } else if (rec->rec_type == LNET_COOKIE_TYPE_MD) { lnet_md_free(list_entry(e, lnet_libmd_t, md_list)); diff --git a/drivers/staging/lustre/lnet/lnet/lib-eq.c b/drivers/staging/lustre/lnet/lnet/lib-eq.c index 6645fdc..4369df3 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-eq.c +++ b/drivers/staging/lustre/lnet/lnet/lib-eq.c @@ -66,7 +66,7 @@ LNetEQAlloc(unsigned int count, lnet_eq_handler_t callback, struct lnet_handle_eq *handle) { - lnet_eq_t *eq; + struct lnet_eq *eq; LASSERT(the_lnet.ln_refcount > 0); @@ -210,7 +210,7 @@ EXPORT_SYMBOL(LNetEQFree); void -lnet_eq_enqueue_event(lnet_eq_t *eq, lnet_event_t *ev) +lnet_eq_enqueue_event(struct lnet_eq *eq, lnet_event_t *ev) { /* MUST called with resource lock hold but w/o lnet_eq_wait_lock */ int index; @@ -239,7 +239,7 @@ } static int -lnet_eq_dequeue_event(lnet_eq_t *eq, lnet_event_t *ev) +lnet_eq_dequeue_event(struct lnet_eq *eq, lnet_event_t *ev) { int new_index = eq->eq_deq_seq & (eq->eq_size - 1); lnet_event_t *new_event = &eq->eq_events[new_index]; @@ -386,7 +386,7 @@ for (;;) { for (i = 0; i < neq; i++) { - lnet_eq_t *eq = lnet_handle2eq(&eventqs[i]); + struct lnet_eq *eq = lnet_handle2eq(&eventqs[i]); if (!eq) { lnet_eq_wait_unlock(); -- 1.8.3.1 From jsimmons at infradead.org Mon Feb 27 00:41:45 2017 From: jsimmons at infradead.org (James Simmons) Date: Sun, 26 Feb 2017 19:41:45 -0500 Subject: [lustre-devel] [PATCH 20/34] staging: lustre: lnet: change lnet_portal_t to proper structure In-Reply-To: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> References: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> Message-ID: <1488156119-19670-21-git-send-email-jsimmons@infradead.org> Change lnet_portal_t from typedef to proper structure. Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/20831 Reviewed-by: Olaf Weber Reviewed-by: Doug Oucharek Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/include/linux/lnet/lib-lnet.h | 10 +++++----- drivers/staging/lustre/include/linux/lnet/lib-types.h | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h index 223e5a3..37b9d66 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h @@ -502,31 +502,31 @@ void lnet_prep_send(struct lnet_msg *msg, int type, lnet_process_id_t target, /* portals functions */ /* portals attributes */ static inline int -lnet_ptl_is_lazy(lnet_portal_t *ptl) +lnet_ptl_is_lazy(struct lnet_portal *ptl) { return !!(ptl->ptl_options & LNET_PTL_LAZY); } static inline int -lnet_ptl_is_unique(lnet_portal_t *ptl) +lnet_ptl_is_unique(struct lnet_portal *ptl) { return !!(ptl->ptl_options & LNET_PTL_MATCH_UNIQUE); } static inline int -lnet_ptl_is_wildcard(lnet_portal_t *ptl) +lnet_ptl_is_wildcard(struct lnet_portal *ptl) { return !!(ptl->ptl_options & LNET_PTL_MATCH_WILDCARD); } static inline void -lnet_ptl_setopt(lnet_portal_t *ptl, int opt) +lnet_ptl_setopt(struct lnet_portal *ptl, int opt) { ptl->ptl_options |= opt; } static inline void -lnet_ptl_unsetopt(lnet_portal_t *ptl, int opt) +lnet_ptl_unsetopt(struct lnet_portal *ptl, int opt) { ptl->ptl_options &= ~opt; } diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index f939492..e00bd38 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -438,7 +438,7 @@ enum { LNET_MATCHMD_FINISH = (LNET_MATCHMD_OK | LNET_MATCHMD_DROP), }; -/* Options for lnet_portal_t::ptl_options */ +/* Options for lnet_portal::ptl_options */ #define LNET_PTL_LAZY (1 << 0) #define LNET_PTL_MATCH_UNIQUE (1 << 1) /* unique match, for RDMA */ #define LNET_PTL_MATCH_WILDCARD (1 << 2) /* wildcard match, @@ -497,7 +497,7 @@ struct lnet_match_table { /* dispatch routed PUT message by hashing source NID for wildcard portals */ #define LNET_PTL_ROTOR_HASH_RT 3 -typedef struct lnet_portal { +struct lnet_portal { spinlock_t ptl_lock; unsigned int ptl_index; /* portal ID, reserved */ /* flags on this portal: lazy, unique... */ @@ -514,7 +514,7 @@ struct lnet_match_table { int ptl_mt_nmaps; /* array of active entries' cpu-partition-id */ int ptl_mt_maps[0]; -} lnet_portal_t; +}; #define LNET_LH_HASH_BITS 12 #define LNET_LH_HASH_SIZE (1ULL << LNET_LH_HASH_BITS) @@ -557,7 +557,7 @@ struct lnet_msg_container { /* # portals */ int ln_nportals; /* the vector of portals */ - lnet_portal_t **ln_portals; + struct lnet_portal **ln_portals; /* percpt ME containers */ struct lnet_res_container **ln_me_containers; /* percpt MD container */ -- 1.8.3.1 From jsimmons at infradead.org Mon Feb 27 00:41:41 2017 From: jsimmons at infradead.org (James Simmons) Date: Sun, 26 Feb 2017 19:41:41 -0500 Subject: [lustre-devel] [PATCH 16/34] staging: lustre: lnet: change lnet_route_t to proper structure In-Reply-To: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> References: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> Message-ID: <1488156119-19670-17-git-send-email-jsimmons@infradead.org> Change lnet_route_t from typedef to proper structure. Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/20831 Reviewed-by: Olaf Weber Reviewed-by: Doug Oucharek Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- .../staging/lustre/include/linux/lnet/lib-lnet.h | 2 +- .../staging/lustre/include/linux/lnet/lib-types.h | 6 ++--- drivers/staging/lustre/lnet/lnet/lib-move.c | 12 +++++----- drivers/staging/lustre/lnet/lnet/router.c | 26 ++++++++++++---------- drivers/staging/lustre/lnet/lnet/router_proc.c | 11 ++++----- 5 files changed, 30 insertions(+), 27 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h index bcfbed1..93e6830 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h @@ -65,7 +65,7 @@ /** exclusive lock */ #define LNET_LOCK_EX CFS_PERCPT_LOCK_EX -static inline int lnet_is_route_alive(lnet_route_t *route) +static inline int lnet_is_route_alive(struct lnet_route *route) { /* gateway is down */ if (!route->lr_gateway->lp_alive) diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index 2cfc1bf..a0d9cad 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -340,7 +340,7 @@ struct lnet_peer { lnet_nid_t lp_nid; /* peer's NID */ int lp_refcount; /* # refs */ int lp_cpt; /* CPT this peer attached on */ - /* # refs from lnet_route_t::lr_gateway */ + /* # refs from lnet_route::lr_gateway */ int lp_rtr_refcount; /* returned RC ping features */ unsigned int lp_ping_feats; @@ -369,7 +369,7 @@ struct lnet_peer_table { #define lnet_peer_aliveness_enabled(lp) (the_lnet.ln_routing && \ (lp)->lp_ni->ni_peertimeout > 0) -typedef struct { +struct lnet_route { struct list_head lr_list; /* chain on net */ struct list_head lr_gwlist; /* chain on gateway */ struct lnet_peer *lr_gateway; /* router node */ @@ -378,7 +378,7 @@ struct lnet_peer_table { unsigned int lr_downis; /* number of down NIs */ __u32 lr_hops; /* how far I am */ unsigned int lr_priority; /* route priority */ -} lnet_route_t; +}; #define LNET_REMOTE_NETS_HASH_DEFAULT (1U << 7) #define LNET_REMOTE_NETS_HASH_MAX (1U << 16) diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c index 9615dcd..9d1ab1f 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-move.c +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c @@ -957,7 +957,7 @@ } static int -lnet_compare_routes(lnet_route_t *r1, lnet_route_t *r2) +lnet_compare_routes(struct lnet_route *r1, struct lnet_route *r2) { struct lnet_peer *p1 = r1->lr_gateway; struct lnet_peer *p2 = r2->lr_gateway; @@ -999,9 +999,9 @@ lnet_nid_t rtr_nid) { lnet_remotenet_t *rnet; - lnet_route_t *route; - lnet_route_t *best_route; - lnet_route_t *last_route; + struct lnet_route *route; + struct lnet_route *best_route; + struct lnet_route *last_route; struct lnet_peer *lp_best; struct lnet_peer *lp; int rc; @@ -2351,8 +2351,8 @@ struct lnet_msg * rnet = list_entry(e, lnet_remotenet_t, lrn_list); if (rnet->lrn_net == dstnet) { - lnet_route_t *route; - lnet_route_t *shortest = NULL; + struct lnet_route *route; + struct lnet_route *shortest = NULL; __u32 shortest_hops = LNET_UNDEFINED_HOPS; __u32 route_hops; diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c index eda829a..8e5af05 100644 --- a/drivers/staging/lustre/lnet/lnet/router.c +++ b/drivers/staging/lustre/lnet/lnet/router.c @@ -268,7 +268,7 @@ static void lnet_shuffle_seed(void) /* NB expects LNET_LOCK held */ static void -lnet_add_route_to_rnet(lnet_remotenet_t *rnet, lnet_route_t *route) +lnet_add_route_to_rnet(lnet_remotenet_t *rnet, struct lnet_route *route) { unsigned int len = 0; unsigned int offset = 0; @@ -301,7 +301,7 @@ static void lnet_shuffle_seed(void) struct list_head *e; lnet_remotenet_t *rnet; lnet_remotenet_t *rnet2; - lnet_route_t *route; + struct lnet_route *route; struct lnet_ni *ni; int add_route; int rc; @@ -368,8 +368,9 @@ static void lnet_shuffle_seed(void) /* Search for a duplicate route (it's a NOOP if it is) */ add_route = 1; list_for_each(e, &rnet2->lrn_routes) { - lnet_route_t *route2 = list_entry(e, lnet_route_t, lr_list); + struct lnet_route *route2; + route2 = list_entry(e, struct lnet_route, lr_list); if (route2->lr_gateway == route->lr_gateway) { add_route = 0; break; @@ -416,8 +417,8 @@ static void lnet_shuffle_seed(void) lnet_check_routes(void) { lnet_remotenet_t *rnet; - lnet_route_t *route; - lnet_route_t *route2; + struct lnet_route *route; + struct lnet_route *route2; struct list_head *e1; struct list_head *e2; int cpt; @@ -437,7 +438,7 @@ static void lnet_shuffle_seed(void) lnet_nid_t nid2; int net; - route = list_entry(e2, lnet_route_t, lr_list); + route = list_entry(e2, struct lnet_route, lr_list); if (!route2) { route2 = route; @@ -472,7 +473,7 @@ static void lnet_shuffle_seed(void) { struct lnet_peer *gateway; lnet_remotenet_t *rnet; - lnet_route_t *route; + struct lnet_route *route; struct list_head *e1; struct list_head *e2; int rc = -ENOENT; @@ -501,7 +502,7 @@ static void lnet_shuffle_seed(void) continue; list_for_each(e2, &rnet->lrn_routes) { - route = list_entry(e2, lnet_route_t, lr_list); + route = list_entry(e2, struct lnet_route, lr_list); gateway = route->lr_gateway; if (!(gw_nid == LNET_NID_ANY || @@ -588,7 +589,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) struct list_head *e1; struct list_head *e2; lnet_remotenet_t *rnet; - lnet_route_t *route; + struct lnet_route *route; int cpt; int i; struct list_head *rn_list; @@ -601,7 +602,8 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) rnet = list_entry(e1, lnet_remotenet_t, lrn_list); list_for_each(e2, &rnet->lrn_routes) { - route = list_entry(e2, lnet_route_t, lr_list); + route = list_entry(e2, struct lnet_route, + lr_list); if (!idx--) { *net = rnet->lrn_net; @@ -646,7 +648,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) { struct lnet_ping_info *info = rcd->rcd_pinginfo; struct lnet_peer *gw = rcd->rcd_gateway; - lnet_route_t *rte; + struct lnet_route *rte; if (!gw->lp_alive) return; @@ -823,7 +825,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) void lnet_router_ni_update_locked(struct lnet_peer *gw, __u32 net) { - lnet_route_t *rte; + struct lnet_route *rte; if ((gw->lp_ping_feats & LNET_PING_FEAT_NI_STATUS)) { list_for_each_entry(rte, &gw->lp_routes, lr_gwlist) { diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c index e672148..1b2817c 100644 --- a/drivers/staging/lustre/lnet/lnet/router_proc.c +++ b/drivers/staging/lustre/lnet/lnet/router_proc.c @@ -171,7 +171,7 @@ static int proc_lnet_routes(struct ctl_table *table, int write, } else { struct list_head *n; struct list_head *r; - lnet_route_t *route = NULL; + struct lnet_route *route = NULL; lnet_remotenet_t *rnet = NULL; int skip = off - 1; struct list_head *rn_list; @@ -197,9 +197,10 @@ static int proc_lnet_routes(struct ctl_table *table, int write, r = rnet->lrn_routes.next; while (r != &rnet->lrn_routes) { - lnet_route_t *re = - list_entry(r, lnet_route_t, - lr_list); + struct lnet_route *re; + + re = list_entry(r, struct lnet_route, + lr_list); if (!skip) { route = re; break; @@ -331,7 +332,7 @@ static int proc_lnet_routers(struct ctl_table *table, int write, int last_ping = cfs_duration_sec(cfs_time_sub(now, peer->lp_ping_timestamp)); int down_ni = 0; - lnet_route_t *rtr; + struct lnet_route *rtr; if ((peer->lp_ping_feats & LNET_PING_FEAT_NI_STATUS)) { -- 1.8.3.1 From jsimmons at infradead.org Mon Feb 27 00:41:50 2017 From: jsimmons at infradead.org (James Simmons) Date: Sun, 26 Feb 2017 19:41:50 -0500 Subject: [lustre-devel] [PATCH 25/34] staging: lustre: lnet: change lnet_event_t to proper structure In-Reply-To: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> References: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> Message-ID: <1488156119-19670-26-git-send-email-jsimmons@infradead.org> Change lnet_event_t from typedef to proper structure. Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/20831 Reviewed-by: Olaf Weber Reviewed-by: Doug Oucharek Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/include/linux/lnet/api.h | 4 ++-- drivers/staging/lustre/include/linux/lnet/lib-lnet.h | 4 ++-- drivers/staging/lustre/include/linux/lnet/lib-types.h | 4 ++-- drivers/staging/lustre/include/linux/lnet/types.h | 6 +++--- drivers/staging/lustre/lnet/lnet/api-ni.c | 4 ++-- drivers/staging/lustre/lnet/lnet/lib-eq.c | 16 ++++++++-------- drivers/staging/lustre/lnet/lnet/lib-md.c | 2 +- drivers/staging/lustre/lnet/lnet/lib-me.c | 2 +- drivers/staging/lustre/lnet/lnet/lib-move.c | 2 +- drivers/staging/lustre/lnet/lnet/lib-msg.c | 8 ++++---- drivers/staging/lustre/lnet/lnet/router.c | 2 +- drivers/staging/lustre/lnet/selftest/rpc.c | 2 +- drivers/staging/lustre/lustre/include/lustre_net.h | 12 ++++++------ drivers/staging/lustre/lustre/ptlrpc/events.c | 14 +++++++------- 14 files changed, 41 insertions(+), 41 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/api.h b/drivers/staging/lustre/include/linux/lnet/api.h index 8609206..b46a769 100644 --- a/drivers/staging/lustre/include/linux/lnet/api.h +++ b/drivers/staging/lustre/include/linux/lnet/api.h @@ -148,7 +148,7 @@ int LNetMDBind(struct lnet_md md_in, * * In addition to the lnet_handle_eq, the LNet API defines two types * associated with events: The ::lnet_event_kind_t defines the kinds of events - * that can be stored in an EQ. The lnet_event_t defines a structure that + * that can be stored in an EQ. The lnet_event defines a structure that * holds the information about with an event. * * There are five functions for dealing with EQs: LNetEQAlloc() is used to @@ -168,7 +168,7 @@ int LNetEQAlloc(unsigned int count_in, int LNetEQPoll(struct lnet_handle_eq *eventqs_in, int neq_in, int timeout_ms, - lnet_event_t *event_out, + struct lnet_event *event_out, int *which_eq_out); /** @} lnet_eq */ diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h index a6cf5be..d770a03 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h @@ -485,12 +485,12 @@ int lnet_dyn_add_ni(lnet_pid_t requested_pid, void lnet_msg_attach_md(struct lnet_msg *msg, struct lnet_libmd *md, unsigned int offset, unsigned int mlen); void lnet_msg_detach_md(struct lnet_msg *msg, int status); -void lnet_build_unlink_event(struct lnet_libmd *md, lnet_event_t *ev); +void lnet_build_unlink_event(struct lnet_libmd *md, struct lnet_event *ev); void lnet_build_msg_event(struct lnet_msg *msg, lnet_event_kind_t ev_type); void lnet_msg_commit(struct lnet_msg *msg, int cpt); void lnet_msg_decommit(struct lnet_msg *msg, int cpt, int status); -void lnet_eq_enqueue_event(struct lnet_eq *eq, lnet_event_t *ev); +void lnet_eq_enqueue_event(struct lnet_eq *eq, struct lnet_event *ev); void lnet_prep_send(struct lnet_msg *msg, int type, lnet_process_id_t target, unsigned int offset, unsigned int len); int lnet_send(lnet_nid_t nid, struct lnet_msg *msg, lnet_nid_t rtr_nid); diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index c98af93..808a05c 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -104,7 +104,7 @@ struct lnet_msg { struct kvec *msg_iov; lnet_kiov_t *msg_kiov; - lnet_event_t msg_ev; + struct lnet_event msg_ev; struct lnet_hdr msg_hdr; }; @@ -123,7 +123,7 @@ struct lnet_eq { lnet_seq_t eq_deq_seq; unsigned int eq_size; lnet_eq_handler_t eq_callback; - lnet_event_t *eq_events; + struct lnet_event *eq_events; int **eq_refs; /* percpt refcount for EQ */ }; diff --git a/drivers/staging/lustre/include/linux/lnet/types.h b/drivers/staging/lustre/include/linux/lnet/types.h index bc3f3e3..53eb1da 100644 --- a/drivers/staging/lustre/include/linux/lnet/types.h +++ b/drivers/staging/lustre/include/linux/lnet/types.h @@ -568,7 +568,7 @@ struct lnet_md { /** * Information about an event on a MD. */ -typedef struct { +struct lnet_event { /** The identifier (nid, pid) of the target. */ lnet_process_id_t target; /** The identifier (nid, pid) of the initiator. */ @@ -635,7 +635,7 @@ struct lnet_md { * to each event. */ volatile lnet_seq_t sequence; -} lnet_event_t; +}; /** * Event queue handler function type. @@ -647,7 +647,7 @@ struct lnet_md { * The handler must not block, must be reentrant, and must not call any LNet * API functions. It should return as quickly as possible. */ -typedef void (*lnet_eq_handler_t)(lnet_event_t *event); +typedef void (*lnet_eq_handler_t)(struct lnet_event *event); #define LNET_EQ_HANDLER_NONE NULL /** @} lnet_eq */ diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index 53c9427..1d2004f 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -888,7 +888,7 @@ struct lnet_ni * } static void -lnet_ping_event_handler(lnet_event_t *event) +lnet_ping_event_handler(struct lnet_event *event) { struct lnet_ping_info *pinfo = event->md.user_ptr; @@ -2133,7 +2133,7 @@ static int lnet_ping(lnet_process_id_t id, int timeout_ms, { struct lnet_handle_eq eqh; struct lnet_handle_md mdh; - lnet_event_t event; + struct lnet_event event; struct lnet_md md = { NULL }; int which; int unlinked = 0; diff --git a/drivers/staging/lustre/lnet/lnet/lib-eq.c b/drivers/staging/lustre/lnet/lnet/lib-eq.c index 4369df3..ce4b835 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-eq.c +++ b/drivers/staging/lustre/lnet/lnet/lib-eq.c @@ -93,7 +93,7 @@ return -ENOMEM; if (count) { - LIBCFS_ALLOC(eq->eq_events, count * sizeof(lnet_event_t)); + LIBCFS_ALLOC(eq->eq_events, count * sizeof(struct lnet_event)); if (!eq->eq_events) goto failed; /* @@ -131,7 +131,7 @@ failed: if (eq->eq_events) - LIBCFS_FREE(eq->eq_events, count * sizeof(lnet_event_t)); + LIBCFS_FREE(eq->eq_events, count * sizeof(struct lnet_event)); if (eq->eq_refs) cfs_percpt_free(eq->eq_refs); @@ -155,7 +155,7 @@ LNetEQFree(struct lnet_handle_eq eqh) { struct lnet_eq *eq; - lnet_event_t *events = NULL; + struct lnet_event *events = NULL; int **refs = NULL; int *ref; int rc = 0; @@ -201,7 +201,7 @@ lnet_res_unlock(LNET_LOCK_EX); if (events) - LIBCFS_FREE(events, size * sizeof(lnet_event_t)); + LIBCFS_FREE(events, size * sizeof(struct lnet_event)); if (refs) cfs_percpt_free(refs); @@ -210,7 +210,7 @@ EXPORT_SYMBOL(LNetEQFree); void -lnet_eq_enqueue_event(struct lnet_eq *eq, lnet_event_t *ev) +lnet_eq_enqueue_event(struct lnet_eq *eq, struct lnet_event *ev) { /* MUST called with resource lock hold but w/o lnet_eq_wait_lock */ int index; @@ -239,10 +239,10 @@ } static int -lnet_eq_dequeue_event(struct lnet_eq *eq, lnet_event_t *ev) +lnet_eq_dequeue_event(struct lnet_eq *eq, struct lnet_event *ev) { int new_index = eq->eq_deq_seq & (eq->eq_size - 1); - lnet_event_t *new_event = &eq->eq_events[new_index]; + struct lnet_event *new_event = &eq->eq_events[new_index]; int rc; /* must called with lnet_eq_wait_lock hold */ @@ -371,7 +371,7 @@ */ int LNetEQPoll(struct lnet_handle_eq *eventqs, int neq, int timeout_ms, - lnet_event_t *event, int *which) + struct lnet_event *event, int *which) { int wait = 1; int rc; diff --git a/drivers/staging/lustre/lnet/lnet/lib-md.c b/drivers/staging/lustre/lnet/lnet/lib-md.c index a3f8927..872f63f 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-md.c +++ b/drivers/staging/lustre/lnet/lnet/lib-md.c @@ -428,7 +428,7 @@ int LNetMDUnlink(struct lnet_handle_md mdh) { - lnet_event_t ev; + struct lnet_event ev; struct lnet_libmd *md; int cpt; diff --git a/drivers/staging/lustre/lnet/lnet/lib-me.c b/drivers/staging/lustre/lnet/lnet/lib-me.c index 75922a5..7614088 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-me.c +++ b/drivers/staging/lustre/lnet/lnet/lib-me.c @@ -224,7 +224,7 @@ { struct lnet_me *me; struct lnet_libmd *md; - lnet_event_t ev; + struct lnet_event ev; int cpt; LASSERT(the_lnet.ln_refcount > 0); diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c index aea899e..96fb7fc 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-move.c +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c @@ -1987,7 +1987,7 @@ * \retval -ENOMEM Memory allocation failure. * \retval -ENOENT Invalid MD object. * - * \see lnet_event_t::hdr_data and lnet_event_kind_t. + * \see lnet_event::hdr_data and lnet_event_kind_t. */ int LNetPut(lnet_nid_t self, struct lnet_handle_md mdh, lnet_ack_req_t ack, diff --git a/drivers/staging/lustre/lnet/lnet/lib-msg.c b/drivers/staging/lustre/lnet/lnet/lib-msg.c index 4b5e3a8..b9b0259 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-msg.c +++ b/drivers/staging/lustre/lnet/lnet/lib-msg.c @@ -39,7 +39,7 @@ #include "../../include/linux/lnet/lib-lnet.h" void -lnet_build_unlink_event(struct lnet_libmd *md, lnet_event_t *ev) +lnet_build_unlink_event(struct lnet_libmd *md, struct lnet_event *ev) { memset(ev, 0, sizeof(*ev)); @@ -57,7 +57,7 @@ lnet_build_msg_event(struct lnet_msg *msg, lnet_event_kind_t ev_type) { struct lnet_hdr *hdr = &msg->msg_hdr; - lnet_event_t *ev = &msg->msg_ev; + struct lnet_event *ev = &msg->msg_ev; LASSERT(!msg->msg_routing); @@ -165,7 +165,7 @@ lnet_msg_decommit_tx(struct lnet_msg *msg, int status) { struct lnet_counters *counters; - lnet_event_t *ev = &msg->msg_ev; + struct lnet_event *ev = &msg->msg_ev; LASSERT(msg->msg_tx_committed); if (status) @@ -217,7 +217,7 @@ lnet_msg_decommit_rx(struct lnet_msg *msg, int status) { struct lnet_counters *counters; - lnet_event_t *ev = &msg->msg_ev; + struct lnet_event *ev = &msg->msg_ev; LASSERT(!msg->msg_tx_committed); /* decommitted or never committed */ LASSERT(msg->msg_rx_committed); diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c index c9edc10..84092ad 100644 --- a/drivers/staging/lustre/lnet/lnet/router.c +++ b/drivers/staging/lustre/lnet/lnet/router.c @@ -733,7 +733,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) } static void -lnet_router_checker_event(lnet_event_t *event) +lnet_router_checker_event(struct lnet_event *event) { struct lnet_rc_data *rcd = event->md.user_ptr; struct lnet_peer *lp; diff --git a/drivers/staging/lustre/lnet/selftest/rpc.c b/drivers/staging/lustre/lnet/selftest/rpc.c index e70785c..f56f740 100644 --- a/drivers/staging/lustre/lnet/selftest/rpc.c +++ b/drivers/staging/lustre/lnet/selftest/rpc.c @@ -1408,7 +1408,7 @@ struct srpc_client_rpc * /* when in kernel always called with LNET_LOCK() held, and in thread context */ static void -srpc_lnet_ev_handler(lnet_event_t *ev) +srpc_lnet_ev_handler(struct lnet_event *ev) { struct srpc_service_cd *scd; struct srpc_event *rpcev = ev->md.user_ptr; diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h index c28c4ac..c7c7c3a 100644 --- a/drivers/staging/lustre/lustre/include/lustre_net.h +++ b/drivers/staging/lustre/lustre/include/lustre_net.h @@ -400,7 +400,7 @@ struct ptlrpc_set_cbdata { * ptlrpc callback & work item stuff */ struct ptlrpc_cb_id { - void (*cbid_fn)(lnet_event_t *ev); /* specific callback fn */ + void (*cbid_fn)(struct lnet_event *ev); /* specific callback fn */ void *cbid_arg; /* additional arg */ }; @@ -1757,11 +1757,11 @@ int ptlrpc_uuid_to_peer(struct obd_uuid *uuid, * underlying buffer * @{ */ -void request_out_callback(lnet_event_t *ev); -void reply_in_callback(lnet_event_t *ev); -void client_bulk_callback(lnet_event_t *ev); -void request_in_callback(lnet_event_t *ev); -void reply_out_callback(lnet_event_t *ev); +void request_out_callback(struct lnet_event *ev); +void reply_in_callback(struct lnet_event *ev); +void client_bulk_callback(struct lnet_event *ev); +void request_in_callback(struct lnet_event *ev); +void reply_out_callback(struct lnet_event *ev); /** @} */ /* ptlrpc/connection.c */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/events.c b/drivers/staging/lustre/lustre/ptlrpc/events.c index ca11b03..3aec148 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/events.c +++ b/drivers/staging/lustre/lustre/ptlrpc/events.c @@ -47,7 +47,7 @@ /* * Client's outgoing request callback */ -void request_out_callback(lnet_event_t *ev) +void request_out_callback(struct lnet_event *ev) { struct ptlrpc_cb_id *cbid = ev->md.user_ptr; struct ptlrpc_request *req = cbid->cbid_arg; @@ -86,7 +86,7 @@ void request_out_callback(lnet_event_t *ev) /* * Client's incoming reply callback */ -void reply_in_callback(lnet_event_t *ev) +void reply_in_callback(struct lnet_event *ev) { struct ptlrpc_cb_id *cbid = ev->md.user_ptr; struct ptlrpc_request *req = cbid->cbid_arg; @@ -176,7 +176,7 @@ void reply_in_callback(lnet_event_t *ev) /* * Client's bulk has been written/read */ -void client_bulk_callback(lnet_event_t *ev) +void client_bulk_callback(struct lnet_event *ev) { struct ptlrpc_cb_id *cbid = ev->md.user_ptr; struct ptlrpc_bulk_desc *desc = cbid->cbid_arg; @@ -289,7 +289,7 @@ static void ptlrpc_req_add_history(struct ptlrpc_service_part *svcpt, /* * Server's incoming request callback */ -void request_in_callback(lnet_event_t *ev) +void request_in_callback(struct lnet_event *ev) { struct ptlrpc_cb_id *cbid = ev->md.user_ptr; struct ptlrpc_request_buffer_desc *rqbd = cbid->cbid_arg; @@ -389,7 +389,7 @@ void request_in_callback(lnet_event_t *ev) /* * Server's outgoing reply callback */ -void reply_out_callback(lnet_event_t *ev) +void reply_out_callback(struct lnet_event *ev) { struct ptlrpc_cb_id *cbid = ev->md.user_ptr; struct ptlrpc_reply_state *rs = cbid->cbid_arg; @@ -429,10 +429,10 @@ void reply_out_callback(lnet_event_t *ev) } } -static void ptlrpc_master_callback(lnet_event_t *ev) +static void ptlrpc_master_callback(struct lnet_event *ev) { struct ptlrpc_cb_id *cbid = ev->md.user_ptr; - void (*callback)(lnet_event_t *ev) = cbid->cbid_fn; + void (*callback)(struct lnet_event *ev) = cbid->cbid_fn; /* Honestly, it's best to find out early. */ LASSERT(cbid->cbid_arg != LP_POISON); -- 1.8.3.1 From jsimmons at infradead.org Mon Feb 27 00:41:55 2017 From: jsimmons at infradead.org (James Simmons) Date: Sun, 26 Feb 2017 19:41:55 -0500 Subject: [lustre-devel] [PATCH 30/34] staging: lustre: lnet: change lnet_event_kind_t to proper enum In-Reply-To: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> References: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> Message-ID: <1488156119-19670-31-git-send-email-jsimmons@infradead.org> Change lnet_event_kind_t from typedef to proper enum. Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/20831 Reviewed-by: Olaf Weber Reviewed-by: Doug Oucharek Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/include/linux/lnet/api.h | 2 +- drivers/staging/lustre/include/linux/lnet/lib-lnet.h | 2 +- drivers/staging/lustre/include/linux/lnet/types.h | 6 +++--- drivers/staging/lustre/lnet/lnet/lib-move.c | 2 +- drivers/staging/lustre/lnet/lnet/lib-msg.c | 2 +- drivers/staging/lustre/lnet/selftest/selftest.h | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/api.h b/drivers/staging/lustre/include/linux/lnet/api.h index 125d5cb..fc42898 100644 --- a/drivers/staging/lustre/include/linux/lnet/api.h +++ b/drivers/staging/lustre/include/linux/lnet/api.h @@ -147,7 +147,7 @@ int LNetMDBind(struct lnet_md md_in, * event that is deposited into the EQ. * * In addition to the lnet_handle_eq, the LNet API defines two types - * associated with events: The ::lnet_event_kind_t defines the kinds of events + * associated with events: The ::lnet_event_kind defines the kinds of events * that can be stored in an EQ. The lnet_event defines a structure that * holds the information about with an event. * diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h index 2d684a7..dce09fe 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h @@ -486,7 +486,7 @@ void lnet_msg_attach_md(struct lnet_msg *msg, struct lnet_libmd *md, unsigned int offset, unsigned int mlen); void lnet_msg_detach_md(struct lnet_msg *msg, int status); void lnet_build_unlink_event(struct lnet_libmd *md, struct lnet_event *ev); -void lnet_build_msg_event(struct lnet_msg *msg, lnet_event_kind_t ev_type); +void lnet_build_msg_event(struct lnet_msg *msg, enum lnet_event_kind ev_type); void lnet_msg_commit(struct lnet_msg *msg, int cpt); void lnet_msg_decommit(struct lnet_msg *msg, int cpt, int status); diff --git a/drivers/staging/lustre/include/linux/lnet/types.h b/drivers/staging/lustre/include/linux/lnet/types.h index 4fde723..a621ab6 100644 --- a/drivers/staging/lustre/include/linux/lnet/types.h +++ b/drivers/staging/lustre/include/linux/lnet/types.h @@ -523,7 +523,7 @@ struct lnet_md { /** * Six types of events can be logged in an event queue. */ -typedef enum { +enum lnet_event_kind { /** An incoming GET operation has completed on the MD. */ LNET_EVENT_GET = 1, /** @@ -559,7 +559,7 @@ struct lnet_md { * \see LNetMDUnlink */ LNET_EVENT_UNLINK, -} lnet_event_kind_t; +}; #define LNET_SEQ_BASETYPE long typedef unsigned LNET_SEQ_BASETYPE lnet_seq_t; @@ -580,7 +580,7 @@ struct lnet_event { */ lnet_nid_t sender; /** Indicates the type of the event. */ - lnet_event_kind_t type; + enum lnet_event_kind type; /** The portal table index specified in the request */ unsigned int pt_index; /** A copy of the match bits specified in the request. */ diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c index 3c54a3d..7fdbc75 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-move.c +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c @@ -1987,7 +1987,7 @@ * \retval -ENOMEM Memory allocation failure. * \retval -ENOENT Invalid MD object. * - * \see lnet_event::hdr_data and lnet_event_kind_t. + * \see lnet_event::hdr_data and lnet_event_kind. */ int LNetPut(lnet_nid_t self, struct lnet_handle_md mdh, lnet_ack_req_t ack, diff --git a/drivers/staging/lustre/lnet/lnet/lib-msg.c b/drivers/staging/lustre/lnet/lnet/lib-msg.c index b9b0259..008ac50 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-msg.c +++ b/drivers/staging/lustre/lnet/lnet/lib-msg.c @@ -54,7 +54,7 @@ * Don't need any lock, must be called after lnet_commit_md */ void -lnet_build_msg_event(struct lnet_msg *msg, lnet_event_kind_t ev_type) +lnet_build_msg_event(struct lnet_msg *msg, enum lnet_event_kind ev_type) { struct lnet_hdr *hdr = &msg->msg_hdr; struct lnet_event *ev = &msg->msg_ev; diff --git a/drivers/staging/lustre/lnet/selftest/selftest.h b/drivers/staging/lustre/lnet/selftest/selftest.h index 2e2c215..3c68cf3 100644 --- a/drivers/staging/lustre/lnet/selftest/selftest.h +++ b/drivers/staging/lustre/lnet/selftest/selftest.h @@ -144,7 +144,7 @@ enum srpc_event_type { /* RPC event */ struct srpc_event { enum srpc_event_type ev_type; /* what's up */ - lnet_event_kind_t ev_lnet; /* LNet event type */ + enum lnet_event_kind ev_lnet; /* LNet event type */ int ev_fired; /* LNet event fired? */ int ev_status; /* LNet event status */ void *ev_data; /* owning server/client RPC */ -- 1.8.3.1 From jsimmons at infradead.org Mon Feb 27 00:41:28 2017 From: jsimmons at infradead.org (James Simmons) Date: Sun, 26 Feb 2017 19:41:28 -0500 Subject: [lustre-devel] [PATCH 03/34] staging: lustre: lnet: change lnet_handle_md_t to proper struct In-Reply-To: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> References: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> Message-ID: <1488156119-19670-4-git-send-email-jsimmons@infradead.org> Change lnet_handle_md_t from a typedef of another typedef into a proper stand alone structure. Create the inline functions LNetInvalidateMDHandle and LNetMDHandleIsInvalid to handle this new piece of data. Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/20831 Reviewed-by: Olaf Weber Reviewed-by: Doug Oucharek Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/include/linux/lnet/api.h | 10 ++++----- .../staging/lustre/include/linux/lnet/lib-lnet.h | 4 ++-- .../staging/lustre/include/linux/lnet/lib-types.h | 4 ++-- drivers/staging/lustre/include/linux/lnet/types.h | 25 ++++++++++++++++++++-- drivers/staging/lustre/lnet/lnet/api-ni.c | 21 ++++++++++-------- drivers/staging/lustre/lnet/lnet/lib-md.c | 7 +++--- drivers/staging/lustre/lnet/lnet/lib-move.c | 4 ++-- drivers/staging/lustre/lnet/lnet/router.c | 12 +++++------ drivers/staging/lustre/lnet/selftest/rpc.c | 10 ++++----- drivers/staging/lustre/lnet/selftest/selftest.h | 16 +++++++------- drivers/staging/lustre/lustre/include/lustre_net.h | 10 ++++----- drivers/staging/lustre/lustre/ptlrpc/client.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/niobuf.c | 4 ++-- 13 files changed, 77 insertions(+), 52 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/api.h b/drivers/staging/lustre/include/linux/lnet/api.h index 1db4e00..32c3f56 100644 --- a/drivers/staging/lustre/include/linux/lnet/api.h +++ b/drivers/staging/lustre/include/linux/lnet/api.h @@ -128,13 +128,13 @@ int LNetMEInsert(lnet_handle_me_t current_in, int LNetMDAttach(lnet_handle_me_t current_in, lnet_md_t md_in, lnet_unlink_t unlink_in, - lnet_handle_md_t *handle_out); + struct lnet_handle_md *md_handle_out); int LNetMDBind(lnet_md_t md_in, lnet_unlink_t unlink_in, - lnet_handle_md_t *handle_out); + struct lnet_handle_md *md_handle_out); -int LNetMDUnlink(lnet_handle_md_t md_in); +int LNetMDUnlink(struct lnet_handle_md md_in); /** @} lnet_md */ /** \defgroup lnet_eq Events and event queues @@ -180,7 +180,7 @@ int LNetEQPoll(struct lnet_handle_eq *eventqs_in, * @{ */ int LNetPut(lnet_nid_t self, - lnet_handle_md_t md_in, + struct lnet_handle_md md_in, lnet_ack_req_t ack_req_in, lnet_process_id_t target_in, unsigned int portal_in, @@ -189,7 +189,7 @@ int LNetPut(lnet_nid_t self, __u64 hdr_data_in); int LNetGet(lnet_nid_t self, - lnet_handle_md_t md_in, + struct lnet_handle_md md_in, lnet_process_id_t target_in, unsigned int portal_in, __u64 match_bits_in, diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h index 808d886..344a8a5 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h @@ -301,13 +301,13 @@ void lnet_res_lh_initialize(struct lnet_res_container *rec, } static inline void -lnet_md2handle(lnet_handle_md_t *handle, lnet_libmd_t *md) +lnet_md2handle(struct lnet_handle_md *handle, lnet_libmd_t *md) { handle->cookie = md->md_lh.lh_cookie; } static inline lnet_libmd_t * -lnet_handle2md(lnet_handle_md_t *handle) +lnet_handle2md(struct lnet_handle_md *handle) { /* ALWAYS called with resource lock held */ lnet_libhandle_t *lh; diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index 199e194..7ce0091 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -299,7 +299,7 @@ struct lnet_tx_queue { typedef struct { /* chain on the_lnet.ln_zombie_rcd or ln_deathrow_rcd */ struct list_head rcd_list; - lnet_handle_md_t rcd_mdh; /* ping buffer MD */ + struct lnet_handle_md rcd_mdh; /* ping buffer MD */ struct lnet_peer *rcd_gateway; /* reference to gateway */ struct lnet_ping_info *rcd_pinginfo; /* ping buffer */ } lnet_rc_data_t; @@ -597,7 +597,7 @@ struct lnet_msg_container { /* percpt router buffer pools */ lnet_rtrbufpool_t **ln_rtrpools; - lnet_handle_md_t ln_ping_target_md; + struct lnet_handle_md ln_ping_target_md; struct lnet_handle_eq ln_ping_target_eq; struct lnet_ping_info *ln_ping_info; diff --git a/drivers/staging/lustre/include/linux/lnet/types.h b/drivers/staging/lustre/include/linux/lnet/types.h index ebf87cd..8dcf3f9 100644 --- a/drivers/staging/lustre/include/linux/lnet/types.h +++ b/drivers/staging/lustre/include/linux/lnet/types.h @@ -284,7 +284,6 @@ struct lnet_ping_info { __u64 cookie; } lnet_handle_any_t; -typedef lnet_handle_any_t lnet_handle_md_t; typedef lnet_handle_any_t lnet_handle_me_t; #define LNET_WIRE_HANDLE_COOKIE_NONE (-1) @@ -339,6 +338,28 @@ static inline int LNetEQHandleIsInvalid(struct lnet_handle_eq h) return (LNET_WIRE_HANDLE_COOKIE_NONE == h.cookie); } +struct lnet_handle_md { + u64 cookie; +}; + +/** + * Invalidate md handle @h. + */ +static inline void LNetInvalidateMDHandle(struct lnet_handle_md *h) +{ + h->cookie = LNET_WIRE_HANDLE_COOKIE_NONE; +} + +/** + * Check whether eq handle @h is invalid. + * + * @return 1 if handle is invalid, 0 if valid. + */ +static inline int LNetMDHandleIsInvalid(struct lnet_handle_md h) +{ + return (LNET_WIRE_HANDLE_COOKIE_NONE == h.cookie); +} + /** * Global process ID. */ @@ -611,7 +632,7 @@ static inline int LNetEQHandleIsInvalid(struct lnet_handle_eq h) * The handle to the MD associated with the event. The handle may be * invalid if the MD has been unlinked. */ - lnet_handle_md_t md_handle; + struct lnet_handle_md md_handle; /** * A snapshot of the state of the MD immediately after the event has * been processed. In particular, the threshold field in md will diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index 0564e93..c9d754d 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -896,7 +896,8 @@ static void lnet_assert_wire_constants(void) } static int -lnet_ping_info_setup(struct lnet_ping_info **ppinfo, lnet_handle_md_t *md_handle, +lnet_ping_info_setup(struct lnet_ping_info **ppinfo, + struct lnet_handle_md *md_handle, int ni_count, bool set_eq) { lnet_process_id_t id = {LNET_NID_ANY, LNET_PID_ANY}; @@ -961,12 +962,13 @@ static void lnet_assert_wire_constants(void) } static void -lnet_ping_md_unlink(struct lnet_ping_info *pinfo, lnet_handle_md_t *md_handle) +lnet_ping_md_unlink(struct lnet_ping_info *pinfo, + struct lnet_handle_md *md_handle) { sigset_t blocked = cfs_block_allsigs(); LNetMDUnlink(*md_handle); - LNetInvalidateHandle(md_handle); + LNetInvalidateMDHandle(md_handle); /* NB md could be busy; this just starts the unlink */ while (pinfo->pi_features != LNET_PING_FEAT_INVAL) { @@ -1003,10 +1005,11 @@ static void lnet_assert_wire_constants(void) } static void -lnet_ping_target_update(struct lnet_ping_info *pinfo, lnet_handle_md_t md_handle) +lnet_ping_target_update(struct lnet_ping_info *pinfo, + struct lnet_handle_md md_handle) { struct lnet_ping_info *old_pinfo = NULL; - lnet_handle_md_t old_md; + struct lnet_handle_md old_md; /* switch the NIs to point to the new ping info created */ lnet_net_lock(LNET_LOCK_EX); @@ -1497,7 +1500,7 @@ void lnet_lib_exit(void) int rc; int ni_count; struct lnet_ping_info *pinfo; - lnet_handle_md_t md_handle; + struct lnet_handle_md md_handle; struct list_head net_head; INIT_LIST_HEAD(&net_head); @@ -1755,7 +1758,7 @@ void lnet_lib_exit(void) { char *nets = conf->cfg_config_u.cfg_net.net_intf; struct lnet_ping_info *pinfo; - lnet_handle_md_t md_handle; + struct lnet_handle_md md_handle; struct lnet_ni *ni; struct list_head net_head; lnet_remotenet_t *rnet; @@ -1835,7 +1838,7 @@ void lnet_lib_exit(void) { lnet_ni_t *ni; struct lnet_ping_info *pinfo; - lnet_handle_md_t md_handle; + struct lnet_handle_md md_handle; int rc; /* don't allow userspace to shutdown the LOLND */ @@ -2139,7 +2142,7 @@ static int lnet_ping(lnet_process_id_t id, int timeout_ms, lnet_process_id_t __user *ids, int n_ids) { struct lnet_handle_eq eqh; - lnet_handle_md_t mdh; + struct lnet_handle_md mdh; lnet_event_t event; lnet_md_t md = { NULL }; int which; diff --git a/drivers/staging/lustre/lnet/lnet/lib-md.c b/drivers/staging/lustre/lnet/lnet/lib-md.c index d97e046..f155839 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-md.c +++ b/drivers/staging/lustre/lnet/lnet/lib-md.c @@ -268,7 +268,7 @@ */ int LNetMDAttach(lnet_handle_me_t meh, lnet_md_t umd, - lnet_unlink_t unlink, lnet_handle_md_t *handle) + lnet_unlink_t unlink, struct lnet_handle_md *handle) { LIST_HEAD(matches); LIST_HEAD(drops); @@ -350,7 +350,8 @@ * LNetInvalidateHandle() on it. */ int -LNetMDBind(lnet_md_t umd, lnet_unlink_t unlink, lnet_handle_md_t *handle) +LNetMDBind(lnet_md_t umd, lnet_unlink_t unlink, + struct lnet_handle_md *handle) { lnet_libmd_t *md; int cpt; @@ -425,7 +426,7 @@ * \retval -ENOENT If \a mdh does not point to a valid MD object. */ int -LNetMDUnlink(lnet_handle_md_t mdh) +LNetMDUnlink(struct lnet_handle_md mdh) { lnet_event_t ev; lnet_libmd_t *md; diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c index 6b0be6c..88d87eb 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-move.c +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c @@ -1988,7 +1988,7 @@ * \see lnet_event_t::hdr_data and lnet_event_kind_t. */ int -LNetPut(lnet_nid_t self, lnet_handle_md_t mdh, lnet_ack_req_t ack, +LNetPut(lnet_nid_t self, struct lnet_handle_md mdh, lnet_ack_req_t ack, lnet_process_id_t target, unsigned int portal, __u64 match_bits, unsigned int offset, __u64 hdr_data) @@ -2193,7 +2193,7 @@ * \retval -ENOENT Invalid MD object. */ int -LNetGet(lnet_nid_t self, lnet_handle_md_t mdh, +LNetGet(lnet_nid_t self, struct lnet_handle_md mdh, lnet_process_id_t target, unsigned int portal, __u64 match_bits, unsigned int offset) { diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c index ba80221..eb14ce2 100644 --- a/drivers/staging/lustre/lnet/lnet/router.c +++ b/drivers/staging/lustre/lnet/lnet/router.c @@ -739,7 +739,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) LASSERT(rcd); if (event->unlinked) { - LNetInvalidateHandle(&rcd->rcd_mdh); + LNetInvalidateMDHandle(&rcd->rcd_mdh); return; } @@ -882,7 +882,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) { LASSERT(list_empty(&rcd->rcd_list)); /* detached from network */ - LASSERT(LNetHandleIsInvalid(rcd->rcd_mdh)); + LASSERT(LNetMDHandleIsInvalid(rcd->rcd_mdh)); if (rcd->rcd_gateway) { int cpt = rcd->rcd_gateway->lp_cpt; @@ -913,7 +913,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) if (!rcd) goto out; - LNetInvalidateHandle(&rcd->rcd_mdh); + LNetInvalidateMDHandle(&rcd->rcd_mdh); INIT_LIST_HEAD(&rcd->rcd_list); LIBCFS_ALLOC(pi, LNET_PINGINFO_SIZE); @@ -957,7 +957,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) out: if (rcd) { - if (!LNetHandleIsInvalid(rcd->rcd_mdh)) { + if (!LNetMDHandleIsInvalid(rcd->rcd_mdh)) { rc = LNetMDUnlink(rcd->rcd_mdh); LASSERT(!rc); } @@ -1023,7 +1023,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) cfs_time_seconds(secs)))) { int rc; lnet_process_id_t id; - lnet_handle_md_t mdh; + struct lnet_handle_md mdh; id.nid = rtr->lp_nid; id.pid = LNET_PID_LUSTRE; @@ -1171,7 +1171,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) while (!list_empty(&the_lnet.ln_rcd_zombie)) { list_for_each_entry_safe(rcd, tmp, &the_lnet.ln_rcd_zombie, rcd_list) { - if (LNetHandleIsInvalid(rcd->rcd_mdh)) + if (LNetMDHandleIsInvalid(rcd->rcd_mdh)) list_move(&rcd->rcd_list, &head); } diff --git a/drivers/staging/lustre/lnet/selftest/rpc.c b/drivers/staging/lustre/lnet/selftest/rpc.c index 3f070eb..af99962 100644 --- a/drivers/staging/lustre/lnet/selftest/rpc.c +++ b/drivers/staging/lustre/lnet/selftest/rpc.c @@ -185,7 +185,7 @@ struct srpc_bulk * rpc->srpc_reqstbuf = buffer; rpc->srpc_peer = buffer->buf_peer; rpc->srpc_self = buffer->buf_self; - LNetInvalidateHandle(&rpc->srpc_replymdh); + LNetInvalidateMDHandle(&rpc->srpc_replymdh); } static void @@ -356,7 +356,7 @@ struct srpc_bulk * static int srpc_post_passive_rdma(int portal, int local, __u64 matchbits, void *buf, int len, int options, lnet_process_id_t peer, - lnet_handle_md_t *mdh, struct srpc_event *ev) + struct lnet_handle_md *mdh, struct srpc_event *ev) { int rc; lnet_md_t md; @@ -395,7 +395,7 @@ struct srpc_bulk * static int srpc_post_active_rdma(int portal, __u64 matchbits, void *buf, int len, int options, lnet_process_id_t peer, lnet_nid_t self, - lnet_handle_md_t *mdh, struct srpc_event *ev) + struct lnet_handle_md *mdh, struct srpc_event *ev) { int rc; lnet_md_t md; @@ -448,7 +448,7 @@ struct srpc_bulk * static int srpc_post_passive_rqtbuf(int service, int local, void *buf, int len, - lnet_handle_md_t *mdh, struct srpc_event *ev) + struct lnet_handle_md *mdh, struct srpc_event *ev) { lnet_process_id_t any = { 0 }; @@ -468,7 +468,7 @@ struct srpc_bulk * struct srpc_msg *msg = &buf->buf_msg; int rc; - LNetInvalidateHandle(&buf->buf_mdh); + LNetInvalidateMDHandle(&buf->buf_mdh); list_add(&buf->buf_list, &scd->scd_buf_posted); scd->scd_buf_nposted++; spin_unlock(&scd->scd_lock); diff --git a/drivers/staging/lustre/lnet/selftest/selftest.h b/drivers/staging/lustre/lnet/selftest/selftest.h index f259480..91088c6 100644 --- a/drivers/staging/lustre/lnet/selftest/selftest.h +++ b/drivers/staging/lustre/lnet/selftest/selftest.h @@ -153,7 +153,7 @@ struct srpc_event { /* bulk descriptor */ struct srpc_bulk { int bk_len; /* len of bulk data */ - lnet_handle_md_t bk_mdh; + struct lnet_handle_md bk_mdh; int bk_sink; /* sink/source */ int bk_niov; /* # iov in bk_iovs */ lnet_kiov_t bk_iovs[0]; @@ -163,7 +163,7 @@ struct srpc_bulk { struct srpc_buffer { struct list_head buf_list; /* chain on srpc_service::*_msgq */ struct srpc_msg buf_msg; - lnet_handle_md_t buf_mdh; + struct lnet_handle_md buf_mdh; lnet_nid_t buf_self; lnet_process_id_t buf_peer; }; @@ -188,7 +188,7 @@ struct srpc_server_rpc { lnet_nid_t srpc_self; lnet_process_id_t srpc_peer; struct srpc_msg srpc_replymsg; - lnet_handle_md_t srpc_replymdh; + struct lnet_handle_md srpc_replymdh; struct srpc_buffer *srpc_reqstbuf; struct srpc_bulk *srpc_bulk; @@ -225,8 +225,8 @@ struct srpc_client_rpc { /* bulk, request(reqst), and reply exchanged on wire */ struct srpc_msg crpc_reqstmsg; struct srpc_msg crpc_replymsg; - lnet_handle_md_t crpc_reqstmdh; - lnet_handle_md_t crpc_replymdh; + struct lnet_handle_md crpc_reqstmdh; + struct lnet_handle_md crpc_replymdh; struct srpc_bulk crpc_bulk; }; @@ -545,9 +545,9 @@ struct srpc_bulk *srpc_alloc_bulk(int cpt, unsigned int off, rpc->crpc_bulk.bk_niov = nbulkiov; rpc->crpc_done = rpc_done; rpc->crpc_fini = rpc_fini; - LNetInvalidateHandle(&rpc->crpc_reqstmdh); - LNetInvalidateHandle(&rpc->crpc_replymdh); - LNetInvalidateHandle(&rpc->crpc_bulk.bk_mdh); + LNetInvalidateMDHandle(&rpc->crpc_reqstmdh); + LNetInvalidateMDHandle(&rpc->crpc_replymdh); + LNetInvalidateMDHandle(&rpc->crpc_bulk.bk_mdh); /* no event is expected at this point */ rpc->crpc_bulkev.ev_fired = 1; diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h index 7955cbf..c28c4ac 100644 --- a/drivers/staging/lustre/lustre/include/lustre_net.h +++ b/drivers/staging/lustre/lustre/include/lustre_net.h @@ -457,7 +457,7 @@ struct ptlrpc_reply_state { struct obd_export *rs_export; struct ptlrpc_service_part *rs_svcpt; /** Lnet metadata handle for the reply */ - lnet_handle_md_t rs_md_h; + struct lnet_handle_md rs_md_h; /** Context for the service thread */ struct ptlrpc_svc_ctx *rs_svc_ctx; @@ -586,11 +586,11 @@ struct ptlrpc_cli_req { /** Link back to the request set */ struct ptlrpc_request_set *cr_set; /** outgoing request MD handle */ - lnet_handle_md_t cr_req_md_h; + struct lnet_handle_md cr_req_md_h; /** request-out callback parameter */ struct ptlrpc_cb_id cr_req_cbid; /** incoming reply MD handle */ - lnet_handle_md_t cr_reply_md_h; + struct lnet_handle_md cr_reply_md_h; wait_queue_head_t cr_reply_waitq; /** reply callback parameter */ struct ptlrpc_cb_id cr_reply_cbid; @@ -1225,7 +1225,7 @@ struct ptlrpc_bulk_desc { int bd_md_count; /* # valid entries in bd_mds */ int bd_md_max_brw; /* max entries in bd_mds */ /** array of associated MDs */ - lnet_handle_md_t bd_mds[PTLRPC_BULK_OPS_COUNT]; + struct lnet_handle_md bd_mds[PTLRPC_BULK_OPS_COUNT]; union { struct { @@ -1376,7 +1376,7 @@ struct ptlrpc_request_buffer_desc { /** Back pointer to service for which this buffer is registered */ struct ptlrpc_service_part *rqbd_svcpt; /** LNet descriptor */ - lnet_handle_md_t rqbd_md_h; + struct lnet_handle_md rqbd_md_h; int rqbd_refcount; /** The buffer itself */ char *rqbd_buffer; diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c index 45b9aec..5645c31 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c @@ -151,7 +151,7 @@ struct ptlrpc_bulk_desc *ptlrpc_new_bulk(unsigned int nfrags, * node. Negotiated ocd_brw_size will always be <= this number. */ for (i = 0; i < PTLRPC_BULK_OPS_COUNT; i++) - LNetInvalidateHandle(&desc->bd_mds[i]); + LNetInvalidateMDHandle(&desc->bd_mds[i]); return desc; free_desc: diff --git a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c index 352f614..64b8ce0 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c +++ b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c @@ -43,7 +43,7 @@ * over \a conn connection to portal \a portal. * Returns 0 on success or error code. */ -static int ptl_send_buf(lnet_handle_md_t *mdh, void *base, int len, +static int ptl_send_buf(struct lnet_handle_md *mdh, void *base, int len, lnet_ack_req_t ack, struct ptlrpc_cb_id *cbid, struct ptlrpc_connection *conn, int portal, __u64 xid, unsigned int offset) @@ -94,7 +94,7 @@ static int ptl_send_buf(lnet_handle_md_t *mdh, void *base, int len, return 0; } -static void mdunlink_iterate_helper(lnet_handle_md_t *bd_mds, int count) +static void mdunlink_iterate_helper(struct lnet_handle_md *bd_mds, int count) { int i; -- 1.8.3.1 From jsimmons at infradead.org Mon Feb 27 00:41:29 2017 From: jsimmons at infradead.org (James Simmons) Date: Sun, 26 Feb 2017 19:41:29 -0500 Subject: [lustre-devel] [PATCH 04/34] staging: lustre: lnet: change lnet_handle_me_t to proper struct In-Reply-To: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> References: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> Message-ID: <1488156119-19670-5-git-send-email-jsimmons@infradead.org> Change lnet_handle_me_t from a typedef of another typedef into a proper stand alone structure. Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/20831 Reviewed-by: Olaf Weber Reviewed-by: Doug Oucharek Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/include/linux/lnet/api.h | 10 +++++----- drivers/staging/lustre/include/linux/lnet/lib-lnet.h | 4 ++-- drivers/staging/lustre/include/linux/lnet/types.h | 6 ++++-- drivers/staging/lustre/lnet/lnet/api-ni.c | 2 +- drivers/staging/lustre/lnet/lnet/lib-md.c | 2 +- drivers/staging/lustre/lnet/lnet/lib-me.c | 8 ++++---- drivers/staging/lustre/lnet/selftest/rpc.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/niobuf.c | 6 +++--- 8 files changed, 21 insertions(+), 19 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/api.h b/drivers/staging/lustre/include/linux/lnet/api.h index 32c3f56..af756e8 100644 --- a/drivers/staging/lustre/include/linux/lnet/api.h +++ b/drivers/staging/lustre/include/linux/lnet/api.h @@ -99,17 +99,17 @@ int LNetMEAttach(unsigned int portal, __u64 ignore_bits_in, lnet_unlink_t unlink_in, lnet_ins_pos_t pos_in, - lnet_handle_me_t *handle_out); + struct lnet_handle_me *handle_out); -int LNetMEInsert(lnet_handle_me_t current_in, +int LNetMEInsert(struct lnet_handle_me current_in, lnet_process_id_t match_id_in, __u64 match_bits_in, __u64 ignore_bits_in, lnet_unlink_t unlink_in, lnet_ins_pos_t position_in, - lnet_handle_me_t *handle_out); + struct lnet_handle_me *handle_out); -int LNetMEUnlink(lnet_handle_me_t current_in); +int LNetMEUnlink(struct lnet_handle_me current_in); /** @} lnet_me */ /** \defgroup lnet_md Memory descriptors @@ -125,7 +125,7 @@ int LNetMEInsert(lnet_handle_me_t current_in, * associated with a MD: LNetMDUnlink(). * @{ */ -int LNetMDAttach(lnet_handle_me_t current_in, +int LNetMDAttach(struct lnet_handle_me current_in, lnet_md_t md_in, lnet_unlink_t unlink_in, struct lnet_handle_md *md_handle_out); diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h index 344a8a5..bd8d117 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h @@ -342,13 +342,13 @@ void lnet_res_lh_initialize(struct lnet_res_container *rec, } static inline void -lnet_me2handle(lnet_handle_me_t *handle, lnet_me_t *me) +lnet_me2handle(struct lnet_handle_me *handle, lnet_me_t *me) { handle->cookie = me->me_lh.lh_cookie; } static inline lnet_me_t * -lnet_handle2me(lnet_handle_me_t *handle) +lnet_handle2me(struct lnet_handle_me *handle) { /* ALWAYS called with resource lock held */ lnet_libhandle_t *lh; diff --git a/drivers/staging/lustre/include/linux/lnet/types.h b/drivers/staging/lustre/include/linux/lnet/types.h index 8dcf3f9..513ad6f 100644 --- a/drivers/staging/lustre/include/linux/lnet/types.h +++ b/drivers/staging/lustre/include/linux/lnet/types.h @@ -284,8 +284,6 @@ struct lnet_ping_info { __u64 cookie; } lnet_handle_any_t; -typedef lnet_handle_any_t lnet_handle_me_t; - #define LNET_WIRE_HANDLE_COOKIE_NONE (-1) /** @@ -360,6 +358,10 @@ static inline int LNetMDHandleIsInvalid(struct lnet_handle_md h) return (LNET_WIRE_HANDLE_COOKIE_NONE == h.cookie); } +struct lnet_handle_me { + u64 cookie; +}; + /** * Global process ID. */ diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index c9d754d..a650fe0 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -901,7 +901,7 @@ static void lnet_assert_wire_constants(void) int ni_count, bool set_eq) { lnet_process_id_t id = {LNET_NID_ANY, LNET_PID_ANY}; - lnet_handle_me_t me_handle; + struct lnet_handle_me me_handle; lnet_md_t md = { NULL }; int rc, rc2; diff --git a/drivers/staging/lustre/lnet/lnet/lib-md.c b/drivers/staging/lustre/lnet/lnet/lib-md.c index f155839..4f2700e 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-md.c +++ b/drivers/staging/lustre/lnet/lnet/lib-md.c @@ -267,7 +267,7 @@ * a MD. */ int -LNetMDAttach(lnet_handle_me_t meh, lnet_md_t umd, +LNetMDAttach(struct lnet_handle_me meh, lnet_md_t umd, lnet_unlink_t unlink, struct lnet_handle_md *handle) { LIST_HEAD(matches); diff --git a/drivers/staging/lustre/lnet/lnet/lib-me.c b/drivers/staging/lustre/lnet/lnet/lib-me.c index eb796a8..0ea64f6 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-me.c +++ b/drivers/staging/lustre/lnet/lnet/lib-me.c @@ -73,7 +73,7 @@ lnet_process_id_t match_id, __u64 match_bits, __u64 ignore_bits, lnet_unlink_t unlink, lnet_ins_pos_t pos, - lnet_handle_me_t *handle) + struct lnet_handle_me *handle) { struct lnet_match_table *mtable; struct lnet_me *me; @@ -140,11 +140,11 @@ * \retval -ENOENT If \a current_meh does not point to a valid match entry. */ int -LNetMEInsert(lnet_handle_me_t current_meh, +LNetMEInsert(struct lnet_handle_me current_meh, lnet_process_id_t match_id, __u64 match_bits, __u64 ignore_bits, lnet_unlink_t unlink, lnet_ins_pos_t pos, - lnet_handle_me_t *handle) + struct lnet_handle_me *handle) { struct lnet_me *current_me; struct lnet_me *new_me; @@ -220,7 +220,7 @@ * \see LNetMDUnlink() for the discussion on delivering unlink event. */ int -LNetMEUnlink(lnet_handle_me_t meh) +LNetMEUnlink(struct lnet_handle_me meh) { lnet_me_t *me; lnet_libmd_t *md; diff --git a/drivers/staging/lustre/lnet/selftest/rpc.c b/drivers/staging/lustre/lnet/selftest/rpc.c index af99962..9a0b06f 100644 --- a/drivers/staging/lustre/lnet/selftest/rpc.c +++ b/drivers/staging/lustre/lnet/selftest/rpc.c @@ -360,7 +360,7 @@ struct srpc_bulk * { int rc; lnet_md_t md; - lnet_handle_me_t meh; + struct lnet_handle_me meh; rc = LNetMEAttach(portal, peer, matchbits, 0, LNET_UNLINK, local ? LNET_INS_LOCAL : LNET_INS_AFTER, &meh); diff --git a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c index 64b8ce0..bb6d76a 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c +++ b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c @@ -115,7 +115,7 @@ static int ptlrpc_register_bulk(struct ptlrpc_request *req) int posted_md; int total_md; u64 mbits; - lnet_handle_me_t me_h; + struct lnet_handle_me me_h; lnet_md_t md; if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_BULK_GET_NET)) @@ -472,7 +472,7 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) int rc2; int mpflag = 0; struct ptlrpc_connection *connection; - lnet_handle_me_t reply_me_h; + struct lnet_handle_me reply_me_h; lnet_md_t reply_md; struct obd_import *imp = request->rq_import; struct obd_device *obd = imp->imp_obd; @@ -722,7 +722,7 @@ int ptlrpc_register_rqbd(struct ptlrpc_request_buffer_desc *rqbd) static lnet_process_id_t match_id = {LNET_NID_ANY, LNET_PID_ANY}; int rc; lnet_md_t md; - lnet_handle_me_t me_h; + struct lnet_handle_me me_h; CDEBUG(D_NET, "LNetMEAttach: portal %d\n", service->srv_req_portal); -- 1.8.3.1 From jsimmons at infradead.org Mon Feb 27 00:41:31 2017 From: jsimmons at infradead.org (James Simmons) Date: Sun, 26 Feb 2017 19:41:31 -0500 Subject: [lustre-devel] [PATCH 06/34] staging: lustre: lnet: change lnet_msg_t to proper structure In-Reply-To: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> References: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> Message-ID: <1488156119-19670-7-git-send-email-jsimmons@infradead.org> Change lnet_msg_t from typedef to proper structure. Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/20831 Reviewed-by: Olaf Weber Reviewed-by: Doug Oucharek Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- .../staging/lustre/include/linux/lnet/lib-lnet.h | 43 +++++++------ .../staging/lustre/include/linux/lnet/lib-types.h | 11 ++-- .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h | 8 +-- .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 10 +-- .../staging/lustre/lnet/klnds/socklnd/socklnd.h | 6 +- .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 8 +-- drivers/staging/lustre/lnet/lnet/api-ni.c | 2 +- drivers/staging/lustre/lnet/lnet/lib-move.c | 75 +++++++++++----------- drivers/staging/lustre/lnet/lnet/lib-msg.c | 25 ++++---- drivers/staging/lustre/lnet/lnet/lib-ptl.c | 4 +- drivers/staging/lustre/lnet/lnet/lo.c | 6 +- 11 files changed, 102 insertions(+), 96 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h index bd8d117..e894990 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h @@ -248,10 +248,10 @@ static inline int lnet_md_unlinkable(lnet_libmd_t *md) LIBCFS_FREE(me, sizeof(*me)); } -static inline lnet_msg_t * +static inline struct lnet_msg * lnet_msg_alloc(void) { - lnet_msg_t *msg; + struct lnet_msg *msg; LIBCFS_ALLOC(msg, sizeof(*msg)); @@ -260,7 +260,7 @@ static inline int lnet_md_unlinkable(lnet_libmd_t *md) } static inline void -lnet_msg_free(lnet_msg_t *msg) +lnet_msg_free(struct lnet_msg *msg) { LASSERT(!msg->msg_onactivelist); LIBCFS_FREE(msg, sizeof(*msg)); @@ -482,20 +482,20 @@ int lnet_dyn_add_ni(lnet_pid_t requested_pid, int lnet_islocalnid(lnet_nid_t nid); int lnet_islocalnet(__u32 net); -void lnet_msg_attach_md(lnet_msg_t *msg, lnet_libmd_t *md, +void lnet_msg_attach_md(struct lnet_msg *msg, lnet_libmd_t *md, unsigned int offset, unsigned int mlen); -void lnet_msg_detach_md(lnet_msg_t *msg, int status); +void lnet_msg_detach_md(struct lnet_msg *msg, int status); void lnet_build_unlink_event(lnet_libmd_t *md, lnet_event_t *ev); -void lnet_build_msg_event(lnet_msg_t *msg, lnet_event_kind_t ev_type); -void lnet_msg_commit(lnet_msg_t *msg, int cpt); -void lnet_msg_decommit(lnet_msg_t *msg, int cpt, int status); +void lnet_build_msg_event(struct lnet_msg *msg, lnet_event_kind_t ev_type); +void lnet_msg_commit(struct lnet_msg *msg, int cpt); +void lnet_msg_decommit(struct lnet_msg *msg, int cpt, int status); void lnet_eq_enqueue_event(lnet_eq_t *eq, lnet_event_t *ev); -void lnet_prep_send(lnet_msg_t *msg, int type, lnet_process_id_t target, +void lnet_prep_send(struct lnet_msg *msg, int type, lnet_process_id_t target, unsigned int offset, unsigned int len); -int lnet_send(lnet_nid_t nid, lnet_msg_t *msg, lnet_nid_t rtr_nid); -void lnet_return_tx_credits_locked(lnet_msg_t *msg); -void lnet_return_rx_credits_locked(lnet_msg_t *msg); +int lnet_send(lnet_nid_t nid, struct lnet_msg *msg, lnet_nid_t rtr_nid); +void lnet_return_tx_credits_locked(struct lnet_msg *msg); +void lnet_return_rx_credits_locked(struct lnet_msg *msg); void lnet_schedule_blocked_locked(lnet_rtrbufpool_t *rbp); void lnet_drop_routed_msgs_locked(struct list_head *list, int cpt); @@ -554,19 +554,22 @@ void lnet_ptl_attach_md(lnet_me_t *me, lnet_libmd_t *md, /* message functions */ int lnet_parse(lnet_ni_t *ni, struct lnet_hdr *hdr, lnet_nid_t fromnid, void *private, int rdma_req); -int lnet_parse_local(lnet_ni_t *ni, lnet_msg_t *msg); -int lnet_parse_forward_locked(lnet_ni_t *ni, lnet_msg_t *msg); +int lnet_parse_local(lnet_ni_t *ni, struct lnet_msg *msg); +int lnet_parse_forward_locked(lnet_ni_t *ni, struct lnet_msg *msg); -void lnet_recv(lnet_ni_t *ni, void *private, lnet_msg_t *msg, int delayed, - unsigned int offset, unsigned int mlen, unsigned int rlen); -void lnet_ni_recv(lnet_ni_t *ni, void *private, lnet_msg_t *msg, +void lnet_recv(lnet_ni_t *ni, void *private, struct lnet_msg *msg, + int delayed, unsigned int offset, unsigned int mlen, + unsigned int rlen); +void lnet_ni_recv(lnet_ni_t *ni, void *private, struct lnet_msg *msg, int delayed, unsigned int offset, unsigned int mlen, unsigned int rlen); -lnet_msg_t *lnet_create_reply_msg(lnet_ni_t *ni, lnet_msg_t *get_msg); -void lnet_set_reply_msg_len(lnet_ni_t *ni, lnet_msg_t *msg, unsigned int len); +struct lnet_msg *lnet_create_reply_msg(lnet_ni_t *ni, + struct lnet_msg *get_msg); +void lnet_set_reply_msg_len(lnet_ni_t *ni, struct lnet_msg *msg, + unsigned int len); -void lnet_finalize(lnet_ni_t *ni, lnet_msg_t *msg, int rc); +void lnet_finalize(lnet_ni_t *ni, struct lnet_msg *msg, int rc); void lnet_drop_message(lnet_ni_t *ni, int cpt, void *private, unsigned int nob); diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index 7ce0091..e3cb795 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -54,7 +54,7 @@ /* forward refs */ struct lnet_libmd; -typedef struct lnet_msg { +struct lnet_msg { struct list_head msg_activelist; struct list_head msg_list; /* Q for credits/MD */ @@ -106,7 +106,7 @@ lnet_event_t msg_ev; struct lnet_hdr msg_hdr; -} lnet_msg_t; +}; typedef struct lnet_libhandle { struct list_head lh_hash_chain; @@ -210,7 +210,8 @@ * non-zero for immediate failure, otherwise complete later with * lnet_finalize() */ - int (*lnd_send)(struct lnet_ni *ni, void *private, lnet_msg_t *msg); + int (*lnd_send)(struct lnet_ni *ni, void *private, + struct lnet_msg *msg); /* * Start receiving 'mlen' bytes of payload data, skipping the following @@ -219,7 +220,7 @@ * complete later with lnet_finalize(). This also gives back a receive * credit if the LND does flow control. */ - int (*lnd_recv)(struct lnet_ni *ni, void *private, lnet_msg_t *msg, + int (*lnd_recv)(struct lnet_ni *ni, void *private, struct lnet_msg *msg, int delayed, struct iov_iter *to, unsigned int rlen); /* @@ -231,7 +232,7 @@ * release resources; lnd_recv() will not be called. */ int (*lnd_eager_recv)(struct lnet_ni *ni, void *private, - lnet_msg_t *msg, void **new_privatep); + struct lnet_msg *msg, void **new_privatep); /* notification of peer health */ void (*lnd_notify)(struct lnet_ni *ni, lnet_nid_t peer, int alive); diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h index 366372d..dbd3b8e 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h @@ -490,7 +490,7 @@ struct kib_tx { /* transmit message */ int tx_status; /* LNET completion status */ unsigned long tx_deadline; /* completion deadline */ __u64 tx_cookie; /* completion cookie */ - lnet_msg_t *tx_lntmsg[2]; /* lnet msgs to finalize on completion */ + struct lnet_msg *tx_lntmsg[2]; /* lnet msgs to finalize on completion */ struct kib_msg *tx_msg; /* message buffer (host vaddr) */ __u64 tx_msgaddr; /* message buffer (I/O addr) */ DECLARE_PCI_UNMAP_ADDR(tx_msgunmap); /* for dma_unmap_single() */ @@ -1032,6 +1032,6 @@ void kiblnd_pack_msg(lnet_ni_t *ni, struct kib_msg *msg, int version, int kiblnd_unpack_msg(struct kib_msg *msg, int nob); int kiblnd_post_rx(struct kib_rx *rx, int credit); -int kiblnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg); -int kiblnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, int delayed, - struct iov_iter *to, unsigned int rlen); +int kiblnd_send(lnet_ni_t *ni, void *private, struct lnet_msg *lntmsg); +int kiblnd_recv(lnet_ni_t *ni, void *private, struct lnet_msg *lntmsg, + int delayed, struct iov_iter *to, unsigned int rlen); diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c index 6eaa548..021e6ac 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c @@ -53,7 +53,7 @@ static int kiblnd_init_rdma(struct kib_conn *conn, struct kib_tx *tx, int type, static void kiblnd_tx_done(lnet_ni_t *ni, struct kib_tx *tx) { - lnet_msg_t *lntmsg[2]; + struct lnet_msg *lntmsg[2]; struct kib_net *net = ni->ni_data; int rc; int i; @@ -1475,7 +1475,7 @@ static int kiblnd_resolve_addr(struct rdma_cm_id *cmid, } int -kiblnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg) +kiblnd_send(lnet_ni_t *ni, void *private, struct lnet_msg *lntmsg) { struct lnet_hdr *hdr = &lntmsg->msg_hdr; int type = lntmsg->msg_type; @@ -1648,7 +1648,7 @@ static int kiblnd_resolve_addr(struct rdma_cm_id *cmid, } static void -kiblnd_reply(lnet_ni_t *ni, struct kib_rx *rx, lnet_msg_t *lntmsg) +kiblnd_reply(lnet_ni_t *ni, struct kib_rx *rx, struct lnet_msg *lntmsg) { lnet_process_id_t target = lntmsg->msg_target; unsigned int niov = lntmsg->msg_niov; @@ -1709,8 +1709,8 @@ static int kiblnd_resolve_addr(struct rdma_cm_id *cmid, } int -kiblnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, int delayed, - struct iov_iter *to, unsigned int rlen) +kiblnd_recv(lnet_ni_t *ni, void *private, struct lnet_msg *lntmsg, + int delayed, struct iov_iter *to, unsigned int rlen) { struct kib_rx *rx = private; struct kib_msg *rxmsg = rx->rx_msg; diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h index 3631998..d03a029 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h @@ -284,7 +284,7 @@ struct ksock_tx { /* transmit packet */ unsigned short tx_nonblk:1; /* it's a non-blocking ACK */ lnet_kiov_t *tx_kiov; /* packet page frags */ struct ksock_conn *tx_conn; /* owning conn */ - lnet_msg_t *tx_lnetmsg; /* lnet message for lnet_finalize() + struct lnet_msg *tx_lnetmsg; /* lnet message for lnet_finalize() */ unsigned long tx_deadline; /* when (in jiffies) tx times out */ struct ksock_msg tx_msg; /* socklnd message buffer */ @@ -650,8 +650,8 @@ static inline __u32 ksocknal_csum(__u32 crc, unsigned char const *p, size_t len) int ksocknal_startup(lnet_ni_t *ni); void ksocknal_shutdown(lnet_ni_t *ni); int ksocknal_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg); -int ksocknal_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg); -int ksocknal_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, +int ksocknal_send(lnet_ni_t *ni, void *private, struct lnet_msg *lntmsg); +int ksocknal_recv(lnet_ni_t *ni, void *private, struct lnet_msg *lntmsg, int delayed, struct iov_iter *to, unsigned int rlen); int ksocknal_accept(lnet_ni_t *ni, struct socket *sock); diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c index 9fbae62..66827f2 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c @@ -395,7 +395,7 @@ struct ksock_tx * void ksocknal_tx_done(lnet_ni_t *ni, struct ksock_tx *tx) { - lnet_msg_t *lnetmsg = tx->tx_lnetmsg; + struct lnet_msg *lnetmsg = tx->tx_lnetmsg; int rc = (!tx->tx_resid && !tx->tx_zc_aborted) ? 0 : -EIO; LASSERT(ni || tx->tx_conn); @@ -938,7 +938,7 @@ struct ksock_route * } int -ksocknal_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg) +ksocknal_send(lnet_ni_t *ni, void *private, struct lnet_msg *lntmsg) { int mpflag = 1; int type = lntmsg->msg_type; @@ -1333,8 +1333,8 @@ struct ksock_route * } int -ksocknal_recv(lnet_ni_t *ni, void *private, lnet_msg_t *msg, int delayed, - struct iov_iter *to, unsigned int rlen) +ksocknal_recv(lnet_ni_t *ni, void *private, struct lnet_msg *msg, + int delayed, struct iov_iter *to, unsigned int rlen) { struct ksock_conn *conn = private; struct ksock_sched *sched = conn->ksnc_scheduler; diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index efafd42..5161b8a 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -1173,7 +1173,7 @@ static void lnet_assert_wire_constants(void) /* * Clear lazy portals and drop delayed messages which hold refs - * on their lnet_msg_t::msg_rxpeer + * on their lnet_msg::msg_rxpeer */ for (i = 0; i < the_lnet.ln_nportals; i++) LNetClearLazyPortal(i); diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c index 88d87eb..a789d7e 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-move.c +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c @@ -364,8 +364,9 @@ EXPORT_SYMBOL(lnet_extract_kiov); void -lnet_ni_recv(lnet_ni_t *ni, void *private, lnet_msg_t *msg, int delayed, - unsigned int offset, unsigned int mlen, unsigned int rlen) +lnet_ni_recv(lnet_ni_t *ni, void *private, struct lnet_msg *msg, + int delayed, unsigned int offset, unsigned int mlen, + unsigned int rlen) { unsigned int niov = 0; struct kvec *iov = NULL; @@ -409,7 +410,7 @@ } static void -lnet_setpayloadbuffer(lnet_msg_t *msg) +lnet_setpayloadbuffer(struct lnet_msg *msg) { lnet_libmd_t *md = msg->msg_md; @@ -428,7 +429,7 @@ } void -lnet_prep_send(lnet_msg_t *msg, int type, lnet_process_id_t target, +lnet_prep_send(struct lnet_msg *msg, int type, lnet_process_id_t target, unsigned int offset, unsigned int len) { msg->msg_type = type; @@ -449,7 +450,7 @@ } static void -lnet_ni_send(lnet_ni_t *ni, lnet_msg_t *msg) +lnet_ni_send(lnet_ni_t *ni, struct lnet_msg *msg) { void *priv = msg->msg_private; int rc; @@ -464,7 +465,7 @@ } static int -lnet_ni_eager_recv(lnet_ni_t *ni, lnet_msg_t *msg) +lnet_ni_eager_recv(lnet_ni_t *ni, struct lnet_msg *msg) { int rc; @@ -595,7 +596,7 @@ * \retval -ECANCELED If the MD of the message has been unlinked. */ static int -lnet_post_send_locked(lnet_msg_t *msg, int do_send) +lnet_post_send_locked(struct lnet_msg *msg, int do_send) { lnet_peer_t *lp = msg->msg_txpeer; lnet_ni_t *ni = lp->lp_ni; @@ -680,7 +681,7 @@ } static lnet_rtrbufpool_t * -lnet_msg2bufpool(lnet_msg_t *msg) +lnet_msg2bufpool(struct lnet_msg *msg) { lnet_rtrbufpool_t *rbp; int cpt; @@ -700,7 +701,7 @@ } static int -lnet_post_routed_recv_locked(lnet_msg_t *msg, int do_recv) +lnet_post_routed_recv_locked(struct lnet_msg *msg, int do_recv) { /* * lnet_parse is going to lnet_net_unlock immediately after this, so it @@ -776,10 +777,10 @@ } void -lnet_return_tx_credits_locked(lnet_msg_t *msg) +lnet_return_tx_credits_locked(struct lnet_msg *msg) { lnet_peer_t *txpeer = msg->msg_txpeer; - lnet_msg_t *msg2; + struct lnet_msg *msg2; if (msg->msg_txcredit) { struct lnet_ni *ni = txpeer->lp_ni; @@ -794,7 +795,7 @@ tq->tq_credits++; if (tq->tq_credits <= 0) { msg2 = list_entry(tq->tq_delayed.next, - lnet_msg_t, msg_list); + struct lnet_msg, msg_list); list_del(&msg2->msg_list); LASSERT(msg2->msg_txpeer->lp_ni == ni); @@ -817,7 +818,7 @@ txpeer->lp_txcredits++; if (txpeer->lp_txcredits <= 0) { msg2 = list_entry(txpeer->lp_txq.next, - lnet_msg_t, msg_list); + struct lnet_msg, msg_list); list_del(&msg2->msg_list); LASSERT(msg2->msg_txpeer == txpeer); @@ -836,12 +837,12 @@ void lnet_schedule_blocked_locked(lnet_rtrbufpool_t *rbp) { - lnet_msg_t *msg; + struct lnet_msg *msg; if (list_empty(&rbp->rbp_msgs)) return; msg = list_entry(rbp->rbp_msgs.next, - lnet_msg_t, msg_list); + struct lnet_msg, msg_list); list_del(&msg->msg_list); (void)lnet_post_routed_recv_locked(msg, 1); @@ -851,8 +852,8 @@ lnet_drop_routed_msgs_locked(struct list_head *list, int cpt) { struct list_head drop; - lnet_msg_t *msg; - lnet_msg_t *tmp; + struct lnet_msg *msg; + struct lnet_msg *tmp; INIT_LIST_HEAD(&drop); @@ -871,10 +872,10 @@ } void -lnet_return_rx_credits_locked(lnet_msg_t *msg) +lnet_return_rx_credits_locked(struct lnet_msg *msg) { lnet_peer_t *rxpeer = msg->msg_rxpeer; - lnet_msg_t *msg2; + struct lnet_msg *msg2; if (msg->msg_rtrcredit) { /* give back global router credits */ @@ -943,7 +944,7 @@ msg->msg_rx_cpt); } else if (rxpeer->lp_rtrcredits <= 0) { msg2 = list_entry(rxpeer->lp_rtrq.next, - lnet_msg_t, msg_list); + struct lnet_msg, msg_list); list_del(&msg2->msg_list); (void)lnet_post_routed_recv_locked(msg2, 1); @@ -1057,7 +1058,7 @@ } int -lnet_send(lnet_nid_t src_nid, lnet_msg_t *msg, lnet_nid_t rtr_nid) +lnet_send(lnet_nid_t src_nid, struct lnet_msg *msg, lnet_nid_t rtr_nid) { lnet_nid_t dst_nid = msg->msg_target.nid; struct lnet_ni *src_ni; @@ -1243,7 +1244,7 @@ } static void -lnet_recv_put(lnet_ni_t *ni, lnet_msg_t *msg) +lnet_recv_put(lnet_ni_t *ni, struct lnet_msg *msg) { struct lnet_hdr *hdr = &msg->msg_hdr; @@ -1264,7 +1265,7 @@ } static int -lnet_parse_put(lnet_ni_t *ni, lnet_msg_t *msg) +lnet_parse_put(lnet_ni_t *ni, struct lnet_msg *msg) { struct lnet_hdr *hdr = &msg->msg_hdr; struct lnet_match_info info; @@ -1322,7 +1323,7 @@ } static int -lnet_parse_get(lnet_ni_t *ni, lnet_msg_t *msg, int rdma_get) +lnet_parse_get(lnet_ni_t *ni, struct lnet_msg *msg, int rdma_get) { struct lnet_match_info info; struct lnet_hdr *hdr = &msg->msg_hdr; @@ -1386,7 +1387,7 @@ } static int -lnet_parse_reply(lnet_ni_t *ni, lnet_msg_t *msg) +lnet_parse_reply(lnet_ni_t *ni, struct lnet_msg *msg) { void *private = msg->msg_private; struct lnet_hdr *hdr = &msg->msg_hdr; @@ -1451,7 +1452,7 @@ } static int -lnet_parse_ack(lnet_ni_t *ni, lnet_msg_t *msg) +lnet_parse_ack(lnet_ni_t *ni, struct lnet_msg *msg) { struct lnet_hdr *hdr = &msg->msg_hdr; lnet_process_id_t src = {0}; @@ -1506,7 +1507,7 @@ * \retval -ve error code */ int -lnet_parse_forward_locked(lnet_ni_t *ni, lnet_msg_t *msg) +lnet_parse_forward_locked(lnet_ni_t *ni, struct lnet_msg *msg) { int rc = 0; @@ -1530,7 +1531,7 @@ } int -lnet_parse_local(lnet_ni_t *ni, lnet_msg_t *msg) +lnet_parse_local(lnet_ni_t *ni, struct lnet_msg *msg) { int rc; @@ -1874,9 +1875,9 @@ { while (!list_empty(head)) { lnet_process_id_t id = {0}; - lnet_msg_t *msg; + struct lnet_msg *msg; - msg = list_entry(head->next, lnet_msg_t, msg_list); + msg = list_entry(head->next, struct lnet_msg, msg_list); list_del(&msg->msg_list); id.nid = msg->msg_hdr.src_nid; @@ -1915,10 +1916,10 @@ lnet_recv_delayed_msg_list(struct list_head *head) { while (!list_empty(head)) { - lnet_msg_t *msg; + struct lnet_msg *msg; lnet_process_id_t id; - msg = list_entry(head->next, lnet_msg_t, msg_list); + msg = list_entry(head->next, struct lnet_msg, msg_list); list_del(&msg->msg_list); /* @@ -2009,7 +2010,7 @@ msg = lnet_msg_alloc(); if (!msg) { - CERROR("Dropping PUT to %s: ENOMEM on lnet_msg_t\n", + CERROR("Dropping PUT to %s: ENOMEM on struct lnet_msg\n", libcfs_id2str(target)); return -ENOMEM; } @@ -2072,8 +2073,8 @@ } EXPORT_SYMBOL(LNetPut); -lnet_msg_t * -lnet_create_reply_msg(lnet_ni_t *ni, lnet_msg_t *getmsg) +struct lnet_msg * +lnet_create_reply_msg(lnet_ni_t *ni, struct lnet_msg *getmsg) { /* * The LND can DMA direct to the GET md (i.e. no REPLY msg). This @@ -2151,7 +2152,7 @@ EXPORT_SYMBOL(lnet_create_reply_msg); void -lnet_set_reply_msg_len(lnet_ni_t *ni, lnet_msg_t *reply, unsigned int len) +lnet_set_reply_msg_len(lnet_ni_t *ni, struct lnet_msg *reply, unsigned int len) { /* * Set the REPLY length, now the RDMA that elides the REPLY message has @@ -2213,7 +2214,7 @@ msg = lnet_msg_alloc(); if (!msg) { - CERROR("Dropping GET to %s: ENOMEM on lnet_msg_t\n", + CERROR("Dropping GET to %s: ENOMEM on struct lnet_msg\n", libcfs_id2str(target)); return -ENOMEM; } diff --git a/drivers/staging/lustre/lnet/lnet/lib-msg.c b/drivers/staging/lustre/lnet/lnet/lib-msg.c index 7ee164e..d35d28b 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-msg.c +++ b/drivers/staging/lustre/lnet/lnet/lib-msg.c @@ -54,7 +54,7 @@ * Don't need any lock, must be called after lnet_commit_md */ void -lnet_build_msg_event(lnet_msg_t *msg, lnet_event_kind_t ev_type) +lnet_build_msg_event(struct lnet_msg *msg, lnet_event_kind_t ev_type) { struct lnet_hdr *hdr = &msg->msg_hdr; lnet_event_t *ev = &msg->msg_ev; @@ -129,7 +129,7 @@ } void -lnet_msg_commit(lnet_msg_t *msg, int cpt) +lnet_msg_commit(struct lnet_msg *msg, int cpt) { struct lnet_msg_container *container = the_lnet.ln_msg_containers[cpt]; lnet_counters_t *counters = the_lnet.ln_counters[cpt]; @@ -162,7 +162,7 @@ } static void -lnet_msg_decommit_tx(lnet_msg_t *msg, int status) +lnet_msg_decommit_tx(struct lnet_msg *msg, int status) { lnet_counters_t *counters; lnet_event_t *ev = &msg->msg_ev; @@ -214,7 +214,7 @@ } static void -lnet_msg_decommit_rx(lnet_msg_t *msg, int status) +lnet_msg_decommit_rx(struct lnet_msg *msg, int status) { lnet_counters_t *counters; lnet_event_t *ev = &msg->msg_ev; @@ -272,7 +272,7 @@ } void -lnet_msg_decommit(lnet_msg_t *msg, int cpt, int status) +lnet_msg_decommit(struct lnet_msg *msg, int cpt, int status) { int cpt2 = cpt; @@ -306,7 +306,7 @@ } void -lnet_msg_attach_md(lnet_msg_t *msg, lnet_libmd_t *md, +lnet_msg_attach_md(struct lnet_msg *msg, lnet_libmd_t *md, unsigned int offset, unsigned int mlen) { /* NB: @offset and @len are only useful for receiving */ @@ -336,7 +336,7 @@ } void -lnet_msg_detach_md(lnet_msg_t *msg, int status) +lnet_msg_detach_md(struct lnet_msg *msg, int status) { lnet_libmd_t *md = msg->msg_md; int unlink; @@ -359,7 +359,7 @@ } static int -lnet_complete_msg_locked(lnet_msg_t *msg, int cpt) +lnet_complete_msg_locked(struct lnet_msg *msg, int cpt) { struct lnet_handle_wire ack_wmd; int rc; @@ -437,7 +437,7 @@ } void -lnet_finalize(lnet_ni_t *ni, lnet_msg_t *msg, int status) +lnet_finalize(lnet_ni_t *ni, struct lnet_msg *msg, int status) { struct lnet_msg_container *container; int my_slot; @@ -502,7 +502,7 @@ while (!list_empty(&container->msc_finalizing)) { msg = list_entry(container->msc_finalizing.next, - lnet_msg_t, msg_list); + struct lnet_msg, msg_list); list_del(&msg->msg_list); @@ -538,9 +538,10 @@ return; while (!list_empty(&container->msc_active)) { - lnet_msg_t *msg = list_entry(container->msc_active.next, - lnet_msg_t, msg_activelist); + struct lnet_msg *msg; + msg = list_entry(container->msc_active.next, + struct lnet_msg, msg_activelist); LASSERT(msg->msg_onactivelist); msg->msg_onactivelist = 0; list_del(&msg->msg_activelist); diff --git a/drivers/staging/lustre/lnet/lnet/lib-ptl.c b/drivers/staging/lustre/lnet/lnet/lib-ptl.c index fa515af..891d028 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-ptl.c +++ b/drivers/staging/lustre/lnet/lnet/lib-ptl.c @@ -657,8 +657,8 @@ struct list_head * struct lnet_portal *ptl = the_lnet.ln_portals[me->me_portal]; struct lnet_match_table *mtable; struct list_head *head; - lnet_msg_t *tmp; - lnet_msg_t *msg; + struct lnet_msg *tmp; + struct lnet_msg *msg; int exhausted = 0; int cpt; diff --git a/drivers/staging/lustre/lnet/lnet/lo.c b/drivers/staging/lustre/lnet/lnet/lo.c index cb213b8..12b6b3a 100644 --- a/drivers/staging/lustre/lnet/lnet/lo.c +++ b/drivers/staging/lustre/lnet/lnet/lo.c @@ -32,7 +32,7 @@ #include "../../include/linux/lnet/lib-lnet.h" static int -lolnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg) +lolnd_send(lnet_ni_t *ni, void *private, struct lnet_msg *lntmsg) { LASSERT(!lntmsg->msg_routing); LASSERT(!lntmsg->msg_target_is_router); @@ -41,10 +41,10 @@ } static int -lolnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, +lolnd_recv(lnet_ni_t *ni, void *private, struct lnet_msg *lntmsg, int delayed, struct iov_iter *to, unsigned int rlen) { - lnet_msg_t *sendmsg = private; + struct lnet_msg *sendmsg = private; if (lntmsg) { /* not discarding */ if (sendmsg->msg_iov) -- 1.8.3.1 From jsimmons at infradead.org Mon Feb 27 00:41:49 2017 From: jsimmons at infradead.org (James Simmons) Date: Sun, 26 Feb 2017 19:41:49 -0500 Subject: [lustre-devel] [PATCH 24/34] staging: lustre: lnet: change lnet_md_t to proper structure In-Reply-To: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> References: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> Message-ID: <1488156119-19670-25-git-send-email-jsimmons@infradead.org> Change lnet_md_t from typedef to proper structure. Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/20831 Reviewed-by: Olaf Weber Reviewed-by: Doug Oucharek Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/include/linux/lnet/api.h | 4 +-- .../staging/lustre/include/linux/lnet/lib-lnet.h | 4 +-- drivers/staging/lustre/include/linux/lnet/types.h | 30 +++++++++++----------- drivers/staging/lustre/lnet/lnet/api-ni.c | 4 +-- drivers/staging/lustre/lnet/lnet/lib-md.c | 10 ++++---- drivers/staging/lustre/lnet/lnet/router.c | 2 +- drivers/staging/lustre/lnet/selftest/rpc.c | 4 +-- drivers/staging/lustre/lustre/ptlrpc/niobuf.c | 8 +++--- drivers/staging/lustre/lustre/ptlrpc/pers.c | 2 +- .../staging/lustre/lustre/ptlrpc/ptlrpc_internal.h | 2 +- 10 files changed, 35 insertions(+), 35 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/api.h b/drivers/staging/lustre/include/linux/lnet/api.h index 2585dbb..8609206 100644 --- a/drivers/staging/lustre/include/linux/lnet/api.h +++ b/drivers/staging/lustre/include/linux/lnet/api.h @@ -125,11 +125,11 @@ int LNetMEInsert(struct lnet_handle_me current_in, * @{ */ int LNetMDAttach(struct lnet_handle_me current_in, - lnet_md_t md_in, + struct lnet_md md_in, lnet_unlink_t unlink_in, struct lnet_handle_md *md_handle_out); -int LNetMDBind(lnet_md_t md_in, +int LNetMDBind(struct lnet_md md_in, lnet_unlink_t unlink_in, struct lnet_handle_md *md_handle_out); diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h index 4a1e0a1..a6cf5be 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h @@ -194,7 +194,7 @@ static inline int lnet_md_unlinkable(struct lnet_libmd *md) } static inline struct lnet_libmd * -lnet_md_alloc(lnet_md_t *umd) +lnet_md_alloc(struct lnet_md *umd) { struct lnet_libmd *md; unsigned int size; @@ -626,7 +626,7 @@ void lnet_copy_kiov2iter(struct iov_iter *to, void lnet_me_unlink(struct lnet_me *me); void lnet_md_unlink(struct lnet_libmd *md); -void lnet_md_deconstruct(struct lnet_libmd *lmd, lnet_md_t *umd); +void lnet_md_deconstruct(struct lnet_libmd *lmd, struct lnet_md *umd); void lnet_register_lnd(struct lnet_lnd *lnd); void lnet_unregister_lnd(struct lnet_lnd *lnd); diff --git a/drivers/staging/lustre/include/linux/lnet/types.h b/drivers/staging/lustre/include/linux/lnet/types.h index d2af335..bc3f3e3 100644 --- a/drivers/staging/lustre/include/linux/lnet/types.h +++ b/drivers/staging/lustre/include/linux/lnet/types.h @@ -377,7 +377,7 @@ struct lnet_handle_me { * Defines the visible parts of a memory descriptor. Values of this type * are used to initialize memory descriptors. */ -typedef struct { +struct lnet_md { /** * Specify the memory region associated with the memory descriptor. * If the options field has: @@ -471,7 +471,7 @@ struct lnet_handle_me { * descriptor are not logged. */ struct lnet_handle_eq eq_handle; -} lnet_md_t; +}; /* * Max Transfer Unit (minimum supported everywhere). @@ -485,29 +485,29 @@ struct lnet_handle_me { #define LNET_MAX_IOV 256 /** - * Options for the MD structure. See lnet_md_t::options. + * Options for the MD structure. See lnet_md::options. */ #define LNET_MD_OP_PUT (1 << 0) -/** See lnet_md_t::options. */ +/** See lnet_md::options. */ #define LNET_MD_OP_GET (1 << 1) -/** See lnet_md_t::options. */ +/** See lnet_md::options. */ #define LNET_MD_MANAGE_REMOTE (1 << 2) /* unused (1 << 3) */ -/** See lnet_md_t::options. */ +/** See lnet_md::options. */ #define LNET_MD_TRUNCATE (1 << 4) -/** See lnet_md_t::options. */ +/** See lnet_md::options. */ #define LNET_MD_ACK_DISABLE (1 << 5) -/** See lnet_md_t::options. */ +/** See lnet_md::options. */ #define LNET_MD_IOVEC (1 << 6) -/** See lnet_md_t::options. */ +/** See lnet_md::options. */ #define LNET_MD_MAX_SIZE (1 << 7) -/** See lnet_md_t::options. */ +/** See lnet_md::options. */ #define LNET_MD_KIOV (1 << 8) /* For compatibility with Cray Portals */ #define LNET_MD_PHYS 0 -/** Infinite threshold on MD operations. See lnet_md_t::threshold */ +/** Infinite threshold on MD operations. See lnet_md::threshold */ #define LNET_MD_THRESH_INF (-1) /* NB lustre portals uses struct iovec internally! */ @@ -591,7 +591,7 @@ struct lnet_handle_me { * The length (in bytes) of the data that was manipulated by the * operation. For truncated operations, the manipulated length will be * the number of bytes specified by the MD (possibly with an offset, - * see lnet_md_t). For all other operations, the manipulated length + * see lnet_md). For all other operations, the manipulated length * will be the length of the requested operation, i.e. rlength. */ unsigned int mlength; @@ -605,7 +605,7 @@ struct lnet_handle_me { * been processed. In particular, the threshold field in md will * reflect the value of the threshold after the operation occurred. */ - lnet_md_t md; + struct lnet_md md; /** * 64 bits of out-of-band user data. Only valid for LNET_EVENT_PUT. * \see LNetPut @@ -627,7 +627,7 @@ struct lnet_handle_me { * The displacement (in bytes) into the memory region that the * operation used. The offset can be determined by the operation for * a remote managed MD or by the local MD. - * \see lnet_md_t::options + * \see lnet_md::options */ unsigned int offset; /** @@ -660,7 +660,7 @@ struct lnet_handle_me { * operation completes (i.e., when the data has been written to a MD of the * target process). * - * \see lnet_md_t::options for the discussion on LNET_MD_ACK_DISABLE by which + * \see lnet_md::options for the discussion on LNET_MD_ACK_DISABLE by which * acknowledgments can be disabled for a MD. */ typedef enum { diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index 34b9b10..53c9427 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -903,7 +903,7 @@ struct lnet_ni * { lnet_process_id_t id = {LNET_NID_ANY, LNET_PID_ANY}; struct lnet_handle_me me_handle; - lnet_md_t md = { NULL }; + struct lnet_md md = { NULL }; int rc, rc2; if (set_eq) { @@ -2134,7 +2134,7 @@ static int lnet_ping(lnet_process_id_t id, int timeout_ms, struct lnet_handle_eq eqh; struct lnet_handle_md mdh; lnet_event_t event; - lnet_md_t md = { NULL }; + struct lnet_md md = { NULL }; int which; int unlinked = 0; int replied = 0; diff --git a/drivers/staging/lustre/lnet/lnet/lib-md.c b/drivers/staging/lustre/lnet/lnet/lib-md.c index bb832c5..a3f8927 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-md.c +++ b/drivers/staging/lustre/lnet/lnet/lib-md.c @@ -84,7 +84,7 @@ } static int -lnet_md_build(struct lnet_libmd *lmd, lnet_md_t *umd, int unlink) +lnet_md_build(struct lnet_libmd *lmd, struct lnet_md *umd, int unlink) { int i; unsigned int niov; @@ -204,7 +204,7 @@ /* must be called with lnet_res_lock held */ void -lnet_md_deconstruct(struct lnet_libmd *lmd, lnet_md_t *umd) +lnet_md_deconstruct(struct lnet_libmd *lmd, struct lnet_md *umd) { /* NB this doesn't copy out all the iov entries so when a * discontiguous MD is copied out, the target gets to know the @@ -223,7 +223,7 @@ } static int -lnet_md_validate(lnet_md_t *umd) +lnet_md_validate(struct lnet_md *umd) { if (!umd->start && umd->length) { CERROR("MD start pointer can not be NULL with length %u\n", @@ -267,7 +267,7 @@ * a MD. */ int -LNetMDAttach(struct lnet_handle_me meh, lnet_md_t umd, +LNetMDAttach(struct lnet_handle_me meh, struct lnet_md umd, lnet_unlink_t unlink, struct lnet_handle_md *handle) { LIST_HEAD(matches); @@ -350,7 +350,7 @@ * LNetInvalidateHandle() on it. */ int -LNetMDBind(lnet_md_t umd, lnet_unlink_t unlink, +LNetMDBind(struct lnet_md umd, lnet_unlink_t unlink, struct lnet_handle_md *handle) { struct lnet_libmd *md; diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c index effa0fe..c9edc10 100644 --- a/drivers/staging/lustre/lnet/lnet/router.c +++ b/drivers/staging/lustre/lnet/lnet/router.c @@ -905,7 +905,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) { struct lnet_rc_data *rcd = NULL; struct lnet_ping_info *pi; - lnet_md_t md; + struct lnet_md md; int rc; int i; diff --git a/drivers/staging/lustre/lnet/selftest/rpc.c b/drivers/staging/lustre/lnet/selftest/rpc.c index 9a0b06f..e70785c 100644 --- a/drivers/staging/lustre/lnet/selftest/rpc.c +++ b/drivers/staging/lustre/lnet/selftest/rpc.c @@ -359,7 +359,7 @@ struct srpc_bulk * struct lnet_handle_md *mdh, struct srpc_event *ev) { int rc; - lnet_md_t md; + struct lnet_md md; struct lnet_handle_me meh; rc = LNetMEAttach(portal, peer, matchbits, 0, LNET_UNLINK, @@ -398,7 +398,7 @@ struct srpc_bulk * struct lnet_handle_md *mdh, struct srpc_event *ev) { int rc; - lnet_md_t md; + struct lnet_md md; md.user_ptr = ev; md.start = buf; diff --git a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c index bb6d76a..befd73c 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c +++ b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c @@ -49,7 +49,7 @@ static int ptl_send_buf(struct lnet_handle_md *mdh, void *base, int len, unsigned int offset) { int rc; - lnet_md_t md; + struct lnet_md md; LASSERT(portal != 0); CDEBUG(D_INFO, "conn=%p id %s\n", conn, libcfs_id2str(conn->c_peer)); @@ -116,7 +116,7 @@ static int ptlrpc_register_bulk(struct ptlrpc_request *req) int total_md; u64 mbits; struct lnet_handle_me me_h; - lnet_md_t md; + struct lnet_md md; if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_BULK_GET_NET)) return 0; @@ -473,7 +473,7 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) int mpflag = 0; struct ptlrpc_connection *connection; struct lnet_handle_me reply_me_h; - lnet_md_t reply_md; + struct lnet_md reply_md; struct obd_import *imp = request->rq_import; struct obd_device *obd = imp->imp_obd; @@ -721,7 +721,7 @@ int ptlrpc_register_rqbd(struct ptlrpc_request_buffer_desc *rqbd) struct ptlrpc_service *service = rqbd->rqbd_svcpt->scp_service; static lnet_process_id_t match_id = {LNET_NID_ANY, LNET_PID_ANY}; int rc; - lnet_md_t md; + struct lnet_md md; struct lnet_handle_me me_h; CDEBUG(D_NET, "LNetMEAttach: portal %d\n", diff --git a/drivers/staging/lustre/lustre/ptlrpc/pers.c b/drivers/staging/lustre/lustre/ptlrpc/pers.c index 601acb8..df4994f 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pers.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pers.c @@ -40,7 +40,7 @@ #include "ptlrpc_internal.h" -void ptlrpc_fill_bulk_md(lnet_md_t *md, struct ptlrpc_bulk_desc *desc, +void ptlrpc_fill_bulk_md(struct lnet_md *md, struct ptlrpc_bulk_desc *desc, int mdidx) { int offset = mdidx * LNET_MAX_IOV; diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h index 8e6a805..d2707a3 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h @@ -234,7 +234,7 @@ struct ptlrpc_nrs_policy *nrs_request_policy(struct ptlrpc_nrs_request *nrq) int ptlrpc_expire_one_request(struct ptlrpc_request *req, int async_unlink); /* pers.c */ -void ptlrpc_fill_bulk_md(lnet_md_t *md, struct ptlrpc_bulk_desc *desc, +void ptlrpc_fill_bulk_md(struct lnet_md *md, struct ptlrpc_bulk_desc *desc, int mdcnt); /* pack_generic.c */ -- 1.8.3.1 From jsimmons at infradead.org Mon Feb 27 00:41:51 2017 From: jsimmons at infradead.org (James Simmons) Date: Sun, 26 Feb 2017 19:41:51 -0500 Subject: [lustre-devel] [PATCH 26/34] staging: lustre: lnet: change lnet_process_id_t to proper structure In-Reply-To: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> References: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> Message-ID: <1488156119-19670-27-git-send-email-jsimmons@infradead.org> Change lnet_process_id_t from typedef to proper structure. Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/20831 Reviewed-by: Olaf Weber Reviewed-by: Doug Oucharek Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/include/linux/lnet/api.h | 12 ++++---- .../staging/lustre/include/linux/lnet/lib-lnet.h | 11 +++---- .../staging/lustre/include/linux/lnet/lib-types.h | 6 ++-- drivers/staging/lustre/include/linux/lnet/lnetst.h | 12 ++++---- drivers/staging/lustre/include/linux/lnet/nidstr.h | 2 +- drivers/staging/lustre/include/linux/lnet/types.h | 12 ++++---- .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 4 +-- .../staging/lustre/lnet/klnds/socklnd/socklnd.c | 26 ++++++++-------- .../staging/lustre/lnet/klnds/socklnd/socklnd.h | 15 +++++----- .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 11 +++---- drivers/staging/lustre/lnet/lnet/api-ni.c | 24 +++++++-------- drivers/staging/lustre/lnet/lnet/lib-me.c | 6 ++-- drivers/staging/lustre/lnet/lnet/lib-move.c | 20 ++++++------- drivers/staging/lustre/lnet/lnet/lib-ptl.c | 8 ++--- drivers/staging/lustre/lnet/lnet/nidstrings.c | 2 +- drivers/staging/lustre/lnet/lnet/router.c | 2 +- drivers/staging/lustre/lnet/selftest/brw_test.c | 4 +-- drivers/staging/lustre/lnet/selftest/conrpc.c | 2 +- drivers/staging/lustre/lnet/selftest/console.c | 35 +++++++++++----------- drivers/staging/lustre/lnet/selftest/console.h | 14 +++++---- drivers/staging/lustre/lnet/selftest/framework.c | 4 +-- drivers/staging/lustre/lnet/selftest/ping_test.c | 2 +- drivers/staging/lustre/lnet/selftest/rpc.c | 11 +++---- drivers/staging/lustre/lnet/selftest/selftest.h | 22 +++++++------- drivers/staging/lustre/lustre/include/lustre_net.h | 8 ++--- drivers/staging/lustre/lustre/llite/llite_lib.c | 2 +- drivers/staging/lustre/lustre/llite/super25.c | 2 +- drivers/staging/lustre/lustre/osc/osc_request.c | 5 ++-- drivers/staging/lustre/lustre/ptlrpc/client.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/connection.c | 6 ++-- drivers/staging/lustre/lustre/ptlrpc/events.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/niobuf.c | 4 +-- 32 files changed, 153 insertions(+), 145 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/api.h b/drivers/staging/lustre/include/linux/lnet/api.h index b46a769..7a67fd2 100644 --- a/drivers/staging/lustre/include/linux/lnet/api.h +++ b/drivers/staging/lustre/include/linux/lnet/api.h @@ -74,7 +74,7 @@ * \see LNetMEAttach * @{ */ -int LNetGetId(unsigned int index, lnet_process_id_t *id); +int LNetGetId(unsigned int index, struct lnet_process_id *id); int LNetDist(lnet_nid_t nid, lnet_nid_t *srcnid, __u32 *order); /** @} lnet_addr */ @@ -93,7 +93,7 @@ * @{ */ int LNetMEAttach(unsigned int portal, - lnet_process_id_t match_id_in, + struct lnet_process_id match_id_in, __u64 match_bits_in, __u64 ignore_bits_in, lnet_unlink_t unlink_in, @@ -101,7 +101,7 @@ int LNetMEAttach(unsigned int portal, struct lnet_handle_me *handle_out); int LNetMEInsert(struct lnet_handle_me current_in, - lnet_process_id_t match_id_in, + struct lnet_process_id match_id_in, __u64 match_bits_in, __u64 ignore_bits_in, lnet_unlink_t unlink_in, @@ -181,7 +181,7 @@ int LNetEQPoll(struct lnet_handle_eq *eventqs_in, int LNetPut(lnet_nid_t self, struct lnet_handle_md md_in, lnet_ack_req_t ack_req_in, - lnet_process_id_t target_in, + struct lnet_process_id target_in, unsigned int portal_in, __u64 match_bits_in, unsigned int offset_in, @@ -189,7 +189,7 @@ int LNetPut(lnet_nid_t self, int LNetGet(lnet_nid_t self, struct lnet_handle_md md_in, - lnet_process_id_t target_in, + struct lnet_process_id target_in, unsigned int portal_in, __u64 match_bits_in, unsigned int offset_in); @@ -202,7 +202,7 @@ int LNetGet(lnet_nid_t self, int LNetSetLazyPortal(int portal); int LNetClearLazyPortal(int portal); int LNetCtl(unsigned int cmd, void *arg); -void LNetDebugPeer(lnet_process_id_t id); +void LNetDebugPeer(struct lnet_process_id id); /** @} lnet_misc */ diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h index d770a03..e21323f 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h @@ -491,8 +491,9 @@ void lnet_msg_attach_md(struct lnet_msg *msg, struct lnet_libmd *md, void lnet_msg_decommit(struct lnet_msg *msg, int cpt, int status); void lnet_eq_enqueue_event(struct lnet_eq *eq, struct lnet_event *ev); -void lnet_prep_send(struct lnet_msg *msg, int type, lnet_process_id_t target, - unsigned int offset, unsigned int len); +void lnet_prep_send(struct lnet_msg *msg, int type, + struct lnet_process_id target, unsigned int offset, + unsigned int len); int lnet_send(lnet_nid_t nid, struct lnet_msg *msg, lnet_nid_t rtr_nid); void lnet_return_tx_credits_locked(struct lnet_msg *msg); void lnet_return_rx_credits_locked(struct lnet_msg *msg); @@ -533,10 +534,10 @@ void lnet_prep_send(struct lnet_msg *msg, int type, lnet_process_id_t target, /* match-table functions */ struct list_head *lnet_mt_match_head(struct lnet_match_table *mtable, - lnet_process_id_t id, __u64 mbits); + struct lnet_process_id id, __u64 mbits); struct lnet_match_table *lnet_mt_of_attach(unsigned int index, - lnet_process_id_t id, __u64 mbits, - __u64 ignore_bits, + struct lnet_process_id id, + __u64 mbits, __u64 ignore_bits, lnet_ins_pos_t pos); int lnet_mt_match_md(struct lnet_match_table *mtable, struct lnet_match_info *info, struct lnet_msg *msg); diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index 808a05c..81c93d4 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -58,7 +58,7 @@ struct lnet_msg { struct list_head msg_activelist; struct list_head msg_list; /* Q for credits/MD */ - lnet_process_id_t msg_target; + struct lnet_process_id msg_target; /* where is it from, it's only for building event */ lnet_nid_t msg_from; __u32 msg_type; @@ -130,7 +130,7 @@ struct lnet_eq { struct lnet_me { struct list_head me_list; struct lnet_libhandle me_lh; - lnet_process_id_t me_match_id; + struct lnet_process_id me_match_id; unsigned int me_portal; unsigned int me_pos; /* hash offset in mt_hash */ __u64 me_match_bits; @@ -447,7 +447,7 @@ enum lnet_match_flags { /* parameter for matching operations (GET, PUT) */ struct lnet_match_info { __u64 mi_mbits; - lnet_process_id_t mi_id; + struct lnet_process_id mi_id; unsigned int mi_opc; unsigned int mi_portal; unsigned int mi_rlength; diff --git a/drivers/staging/lustre/include/linux/lnet/lnetst.h b/drivers/staging/lustre/include/linux/lnet/lnetst.h index c81c246..ea736f8 100644 --- a/drivers/staging/lustre/include/linux/lnet/lnetst.h +++ b/drivers/staging/lustre/include/linux/lnet/lnetst.h @@ -86,7 +86,7 @@ struct lst_bid { #define LST_NODE_UNKNOWN 0x8 /* node not in session */ struct lstcon_node_ent { - lnet_process_id_t nde_id; /* id of node */ + struct lnet_process_id nde_id; /* id of node */ int nde_state; /* state of node */ }; /*** node entry, for list_group command */ @@ -126,7 +126,7 @@ struct lstcon_test_batch_ent { struct lstcon_rpc_ent { struct list_head rpe_link; /* link chain */ - lnet_process_id_t rpe_peer; /* peer's id */ + struct lnet_process_id rpe_peer; /* peer's id */ struct timeval rpe_stamp; /* time stamp of RPC */ int rpe_state; /* peer's state */ int rpe_rpc_errno; /* RPC errno */ @@ -287,7 +287,7 @@ struct lstio_debug_args { group|batch */ int lstio_dbg_count; /* IN: # of test nodes to debug */ - lnet_process_id_t __user *lstio_dbg_idsp; /* IN: id of test + struct lnet_process_id __user *lstio_dbg_idsp; /* IN: id of test nodes */ struct list_head __user *lstio_dbg_resultp; /* OUT: list head of result buffer */ @@ -317,7 +317,7 @@ struct lstio_group_update_args { int lstio_grp_nmlen; /* IN: name length */ char __user *lstio_grp_namep; /* IN: group name */ int lstio_grp_count; /* IN: # of nodes id */ - lnet_process_id_t __user *lstio_grp_idsp; /* IN: array of nodes */ + struct lnet_process_id __user *lstio_grp_idsp; /* IN: array of nodes */ struct list_head __user *lstio_grp_resultp; /* OUT: list head of result buffer */ }; @@ -329,7 +329,7 @@ struct lstio_group_nodes_args { int lstio_grp_count; /* IN: # of nodes */ /** OUT: session features */ unsigned int __user *lstio_grp_featp; - lnet_process_id_t __user *lstio_grp_idsp; /* IN: nodes */ + struct lnet_process_id __user *lstio_grp_idsp; /* IN: nodes */ struct list_head __user *lstio_grp_resultp; /* OUT: list head of result buffer */ }; @@ -429,7 +429,7 @@ struct lstio_stat_args { length */ char __user *lstio_sta_namep; /* IN: group name */ int lstio_sta_count; /* IN: # of pid */ - lnet_process_id_t __user *lstio_sta_idsp; /* IN: pid */ + struct lnet_process_id __user *lstio_sta_idsp; /* IN: pid */ struct list_head __user *lstio_sta_resultp; /* OUT: list head of result buffer */ }; diff --git a/drivers/staging/lustre/include/linux/lnet/nidstr.h b/drivers/staging/lustre/include/linux/lnet/nidstr.h index 937fcc9..ecdd0db 100644 --- a/drivers/staging/lustre/include/linux/lnet/nidstr.h +++ b/drivers/staging/lustre/include/linux/lnet/nidstr.h @@ -88,7 +88,7 @@ static inline char *libcfs_nid2str(lnet_nid_t nid) __u32 libcfs_str2net(const char *str); lnet_nid_t libcfs_str2nid(const char *str); int libcfs_str2anynid(lnet_nid_t *nid, const char *str); -char *libcfs_id2str(lnet_process_id_t id); +char *libcfs_id2str(struct lnet_process_id id); void cfs_free_nidlist(struct list_head *list); int cfs_parse_nidlist(char *str, int len, struct list_head *list); int cfs_print_nidlist(char *buffer, int count, struct list_head *list); diff --git a/drivers/staging/lustre/include/linux/lnet/types.h b/drivers/staging/lustre/include/linux/lnet/types.h index 53eb1da..74118d0 100644 --- a/drivers/staging/lustre/include/linux/lnet/types.h +++ b/drivers/staging/lustre/include/linux/lnet/types.h @@ -64,7 +64,7 @@ typedef __u64 lnet_nid_t; /** * ID of a process in a node. Shortened as PID to distinguish from - * lnet_process_id_t, the global process ID. + * lnet_process_id, the global process ID. */ typedef __u32 lnet_pid_t; @@ -114,7 +114,7 @@ static inline __u32 LNET_MKNET(__u32 type, __u32 num) #define WIRE_ATTR __packed -/* Packed version of lnet_process_id_t to transfer via network */ +/* Packed version of lnet_process_id to transfer via network */ struct lnet_process_id_packed { /* node id / process id */ lnet_nid_t nid; @@ -330,12 +330,12 @@ struct lnet_handle_me { /** * Global process ID. */ -typedef struct { +struct lnet_process_id { /** node id */ lnet_nid_t nid; /** process id */ lnet_pid_t pid; -} lnet_process_id_t; +}; /** @} lnet_addr */ /** \addtogroup lnet_me @@ -570,9 +570,9 @@ struct lnet_md { */ struct lnet_event { /** The identifier (nid, pid) of the target. */ - lnet_process_id_t target; + struct lnet_process_id target; /** The identifier (nid, pid) of the initiator. */ - lnet_process_id_t initiator; + struct lnet_process_id initiator; /** * The NID of the immediate sender. If the request has been forwarded * by routers, this is the NID of the last hop; otherwise it's the diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c index 0c9b40f..e850f4c 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c @@ -1482,7 +1482,7 @@ static int kiblnd_resolve_addr(struct rdma_cm_id *cmid, { struct lnet_hdr *hdr = &lntmsg->msg_hdr; int type = lntmsg->msg_type; - lnet_process_id_t target = lntmsg->msg_target; + struct lnet_process_id target = lntmsg->msg_target; int target_is_router = lntmsg->msg_target_is_router; int routing = lntmsg->msg_routing; unsigned int payload_niov = lntmsg->msg_niov; @@ -1653,7 +1653,7 @@ static int kiblnd_resolve_addr(struct rdma_cm_id *cmid, static void kiblnd_reply(struct lnet_ni *ni, struct kib_rx *rx, struct lnet_msg *lntmsg) { - lnet_process_id_t target = lntmsg->msg_target; + struct lnet_process_id target = lntmsg->msg_target; unsigned int niov = lntmsg->msg_niov; struct kvec *iov = lntmsg->msg_iov; lnet_kiov_t *kiov = lntmsg->msg_kiov; diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c index f92fa4b..fbbd8a5 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c @@ -97,7 +97,7 @@ static int ksocknal_create_peer(struct ksock_peer **peerp, struct lnet_ni *ni, - lnet_process_id_t id) + struct lnet_process_id id) { int cpt = lnet_cpt_of_nid(id.nid); struct ksock_net *net = ni->ni_data; @@ -173,7 +173,7 @@ } struct ksock_peer * -ksocknal_find_peer_locked(struct lnet_ni *ni, lnet_process_id_t id) +ksocknal_find_peer_locked(struct lnet_ni *ni, struct lnet_process_id id) { struct list_head *peer_list = ksocknal_nid2peerlist(id.nid); struct list_head *tmp; @@ -200,7 +200,7 @@ struct ksock_peer * } struct ksock_peer * -ksocknal_find_peer(struct lnet_ni *ni, lnet_process_id_t id) +ksocknal_find_peer(struct lnet_ni *ni, struct lnet_process_id id) { struct ksock_peer *peer; @@ -247,7 +247,7 @@ struct ksock_peer * static int ksocknal_get_peer_info(struct lnet_ni *ni, int index, - lnet_process_id_t *id, __u32 *myip, __u32 *peer_ip, + struct lnet_process_id *id, __u32 *myip, __u32 *peer_ip, int *port, int *conn_count, int *share_count) { struct ksock_peer *peer; @@ -450,7 +450,7 @@ struct ksock_peer * } int -ksocknal_add_peer(struct lnet_ni *ni, lnet_process_id_t id, __u32 ipaddr, +ksocknal_add_peer(struct lnet_ni *ni, struct lnet_process_id id, __u32 ipaddr, int port) { struct list_head *tmp; @@ -569,7 +569,7 @@ struct ksock_peer * } static int -ksocknal_del_peer(struct lnet_ni *ni, lnet_process_id_t id, __u32 ip) +ksocknal_del_peer(struct lnet_ni *ni, struct lnet_process_id id, __u32 ip) { LIST_HEAD(zombies); struct list_head *ptmp; @@ -1031,7 +1031,7 @@ struct ksock_peer * { rwlock_t *global_lock = &ksocknal_data.ksnd_global_lock; LIST_HEAD(zombies); - lnet_process_id_t peerid; + struct lnet_process_id peerid; struct list_head *tmp; __u64 incarnation; struct ksock_conn *conn; @@ -1764,7 +1764,7 @@ struct ksock_peer * } int -ksocknal_close_matching_conns(lnet_process_id_t id, __u32 ipaddr) +ksocknal_close_matching_conns(struct lnet_process_id id, __u32 ipaddr) { struct ksock_peer *peer; struct list_head *ptmp; @@ -1817,7 +1817,7 @@ struct ksock_peer * * The router is telling me she's been notified of a change in * gateway state.... */ - lnet_process_id_t id = {0}; + struct lnet_process_id id = {0}; id.nid = gw_nid; id.pid = LNET_PID_ANY; @@ -1845,7 +1845,7 @@ struct ksock_peer * unsigned long now = cfs_time_current(); struct ksock_peer *peer = NULL; rwlock_t *glock = &ksocknal_data.ksnd_global_lock; - lnet_process_id_t id = { + struct lnet_process_id id = { .nid = nid, .pid = LNET_PID_LUSTRE, }; @@ -1933,7 +1933,7 @@ struct ksock_peer * } } -static int ksocknal_push(struct lnet_ni *ni, lnet_process_id_t id) +static int ksocknal_push(struct lnet_ni *ni, struct lnet_process_id id) { struct list_head *start; struct list_head *end; @@ -2135,7 +2135,7 @@ static int ksocknal_push(struct lnet_ni *ni, lnet_process_id_t id) int ksocknal_ctl(struct lnet_ni *ni, unsigned int cmd, void *arg) { - lnet_process_id_t id = {0}; + struct lnet_process_id id = {0}; struct libcfs_ioctl_data *data = arg; int rc; @@ -2592,7 +2592,7 @@ static int ksocknal_push(struct lnet_ni *ni, lnet_process_id_t id) { struct ksock_net *net = ni->ni_data; int i; - lnet_process_id_t anyid = {0}; + struct lnet_process_id anyid = {0}; anyid.nid = LNET_NID_ANY; anyid.pid = LNET_PID_ANY; diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h index 99fec18..3f48b60 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h @@ -428,7 +428,7 @@ struct ksock_peer { unsigned long ksnp_last_alive; /* when (in jiffies) I was last * alive */ - lnet_process_id_t ksnp_id; /* who's on the other end(s) */ + struct lnet_process_id ksnp_id; /* who's on the other end(s) */ atomic_t ksnp_refcount; /* # users */ int ksnp_sharecount; /* lconf usage counter */ int ksnp_closing; /* being closed */ @@ -655,12 +655,12 @@ int ksocknal_recv(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg, int delayed, struct iov_iter *to, unsigned int rlen); int ksocknal_accept(struct lnet_ni *ni, struct socket *sock); -int ksocknal_add_peer(struct lnet_ni *ni, lnet_process_id_t id, __u32 ip, +int ksocknal_add_peer(struct lnet_ni *ni, struct lnet_process_id id, __u32 ip, int port); struct ksock_peer *ksocknal_find_peer_locked(struct lnet_ni *ni, - lnet_process_id_t id); + struct lnet_process_id id); struct ksock_peer *ksocknal_find_peer(struct lnet_ni *ni, - lnet_process_id_t id); + struct lnet_process_id id); void ksocknal_peer_failed(struct ksock_peer *peer); int ksocknal_create_conn(struct lnet_ni *ni, struct ksock_route *route, struct socket *sock, int type); @@ -670,12 +670,12 @@ int ksocknal_create_conn(struct lnet_ni *ni, struct ksock_route *route, int ksocknal_close_peer_conns_locked(struct ksock_peer *peer, __u32 ipaddr, int why); int ksocknal_close_conn_and_siblings(struct ksock_conn *conn, int why); -int ksocknal_close_matching_conns(lnet_process_id_t id, __u32 ipaddr); +int ksocknal_close_matching_conns(struct lnet_process_id id, __u32 ipaddr); struct ksock_conn *ksocknal_find_conn_locked(struct ksock_peer *peer, struct ksock_tx *tx, int nonblk); int ksocknal_launch_packet(struct lnet_ni *ni, struct ksock_tx *tx, - lnet_process_id_t id); + struct lnet_process_id id); struct ksock_tx *ksocknal_alloc_tx(int type, int size); void ksocknal_free_tx(struct ksock_tx *tx); struct ksock_tx *ksocknal_alloc_tx_noop(__u64 cookie, int nonblk); @@ -696,7 +696,8 @@ int ksocknal_launch_packet(struct lnet_ni *ni, struct ksock_tx *tx, int ksocknal_send_hello(struct lnet_ni *ni, struct ksock_conn *conn, lnet_nid_t peer_nid, struct ksock_hello_msg *hello); int ksocknal_recv_hello(struct lnet_ni *ni, struct ksock_conn *conn, - struct ksock_hello_msg *hello, lnet_process_id_t *id, + struct ksock_hello_msg *hello, + struct lnet_process_id *id, __u64 *incarnation); void ksocknal_read_callback(struct ksock_conn *conn); void ksocknal_write_callback(struct ksock_conn *conn); diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c index 8cea4f6..695b586 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c @@ -846,7 +846,7 @@ struct ksock_route * int ksocknal_launch_packet(struct lnet_ni *ni, struct ksock_tx *tx, - lnet_process_id_t id) + struct lnet_process_id id) { struct ksock_peer *peer; struct ksock_conn *conn; @@ -943,7 +943,7 @@ struct ksock_route * { int mpflag = 1; int type = lntmsg->msg_type; - lnet_process_id_t target = lntmsg->msg_target; + struct lnet_process_id target = lntmsg->msg_target; unsigned int payload_niov = lntmsg->msg_niov; struct kvec *payload_iov = lntmsg->msg_iov; lnet_kiov_t *payload_kiov = lntmsg->msg_kiov; @@ -1133,7 +1133,7 @@ struct ksock_route * ksocknal_process_receive(struct ksock_conn *conn) { struct lnet_hdr *lhdr; - lnet_process_id_t *id; + struct lnet_process_id *id; int rc; LASSERT(atomic_read(&conn->ksnc_conn_refcount) > 0); @@ -1715,7 +1715,8 @@ void ksocknal_write_callback(struct ksock_conn *conn) int ksocknal_recv_hello(struct lnet_ni *ni, struct ksock_conn *conn, - struct ksock_hello_msg *hello, lnet_process_id_t *peerid, + struct ksock_hello_msg *hello, + struct lnet_process_id *peerid, __u64 *incarnation) { /* Return < 0 fatal error @@ -1729,7 +1730,7 @@ void ksocknal_write_callback(struct ksock_conn *conn) int proto_match; int rc; struct ksock_proto *proto; - lnet_process_id_t recv_id; + struct lnet_process_id recv_id; /* socket type set on active connections - not set on passive */ LASSERT(!active == !(conn->ksnc_type != SOCKLND_CONN_NONE)); diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index 1d2004f..0b91d18 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -58,8 +58,8 @@ module_param(rnet_htable_size, int, 0444); MODULE_PARM_DESC(rnet_htable_size, "size of remote network hash table"); -static int lnet_ping(lnet_process_id_t id, int timeout_ms, - lnet_process_id_t __user *ids, int n_ids); +static int lnet_ping(struct lnet_process_id id, int timeout_ms, + struct lnet_process_id __user *ids, int n_ids); static char * lnet_get_routes(void) @@ -901,7 +901,7 @@ struct lnet_ni * struct lnet_handle_md *md_handle, int ni_count, bool set_eq) { - lnet_process_id_t id = {LNET_NID_ANY, LNET_PID_ANY}; + struct lnet_process_id id = {LNET_NID_ANY, LNET_PID_ANY}; struct lnet_handle_me me_handle; struct lnet_md md = { NULL }; int rc, rc2; @@ -1887,7 +1887,7 @@ void lnet_lib_exit(void) { struct libcfs_ioctl_data *data = arg; struct lnet_ioctl_config_data *config; - lnet_process_id_t id = {0}; + struct lnet_process_id id = {0}; struct lnet_ni *ni; int rc; unsigned long secs_passed; @@ -2059,7 +2059,7 @@ void lnet_lib_exit(void) id.pid = data->ioc_u32[0]; rc = lnet_ping(id, data->ioc_u32[1], /* timeout */ data->ioc_pbuf1, - data->ioc_plen1 / sizeof(lnet_process_id_t)); + data->ioc_plen1 / sizeof(struct lnet_process_id)); if (rc < 0) return rc; data->ioc_count = rc; @@ -2082,25 +2082,25 @@ void lnet_lib_exit(void) } EXPORT_SYMBOL(LNetCtl); -void LNetDebugPeer(lnet_process_id_t id) +void LNetDebugPeer(struct lnet_process_id id) { lnet_debug_peer(id.nid); } EXPORT_SYMBOL(LNetDebugPeer); /** - * Retrieve the lnet_process_id_t ID of LNet interface at \a index. Note that + * Retrieve the lnet_process_id ID of LNet interface at \a index. Note that * all interfaces share a same PID, as requested by LNetNIInit(). * * \param index Index of the interface to look up. * \param id On successful return, this location will hold the - * lnet_process_id_t ID of the interface. + * lnet_process_id ID of the interface. * * \retval 0 If an interface exists at \a index. * \retval -ENOENT If no interface has been found. */ int -LNetGetId(unsigned int index, lnet_process_id_t *id) +LNetGetId(unsigned int index, struct lnet_process_id *id) { struct lnet_ni *ni; struct list_head *tmp; @@ -2128,8 +2128,8 @@ void LNetDebugPeer(lnet_process_id_t id) } EXPORT_SYMBOL(LNetGetId); -static int lnet_ping(lnet_process_id_t id, int timeout_ms, - lnet_process_id_t __user *ids, int n_ids) +static int lnet_ping(struct lnet_process_id id, int timeout_ms, + struct lnet_process_id __user *ids, int n_ids) { struct lnet_handle_eq eqh; struct lnet_handle_md mdh; @@ -2141,7 +2141,7 @@ static int lnet_ping(lnet_process_id_t id, int timeout_ms, const int a_long_time = 60000; /* mS */ int infosz; struct lnet_ping_info *info; - lnet_process_id_t tmpid; + struct lnet_process_id tmpid; int i; int nob; int rc; diff --git a/drivers/staging/lustre/lnet/lnet/lib-me.c b/drivers/staging/lustre/lnet/lnet/lib-me.c index 7614088..d8f40de 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-me.c +++ b/drivers/staging/lustre/lnet/lnet/lib-me.c @@ -46,7 +46,7 @@ * \param portal The portal table index where the ME should be attached. * \param match_id Specifies the match criteria for the process ID of * the requester. The constants LNET_PID_ANY and LNET_NID_ANY can be - * used to wildcard either of the identifiers in the lnet_process_id_t + * used to wildcard either of the identifiers in the lnet_process_id * structure. * \param match_bits,ignore_bits Specify the match criteria to apply * to the match bits in the incoming request. The ignore bits are used @@ -70,7 +70,7 @@ */ int LNetMEAttach(unsigned int portal, - lnet_process_id_t match_id, + struct lnet_process_id match_id, __u64 match_bits, __u64 ignore_bits, lnet_unlink_t unlink, lnet_ins_pos_t pos, struct lnet_handle_me *handle) @@ -141,7 +141,7 @@ */ int LNetMEInsert(struct lnet_handle_me current_meh, - lnet_process_id_t match_id, + struct lnet_process_id match_id, __u64 match_bits, __u64 ignore_bits, lnet_unlink_t unlink, lnet_ins_pos_t pos, struct lnet_handle_me *handle) diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c index 96fb7fc..3c54a3d 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-move.c +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c @@ -429,7 +429,7 @@ } void -lnet_prep_send(struct lnet_msg *msg, int type, lnet_process_id_t target, +lnet_prep_send(struct lnet_msg *msg, int type, struct lnet_process_id target, unsigned int offset, unsigned int len) { msg->msg_type = type; @@ -1392,7 +1392,7 @@ { void *private = msg->msg_private; struct lnet_hdr *hdr = &msg->msg_hdr; - lnet_process_id_t src = {0}; + struct lnet_process_id src = {0}; struct lnet_libmd *md; int rlength; int mlength; @@ -1456,7 +1456,7 @@ lnet_parse_ack(struct lnet_ni *ni, struct lnet_msg *msg) { struct lnet_hdr *hdr = &msg->msg_hdr; - lnet_process_id_t src = {0}; + struct lnet_process_id src = {0}; struct lnet_libmd *md; int cpt; @@ -1580,8 +1580,8 @@ void lnet_print_hdr(struct lnet_hdr *hdr) { - lnet_process_id_t src = {0}; - lnet_process_id_t dst = {0}; + struct lnet_process_id src = {0}; + struct lnet_process_id dst = {0}; char *type_str = lnet_msgtyp2str(hdr->type); src.nid = hdr->src_nid; @@ -1875,7 +1875,7 @@ lnet_drop_delayed_msg_list(struct list_head *head, char *reason) { while (!list_empty(head)) { - lnet_process_id_t id = {0}; + struct lnet_process_id id = {0}; struct lnet_msg *msg; msg = list_entry(head->next, struct lnet_msg, msg_list); @@ -1918,7 +1918,7 @@ { while (!list_empty(head)) { struct lnet_msg *msg; - lnet_process_id_t id; + struct lnet_process_id id; msg = list_entry(head->next, struct lnet_msg, msg_list); list_del(&msg->msg_list); @@ -1991,7 +1991,7 @@ */ int LNetPut(lnet_nid_t self, struct lnet_handle_md mdh, lnet_ack_req_t ack, - lnet_process_id_t target, unsigned int portal, + struct lnet_process_id target, unsigned int portal, __u64 match_bits, unsigned int offset, __u64 hdr_data) { @@ -2087,7 +2087,7 @@ struct lnet_msg * */ struct lnet_msg *msg = lnet_msg_alloc(); struct lnet_libmd *getmd = getmsg->msg_md; - lnet_process_id_t peer_id = getmsg->msg_target; + struct lnet_process_id peer_id = getmsg->msg_target; int cpt; LASSERT(!getmsg->msg_target_is_router); @@ -2197,7 +2197,7 @@ struct lnet_msg * */ int LNetGet(lnet_nid_t self, struct lnet_handle_md mdh, - lnet_process_id_t target, unsigned int portal, + struct lnet_process_id target, unsigned int portal, __u64 match_bits, unsigned int offset) { struct lnet_msg *msg; diff --git a/drivers/staging/lustre/lnet/lnet/lib-ptl.c b/drivers/staging/lustre/lnet/lnet/lib-ptl.c index 9ea3c08..fc67af0 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-ptl.c +++ b/drivers/staging/lustre/lnet/lnet/lib-ptl.c @@ -39,7 +39,7 @@ MODULE_PARM_DESC(portal_rotor, "redirect PUTs to different cpu-partitions"); static int -lnet_ptl_match_type(unsigned int index, lnet_process_id_t match_id, +lnet_ptl_match_type(unsigned int index, struct lnet_process_id match_id, __u64 mbits, __u64 ignore_bits) { struct lnet_portal *ptl = the_lnet.ln_portals[index]; @@ -212,7 +212,7 @@ } static struct lnet_match_table * -lnet_match2mt(struct lnet_portal *ptl, lnet_process_id_t id, __u64 mbits) +lnet_match2mt(struct lnet_portal *ptl, struct lnet_process_id id, __u64 mbits) { if (LNET_CPT_NUMBER == 1) return ptl->ptl_mtables[0]; /* the only one */ @@ -223,7 +223,7 @@ } struct lnet_match_table * -lnet_mt_of_attach(unsigned int index, lnet_process_id_t id, +lnet_mt_of_attach(unsigned int index, struct lnet_process_id id, __u64 mbits, __u64 ignore_bits, lnet_ins_pos_t pos) { struct lnet_portal *ptl; @@ -357,7 +357,7 @@ struct lnet_match_table * struct list_head * lnet_mt_match_head(struct lnet_match_table *mtable, - lnet_process_id_t id, __u64 mbits) + struct lnet_process_id id, __u64 mbits) { struct lnet_portal *ptl = the_lnet.ln_portals[mtable->mt_portal]; unsigned long hash = mbits; diff --git a/drivers/staging/lustre/lnet/lnet/nidstrings.c b/drivers/staging/lustre/lnet/lnet/nidstrings.c index a9fe3e6..298533d 100644 --- a/drivers/staging/lustre/lnet/lnet/nidstrings.c +++ b/drivers/staging/lustre/lnet/lnet/nidstrings.c @@ -1226,7 +1226,7 @@ static void cfs_ip_min_max(struct list_head *nidlist, __u32 *min_nid, EXPORT_SYMBOL(libcfs_str2nid); char * -libcfs_id2str(lnet_process_id_t id) +libcfs_id2str(struct lnet_process_id id) { char *str = libcfs_next_nidstring(); diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c index 84092ad..194a220 100644 --- a/drivers/staging/lustre/lnet/lnet/router.c +++ b/drivers/staging/lustre/lnet/lnet/router.c @@ -1024,7 +1024,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) cfs_time_after(now, cfs_time_add(rtr->lp_ping_timestamp, cfs_time_seconds(secs)))) { int rc; - lnet_process_id_t id; + struct lnet_process_id id; struct lnet_handle_md mdh; id.nid = rtr->lp_nid; diff --git a/drivers/staging/lustre/lnet/selftest/brw_test.c b/drivers/staging/lustre/lnet/selftest/brw_test.c index b9ac34e..f8b9175 100644 --- a/drivers/staging/lustre/lnet/selftest/brw_test.c +++ b/drivers/staging/lustre/lnet/selftest/brw_test.c @@ -267,8 +267,8 @@ static int brw_inject_one_error(void) } static int -brw_client_prep_rpc(struct sfw_test_unit *tsu, - lnet_process_id_t dest, struct srpc_client_rpc **rpcpp) +brw_client_prep_rpc(struct sfw_test_unit *tsu, struct lnet_process_id dest, + struct srpc_client_rpc **rpcpp) { struct srpc_bulk *bulk = tsu->tsu_private; struct sfw_test_instance *tsi = tsu->tsu_instance; diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c b/drivers/staging/lustre/lnet/selftest/conrpc.c index 680a559..7985b09 100644 --- a/drivers/staging/lustre/lnet/selftest/conrpc.c +++ b/drivers/staging/lustre/lnet/selftest/conrpc.c @@ -505,7 +505,7 @@ void lstcon_rpc_stat_reply(struct lstcon_rpc_trans *, struct srpc_msg *, jiffies_to_timeval(dur, &tv); if (copy_to_user(&ent->rpe_peer, &nd->nd_id, - sizeof(lnet_process_id_t)) || + sizeof(struct lnet_process_id)) || copy_to_user(&ent->rpe_stamp, &tv, sizeof(tv)) || copy_to_user(&ent->rpe_state, &nd->nd_state, sizeof(nd->nd_state)) || diff --git a/drivers/staging/lustre/lnet/selftest/console.c b/drivers/staging/lustre/lnet/selftest/console.c index 358cae8..d62c448 100644 --- a/drivers/staging/lustre/lnet/selftest/console.c +++ b/drivers/staging/lustre/lnet/selftest/console.c @@ -65,7 +65,8 @@ } static int -lstcon_node_find(lnet_process_id_t id, struct lstcon_node **ndpp, int create) +lstcon_node_find(struct lnet_process_id id, struct lstcon_node **ndpp, + int create) { struct lstcon_ndlink *ndl; unsigned int idx = LNET_NIDADDR(id.nid) % LST_GLOBAL_HASHSIZE; @@ -135,7 +136,7 @@ } static int -lstcon_ndlink_find(struct list_head *hash, lnet_process_id_t id, +lstcon_ndlink_find(struct list_head *hash, struct lnet_process_id id, struct lstcon_ndlink **ndlpp, int create) { unsigned int idx = LNET_NIDADDR(id.nid) % LST_NODE_HASHSIZE; @@ -283,7 +284,7 @@ static void lstcon_group_ndlink_release(struct lstcon_group *, } static int -lstcon_group_ndlink_find(struct lstcon_group *grp, lnet_process_id_t id, +lstcon_group_ndlink_find(struct lstcon_group *grp, struct lnet_process_id id, struct lstcon_ndlink **ndlpp, int create) { int rc; @@ -397,14 +398,14 @@ static void lstcon_group_ndlink_release(struct lstcon_group *, static int lstcon_group_nodes_add(struct lstcon_group *grp, - int count, lnet_process_id_t __user *ids_up, + int count, struct lnet_process_id __user *ids_up, unsigned int *featp, struct list_head __user *result_up) { struct lstcon_rpc_trans *trans; struct lstcon_ndlink *ndl; struct lstcon_group *tmp; - lnet_process_id_t id; + struct lnet_process_id id; int i; int rc; @@ -465,13 +466,13 @@ static void lstcon_group_ndlink_release(struct lstcon_group *, static int lstcon_group_nodes_remove(struct lstcon_group *grp, - int count, lnet_process_id_t __user *ids_up, + int count, struct lnet_process_id __user *ids_up, struct list_head __user *result_up) { struct lstcon_rpc_trans *trans; struct lstcon_ndlink *ndl; struct lstcon_group *tmp; - lnet_process_id_t id; + struct lnet_process_id id; int rc; int i; @@ -543,9 +544,8 @@ static void lstcon_group_ndlink_release(struct lstcon_group *, } int -lstcon_nodes_add(char *name, int count, lnet_process_id_t __user *ids_up, - unsigned int *featp, - struct list_head __user *result_up) +lstcon_nodes_add(char *name, int count, struct lnet_process_id __user *ids_up, + unsigned int *featp, struct list_head __user *result_up) { struct lstcon_group *grp; int rc; @@ -650,7 +650,8 @@ static void lstcon_group_ndlink_release(struct lstcon_group *, } int -lstcon_nodes_remove(char *name, int count, lnet_process_id_t __user *ids_up, +lstcon_nodes_remove(char *name, int count, + struct lnet_process_id __user *ids_up, struct list_head __user *result_up) { struct lstcon_group *grp = NULL; @@ -1533,12 +1534,12 @@ static void lstcon_group_ndlink_release(struct lstcon_group *, } int -lstcon_nodes_stat(int count, lnet_process_id_t __user *ids_up, +lstcon_nodes_stat(int count, struct lnet_process_id __user *ids_up, int timeout, struct list_head __user *result_up) { struct lstcon_ndlink *ndl; struct lstcon_group *tmp; - lnet_process_id_t id; + struct lnet_process_id id; int i; int rc; @@ -1644,11 +1645,11 @@ static void lstcon_group_ndlink_release(struct lstcon_group *, } int -lstcon_nodes_debug(int timeout, - int count, lnet_process_id_t __user *ids_up, +lstcon_nodes_debug(int timeout, int count, + struct lnet_process_id __user *ids_up, struct list_head __user *result_up) { - lnet_process_id_t id; + struct lnet_process_id id; struct lstcon_ndlink *ndl; struct lstcon_group *grp; int i; @@ -1697,7 +1698,7 @@ static void lstcon_group_ndlink_release(struct lstcon_group *, static void lstcon_new_session_id(struct lst_sid *sid) { - lnet_process_id_t id; + struct lnet_process_id id; LASSERT(console_session.ses_state == LST_SESSION_NONE); diff --git a/drivers/staging/lustre/lnet/selftest/console.h b/drivers/staging/lustre/lnet/selftest/console.h index 05b4b70..e3e11aa 100644 --- a/drivers/staging/lustre/lnet/selftest/console.h +++ b/drivers/staging/lustre/lnet/selftest/console.h @@ -48,7 +48,7 @@ /* node descriptor */ struct lstcon_node { - lnet_process_id_t nd_id; /* id of the node */ + struct lnet_process_id nd_id; /* id of the node */ int nd_ref; /* reference count */ int nd_state; /* state of the node */ int nd_timeout; /* session timeout */ @@ -180,7 +180,7 @@ struct lstcon_session { } static inline struct list_head * -lstcon_id2hash(lnet_process_id_t id, struct list_head *hash) +lstcon_id2hash(struct lnet_process_id id, struct list_head *hash) { unsigned int idx = LNET_NIDADDR(id.nid) % LST_NODE_HASHSIZE; @@ -203,15 +203,17 @@ int lstcon_batch_debug(int timeout, char *name, int client, struct list_head __user *result_up); int lstcon_group_debug(int timeout, char *name, struct list_head __user *result_up); -int lstcon_nodes_debug(int timeout, int nnd, lnet_process_id_t __user *nds_up, +int lstcon_nodes_debug(int timeout, int nnd, + struct lnet_process_id __user *nds_up, struct list_head __user *result_up); int lstcon_group_add(char *name); int lstcon_group_del(char *name); int lstcon_group_clean(char *name, int args); int lstcon_group_refresh(char *name, struct list_head __user *result_up); -int lstcon_nodes_add(char *name, int nnd, lnet_process_id_t __user *nds_up, +int lstcon_nodes_add(char *name, int nnd, struct lnet_process_id __user *nds_up, unsigned int *featp, struct list_head __user *result_up); -int lstcon_nodes_remove(char *name, int nnd, lnet_process_id_t __user *nds_up, +int lstcon_nodes_remove(char *name, int nnd, + struct lnet_process_id __user *nds_up, struct list_head __user *result_up); int lstcon_group_info(char *name, struct lstcon_ndlist_ent __user *gent_up, int *index_p, int *ndent_p, @@ -232,7 +234,7 @@ int lstcon_batch_info(char *name, struct lstcon_test_batch_ent __user *ent_up, int *ndent_p, struct lstcon_node_ent __user *dents_up); int lstcon_group_stat(char *grp_name, int timeout, struct list_head __user *result_up); -int lstcon_nodes_stat(int count, lnet_process_id_t __user *ids_up, +int lstcon_nodes_stat(int count, struct lnet_process_id __user *ids_up, int timeout, struct list_head __user *result_up); int lstcon_test_add(char *batch_name, int type, int loop, int concur, int dist, int span, diff --git a/drivers/staging/lustre/lnet/selftest/framework.c b/drivers/staging/lustre/lnet/selftest/framework.c index 9dd4e1a..ef27bff 100644 --- a/drivers/staging/lustre/lnet/selftest/framework.c +++ b/drivers/staging/lustre/lnet/selftest/framework.c @@ -899,7 +899,7 @@ } int -sfw_create_test_rpc(struct sfw_test_unit *tsu, lnet_process_id_t peer, +sfw_create_test_rpc(struct sfw_test_unit *tsu, struct lnet_process_id peer, unsigned int features, int nblk, int blklen, struct srpc_client_rpc **rpcpp) { @@ -1379,7 +1379,7 @@ } struct srpc_client_rpc * -sfw_create_rpc(lnet_process_id_t peer, int service, +sfw_create_rpc(struct lnet_process_id peer, int service, unsigned int features, int nbulkiov, int bulklen, void (*done)(struct srpc_client_rpc *), void *priv) { diff --git a/drivers/staging/lustre/lnet/selftest/ping_test.c b/drivers/staging/lustre/lnet/selftest/ping_test.c index b9601b0..9653ac6 100644 --- a/drivers/staging/lustre/lnet/selftest/ping_test.c +++ b/drivers/staging/lustre/lnet/selftest/ping_test.c @@ -82,7 +82,7 @@ struct lst_ping_data { } static int -ping_client_prep_rpc(struct sfw_test_unit *tsu, lnet_process_id_t dest, +ping_client_prep_rpc(struct sfw_test_unit *tsu, struct lnet_process_id dest, struct srpc_client_rpc **rpc) { struct srpc_ping_reqst *req; diff --git a/drivers/staging/lustre/lnet/selftest/rpc.c b/drivers/staging/lustre/lnet/selftest/rpc.c index f56f740..2231ed2 100644 --- a/drivers/staging/lustre/lnet/selftest/rpc.c +++ b/drivers/staging/lustre/lnet/selftest/rpc.c @@ -355,7 +355,7 @@ struct srpc_bulk * static int srpc_post_passive_rdma(int portal, int local, __u64 matchbits, void *buf, - int len, int options, lnet_process_id_t peer, + int len, int options, struct lnet_process_id peer, struct lnet_handle_md *mdh, struct srpc_event *ev) { int rc; @@ -394,8 +394,9 @@ struct srpc_bulk * static int srpc_post_active_rdma(int portal, __u64 matchbits, void *buf, int len, - int options, lnet_process_id_t peer, lnet_nid_t self, - struct lnet_handle_md *mdh, struct srpc_event *ev) + int options, struct lnet_process_id peer, + lnet_nid_t self, struct lnet_handle_md *mdh, + struct srpc_event *ev) { int rc; struct lnet_md md; @@ -450,7 +451,7 @@ struct srpc_bulk * srpc_post_passive_rqtbuf(int service, int local, void *buf, int len, struct lnet_handle_md *mdh, struct srpc_event *ev) { - lnet_process_id_t any = { 0 }; + struct lnet_process_id any = { 0 }; any.nid = LNET_NID_ANY; any.pid = LNET_PID_ANY; @@ -1310,7 +1311,7 @@ struct srpc_bulk * } struct srpc_client_rpc * -srpc_create_client_rpc(lnet_process_id_t peer, int service, +srpc_create_client_rpc(struct lnet_process_id peer, int service, int nbulkiov, int bulklen, void (*rpc_done)(struct srpc_client_rpc *), void (*rpc_fini)(struct srpc_client_rpc *), void *priv) diff --git a/drivers/staging/lustre/lnet/selftest/selftest.h b/drivers/staging/lustre/lnet/selftest/selftest.h index 91088c6..2e2c215 100644 --- a/drivers/staging/lustre/lnet/selftest/selftest.h +++ b/drivers/staging/lustre/lnet/selftest/selftest.h @@ -165,7 +165,7 @@ struct srpc_buffer { struct srpc_msg buf_msg; struct lnet_handle_md buf_mdh; lnet_nid_t buf_self; - lnet_process_id_t buf_peer; + struct lnet_process_id buf_peer; }; struct swi_workitem; @@ -186,7 +186,7 @@ struct srpc_server_rpc { struct swi_workitem srpc_wi; struct srpc_event srpc_ev; /* bulk/reply event */ lnet_nid_t srpc_self; - lnet_process_id_t srpc_peer; + struct lnet_process_id srpc_peer; struct srpc_msg srpc_replymsg; struct lnet_handle_md srpc_replymdh; struct srpc_buffer *srpc_reqstbuf; @@ -206,7 +206,7 @@ struct srpc_client_rpc { int crpc_timeout; /* # seconds to wait for reply */ struct stt_timer crpc_timer; struct swi_workitem crpc_wi; - lnet_process_id_t crpc_dest; + struct lnet_process_id crpc_dest; void (*crpc_done)(struct srpc_client_rpc *); void (*crpc_fini)(struct srpc_client_rpc *); @@ -355,7 +355,7 @@ struct sfw_test_client_ops { * client */ int (*tso_prep_rpc)(struct sfw_test_unit *tsu, - lnet_process_id_t dest, + struct lnet_process_id dest, struct srpc_client_rpc **rpc); /* prep a tests rpc */ void (*tso_done_rpc)(struct sfw_test_unit *tsu, struct srpc_client_rpc *rpc); /* done a test rpc */ @@ -392,8 +392,8 @@ struct sfw_test_instance { }; /* - * XXX: trailing (PAGE_SIZE % sizeof(lnet_process_id_t)) bytes at the end of - * pages are not used + * XXX: trailing (PAGE_SIZE % sizeof(struct lnet_process_id)) bytes at the end + * of pages are not used */ #define SFW_MAX_CONCUR LST_MAX_CONCUR #define SFW_ID_PER_PAGE (PAGE_SIZE / sizeof(struct lnet_process_id_packed)) @@ -402,7 +402,7 @@ struct sfw_test_instance { struct sfw_test_unit { struct list_head tsu_list; /* chain on lst_test_instance */ - lnet_process_id_t tsu_dest; /* id of dest node */ + struct lnet_process_id tsu_dest; /* id of dest node */ int tsu_loop; /* loop count of the test */ struct sfw_test_instance *tsu_instance; /* pointer to test instance */ void *tsu_private; /* private data */ @@ -416,11 +416,11 @@ struct sfw_test_case { }; struct srpc_client_rpc * -sfw_create_rpc(lnet_process_id_t peer, int service, +sfw_create_rpc(struct lnet_process_id peer, int service, unsigned int features, int nbulkiov, int bulklen, void (*done)(struct srpc_client_rpc *), void *priv); int sfw_create_test_rpc(struct sfw_test_unit *tsu, - lnet_process_id_t peer, unsigned int features, + struct lnet_process_id peer, unsigned int features, int nblk, int blklen, struct srpc_client_rpc **rpc); void sfw_abort_rpc(struct srpc_client_rpc *rpc); void sfw_post_rpc(struct srpc_client_rpc *rpc); @@ -434,7 +434,7 @@ int sfw_make_session(struct srpc_mksn_reqst *request, struct srpc_mksn_reply *reply); struct srpc_client_rpc * -srpc_create_client_rpc(lnet_process_id_t peer, int service, +srpc_create_client_rpc(struct lnet_process_id peer, int service, int nbulkiov, int bulklen, void (*rpc_done)(struct srpc_client_rpc *), void (*rpc_fini)(struct srpc_client_rpc *), void *priv); @@ -522,7 +522,7 @@ struct srpc_bulk *srpc_alloc_bulk(int cpt, unsigned int off, } static inline void -srpc_init_client_rpc(struct srpc_client_rpc *rpc, lnet_process_id_t peer, +srpc_init_client_rpc(struct srpc_client_rpc *rpc, struct lnet_process_id peer, int service, int nbulkiov, int bulklen, void (*rpc_done)(struct srpc_client_rpc *), void (*rpc_fini)(struct srpc_client_rpc *), void *priv) diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h index c7c7c3a..d61b000 100644 --- a/drivers/staging/lustre/lustre/include/lustre_net.h +++ b/drivers/staging/lustre/lustre/include/lustre_net.h @@ -288,7 +288,7 @@ struct ptlrpc_connection { /** Our own lnet nid for this connection */ lnet_nid_t c_self; /** Remote side nid for this connection */ - lnet_process_id_t c_peer; + struct lnet_process_id c_peer; /** UUID of the other side */ struct obd_uuid c_remote_uuid; /** reference counter for this connection */ @@ -876,7 +876,7 @@ struct ptlrpc_request { /** our LNet NID */ lnet_nid_t rq_self; /** Peer description (the other side) */ - lnet_process_id_t rq_peer; + struct lnet_process_id rq_peer; /** * service time estimate (secs) * If the request is not served by this time, it is marked as timed out. @@ -1751,7 +1751,7 @@ static inline bool nrs_policy_compat_one(const struct ptlrpc_service *svc, /* ptlrpc/events.c */ extern struct lnet_handle_eq ptlrpc_eq_h; int ptlrpc_uuid_to_peer(struct obd_uuid *uuid, - lnet_process_id_t *peer, lnet_nid_t *self); + struct lnet_process_id *peer, lnet_nid_t *self); /** * These callbacks are invoked by LNet when something happened to * underlying buffer @@ -1765,7 +1765,7 @@ int ptlrpc_uuid_to_peer(struct obd_uuid *uuid, /** @} */ /* ptlrpc/connection.c */ -struct ptlrpc_connection *ptlrpc_connection_get(lnet_process_id_t peer, +struct ptlrpc_connection *ptlrpc_connection_get(struct lnet_process_id peer, lnet_nid_t self, struct obd_uuid *uuid); int ptlrpc_connection_put(struct ptlrpc_connection *c); diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 973eee6..7b80040 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -2512,7 +2512,7 @@ ssize_t ll_copy_user_md(const struct lov_user_md __user *md, void ll_compute_rootsquash_state(struct ll_sb_info *sbi) { struct root_squash_info *squash = &sbi->ll_squash; - lnet_process_id_t id; + struct lnet_process_id id; bool matched; int i; diff --git a/drivers/staging/lustre/lustre/llite/super25.c b/drivers/staging/lustre/lustre/llite/super25.c index 4759802..56f4b10 100644 --- a/drivers/staging/lustre/lustre/llite/super25.c +++ b/drivers/staging/lustre/lustre/llite/super25.c @@ -84,7 +84,7 @@ struct super_operations lustre_super_operations = { static int __init lustre_init(void) { - lnet_process_id_t lnet_id; + struct lnet_process_id lnet_id; struct timespec64 ts; int i, rc, seed[2]; diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 4cf0664..d8aa3fb 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -1195,7 +1195,8 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli, return rc; } -static int check_write_checksum(struct obdo *oa, const lnet_process_id_t *peer, +static int check_write_checksum(struct obdo *oa, + const struct lnet_process_id *peer, __u32 client_cksum, __u32 server_cksum, int nob, u32 page_count, struct brw_page **pga, enum cksum_type client_cksum_type) @@ -1245,7 +1246,7 @@ static int check_write_checksum(struct obdo *oa, const lnet_process_id_t *peer, static int osc_brw_fini_request(struct ptlrpc_request *req, int rc) { struct osc_brw_async_args *aa = (void *)&req->rq_async_args; - const lnet_process_id_t *peer = + const struct lnet_process_id *peer = &req->rq_import->imp_connection->c_peer; struct client_obd *cli = aa->aa_cli; struct ost_body *body; diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c index 5645c31..6466974 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c @@ -78,7 +78,7 @@ struct ptlrpc_connection *ptlrpc_uuid_to_connection(struct obd_uuid *uuid) { struct ptlrpc_connection *c; lnet_nid_t self; - lnet_process_id_t peer; + struct lnet_process_id peer; int err; /* diff --git a/drivers/staging/lustre/lustre/ptlrpc/connection.c b/drivers/staging/lustre/lustre/ptlrpc/connection.c index 6c7c8b6..73a2dbb 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/connection.c +++ b/drivers/staging/lustre/lustre/ptlrpc/connection.c @@ -41,7 +41,7 @@ static struct cfs_hash_ops conn_hash_ops; struct ptlrpc_connection * -ptlrpc_connection_get(lnet_process_id_t peer, lnet_nid_t self, +ptlrpc_connection_get(struct lnet_process_id peer, lnet_nid_t self, struct obd_uuid *uuid) { struct ptlrpc_connection *conn, *conn2; @@ -155,14 +155,14 @@ void ptlrpc_connection_fini(void) static unsigned int conn_hashfn(struct cfs_hash *hs, const void *key, unsigned int mask) { - return cfs_hash_djb2_hash(key, sizeof(lnet_process_id_t), mask); + return cfs_hash_djb2_hash(key, sizeof(struct lnet_process_id), mask); } static int conn_keycmp(const void *key, struct hlist_node *hnode) { struct ptlrpc_connection *conn; - const lnet_process_id_t *conn_key; + const struct lnet_process_id *conn_key; LASSERT(key); conn_key = key; diff --git a/drivers/staging/lustre/lustre/ptlrpc/events.c b/drivers/staging/lustre/lustre/ptlrpc/events.c index 3aec148..978bdac 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/events.c +++ b/drivers/staging/lustre/lustre/ptlrpc/events.c @@ -446,7 +446,7 @@ static void ptlrpc_master_callback(struct lnet_event *ev) } int ptlrpc_uuid_to_peer(struct obd_uuid *uuid, - lnet_process_id_t *peer, lnet_nid_t *self) + struct lnet_process_id *peer, lnet_nid_t *self) { int best_dist = 0; __u32 best_order = 0; diff --git a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c index befd73c..e3d2c0d 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c +++ b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c @@ -109,7 +109,7 @@ static void mdunlink_iterate_helper(struct lnet_handle_md *bd_mds, int count) static int ptlrpc_register_bulk(struct ptlrpc_request *req) { struct ptlrpc_bulk_desc *desc = req->rq_bulk; - lnet_process_id_t peer; + struct lnet_process_id peer; int rc = 0; int rc2; int posted_md; @@ -719,7 +719,7 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) int ptlrpc_register_rqbd(struct ptlrpc_request_buffer_desc *rqbd) { struct ptlrpc_service *service = rqbd->rqbd_svcpt->scp_service; - static lnet_process_id_t match_id = {LNET_NID_ANY, LNET_PID_ANY}; + static struct lnet_process_id match_id = {LNET_NID_ANY, LNET_PID_ANY}; int rc; struct lnet_md md; struct lnet_handle_me me_h; -- 1.8.3.1 From jsimmons at infradead.org Mon Feb 27 00:41:42 2017 From: jsimmons at infradead.org (James Simmons) Date: Sun, 26 Feb 2017 19:41:42 -0500 Subject: [lustre-devel] [PATCH 17/34] staging: lustre: lnet: change lnet_remotenet_t to proper structure In-Reply-To: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> References: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> Message-ID: <1488156119-19670-18-git-send-email-jsimmons@infradead.org> Change lnet_remotenet_t from typedef to proper structure. Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/20831 Reviewed-by: Olaf Weber Reviewed-by: Doug Oucharek Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- .../staging/lustre/include/linux/lnet/lib-lnet.h | 2 +- .../staging/lustre/include/linux/lnet/lib-types.h | 4 ++-- drivers/staging/lustre/lnet/lnet/api-ni.c | 2 +- drivers/staging/lustre/lnet/lnet/lib-move.c | 6 +++--- drivers/staging/lustre/lnet/lnet/router.c | 24 +++++++++++----------- drivers/staging/lustre/lnet/lnet/router_proc.c | 4 ++-- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h index 93e6830..8483a4a 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h @@ -473,7 +473,7 @@ int lnet_get_route(int idx, __u32 *net, __u32 *hops, int lnet_rtrpools_enable(void); void lnet_rtrpools_disable(void); void lnet_rtrpools_free(int keep_pools); -lnet_remotenet_t *lnet_find_net_locked(__u32 net); +struct lnet_remotenet *lnet_find_net_locked(__u32 net); int lnet_dyn_add_ni(lnet_pid_t requested_pid, struct lnet_ioctl_config_data *conf); int lnet_dyn_del_ni(__u32 net); diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index a0d9cad..04ad728 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -384,12 +384,12 @@ struct lnet_route { #define LNET_REMOTE_NETS_HASH_MAX (1U << 16) #define LNET_REMOTE_NETS_HASH_SIZE (1 << the_lnet.ln_remote_nets_hbits) -typedef struct { +struct lnet_remotenet { struct list_head lrn_list; /* chain on ln_remote_nets_hash */ struct list_head lrn_routes; /* routes to me */ __u32 lrn_net; /* my net number */ -} lnet_remotenet_t; +}; /** lnet message has credit and can be submitted to lnd for send/receive */ #define LNET_CREDIT_OK 0 diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index 88279ed..c03e701 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -1762,7 +1762,7 @@ void lnet_lib_exit(void) struct lnet_handle_md md_handle; struct lnet_ni *ni; struct list_head net_head; - lnet_remotenet_t *rnet; + struct lnet_remotenet *rnet; int rc; INIT_LIST_HEAD(&net_head); diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c index 9d1ab1f..3581100 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-move.c +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c @@ -998,7 +998,7 @@ lnet_find_route_locked(struct lnet_ni *ni, lnet_nid_t target, lnet_nid_t rtr_nid) { - lnet_remotenet_t *rnet; + struct lnet_remotenet *rnet; struct lnet_route *route; struct lnet_route *best_route; struct lnet_route *last_route; @@ -2291,7 +2291,7 @@ struct lnet_msg * { struct list_head *e; struct lnet_ni *ni; - lnet_remotenet_t *rnet; + struct lnet_remotenet *rnet; __u32 dstnet = LNET_NIDNET(dstnid); int hops; int cpt; @@ -2348,7 +2348,7 @@ struct lnet_msg * rn_list = lnet_net2rnethash(dstnet); list_for_each(e, rn_list) { - rnet = list_entry(e, lnet_remotenet_t, lrn_list); + rnet = list_entry(e, struct lnet_remotenet, lrn_list); if (rnet->lrn_net == dstnet) { struct lnet_route *route; diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c index 8e5af05..9a5faba 100644 --- a/drivers/staging/lustre/lnet/lnet/router.c +++ b/drivers/staging/lustre/lnet/lnet/router.c @@ -217,10 +217,10 @@ } } -lnet_remotenet_t * +struct lnet_remotenet * lnet_find_net_locked(__u32 net) { - lnet_remotenet_t *rnet; + struct lnet_remotenet *rnet; struct list_head *tmp; struct list_head *rn_list; @@ -228,7 +228,7 @@ rn_list = lnet_net2rnethash(net); list_for_each(tmp, rn_list) { - rnet = list_entry(tmp, lnet_remotenet_t, lrn_list); + rnet = list_entry(tmp, struct lnet_remotenet, lrn_list); if (rnet->lrn_net == net) return rnet; @@ -268,7 +268,7 @@ static void lnet_shuffle_seed(void) /* NB expects LNET_LOCK held */ static void -lnet_add_route_to_rnet(lnet_remotenet_t *rnet, struct lnet_route *route) +lnet_add_route_to_rnet(struct lnet_remotenet *rnet, struct lnet_route *route) { unsigned int len = 0; unsigned int offset = 0; @@ -299,8 +299,8 @@ static void lnet_shuffle_seed(void) unsigned int priority) { struct list_head *e; - lnet_remotenet_t *rnet; - lnet_remotenet_t *rnet2; + struct lnet_remotenet *rnet; + struct lnet_remotenet *rnet2; struct lnet_route *route; struct lnet_ni *ni; int add_route; @@ -416,7 +416,7 @@ static void lnet_shuffle_seed(void) int lnet_check_routes(void) { - lnet_remotenet_t *rnet; + struct lnet_remotenet *rnet; struct lnet_route *route; struct lnet_route *route2; struct list_head *e1; @@ -430,7 +430,7 @@ static void lnet_shuffle_seed(void) for (i = 0; i < LNET_REMOTE_NETS_HASH_SIZE; i++) { rn_list = &the_lnet.ln_remote_nets_hash[i]; list_for_each(e1, rn_list) { - rnet = list_entry(e1, lnet_remotenet_t, lrn_list); + rnet = list_entry(e1, struct lnet_remotenet, lrn_list); route2 = NULL; list_for_each(e2, &rnet->lrn_routes) { @@ -472,7 +472,7 @@ static void lnet_shuffle_seed(void) lnet_del_route(__u32 net, lnet_nid_t gw_nid) { struct lnet_peer *gateway; - lnet_remotenet_t *rnet; + struct lnet_remotenet *rnet; struct lnet_route *route; struct list_head *e1; struct list_head *e2; @@ -495,7 +495,7 @@ static void lnet_shuffle_seed(void) again: list_for_each(e1, rn_list) { - rnet = list_entry(e1, lnet_remotenet_t, lrn_list); + rnet = list_entry(e1, struct lnet_remotenet, lrn_list); if (!(net == LNET_NIDNET(LNET_NID_ANY) || net == rnet->lrn_net)) @@ -588,7 +588,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) { struct list_head *e1; struct list_head *e2; - lnet_remotenet_t *rnet; + struct lnet_remotenet *rnet; struct lnet_route *route; int cpt; int i; @@ -599,7 +599,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) for (i = 0; i < LNET_REMOTE_NETS_HASH_SIZE; i++) { rn_list = &the_lnet.ln_remote_nets_hash[i]; list_for_each(e1, rn_list) { - rnet = list_entry(e1, lnet_remotenet_t, lrn_list); + rnet = list_entry(e1, struct lnet_remotenet, lrn_list); list_for_each(e2, &rnet->lrn_routes) { route = list_entry(e2, struct lnet_route, diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c index 1b2817c..779ec69 100644 --- a/drivers/staging/lustre/lnet/lnet/router_proc.c +++ b/drivers/staging/lustre/lnet/lnet/router_proc.c @@ -172,7 +172,7 @@ static int proc_lnet_routes(struct ctl_table *table, int write, struct list_head *n; struct list_head *r; struct lnet_route *route = NULL; - lnet_remotenet_t *rnet = NULL; + struct lnet_remotenet *rnet = NULL; int skip = off - 1; struct list_head *rn_list; int i; @@ -191,7 +191,7 @@ static int proc_lnet_routes(struct ctl_table *table, int write, n = rn_list->next; while (n != rn_list && !route) { - rnet = list_entry(n, lnet_remotenet_t, + rnet = list_entry(n, struct lnet_remotenet, lrn_list); r = rnet->lrn_routes.next; -- 1.8.3.1 From jsimmons at infradead.org Mon Feb 27 00:41:34 2017 From: jsimmons at infradead.org (James Simmons) Date: Sun, 26 Feb 2017 19:41:34 -0500 Subject: [lustre-devel] [PATCH 09/34] staging: lustre: lnet: change lnet_me_t to proper structure In-Reply-To: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> References: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> Message-ID: <1488156119-19670-10-git-send-email-jsimmons@infradead.org> Change lnet_me_t from typedef to proper structure. Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/20831 Reviewed-by: Olaf Weber Reviewed-by: Doug Oucharek Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/include/linux/lnet/lib-lnet.h | 18 +++++++++--------- drivers/staging/lustre/include/linux/lnet/lib-types.h | 6 +++--- drivers/staging/lustre/lnet/lnet/lib-md.c | 2 +- drivers/staging/lustre/lnet/lnet/lib-me.c | 4 ++-- drivers/staging/lustre/lnet/lnet/lib-ptl.c | 14 +++++++------- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h index 9e33d0a..a82bb3c 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h @@ -233,17 +233,17 @@ static inline int lnet_md_unlinkable(lnet_libmd_t *md) LIBCFS_FREE(md, size); } -static inline lnet_me_t * +static inline struct lnet_me * lnet_me_alloc(void) { - lnet_me_t *me; + struct lnet_me *me; LIBCFS_ALLOC(me, sizeof(*me)); return me; } static inline void -lnet_me_free(lnet_me_t *me) +lnet_me_free(struct lnet_me *me) { LIBCFS_FREE(me, sizeof(*me)); } @@ -342,12 +342,12 @@ void lnet_res_lh_initialize(struct lnet_res_container *rec, } static inline void -lnet_me2handle(struct lnet_handle_me *handle, lnet_me_t *me) +lnet_me2handle(struct lnet_handle_me *handle, struct lnet_me *me) { handle->cookie = me->me_lh.lh_cookie; } -static inline lnet_me_t * +static inline struct lnet_me * lnet_handle2me(struct lnet_handle_me *handle) { /* ALWAYS called with resource lock held */ @@ -360,7 +360,7 @@ void lnet_res_lh_initialize(struct lnet_res_container *rec, if (!lh) return NULL; - return lh_entry(lh, lnet_me_t, me_lh); + return lh_entry(lh, struct lnet_me, me_lh); } static inline void @@ -542,9 +542,9 @@ int lnet_mt_match_md(struct lnet_match_table *mtable, struct lnet_match_info *info, struct lnet_msg *msg); /* portals match/attach functions */ -void lnet_ptl_attach_md(lnet_me_t *me, lnet_libmd_t *md, +void lnet_ptl_attach_md(struct lnet_me *me, lnet_libmd_t *md, struct list_head *matches, struct list_head *drops); -void lnet_ptl_detach_md(lnet_me_t *me, lnet_libmd_t *md); +void lnet_ptl_detach_md(struct lnet_me *me, lnet_libmd_t *md); int lnet_ptl_match_md(struct lnet_match_info *info, struct lnet_msg *msg); /* initialized and finalize portals */ @@ -623,7 +623,7 @@ void lnet_copy_kiov2iter(struct iov_iter *to, unsigned int nkiov, const lnet_kiov_t *kiov, unsigned int kiovoffset, unsigned int nob); -void lnet_me_unlink(lnet_me_t *me); +void lnet_me_unlink(struct lnet_me *me); void lnet_md_unlink(lnet_libmd_t *md); void lnet_md_deconstruct(lnet_libmd_t *lmd, lnet_md_t *umd); diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index 19e01cc..3384860 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -127,7 +127,7 @@ struct lnet_eq { int **eq_refs; /* percpt refcount for EQ */ }; -typedef struct lnet_me { +struct lnet_me { struct list_head me_list; struct lnet_libhandle me_lh; lnet_process_id_t me_match_id; @@ -137,12 +137,12 @@ struct lnet_eq { __u64 me_ignore_bits; lnet_unlink_t me_unlink; struct lnet_libmd *me_md; -} lnet_me_t; +}; typedef struct lnet_libmd { struct list_head md_list; struct lnet_libhandle md_lh; - lnet_me_t *md_me; + struct lnet_me *md_me; char *md_start; unsigned int md_offset; unsigned int md_length; diff --git a/drivers/staging/lustre/lnet/lnet/lib-md.c b/drivers/staging/lustre/lnet/lnet/lib-md.c index 4f2700e..dd3cdda 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-md.c +++ b/drivers/staging/lustre/lnet/lnet/lib-md.c @@ -44,7 +44,7 @@ { if (!(md->md_flags & LNET_MD_FLAG_ZOMBIE)) { /* first unlink attempt... */ - lnet_me_t *me = md->md_me; + struct lnet_me *me = md->md_me; md->md_flags |= LNET_MD_FLAG_ZOMBIE; diff --git a/drivers/staging/lustre/lnet/lnet/lib-me.c b/drivers/staging/lustre/lnet/lnet/lib-me.c index 0ea64f6..20cc8f8 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-me.c +++ b/drivers/staging/lustre/lnet/lnet/lib-me.c @@ -222,7 +222,7 @@ int LNetMEUnlink(struct lnet_handle_me meh) { - lnet_me_t *me; + struct lnet_me *me; lnet_libmd_t *md; lnet_event_t ev; int cpt; @@ -256,7 +256,7 @@ /* call with lnet_res_lock please */ void -lnet_me_unlink(lnet_me_t *me) +lnet_me_unlink(struct lnet_me *me) { list_del(&me->me_list); diff --git a/drivers/staging/lustre/lnet/lnet/lib-ptl.c b/drivers/staging/lustre/lnet/lnet/lib-ptl.c index 891d028..b538939 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-ptl.c +++ b/drivers/staging/lustre/lnet/lnet/lib-ptl.c @@ -140,7 +140,7 @@ */ unsigned int offset; unsigned int mlength; - lnet_me_t *me = md->md_me; + struct lnet_me *me = md->md_me; /* MD exhausted */ if (lnet_md_exhausted(md)) @@ -376,8 +376,8 @@ struct list_head * struct lnet_match_info *info, struct lnet_msg *msg) { struct list_head *head; - lnet_me_t *me; - lnet_me_t *tmp; + struct lnet_me *me; + struct lnet_me *tmp; int exhausted = 0; int rc; @@ -641,7 +641,7 @@ struct list_head * } void -lnet_ptl_detach_md(lnet_me_t *me, lnet_libmd_t *md) +lnet_ptl_detach_md(struct lnet_me *me, lnet_libmd_t *md) { LASSERT(me->me_md == md && md->md_me == me); @@ -651,7 +651,7 @@ struct list_head * /* called with lnet_res_lock held */ void -lnet_ptl_attach_md(lnet_me_t *me, lnet_libmd_t *md, +lnet_ptl_attach_md(struct lnet_me *me, lnet_libmd_t *md, struct list_head *matches, struct list_head *drops) { struct lnet_portal *ptl = the_lnet.ln_portals[me->me_portal]; @@ -756,7 +756,7 @@ struct list_head * LASSERT(list_empty(&ptl->ptl_msg_stealing)); cfs_percpt_for_each(mtable, i, ptl->ptl_mtables) { struct list_head *mhash; - lnet_me_t *me; + struct lnet_me *me; int j; if (!mtable->mt_mhash) /* uninitialized match-table */ @@ -767,7 +767,7 @@ struct list_head * for (j = 0; j < LNET_MT_HASH_SIZE + 1; j++) { while (!list_empty(&mhash[j])) { me = list_entry(mhash[j].next, - lnet_me_t, me_list); + struct lnet_me, me_list); CERROR("Active ME %p on exit\n", me); list_del(&me->me_list); lnet_me_free(me); -- 1.8.3.1 From jsimmons at infradead.org Mon Feb 27 00:41:37 2017 From: jsimmons at infradead.org (James Simmons) Date: Sun, 26 Feb 2017 19:41:37 -0500 Subject: [lustre-devel] [PATCH 12/34] staging: lustre: lnet: change lnd_t to proper structure In-Reply-To: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> References: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> Message-ID: <1488156119-19670-13-git-send-email-jsimmons@infradead.org> Change lnd_t from typedef to proper structure. Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/20831 Reviewed-by: Olaf Weber Reviewed-by: Doug Oucharek Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/include/linux/lnet/lib-lnet.h | 6 +++--- drivers/staging/lustre/include/linux/lnet/lib-types.h | 6 +++--- drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 4 ++-- drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c | 2 +- drivers/staging/lustre/lnet/lnet/api-ni.c | 14 +++++++------- drivers/staging/lustre/lnet/lnet/lo.c | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h index 685c5d4..9a29769 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h @@ -439,7 +439,7 @@ void lnet_res_lh_initialize(struct lnet_res_container *rec, ((1U << the_lnet.ln_remote_nets_hbits) - 1)]; } -extern lnd_t the_lolnd; +extern struct lnet_lnd the_lolnd; extern int avoid_asym_router_failure; int lnet_cpt_of_nid_locked(lnet_nid_t nid); @@ -628,8 +628,8 @@ void lnet_copy_kiov2iter(struct iov_iter *to, void lnet_md_unlink(struct lnet_libmd *md); void lnet_md_deconstruct(struct lnet_libmd *lmd, lnet_md_t *umd); -void lnet_register_lnd(lnd_t *lnd); -void lnet_unregister_lnd(lnd_t *lnd); +void lnet_register_lnd(struct lnet_lnd *lnd); +void lnet_unregister_lnd(struct lnet_lnd *lnd); int lnet_connect(struct socket **sockp, lnet_nid_t peer_nid, __u32 local_ip, __u32 peer_ip, int peer_port); diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index 59d7143..8a65db2 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -179,7 +179,7 @@ struct lnet_test_peer { struct lnet_ni; /* forward ref */ -typedef struct lnet_lnd { +struct lnet_lnd { /* fields managed by portals */ struct list_head lnd_list; /* stash in the LND table */ int lnd_refcount; /* # active instances */ @@ -243,7 +243,7 @@ struct lnet_test_peer { /* accept a new connection */ int (*lnd_accept)(struct lnet_ni *ni, struct socket *sock); -} lnd_t; +}; struct lnet_tx_queue { int tq_credits; /* # tx credits free */ @@ -267,7 +267,7 @@ struct lnet_tx_queue { __u32 *ni_cpts; /* bond NI on some CPTs */ lnet_nid_t ni_nid; /* interface's NID */ void *ni_data; /* instance-specific data */ - lnd_t *ni_lnd; /* procedural interface */ + struct lnet_lnd *ni_lnd; /* procedural interface */ struct lnet_tx_queue **ni_tx_queues; /* percpt TX queues */ int **ni_refs; /* percpt reference count */ time64_t ni_last_alive;/* when I was last alive */ diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c index 6f73454..29a5263 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c @@ -38,7 +38,7 @@ #include #include "o2iblnd.h" -static lnd_t the_o2iblnd; +static struct lnet_lnd the_o2iblnd; struct kib_data kiblnd_data; @@ -2938,7 +2938,7 @@ static int kiblnd_startup(lnet_ni_t *ni) return -ENETDOWN; } -static lnd_t the_o2iblnd = { +static struct lnet_lnd the_o2iblnd = { .lnd_type = O2IBLND, .lnd_startup = kiblnd_startup, .lnd_shutdown = kiblnd_shutdown, diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c index 3b08aff..258507f 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c @@ -39,7 +39,7 @@ #include "socklnd.h" -static lnd_t the_ksocklnd; +static struct lnet_lnd the_ksocklnd; struct ksock_nal_data ksocknal_data; static struct ksock_interface * diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index aeb9e6f..d31a50b 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -265,15 +265,15 @@ static void lnet_assert_wire_constants(void) BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.hello.type) != 4); } -static lnd_t * +static struct lnet_lnd * lnet_find_lnd_by_type(__u32 type) { - lnd_t *lnd; + struct lnet_lnd *lnd; struct list_head *tmp; /* holding lnd mutex */ list_for_each(tmp, &the_lnet.ln_lnds) { - lnd = list_entry(tmp, lnd_t, lnd_list); + lnd = list_entry(tmp, struct lnet_lnd, lnd_list); if (lnd->lnd_type == type) return lnd; @@ -283,7 +283,7 @@ static void lnet_assert_wire_constants(void) } void -lnet_register_lnd(lnd_t *lnd) +lnet_register_lnd(struct lnet_lnd *lnd) { mutex_lock(&the_lnet.ln_lnd_mutex); @@ -300,7 +300,7 @@ static void lnet_assert_wire_constants(void) EXPORT_SYMBOL(lnet_register_lnd); void -lnet_unregister_lnd(lnd_t *lnd) +lnet_unregister_lnd(struct lnet_lnd *lnd) { mutex_lock(&the_lnet.ln_lnd_mutex); @@ -1220,7 +1220,7 @@ struct lnet_libhandle * struct lnet_ioctl_config_lnd_tunables *lnd_tunables = NULL; int rc = -EINVAL; int lnd_type; - lnd_t *lnd; + struct lnet_lnd *lnd; struct lnet_tx_queue *tq; int i; @@ -1475,7 +1475,7 @@ void lnet_lib_exit(void) while (!list_empty(&the_lnet.ln_lnds)) lnet_unregister_lnd(list_entry(the_lnet.ln_lnds.next, - lnd_t, lnd_list)); + struct lnet_lnd, lnd_list)); lnet_destroy_locks(); } diff --git a/drivers/staging/lustre/lnet/lnet/lo.c b/drivers/staging/lustre/lnet/lnet/lo.c index 12b6b3a..d11b4f9 100644 --- a/drivers/staging/lustre/lnet/lnet/lo.c +++ b/drivers/staging/lustre/lnet/lnet/lo.c @@ -88,7 +88,7 @@ return 0; } -lnd_t the_lolnd = { +struct lnet_lnd the_lolnd = { /* .lnd_list = */ {&the_lolnd.lnd_list, &the_lolnd.lnd_list}, /* .lnd_refcount = */ 0, /* .lnd_type = */ LOLND, -- 1.8.3.1 From jsimmons at infradead.org Mon Feb 27 00:41:39 2017 From: jsimmons at infradead.org (James Simmons) Date: Sun, 26 Feb 2017 19:41:39 -0500 Subject: [lustre-devel] [PATCH 14/34] staging: lustre: lnet: change lnet_rc_data_t to proper structure In-Reply-To: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> References: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> Message-ID: <1488156119-19670-15-git-send-email-jsimmons@infradead.org> Change lnet_rc_data_t from typedef to proper structure. Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/20831 Reviewed-by: Olaf Weber Reviewed-by: Doug Oucharek Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/include/linux/lnet/lib-types.h | 6 +++--- drivers/staging/lustre/lnet/lnet/router.c | 18 +++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index bcfb0c7..10bf60f 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -297,13 +297,13 @@ struct lnet_ni { /* router checker data, per router */ #define LNET_MAX_RTR_NIS 16 #define LNET_PINGINFO_SIZE offsetof(struct lnet_ping_info, pi_ni[LNET_MAX_RTR_NIS]) -typedef struct { +struct lnet_rc_data { /* chain on the_lnet.ln_zombie_rcd or ln_deathrow_rcd */ struct list_head rcd_list; struct lnet_handle_md rcd_mdh; /* ping buffer MD */ struct lnet_peer *rcd_gateway; /* reference to gateway */ struct lnet_ping_info *rcd_pinginfo; /* ping buffer */ -} lnet_rc_data_t; +}; typedef struct lnet_peer { struct list_head lp_hashlist; /* chain on peer hash */ @@ -345,7 +345,7 @@ struct lnet_ni { /* returned RC ping features */ unsigned int lp_ping_feats; struct list_head lp_routes; /* routers on this peer */ - lnet_rc_data_t *lp_rcd; /* router checker state */ + struct lnet_rc_data *lp_rcd; /* router checker state */ } lnet_peer_t; /* peer hash size */ diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c index 85fdd08..c73d7a0 100644 --- a/drivers/staging/lustre/lnet/lnet/router.c +++ b/drivers/staging/lustre/lnet/lnet/router.c @@ -642,7 +642,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) * networks on that router. */ static void -lnet_parse_rc_info(lnet_rc_data_t *rcd) +lnet_parse_rc_info(struct lnet_rc_data *rcd) { struct lnet_ping_info *info = rcd->rcd_pinginfo; struct lnet_peer *gw = rcd->rcd_gateway; @@ -733,7 +733,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) static void lnet_router_checker_event(lnet_event_t *event) { - lnet_rc_data_t *rcd = event->md.user_ptr; + struct lnet_rc_data *rcd = event->md.user_ptr; struct lnet_peer *lp; LASSERT(rcd); @@ -878,7 +878,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) } static void -lnet_destroy_rc_data(lnet_rc_data_t *rcd) +lnet_destroy_rc_data(struct lnet_rc_data *rcd) { LASSERT(list_empty(&rcd->rcd_list)); /* detached from network */ @@ -898,10 +898,10 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) LIBCFS_FREE(rcd, sizeof(*rcd)); } -static lnet_rc_data_t * +static struct lnet_rc_data * lnet_create_rc_data_locked(lnet_peer_t *gateway) { - lnet_rc_data_t *rcd = NULL; + struct lnet_rc_data *rcd = NULL; struct lnet_ping_info *pi; lnet_md_t md; int rc; @@ -984,7 +984,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) static void lnet_ping_router_locked(lnet_peer_t *rtr) { - lnet_rc_data_t *rcd = NULL; + struct lnet_rc_data *rcd = NULL; unsigned long now = cfs_time_current(); int secs; @@ -1124,8 +1124,8 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) static void lnet_prune_rc_data(int wait_unlink) { - lnet_rc_data_t *rcd; - lnet_rc_data_t *tmp; + struct lnet_rc_data *rcd; + struct lnet_rc_data *tmp; lnet_peer_t *lp; struct list_head head; int i = 2; @@ -1182,7 +1182,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) while (!list_empty(&head)) { rcd = list_entry(head.next, - lnet_rc_data_t, rcd_list); + struct lnet_rc_data, rcd_list); list_del_init(&rcd->rcd_list); lnet_destroy_rc_data(rcd); } -- 1.8.3.1 From jsimmons at infradead.org Mon Feb 27 00:41:57 2017 From: jsimmons at infradead.org (James Simmons) Date: Sun, 26 Feb 2017 19:41:57 -0500 Subject: [lustre-devel] [PATCH 32/34] staging: lustre: lnet: remove LNET_SEQ_BASETYPE In-Reply-To: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> References: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> Message-ID: <1488156119-19670-33-git-send-email-jsimmons@infradead.org> The lnet_seq_t is a simple unsigned long so lets simplify it. Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/20831 Reviewed-by: Olaf Weber Reviewed-by: Doug Oucharek Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/include/linux/lnet/lib-types.h | 4 ++-- drivers/staging/lustre/include/linux/lnet/types.h | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index b9f1bd2..69c11c1 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -119,8 +119,8 @@ struct lnet_libhandle { struct lnet_eq { struct list_head eq_list; struct lnet_libhandle eq_lh; - lnet_seq_t eq_enq_seq; - lnet_seq_t eq_deq_seq; + unsigned long eq_enq_seq; + unsigned long eq_deq_seq; unsigned int eq_size; lnet_eq_handler_t eq_callback; struct lnet_event *eq_events; diff --git a/drivers/staging/lustre/include/linux/lnet/types.h b/drivers/staging/lustre/include/linux/lnet/types.h index 8e10ad6..7d39496 100644 --- a/drivers/staging/lustre/include/linux/lnet/types.h +++ b/drivers/staging/lustre/include/linux/lnet/types.h @@ -561,9 +561,7 @@ enum lnet_event_kind { LNET_EVENT_UNLINK, }; -#define LNET_SEQ_BASETYPE long -typedef unsigned LNET_SEQ_BASETYPE lnet_seq_t; -#define LNET_SEQ_GT(a, b) (((signed LNET_SEQ_BASETYPE)((a) - (b))) > 0) +#define LNET_SEQ_GT(a, b) (((signed long)((a) - (b))) > 0) /** * Information about an event on a MD. @@ -634,7 +632,7 @@ struct lnet_event { * The sequence number for this event. Sequence numbers are unique * to each event. */ - volatile lnet_seq_t sequence; + volatile unsigned long sequence; }; /** -- 1.8.3.1 From jsimmons at infradead.org Mon Feb 27 00:41:58 2017 From: jsimmons at infradead.org (James Simmons) Date: Sun, 26 Feb 2017 19:41:58 -0500 Subject: [lustre-devel] [PATCH 33/34] staging: lustre: lnet: remove unused lnet_md_iovec_t In-Reply-To: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> References: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> Message-ID: <1488156119-19670-34-git-send-email-jsimmons@infradead.org> The typedef lnet_md_iovec_t is never used so kill it off. Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/20831 Reviewed-by: Olaf Weber Reviewed-by: Doug Oucharek Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/include/linux/lnet/types.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/types.h b/drivers/staging/lustre/include/linux/lnet/types.h index 7d39496..44cee82 100644 --- a/drivers/staging/lustre/include/linux/lnet/types.h +++ b/drivers/staging/lustre/include/linux/lnet/types.h @@ -510,9 +510,6 @@ struct lnet_md { /** Infinite threshold on MD operations. See lnet_md::threshold */ #define LNET_MD_THRESH_INF (-1) -/* NB lustre portals uses struct iovec internally! */ -typedef struct iovec lnet_md_iovec_t; - typedef struct bio_vec lnet_kiov_t; /** @} lnet_md */ -- 1.8.3.1 From jsimmons at infradead.org Mon Feb 27 00:41:56 2017 From: jsimmons at infradead.org (James Simmons) Date: Sun, 26 Feb 2017 19:41:56 -0500 Subject: [lustre-devel] [PATCH 31/34] staging: lustre: lnet: change lnet_ack_req_t to proper enum In-Reply-To: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> References: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> Message-ID: <1488156119-19670-32-git-send-email-jsimmons@infradead.org> Change lnet_ack_req_t from typedef to proper enum. Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/20831 Reviewed-by: Olaf Weber Reviewed-by: Doug Oucharek Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/include/linux/lnet/api.h | 2 +- drivers/staging/lustre/include/linux/lnet/types.h | 4 ++-- drivers/staging/lustre/lnet/lnet/lib-move.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/niobuf.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/api.h b/drivers/staging/lustre/include/linux/lnet/api.h index fc42898..f4b6de2 100644 --- a/drivers/staging/lustre/include/linux/lnet/api.h +++ b/drivers/staging/lustre/include/linux/lnet/api.h @@ -180,7 +180,7 @@ int LNetEQPoll(struct lnet_handle_eq *eventqs_in, */ int LNetPut(lnet_nid_t self, struct lnet_handle_md md_in, - lnet_ack_req_t ack_req_in, + enum lnet_ack_req ack_req_in, struct lnet_process_id target_in, unsigned int portal_in, __u64 match_bits_in, diff --git a/drivers/staging/lustre/include/linux/lnet/types.h b/drivers/staging/lustre/include/linux/lnet/types.h index a621ab6..8e10ad6 100644 --- a/drivers/staging/lustre/include/linux/lnet/types.h +++ b/drivers/staging/lustre/include/linux/lnet/types.h @@ -663,12 +663,12 @@ struct lnet_event { * \see lnet_md::options for the discussion on LNET_MD_ACK_DISABLE by which * acknowledgments can be disabled for a MD. */ -typedef enum { +enum lnet_ack_req { /** Request an acknowledgment */ LNET_ACK_REQ, /** Request that no acknowledgment should be generated. */ LNET_NOACK_REQ -} lnet_ack_req_t; +}; /** @} lnet_data */ /** @} lnet */ diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c index 7fdbc75..48e1f5b 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-move.c +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c @@ -1990,7 +1990,7 @@ * \see lnet_event::hdr_data and lnet_event_kind. */ int -LNetPut(lnet_nid_t self, struct lnet_handle_md mdh, lnet_ack_req_t ack, +LNetPut(lnet_nid_t self, struct lnet_handle_md mdh, enum lnet_ack_req ack, struct lnet_process_id target, unsigned int portal, __u64 match_bits, unsigned int offset, __u64 hdr_data) diff --git a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c index e3d2c0d..eddc192 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c +++ b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c @@ -44,7 +44,7 @@ * Returns 0 on success or error code. */ static int ptl_send_buf(struct lnet_handle_md *mdh, void *base, int len, - lnet_ack_req_t ack, struct ptlrpc_cb_id *cbid, + enum lnet_ack_req ack, struct ptlrpc_cb_id *cbid, struct ptlrpc_connection *conn, int portal, __u64 xid, unsigned int offset) { -- 1.8.3.1 From jsimmons at infradead.org Mon Feb 27 00:41:27 2017 From: jsimmons at infradead.org (James Simmons) Date: Sun, 26 Feb 2017 19:41:27 -0500 Subject: [lustre-devel] [PATCH 02/34] staging: lustre: lnet: change lnet_handle_eq_t to proper struct In-Reply-To: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> References: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> Message-ID: <1488156119-19670-3-git-send-email-jsimmons@infradead.org> Change lnet_handle_eq_t from a typedef of another typedef into a proper stand alone structure. Create the inline functions LNetInvalidateEQHandle and LNetEQHandleIsInvalid to handle this new piece of data. Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/20831 Reviewed-by: Olaf Weber Reviewed-by: Doug Oucharek Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/include/linux/lnet/api.h | 8 +++---- .../staging/lustre/include/linux/lnet/lib-lnet.h | 6 +++--- .../staging/lustre/include/linux/lnet/lib-types.h | 4 ++-- drivers/staging/lustre/include/linux/lnet/types.h | 25 ++++++++++++++++++++-- drivers/staging/lustre/lnet/lnet/api-ni.c | 4 ++-- drivers/staging/lustre/lnet/lnet/lib-eq.c | 6 +++--- drivers/staging/lustre/lnet/lnet/lib-md.c | 4 ++-- drivers/staging/lustre/lnet/lnet/router.c | 2 +- drivers/staging/lustre/lnet/selftest/rpc.c | 4 ++-- drivers/staging/lustre/lustre/include/lustre_net.h | 2 +- drivers/staging/lustre/lustre/ptlrpc/events.c | 2 +- 11 files changed, 44 insertions(+), 23 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/api.h b/drivers/staging/lustre/include/linux/lnet/api.h index cb0d6b4..1db4e00 100644 --- a/drivers/staging/lustre/include/linux/lnet/api.h +++ b/drivers/staging/lustre/include/linux/lnet/api.h @@ -147,7 +147,7 @@ int LNetMDBind(lnet_md_t md_in, * associated with it. If an event handler exists, it will be run for each * event that is deposited into the EQ. * - * In addition to the lnet_handle_eq_t, the LNet API defines two types + * In addition to the lnet_handle_eq, the LNet API defines two types * associated with events: The ::lnet_event_kind_t defines the kinds of events * that can be stored in an EQ. The lnet_event_t defines a structure that * holds the information about with an event. @@ -162,11 +162,11 @@ int LNetMDBind(lnet_md_t md_in, */ int LNetEQAlloc(unsigned int count_in, lnet_eq_handler_t handler, - lnet_handle_eq_t *handle_out); + struct lnet_handle_eq *handle_out); -int LNetEQFree(lnet_handle_eq_t eventq_in); +int LNetEQFree(struct lnet_handle_eq eventq_in); -int LNetEQPoll(lnet_handle_eq_t *eventqs_in, +int LNetEQPoll(struct lnet_handle_eq *eventqs_in, int neq_in, int timeout_ms, lnet_event_t *event_out, diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h index 3d19402..808d886 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h @@ -278,10 +278,10 @@ void lnet_res_lh_initialize(struct lnet_res_container *rec, } static inline void -lnet_eq2handle(lnet_handle_eq_t *handle, lnet_eq_t *eq) +lnet_eq2handle(struct lnet_handle_eq *handle, lnet_eq_t *eq) { if (!eq) { - LNetInvalidateHandle(handle); + LNetInvalidateEQHandle(handle); return; } @@ -289,7 +289,7 @@ void lnet_res_lh_initialize(struct lnet_res_container *rec, } static inline lnet_eq_t * -lnet_handle2eq(lnet_handle_eq_t *handle) +lnet_handle2eq(struct lnet_handle_eq *handle) { lnet_libhandle_t *lh; diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index 9850398..199e194 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -598,13 +598,13 @@ struct lnet_msg_container { lnet_rtrbufpool_t **ln_rtrpools; lnet_handle_md_t ln_ping_target_md; - lnet_handle_eq_t ln_ping_target_eq; + struct lnet_handle_eq ln_ping_target_eq; struct lnet_ping_info *ln_ping_info; /* router checker startup/shutdown state */ int ln_rc_state; /* router checker's event queue */ - lnet_handle_eq_t ln_rc_eqh; + struct lnet_handle_eq ln_rc_eqh; /* rcd still pending on net */ struct list_head ln_rcd_deathrow; /* rcd ready for free */ diff --git a/drivers/staging/lustre/include/linux/lnet/types.h b/drivers/staging/lustre/include/linux/lnet/types.h index 1c8de72..ebf87cd 100644 --- a/drivers/staging/lustre/include/linux/lnet/types.h +++ b/drivers/staging/lustre/include/linux/lnet/types.h @@ -284,7 +284,6 @@ struct lnet_ping_info { __u64 cookie; } lnet_handle_any_t; -typedef lnet_handle_any_t lnet_handle_eq_t; typedef lnet_handle_any_t lnet_handle_md_t; typedef lnet_handle_any_t lnet_handle_me_t; @@ -318,6 +317,28 @@ static inline int LNetHandleIsInvalid(lnet_handle_any_t h) return h.cookie == LNET_WIRE_HANDLE_COOKIE_NONE; } +struct lnet_handle_eq { + u64 cookie; +}; + +/** + * Invalidate eq handle @h. + */ +static inline void LNetInvalidateEQHandle(struct lnet_handle_eq *h) +{ + h->cookie = LNET_WIRE_HANDLE_COOKIE_NONE; +} + +/** + * Check whether eq handle @h is invalid. + * + * @return 1 if handle is invalid, 0 if valid. + */ +static inline int LNetEQHandleIsInvalid(struct lnet_handle_eq h) +{ + return (LNET_WIRE_HANDLE_COOKIE_NONE == h.cookie); +} + /** * Global process ID. */ @@ -461,7 +482,7 @@ static inline int LNetHandleIsInvalid(lnet_handle_any_t h) * by LNetInvalidateHandle()), operations performed on this memory * descriptor are not logged. */ - lnet_handle_eq_t eq_handle; + struct lnet_handle_eq eq_handle; } lnet_md_t; /* diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index 08b38ef..0564e93 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -1433,7 +1433,7 @@ int lnet_lib_init(void) } the_lnet.ln_refcount = 0; - LNetInvalidateHandle(&the_lnet.ln_rc_eqh); + LNetInvalidateEQHandle(&the_lnet.ln_rc_eqh); INIT_LIST_HEAD(&the_lnet.ln_lnds); INIT_LIST_HEAD(&the_lnet.ln_rcd_zombie); INIT_LIST_HEAD(&the_lnet.ln_rcd_deathrow); @@ -2138,7 +2138,7 @@ void LNetDebugPeer(lnet_process_id_t id) static int lnet_ping(lnet_process_id_t id, int timeout_ms, lnet_process_id_t __user *ids, int n_ids) { - lnet_handle_eq_t eqh; + struct lnet_handle_eq eqh; lnet_handle_md_t mdh; lnet_event_t event; lnet_md_t md = { NULL }; diff --git a/drivers/staging/lustre/lnet/lnet/lib-eq.c b/drivers/staging/lustre/lnet/lnet/lib-eq.c index d05c6cc..6645fdc 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-eq.c +++ b/drivers/staging/lustre/lnet/lnet/lib-eq.c @@ -64,7 +64,7 @@ */ int LNetEQAlloc(unsigned int count, lnet_eq_handler_t callback, - lnet_handle_eq_t *handle) + struct lnet_handle_eq *handle) { lnet_eq_t *eq; @@ -152,7 +152,7 @@ * \retval -EBUSY If the EQ is still in use by some MDs. */ int -LNetEQFree(lnet_handle_eq_t eqh) +LNetEQFree(struct lnet_handle_eq eqh) { struct lnet_eq *eq; lnet_event_t *events = NULL; @@ -370,7 +370,7 @@ * \retval -ENOENT If there's an invalid handle in \a eventqs. */ int -LNetEQPoll(lnet_handle_eq_t *eventqs, int neq, int timeout_ms, +LNetEQPoll(struct lnet_handle_eq *eventqs, int neq, int timeout_ms, lnet_event_t *event, int *which) { int wait = 1; diff --git a/drivers/staging/lustre/lnet/lnet/lib-md.c b/drivers/staging/lustre/lnet/lnet/lib-md.c index eab53cd..d97e046 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-md.c +++ b/drivers/staging/lustre/lnet/lnet/lib-md.c @@ -165,7 +165,7 @@ /* must be called with resource lock held */ static int -lnet_md_link(lnet_libmd_t *md, lnet_handle_eq_t eq_handle, int cpt) +lnet_md_link(lnet_libmd_t *md, struct lnet_handle_eq eq_handle, int cpt) { struct lnet_res_container *container = the_lnet.ln_md_containers[cpt]; @@ -185,7 +185,7 @@ * maybe there we shouldn't even allow LNET_EQ_NONE!) * LASSERT(!eq); */ - if (!LNetHandleIsInvalid(eq_handle)) { + if (!LNetEQHandleIsInvalid(eq_handle)) { md->md_eq = lnet_handle2eq(&eq_handle); if (!md->md_eq) diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c index cf22525..ba80221 100644 --- a/drivers/staging/lustre/lnet/lnet/router.c +++ b/drivers/staging/lustre/lnet/lnet/router.c @@ -933,7 +933,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) md.options = LNET_MD_TRUNCATE; md.eq_handle = the_lnet.ln_rc_eqh; - LASSERT(!LNetHandleIsInvalid(the_lnet.ln_rc_eqh)); + LASSERT(!LNetEQHandleIsInvalid(the_lnet.ln_rc_eqh)); rc = LNetMDBind(md, LNET_UNLINK, &rcd->rcd_mdh); if (rc < 0) { CERROR("Can't bind MD: %d\n", rc); diff --git a/drivers/staging/lustre/lnet/selftest/rpc.c b/drivers/staging/lustre/lnet/selftest/rpc.c index 92cd411..3f070eb 100644 --- a/drivers/staging/lustre/lnet/selftest/rpc.c +++ b/drivers/staging/lustre/lnet/selftest/rpc.c @@ -53,7 +53,7 @@ enum srpc_state { static struct smoketest_rpc { spinlock_t rpc_glock; /* global lock */ struct srpc_service *rpc_services[SRPC_SERVICE_MAX_ID + 1]; - lnet_handle_eq_t rpc_lnet_eq; /* _the_ LNet event queue */ + struct lnet_handle_eq rpc_lnet_eq; /* _the_ LNet event queue */ enum srpc_state rpc_state; struct srpc_counters rpc_counters; __u64 rpc_matchbits; /* matchbits counter */ @@ -1622,7 +1622,7 @@ struct srpc_client_rpc * srpc_data.rpc_state = SRPC_STATE_NI_INIT; - LNetInvalidateHandle(&srpc_data.rpc_lnet_eq); + LNetInvalidateEQHandle(&srpc_data.rpc_lnet_eq); rc = LNetEQAlloc(0, srpc_lnet_ev_handler, &srpc_data.rpc_lnet_eq); if (rc) { CERROR("LNetEQAlloc() has failed: %d\n", rc); diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h index 1b48df0..7955cbf 100644 --- a/drivers/staging/lustre/lustre/include/lustre_net.h +++ b/drivers/staging/lustre/lustre/include/lustre_net.h @@ -1749,7 +1749,7 @@ static inline bool nrs_policy_compat_one(const struct ptlrpc_service *svc, /** @} nrs */ /* ptlrpc/events.c */ -extern lnet_handle_eq_t ptlrpc_eq_h; +extern struct lnet_handle_eq ptlrpc_eq_h; int ptlrpc_uuid_to_peer(struct obd_uuid *uuid, lnet_process_id_t *peer, lnet_nid_t *self); /** diff --git a/drivers/staging/lustre/lustre/ptlrpc/events.c b/drivers/staging/lustre/lustre/ptlrpc/events.c index dc0fe9d..ca11b03 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/events.c +++ b/drivers/staging/lustre/lustre/ptlrpc/events.c @@ -42,7 +42,7 @@ #include "../include/lustre_sec.h" #include "ptlrpc_internal.h" -lnet_handle_eq_t ptlrpc_eq_h; +struct lnet_handle_eq ptlrpc_eq_h; /* * Client's outgoing request callback -- 1.8.3.1 From jsimmons at infradead.org Mon Feb 27 00:41:44 2017 From: jsimmons at infradead.org (James Simmons) Date: Sun, 26 Feb 2017 19:41:44 -0500 Subject: [lustre-devel] [PATCH 19/34] staging: lustre: lnet: change lnet_rtrbuf_t to proper structure In-Reply-To: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> References: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> Message-ID: <1488156119-19670-20-git-send-email-jsimmons@infradead.org> Change lnet_rtrbuf_t from typedef to proper structure. Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/20831 Reviewed-by: Olaf Weber Reviewed-by: Doug Oucharek Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/include/linux/lnet/lib-lnet.h | 2 +- drivers/staging/lustre/include/linux/lnet/lib-types.h | 4 ++-- drivers/staging/lustre/lnet/lnet/lib-move.c | 8 ++++---- drivers/staging/lustre/lnet/lnet/router.c | 18 +++++++++--------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h index 61a911a..223e5a3 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h @@ -468,7 +468,7 @@ int lnet_get_route(int idx, __u32 *net, __u32 *hops, void lnet_router_debugfs_init(void); void lnet_router_debugfs_fini(void); int lnet_rtrpools_alloc(int im_a_router); -void lnet_destroy_rtrbuf(lnet_rtrbuf_t *rb, int npages); +void lnet_destroy_rtrbuf(struct lnet_rtrbuf *rb, int npages); int lnet_rtrpools_adjust(int tiny, int small, int large); int lnet_rtrpools_enable(void); void lnet_rtrpools_disable(void); diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index b654ab6..f939492 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -410,11 +410,11 @@ struct lnet_rtrbufpool { int rbp_mincredits; /* low water mark */ }; -typedef struct { +struct lnet_rtrbuf { struct list_head rb_list; /* chain on rbp_bufs */ struct lnet_rtrbufpool *rb_pool; /* owning pool */ lnet_kiov_t rb_kiov[0]; /* the buffer space */ -} lnet_rtrbuf_t; +}; #define LNET_PEER_HASHSIZE 503 /* prime! */ diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c index 2d31e1f..aea899e 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-move.c +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c @@ -711,7 +711,7 @@ */ struct lnet_peer *lp = msg->msg_rxpeer; struct lnet_rtrbufpool *rbp; - lnet_rtrbuf_t *rb; + struct lnet_rtrbuf *rb; LASSERT(!msg->msg_iov); LASSERT(!msg->msg_kiov); @@ -759,7 +759,7 @@ } LASSERT(!list_empty(&rbp->rbp_bufs)); - rb = list_entry(rbp->rbp_bufs.next, lnet_rtrbuf_t, rb_list); + rb = list_entry(rbp->rbp_bufs.next, struct lnet_rtrbuf, rb_list); list_del(&rb->rb_list); msg->msg_niov = rbp->rbp_npages; @@ -879,7 +879,7 @@ if (msg->msg_rtrcredit) { /* give back global router credits */ - lnet_rtrbuf_t *rb; + struct lnet_rtrbuf *rb; struct lnet_rtrbufpool *rbp; /* @@ -889,7 +889,7 @@ */ LASSERT(msg->msg_kiov); - rb = list_entry(msg->msg_kiov, lnet_rtrbuf_t, rb_kiov[0]); + rb = list_entry(msg->msg_kiov, struct lnet_rtrbuf, rb_kiov[0]); rbp = rb->rb_pool; msg->msg_kiov = NULL; diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c index a5f1f85..effa0fe 100644 --- a/drivers/staging/lustre/lnet/lnet/router.c +++ b/drivers/staging/lustre/lnet/lnet/router.c @@ -1305,9 +1305,9 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) } void -lnet_destroy_rtrbuf(lnet_rtrbuf_t *rb, int npages) +lnet_destroy_rtrbuf(struct lnet_rtrbuf *rb, int npages) { - int sz = offsetof(lnet_rtrbuf_t, rb_kiov[npages]); + int sz = offsetof(struct lnet_rtrbuf, rb_kiov[npages]); while (--npages >= 0) __free_page(rb->rb_kiov[npages].bv_page); @@ -1315,13 +1315,13 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) LIBCFS_FREE(rb, sz); } -static lnet_rtrbuf_t * +static struct lnet_rtrbuf * lnet_new_rtrbuf(struct lnet_rtrbufpool *rbp, int cpt) { int npages = rbp->rbp_npages; - int sz = offsetof(lnet_rtrbuf_t, rb_kiov[npages]); + int sz = offsetof(struct lnet_rtrbuf, rb_kiov[npages]); struct page *page; - lnet_rtrbuf_t *rb; + struct lnet_rtrbuf *rb; int i; LIBCFS_CPT_ALLOC(rb, lnet_cpt_table(), cpt, sz); @@ -1355,8 +1355,8 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) { int npages = rbp->rbp_npages; struct list_head tmp; - lnet_rtrbuf_t *rb; - lnet_rtrbuf_t *temp; + struct lnet_rtrbuf *rb; + struct lnet_rtrbuf *temp; if (!rbp->rbp_nbuffers) /* not initialized or already freed */ return; @@ -1383,7 +1383,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) lnet_rtrpool_adjust_bufs(struct lnet_rtrbufpool *rbp, int nbufs, int cpt) { struct list_head rb_list; - lnet_rtrbuf_t *rb; + struct lnet_rtrbuf *rb; int num_rb; int num_buffers = 0; int old_req_nbufs; @@ -1458,7 +1458,7 @@ int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) failed: while (!list_empty(&rb_list)) { - rb = list_entry(rb_list.next, lnet_rtrbuf_t, rb_list); + rb = list_entry(rb_list.next, struct lnet_rtrbuf, rb_list); list_del(&rb->rb_list); lnet_destroy_rtrbuf(rb, npages); } -- 1.8.3.1 From jsimmons at infradead.org Mon Feb 27 00:41:46 2017 From: jsimmons at infradead.org (James Simmons) Date: Sun, 26 Feb 2017 19:41:46 -0500 Subject: [lustre-devel] [PATCH 21/34] staging: lustre: lnet: change lnet_t to proper structure In-Reply-To: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> References: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> Message-ID: <1488156119-19670-22-git-send-email-jsimmons@infradead.org> Change lnet_t from typedef to proper structure. Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/20831 Reviewed-by: Olaf Weber Reviewed-by: Doug Oucharek Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/include/linux/lnet/lib-lnet.h | 2 +- drivers/staging/lustre/include/linux/lnet/lib-types.h | 4 ++-- drivers/staging/lustre/lnet/lnet/api-ni.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h index 37b9d66..4ffe79c 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h @@ -41,7 +41,7 @@ #include "lib-types.h" #include "lib-dlc.h" -extern lnet_t the_lnet; /* THE network */ +extern struct lnet the_lnet; /* THE network */ #if (BITS_PER_LONG == 32) /* 2 CPTs, allowing more CPTs might make us under memory pressure */ diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index e00bd38..5bf1819 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -545,7 +545,7 @@ struct lnet_msg_container { #define LNET_RC_STATE_RUNNING 1 /* started up OK */ #define LNET_RC_STATE_STOPPING 2 /* telling thread to stop */ -typedef struct { +struct lnet { /* CPU partition table of LNet */ struct cfs_cpt_table *ln_cpt_table; /* number of CPTs in ln_cpt_table */ @@ -648,6 +648,6 @@ struct lnet_msg_container { */ wait_queue_head_t ln_rc_waitq; -} lnet_t; +}; #endif diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index c03e701..024b8e3 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -39,7 +39,7 @@ #define D_LNI D_CONSOLE -lnet_t the_lnet; /* THE state of the network */ +struct lnet the_lnet; /* THE state of the network */ EXPORT_SYMBOL(the_lnet); static char *ip2nets = ""; -- 1.8.3.1 From jsimmons at infradead.org Mon Feb 27 00:41:47 2017 From: jsimmons at infradead.org (James Simmons) Date: Sun, 26 Feb 2017 19:41:47 -0500 Subject: [lustre-devel] [PATCH 22/34] staging: lustre: lnet: give LNET_MATCH* enum a name In-Reply-To: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> References: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> Message-ID: <1488156119-19670-23-git-send-email-jsimmons@infradead.org> The LNET_MATCH* flags are an enum without a name. Lets label that enum. Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/20831 Reviewed-by: Olaf Weber Reviewed-by: Doug Oucharek Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/include/linux/lnet/lib-types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index 5bf1819..ffc961f 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -425,7 +425,7 @@ struct lnet_rtrbuf { /* # different router buffer pools */ #define LNET_NRBPOOLS (LNET_LARGE_BUF_IDX + 1) -enum { +enum lnet_match_flags { /* Didn't match anything */ LNET_MATCHMD_NONE = (1 << 0), /* Matched OK */ -- 1.8.3.1 From jsimmons at infradead.org Mon Feb 27 00:41:52 2017 From: jsimmons at infradead.org (James Simmons) Date: Sun, 26 Feb 2017 19:41:52 -0500 Subject: [lustre-devel] [PATCH 27/34] staging: lustre: lnet: change lnet_msg_type_t to proper enum In-Reply-To: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> References: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> Message-ID: <1488156119-19670-28-git-send-email-jsimmons@infradead.org> Change lnet_msg_type_t from typedef to proper enum. Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/20831 Reviewed-by: Olaf Weber Reviewed-by: Doug Oucharek Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/include/linux/lnet/types.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/types.h b/drivers/staging/lustre/include/linux/lnet/types.h index 74118d0..6a24189 100644 --- a/drivers/staging/lustre/include/linux/lnet/types.h +++ b/drivers/staging/lustre/include/linux/lnet/types.h @@ -132,13 +132,13 @@ struct lnet_handle_wire { __u64 wh_object_cookie; } WIRE_ATTR; -typedef enum { +enum lnet_msg_type { LNET_MSG_ACK = 0, LNET_MSG_PUT, LNET_MSG_GET, LNET_MSG_REPLY, LNET_MSG_HELLO, -} lnet_msg_type_t; +}; /* * The variant fields of the portals message header are aligned on an 8 @@ -182,7 +182,7 @@ struct lnet_hdr { lnet_nid_t src_nid; lnet_pid_t dest_pid; lnet_pid_t src_pid; - __u32 type; /* lnet_msg_type_t */ + __u32 type; /* enum lnet_msg_type */ __u32 payload_length; /* payload data to follow */ /*<------__u64 aligned------->*/ union { -- 1.8.3.1 From jsimmons at infradead.org Mon Feb 27 00:41:54 2017 From: jsimmons at infradead.org (James Simmons) Date: Sun, 26 Feb 2017 19:41:54 -0500 Subject: [lustre-devel] [PATCH 29/34] staging: lustre: lnet: change lnet_ins_pos_t to proper enum In-Reply-To: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> References: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> Message-ID: <1488156119-19670-30-git-send-email-jsimmons@infradead.org> Change lnet_ins_pos_t from typedef to proper enum. Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/20831 Reviewed-by: Olaf Weber Reviewed-by: Doug Oucharek Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/include/linux/lnet/api.h | 4 ++-- drivers/staging/lustre/include/linux/lnet/lib-lnet.h | 2 +- drivers/staging/lustre/include/linux/lnet/types.h | 6 +++--- drivers/staging/lustre/lnet/lnet/lib-me.c | 4 ++-- drivers/staging/lustre/lnet/lnet/lib-ptl.c | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/api.h b/drivers/staging/lustre/include/linux/lnet/api.h index 5537097..125d5cb 100644 --- a/drivers/staging/lustre/include/linux/lnet/api.h +++ b/drivers/staging/lustre/include/linux/lnet/api.h @@ -97,7 +97,7 @@ int LNetMEAttach(unsigned int portal, __u64 match_bits_in, __u64 ignore_bits_in, enum lnet_unlink unlink_in, - lnet_ins_pos_t pos_in, + enum lnet_ins_pos pos_in, struct lnet_handle_me *handle_out); int LNetMEInsert(struct lnet_handle_me current_in, @@ -105,7 +105,7 @@ int LNetMEInsert(struct lnet_handle_me current_in, __u64 match_bits_in, __u64 ignore_bits_in, enum lnet_unlink unlink_in, - lnet_ins_pos_t position_in, + enum lnet_ins_pos position_in, struct lnet_handle_me *handle_out); int LNetMEUnlink(struct lnet_handle_me current_in); diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h index e21323f..2d684a7 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h @@ -538,7 +538,7 @@ struct list_head *lnet_mt_match_head(struct lnet_match_table *mtable, struct lnet_match_table *lnet_mt_of_attach(unsigned int index, struct lnet_process_id id, __u64 mbits, __u64 ignore_bits, - lnet_ins_pos_t pos); + enum lnet_ins_pos pos); int lnet_mt_match_md(struct lnet_match_table *mtable, struct lnet_match_info *info, struct lnet_msg *msg); diff --git a/drivers/staging/lustre/include/linux/lnet/types.h b/drivers/staging/lustre/include/linux/lnet/types.h index 9010895..4fde723 100644 --- a/drivers/staging/lustre/include/linux/lnet/types.h +++ b/drivers/staging/lustre/include/linux/lnet/types.h @@ -352,20 +352,20 @@ enum lnet_unlink { }; /** - * Values of the type lnet_ins_pos_t are used to control where a new match + * Values of the type lnet_ins_pos are used to control where a new match * entry is inserted. The value LNET_INS_BEFORE is used to insert the new * entry before the current entry or before the head of the list. The value * LNET_INS_AFTER is used to insert the new entry after the current entry * or after the last item in the list. */ -typedef enum { +enum lnet_ins_pos { /** insert ME before current position or head of the list */ LNET_INS_BEFORE, /** insert ME after current position or tail of the list */ LNET_INS_AFTER, /** attach ME at tail of local CPU partition ME list */ LNET_INS_LOCAL -} lnet_ins_pos_t; +}; /** @} lnet_me */ diff --git a/drivers/staging/lustre/lnet/lnet/lib-me.c b/drivers/staging/lustre/lnet/lnet/lib-me.c index a944f1f..e9b3eed 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-me.c +++ b/drivers/staging/lustre/lnet/lnet/lib-me.c @@ -72,7 +72,7 @@ LNetMEAttach(unsigned int portal, struct lnet_process_id match_id, __u64 match_bits, __u64 ignore_bits, - enum lnet_unlink unlink, lnet_ins_pos_t pos, + enum lnet_unlink unlink, enum lnet_ins_pos pos, struct lnet_handle_me *handle) { struct lnet_match_table *mtable; @@ -143,7 +143,7 @@ LNetMEInsert(struct lnet_handle_me current_meh, struct lnet_process_id match_id, __u64 match_bits, __u64 ignore_bits, - enum lnet_unlink unlink, lnet_ins_pos_t pos, + enum lnet_unlink unlink, enum lnet_ins_pos pos, struct lnet_handle_me *handle) { struct lnet_me *current_me; diff --git a/drivers/staging/lustre/lnet/lnet/lib-ptl.c b/drivers/staging/lustre/lnet/lnet/lib-ptl.c index fc67af0..63cce0c 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-ptl.c +++ b/drivers/staging/lustre/lnet/lnet/lib-ptl.c @@ -224,7 +224,7 @@ struct lnet_match_table * lnet_mt_of_attach(unsigned int index, struct lnet_process_id id, - __u64 mbits, __u64 ignore_bits, lnet_ins_pos_t pos) + __u64 mbits, __u64 ignore_bits, enum lnet_ins_pos pos) { struct lnet_portal *ptl; struct lnet_match_table *mtable; -- 1.8.3.1 From jsimmons at infradead.org Mon Feb 27 00:41:59 2017 From: jsimmons at infradead.org (James Simmons) Date: Sun, 26 Feb 2017 19:41:59 -0500 Subject: [lustre-devel] [PATCH 34/34] staging: lustre: lnet: use struct bio_vec instead of typedef In-Reply-To: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> References: <1488156119-19670-1-git-send-email-jsimmons@infradead.org> Message-ID: <1488156119-19670-35-git-send-email-jsimmons@infradead.org> Kill off lnet_kiov_t and use struct bio_vec directly. Signed-off-by: James Simmons --- drivers/staging/lustre/include/linux/lnet/lib-lnet.h | 8 ++++---- drivers/staging/lustre/include/linux/lnet/lib-types.h | 6 +++--- drivers/staging/lustre/include/linux/lnet/types.h | 7 +++---- drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 6 +++--- drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h | 12 ++++++------ drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 6 +++--- drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c | 4 ++-- drivers/staging/lustre/lnet/lnet/lib-move.c | 10 +++++----- drivers/staging/lustre/lnet/selftest/conrpc.c | 4 ++-- drivers/staging/lustre/lnet/selftest/selftest.h | 2 +- 10 files changed, 32 insertions(+), 33 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h index dce09fe..8ae7423 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h @@ -612,16 +612,16 @@ int lnet_extract_iov(int dst_niov, struct kvec *dst, int src_niov, const struct kvec *src, unsigned int offset, unsigned int len); -unsigned int lnet_kiov_nob(unsigned int niov, lnet_kiov_t *iov); -int lnet_extract_kiov(int dst_niov, lnet_kiov_t *dst, - int src_niov, const lnet_kiov_t *src, +unsigned int lnet_kiov_nob(unsigned int niov, struct bio_vec *iov); +int lnet_extract_kiov(int dst_niov, struct bio_vec *dst, + int src_niov, const struct bio_vec *src, unsigned int offset, unsigned int len); void lnet_copy_iov2iter(struct iov_iter *to, unsigned int nsiov, const struct kvec *siov, unsigned int soffset, unsigned int nob); void lnet_copy_kiov2iter(struct iov_iter *to, - unsigned int nkiov, const lnet_kiov_t *kiov, + unsigned int nkiov, const struct bio_vec *kiov, unsigned int kiovoffset, unsigned int nob); void lnet_me_unlink(struct lnet_me *me); diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index 69c11c1..321752d 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -102,7 +102,7 @@ struct lnet_msg { unsigned int msg_offset; unsigned int msg_niov; struct kvec *msg_iov; - lnet_kiov_t *msg_kiov; + struct bio_vec *msg_kiov; struct lnet_event msg_ev; struct lnet_hdr msg_hdr; @@ -156,7 +156,7 @@ struct lnet_libmd { unsigned int md_niov; /* # frags */ union { struct kvec iov[LNET_MAX_IOV]; - lnet_kiov_t kiov[LNET_MAX_IOV]; + struct bio_vec kiov[LNET_MAX_IOV]; } md_iov; }; @@ -413,7 +413,7 @@ struct lnet_rtrbufpool { struct lnet_rtrbuf { struct list_head rb_list; /* chain on rbp_bufs */ struct lnet_rtrbufpool *rb_pool; /* owning pool */ - lnet_kiov_t rb_kiov[0]; /* the buffer space */ + struct bio_vec rb_kiov[0]; /* the buffer space */ }; #define LNET_PEER_HASHSIZE 503 /* prime! */ diff --git a/drivers/staging/lustre/include/linux/lnet/types.h b/drivers/staging/lustre/include/linux/lnet/types.h index 44cee82..1be9b7a 100644 --- a/drivers/staging/lustre/include/linux/lnet/types.h +++ b/drivers/staging/lustre/include/linux/lnet/types.h @@ -382,9 +382,9 @@ struct lnet_md { * Specify the memory region associated with the memory descriptor. * If the options field has: * - LNET_MD_KIOV bit set: The start field points to the starting - * address of an array of lnet_kiov_t and the length field specifies + * address of an array of struct bio_vec and the length field specifies * the number of entries in the array. The length can't be bigger - * than LNET_MAX_IOV. The lnet_kiov_t is used to describe page-based + * than LNET_MAX_IOV. The struct bio_vec is used to describe page-based * fragments that are not necessarily mapped in virtual memory. * - LNET_MD_IOVEC bit set: The start field points to the starting * address of an array of struct iovec and the length field specifies @@ -444,7 +444,7 @@ struct lnet_md { * acknowledgment. Acknowledgments are never sent for GET operations. * The data sent in the REPLY serves as an implicit acknowledgment. * - LNET_MD_KIOV: The start and length fields specify an array of - * lnet_kiov_t. + * struct bio_vec. * - LNET_MD_IOVEC: The start and length fields specify an array of * struct iovec. * - LNET_MD_MAX_SIZE: The max_size field is valid. @@ -510,7 +510,6 @@ struct lnet_md { /** Infinite threshold on MD operations. See lnet_md::threshold */ #define LNET_MD_THRESH_INF (-1) -typedef struct bio_vec lnet_kiov_t; /** @} lnet_md */ /** \addtogroup lnet_eq diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c index e850f4c..4a519c4 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c @@ -699,7 +699,7 @@ static int kiblnd_map_tx(struct lnet_ni *ni, struct kib_tx *tx, static int kiblnd_setup_rd_kiov(struct lnet_ni *ni, struct kib_tx *tx, struct kib_rdma_desc *rd, int nkiov, - const lnet_kiov_t *kiov, int offset, int nob) + const struct bio_vec *kiov, int offset, int nob) { struct kib_net *net = ni->ni_data; struct scatterlist *sg; @@ -1487,7 +1487,7 @@ static int kiblnd_resolve_addr(struct rdma_cm_id *cmid, int routing = lntmsg->msg_routing; unsigned int payload_niov = lntmsg->msg_niov; struct kvec *payload_iov = lntmsg->msg_iov; - lnet_kiov_t *payload_kiov = lntmsg->msg_kiov; + struct bio_vec *payload_kiov = lntmsg->msg_kiov; unsigned int payload_offset = lntmsg->msg_offset; unsigned int payload_nob = lntmsg->msg_len; struct iov_iter from; @@ -1656,7 +1656,7 @@ static int kiblnd_resolve_addr(struct rdma_cm_id *cmid, struct lnet_process_id target = lntmsg->msg_target; unsigned int niov = lntmsg->msg_niov; struct kvec *iov = lntmsg->msg_iov; - lnet_kiov_t *kiov = lntmsg->msg_kiov; + struct bio_vec *kiov = lntmsg->msg_kiov; unsigned int offset = lntmsg->msg_offset; unsigned int nob = lntmsg->msg_len; struct kib_tx *tx; diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h index 3f48b60..5540de6 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h @@ -256,11 +256,11 @@ struct ksock_nal_data { /* * A packet just assembled for transmission is represented by 1 or more * struct iovec fragments (the first frag contains the portals header), - * followed by 0 or more lnet_kiov_t fragments. + * followed by 0 or more struct bio_vec fragments. * * On the receive side, initially 1 struct iovec fragment is posted for * receive (the header). Once the header has been received, the payload is - * received into either struct iovec or lnet_kiov_t fragments, depending on + * received into either struct iovec or struct bio_vec fragments, depending on * what the header matched or whether the message needs forwarding. */ struct ksock_conn; /* forward ref */ @@ -282,7 +282,7 @@ struct ksock_tx { /* transmit packet */ unsigned short tx_zc_capable:1; /* payload is large enough for ZC */ unsigned short tx_zc_checked:1; /* Have I checked if I should ZC? */ unsigned short tx_nonblk:1; /* it's a non-blocking ACK */ - lnet_kiov_t *tx_kiov; /* packet page frags */ + struct bio_vec *tx_kiov; /* packet page frags */ struct ksock_conn *tx_conn; /* owning conn */ struct lnet_msg *tx_lnetmsg; /* lnet message for lnet_finalize() */ @@ -292,7 +292,7 @@ struct ksock_tx { /* transmit packet */ union { struct { struct kvec iov; /* virt hdr */ - lnet_kiov_t kiov[0]; /* paged payload */ + struct bio_vec kiov[0]; /* paged payload */ } paged; struct { struct kvec iov[1]; /* virt hdr + payload */ @@ -310,7 +310,7 @@ struct ksock_tx { /* transmit packet */ */ union ksock_rxiovspace { struct kvec iov[LNET_MAX_IOV]; - lnet_kiov_t kiov[LNET_MAX_IOV]; + struct bio_vec kiov[LNET_MAX_IOV]; }; #define SOCKNAL_RX_KSM_HEADER 1 /* reading ksock message header */ @@ -362,7 +362,7 @@ struct ksock_conn { int ksnc_rx_niov; /* # iovec frags */ struct kvec *ksnc_rx_iov; /* the iovec frags */ int ksnc_rx_nkiov; /* # page frags */ - lnet_kiov_t *ksnc_rx_kiov; /* the page frags */ + struct bio_vec *ksnc_rx_kiov; /* the page frags */ union ksock_rxiovspace ksnc_rx_iov_space; /* space for frag descriptors */ __u32 ksnc_rx_csum; /* partial checksum for incoming * data diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c index 695b586..eaa4399 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c @@ -145,7 +145,7 @@ struct ksock_tx * static int ksocknal_send_kiov(struct ksock_conn *conn, struct ksock_tx *tx) { - lnet_kiov_t *kiov = tx->tx_kiov; + struct bio_vec *kiov = tx->tx_kiov; int nob; int rc; @@ -298,7 +298,7 @@ struct ksock_tx * static int ksocknal_recv_kiov(struct ksock_conn *conn) { - lnet_kiov_t *kiov = conn->ksnc_rx_kiov; + struct bio_vec *kiov = conn->ksnc_rx_kiov; int nob; int rc; @@ -946,7 +946,7 @@ struct ksock_route * struct lnet_process_id target = lntmsg->msg_target; unsigned int payload_niov = lntmsg->msg_niov; struct kvec *payload_iov = lntmsg->msg_iov; - lnet_kiov_t *payload_kiov = lntmsg->msg_kiov; + struct bio_vec *payload_kiov = lntmsg->msg_kiov; unsigned int payload_offset = lntmsg->msg_offset; unsigned int payload_nob = lntmsg->msg_len; struct ksock_tx *tx; diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c index 4bcab4b..8a036f4 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c @@ -99,7 +99,7 @@ ksocknal_lib_send_kiov(struct ksock_conn *conn, struct ksock_tx *tx) { struct socket *sock = conn->ksnc_sock; - lnet_kiov_t *kiov = tx->tx_kiov; + struct bio_vec *kiov = tx->tx_kiov; int rc; int nob; @@ -215,7 +215,7 @@ ksocknal_lib_recv_kiov(struct ksock_conn *conn) { unsigned int niov = conn->ksnc_rx_nkiov; - lnet_kiov_t *kiov = conn->ksnc_rx_kiov; + struct bio_vec *kiov = conn->ksnc_rx_kiov; struct msghdr msg = { .msg_flags = 0 }; diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c index 48e1f5b..a99c5c0 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-move.c +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c @@ -212,7 +212,7 @@ void lnet_copy_kiov2iter(struct iov_iter *to, - unsigned int nsiov, const lnet_kiov_t *siov, + unsigned int nsiov, const struct bio_vec *siov, unsigned int soffset, unsigned int nob) { if (!nob) @@ -298,7 +298,7 @@ EXPORT_SYMBOL(lnet_extract_iov); unsigned int -lnet_kiov_nob(unsigned int niov, lnet_kiov_t *kiov) +lnet_kiov_nob(unsigned int niov, struct bio_vec *kiov) { unsigned int nob = 0; @@ -311,8 +311,8 @@ EXPORT_SYMBOL(lnet_kiov_nob); int -lnet_extract_kiov(int dst_niov, lnet_kiov_t *dst, - int src_niov, const lnet_kiov_t *src, +lnet_extract_kiov(int dst_niov, struct bio_vec *dst, + int src_niov, const struct bio_vec *src, unsigned int offset, unsigned int len) { /* @@ -370,7 +370,7 @@ { unsigned int niov = 0; struct kvec *iov = NULL; - lnet_kiov_t *kiov = NULL; + struct bio_vec *kiov = NULL; struct iov_iter to; int rc; diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c b/drivers/staging/lustre/lnet/selftest/conrpc.c index 7985b09..da36c55 100644 --- a/drivers/staging/lustre/lnet/selftest/conrpc.c +++ b/drivers/staging/lustre/lnet/selftest/conrpc.c @@ -699,7 +699,7 @@ void lstcon_rpc_stat_reply(struct lstcon_rpc_trans *, struct srpc_msg *, } static struct lnet_process_id_packed * -lstcon_next_id(int idx, int nkiov, lnet_kiov_t *kiov) +lstcon_next_id(int idx, int nkiov, struct bio_vec *kiov) { struct lnet_process_id_packed *pid; int i; @@ -715,7 +715,7 @@ void lstcon_rpc_stat_reply(struct lstcon_rpc_trans *, struct srpc_msg *, static int lstcon_dstnodes_prep(struct lstcon_group *grp, int idx, - int dist, int span, int nkiov, lnet_kiov_t *kiov) + int dist, int span, int nkiov, struct bio_vec *kiov) { struct lnet_process_id_packed *pid; struct lstcon_ndlink *ndl; diff --git a/drivers/staging/lustre/lnet/selftest/selftest.h b/drivers/staging/lustre/lnet/selftest/selftest.h index 3c68cf3..b614e6f 100644 --- a/drivers/staging/lustre/lnet/selftest/selftest.h +++ b/drivers/staging/lustre/lnet/selftest/selftest.h @@ -156,7 +156,7 @@ struct srpc_bulk { struct lnet_handle_md bk_mdh; int bk_sink; /* sink/source */ int bk_niov; /* # iov in bk_iovs */ - lnet_kiov_t bk_iovs[0]; + struct bio_vec bk_iovs[0]; }; /* message buffer descriptor */ -- 1.8.3.1 From joe at perches.com Mon Feb 27 19:25:29 2017 From: joe at perches.com (Joe Perches) Date: Mon, 27 Feb 2017 11:25:29 -0800 Subject: [lustre-devel] [PATCH 1/5] staging: lustre: Remove unnecessary else after return In-Reply-To: <1488219268-3006-1-git-send-email-singhalsimran0@gmail.com> References: <1488219268-3006-1-git-send-email-singhalsimran0@gmail.com> Message-ID: <1488223529.25838.8.camel@perches.com> On Mon, 2017-02-27 at 23:44 +0530, simran singhal wrote: > This patch fixes the checkpatch warning that else is not generally > useful after a break or return. checkpatch doesn't actually warn for this style if (foo) return bar; else return baz; > @@ > expression e2; > statement s1; > @@ > if(e2) { ... return ...; } > -else > s1 > > Signed-off-by: simran singhal > --- > drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c | 3 +-- > drivers/staging/lustre/lustre/ldlm/ldlm_pool.c | 3 +-- > 2 files changed, 2 insertions(+), 4 deletions(-) > > diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c > index fbbd8a5..02d49b7 100644 > --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c > +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c > @@ -1806,8 +1806,7 @@ ksocknal_close_matching_conns(struct lnet_process_id id, __u32 ipaddr) > > if (!count) > return -ENOENT; > - else > - return 0; > + return 0; > } > > void > diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c > index cf3fc57..ac32c82 100644 > --- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c > +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c > @@ -338,8 +338,7 @@ static int ldlm_cli_pool_shrink(struct ldlm_pool *pl, > > if (nr == 0) > return (unused / 100) * sysctl_vfs_cache_pressure; > - else > - return ldlm_cancel_lru(ns, nr, LCF_ASYNC, LDLM_LRU_FLAG_SHRINK); > + return ldlm_cancel_lru(ns, nr, LCF_ASYNC, LDLM_LRU_FLAG_SHRINK); > } > > static const struct ldlm_pool_ops ldlm_cli_pool_ops = { From joe at perches.com Mon Feb 27 19:31:08 2017 From: joe at perches.com (Joe Perches) Date: Mon, 27 Feb 2017 11:31:08 -0800 Subject: [lustre-devel] [PATCH 4/5] staging: sm750fb: Remove unnecessary else after return In-Reply-To: <1488219268-3006-4-git-send-email-singhalsimran0@gmail.com> References: <1488219268-3006-1-git-send-email-singhalsimran0@gmail.com> <1488219268-3006-4-git-send-email-singhalsimran0@gmail.com> Message-ID: <1488223868.25838.10.camel@perches.com> On Mon, 2017-02-27 at 23:44 +0530, simran singhal wrote: > This patch fixes the checkpatch warning that else is not generally > useful after a break or return. [] > diff --git a/drivers/staging/sm750fb/ddk750_swi2c.c b/drivers/staging/sm750fb/ddk750_swi2c.c [] > @@ -295,8 +294,7 @@ static long sw_i2c_write_byte(unsigned char data) > > if (i < 0xff) > return 0; > - else > - return -1; > + return -1; Assuming -1 is some sort of error, it'd be a more common style to use if (i >= 0xff) return -1; return 0; Looking at the code, it might make sense to use something like: /* SDA still != 0 */ if (i >= 0xff) return -1; return 0; } From joe at perches.com Mon Feb 27 19:41:08 2017 From: joe at perches.com (Joe Perches) Date: Mon, 27 Feb 2017 11:41:08 -0800 Subject: [lustre-devel] [PATCH 5/5] staging: gdm724x: Remove unnecessary else after return In-Reply-To: <1488219268-3006-5-git-send-email-singhalsimran0@gmail.com> References: <1488219268-3006-1-git-send-email-singhalsimran0@gmail.com> <1488219268-3006-5-git-send-email-singhalsimran0@gmail.com> Message-ID: <1488224468.25838.11.camel@perches.com> On Mon, 2017-02-27 at 23:44 +0530, simran singhal wrote: > This patch fixes the checkpatch warning that else is not generally > useful after a break or return. > This was done using Coccinelle: > @@ > expression e2; > statement s1; > @@ > if(e2) { ... return ...; } > -else > s1 [] > diff --git a/drivers/staging/gdm724x/gdm_endian.c b/drivers/staging/gdm724x/gdm_endian.c [] > @@ -26,30 +26,26 @@ __dev16 gdm_cpu_to_dev16(struct gdm_endian *ed, u16 x) > { > if (ed->dev_ed == ENDIANNESS_LITTLE) > return (__force __dev16)cpu_to_le16(x); > - else > - return (__force __dev16)cpu_to_be16(x); > + return (__force __dev16)cpu_to_be16(x); again, not a checkpatch message for any of the suggested modified hunks. From joe at perches.com Mon Feb 27 20:43:20 2017 From: joe at perches.com (Joe Perches) Date: Mon, 27 Feb 2017 12:43:20 -0800 Subject: [lustre-devel] [PATCH 1/5] staging: lustre: Remove unnecessary else after return In-Reply-To: References: <1488219268-3006-1-git-send-email-singhalsimran0@gmail.com> <1488223529.25838.8.camel@perches.com> Message-ID: <1488228200.25838.14.camel@perches.com> On Tue, 2017-02-28 at 01:51 +0530, SIMRAN SINGHAL wrote: > On Tue, Feb 28, 2017 at 12:55 AM, Joe Perches wrote: > > On Mon, 2017-02-27 at 23:44 +0530, simran singhal wrote: > > > This patch fixes the checkpatch warning that else is not generally > > > useful after a break or return. > > > > checkpatch doesn't actually warn for this style > > > > if (foo) > > return bar; > > else > > return baz; > > > > ok, My bad > so, I have to change commit message as checkpatch doesn't warn for this style. Perhaps better would be to leave them unchanged instead. > > > diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c [] > > > @@ -1806,8 +1806,7 @@ ksocknal_close_matching_conns(struct lnet_process_id id, __u32 ipaddr) > > > > > > if (!count) > > > return -ENOENT; > > > - else > > > - return 0; > > > + return 0; There might be a case for this one. error returns are generally in the form { [...] err = func(...); if (err < 0) return err; return 0; } From julia.lawall at lip6.fr Mon Feb 27 21:15:38 2017 From: julia.lawall at lip6.fr (Julia Lawall) Date: Mon, 27 Feb 2017 22:15:38 +0100 (CET) Subject: [lustre-devel] [Outreachy kernel] [PATCH 4/5] staging: sm750fb: Remove unnecessary else after return In-Reply-To: <1488219268-3006-4-git-send-email-singhalsimran0@gmail.com> References: <1488219268-3006-1-git-send-email-singhalsimran0@gmail.com> <1488219268-3006-4-git-send-email-singhalsimran0@gmail.com> Message-ID: On Mon, 27 Feb 2017, simran singhal wrote: > This patch fixes the checkpatch warning that else is not generally > useful after a break or return. > > This was done using Coccinelle: > @@ > expression e2; > statement s1; > @@ > if(e2) { ... return ...; } > -else > s1 > > Signed-off-by: simran singhal > --- > drivers/staging/sm750fb/ddk750_sii164.c | 6 ++---- > drivers/staging/sm750fb/ddk750_swi2c.c | 6 ++---- > 2 files changed, 4 insertions(+), 8 deletions(-) > > diff --git a/drivers/staging/sm750fb/ddk750_sii164.c b/drivers/staging/sm750fb/ddk750_sii164.c > index 259006a..6906598 100644 > --- a/drivers/staging/sm750fb/ddk750_sii164.c > +++ b/drivers/staging/sm750fb/ddk750_sii164.c > @@ -368,8 +368,7 @@ unsigned char sii164IsConnected(void) > hotPlugValue = i2cReadReg(SII164_I2C_ADDRESS, SII164_DETECT) & SII164_DETECT_HOT_PLUG_STATUS_MASK; > if (hotPlugValue == SII164_DETECT_HOT_PLUG_STATUS_ON) > return 1; > - else > - return 0; > + return 0; Totally unrelated to what you are doing, but I wonder if these return values should be true and false? Perhaps it would help to see how the return values are used at the calling context. julia > } > > /* > @@ -387,8 +386,7 @@ unsigned char sii164CheckInterrupt(void) > detectReg = i2cReadReg(SII164_I2C_ADDRESS, SII164_DETECT) & SII164_DETECT_MONITOR_STATE_MASK; > if (detectReg == SII164_DETECT_MONITOR_STATE_CHANGE) > return 1; > - else > - return 0; > + return 0; > } > > /* > diff --git a/drivers/staging/sm750fb/ddk750_swi2c.c b/drivers/staging/sm750fb/ddk750_swi2c.c > index a4ac07c..5997349 100644 > --- a/drivers/staging/sm750fb/ddk750_swi2c.c > +++ b/drivers/staging/sm750fb/ddk750_swi2c.c > @@ -199,8 +199,7 @@ static unsigned char sw_i2c_read_sda(void) > gpio_data = peek32(sw_i2c_data_gpio_data_reg); > if (gpio_data & (1 << sw_i2c_data_gpio)) > return 1; > - else > - return 0; > + return 0; > } > > /* > @@ -295,8 +294,7 @@ static long sw_i2c_write_byte(unsigned char data) > > if (i < 0xff) > return 0; > - else > - return -1; > + return -1; > } > > /* > -- > 2.7.4 > > -- > You received this message because you are subscribed to the Google Groups "outreachy-kernel" group. > To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe at googlegroups.com. > To post to this group, send email to outreachy-kernel at googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1488219268-3006-4-git-send-email-singhalsimran0%40gmail.com. > For more options, visit https://groups.google.com/d/optout. > From julia.lawall at lip6.fr Mon Feb 27 21:19:51 2017 From: julia.lawall at lip6.fr (Julia Lawall) Date: Mon, 27 Feb 2017 22:19:51 +0100 (CET) Subject: [lustre-devel] [Outreachy kernel] [PATCH 3/5] staging: rtl8712: Remove unnecessary else after return In-Reply-To: <1488219268-3006-3-git-send-email-singhalsimran0@gmail.com> References: <1488219268-3006-1-git-send-email-singhalsimran0@gmail.com> <1488219268-3006-3-git-send-email-singhalsimran0@gmail.com> Message-ID: On Mon, 27 Feb 2017, simran singhal wrote: > This patch fixes the checkpatch warning that else is not generally > useful after a break or return. > > This was done using Coccinelle: > @@ > expression e2; > statement s1; > @@ > if(e2) { ... return ...; } > -else > s1 One might be surprised that the following code was detected using the above semantic patch, because in the code below there is no return in the if branches. Actually, as a special feature, when one has an if branch that ends in return, Coccinelle will skip through any gotos and see if the return is matched afterward. Indeed it is a common pattern to have if (...) { foo(x); bar(y); return -ENOMEM; } But the code can also be cut up as eg if (...) { ret = -ENOMEM; goto out; } ... out: foo(x); bar(y); return ret; To avoid having to write multiple patterns for these cases, Coccinelle will just jump through the return in the second case, allowing the same pattern to match both of them. julia > > Signed-off-by: simran singhal > --- > drivers/staging/rtl8712/os_intfs.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/staging/rtl8712/os_intfs.c b/drivers/staging/rtl8712/os_intfs.c > index 8836b31..3062167 100644 > --- a/drivers/staging/rtl8712/os_intfs.c > +++ b/drivers/staging/rtl8712/os_intfs.c > @@ -411,8 +411,7 @@ static int netdev_open(struct net_device *pnetdev) > goto netdev_open_error; > if (!padapter->dvobjpriv.inirp_init) > goto netdev_open_error; > - else > - padapter->dvobjpriv.inirp_init(padapter); > + padapter->dvobjpriv.inirp_init(padapter); > r8712_set_ps_mode(padapter, padapter->registrypriv.power_mgnt, > padapter->registrypriv.smart_ps); > } > -- > 2.7.4 > > -- > You received this message because you are subscribed to the Google Groups "outreachy-kernel" group. > To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe at googlegroups.com. > To post to this group, send email to outreachy-kernel at googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1488219268-3006-3-git-send-email-singhalsimran0%40gmail.com. > For more options, visit https://groups.google.com/d/optout. > From julia.lawall at lip6.fr Mon Feb 27 21:25:23 2017 From: julia.lawall at lip6.fr (Julia Lawall) Date: Mon, 27 Feb 2017 22:25:23 +0100 (CET) Subject: [lustre-devel] [Outreachy kernel] [PATCH 2/5] staging: rtl8192u: Remove unnecessary else after return In-Reply-To: <1488219268-3006-2-git-send-email-singhalsimran0@gmail.com> References: <1488219268-3006-1-git-send-email-singhalsimran0@gmail.com> <1488219268-3006-2-git-send-email-singhalsimran0@gmail.com> Message-ID: On Mon, 27 Feb 2017, simran singhal wrote: > This patch fixes the checkpatch warning that else is not generally > useful after a break or return. > > This was done using Coccinelle: > > @@ > expression e2; > statement s1; > @@ > if(e2) { ... return ...; } > -else > s1 > > Signed-off-by: simran singhal > --- > drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c > index 2453413..4d6c928 100644 > --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c > +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c > @@ -374,8 +374,7 @@ static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) > > if (!tcb_desc->bHwSec) > return ret; > - else > - return 0; > + return 0; In contrast to another patch I commented on, it seems likely that here 0 means success. Converting 0 to false when that is what it means (ie not here) makes the code more understandable. julia From bevans at cray.com Tue Feb 28 16:23:30 2017 From: bevans at cray.com (Ben Evans) Date: Tue, 28 Feb 2017 16:23:30 +0000 Subject: [lustre-devel] Proposal for JobID caching In-Reply-To: <9F0ECE95-3C4B-495D-97BB-9B3AA211D43A@intel.com> References: <6E2CFE03-A158-4D82-82BA-AF0A175AA358@intel.com> <9BEFFD88-0537-43AB-8352-6477F30906DA@intel.com> <9F0ECE95-3C4B-495D-97BB-9B3AA211D43A@intel.com> Message-ID: On 2/16/17, 5:30 PM, "Dilger, Andreas" wrote: >On Feb 16, 2017, at 07:36, Ben Evans wrote: >> >> >> >> On 2/7/17, 6:01 PM, "Dilger, Andreas" wrote: >> >>> On Feb 2, 2017, at 08:20, Ben Evans wrote: >>>> >>>> https://review.whamcloud.com/#/c/25208/ is a working version of what I >>>> had >>>> proposed, including the suggested changes to default to procname_uid. >>>> This is not perfect, but the performance is much improved over the >>>> current >>>> methods, and unlike inode-based caching Metadata performance isn't >>>> negatively affected. Multiple simultaneous jobs can be run on the >>>>same >>>> file, and get appropriate metrics. >>> >>> I reviewed the patch, and one question that I had is whether you've >>>tested >>> if the JobID is correct when read/write RPCs are generated by >>>readahead or >>> ptlrpcd? That may be more relevant once the async readahead threads >>>are >>> implemented by Dmitry. With an inode-based JobID cache then the JobID >>>can >>> (usually) be correctly determined even if the RPC is not generated in >>>the >>> context of the user process. >>> >>> I don't think that is necessarily a fault in your patch, but it may be >>> that >>> the JobID determination hasn't kept pace with other changes in the >>>code. >>> It >>> would be great if you would verify (possibly with a test attached to >>>your >>> patch) that JobID is assigned to all the RPCs that need it. >> >> I've seen some lustre thread names pop into the JobID under the >> procname_uid scheme when doing something like a dd test. Filtering them >> out would be relatively straightforward, and keeping the old JobID (if >> available) in the lookup table would be the way to get the most reliable >> info. There shouldn't be a difference with the current behavior in this >> regard. >> >> My issue with putting the information in the inode stems from 2 cases, >>the >> first is RobinHood, which stats *everything*. In the proposed solution, >> one lookup would be done every 30 seconds. Storing the inode, it would >> happen for every stat, then never used again. >> >> The other case is less probable, but still out there, in an environment >> with multiple jobs per node, you may be running two different jobs on >>the >> same input set, which would corrupt the counting. > >If there are two jobs using the same input files, I suspect the second one >would get the data from the client cache, and not log anything on the >server >at all. In any case, I don't think that would be any different than the >two >jobs are randomly interleaving their access to the same files on the >server. > >Conversely, having "ptlrpcd/0" appear in the jobstats doesn't really help >anyone figure out which user/job is causing IO traffic on the server. If >RPCs generated by ptlrpcd, statahead, and other service threads that do >work >on behalf of user processes (including readahead in the near future) have >the >proper JobID then that would be much more useful. > >Some suggestions on how to handle this, off the top of my head: >- blacklist service thread PIDs at startup in the JobID hash and have them > get the JobID by some other method (e.g. inode, DLM lock/resource, >other) >- store the JobID explicitly with the IO request when it is being put into > a cache/queue and use this when submitting the RPC if present, >otherwise get > it from the hash > >The latter may be preferable, since it doesn't need to do anything for >sync >RPCs generated in process context, and avoids an extra lookup when >processing >the RPC. You might consider the first method for debugging when/where >such >RPCs are generated, and have the backlisted threads dump a stack once if >they >are being looked up in the JobID hash. > >Cheers, Andreas I'm thinking a combination of approaches: Use the hash as the primary source, but populate the inode with the data as well and use it when one of the "reserved" names pops up as the jobID. For any file access, the open would trigger a JobID lookup, which would put the correct info into the hash, and then into the inode. As the JobID is updated the inode's store would also be updated. For a lookup, if the table returns ptlrpc, or any other of the Lustre threads, then the inode cache would be used. This way, we're doing as few userspace lookups as possible, fixing the readahead hole that currently exists, and not having an issue with processes like find or robinhood which touch a lot of files. -Ben From julia.lawall at lip6.fr Tue Feb 28 19:00:57 2017 From: julia.lawall at lip6.fr (Julia Lawall) Date: Tue, 28 Feb 2017 20:00:57 +0100 (CET) Subject: [lustre-devel] [Outreachy kernel] [PATCH 4/5] staging: sm750fb: Remove unnecessary else after return In-Reply-To: References: <1488219268-3006-1-git-send-email-singhalsimran0@gmail.com> <1488219268-3006-4-git-send-email-singhalsimran0@gmail.com> Message-ID: On Wed, 1 Mar 2017, SIMRAN SINGHAL wrote: > On Tue, Feb 28, 2017 at 2:45 AM, Julia Lawall wrote: > > > > > > On Mon, 27 Feb 2017, simran singhal wrote: > > > >> This patch fixes the checkpatch warning that else is not generally > >> useful after a break or return. > >> > >> This was done using Coccinelle: > >> @@ > >> expression e2; > >> statement s1; > >> @@ > >> if(e2) { ... return ...; } > >> -else > >> s1 > >> > >> Signed-off-by: simran singhal > >> --- > >> drivers/staging/sm750fb/ddk750_sii164.c | 6 ++---- > >> drivers/staging/sm750fb/ddk750_swi2c.c | 6 ++---- > >> 2 files changed, 4 insertions(+), 8 deletions(-) > >> > >> diff --git a/drivers/staging/sm750fb/ddk750_sii164.c b/drivers/staging/sm750fb/ddk750_sii164.c > >> index 259006a..6906598 100644 > >> --- a/drivers/staging/sm750fb/ddk750_sii164.c > >> +++ b/drivers/staging/sm750fb/ddk750_sii164.c > >> @@ -368,8 +368,7 @@ unsigned char sii164IsConnected(void) > >> hotPlugValue = i2cReadReg(SII164_I2C_ADDRESS, SII164_DETECT) & SII164_DETECT_HOT_PLUG_STATUS_MASK; > >> if (hotPlugValue == SII164_DETECT_HOT_PLUG_STATUS_ON) > >> return 1; > >> - else > >> - return 0; > >> + return 0; > > > > > > Totally unrelated to what you are doing, but I wonder if these return > > values should be true and false? Perhaps it would help to see how the > > return values are used at the calling context. > > > you want me to go ahead with what Joe mentioned and also do the same > changes here also. I think that it would be best to complete what you have underway already. When those patches are picked up by Greg, you can look into the possibility of using true and false. julia > > julia > > > >> } > >> > >> /* > >> @@ -387,8 +386,7 @@ unsigned char sii164CheckInterrupt(void) > >> detectReg = i2cReadReg(SII164_I2C_ADDRESS, SII164_DETECT) & SII164_DETECT_MONITOR_STATE_MASK; > >> if (detectReg == SII164_DETECT_MONITOR_STATE_CHANGE) > >> return 1; > >> - else > >> - return 0; > >> + return 0; > >> } > >> > >> /* > >> diff --git a/drivers/staging/sm750fb/ddk750_swi2c.c b/drivers/staging/sm750fb/ddk750_swi2c.c > >> index a4ac07c..5997349 100644 > >> --- a/drivers/staging/sm750fb/ddk750_swi2c.c > >> +++ b/drivers/staging/sm750fb/ddk750_swi2c.c > >> @@ -199,8 +199,7 @@ static unsigned char sw_i2c_read_sda(void) > >> gpio_data = peek32(sw_i2c_data_gpio_data_reg); > >> if (gpio_data & (1 << sw_i2c_data_gpio)) > >> return 1; > >> - else > >> - return 0; > >> + return 0; > >> } > >> > >> /* > >> @@ -295,8 +294,7 @@ static long sw_i2c_write_byte(unsigned char data) > >> > >> if (i < 0xff) > >> return 0; > >> - else > >> - return -1; > >> + return -1; > >> } > >> > >> /* > >> -- > >> 2.7.4 > >> > >> -- > >> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group. > >> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe at googlegroups.com. > >> To post to this group, send email to outreachy-kernel at googlegroups.com. > >> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1488219268-3006-4-git-send-email-singhalsimran0%40gmail.com. > >> For more options, visit https://groups.google.com/d/optout. > >> > > -- > You received this message because you are subscribed to the Google Groups "outreachy-kernel" group. > To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe at googlegroups.com. > To post to this group, send email to outreachy-kernel at googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/CALrZqyNXbn1SZ8Daws7yKkYm-C-U9FHyJ_eRxvuem1Fk%2BMqs%3Dg%40mail.gmail.com. > For more options, visit https://groups.google.com/d/optout. > From julia.lawall at lip6.fr Tue Feb 28 19:14:21 2017 From: julia.lawall at lip6.fr (Julia Lawall) Date: Tue, 28 Feb 2017 20:14:21 +0100 (CET) Subject: [lustre-devel] [Outreachy kernel] Re: [PATCH 1/5] staging: lustre: Remove unnecessary else after return In-Reply-To: References: <1488219268-3006-1-git-send-email-singhalsimran0@gmail.com> <1488223529.25838.8.camel@perches.com> <1488228200.25838.14.camel@perches.com> Message-ID: On Wed, 1 Mar 2017, SIMRAN SINGHAL wrote: > On Tue, Feb 28, 2017 at 2:13 AM, Joe Perches wrote: > > On Tue, 2017-02-28 at 01:51 +0530, SIMRAN SINGHAL wrote: > >> On Tue, Feb 28, 2017 at 12:55 AM, Joe Perches wrote: > >> > On Mon, 2017-02-27 at 23:44 +0530, simran singhal wrote: > >> > > This patch fixes the checkpatch warning that else is not generally > >> > > useful after a break or return. > >> > > >> > checkpatch doesn't actually warn for this style > >> > > >> > if (foo) > >> > return bar; > >> > else > >> > return baz; > >> > > >> > >> ok, My bad > >> so, I have to change commit message as checkpatch doesn't warn for this style. > > > > Perhaps better would be to leave them unchanged instead. > > > >> > > diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c > > [] > >> > > @@ -1806,8 +1806,7 @@ ksocknal_close_matching_conns(struct lnet_process_id id, __u32 ipaddr) > >> > > > >> > > if (!count) > >> > > return -ENOENT; > >> > > - else > >> > > - return 0; > >> > > + return 0; > > > > There might be a case for this one. > > error returns are generally in the form > > > > { > > [...] > > > > err = func(...); > > if (err < 0) > > return err; > > > > return 0; > > } > Not sure, what's the problem in removing else as according to me > there is no use of else. > > In this case if (if condition) does not satisfy then else condition will > be satisfied and function will return 0. I think that "there might be a case for" was a positive comment. In any case, it looks nicer to me if success is outside of a conditional and failure is under a conditional. Or to be more precise, Coccinelle bug finding rules tend to work better if that property is respected. julia > > -- > You received this message because you are subscribed to the Google Groups "outreachy-kernel" group. > To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe at googlegroups.com. > To post to this group, send email to outreachy-kernel at googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/CALrZqyP-BRPj4jEFgU%3DB_AV7E4-tJfgaXwwxRhUprLg_4gWQkg%40mail.gmail.com. > For more options, visit https://groups.google.com/d/optout. > From julia.lawall at lip6.fr Tue Feb 28 19:18:17 2017 From: julia.lawall at lip6.fr (Julia Lawall) Date: Tue, 28 Feb 2017 20:18:17 +0100 (CET) Subject: [lustre-devel] [Outreachy kernel] Re: [PATCH 5/5] staging: gdm724x: Remove unnecessary else after return In-Reply-To: References: <1488219268-3006-1-git-send-email-singhalsimran0@gmail.com> <1488219268-3006-5-git-send-email-singhalsimran0@gmail.com> <1488224468.25838.11.camel@perches.com> Message-ID: On Wed, 1 Mar 2017, SIMRAN SINGHAL wrote: > On Tue, Feb 28, 2017 at 1:49 AM, SIMRAN SINGHAL > wrote: > > On Tue, Feb 28, 2017 at 1:11 AM, Joe Perches wrote: > >> On Mon, 2017-02-27 at 23:44 +0530, simran singhal wrote: > >>> This patch fixes the checkpatch warning that else is not generally > >>> useful after a break or return. > >> > >>> This was done using Coccinelle: > >>> @@ > >>> expression e2; > >>> statement s1; > >>> @@ > >>> if(e2) { ... return ...; } > >>> -else > >>> s1 > >> [] > >>> diff --git a/drivers/staging/gdm724x/gdm_endian.c b/drivers/staging/gdm724x/gdm_endian.c > >> [] > >>> @@ -26,30 +26,26 @@ __dev16 gdm_cpu_to_dev16(struct gdm_endian *ed, u16 x) > >>> { > >>> if (ed->dev_ed == ENDIANNESS_LITTLE) > >>> return (__force __dev16)cpu_to_le16(x); > >>> - else > >>> - return (__force __dev16)cpu_to_be16(x); > >>> + return (__force __dev16)cpu_to_be16(x); > >> > >> again, not a checkpatch message for any of the > >> suggested modified hunks. > >> > I am not getting what's the problem in removing else or may be I > am wrong you just want to say that I should change the commit message. Yes, I think that the issue is just the commit message. Was it really checkpatch that motivated you to do this? Joe maintains checkpatch, and he doesn't think that it gives such a warning. julia From joe at perches.com Tue Feb 28 19:18:32 2017 From: joe at perches.com (Joe Perches) Date: Tue, 28 Feb 2017 11:18:32 -0800 Subject: [lustre-devel] [PATCH 5/5] staging: gdm724x: Remove unnecessary else after return In-Reply-To: References: <1488219268-3006-1-git-send-email-singhalsimran0@gmail.com> <1488219268-3006-5-git-send-email-singhalsimran0@gmail.com> <1488224468.25838.11.camel@perches.com> Message-ID: <1488309512.25838.32.camel@perches.com> On Wed, 2017-03-01 at 00:41 +0530, SIMRAN SINGHAL wrote: > On Tue, Feb 28, 2017 at 1:49 AM, SIMRAN SINGHAL > wrote: > > On Tue, Feb 28, 2017 at 1:11 AM, Joe Perches wrote: > > > On Mon, 2017-02-27 at 23:44 +0530, simran singhal wrote: > > > > This patch fixes the checkpatch warning that else is not generally > > > > useful after a break or return. > > > > This was done using Coccinelle: > > > > @@ > > > > expression e2; > > > > statement s1; > > > > @@ > > > > if(e2) { ... return ...; } > > > > -else > > > > s1 > > > > > > [] > > > > diff --git a/drivers/staging/gdm724x/gdm_endian.c b/drivers/staging/gdm724x/gdm_endian.c > > > > > > [] > > > > @@ -26,30 +26,26 @@ __dev16 gdm_cpu_to_dev16(struct gdm_endian *ed, u16 x) > > > > { > > > > if (ed->dev_ed == ENDIANNESS_LITTLE) > > > > return (__force __dev16)cpu_to_le16(x); > > > > - else > > > > - return (__force __dev16)cpu_to_be16(x); > > > > + return (__force __dev16)cpu_to_be16(x); > > > > > > again, not a checkpatch message for any of the > > > suggested modified hunks. > > > > > I am not getting what's the problem in removing else or may be I > am wrong you just want to say that I should change the commit message. 2 things: 1: The commit message is incorrect. 2: This form is fundamentally OK: if (foo) return bar; else return baz; So I think this patch is not good. From julia.lawall at lip6.fr Tue Feb 28 19:19:28 2017 From: julia.lawall at lip6.fr (Julia Lawall) Date: Tue, 28 Feb 2017 20:19:28 +0100 (CET) Subject: [lustre-devel] [Outreachy kernel] [PATCH 3/5] staging: rtl8712: Remove unnecessary else after return In-Reply-To: References: <1488219268-3006-1-git-send-email-singhalsimran0@gmail.com> <1488219268-3006-3-git-send-email-singhalsimran0@gmail.com> Message-ID: On Wed, 1 Mar 2017, SIMRAN SINGHAL wrote: > On Tue, Feb 28, 2017 at 2:49 AM, Julia Lawall wrote: > > > > > > On Mon, 27 Feb 2017, simran singhal wrote: > > > >> This patch fixes the checkpatch warning that else is not generally > >> useful after a break or return. > >> > >> This was done using Coccinelle: > >> @@ > >> expression e2; > >> statement s1; > >> @@ > >> if(e2) { ... return ...; } > >> -else > >> s1 > > > > One might be surprised that the following code was detected using the > > above semantic patch, because in the code below there is no return in the > > if branches. Actually, as a special feature, when one has an if branch > > that ends in return, Coccinelle will skip through any gotos and see if the > > return is matched afterward. Indeed it is a common pattern to have > > > > if (...) { > > foo(x); > > bar(y); > > return -ENOMEM; > > } > > > > But the code can also be cut up as eg > > > > if (...) { > > ret = -ENOMEM; > > goto out; > > } > > ... > > out: > > foo(x); > > bar(y); > > return ret; > > > > To avoid having to write multiple patterns for these cases, Coccinelle > > will just jump through the return in the second case, allowing the same > > pattern to match both of them. > > > Julia, Thanks for explaination. Its really helpful. > > But I think there is no problem in removing else. > Because it will execute this > > padapter->dvobjpriv.inirp_init(padapter); > > when if condition will not satisfy. It seems ok to me. julia > > > julia > > > >> > >> Signed-off-by: simran singhal > >> --- > >> drivers/staging/rtl8712/os_intfs.c | 3 +-- > >> 1 file changed, 1 insertion(+), 2 deletions(-) > >> > >> diff --git a/drivers/staging/rtl8712/os_intfs.c b/drivers/staging/rtl8712/os_intfs.c > >> index 8836b31..3062167 100644 > >> --- a/drivers/staging/rtl8712/os_intfs.c > >> +++ b/drivers/staging/rtl8712/os_intfs.c > >> @@ -411,8 +411,7 @@ static int netdev_open(struct net_device *pnetdev) > >> goto netdev_open_error; > >> if (!padapter->dvobjpriv.inirp_init) > >> goto netdev_open_error; > >> - else > >> - padapter->dvobjpriv.inirp_init(padapter); > >> + padapter->dvobjpriv.inirp_init(padapter); > >> r8712_set_ps_mode(padapter, padapter->registrypriv.power_mgnt, > >> padapter->registrypriv.smart_ps); > >> } > >> -- > >> 2.7.4 > >> > >> -- > >> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group. > >> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe at googlegroups.com. > >> To post to this group, send email to outreachy-kernel at googlegroups.com. > >> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1488219268-3006-3-git-send-email-singhalsimran0%40gmail.com. > >> For more options, visit https://groups.google.com/d/optout. > >> > From julia.lawall at lip6.fr Tue Feb 28 19:21:44 2017 From: julia.lawall at lip6.fr (Julia Lawall) Date: Tue, 28 Feb 2017 20:21:44 +0100 (CET) Subject: [lustre-devel] [Outreachy kernel] Re: [PATCH 5/5] staging: gdm724x: Remove unnecessary else after return In-Reply-To: <1488309512.25838.32.camel@perches.com> References: <1488219268-3006-1-git-send-email-singhalsimran0@gmail.com> <1488219268-3006-5-git-send-email-singhalsimran0@gmail.com> <1488224468.25838.11.camel@perches.com> <1488309512.25838.32.camel@perches.com> Message-ID: On Tue, 28 Feb 2017, Joe Perches wrote: > On Wed, 2017-03-01 at 00:41 +0530, SIMRAN SINGHAL wrote: > > On Tue, Feb 28, 2017 at 1:49 AM, SIMRAN SINGHAL > > wrote: > > > On Tue, Feb 28, 2017 at 1:11 AM, Joe Perches wrote: > > > > On Mon, 2017-02-27 at 23:44 +0530, simran singhal wrote: > > > > > This patch fixes the checkpatch warning that else is not generally > > > > > useful after a break or return. > > > > > This was done using Coccinelle: > > > > > @@ > > > > > expression e2; > > > > > statement s1; > > > > > @@ > > > > > if(e2) { ... return ...; } > > > > > -else > > > > > s1 > > > > > > > > [] > > > > > diff --git a/drivers/staging/gdm724x/gdm_endian.c b/drivers/staging/gdm724x/gdm_endian.c > > > > > > > > [] > > > > > @@ -26,30 +26,26 @@ __dev16 gdm_cpu_to_dev16(struct gdm_endian *ed, u16 x) > > > > > { > > > > > if (ed->dev_ed == ENDIANNESS_LITTLE) > > > > > return (__force __dev16)cpu_to_le16(x); > > > > > - else > > > > > - return (__force __dev16)cpu_to_be16(x); > > > > > + return (__force __dev16)cpu_to_be16(x); > > > > > > > > again, not a checkpatch message for any of the > > > > suggested modified hunks. > > > > > > > > I am not getting what's the problem in removing else or may be I > > am wrong you just want to say that I should change the commit message. > > 2 things: > > 1: The commit message is incorrect. > 2: This form is fundamentally OK: > > if (foo) > return bar; > else > return baz; > > > So I think this patch is not good. I agree in this case. The two branches are quite parallel. In some of the other patches, the if was looking for the absence of some resource or the failure of something, so there was a clear distinction between one branch being cleanup on failure and the other branch being the continuing successful computation, even if it is just to return a success indicator. julia From andreas.dilger at intel.com Tue Feb 28 21:17:54 2017 From: andreas.dilger at intel.com (Dilger, Andreas) Date: Tue, 28 Feb 2017 21:17:54 +0000 Subject: [lustre-devel] Proposal for JobID caching In-Reply-To: References: <6E2CFE03-A158-4D82-82BA-AF0A175AA358@intel.com> <9BEFFD88-0537-43AB-8352-6477F30906DA@intel.com> <9F0ECE95-3C4B-495D-97BB-9B3AA211D43A@intel.com> Message-ID: <1477BB45-0F58-4C49-89FB-D3B219EA6A68@intel.com> On Feb 28, 2017, at 09:23, Ben Evans wrote: > > > > On 2/16/17, 5:30 PM, "Dilger, Andreas" wrote: > >> On Feb 16, 2017, at 07:36, Ben Evans wrote: >>> >>> >>> >>> On 2/7/17, 6:01 PM, "Dilger, Andreas" wrote: >>> >>>> On Feb 2, 2017, at 08:20, Ben Evans wrote: >>>>> >>>>> https://review.whamcloud.com/#/c/25208/ is a working version of what I >>>>> had >>>>> proposed, including the suggested changes to default to procname_uid. >>>>> This is not perfect, but the performance is much improved over the >>>>> current >>>>> methods, and unlike inode-based caching Metadata performance isn't >>>>> negatively affected. Multiple simultaneous jobs can be run on the >>>>> same >>>>> file, and get appropriate metrics. >>>> >>>> I reviewed the patch, and one question that I had is whether you've >>>> tested >>>> if the JobID is correct when read/write RPCs are generated by >>>> readahead or >>>> ptlrpcd? That may be more relevant once the async readahead threads >>>> are >>>> implemented by Dmitry. With an inode-based JobID cache then the JobID >>>> can >>>> (usually) be correctly determined even if the RPC is not generated in >>>> the >>>> context of the user process. >>>> >>>> I don't think that is necessarily a fault in your patch, but it may be >>>> that >>>> the JobID determination hasn't kept pace with other changes in the >>>> code. >>>> It >>>> would be great if you would verify (possibly with a test attached to >>>> your >>>> patch) that JobID is assigned to all the RPCs that need it. >>> >>> I've seen some lustre thread names pop into the JobID under the >>> procname_uid scheme when doing something like a dd test. Filtering them >>> out would be relatively straightforward, and keeping the old JobID (if >>> available) in the lookup table would be the way to get the most reliable >>> info. There shouldn't be a difference with the current behavior in this >>> regard. >>> >>> My issue with putting the information in the inode stems from 2 cases, >>> the >>> first is RobinHood, which stats *everything*. In the proposed solution, >>> one lookup would be done every 30 seconds. Storing the inode, it would >>> happen for every stat, then never used again. >>> >>> The other case is less probable, but still out there, in an environment >>> with multiple jobs per node, you may be running two different jobs on >>> the >>> same input set, which would corrupt the counting. >> >> If there are two jobs using the same input files, I suspect the second one >> would get the data from the client cache, and not log anything on the >> server >> at all. In any case, I don't think that would be any different than the >> two >> jobs are randomly interleaving their access to the same files on the >> server. >> >> Conversely, having "ptlrpcd/0" appear in the jobstats doesn't really help >> anyone figure out which user/job is causing IO traffic on the server. If >> RPCs generated by ptlrpcd, statahead, and other service threads that do >> work >> on behalf of user processes (including readahead in the near future) have >> the >> proper JobID then that would be much more useful. >> >> Some suggestions on how to handle this, off the top of my head: >> - blacklist service thread PIDs at startup in the JobID hash and have them >> get the JobID by some other method (e.g. inode, DLM lock/resource, >> other) >> - store the JobID explicitly with the IO request when it is being put into >> a cache/queue and use this when submitting the RPC if present, >> otherwise get >> it from the hash >> >> The latter may be preferable, since it doesn't need to do anything for >> sync >> RPCs generated in process context, and avoids an extra lookup when >> processing >> the RPC. You might consider the first method for debugging when/where >> such >> RPCs are generated, and have the backlisted threads dump a stack once if >> they >> are being looked up in the JobID hash. >> >> Cheers, Andreas > > I'm thinking a combination of approaches: Use the hash as the primary > source, but populate the inode with the data as well and use it when one > of the "reserved" names pops up as the jobID. > > For any file access, the open would trigger a JobID lookup, which would > put the correct info into the hash, and then into the inode. As the JobID > is updated the inode's store would also be updated. > > For a lookup, if the table returns ptlrpc, or any other of the Lustre > threads, then the inode cache would be used. > > This way, we're doing as few userspace lookups as possible, fixing the > readahead hole that currently exists, and not having an issue with > processes like find or robinhood which touch a lot of files. Yes, this sounds the same as what I was thinking. It should be possible to "blacklist" the client threads (ptlrpcd, statahead, ll_ping, wherever we use kthread_run() on the client). Cheers, Andreas -- Andreas Dilger Lustre Principal Architect Intel Corporation