socket: disallow CBC cipher modes

This is related to CVE-2014-3566 a.k.a. POODLE.

	http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2014-3566

POODLE is specific to CBC cipher modes in SSLv3.  Because there is no
way to prevent SSLv3 fallback on a system with an unpatched version of
OpenSSL, users of such systems can only be protected by disallowing CBC
modes.  The default cipher-mode specification in our code has been
changed accordingly.  Users can still set their own cipher modes if they
wish.  To support them, the ssl-authz.t test script provides an example
of how to combine the CBC exclusion with other criteria in a script.

Change-Id: Ib1fa547082fbb7de9df94ffd182b1800d6e354e5
BUG: 1155328
Signed-off-by: Jeff Darcy <jdarcy@redhat.com>
Reviewed-on: http://review.gluster.org/8962
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
geo-rep/glusterd: Enable changelog and marker during geo-rep create.

PROBLEM:
Geo-rep misses few a files to sync when I/O happenned during
geo-rep start.

ANALYSES:
To use the available changelogs to handle deletes/renames,
'xsync upper limit' is introduced which limits the xsync
crawl till the changelog register time.  But there is a
small time interval between the changelog register time and
the time changelog actually enabled. If there is I/O between
this interval, it will not be synced through xsync as it is
beyond changelog register time and not through changelog also
as changelog is not actually enabled.

SOLUTION:
Enable changelog and marker during geo-rep create instead
of geo-rep start so that entries are captured in changelog
and above said interval is nullified.

Change-Id: Ic5f0457a4b67a335cbbb37d34db5f8cb8bc901c4
BUG: 1139196
Signed-off-by: Kotresh HR <khiremat@redhat.com>
Reviewed-on: http://review.gluster.org/8650
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Aravinda VK <avishwan@redhat.com>
Reviewed-by: Avra Sengupta <asengupt@redhat.com>
Reviewed-by: Venky Shankar <vshankar@redhat.com>
Tested-by: Venky Shankar <vshankar@redhat.com>
ec: Fix rebalance issues

Some issues in ec xlator made that rebalance didn't complete
successfully and generated some warnings and errors in the
log. The most critical error was a race condition that caused
false corruption detection when two specific operations were
executed sequentially and they shared the same lock.

This explains the problem:

1. A setxattr is issued.
2. setxattr: ec locks the inode before updating the xattr.
3. setxattr: The xattr is updated.
4. setxattr: Upper xlator is notified that the operation completed.
5. setxattr: A background task is initiated to update the version
             of the file.
6. A stat is issued on the same file.
7. stat: Since the lock is already acquired, it's reused.
8. stat: A lookup is issued to determine version and size
         information of the file.

At this point, operations 5 and 8 can interfere. This can make that
lookup sees different information on each brick, determining that
some bricks are corrupted and incorrectly excluding them from the
operation and initiating a self-heal. In some cases this false
detection combined with self-heal could lead to invalid updates of
the trusted.ec.size xattr, leaving the file smaller than it should
be.

This only happens if the first operation does not perform a lookup,
because chained operations reuse the information returned by the
previous one, avoiding this kind of problems.

To solve this, now the background update is executed atomically with
the posterior unlock. This avoids some reuses of the lock while
updating. However this reduces performance because the window in
which new requests can reuse the lock is much smaller now. This has
been alleviated by using the same technique implemented in AFR (i.e.
waiting some time before releasing the lock).

Some minor changes also introduced in this patch:

* Bug in management of 'trusted.glusterfs.pathinfo' that was writing
  beyond the allocated space.
* Uninitialized variable.
* trusted.ec.config was not created for regular files created with
  mknod.
* An invalid state was used in access fop.

Change-Id: Idfaf69578ed04dbac97a62710326729715b9b395
BUG: 1152902
Signed-off-by: Xavier Hernandez <xhernandez@datalab.es>
Reviewed-on: http://review.gluster.org/8947
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
glusterd: really get the inode size for a brick

The device to get the inode size from does not get passed to the tool
(tune2fs, xfs_info or the like) that is called. This is probably just an
oversight. While correcting this, cleanup some bits of the function too.

Change-Id: Ida45852cba061631fb304bc7dd5286df1a808010
BUG: 1130462
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Reviewed-on: http://review.gluster.org/8492
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Tested-by: Krishnan Parthasarathi <kparthas@redhat.com>
doc: documentation of inode and dentry management

Change-Id: Ica510752d011596e8ecff5ea13c4b2bbf76ba186
BUG: 1145475
Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com>
Reviewed-on: http://review.gluster.org/8815
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
features/snapview-server: check if the reference to the snapshot world is
correct before doing any fop

The following operations might lead to problems:
* Create a file on the glusterfs mount point
* Create a snapshot (say "snap1")
* Access the contents of the snapshot
* Delete the file from the mount point
* Delete the snapshot "snap1"
* Create a new snapshot "snap1"

Now accessing the new snapshot "snap1" gives problems. Because the inode and
dentry created for snap1 would not be deleted upon the deletion of the snapshot
(as deletion of snapshot is a gluster cli operation, not a fop). So next time
upon creation of a new snap with same name, the previous inode and dentry itself
will be used. But the inode context contains old information about the glfs_t
instance and the handle in the gfapi world. Directly accessing them without
proper check leads to ENOTCONN errors. Thus the glfs_t instance should be
checked before accessing. If its wrong, then right instance should be obtained
by doing the lookup.

Change-Id: Idca0c8015ff632447cea206a4807d8ef968424fa
BUG: 1151004
Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com>
Reviewed-on: http://review.gluster.org/8917
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
ec: Correctly handle xtime extended attribute

Change-Id: I2bd34f063d6bf1835d5ae57a8e9aa03f3ec3deb3
BUG: 1156404
Signed-off-by: Xavier Hernandez <xhernandez@datalab.es>
Reviewed-on: http://review.gluster.org/8972
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Dan Lambright <dlambrig@redhat.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
glusterfs.spec.in: use upstream logrotate exclusively

retiring Fedora dist-git *.logrotate files

Change-Id: I6a94aac6f45573216de3f9e673d10db6de5ccb98
BUG: 1126832
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
Reviewed-on: http://review.gluster.org/8418
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
changelog: replace MAKE_HTIME_FILE_PATH with snprintf()

The used once MAKE_HTIME_FILE_PATH macro uses strcpy and strcat into a
fixed buffer without checking the input lengths.

Recommend replacing with a snprintf.

Change-Id: Ia0245096774dc84be1b937e1d5750f3634fff034
BUG: 1099645
Reported-by: Keith Schincke <kschinck@redhat.com>
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Reviewed-on: http://review.gluster.org/8977
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Venky Shankar <vshankar@redhat.com>
Tested-by: Venky Shankar <vshankar@redhat.com>
Posix: Brick failure detection fix for ext4 filesystem

Issue: stat() on XFS has a check for the filesystem status but
ext4 does not.

Fix: Replacing stat() call with open, write and read  to a new file under the
"brick/.glusterfs" directory. This change will work for xfs, ext4 and other
fileystems.

Change-Id: Id03c4bc07df4ee22916a293442bd74819b051839
BUG: 1130242
Signed-off-by: Lalatendu Mohanty <lmohanty@redhat.com>
Reviewed-on: http://review.gluster.org/8213
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
geo-rep: gid is not set in entry ops

uid is sent in place of gid while CREATE and
MKDIR.

Change-Id: Icd1072cb9dcbfc1f419a3cdd456f3d02168175fa
BUG: 1104954
Signed-off-by: Aravinda VK <avishwan@redhat.com>
Reviewed-on: http://review.gluster.org/7984
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Kotresh HR <khiremat@redhat.com>
Reviewed-by: Venky Shankar <vshankar@redhat.com>
Tested-by: Venky Shankar <vshankar@redhat.com>
Regression test portability: quota-anon-fd-nfs.t

Fix portability problems in quota-anon-fd-nfs.t
- Use mount_nfs wrapper and include nfs.rc to get it defined.
- umount NFS before cleanup to avvoid deadlocks.
- umount -l is Linux-specific, use umount -f on BSD.
- wait for 1s for portmap registration before mouting NFS.
- mount from $H0 instead of localhost: the later fails on NetBSD.
- Test quota without filling GB of data, 20MB is enough and it
  will be gentle with smaller setups.
- wait for write behind to complete before testing quota overflow

BUG: 1129939
Change-Id: I097d5faed2fa7b6438aaa56def85172f23bbe7dc
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
Reviewed-on: http://review.gluster.org/8969
Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Tested-by: Kiran Patil <kiran@fractalio.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
glusterd: op state machine shouldn't use global peer list

Problem : op state machine was relying on the global peer list while sending
lock/stage/unlock commit rpc requests to the peers in the cluster. Trusting on
global peer list structure is dangerous as this structure gets modified if any
peer modification command is attempted in the cluster when there is a ongoing
transaction going through the state machine. An ideal usecase of this problem
when rebalance is in progress and peer probe is executed rebalance op-sm and
peer probe may run into race making peerinfo structure go for toss.

Solution: Use local copy of peer list (xaction_peers) in glusterd op-sm.

Change-Id: I1ff7118dc6a9a72633e2e87b7ab7bae1796595e0
BUG: 1152890
Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
Reviewed-on: http://review.gluster.org/8932
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Reviewed-by: Kaushal M <kaushal@redhat.com>
inode: include dentry cycle checks for all existing inodes

inode_link() has the responsibility of maintaining the DAGness of
the dentry tree, and prevent cyclic loops from forming. To do this
the technique used is to perform cyclic check only while linking
inodes which already were linked in the inode table (i.e linking
a new_inode() can never form a loop).

While this was how it was supposed to be all along, the @old_inode
variable was missed out to get updated if the given inode to inode_link
itself was already linked (i.e, the code was only handling a complex
case when the given new inode had a gfid which already existed)

Without this patch, it is possible to call inode_link in a specific
way which results in dentry loops.

Change-Id: I4c87fa2d63f11e31c73d8b847e56962f6c983880
BUG: 1158226
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.org/8995
Reviewed-by: Harshavardhana <harsha@harshavardhana.net>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Tested-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
feature/changelog: Fix changelog missing SETATTR entries.

Problem: Valid SETATTR entries are missing in changelog when more
         than one metadata operation happen on same inode within
         changelog roll-over time.

Cause: Metadata entries with fop num being GF_FOP_NULL are logged
       in changelog which is of no use. Since slice version
       checking is done for metadata entries to avoid logging of
       subsequent entries of same inode falling into same
       changelog, if the entry with GF_FOP_NULL is logged first,
       subsequent valid ones will be missed.

Solution: Have a boundary condition to log only those fops whose fop
          number falls between GF_FOP_NULL and GF_FOP_MAXVALUE.

Change-Id: Iff585ea573ac5e521a361541c6646225943f0b2d
BUG: 1104954
Signed-off-by: Kotresh HR <khiremat@redhat.com>
Reviewed-on: http://review.gluster.org/8964
Reviewed-by: Aravinda VK <avishwan@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Venky Shankar <vshankar@redhat.com>
Tested-by: Venky Shankar <vshankar@redhat.com>
Avoid spurious EINVAL in posix_readdir()

On non Linux systems, we check that seekdir() succeeds and we return
EINVAL if it does not. We need this to avoid infinite loops if some
other component in GlusterFS makes an invalid seekdir() usage. This
was introduced in this change: http://review.gluster.org/#/c/8760/

But seekdir() also fails when using the offset returned for the
last entry, and this is expected behavior. As a result, the seekdir()
test produces a spurious EINVAL when reaching end of directory. That
error is not propagated to calling process, but it may harm internal
GlusterFS processing. At least it produce a spurious error message
in brick's log.

We fix the problem by remembering the last entry offset in fd private
data. When a new posix_readdir() invocation requests that offset,
we avoid returning EINVAL.

BUG: 1129939
Change-Id: I4e67a2ea46538aae63eea663dd4aa33b16ad24c7
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
Reviewed-on: http://review.gluster.org/8926
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
CLI: Show warning message only for remove-brick commit

Earlier warning message for checking the removed-bricks for
any unmigrated files was thrown both for remove-brick commit
and force.

With this change the warning message will be shown only for
remove-brick commit.

Change-Id: Ib1fa47d831d5189088c77c5cf709a25ff36d7379
BUG: 1157974
Signed-off-by: Susant Palai <spalai@redhat.com>
Reviewed-on: http://review.gluster.org/8983
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
Reviewed-by: Kaushal M <kaushal@redhat.com>
logrotate: gluster logrotate config should not be global

Issue : Previously glusterfs logrotate config file pollutes
global config. So moved the directives inside the curly braces,
 so they don't pollute the global config state.

Change-Id: I8836893dfcdf457d9c5d766612d687bfce64e2ae
BUG: 1126802
Signed-off-by: Lalatendu Mohanty <lmohanty@redhat.com>
Reviewed-on: http://review.gluster.org/8994
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Regression test portability: self-heald.t

Fix portability problems in updated self-heald.t:
- Use the k suffit in dd(1) bs argument instead of less portable M and K
- Error message for disconnected bricks in NetBSD is "Socket is not connected"
- On touch d/a while bricks are down, NetBSD updates d ctime/mtime even
  on bricks where a is not present, resulting in a different to-be-healed
  count than on Linux. We now tes both values. If NetBSD behavior is a bug,
  it is not in the heal process and should be tested somewhere else.

This also requires fixes in heal process: http://review.gluster.org/8936

BUG: 1129939
Change-Id: Ibda1902a8fd64aa7cc5202744adca825e6b251c9
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
Reviewed-on: http://review.gluster.org/8968
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Fixed missing / in replace-brick pause example

BUG: 1155421
Change-Id: I079f738e8381bada4595d3600921a39581edaea7
Signed-off-by: Joe Julian <me@joejulian.name>
Reviewed-on: http://review.gluster.org/8963
Reviewed-by: Humble Devassy Chirammal <humble.devassy@gmail.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>